Esempio n. 1
0
 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 == Stu3IdentifierConfig.get_fhir_chfid_type_code():
             self.assertEqual(self._TEST_CHF_ID, identifier.value)
         elif code == Stu3IdentifierConfig.get_fhir_uuid_type_code() and not isinstance(identifier.value, UUID):
             self.assertEqual(self._TEST_UUID, identifier.value)
         elif code == Stu3IdentifierConfig.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(Stu3MaritalConfig.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)
 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,
         Stu3IdentifierConfig.get_fhir_identifier_type_system(),
         Stu3IdentifierConfig.get_fhir_chfid_type_code())
     identifiers.append(chf_id)
     passport = PatientConverter.build_fhir_identifier(
         self._TEST_PASSPORT,
         Stu3IdentifierConfig.get_fhir_identifier_type_system(),
         Stu3IdentifierConfig.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(
         Stu3MaritalConfig.get_fhir_divorced_code(),
         Stu3MaritalConfig.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 build_fhir_marital_status(cls, fhir_patient, imis_insuree):
     if imis_insuree.marital is not None:
         if imis_insuree.marital == ImisMaritalStatus.MARRIED.value:
             fhir_patient.maritalStatus = \
                 cls.build_codeable_concept(Stu3MaritalConfig.get_fhir_married_code(),
                                            Stu3MaritalConfig.get_fhir_marital_status_system())
         elif imis_insuree.marital == ImisMaritalStatus.SINGLE.value:
             fhir_patient.maritalStatus = \
                 cls.build_codeable_concept(Stu3MaritalConfig.get_fhir_never_married_code(),
                                            Stu3MaritalConfig.get_fhir_marital_status_system())
         elif imis_insuree.marital == ImisMaritalStatus.DIVORCED.value:
             fhir_patient.maritalStatus = \
                 cls.build_codeable_concept(Stu3MaritalConfig.get_fhir_divorced_code(),
                                            Stu3MaritalConfig.get_fhir_marital_status_system())
         elif imis_insuree.marital == ImisMaritalStatus.WIDOWED.value:
             fhir_patient.maritalStatus = \
                 cls.build_codeable_concept(Stu3MaritalConfig.get_fhir_widowed_code(),
                                            Stu3MaritalConfig.get_fhir_marital_status_system())
         elif imis_insuree.marital == ImisMaritalStatus.NOT_SPECIFIED.value:
             fhir_patient.maritalStatus = \
                 cls.build_codeable_concept(Stu3MaritalConfig.get_fhir_unknown_marital_status_code(),
                                            Stu3MaritalConfig.get_fhir_marital_status_system())
 def build_imis_marital(cls, imis_insuree, fhir_patient):
     marital_status = fhir_patient.maritalStatus
     if marital_status is not None:
         for maritialCoding in marital_status.coding:
             if maritialCoding.system == Stu3MaritalConfig.get_fhir_marital_status_system():
                 code = maritialCoding.code
                 if code == Stu3MaritalConfig.get_fhir_married_code():
                     imis_insuree.marital = ImisMaritalStatus.MARRIED.value
                 elif code == Stu3MaritalConfig.get_fhir_never_married_code():
                     imis_insuree.marital = ImisMaritalStatus.SINGLE.value
                 elif code == Stu3MaritalConfig.get_fhir_divorced_code():
                     imis_insuree.marital = ImisMaritalStatus.DIVORCED.value
                 elif code == Stu3MaritalConfig.get_fhir_widowed_code():
                     imis_insuree.marital = ImisMaritalStatus.WIDOWED.value
                 elif code == Stu3MaritalConfig.get_fhir_unknown_marital_status_code():
                     imis_insuree.marital = ImisMaritalStatus.NOT_SPECIFIED.value