def verify_updated_obj(self, updated_obj):
     self.assertTrue(isinstance(updated_obj, PractitionerRole))
     self.assertEqual(
         self._TEST_UPDATED_LOCATION_CODE,
         LocationConverter.get_resource_id_from_reference(
             updated_obj.location[0]))
     self.assertEqual(
         self._TEST_UPDATED_LOCATION_NAME,
         LocationConverter.get_imis_obj_by_fhir_reference(
             updated_obj.location[0]).name)
 def update_resource(self, data):
     new_location = self._create_and_save_hf()
     new_location.name = self._TEST_UPDATED_LOCATION_NAME
     new_location.code = self._TEST_UPDATED_LOCATION_CODE
     new_location.save()
     data['location'][0] = LocationConverter.build_fhir_resource_reference(
         new_location).toDict()
Exemple #3
0
 def build_imis_health_facility(cls, errors, fhir_claim, imis_claim):
     if fhir_claim.facility:
         health_facility = LocationConverter.get_imis_obj_by_fhir_reference(
             fhir_claim.facility)
         if health_facility:
             imis_claim.health_facility = health_facility
             imis_claim.health_facility_code = health_facility.code
     cls.valid_condition(imis_claim.health_facility is None,
                         gettext('Missing the facility reference'), errors)
    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
 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 == R4IdentifierConfig.get_fhir_uuid_type_code():
             self.assertEqual(fhir_obj.id, identifier.value)
         elif code == R4IdentifierConfig.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(R4LocationConfig.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)
Exemple #6
0
 def create_test_fhir_instance(self):
     fhir_claim = FHIRClaim()
     fhir_claim.id = self._TEST_UUID
     fhir_claim.patient = PatientConverter.build_fhir_resource_reference(
         self._TEST_INSUREE)
     claim_code = ClaimConverter.build_fhir_identifier(
         self._TEST_CODE,
         R4IdentifierConfig.get_fhir_identifier_type_system(),
         R4IdentifierConfig.get_fhir_claim_code_type())
     fhir_claim.identifier = [claim_code]
     billable_period = Period()
     billable_period.start = self._TEST_DATE_FROM
     billable_period.end = self._TEST_DATE_TO
     fhir_claim.billablePeriod = billable_period
     diagnoses = []
     ClaimConverter.build_fhir_diagnosis(diagnoses,
                                         self._TEST_DIAGNOSIS_CODE.code,
                                         ImisClaimIcdTypes.ICD_0.value)
     fhir_claim.diagnosis = diagnoses
     total = Money()
     total.value = self._TEST_CLAIMED
     fhir_claim.total = total
     fhir_claim.created = self._TEST_DATE_CLAIMED
     fhir_claim.facility = LocationConverter.build_fhir_resource_reference(
         self._TEST_HF)
     supportingInfo = []
     guarantee_id_code = R4ClaimConfig.get_fhir_claim_information_guarantee_id_code(
     )
     ClaimConverter.build_fhir_string_information(supportingInfo,
                                                  guarantee_id_code,
                                                  self._TEST_GUARANTEE_ID)
     explanation_code = R4ClaimConfig.get_fhir_claim_information_explanation_code(
     )
     ClaimConverter.build_fhir_string_information(supportingInfo,
                                                  explanation_code,
                                                  self._TEST_EXPLANATION)
     fhir_claim.supportingInfo = supportingInfo
     fhir_claim.enterer = PractitionerConverter.build_fhir_resource_reference(
         self._TEST_CLAIM_ADMIN)
     fhir_claim.type = ClaimConverter.build_simple_codeable_concept(
         self._TEST_VISIT_TYPE)
     type = R4ClaimConfig.get_fhir_claim_item_code()
     ClaimConverter.build_fhir_item(fhir_claim, self._TEST_ITEM_CODE, type,
                                    self._TEST_ITEM)
     type = R4ClaimConfig.get_fhir_claim_service_code()
     ClaimConverter.build_fhir_item(fhir_claim, self._TEST_SERVICE_CODE,
                                    type, self._TEST_SERVICE)
     return fhir_claim
Exemple #7
0
class LocationSerializer(BaseFHIRSerializer):
    fhirConverter = LocationConverter()

    def create(self, validated_data):
        copied_data = copy.deepcopy(validated_data)
        del copied_data['_state']
        return Location.objects.create(**copied_data)

    def update(self, instance, validated_data):
        # TODO legalForm isn't covered because that value is missing in the model
        # TODO LocationId isn't covered because that value is missing in the model
        # TODO offline isn't covered in the current version of API
        # TODO care_type isn't covered in the current version of API
        instance.code = validated_data.get('code', instance.code)
        instance.name = validated_data.get('name', instance.name)
        instance.type = validated_data.get('type', instance.type)
        instance.partOf = validated_data.get('partOf', instance.partOf)
        instance.audit_user_id = self.get_audit_user_id()
        instance.save()
        return instance