Search in sources :

Example 6 with PositiveIntType

use of org.hl7.fhir.r4.model.PositiveIntType in project org.hl7.fhir.core by hapifhir.

the class PositiveIntTypeNullTest method copy.

@Test
@DisplayName("Test null value copy()")
void copy() {
    PositiveIntType nullPositiveInt = new PositiveIntType();
    PositiveIntType copyPositiveInt = nullPositiveInt.copy();
    Assertions.assertNull(copyPositiveInt.getValue());
}
Also used : PositiveIntType(org.hl7.fhir.r4b.model.PositiveIntType) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 7 with PositiveIntType

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

the class FhirStu3 method encounterClaim.

/**
 * Create an entry for the given Claim, associated to an Encounter.
 *
 * @param rand Source of randomness to use when generating ids etc
 * @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(RandomNumberGenerator rand, BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, Claim claim) {
    org.hl7.fhir.dstu3.model.Claim claimResource = new org.hl7.fhir.dstu3.model.Claim();
    org.hl7.fhir.dstu3.model.Encounter encounterResource = (org.hl7.fhir.dstu3.model.Encounter) encounterEntry.getResource();
    claimResource.setStatus(ClaimStatus.ACTIVE);
    claimResource.setUse(org.hl7.fhir.dstu3.model.Claim.Use.COMPLETE);
    // duration of encounter
    claimResource.setBillablePeriod(encounterResource.getPeriod());
    claimResource.setPatient(new Reference(personEntry.getFullUrl()));
    claimResource.setOrganization(encounterResource.getServiceProvider());
    // add item for encounter
    claimResource.addItem(new ItemComponent(new PositiveIntType(1)).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
            ItemComponent claimItem = new ItemComponent(new PositiveIntType(itemSequence));
            Code primaryCode = item.codes.get(0);
            String system = ExportHelper.getSystemURI(primaryCode.system);
            CodeableConcept serviceProvided = new CodeableConcept().addCoding(new Coding().setCode(primaryCode.code).setVersion("v1").setSystem(system));
            claimItem.setService(serviceProvided);
            // calculate the cost of the procedure
            Money moneyResource = new Money();
            moneyResource.setCode("USD");
            moneyResource.setSystem("urn:iso:std:iso:4217");
            moneyResource.setValue(item.getCost());
            claimItem.setNet(moneyResource);
            if (item instanceof HealthRecord.Procedure) {
                Type procedureReference = new Reference(item.fullUrl);
                ProcedureComponent claimProcedure = new ProcedureComponent(new PositiveIntType(procedureSequence), procedureReference);
                claimResource.addProcedure(claimProcedure);
                claimItem.addProcedureLinkId(procedureSequence);
                procedureSequence++;
            } else {
                Reference informationReference = new Reference(item.fullUrl);
                SpecialConditionComponent informationComponent = new SpecialConditionComponent();
                informationComponent.setSequence(informationSequence);
                informationComponent.setValue(informationReference);
                CodeableConcept category = new CodeableConcept();
                category.getCodingFirstRep().setSystem("http://hl7.org/fhir/claiminformationcategory").setCode("info");
                informationComponent.setCategory(category);
                claimResource.addInformation(informationComponent);
                claimItem.addInformationLinkId(informationSequence);
                claimItem.setService(claimResource.getType());
                informationSequence++;
            }
            claimResource.addItem(claimItem);
        } else {
            // assume it's a Condition, we don't have a Condition class specifically
            // add diagnosisComponent to claim
            Reference diagnosisReference = new Reference(item.fullUrl);
            org.hl7.fhir.dstu3.model.Claim.DiagnosisComponent diagnosisComponent = new org.hl7.fhir.dstu3.model.Claim.DiagnosisComponent(new PositiveIntType(conditionSequence), diagnosisReference);
            claimResource.addDiagnosis(diagnosisComponent);
            // update claimItems with diagnosis
            ItemComponent diagnosisItem = new ItemComponent(new PositiveIntType(itemSequence));
            diagnosisItem.addDiagnosisLinkId(conditionSequence);
            claimResource.addItem(diagnosisItem);
            conditionSequence++;
        }
        itemSequence++;
    }
    Money moneyResource = new Money();
    moneyResource.setCode("USD");
    moneyResource.setSystem("urn:iso:std:iso:4217");
    moneyResource.setValue(claim.getTotalClaimCost());
    claimResource.setTotal(moneyResource);
    return newEntry(rand, bundle, claimResource);
}
Also used : ProcedureComponent(org.hl7.fhir.dstu3.model.Claim.ProcedureComponent) PositiveIntType(org.hl7.fhir.dstu3.model.PositiveIntType) Money(org.hl7.fhir.dstu3.model.Money) Coding(org.hl7.fhir.dstu3.model.Coding) ItemComponent(org.hl7.fhir.dstu3.model.Claim.ItemComponent) SupplyDeliverySuppliedItemComponent(org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Procedure(org.mitre.synthea.world.concepts.HealthRecord.Procedure) Reference(org.hl7.fhir.dstu3.model.Reference) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) ContactPoint(org.hl7.fhir.dstu3.model.ContactPoint) SpecialConditionComponent(org.hl7.fhir.dstu3.model.Claim.SpecialConditionComponent) HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) Type(org.hl7.fhir.dstu3.model.Type) DigitalMediaType(org.hl7.fhir.dstu3.model.Media.DigitalMediaType) EncounterType(org.mitre.synthea.world.concepts.HealthRecord.EncounterType) CodeType(org.hl7.fhir.dstu3.model.CodeType) IntegerType(org.hl7.fhir.dstu3.model.IntegerType) PositiveIntType(org.hl7.fhir.dstu3.model.PositiveIntType) NodeType(org.hl7.fhir.utilities.xhtml.NodeType) StringType(org.hl7.fhir.dstu3.model.StringType) BooleanType(org.hl7.fhir.dstu3.model.BooleanType) DateType(org.hl7.fhir.dstu3.model.DateType) DateTimeType(org.hl7.fhir.dstu3.model.DateTimeType) BundleType(org.hl7.fhir.dstu3.model.Bundle.BundleType) DecimalType(org.hl7.fhir.dstu3.model.DecimalType) AllergyIntoleranceType(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType) Claim(org.mitre.synthea.world.concepts.Claim) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 8 with PositiveIntType

use of org.hl7.fhir.r4.model.PositiveIntType 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 9 with PositiveIntType

use of org.hl7.fhir.r4.model.PositiveIntType 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)

Example 10 with PositiveIntType

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

the class FhirStu3 method medicationClaim.

/**
 * Create an entry for the given Claim, which references a Medication.
 *
 * @param rand Source of randomness to use when generating ids etc
 * @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(RandomNumberGenerator rand, BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, Claim claim, BundleEntryComponent medicationEntry) {
    org.hl7.fhir.dstu3.model.Claim claimResource = new org.hl7.fhir.dstu3.model.Claim();
    org.hl7.fhir.dstu3.model.Encounter encounterResource = (org.hl7.fhir.dstu3.model.Encounter) encounterEntry.getResource();
    claimResource.setStatus(ClaimStatus.ACTIVE);
    claimResource.setUse(org.hl7.fhir.dstu3.model.Claim.Use.COMPLETE);
    // duration of encounter
    claimResource.setBillablePeriod(encounterResource.getPeriod());
    claimResource.setPatient(new Reference(personEntry.getFullUrl()));
    claimResource.setOrganization(encounterResource.getServiceProvider());
    // add item for encounter
    claimResource.addItem(new org.hl7.fhir.dstu3.model.Claim.ItemComponent(new PositiveIntType(1)).addEncounter(new Reference(encounterEntry.getFullUrl())));
    // add prescription.
    claimResource.setPrescription(new Reference(medicationEntry.getFullUrl()));
    Money moneyResource = new Money();
    moneyResource.setValue(claim.getTotalClaimCost());
    moneyResource.setCode("USD");
    moneyResource.setSystem("urn:iso:std:iso:4217");
    claimResource.setTotal(moneyResource);
    return newEntry(rand, bundle, claimResource);
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) PositiveIntType(org.hl7.fhir.dstu3.model.PositiveIntType) Money(org.hl7.fhir.dstu3.model.Money) ItemComponent(org.hl7.fhir.dstu3.model.Claim.ItemComponent) SupplyDeliverySuppliedItemComponent(org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Claim(org.mitre.synthea.world.concepts.Claim)

Aggregations

Test (org.junit.jupiter.api.Test)6 PositiveIntType (org.hl7.fhir.r4.model.PositiveIntType)5 Reference (org.hl7.fhir.r4.model.Reference)5 PositiveIntType (org.hl7.fhir.r4b.model.PositiveIntType)5 DisplayName (org.junit.jupiter.api.DisplayName)5 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)4 Money (org.hl7.fhir.r4.model.Money)4 Claim (org.mitre.synthea.world.concepts.Claim)4 Encounter (org.mitre.synthea.world.concepts.HealthRecord.Encounter)4 PositiveIntType (org.hl7.fhir.dstu3.model.PositiveIntType)3 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)3 TransformerConstants (gov.cms.bfd.server.war.commons.TransformerConstants)2 C4BBIdentifierType (gov.cms.bfd.server.war.commons.carin.C4BBIdentifierType)2 C4BBOrganizationIdentifierType (gov.cms.bfd.server.war.commons.carin.C4BBOrganizationIdentifierType)2 BadCodeMonkeyException (gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException)2 BigDecimal (java.math.BigDecimal)2 Date (java.util.Date)2 List (java.util.List)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2