Exemplo n.º 1
0
    def test_message_to_edifact(self):
        expected_edifact_message = ("UNH+00001+FHSREG:0:1:FH:FHS001'"
                                    "BGM+++507'"
                                    "NAD+FHS+XX1:954'"
                                    "DTM+137:201905070900:203'"
                                    "RFF+950:G5'"
                                    "S01+1'"
                                    "RFF+TN:17'"
                                    "NAD+GP+4826940,281:900'"
                                    "GIS+1:ZZZ'"
                                    "DTM+961:20190505:102'"
                                    "FTX+RGI+++DIED IN INFINITY WARS'"
                                    "S02+2'"
                                    "PNA+PAT+N/10/10:OPI'"
                                    "UNT+14+00001'")

        msg_bgn = MessageBeginning(party_id="XX1",
                                   date_time="201905070900",
                                   ref_number="G5")
        msg_seg_reg_details = MessageSegmentDeathRegistrationDetails(
            transaction_number=17,
            party_id="4826940,281",
            date_time="20190505",
            free_text="Died in Infinity Wars")

        msg_seg_pat_details = MessageSegmentDeathPatientDetails(
            id_number="N/10/10")

        msg = DeathRegistrationMessage(
            sequence_number="00001",
            message_beginning=msg_bgn,
            message_segment_registration_details=msg_seg_reg_details,
            message_segment_patient_details=msg_seg_pat_details).to_edifact()
        self.assertEqual(msg, expected_edifact_message)
Exemplo n.º 2
0
    def test_create_message(self):
        """
        Test the function to create an edifact message
        """
        with self.subTest("Death Registration"):
            msg_bgn = MessageBeginning(party_id="XX1",
                                       date_time="201904230900",
                                       ref_number="G5")
            msg_seg_pat_details = MessageSegmentDeathPatientDetails(
                id_number="NHSNO22222")
            msg_seg_reg_details = MessageSegmentDeathRegistrationDetails(
                transaction_number=17,
                party_id="4826940,281",
                date_time="2019-04-20 09:00:04.159338")
            expected = DeathRegistrationMessage(
                sequence_number="000001",
                message_beginning=msg_bgn,
                message_segment_registration_details=msg_seg_reg_details,
                message_segment_patient_details=msg_seg_pat_details).segments

            op_def = fixtures.create_operation_definition_for_death_registration(
            )

            message_adaptor = MessageDeathAdaptor(fhir_operation=op_def)
            message = message_adaptor.create_message().segments

            compare(message, expected)
    def test_message_to_edifact(self):
        expected_edifact_message = (
            "UNH+00001+FHSREG:0:1:FH:FHS001'"
            "BGM+++507'"
            "NAD+FHS+XX1:954'"
            "DTM+137:201904230900:203'"
            "RFF+950:G1'"
            "S01+1'"
            "RFF+TN:17'"
            "NAD+GP+4826940,281:900'"
            "HEA+ACD+A:ZZZ'"
            "HEA+ATP+1:ZZZ'"
            "DTM+956:20190423:102'"
            "LOC+950+BURY'"
            "S02+2'"
            "PNA+PAT+N/10/10:OPI+++SU:STEVENS+FO:CHARLES+TI:MR+MI:ANTHONY+FS:JOHN'"
            "DTM+329:20190420:102'"
            "PDI+1'"
            "NAD+PAT++MOORSIDE FARM:OLD LANE:ST PAULS CRAY:ORPINGTON:KENT+++++BR6 7EW'"
            "UNT+18+00001'")

        msg_bgn = MessageBeginning(party_id="XX1",
                                   date_time="201904230900",
                                   ref_number="G1")
        msg_seg_reg_details = MessageSegmentBirthRegistrationDetails(
            transaction_number=17,
            party_id="4826940,281",
            date_time="20190423",
            location="Bury")
        patient_name = Name(family_name="Stevens",
                            first_given_forename="Charles",
                            title="Mr",
                            middle_name="Anthony",
                            third_given_forename="John")
        patient_address = Address(house_name="MOORSIDE FARM",
                                  address_line_1="OLD LANE",
                                  address_line_2="ST PAULS CRAY",
                                  town="ORPINGTON",
                                  county="KENT",
                                  post_code="BR6 7EW")

        msg_seg_pat_details = MessageSegmentBirthPatientDetails(
            id_number="N/10/10",
            name=patient_name,
            date_of_birth="20190420",
            gender="1",
            address=patient_address)

        msg = BirthRegistrationMessage(
            sequence_number="00001",
            message_beginning=msg_bgn,
            message_segment_registration_details=msg_seg_reg_details,
            message_segment_patient_details=msg_seg_pat_details).to_edifact()
        self.assertEqual(msg, expected_edifact_message)
Exemplo n.º 4
0
    def test_create_message_beginning(self):
        """
        Test the function to create an edifact section representing the beginning of a message
        """
        with self.subTest("Message beginning for a death registration"):
            expected = MessageBeginning(party_id="XX1",
                                        date_time="201904230900",
                                        ref_number="G5").segments

            op_def = fixtures.create_operation_definition_for_death_registration(
            )

            message_adaptor = MessageDeathAdaptor(fhir_operation=op_def)
            msg_bgn = message_adaptor.create_message_beginning().segments

            compare(msg_bgn, expected)
    def test_interchange_to_edifact(self):
        with self.subTest(
                "When the transaction is to register a patient deduction (death)"
        ):
            expected_edifact_interchange = (
                "UNB+UNOA:2+SNDR+RECP+190507:0900+00001++FHSREG'"
                "UNH+00001+FHSREG:0:1:FH:FHS001'"
                "BGM+++507'"
                "NAD+FHS+XX1:954'"
                "DTM+137:201905070900:203'"
                "RFF+950:G5'"
                "S01+1'"
                "RFF+TN:17'"
                "NAD+GP+4826940,281:900'"
                "GIS+1:ZZZ'"
                "DTM+961:20190505:102'"
                "FTX+RGI+++DIED IN INFINITY WARS'"
                "S02+2'"
                "PNA+PAT+N/10/10:OPI'"
                "UNT+14+00001'"
                "UNZ+1+00001'")

            msg_bgn = MessageBeginning(party_id="XX1",
                                       date_time="201905070900",
                                       ref_number="G5")
            msg_seg_reg_details = MessageSegmentDeathRegistrationDetails(
                transaction_number=17,
                party_id="4826940,281",
                date_time="20190505",
                free_text="Died in Infinity Wars")

            msg_seg_pat_details = MessageSegmentDeathPatientDetails(
                id_number="N/10/10")

            msg = DeathRegistrationMessage(
                sequence_number="00001",
                message_beginning=msg_bgn,
                message_segment_registration_details=msg_seg_reg_details,
                message_segment_patient_details=msg_seg_pat_details)
            msgs = Messages([msg])

            interchange = Interchange(sender="SNDR",
                                      recipient="RECP",
                                      date_time="190507:0900",
                                      sequence_number="00001",
                                      messages=msgs).to_edifact()
            self.assertEqual(interchange, expected_edifact_interchange)
    def create_message_beginning(self) -> MessageBeginning:
        """
        Create the beginning of the message
        :return: MessageBeginning
        """
        nhais_id = finders.get_parameter_value(
            fhir_operation=self.fhir_operation,
            parameter_name=ParameterName.NHAIS_CYPHER)

        ref_number = self.get_reference_number()
        formatted_date_time = date_formatter.format_date(
            date_time=self.fhir_operation.date.as_json(),
            format_qualifier="203")

        msg_bgn = MessageBeginning(party_id=nhais_id,
                                   date_time=formatted_date_time,
                                   ref_number=ref_number)

        return msg_bgn
 def test_message_beginning_to_edifact(self):
     expected_edifact_message = """BGM+++507'NAD+FHS+XX1:954'DTM+137:201904230900:203'RFF+950:G1'"""
     msg_bgn = MessageBeginning(party_id="XX1",
                                date_time="201904230900",
                                ref_number="G1").to_edifact()
     self.assertEqual(msg_bgn, expected_edifact_message)