def to_fhir_obj(cls, imis_claim): fhir_claim_response = ClaimResponse() fhir_claim_response.created = TimeUtils.date().isoformat() fhir_claim_response.request = ClaimConverter.build_fhir_resource_reference( imis_claim) cls.build_fhir_pk(fhir_claim_response, imis_claim.uuid) ClaimConverter.build_fhir_identifiers(fhir_claim_response, imis_claim) cls.build_fhir_outcome(fhir_claim_response, imis_claim) cls.build_fhir_payment(fhir_claim_response, imis_claim) cls.build_fhir_total_benefit(fhir_claim_response, imis_claim) cls.build_fhir_errors(fhir_claim_response, imis_claim) cls.build_fhir_communication_request_reference(fhir_claim_response, imis_claim) cls.build_fhir_items(fhir_claim_response, imis_claim) return fhir_claim_response
def test_to_fhir_obj(self, cs_mock, ci_mock): cs_mock.filter.return_value = [self._TEST_SERVICE] ci_mock.filter.return_value = [self._TEST_ITEM] imis_claim = self.create_test_imis_instance() fhir_claim = ClaimConverter.to_fhir_obj(imis_claim) self.verify_fhir_instance(fhir_claim)
class ClaimSerializer(BaseFHIRSerializer): fhirConverter = ClaimConverter() def create(self, validated_data): claim_submit = ClaimSubmit(date=validated_data.get('date_claimed'), code=validated_data.get('code'), icd_code=validated_data.get('icd_code'), icd_code_1=validated_data.get('icd1_code'), icd_code_2=validated_data.get('icd2_code'), icd_code_3=validated_data.get('icd3_code'), icd_code_4=validated_data.get('icd4_code'), total=validated_data.get('claimed'), start_date=validated_data.get('date_from'), end_date=validated_data.get('date_to'), insuree_chf_id=validated_data.get('insuree_chf_code'), health_facility_code=validated_data.get('health_facility_code'), claim_admin_code=validated_data.get('claim_admin_code'), visit_type=validated_data.get('visit_type'), guarantee_no=validated_data.get('guarantee_id'), item_submits=validated_data.get('submit_items'), service_submits=validated_data.get('submit_services'), comment=validated_data.get('explanation') ) request = self.context.get("request") ClaimSubmitService(request.user).submit(claim_submit) return self.create_claim_response(validated_data.get('code')) def create_claim_response(self, claim_code): claim = get_object_or_404(Claim, code=claim_code) return ClaimResponseConverter.to_fhir_obj(claim)
def test_to_imis_obj(self, mock_insuree, mock_cdc, mock_pc, mock_hfc): self.setUp() mock_insuree.return_value = self._TEST_INSUREE mock_cdc.get.return_value = self._TEST_DIAGNOSIS_CODE mock_pc.return_value = self._TEST_CLAIM_ADMIN mock_hfc.return_value = self._TEST_HF fhir_claim = self.create_test_fhir_instance() imis_claim = ClaimConverter.to_imis_obj(fhir_claim, None) self.verify_imis_instance(imis_claim)
def generate_fhir_claim_items(cls, imis_claim): claim = Claim() ClaimConverter.build_fhir_items(claim, imis_claim) return claim.item
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