Search in sources :

Example 1 with ProcessPriority

use of org.hl7.fhir.r4.model.codesystems.ProcessPriority in project synthea by synthetichealth.

the class FhirR4 method encounterClaim.

/**
 * Create an entry for the given Claim, associated to an Encounter.
 *
 * @param person         The patient having the encounter.
 * @param personEntry    Entry for the person
 * @param bundle         The Bundle to add to
 * @param encounterEntry The current Encounter
 * @param claim          the Claim object
 * @return the added Entry
 */
private static BundleEntryComponent encounterClaim(Person person, BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, Claim claim) {
    org.hl7.fhir.r4.model.Claim claimResource = new org.hl7.fhir.r4.model.Claim();
    org.hl7.fhir.r4.model.Encounter encounterResource = (org.hl7.fhir.r4.model.Encounter) encounterEntry.getResource();
    claimResource.setStatus(ClaimStatus.ACTIVE);
    CodeableConcept type = new CodeableConcept();
    type.getCodingFirstRep().setSystem("http://terminology.hl7.org/CodeSystem/claim-type").setCode("institutional");
    claimResource.setType(type);
    claimResource.setUse(org.hl7.fhir.r4.model.Claim.Use.CLAIM);
    InsuranceComponent insuranceComponent = new InsuranceComponent();
    insuranceComponent.setSequence(1);
    insuranceComponent.setFocal(true);
    insuranceComponent.setCoverage(new Reference().setDisplay(claim.payer.getName()));
    claimResource.addInsurance(insuranceComponent);
    // duration of encounter
    claimResource.setBillablePeriod(encounterResource.getPeriod());
    claimResource.setCreated(encounterResource.getPeriod().getEnd());
    claimResource.setPatient(new Reference().setReference(personEntry.getFullUrl()).setDisplay((String) person.attributes.get(Person.NAME)));
    claimResource.setProvider(encounterResource.getServiceProvider());
    if (USE_US_CORE_IG) {
        claimResource.setFacility(encounterResource.getLocationFirstRep().getLocation());
    }
    // set the required priority
    CodeableConcept priority = new CodeableConcept();
    priority.getCodingFirstRep().setSystem("http://terminology.hl7.org/CodeSystem/processpriority").setCode("normal");
    claimResource.setPriority(priority);
    // add item for encounter
    claimResource.addItem(new ItemComponent(new PositiveIntType(1), encounterResource.getTypeFirstRep()).addEncounter(new Reference(encounterEntry.getFullUrl())));
    int itemSequence = 2;
    int conditionSequence = 1;
    int procedureSequence = 1;
    int informationSequence = 1;
    for (Claim.ClaimEntry claimEntry : claim.items) {
        HealthRecord.Entry item = claimEntry.entry;
        if (Costs.hasCost(item)) {
            // update claimItems list
            Code primaryCode = item.codes.get(0);
            String system = ExportHelper.getSystemURI(primaryCode.system);
            ItemComponent claimItem = new ItemComponent(new PositiveIntType(itemSequence), mapCodeToCodeableConcept(primaryCode, system));
            // calculate the cost of the procedure
            Money moneyResource = new Money();
            moneyResource.setCurrency("USD");
            moneyResource.setValue(item.getCost());
            claimItem.setNet(moneyResource);
            claimResource.addItem(claimItem);
            if (item instanceof Procedure) {
                Type procedureReference = new Reference(item.fullUrl);
                ProcedureComponent claimProcedure = new ProcedureComponent(new PositiveIntType(procedureSequence), procedureReference);
                claimResource.addProcedure(claimProcedure);
                claimItem.addProcedureSequence(procedureSequence);
                procedureSequence++;
            } else {
                Reference informationReference = new Reference(item.fullUrl);
                SupportingInformationComponent informationComponent = new SupportingInformationComponent();
                informationComponent.setSequence(informationSequence);
                informationComponent.setValue(informationReference);
                CodeableConcept category = new CodeableConcept();
                category.getCodingFirstRep().setSystem("http://terminology.hl7.org/CodeSystem/claiminformationcategory").setCode("info");
                informationComponent.setCategory(category);
                claimResource.addSupportingInfo(informationComponent);
                claimItem.addInformationSequence(informationSequence);
                informationSequence++;
            }
        } else {
            // assume it's a Condition, we don't have a Condition class specifically
            // add diagnosisComponent to claim
            Reference diagnosisReference = new Reference(item.fullUrl);
            DiagnosisComponent diagnosisComponent = new DiagnosisComponent(new PositiveIntType(conditionSequence), diagnosisReference);
            claimResource.addDiagnosis(diagnosisComponent);
            // update claimItems with diagnosis
            ItemComponent diagnosisItem = new ItemComponent(new PositiveIntType(itemSequence), mapCodeToCodeableConcept(item.codes.get(0), SNOMED_URI));
            diagnosisItem.addDiagnosisSequence(conditionSequence);
            claimResource.addItem(diagnosisItem);
            conditionSequence++;
        }
        itemSequence++;
    }
    Money moneyResource = new Money();
    moneyResource.setCurrency("USD");
    moneyResource.setValue(claim.getTotalClaimCost());
    claimResource.setTotal(moneyResource);
    return newEntry(person, bundle, claimResource);
}
Also used : DiagnosisComponent(org.hl7.fhir.r4.model.Claim.DiagnosisComponent) ProcedureComponent(org.hl7.fhir.r4.model.Claim.ProcedureComponent) PositiveIntType(org.hl7.fhir.r4.model.PositiveIntType) Money(org.hl7.fhir.r4.model.Money) SupportingInformationComponent(org.hl7.fhir.r4.model.Claim.SupportingInformationComponent) SupplyDeliverySuppliedItemComponent(org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent) ItemComponent(org.hl7.fhir.r4.model.Claim.ItemComponent) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Procedure(org.mitre.synthea.world.concepts.HealthRecord.Procedure) Reference(org.hl7.fhir.r4.model.Reference) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) InsuranceComponent(org.hl7.fhir.r4.model.Claim.InsuranceComponent) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) IntegerType(org.hl7.fhir.r4.model.IntegerType) BooleanType(org.hl7.fhir.r4.model.BooleanType) BundleType(org.hl7.fhir.r4.model.Bundle.BundleType) EncounterType(org.mitre.synthea.world.concepts.HealthRecord.EncounterType) DeviceNameType(org.hl7.fhir.r4.model.Device.DeviceNameType) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) AllergyIntoleranceType(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceType) LocationPhysicalType(org.hl7.fhir.r4.model.codesystems.LocationPhysicalType) DecimalType(org.hl7.fhir.r4.model.DecimalType) CodeType(org.hl7.fhir.r4.model.CodeType) NodeType(org.hl7.fhir.utilities.xhtml.NodeType) StringType(org.hl7.fhir.r4.model.StringType) DateType(org.hl7.fhir.r4.model.DateType) PositiveIntType(org.hl7.fhir.r4.model.PositiveIntType) Type(org.hl7.fhir.r4.model.Type) DoseRateType(org.hl7.fhir.r4.model.codesystems.DoseRateType) Claim(org.mitre.synthea.world.concepts.Claim) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 2 with ProcessPriority

use of org.hl7.fhir.r4.model.codesystems.ProcessPriority in project synthea by synthetichealth.

the class FhirR4 method medicationClaim.

/**
 * Create an entry for the given Claim, which references a Medication.
 *
 * @param person         The person being prescribed medication
 * @param personEntry     Entry for the person
 * @param bundle          The Bundle to add to
 * @param encounterEntry  The current Encounter
 * @param claim           the Claim object
 * @param medicationEntry The Entry for the Medication object, previously created
 * @return the added Entry
 */
private static BundleEntryComponent medicationClaim(Person person, BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, Claim claim, BundleEntryComponent medicationEntry) {
    org.hl7.fhir.r4.model.Claim claimResource = new org.hl7.fhir.r4.model.Claim();
    org.hl7.fhir.r4.model.Encounter encounterResource = (org.hl7.fhir.r4.model.Encounter) encounterEntry.getResource();
    claimResource.setStatus(ClaimStatus.ACTIVE);
    CodeableConcept type = new CodeableConcept();
    type.getCodingFirstRep().setSystem("http://terminology.hl7.org/CodeSystem/claim-type").setCode("pharmacy");
    claimResource.setType(type);
    claimResource.setUse(org.hl7.fhir.r4.model.Claim.Use.CLAIM);
    // Get the insurance info at the time that the encounter occurred.
    InsuranceComponent insuranceComponent = new InsuranceComponent();
    insuranceComponent.setSequence(1);
    insuranceComponent.setFocal(true);
    insuranceComponent.setCoverage(new Reference().setDisplay(claim.payer.getName()));
    claimResource.addInsurance(insuranceComponent);
    // duration of encounter
    claimResource.setBillablePeriod(encounterResource.getPeriod());
    claimResource.setCreated(encounterResource.getPeriod().getEnd());
    claimResource.setPatient(new Reference(personEntry.getFullUrl()));
    claimResource.setProvider(encounterResource.getServiceProvider());
    // set the required priority
    CodeableConcept priority = new CodeableConcept();
    priority.getCodingFirstRep().setSystem("http://terminology.hl7.org/CodeSystem/processpriority").setCode("normal");
    claimResource.setPriority(priority);
    // add item for encounter
    claimResource.addItem(new ItemComponent(new PositiveIntType(1), encounterResource.getTypeFirstRep()).addEncounter(new Reference(encounterEntry.getFullUrl())));
    // add prescription.
    claimResource.setPrescription(new Reference(medicationEntry.getFullUrl()));
    Money moneyResource = new Money();
    moneyResource.setValue(claim.getTotalClaimCost());
    moneyResource.setCurrency("USD");
    claimResource.setTotal(moneyResource);
    return newEntry(person, bundle, claimResource);
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) InsuranceComponent(org.hl7.fhir.r4.model.Claim.InsuranceComponent) PositiveIntType(org.hl7.fhir.r4.model.PositiveIntType) Money(org.hl7.fhir.r4.model.Money) SupplyDeliverySuppliedItemComponent(org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent) ItemComponent(org.hl7.fhir.r4.model.Claim.ItemComponent) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Claim(org.mitre.synthea.world.concepts.Claim) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Aggregations

InsuranceComponent (org.hl7.fhir.r4.model.Claim.InsuranceComponent)2 ItemComponent (org.hl7.fhir.r4.model.Claim.ItemComponent)2 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)2 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)2 Money (org.hl7.fhir.r4.model.Money)2 PositiveIntType (org.hl7.fhir.r4.model.PositiveIntType)2 Reference (org.hl7.fhir.r4.model.Reference)2 SupplyDeliverySuppliedItemComponent (org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent)2 Claim (org.mitre.synthea.world.concepts.Claim)2 Encounter (org.mitre.synthea.world.concepts.HealthRecord.Encounter)2 AllergyIntoleranceType (org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceType)1 BooleanType (org.hl7.fhir.r4.model.BooleanType)1 BundleType (org.hl7.fhir.r4.model.Bundle.BundleType)1 DiagnosisComponent (org.hl7.fhir.r4.model.Claim.DiagnosisComponent)1 ProcedureComponent (org.hl7.fhir.r4.model.Claim.ProcedureComponent)1 SupportingInformationComponent (org.hl7.fhir.r4.model.Claim.SupportingInformationComponent)1 CodeType (org.hl7.fhir.r4.model.CodeType)1 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)1 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)1 DateType (org.hl7.fhir.r4.model.DateType)1