Search in sources :

Example 31 with Encounter

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);
        }
    }
}
Also used : Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) QualityOfLifeModule(org.mitre.synthea.modules.QualityOfLifeModule) CardiovascularDiseaseModule(org.mitre.synthea.modules.CardiovascularDiseaseModule) EncounterModule(org.mitre.synthea.modules.EncounterModule) WeightLossModule(org.mitre.synthea.modules.WeightLossModule) LifecycleModule(org.mitre.synthea.modules.LifecycleModule) DeathModule(org.mitre.synthea.modules.DeathModule) Test(org.junit.Test)

Example 32 with Encounter

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"));
        }
    }
}
Also used : Entry(org.mitre.synthea.world.concepts.HealthRecord.Entry) Procedure(org.mitre.synthea.world.concepts.HealthRecord.Procedure) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Code(org.mitre.synthea.world.concepts.HealthRecord.Code)

Example 33 with Encounter

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);
    }
}
Also used : Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter)

Example 34 with 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));
    }
}
Also used : Entry(org.mitre.synthea.world.concepts.HealthRecord.Entry) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Procedure(org.mitre.synthea.world.concepts.HealthRecord.Procedure)

Example 35 with Encounter

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);
    }
}
Also used : HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) Medication(org.mitre.synthea.world.concepts.HealthRecord.Medication) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter)

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