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_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_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]