Search in sources :

Example 71 with Encounter

use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.

the class HealthRecordTest method testReportSomeObs.

@Test
public void testReportSomeObs() {
    Person person = new Person(0L);
    person.coverage.setPayerAtTime(time, noInsurance);
    HealthRecord record = new HealthRecord(person);
    Encounter encounter = record.encounterStart(time, EncounterType.WELLNESS);
    record.observation(time, "A", "A");
    record.observation(time, "B", "B");
    record.observation(time, "C", "C");
    Report report = record.report(time, "R", 2);
    Assert.assertEquals(3, encounter.observations.size());
    Assert.assertEquals(2, report.observations.size());
    Assert.assertEquals("B", report.observations.get(0).value);
    Assert.assertEquals("C", report.observations.get(1).value);
}
Also used : Report(org.mitre.synthea.world.concepts.HealthRecord.Report) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Person(org.mitre.synthea.world.agents.Person) Test(org.junit.Test)

Example 72 with Encounter

use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.

the class HealthRecordTest method testReportTooManyObs.

@Test
public void testReportTooManyObs() {
    Person person = new Person(0L);
    person.coverage.setPayerAtTime(time, noInsurance);
    HealthRecord record = new HealthRecord(person);
    Encounter encounter = record.encounterStart(time, EncounterType.WELLNESS);
    record.observation(time, "A", "A");
    record.observation(time, "B", "B");
    record.observation(time, "C", "C");
    Report report = record.report(time, "R", 4);
    Assert.assertEquals(3, encounter.observations.size());
    Assert.assertEquals(3, report.observations.size());
    Assert.assertEquals("A", report.observations.get(0).value);
    Assert.assertEquals("B", report.observations.get(1).value);
    Assert.assertEquals("C", report.observations.get(2).value);
}
Also used : Report(org.mitre.synthea.world.concepts.HealthRecord.Report) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Person(org.mitre.synthea.world.agents.Person) Test(org.junit.Test)

Example 73 with Encounter

use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.

the class LossOfCareHealthRecordTest method personRunsOutOfCurrentYearIncomeThenNextYearBegins.

@Test
public void personRunsOutOfCurrentYearIncomeThenNextYearBegins() {
    Person person = new Person(0L);
    person.coverage.setPayerAtTime(time, Payer.noInsurance);
    person.setProvider(EncounterType.WELLNESS, new Provider());
    Code code = new Code("SNOMED-CT", "705129", "Fake Code");
    // Set person's income to be $1 lower than the cost of an encounter.
    person.attributes.put(Person.INCOME, (int) defaultEncounterCost - 1);
    // Set person's birthdate
    person.attributes.put(Person.BIRTHDATE, time);
    // First encounter of current year is uncovered but affordable.
    Encounter coveredEncounterYearOne = person.encounterStart(time, EncounterType.WELLNESS);
    coveredEncounterYearOne.codes.add(code);
    coveredEncounterYearOne.provider = new Provider();
    person.record.encounterEnd(time, EncounterType.WELLNESS);
    // Person is in debt $1. They should not receive any more care.
    assertTrue(person.defaultRecord.encounters.contains(coveredEncounterYearOne));
    assertFalse(person.lossOfCareRecord.encounters.contains(coveredEncounterYearOne));
    // Second encounter of current year is uncovered and not affordable.
    Encounter uncoveredEncounterYearOne = person.encounterStart(time, EncounterType.WELLNESS);
    uncoveredEncounterYearOne.codes.add(code);
    uncoveredEncounterYearOne.provider = new Provider();
    person.record.encounterEnd(time, EncounterType.WELLNESS);
    // Person should have this encounter in the uncoveredHealthRecord.
    assertFalse(person.defaultRecord.encounters.contains(uncoveredEncounterYearOne));
    assertTrue(person.lossOfCareRecord.encounters.contains(uncoveredEncounterYearOne));
    // Next year begins. Person should enough income to cover one encounter for the year.
    long oneYear = Utilities.convertTime("years", 1) + 1;
    person.coverage.setPayerAtTime(time + oneYear, Payer.noInsurance);
    // First encounter of next year is uncovered but affordable.
    Encounter coveredEncounterYearTwo = person.encounterStart(time + oneYear, EncounterType.WELLNESS);
    coveredEncounterYearTwo.codes.add(code);
    coveredEncounterYearTwo.provider = new Provider();
    person.record.encounterEnd(time + oneYear, EncounterType.WELLNESS);
    // Person is in debt $1. They should not receive any more care.
    assertTrue(person.defaultRecord.encounters.contains(coveredEncounterYearTwo));
    assertFalse(person.lossOfCareRecord.encounters.contains(coveredEncounterYearTwo));
    // Second encounter of next year is uncovered and not affordable.
    Encounter uncoveredEncounterYearTwo = person.encounterStart(time + oneYear, EncounterType.WELLNESS);
    uncoveredEncounterYearTwo.codes.add(code);
    uncoveredEncounterYearTwo.provider = new Provider();
    person.record.encounterEnd(time + oneYear, EncounterType.WELLNESS);
    // Person should have this encounter in the uncoveredHealthRecord.
    assertFalse(person.defaultRecord.encounters.contains(uncoveredEncounterYearTwo));
    assertTrue(person.lossOfCareRecord.encounters.contains(uncoveredEncounterYearTwo));
}
Also used : Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Person(org.mitre.synthea.world.agents.Person) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) Provider(org.mitre.synthea.world.agents.Provider) Test(org.junit.Test)

Example 74 with Encounter

use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.

the class EncounterModuleTest method testEncounterHasClinician.

@Test
public void testEncounterHasClinician() {
    module.process(person, System.currentTimeMillis());
    assertNotNull(person.record);
    assertFalse(person.record.encounters.isEmpty());
    int last = person.record.encounters.size() - 1;
    Encounter encounter = person.record.encounters.get(last);
    assertNotNull("Encounter must have clinician", encounter.clinician);
    assertNotNull("Encounter must have provider organization", encounter.provider);
}
Also used : Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Test(org.junit.Test) ProviderTest(org.mitre.synthea.world.agents.ProviderTest)

Example 75 with Encounter

use of org.mitre.synthea.world.concepts.HealthRecord.Encounter 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)

Aggregations

Encounter (org.mitre.synthea.world.concepts.HealthRecord.Encounter)99 Test (org.junit.Test)54 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)51 HealthRecord (org.mitre.synthea.world.concepts.HealthRecord)29 Person (org.mitre.synthea.world.agents.Person)28 ProviderTest (org.mitre.synthea.world.agents.ProviderTest)22 DeathModule (org.mitre.synthea.modules.DeathModule)17 QualityOfLifeModule (org.mitre.synthea.modules.QualityOfLifeModule)17 ArrayList (java.util.ArrayList)16 CardiovascularDiseaseModule (org.mitre.synthea.modules.CardiovascularDiseaseModule)16 EncounterModule (org.mitre.synthea.modules.EncounterModule)16 LifecycleModule (org.mitre.synthea.modules.LifecycleModule)16 WeightLossModule (org.mitre.synthea.modules.WeightLossModule)16 Provider (org.mitre.synthea.world.agents.Provider)16 Medication (org.mitre.synthea.world.concepts.HealthRecord.Medication)16 Observation (org.mitre.synthea.world.concepts.HealthRecord.Observation)16 Procedure (org.mitre.synthea.world.concepts.HealthRecord.Procedure)16 Report (org.mitre.synthea.world.concepts.HealthRecord.Report)14 Date (java.util.Date)13 Claim (org.mitre.synthea.world.concepts.Claim)12