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, Stu3IdentifierConfig.get_fhir_identifier_type_system(), Stu3IdentifierConfig.get_fhir_uuid_type_code()) claim_code = ClaimResponseConverter.build_fhir_identifier( self._TEST_CODE, Stu3IdentifierConfig.get_fhir_identifier_type_system(), Stu3IdentifierConfig.get_fhir_claim_code_type()) fhir_claim_response.identifier = [pk_id, claim_code] display = Stu3ClaimConfig.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
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_communication_request = CommunicationRequest() fhir_communication_request.id = self._TEST_FEEDBACK_ID fhir_communication_request.occurrenceDateTime = self._TEST_FEEDBACK_DATE identifiers = [] identifier = Converter.build_fhir_identifier( self._TEST_FEEDBACK_ID, Stu3IdentifierConfig.get_fhir_identifier_type_system(), Stu3IdentifierConfig.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): 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 == Stu3IdentifierConfig.get_fhir_uuid_type_code(): self.assertEqual(str(self._TEST_UUID), identifier.value) elif identifier.type.coding[0].code == Stu3IdentifierConfig.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_APPROVED, fhir_obj.totalBenefit.value) 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)
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, Stu3IdentifierConfig.get_fhir_uuid_type_code()) return result
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 == Stu3IdentifierConfig.get_fhir_uuid_type_code(): self.assertEqual(fhir_obj.id, identifier.value) elif identifier.type.coding[ 0].code == Stu3IdentifierConfig.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 information in fhir_obj.information: if information.category.text == Stu3ClaimConfig.get_fhir_claim_information_explanation_code( ): self.assertEqual(self._TEST_EXPLANATION, information.valueString) elif information.category.text == Stu3ClaimConfig.get_fhir_claim_information_guarantee_id_code( ): self.assertEqual(self._TEST_GUARANTEE_ID, information.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 == Stu3ClaimConfig.get_fhir_claim_item_code( ): self.assertEqual(self._TEST_ITEM_CODE, item.service.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.information[item.informationLinkId[0] - 1].valueString) elif item.category.text == Stu3ClaimConfig.get_fhir_claim_service_code( ): self.assertEqual(self._TEST_SERVICE_CODE, item.service.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.information[item.informationLinkId[0] - 1].valueString)
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 == Stu3IdentifierConfig.get_fhir_uuid_type_code(): self.assertEqual(fhir_obj.id, identifier.value) elif code == Stu3IdentifierConfig.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(Stu3LocationConfig.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 = PractitionerConverter.get_first_coding_from_codeable_concept( identifier.type).code if code == Stu3IdentifierConfig.get_fhir_claim_admin_code_type(): self.assertEqual(self._TEST_CODE, identifier.value) elif code == Stu3IdentifierConfig.get_fhir_uuid_type_code(): self.assertEqual(self._TEST_UUID, identifier.value) self.assertEqual(self._TEST_DOB, fhir_obj.birthDate) 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)
def build_fhir_uuid_identifier(cls, identifiers, imis_object): if imis_object.uuid is not None: identifier = cls.build_fhir_identifier(imis_object.uuid, Stu3IdentifierConfig.get_fhir_identifier_type_system(), Stu3IdentifierConfig.get_fhir_uuid_type_code()) identifiers.append(identifier)