Esempio n. 1
0
 def build_fhir_location_code_identifier(cls, identifiers, imis_hf):
     if imis_hf is not None:
         identifier = cls.build_fhir_identifier(
             imis_hf.code,
             R4IdentifierConfig.get_fhir_identifier_type_system(),
             R4IdentifierConfig.get_fhir_facility_id_type())
         identifiers.append(identifier)
    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 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_fhir_code_identifier(cls, identifiers, imis_claim_admin):
     if imis_claim_admin.code:
         identifier = cls.build_fhir_identifier(
             imis_claim_admin.code,
             R4IdentifierConfig.get_fhir_identifier_type_system(),
             R4IdentifierConfig.get_fhir_claim_admin_code_type())
         identifiers.append(identifier)
Esempio n. 5
0
 def build_fhir_identifiers(cls, fhir_claim, imis_claim):
     identifiers = []
     cls.build_fhir_uuid_identifier(identifiers, imis_claim)
     claim_code = cls.build_fhir_identifier(
         imis_claim.code,
         R4IdentifierConfig.get_fhir_identifier_type_system(),
         R4IdentifierConfig.get_fhir_claim_code_type())
     identifiers.append(claim_code)
     fhir_claim.identifier = identifiers
Esempio n. 6
0
    def verify_fhir_instance(self, fhir_obj):
        self.assertIsNotNone(fhir_obj.patient.reference)
        self.assertEqual(str(self._TEST_UUID), fhir_obj.id)
        for identifier in fhir_obj.identifier:
            if identifier.type.coding[
                    0].code == R4IdentifierConfig.get_fhir_uuid_type_code():
                self.assertEqual(fhir_obj.id, identifier.value)
            elif identifier.type.coding[
                    0].code == R4IdentifierConfig.get_fhir_claim_code_type():
                self.assertEqual(self._TEST_CODE, identifier.value)

        self.assertEqual(self._TEST_DATE_FROM, fhir_obj.billablePeriod.start)
        self.assertEqual(self._TEST_DATE_TO, fhir_obj.billablePeriod.end)
        for diagnosis in fhir_obj.diagnosis:
            type = diagnosis.type[0].text
            code = diagnosis.diagnosisCodeableConcept.coding[0].code
            if type == ImisClaimIcdTypes.ICD_0.value:
                self.assertEqual(self._TEST_MAIN_ICD_CODE, code)

        self.assertEqual(self._TEST_CLAIMED, fhir_obj.total.value)
        self.assertEqual(self._TEST_DATE_CLAIMED, fhir_obj.created)
        self.assertIsNotNone(fhir_obj.facility.reference)
        for supportingInfo in fhir_obj.supportingInfo:
            if supportingInfo.category.text == R4ClaimConfig.get_fhir_claim_information_explanation_code(
            ):
                self.assertEqual(self._TEST_EXPLANATION,
                                 supportingInfo.valueString)
            elif supportingInfo.category.text == R4ClaimConfig.get_fhir_claim_information_guarantee_id_code(
            ):
                self.assertEqual(self._TEST_GUARANTEE_ID,
                                 supportingInfo.valueString)
        self.assertIsNotNone(fhir_obj.enterer.reference)
        self.assertEqual(self._TEST_VISIT_TYPE, fhir_obj.type.text)
        for item in fhir_obj.item:
            if item.category.text == R4ClaimConfig.get_fhir_claim_item_code():
                self.assertEqual(self._TEST_ITEM_CODE,
                                 item.productOrService.text)
                self.assertEqual(self._TEST_ITEM_QUANTITY_PROVIDED,
                                 item.quantity.value)
                self.assertEqual(self._TEST_ITEM_PRICE_ASKED,
                                 item.unitPrice.value)
                self.assertEqual(
                    self._TEST_ITEM_EXPLANATION,
                    fhir_obj.supportingInfo[item.informationLinkId[0] -
                                            1].valueString)
            elif item.category.text == R4ClaimConfig.get_fhir_claim_service_code(
            ):
                self.assertEqual(self._TEST_SERVICE_CODE,
                                 item.productOrService.text)
                self.assertEqual(self._TEST_SERVICE_QUANTITY_PROVIDED,
                                 item.quantity.value)
                self.assertEqual(self._TEST_SERVICE_PRICE_ASKED,
                                 item.unitPrice.value)
                self.assertEqual(
                    self._TEST_SERVICE_EXPLANATION,
                    fhir_obj.supportingInfo[item.informationLinkId[0] -
                                            1].valueString)
 def build_fhir_passport_identifier(cls, identifiers, imis_insuree):
     if hasattr(imis_insuree,
                "typeofid") and imis_insuree.typeofid is not None:
         pass  # TODO typeofid isn't provided, this section should contain logic used to create passport field based on typeofid
     elif imis_insuree.passport is not None:
         identifier = cls.build_fhir_identifier(
             imis_insuree.passport,
             R4IdentifierConfig.get_fhir_identifier_type_system(),
             R4IdentifierConfig.get_fhir_passport_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
Esempio n. 9
0
 def build_fhir_uuid_identifier(cls, identifiers, imis_object):
     if hasattr(imis_object,'uuid') and imis_object.uuid is not None:
         identifier = cls.build_fhir_identifier(imis_object.uuid,
                                                R4IdentifierConfig.get_fhir_identifier_type_system(),
                                                R4IdentifierConfig.get_fhir_uuid_type_code())
         identifiers.append(identifier)
     elif hasattr(imis_object,'id') and imis_object.id is not None:
         identifier = cls.build_fhir_identifier(imis_object.id,
                                                R4IdentifierConfig.get_fhir_identifier_type_system(),
                                                R4IdentifierConfig.get_fhir_uuid_type_code())
         identifiers.append(identifier)
     else:
         raise FHIRRequestProcessException(['Cannot construct an identifier, the object has no uuid nor id: {}'])
Esempio n. 10
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
Esempio n. 11
0
 def verify_fhir_instance(self, fhir_obj):
     self.assertEqual(self._TEST_UUID, fhir_obj.id)
     main_id_check = False
     for identifier in fhir_obj.identifier:
         if identifier.value == fhir_obj.id:
             main_id_check = True
         if identifier.type.coding[
                 0].code == R4IdentifierConfig.get_fhir_uuid_type_code():
             self.assertEqual(str(self._TEST_UUID), identifier.value)
         elif identifier.type.coding[
                 0].code == R4IdentifierConfig.get_fhir_claim_code_type():
             self.assertEqual(self._TEST_CODE, identifier.value)
     self.assertTrue(main_id_check,
                     "One of the identifiers should match the main ID")
     self.assertEqual(self._TEST_STATUS, fhir_obj.outcome.coding[0].code)
     self.assertEqual(self._TEST_ADJUSTMENT,
                      fhir_obj.payment.adjustmentReason.text)
     self.assertEqual(self._TEST_DATE_PROCESSED, fhir_obj.payment.date)
     self.assertEqual(self._TEST_REJECTION_REASON,
                      fhir_obj.error[0].code.coding[0].code)
     self.assertEqual(
         str(self._TEST_FEEDBACK_UUID),
         CommunicationRequestConverter.get_resource_id_from_reference(
             fhir_obj.communicationRequest[0]))
     self.assertEqual(
         str(self._TEST_ITEM_STATUS),
         fhir_obj.item[0].adjudication[0].reason.coding[0].code)
     self.assertEqual(self._TEST_ITEM_QUANTITY_APPROVED,
                      fhir_obj.item[0].adjudication[0].value)
     self.assertEqual(self._TEST_ITEM_JUSTIFICATION,
                      fhir_obj.processNote[0].text)
     self.assertEqual(
         str(self._TEST_ITEM_REJECTED_REASON),
         fhir_obj.item[0].adjudication[1].reason.coding[0].code)
     self.assertEqual(self._TEST_ITEM_LIMITATION_VALUE,
                      fhir_obj.item[0].adjudication[0].amount.value)
     self.assertEqual(
         str(self._TEST_SERVICE_STATUS),
         fhir_obj.item[1].adjudication[0].reason.coding[0].code)
     self.assertEqual(self._TEST_SERVICE_QUANTITY_APPROVED,
                      fhir_obj.item[1].adjudication[0].value)
     self.assertEqual(self._TEST_SERVICE_JUSTIFICATION,
                      fhir_obj.processNote[1].text)
     self.assertEqual(
         str(self._TEST_SERVICE_REJECTED_REASON),
         fhir_obj.item[1].adjudication[1].reason.coding[0].code)
     self.assertEqual(self._TEST_SERVICE_LIMITATION_VALUE,
                      fhir_obj.item[1].adjudication[0].amount.value)
Esempio n. 12
0
 def get_id_for_created_resource(self, response):
     result = None
     fhir_obj = FHIRBaseObject.loads(response.content, 'json')
     if hasattr(fhir_obj, 'identifier'):
         result = BaseFHIRConverter.get_fhir_identifier_by_code(fhir_obj.identifier,
                                                                R4IdentifierConfig.get_fhir_uuid_type_code())
     return result
Esempio n. 13
0
 def build_imis_identifier(cls, imis_claim, fhir_claim, errors):
     value = cls.get_fhir_identifier_by_code(
         fhir_claim.identifier,
         R4IdentifierConfig.get_fhir_claim_code_type())
     if value:
         imis_claim.code = value
     cls.valid_condition(imis_claim.code is None,
                         gettext('Missing the claim code'), errors)
Esempio n. 14
0
 def build_imis_hf_identiftier(cls, imis_hf, fhir_location, errors):
     value = cls.get_fhir_identifier_by_code(
         fhir_location.identifier,
         R4IdentifierConfig.get_fhir_facility_id_type())
     if value:
         imis_hf.code = value
     cls.valid_condition(imis_hf.code is None,
                         gettext('Missing location code'), errors)
 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 build_imis_identifiers(cls, imis_claim_admin, fhir_practitioner,
                            errors):
     value = cls.get_fhir_identifier_by_code(
         fhir_practitioner.identifier,
         R4IdentifierConfig.get_fhir_claim_admin_code_type())
     if value:
         imis_claim_admin.code = value
     cls.valid_condition(imis_claim_admin.code is None,
                         gettext('Missing the claim admin code'), errors)
Esempio n. 17
0
 def get_fhir_identifier_by_code(cls, identifiers, lookup_code):
     value = None
     for identifier in identifiers or []:
         first_coding = cls.get_first_coding_from_codeable_concept(identifier.type)
         if first_coding.system == R4IdentifierConfig.get_fhir_identifier_type_system() \
             and first_coding.code == lookup_code:
             value = identifier.value
             break
     return value
 def create_test_fhir_instance(self):
     fhir_communication_request = CommunicationRequest()
     fhir_communication_request.id = self._TEST_FEEDBACK_UUID
     fhir_communication_request.occurrenceDateTime = self._TEST_FEEDBACK_DATE
     identifiers = []
     identifier = Converter.build_fhir_identifier(self._TEST_FEEDBACK_UUID,
                                                  R4IdentifierConfig.get_fhir_identifier_type_system(),
                                                  R4IdentifierConfig.get_fhir_uuid_type_code())
     identifiers.append(identifier)
     fhir_communication_request.identifier = identifiers
     reasons = [Converter.build_codeable_concept(Config.get_fhir_care_rendered_code(),
                                                 text=str(self._TEST_CARE_RENDERED)),
                Converter.build_codeable_concept(Config.get_fhir_payment_asked_code(),
                                                 text=str(self._TEST_PAYMENT_ASKED)),
                Converter.build_codeable_concept(Config.get_fhir_drug_prescribed_code(),
                                                 text=str(self._TEST_DRUG_PRESCRIBED)),
                Converter.build_codeable_concept(Config.get_fhir_drug_received_code(),
                                                 text=str(self._TEST_DRUG_RECEIVED)),
                Converter.build_codeable_concept(Config.get_fhir_asessment_code(),
                                                 text=str(self._TEST_ASESSMENT))]
     fhir_communication_request.reasonCode = reasons
     return fhir_communication_request
 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)
 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)
Esempio n. 21
0
 def create_test_fhir_instance(self):
     fhir_claim_response = ClaimResponse()
     fhir_claim_response.id = self._TEST_UUID
     pk_id = ClaimResponseConverter.build_fhir_identifier(
         self._TEST_UUID,
         R4IdentifierConfig.get_fhir_identifier_type_system(),
         R4IdentifierConfig.get_fhir_uuid_type_code())
     claim_code = ClaimResponseConverter.build_fhir_identifier(
         self._TEST_CODE,
         R4IdentifierConfig.get_fhir_identifier_type_system(),
         R4IdentifierConfig.get_fhir_claim_code_type())
     fhir_claim_response.identifier = [pk_id, claim_code]
     display = R4ClaimConfig.get_fhir_claim_status_rejected_code()
     fhir_claim_response.outcome = ClaimResponseConverter.build_codeable_concept(
         self._TEST_STATUS, system=None, text=display)
     fhir_payment = ClaimResponsePayment()
     fhir_payment.adjustmentReason = ClaimResponseConverter.build_simple_codeable_concept(
         self._TEST_ADJUSTMENT)
     fhir_payment.date = self._TEST_DATE_PROCESSED
     fhir_claim_response.payment = fhir_payment
     #total_approved = Money()
     #total_approved.value = self._TEST_APPROVED
     #fhir_claim_response.totalBenefit = total_approved
     fhir_error = ClaimResponseError()
     fhir_error.code = ClaimResponseConverter.build_codeable_concept(
         self._TEST_REJECTION_REASON)
     fhir_claim_response.error = [fhir_error]
     # This is an IMIS object that is converted to FHIR
     feedback = Feedback()
     feedback.id = self._TEST_FEEDBACK_ID
     feedback.uuid = self._TEST_FEEDBACK_UUID
     fhir_claim_response.communicationRequest = \
         [CommunicationRequestConverter.build_fhir_resource_reference(feedback)]
     self.build_response_item(fhir_claim_response)
     self.build_response_service(fhir_claim_response)
     return fhir_claim_response