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;
}
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()));
}
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());
}
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()));
}
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));
}
Aggregations