use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class StateTest method the_dead_should_stay_dead_forever.
@Test
public void the_dead_should_stay_dead_forever() throws Exception {
Module module = TestHelper.getFixture("death_life_expectancy.json");
long timestep = Long.parseLong(Config.get("generate.timestep"));
long timeT = time;
while (person.alive(timeT)) {
module.process(person, timeT);
timeT += timestep;
}
// Now check that the person stayed dead...
long deathTime = (Long) person.attributes.get(Person.DEATHDATE);
for (Encounter encounter : person.record.encounters) {
if (!encounter.codes.contains(DeathModule.DEATH_CERTIFICATION)) {
assertTrue(encounter.start < deathTime);
}
}
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class CardiovascularDiseaseModule method atrialFibrillationTreatment.
/**
* Start or stop medication treatments and possibly perform a procedural intervention
* depending on whether or not the patient has "atrial_fibrillation" by looking for
* the attribute "atrial_fibrillation".
* @param person The patient.
* @param time The time.
*/
private static void atrialFibrillationTreatment(Person person, long time) {
List<String> meds = filter_meds_by_year(Arrays.asList("warfarin", "verapamil", "digoxin"), time);
if ((Boolean) person.attributes.getOrDefault("atrial_fibrillation", false)) {
for (String med : meds) {
prescribeMedication(med, person, time, true);
}
// catheter ablation is a more extreme measure than electrical cardioversion and is usually
// only performed
// when medication and other procedures are not preferred or have failed. As a rough
// simulation of this,
// we arbitrarily chose a 20% chance of getting catheter ablation and 80% of getting
// cardioversion
String afibProcedure = person.rand() < 0.2 ? "catheter_ablation" : "electrical_cardioversion";
Code code = LOOKUP.get(afibProcedure);
Procedure procedure = person.record.procedure(time, code.display);
procedure.name = "Atrial Fibrillation Treatment";
procedure.codes.add(code);
procedure.reasons.add(LOOKUP.get("atrial_fibrillation"));
if (afibProcedure.equals("catheter_ablation") && person.rand() <= 0.1) {
// 10.0% chance the patient will receive a pacemaker.
if (!person.record.present.containsKey("pacemaker")) {
Entry device = person.record.deviceImplant(time, "pacemaker");
device.codes.add(LOOKUP.get("pacemaker"));
}
}
// increment number of procedures by respective hospital
Encounter encounter = (Encounter) person.attributes.get(CVD_ENCOUNTER);
if (encounter != null) {
int year = Utilities.getYear(time);
encounter.provider.incrementProcedures(year);
}
} else {
for (String med : meds) {
person.record.medicationEnd(time, med, LOOKUP.get("cardiovascular_improved"));
}
}
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class CardiovascularDiseaseModule method beginOrContinueEmergency.
private static void beginOrContinueEmergency(Person person, long time, Code code) {
if (!person.attributes.containsKey(CVD_ENCOUNTER)) {
Encounter encounter = EncounterModule.createEncounter(person, time, EncounterType.EMERGENCY, ClinicianSpecialty.GENERAL_PRACTICE, code);
person.attributes.put(CVD_ENCOUNTER, encounter);
}
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class CardiovascularDiseaseModule method performEmergency.
/**
* Perform an emergency cardiovascular disease encounter.
* @param person The patient.
* @param time The time of the emergency.
* @param diagnosis The diagnosis to be made.
*/
public static void performEmergency(Person person, long time, String diagnosis) {
Encounter encounter = (Encounter) person.attributes.get(CVD_ENCOUNTER);
int year = Utilities.getYear(time);
Entry condition = person.record.conditionStart(time, diagnosis);
condition.codes.add(LOOKUP.get(diagnosis));
for (String med : filter_meds_by_year(EMERGENCY_MEDS.get(diagnosis), time)) {
prescribeMedication(med, person, time, false);
person.record.medicationEnd(time + TimeUnit.MINUTES.toMillis(15), med, LOOKUP.get("stop_drug"));
}
// In these type of emergencies, everyone gets an echocardiogram
Procedure procedure = person.record.procedure(time, "echocardiogram");
procedure.name = "Echocardiogram";
procedure.codes.add(LOOKUP.get("echocardiogram"));
procedure.reasons.add(LOOKUP.get(diagnosis));
for (String proc : EMERGENCY_PROCEDURES.get(diagnosis)) {
procedure = person.record.procedure(time, proc);
procedure.name = "Cardiovascular Disease Emergency";
procedure.codes.add(LOOKUP.get(proc));
procedure.reasons.add(LOOKUP.get(diagnosis));
if (proc.equals("implant_cardioverter_defib")) {
if (!person.record.present.containsKey("defibrillator")) {
Entry device = person.record.deviceImplant(time, "defibrillator");
device.codes.add(LOOKUP.get("defibrillator"));
}
} else if (proc.equals("percutaneous_coronary_intervention")) {
if (!person.record.present.containsKey("stent")) {
Entry device = person.record.deviceImplant(time, "stent");
device.codes.add(LOOKUP.get("stent"));
}
}
// increment number of procedures performed by respective hospital
encounter.provider.incrementProcedures(year);
}
for (String cond : HISTORY_CONDITIONS.get(diagnosis)) {
Entry historyCond = person.record.conditionStart(time, cond);
historyCond.codes.add(LOOKUP.get(cond));
}
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class CardiovascularDiseaseModule method prescribeMedication.
private static void prescribeMedication(String med, Person person, long time, boolean chronic) {
Medication entry = person.record.medicationStart(time, med, chronic);
HealthRecord.Code medicationCode = LOOKUP.get(med);
if (!entry.containsCode(medicationCode.code, medicationCode.system)) {
entry.codes.add(medicationCode);
}
// increment number of prescriptions prescribed
Encounter encounter = (Encounter) person.attributes.get(CVD_ENCOUNTER);
if (encounter != null) {
int year = Utilities.getYear(time);
encounter.provider.incrementPrescriptions(year);
}
}
Aggregations