def build_fhir_chfid_identifier(cls, identifiers, imis_insuree): if imis_insuree.chf_id is not None: identifier = cls.build_fhir_identifier( imis_insuree.chf_id, R4IdentifierConfig.get_fhir_identifier_type_system(), R4IdentifierConfig.get_fhir_chfid_type_code()) identifiers.append(identifier)
def build_imis_identifiers(cls, imis_insuree, fhir_patient): value = cls.get_fhir_identifier_by_code( fhir_patient.identifier, R4IdentifierConfig.get_fhir_chfid_type_code()) if value: imis_insuree.chf_id = value value = cls.get_fhir_identifier_by_code( fhir_patient.identifier, R4IdentifierConfig.get_fhir_passport_type_code()) if value: imis_insuree.passport = value
def create_test_fhir_instance(self): fhir_patient = Patient() name = HumanName() name.family = self._TEST_LAST_NAME name.given = [self._TEST_OTHER_NAME] name.use = NameUse.USUAL.value fhir_patient.name = [name] identifiers = [] chf_id = PatientConverter.build_fhir_identifier( self._TEST_CHF_ID, R4IdentifierConfig.get_fhir_identifier_type_system(), R4IdentifierConfig.get_fhir_chfid_type_code()) identifiers.append(chf_id) passport = PatientConverter.build_fhir_identifier( self._TEST_PASSPORT, R4IdentifierConfig.get_fhir_identifier_type_system(), R4IdentifierConfig.get_fhir_passport_type_code()) identifiers.append(passport) fhir_patient.identifier = identifiers fhir_patient.birthDate = self._TEST_DOB fhir_patient.gender = AdministrativeGender.MALE.value fhir_patient.maritalStatus = PatientConverter.build_codeable_concept( R4MaritalConfig.get_fhir_divorced_code(), R4MaritalConfig.get_fhir_marital_status_system()) telecom = [] phone = PatientConverter.build_fhir_contact_point( self._TEST_PHONE, ContactPointSystem.PHONE.value, ContactPointUse.HOME.value) telecom.append(phone) email = PatientConverter.build_fhir_contact_point( self._TEST_EMAIL, ContactPointSystem.EMAIL.value, ContactPointUse.HOME.value) telecom.append(email) fhir_patient.telecom = telecom addresses = [] current_address = PatientConverter.build_fhir_address( self._TEST_ADDRESS, AddressUse.HOME.value, AddressType.PHYSICAL.value) addresses.append(current_address) geolocation = PatientConverter.build_fhir_address( self._TEST_GEOLOCATION, AddressUse.HOME.value, AddressType.BOTH.value) addresses.append(geolocation) fhir_patient.address = addresses return fhir_patient
def verify_fhir_instance(self, fhir_obj): self.assertEqual(1, len(fhir_obj.name)) human_name = fhir_obj.name[0] self.assertTrue(isinstance(human_name, HumanName)) self.assertEqual(self._TEST_OTHER_NAME, human_name.given[0]) self.assertEqual(self._TEST_LAST_NAME, human_name.family) self.assertEqual(NameUse.USUAL.value, human_name.use) for identifier in fhir_obj.identifier: self.assertTrue(isinstance(identifier, Identifier)) code = PatientConverter.get_first_coding_from_codeable_concept( identifier.type).code if code == R4IdentifierConfig.get_fhir_chfid_type_code(): self.assertEqual(self._TEST_CHF_ID, identifier.value) elif code == R4IdentifierConfig.get_fhir_uuid_type_code( ) and not isinstance(identifier.value, UUID): self.assertEqual(self._TEST_UUID, identifier.value) elif code == R4IdentifierConfig.get_fhir_passport_type_code(): self.assertEqual(self._TEST_PASSPORT, identifier.value) self.assertEqual(self._TEST_DOB, fhir_obj.birthDate) self.assertEqual(AdministrativeGender.MALE.value, fhir_obj.gender) marital_code = PatientConverter.get_first_coding_from_codeable_concept( fhir_obj.maritalStatus).code self.assertEqual(R4MaritalConfig.get_fhir_divorced_code(), marital_code) self.assertEqual(2, len(fhir_obj.telecom)) for telecom in fhir_obj.telecom: self.assertTrue(isinstance(telecom, ContactPoint)) 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) self.assertEqual(2, len(fhir_obj.address)) for adddress in fhir_obj.address: self.assertTrue(isinstance(adddress, Address)) if adddress.type == AddressType.PHYSICAL.value: self.assertEqual(self._TEST_ADDRESS, adddress.text) elif adddress.type == AddressType.BOTH.value: self.assertEqual(self._TEST_GEOLOCATION, adddress.text)