def create_test_fhir_instance(self): fhir_claim_response = ClaimResponse() fhir_claim_response.id = self._TEST_CODE pk_id = ClaimResponseConverter.build_fhir_identifier( self._TEST_ID, Stu3IdentifierConfig.get_fhir_identifier_type_system(), Stu3IdentifierConfig.get_fhir_id_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] feedback = Feedback() feedback.id = self._TEST_FEEDBACK_ID 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(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 build_imis_identifier(cls, imis_claim, fhir_claim, errors): value = cls.get_fhir_identifier_by_code( fhir_claim.identifier, Stu3IdentifierConfig.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)
def build_fhir_identifiers(cls, fhir_claim, imis_claim): identifiers = [] cls.build_fhir_id_identifier(identifiers, imis_claim) claim_code = cls.build_fhir_identifier( imis_claim.code, Stu3IdentifierConfig.get_fhir_identifier_type_system(), Stu3IdentifierConfig.get_fhir_claim_code_type()) identifiers.append(claim_code) fhir_claim.identifier = identifiers
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 create_test_fhir_instance(self): fhir_claim = FHIRClaim() fhir_claim.id = self._TEST_CODE fhir_claim.patient = PatientConverter.build_fhir_resource_reference( self._TEST_INSUREE) claim_code = ClaimConverter.build_fhir_identifier( self._TEST_CODE, Stu3IdentifierConfig.get_fhir_identifier_type_system(), Stu3IdentifierConfig.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) information = [] guarantee_id_code = Stu3ClaimConfig.get_fhir_claim_information_guarantee_id_code( ) ClaimConverter.build_fhir_string_information(information, guarantee_id_code, self._TEST_GUARANTEE_ID) explanation_code = Stu3ClaimConfig.get_fhir_claim_information_explanation_code( ) ClaimConverter.build_fhir_string_information(information, explanation_code, self._TEST_EXPLANATION) fhir_claim.information = information 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 = Stu3ClaimConfig.get_fhir_claim_item_code() ClaimConverter.build_fhir_item(fhir_claim, self._TEST_ITEM_CODE, type, self._TEST_ITEM) type = Stu3ClaimConfig.get_fhir_claim_service_code() ClaimConverter.build_fhir_item(fhir_claim, self._TEST_SERVICE_CODE, type, self._TEST_SERVICE) return fhir_claim