use of org.mitre.synthea.world.concepts.HealthRecord 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
double coverage = encounter.claim.totals.coinsurance + encounter.claim.totals.payer;
assertEquals(person.coverage.getTotalCoverage(), coverage, 0.001);
double result = encounter.claim.totals.coinsurance + encounter.claim.totals.copay + encounter.claim.totals.deductible + encounter.claim.totals.payer + encounter.claim.totals.pocket;
assertEquals(encounter.getCost().doubleValue(), result, 0.001);
// Person's expenses should equal the copay.
double expenses = encounter.claim.totals.copay + encounter.claim.totals.deductible + encounter.claim.totals.pocket;
assertEquals(person.coverage.getTotalExpenses(), expenses, 0.001);
}
use of org.mitre.synthea.world.concepts.HealthRecord 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 in project synthea by synthetichealth.
the class Exporter method filterForExport.
/**
* Filter the patient's history to only the last __ years
* but also include relevant history from before that. Exclude
* any history that occurs after the specified end_time -- typically
* this is the current time/System.currentTimeMillis().
*
* @param original The Person to filter.
* @param yearsToKeep The last __ years to keep.
* @param endTime The time the history ends.
* @return Modified Person with history expunged.
*/
public static Person filterForExport(Person original, int yearsToKeep, long endTime) {
// TODO: clone the patient so that we export only the last _ years
// but the rest still exists, just in case
// .clone();
Person filtered = original;
if (filtered.hasMultipleRecords) {
for (String key : filtered.records.keySet()) {
HealthRecord record = filtered.records.get(key);
filterForExport(record, yearsToKeep, endTime);
}
} else {
filtered.record = filterForExport(filtered.record, yearsToKeep, endTime);
}
return filtered;
}
use of org.mitre.synthea.world.concepts.HealthRecord in project synthea by synthetichealth.
the class Exporter method filterForExport.
/**
* Filter the health record to only the last __ years
* but also include relevant history from before that. Exclude
* any history that occurs after the specified end_time -- typically
* this is the current time/System.currentTimeMillis().
*
* @param record The record to filter.
* @param yearsToKeep The last __ years to keep.
* @param endTime The time the history ends.
* @return Modified record with history expunged.
*/
private static HealthRecord filterForExport(HealthRecord record, int yearsToKeep, long endTime) {
long cutoffDate = endTime - Utilities.convertTime("years", yearsToKeep);
Predicate<HealthRecord.Entry> notFutureDated = e -> e.start <= endTime;
for (Encounter encounter : record.encounters) {
List<Claim.ClaimEntry> claimItems = encounter.claim.items;
// keep conditions if still active, regardless of start date
Predicate<HealthRecord.Entry> conditionActive = c -> record.conditionActive(c.type);
// or if the condition was active at any point since the cutoff date
Predicate<HealthRecord.Entry> activeWithinCutoff = c -> c.stop != 0L && c.stop > cutoffDate;
Predicate<HealthRecord.Entry> keepCondition = conditionActive.or(activeWithinCutoff);
filterEntries(encounter.conditions, claimItems, cutoffDate, endTime, keepCondition);
// allergies are essentially the same as conditions
// But we need to redefine all of the predicates, because we are talking about Allergies as
// opposed to Entries... You would think that it would work... but generics are hard
Predicate<HealthRecord.Allergy> allergyActive = c -> record.allergyActive(c.type);
// or if the condition was active at any point since the cutoff date
Predicate<HealthRecord.Allergy> allergyActiveWithinCutoff = c -> c.stop != 0L && c.stop > cutoffDate;
Predicate<HealthRecord.Allergy> keepAllergy = allergyActive.or(allergyActiveWithinCutoff);
filterEntries(encounter.allergies, claimItems, cutoffDate, endTime, keepAllergy);
// some of the "future death" logic could potentially add a future-dated death certificate
Predicate<Observation> isCauseOfDeath = o -> DeathModule.CAUSE_OF_DEATH_CODE.code.equals(o.type);
// keep cause of death unless it's future dated
Predicate<Observation> keepObservation = isCauseOfDeath.and(notFutureDated);
filterEntries(encounter.observations, claimItems, cutoffDate, endTime, keepObservation);
// keep all death certificates, unless they are future-dated
Predicate<Report> isDeathCertificate = r -> DeathModule.DEATH_CERTIFICATE.code.equals(r.type);
Predicate<Report> keepReport = isDeathCertificate.and(notFutureDated);
filterEntries(encounter.reports, claimItems, cutoffDate, endTime, keepReport);
filterEntries(encounter.procedures, claimItems, cutoffDate, endTime, null);
// keep medications if still active, regardless of start date
filterEntries(encounter.medications, claimItems, cutoffDate, endTime, med -> record.medicationActive(med.type));
filterEntries(encounter.immunizations, claimItems, cutoffDate, endTime, null);
// keep careplans if they are still active, regardless of start date
filterEntries(encounter.careplans, claimItems, cutoffDate, endTime, cp -> record.careplanActive(cp.type));
}
// if ANY of these are not empty, the encounter is not empty
Predicate<Encounter> encounterNotEmpty = e -> !e.conditions.isEmpty() || !e.allergies.isEmpty() || !e.observations.isEmpty() || !e.reports.isEmpty() || !e.procedures.isEmpty() || !e.medications.isEmpty() || !e.immunizations.isEmpty() || !e.careplans.isEmpty();
Predicate<Encounter> isDeathCertification = e -> !e.codes.isEmpty() && DeathModule.DEATH_CERTIFICATION.equals(e.codes.get(0));
Predicate<Encounter> keepEncounter = encounterNotEmpty.or(isDeathCertification.and(notFutureDated));
// finally filter out any empty encounters
filterEntries(record.encounters, Collections.emptyList(), cutoffDate, endTime, keepEncounter);
return record;
}
use of org.mitre.synthea.world.concepts.HealthRecord in project synthea by synthetichealth.
the class LogicTest method test_condition_condition.
@Test
public void test_condition_condition() {
person.record = new HealthRecord(person);
assertFalse(doTest("diabetesConditionTest"));
assertFalse(doTest("alzheimersConditionTest"));
HealthRecord.Code diabetesCode = new HealthRecord.Code("SNOMED-CT", "73211009", "Diabetes mellitus");
person.record.conditionStart(time, diabetesCode.code);
assertTrue(doTest("diabetesConditionTest"));
assertFalse(doTest("alzheimersConditionTest"));
time += Utilities.convertTime("years", 10);
person.record.conditionEnd(time, diabetesCode.code);
assertFalse(doTest("diabetesConditionTest"));
HealthRecord.Code alzCode = new HealthRecord.Code("SNOMED-CT", "26929004", "Alzheimer's disease (disorder)");
HealthRecord.Entry cond = person.record.conditionStart(time, alzCode.code);
person.attributes.put("Alzheimer's Variant", cond);
assertTrue(doTest("alzheimersConditionTest"));
}
Aggregations