def create_test_fhir_instance(self):
        location = Location()
        identifier = LocationConverter.build_fhir_identifier(
            self._TEST_HF_CODE,
            R4IdentifierConfig.get_fhir_identifier_type_system(),
            R4IdentifierConfig.get_fhir_facility_id_type())
        location.identifier = [identifier]
        location.name = self._TEST_HF_NAME
        location.type = LocationConverter.build_codeable_concept(
            R4LocationConfig.get_fhir_code_for_hospital(),
            R4LocationConfig.get_fhir_location_site_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
Exemplo n.º 2
0
 def build_fhir_type(cls, fhir_location, imis_hf):
     code = ""
     text = ""
     if imis_hf.level == ImisHfLevel.HEALTH_CENTER.value:
         code = R4LocationConfig.get_fhir_code_for_health_center()
         text = "health-center"
     elif imis_hf.level == ImisHfLevel.DISPENSARY.value:
         code = R4LocationConfig.get_fhir_code_for_dispensary()
         text = "dispensary"
     elif imis_hf.level == ImisHfLevel.HOSPITAL.value:
         code = R4LocationConfig.get_fhir_code_for_hospital()
         text = "hospital"
     fhir_location.type = \
         [cls.build_codeable_concept(code, R4LocationConfig.get_fhir_location_site_type_system(), text=text)]
    def build_fhir_healthcare_service_category(cls, fhir_hcs, imis_hf):
        code = ""
        text = ""
        if imis_hf.level == ImisHfLevel.HEALTH_CENTER.value:
            code = R4LocationConfig.get_fhir_code_for_health_center()
            text = "Hospital center"
        elif imis_hf.level == ImisHfLevel.HOSPITAL.value:
            code = R4LocationConfig.get_fhir_code_for_hospital()
            text = "Hospital"
        elif imis_hf.level == ImisHfLevel.DISPENSARY.value:
            code = R4LocationConfig.get_fhir_code_for_dispensary()
            text = "Dispensary"

        fhir_hcs.category = \
            [cls.build_codeable_concept(code, R4LocationConfig.get_fhir_location_site_type_system(), text=text)]
    def build_imis_hf_level(cls, imis_hf, fhir_hcs, errors):
        location_type = fhir_hcs.category
        if not cls.valid_condition(location_type is None,
                                   gettext('Missing patient `type` attribute'),
                                   errors):
            for maritalCoding in location_type.coding:
                if maritalCoding.system == R4LocationConfig.get_fhir_location_site_type_system(
                ):
                    code = maritalCoding.code
                    if code == R4LocationConfig.get_fhir_code_for_health_center(
                    ):
                        imis_hf.level = ImisHfLevel.HEALTH_CENTER.value
                    elif code == R4LocationConfig.get_fhir_code_for_hospital():
                        imis_hf.level = ImisHfLevel.HOSPITAL.value
                    elif code == R4LocationConfig.get_fhir_code_for_dispensary(
                    ):
                        imis_hf.level = ImisHfLevel.DISPENSARY.value

            cls.valid_condition(imis_hf.level is None,
                                gettext('Missing hf level'), errors)