Search in sources :

Example 36 with Encounter

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

the class EncounterModule method process.

@Override
public boolean process(Person person, long time) {
    if (!person.alive(time)) {
        return true;
    }
    if (person.hasCurrentEncounter()) {
        // Don't start a new encounter here if there is already an active encounter
        return false;
    }
    boolean startedEncounter = false;
    Encounter encounter = null;
    // add a wellness encounter if this is the right time
    if (person.record.timeSinceLastWellnessEncounter(time) >= recommendedTimeBetweenWellnessVisits(person, time)) {
        Code code = getWellnessVisitCode(person, time);
        encounter = createEncounter(person, time, EncounterType.WELLNESS, ClinicianSpecialty.GENERAL_PRACTICE, code);
        encounter.name = "Encounter Module Scheduled Wellness";
        person.attributes.put(ACTIVE_WELLNESS_ENCOUNTER, true);
        startedEncounter = true;
    } else if (person.symptomTotal() > EMERGENCY_SYMPTOM_THRESHOLD) {
        if (!person.attributes.containsKey(LAST_VISIT_SYMPTOM_TOTAL)) {
            person.attributes.put(LAST_VISIT_SYMPTOM_TOTAL, 0);
        }
        if (person.symptomTotal() != (int) person.attributes.get(LAST_VISIT_SYMPTOM_TOTAL)) {
            person.attributes.put(LAST_VISIT_SYMPTOM_TOTAL, person.symptomTotal());
            person.addressLargestSymptom();
            encounter = createEncounter(person, time, EncounterType.EMERGENCY, ClinicianSpecialty.GENERAL_PRACTICE, ENCOUNTER_EMERGENCY);
            encounter.name = "Encounter Module Symptom Driven";
            person.attributes.put(ACTIVE_EMERGENCY_ENCOUNTER, true);
            startedEncounter = true;
        }
    } else if (person.symptomTotal() > URGENT_CARE_SYMPTOM_THRESHOLD) {
        if (!person.attributes.containsKey(LAST_VISIT_SYMPTOM_TOTAL)) {
            person.attributes.put(LAST_VISIT_SYMPTOM_TOTAL, 0);
        }
        if (person.symptomTotal() != (int) person.attributes.get(LAST_VISIT_SYMPTOM_TOTAL)) {
            person.attributes.put(LAST_VISIT_SYMPTOM_TOTAL, person.symptomTotal());
            person.addressLargestSymptom();
            encounter = createEncounter(person, time, EncounterType.URGENTCARE, ClinicianSpecialty.GENERAL_PRACTICE, ENCOUNTER_URGENTCARE);
            encounter.name = "Encounter Module Symptom Driven";
            person.attributes.put(ACTIVE_URGENT_CARE_ENCOUNTER, true);
            startedEncounter = true;
        }
    } else if (person.symptomTotal() > PCP_SYMPTOM_THRESHOLD) {
        if (!person.attributes.containsKey(LAST_VISIT_SYMPTOM_TOTAL)) {
            person.attributes.put(LAST_VISIT_SYMPTOM_TOTAL, 0);
        }
        if (person.symptomTotal() != (int) person.attributes.get(LAST_VISIT_SYMPTOM_TOTAL)) {
            person.attributes.put(LAST_VISIT_SYMPTOM_TOTAL, person.symptomTotal());
            person.addressLargestSymptom();
            encounter = createEncounter(person, time, EncounterType.OUTPATIENT, ClinicianSpecialty.GENERAL_PRACTICE, ENCOUNTER_CHECKUP);
            encounter.name = "Encounter Module Symptom Driven";
            person.attributes.put(ACTIVE_WELLNESS_ENCOUNTER, true);
            startedEncounter = true;
        }
    }
    if (startedEncounter) {
        person.setCurrentEncounter(this, encounter);
        CardiovascularDiseaseModule.performEncounter(person, time, encounter);
        Immunizations.performEncounter(person, time);
    }
    // java modules will never "finish"
    return false;
}
Also used : Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Code(org.mitre.synthea.world.concepts.HealthRecord.Code)

Example 37 with Encounter

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

the class PayerTest method costsCoveredByPayer.

@Test
public void costsCoveredByPayer() {
    long time = 0L;
    Costs.loadCostData();
    person = new Person(time);
    person.coverage.setPayerAtTime(time, testPrivatePayer1);
    Code code = new Code("SNOMED-CT", "705129", "Fake SNOMED with the same code as an RxNorm code");
    Encounter fakeEncounter = person.record.encounterStart(time, EncounterType.WELLNESS);
    fakeEncounter.codes.add(code);
    fakeEncounter.provider = new Provider();
    person.record.encounterEnd(0L, EncounterType.WELLNESS);
    // check the copays match
    assertTrue(testPrivatePayer1.getDeductible().equals(fakeEncounter.claim.totals.deductible));
    // check that totals match
    assertTrue(fakeEncounter.getCost().equals(fakeEncounter.claim.totals.cost));
    BigDecimal result = fakeEncounter.claim.totals.coinsurance.add(fakeEncounter.claim.totals.copay).add(fakeEncounter.claim.totals.deductible).add(fakeEncounter.claim.totals.payer).add(fakeEncounter.claim.totals.pocket);
    assertTrue(fakeEncounter.getCost().equals(result));
    // The total cost should equal the Cost to the Payer summed with the Payer's copay amount.
    assertTrue(fakeEncounter.getCost().equals(testPrivatePayer1.getAmountCovered().add(fakeEncounter.claim.getPatientCost())));
    // The total cost should equal the Payer's uncovered costs plus the Payer's covered costs.
    assertTrue(fakeEncounter.getCost().equals(testPrivatePayer1.getAmountCovered().add(testPrivatePayer1.getAmountUncovered())));
    // The total coverage by the payer should equal the person's covered costs.
    assertTrue(person.coverage.getTotalCoverage().equals(testPrivatePayer1.getAmountCovered()));
}
Also used : Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 38 with Encounter

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

the class PayerTest method incrementEncounters.

@Test
public void incrementEncounters() {
    person = new Person(0L);
    person.coverage.setPayerAtTime(0L, testPrivatePayer1);
    HealthRecord healthRecord = new HealthRecord(person);
    Code code = new Code("SNOMED-CT", "705129", "Fake Code");
    Encounter fakeEncounter = healthRecord.encounterStart(0L, EncounterType.INPATIENT);
    fakeEncounter.codes.add(code);
    fakeEncounter.provider = new Provider();
    healthRecord.encounterEnd(0L, EncounterType.INPATIENT);
    fakeEncounter = healthRecord.encounterStart(0L, EncounterType.AMBULATORY);
    fakeEncounter.provider = new Provider();
    fakeEncounter.codes.add(code);
    healthRecord.encounterEnd(0L, EncounterType.AMBULATORY);
    fakeEncounter = healthRecord.encounterStart(0L, EncounterType.EMERGENCY);
    fakeEncounter.codes.add(code);
    fakeEncounter.provider = new Provider();
    healthRecord.encounterEnd(0L, EncounterType.EMERGENCY);
    assertEquals(3, testPrivatePayer1.getEncountersCoveredCount());
}
Also used : HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) Test(org.junit.Test)

Example 39 with Encounter

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

the class PayerTest method costsUncoveredByNoInsurance.

@Test
public void costsUncoveredByNoInsurance() {
    Costs.loadCostData();
    Payer.loadNoInsurance();
    person = new Person(0L);
    person.coverage.setPayerAtTime(0L, Payer.noInsurance);
    Code code = new Code("SNOMED-CT", "705129", "Fake SNOMED with the same code as an RxNorm code");
    Encounter fakeEncounter = person.record.encounterStart(0L, EncounterType.WELLNESS);
    fakeEncounter.codes.add(code);
    fakeEncounter.provider = new Provider();
    person.record.encounterEnd(0L, EncounterType.WELLNESS);
    // The No Insurance payer should have $0.0 coverage.
    assertTrue(Payer.noInsurance.getAmountCovered().equals(Claim.ZERO_CENTS));
    // The No Insurance's uncovered costs should equal the total cost.
    assertTrue(fakeEncounter.getCost().equals(Payer.noInsurance.getAmountUncovered()));
    // The person's expenses shoudl equal the total cost.
    assertTrue(fakeEncounter.getCost().equals(person.coverage.getTotalExpenses()));
}
Also used : Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) Test(org.junit.Test)

Example 40 with Encounter

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

the class PayerTest method payerCoversEncounter.

@Test
public void payerCoversEncounter() {
    person = new Person(0L);
    person.attributes.put(Person.BIRTHDATE, 0L);
    person.coverage.setPayerAtTime(0L, testPrivatePayer1);
    HealthRecord healthRecord = new HealthRecord(person);
    Encounter encounter = healthRecord.encounterStart(0L, EncounterType.INPATIENT);
    encounter.provider = new Provider();
    encounter.codes.add(new Code("SNOMED-CT", "705129", "Fake SNOMED for null entry"));
    assertTrue(testPrivatePayer1.coversService(encounter.type));
    healthRecord.encounterEnd(0L, EncounterType.INPATIENT);
    // Person's coverage should equal the cost of the encounter
    BigDecimal coverage = encounter.claim.totals.coinsurance.add(encounter.claim.totals.payer);
    assertTrue(person.coverage.getTotalCoverage().equals(coverage));
    BigDecimal result = encounter.claim.totals.coinsurance.add(encounter.claim.totals.copay).add(encounter.claim.totals.deductible).add(encounter.claim.totals.payer).add(encounter.claim.totals.pocket);
    assertTrue(encounter.getCost().equals(result));
    // Person's expenses should equal the copay.
    BigDecimal expenses = encounter.claim.totals.copay.add(encounter.claim.totals.deductible).add(encounter.claim.totals.pocket);
    assertTrue(person.coverage.getTotalExpenses().equals(expenses));
}
Also used : HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

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