コード例 #1
0
 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)
コード例 #2
0
 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)
コード例 #3
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)
コード例 #4
0
 def build_imis_supportingInfo(cls, imis_claim, fhir_claim):
     if fhir_claim.supportingInfo:
         for supportingInfo in fhir_claim.supportingInfo:
             category = supportingInfo.category
             if category and category.text == R4ClaimConfig.get_fhir_claim_information_guarantee_id_code(
             ):
                 imis_claim.guarantee_id = supportingInfo.valueString
             elif category and category.text == R4ClaimConfig.get_fhir_claim_information_explanation_code(
             ):
                 imis_claim.explanation = supportingInfo.valueString
コード例 #5
0
 def build_fhir_supportingInfo(cls, fhir_claim, imis_claim):
     guarantee_id_code = R4ClaimConfig.get_fhir_claim_information_guarantee_id_code(
     )
     cls.build_fhir_string_information(fhir_claim.supportingInfo,
                                       guarantee_id_code,
                                       imis_claim.guarantee_id)
     explanation_code = R4ClaimConfig.get_fhir_claim_information_explanation_code(
     )
     cls.build_fhir_string_information(fhir_claim.supportingInfo,
                                       explanation_code,
                                       imis_claim.explanation)
コード例 #6
0
 def get_status_display_by_code(cls, code):
     display = None
     if code == 1:
         display = R4ClaimConfig.get_fhir_claim_status_rejected_code()
     elif code == 2:
         display = R4ClaimConfig.get_fhir_claim_status_entered_code()
     elif code == 4:
         display = R4ClaimConfig.get_fhir_claim_status_checked_code()
     elif code == 8:
         display = R4ClaimConfig.get_fhir_claim_status_processed_code()
     elif code == 16:
         display = R4ClaimConfig.get_fhir_claim_status_valuated_code()
     return display
コード例 #7
0
 def build_imis_submit_items_and_services(cls, imis_claim, fhir_claim):
     imis_items = []
     imis_services = []
     if fhir_claim.item:
         for item in fhir_claim.item:
             if item.category:
                 if item.category.text == R4ClaimConfig.get_fhir_claim_item_code(
                 ):
                     cls.build_imis_submit_item(imis_items, item)
                 elif item.category.text == R4ClaimConfig.get_fhir_claim_service_code(
                 ):
                     cls.build_imis_submit_service(imis_services, item)
     # added additional attributes which will be used to create ClaimRequest in serializer
     imis_claim.submit_items = imis_items
     imis_claim.submit_services = imis_services
コード例 #8
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
コード例 #9
0
    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)
コード例 #10
0
    def build_fhir_items(cls, fhir_claim_response, imis_claim):
        for claim_item in cls.generate_fhir_claim_items(imis_claim):
            type = claim_item.category.text
            code = claim_item.productOrService.text

            if type == R4ClaimConfig.get_fhir_claim_item_code():
                serviced = cls.get_imis_claim_item_by_code(code, imis_claim.id)
            elif type == R4ClaimConfig.get_fhir_claim_service_code():
                serviced = cls.get_service_claim_item_by_code(
                    code, imis_claim.id)
            else:
                raise FHIRRequestProcessException([
                    'Could not assign category {} for claim_item: {}'.format(
                        type, claim_item)
                ])

            cls._build_response_items(fhir_claim_response, claim_item,
                                      serviced, type,
                                      serviced.rejection_reason, imis_claim)
コード例 #11
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
コード例 #12
0
 def build_items_for_imis_services(cls, fhir_claim, imis_claim):
     for service in imis_claim.services.all():
         if service:
             type = R4ClaimConfig.get_fhir_claim_service_code()
             cls.build_fhir_item(fhir_claim, service.service.code, type,
                                 service)
コード例 #13
0
 def build_items_for_imis_item(cls, fhir_claim, imis_claim):
     for item in imis_claim.items.all():
         if item:
             type = R4ClaimConfig.get_fhir_claim_item_code()
             cls.build_fhir_item(fhir_claim, item.item.code, type, item)