def build_contract_valued_item(cls, contract_asset, imis_policy): valued_item = ContractTermAssetValuedItem() policy_value = Money() policy_value.value = imis_policy.value valued_item.net = policy_value contract_asset.valuedItem.append(valued_item) return contract_asset
def build_fhir_item(cls, fhir_claim, code, item_type, item): fhir_item = FHIRClaimItem() fhir_item.sequence = FhirUtils.get_next_array_sequential_id( fhir_claim.item) unit_price = Money() unit_price.value = item.price_asked if hasattr(core, 'currency'): unit_price.currency = core.currency fhir_item.unitPrice = unit_price fhir_quantity = Quantity() fhir_quantity.value = item.qty_provided fhir_item.quantity = fhir_quantity fhir_item.productOrService = cls.build_simple_codeable_concept(code) fhir_item.category = cls.build_simple_codeable_concept(item_type) item_explanation_code = R4ClaimConfig.get_fhir_claim_item_explanation_code( ) information = cls.build_fhir_string_information( fhir_claim.supportingInfo, item_explanation_code, item.explanation) if information: fhir_item.informationSequence = [information.sequence] extension = Extension() if fhir_item.category.text == "item": medication = cls.build_medication_extension(extension) fhir_item.extension.append(medication) elif fhir_item.category.text == "service": activity_definition = cls.build_activity_definition_extension( extension) fhir_item.extension.append(activity_definition) fhir_claim.item.append(fhir_item)
def build_response_service(self, fhir_claim_response): service = ClaimResponseItem() service.itemSequence = 2 service_general_adjudication = ClaimResponseItemAdjudication() service_general_adjudication.category = ClaimResponseConverter.build_simple_codeable_concept( R4ClaimConfig.get_fhir_claim_item_general_adjudication_code()) item_limitation = Money() item_limitation.value = self._TEST_SERVICE_LIMITATION_VALUE service_general_adjudication.amount = item_limitation service_general_adjudication.reason = ClaimResponseConverter \ .build_codeable_concept(self._TEST_SERVICE_STATUS, R4ClaimConfig.get_fhir_claim_item_status_rejected_code()) service_general_adjudication.value = self._TEST_SERVICE_QUANTITY_APPROVED service.adjudication.append(service_general_adjudication) item_rejection_adjudication = ClaimResponseItemAdjudication() item_rejection_adjudication.category = ClaimResponseConverter.build_simple_codeable_concept( R4ClaimConfig. get_fhir_claim_item_rejected_reason_adjudication_code()) item_rejection_adjudication.reason = ClaimResponseConverter.build_codeable_concept( self._TEST_SERVICE_REJECTED_REASON) service.adjudication.append(item_rejection_adjudication) service.noteNumber = [2] fhir_claim_response.item.append(service) item_note = ClaimResponseProcessNote() item_note.number = 2 item_note.text = self._TEST_SERVICE_JUSTIFICATION fhir_claim_response.processNote.append(item_note)
def build_response_item(self, fhir_claim_response): item = ClaimResponseItem() item.itemSequence = 1 item_general_adjudication = ClaimResponseItemAdjudication() item_general_adjudication.category = ClaimResponseConverter.build_simple_codeable_concept( R4ClaimConfig.get_fhir_claim_item_general_adjudication_code()) item_limitation = Money() item_limitation.value = self._TEST_ITEM_LIMITATION_VALUE item_general_adjudication.amount = item_limitation item_general_adjudication.reason = ClaimResponseConverter \ .build_codeable_concept(self._TEST_ITEM_STATUS, R4ClaimConfig.get_fhir_claim_item_status_passed_code()) item_general_adjudication.value = self._TEST_ITEM_QUANTITY_APPROVED item.adjudication.append(item_general_adjudication) item_rejection_adjudication = ClaimResponseItemAdjudication() item_rejection_adjudication.category = ClaimResponseConverter.build_simple_codeable_concept( R4ClaimConfig. get_fhir_claim_item_rejected_reason_adjudication_code()) item_rejection_adjudication.reason = ClaimResponseConverter.build_codeable_concept( self._TEST_ITEM_REJECTED_REASON) item.adjudication.append(item_rejection_adjudication) item.noteNumber = [1] fhir_claim_response.item.append(item) item_note = ClaimResponseProcessNote() item_note.number = 1 item_note.text = self._TEST_ITEM_JUSTIFICATION fhir_claim_response.processNote.append(item_note)
def build_contract_valued_item(self, contract, imis_coverage): valued_item = ContractTermAssetValuedItem() policy_value = Money() policy_value.value = imis_coverage.value valued_item.net = policy_value contract.term[0].asset[0].valuedItem[0] = [valued_item] return contract
def build_fhir_total(cls, fhir_claim, imis_claim): total_claimed = imis_claim.claimed if not total_claimed: total_claimed = 0 fhir_total = Money() fhir_total.value = total_claimed if hasattr(core, 'currency'): fhir_total.currency = core.currency fhir_claim.total = fhir_total
def build_contract_valued_item(self, contract, imis_coverage): valued_item = ContractTermAssetValuedItem() policy_value = Money() policy_value.value = imis_coverage.value valued_item.net = policy_value if contract.term is None: contract.term = [ContractTerm()] elif len(contract.term) == 0: contract.term.append(ContractTerm()) if contract.term[0].asset is None: contract.term[0].asset = [ContractTermAsset()] elif len(contract.term[0].asset) == 0: contract.term[0].asset.append(ContractTermAsset()) contract.term[0].asset[0].valuedItem.append(valued_item) return contract
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
def build_unit_price_extension(cls, value): extension = Extension() money = Money() extension.url = "unitPrice" extension.valueMoney = money extension.valueMoney.value = value if hasattr(core, 'currency'): extension.valueMoney.currency = core.currency return extension
def build_fhir_money_item_benefit(cls, item, allowed_value, used_value): benefit = cls.build_fhir_generic_item_benefit() allowed_money_value = Money() allowed_money_value.value = allowed_value or 0 benefit.allowedMoney = allowed_money_value used_money_value = Money() used_money_value.value = used_value or 0 benefit.usedMoney = used_money_value item.benefit.append(benefit)
def build_fhir_total_reinsured(cls, imis_claim): fhir_total = ClaimResponseTotal() money = Money() fhir_total.amount = money if imis_claim.reinsured is not None: fhir_total.category = CodeableConcept() coding = Coding() coding.code = "R" coding.system = "http://terminology.hl7.org/CodeSystem/adjudication.html" coding.display = "Reinsured" fhir_total.category.coding.append(coding) fhir_total.category.text = "Valuated < Reinsured < Approved < Claimed" fhir_total.amount.value = imis_claim.reinsured if hasattr(core, 'currency'): fhir_total.amount.currency = core.currency return fhir_total
def build_fhir_money_item_benefit(cls, item, value): benefit = cls.build_fhir_generic_item_benefit() money_value = Money() money_value.value = value benefit.allowedMoney = money_value item.benefit.append(benefit)
def build_fhir_item_adjudication(cls, item, rejected_reason, imis_claim): item_adjudication_asked = ClaimResponseItemAdjudication() item_adjudication_adjusted = ClaimResponseItemAdjudication() item_adjudication_approved = ClaimResponseItemAdjudication() item_adjudication_valuated = ClaimResponseItemAdjudication() price_asked = Money() price_asked.value = item.price_asked price_adjusted = Money() price_adjusted.value = item.price_adjusted price_approved = Money() price_approved.value = item.price_approved price_valuated = Money() price_valuated.value = item.price_valuated if hasattr(core, 'currency'): price_asked.currency = core.currency price_adjusted.currency = core.currency price_valuated.currency = core.currency price_approved.currency = core.currency value = None if rejected_reason == 0: value = item.qty_approved else: value = item.qty_provided item_adjudication_asked.reason = cls.build_fhir_adjudication_reason( item, rejected_reason) item_adjudication_asked.amount = price_asked item_adjudication_adjusted.reason = cls.build_fhir_adjudication_reason( item, rejected_reason) if price_adjusted.value is not None and price_adjusted.value != 0.0: item_adjudication_adjusted.amount = price_adjusted item_adjudication_approved.reason = cls.build_fhir_adjudication_reason( item, rejected_reason) if price_approved.value is not None and price_approved.value != 0.0: item_adjudication_approved.amount = price_approved item_adjudication_valuated.reason = cls.build_fhir_adjudication_reason( item, rejected_reason) if price_valuated.value is not None and price_valuated.value != 0.0: item_adjudication_valuated.amount = price_valuated if imis_claim.status == 1: item_adjudication_asked.category = \ cls.build_codeable_concept(1, text="rejected") item_adjudication_asked.value = item.qty_provided return [item_adjudication_asked] if imis_claim.status == 2: item_adjudication_asked.category = \ cls.build_codeable_concept(2, text="entered") item_adjudication_asked.value = item.qty_provided return [item_adjudication_asked] if imis_claim.status == 4: item_adjudication_asked.category = \ cls.build_codeable_concept(2, text="entered") item_adjudication_adjusted.category = \ cls.build_codeable_concept(4, text="checked") item_adjudication_asked.value = item.qty_provided if item.qty_approved is not None and item.qty_approved != 0.0: value = item.qty_approved else: value = item.qty_provided item_adjudication_adjusted.value = value return [item_adjudication_asked, item_adjudication_adjusted] if imis_claim.status == 8: item_adjudication_asked.category = \ cls.build_codeable_concept(2, text="entered") item_adjudication_adjusted.category = \ cls.build_codeable_concept(4, text="checked") item_adjudication_approved.category = \ cls.build_codeable_concept(8, text="processed") item_adjudication_asked.value = item.qty_provided if item.qty_approved is not None and item.qty_approved != 0.0: value = item.qty_approved else: value = item.qty_provided item_adjudication_adjusted.value = value item_adjudication_approved.value = value return [ item_adjudication_asked, item_adjudication_adjusted, item_adjudication_approved ] if imis_claim.status == 16: item_adjudication_asked.category = \ cls.build_codeable_concept(2, text="entered") item_adjudication_adjusted.category = \ cls.build_codeable_concept(4, text="checked") item_adjudication_approved.category = \ cls.build_codeable_concept(8, text="processed") item_adjudication_valuated.category = \ cls.build_codeable_concept(16, text="valuated") item_adjudication_asked.value = item.qty_provided if item.qty_approved is not None and item.qty_approved != 0.0: value = item.qty_approved else: value = item.qty_provided item_adjudication_adjusted.value = value item_adjudication_approved.value = value item_adjudication_valuated.value = value return [ item_adjudication_asked, item_adjudication_adjusted, item_adjudication_approved, item_adjudication_valuated ] if rejected_reason != 0: item_adjudication_asked.reason = cls.build_fhir_adjudication_reason( item, rejected_reason) item_adjudication_asked.amount = price_asked item_adjudication_asked.category = \ cls.build_codeable_concept(1, text="rejected") item_adjudication_asked.value = item.qty_provided return [item_adjudication_asked]