def build_contract_signer(cls, contract, imis_policy): if imis_policy.officer is not None: reference = cls.build_fhir_resource_reference( imis_policy.officer, "Practitioner") signer = ContractSigner() signer.party = reference eo_type = cls.build_simple_codeable_concept( R4CoverageConfig.get_signer_eo_type_code()) signer.type = eo_type if contract.signer is None: contract.signer = signer else: contract.signer.append(signer) if imis_policy.family is not None: if imis_policy.family.head_insuree is not None: reference = cls.build_fhir_resource_reference( imis_policy.family.head_insuree, "Patient") signer = ContractSigner() signer.party = reference eo_type = cls.build_simple_codeable_concept( R4CoverageConfig.get_signer_head_type_code()) signer.type = eo_type if contract.signer is None: contract.signer = signer else: contract.signer.append(signer)
def __map_status(cls, code): codes = { 1: R4CoverageConfig.get_status_idle_code(), 2: R4CoverageConfig.get_status_active_code(), 4: R4CoverageConfig.get_status_suspended_code(), 8: R4CoverageConfig.get_status_expired_code(), } return codes[code]
def build_contract_state(cls, contract, imis_policy): if imis_policy.stage is imis_policy.STAGE_NEW: contract.legalState = cls.build_simple_codeable_concept( R4CoverageConfig.get_status_offered_code()) elif imis_policy.stage is imis_policy.STAGE_RENEWED: contract.legalState = cls.build_simple_codeable_concept( R4CoverageConfig.get_status_renewed_code()) else: contract.legalState = cls.build_simple_codeable_concept( imis_policy.stage) return contract
def build_contract_status(cls, contract, imis_policy): if imis_policy.status is imis_policy.STATUS_ACTIVE: contract.status = R4CoverageConfig.get_status_policy_code() elif imis_policy.status is imis_policy.STATUS_IDLE: contract.status = R4CoverageConfig.get_status_offered_code() elif imis_policy.status is imis_policy.STATUS_EXPIRED: contract.status = R4CoverageConfig.get_status_terminated_code() elif imis_policy.status is imis_policy.STATUS_SUSPENDED: contract.status = R4CoverageConfig.get_status_disputed_code() else: contract.status = imis_policy.status return contract
def __build_product_plan_display(cls, class_, product): product_coverage = {} service_code = R4CoverageConfig.get_service_code() item_code = R4CoverageConfig.get_item_code() product_items = ProductItem.objects.filter(product=product).all() product_services = ProductService.objects.filter(product=product).all() product_coverage[item_code] = [ item.item.code for item in product_items ] product_coverage[service_code] = [ service.service.code for service in product_services ] class_.type = product.name class_.name = str(product_coverage)
def build_coverage_policy_holder(cls, fhir_coverage, imis_policy): reference = Reference() resource_type = R4CoverageConfig.get_family_reference_code() resource_id = imis_policy.family.uuid reference.reference = resource_type + '/' + str(resource_id) fhir_coverage.policyHolder = reference return fhir_coverage
def build_coverage_class(cls, fhir_coverage, imis_coverage): class_ = CoverageClass() product = imis_coverage.product class_.type = R4CoverageConfig.get_product_code() + "/" + str( product.uuid) class_.name = product.code cls.__build_product_plan_display(class_, product) fhir_coverage.classes = [class_]
def build_contract_party(cls, contract, imis_coverage): if imis_coverage.officer is not None: party = ContractTermOfferParty() reference = PractitionerConverter.build_fhir_resource_reference( imis_coverage.officer) party.reference = reference provider_role = cls.build_simple_codeable_concept( R4CoverageConfig.get_practitioner_role_code()) party.role = [provider_role] contract.term[0].offer[0].party[0] = [party]
def build_contract_asset_context(cls, contract_term_asset, imis_policy): insureePolicies = imis_policy.insuree_policies.all() for insureePolicy in insureePolicies: if insureePolicy.insuree.head is True: party_role = cls.build_simple_codeable_concept( R4CoverageConfig.get_offer_insuree_role_code()) else: party_role = cls.build_simple_codeable_concept( R4CoverageConfig.get_offer_dependant_role_code()) assetContext = ContractTermAssetContext() assetContext.code = [party_role] display = insureePolicy.insuree.uuid + ":" + imis_policy.family.location.code # used for the DHIS integration assetContext.reference = cls.build_fhir_resource_reference( insureePolicy.insuree, "Patient", display) if contract_term_asset.context is None: contract_term_asset.context = [assetContext] else: contract_term_asset.context.append(assetContext) return contract_term_asset
def build_contract_party(cls, contract, imis_coverage): if imis_coverage.officer is not None: party = ContractTermOfferParty() reference = PractitionerConverter.build_fhir_resource_reference( imis_coverage.officer) party.reference.append(reference) if contract.term is None: contract.term.append[ContractTerm()] elif len(contract.term) == 0: contract.term.append(ContractTerm()) if contract.term[0].offer is None: contract.term[0].offer = ContractTermOffer() provider_role = cls.build_simple_codeable_concept( R4CoverageConfig.get_practitioner_role_code()) party.role = provider_role contract.term[0].offer.party.append(party)
def __build_enroll_date(cls, fhir_coverage, imis_coverage): enroll_date = cls.__build_date_extension( imis_coverage.enroll_date, R4CoverageConfig.get_enroll_date_code()) fhir_coverage.extension.append(enroll_date)