示例#1
0
    def create_test_fhir_instance(self):
        location = Location()
        identifier = LocationConverter.build_fhir_identifier(
            self._TEST_HF_CODE,
            Stu3IdentifierConfig.get_fhir_identifier_type_system(),
            Stu3IdentifierConfig.get_fhir_facility_id_type())
        location.identifier = [identifier]
        location.name = self._TEST_HF_NAME
        location.type = LocationConverter.build_codeable_concept(
            Stu3LocationConfig.get_fhir_code_for_hospital(),
            Stu3LocationConfig.get_fhir_location_role_type_system())
        location.address = LocationConverter.build_fhir_address(
            self._TEST_ADDRESS, AddressUse.HOME.value,
            AddressType.PHYSICAL.value)
        telecom = []
        phone = LocationConverter.build_fhir_contact_point(
            self._TEST_PHONE, ContactPointSystem.PHONE.value,
            ContactPointUse.HOME.value)
        telecom.append(phone)
        fax = LocationConverter.build_fhir_contact_point(
            self._TEST_FAX, ContactPointSystem.FAX.value,
            ContactPointUse.HOME.value)
        telecom.append(fax)
        email = LocationConverter.build_fhir_contact_point(
            self._TEST_EMAIL, ContactPointSystem.EMAIL.value,
            ContactPointUse.HOME.value)
        telecom.append(email)
        location.telecom = telecom

        return location
    def build_fhir_location_type(cls, fhir_location, imis_hf):
        code = ""
        if imis_hf.level == ImisHfLevel.HEALTH_CENTER.value:
            code = Stu3LocationConfig.get_fhir_code_for_health_center()
        elif imis_hf.level == ImisHfLevel.HOSPITAL.value:
            code = Stu3LocationConfig.get_fhir_code_for_hospital()
        elif imis_hf.level == ImisHfLevel.DISPENSARY.value:
            code = Stu3LocationConfig.get_fhir_code_for_dispensary()

        fhir_location.type = \
            cls.build_codeable_concept(code, Stu3LocationConfig.get_fhir_location_role_type_system())
    def build_imis_hf_level(cls, imis_hf, fhir_location, errors):
        location_type = fhir_location.type
        if not cls.valid_condition(location_type is None,
                                   gettext('Missing patient `type` attribute'),
                                   errors):
            for maritialCoding in location_type.coding:
                if maritialCoding.system == Stu3LocationConfig.get_fhir_location_role_type_system(
                ):
                    code = maritialCoding.code
                    if code == Stu3LocationConfig.get_fhir_code_for_health_center(
                    ):
                        imis_hf.level = ImisHfLevel.HEALTH_CENTER.value
                    elif code == Stu3LocationConfig.get_fhir_code_for_hospital(
                    ):
                        imis_hf.level = ImisHfLevel.HOSPITAL.value
                    elif code == Stu3LocationConfig.get_fhir_code_for_dispensary(
                    ):
                        imis_hf.level = ImisHfLevel.DISPENSARY.value

            cls.valid_condition(imis_hf.level is None,
                                gettext('Missing hf level'), errors)
 def verify_fhir_instance(self, fhir_obj):
     for identifier in fhir_obj.identifier:
         code = LocationConverter.get_first_coding_from_codeable_concept(identifier.type).code
         if code == Stu3IdentifierConfig.get_fhir_uuid_type_code():
             self.assertEqual(fhir_obj.id, identifier.value)
         elif code == Stu3IdentifierConfig.get_fhir_facility_id_type():
             self.assertEqual(self._TEST_HF_CODE, identifier.value)
     self.assertEqual(self._TEST_HF_NAME, fhir_obj.name)
     type_code = LocationConverter.get_first_coding_from_codeable_concept(fhir_obj.type).code
     self.assertEqual(Stu3LocationConfig.get_fhir_code_for_hospital(), type_code)
     self.assertEqual(self._TEST_ADDRESS, fhir_obj.address.text)
     self.assertEqual(3, len(fhir_obj.telecom))
     for telecom in fhir_obj.telecom:
         if telecom.system == ContactPointSystem.PHONE.value:
             self.assertEqual(self._TEST_PHONE, telecom.value)
         elif telecom.system == ContactPointSystem.EMAIL.value:
             self.assertEqual(self._TEST_EMAIL, telecom.value)
         elif telecom.system == ContactPointSystem.FAX.value:
             self.assertEqual(self._TEST_FAX, telecom.value)