Search in sources :

Example 1 with EncounterModule

use of org.mitre.synthea.modules.EncounterModule in project synthea by synthetichealth.

the class Generator method updatePerson.

/**
 * Update a previously created person from the time they were last updated until Generator.stop or
 * they die, whichever comes sooner.
 * @param person the previously created person to update
 */
public void updatePerson(Person person) {
    HealthInsuranceModule healthInsuranceModule = new HealthInsuranceModule();
    EncounterModule encounterModule = new EncounterModule();
    long time = person.lastUpdated;
    while (person.alive(time) && time < stop) {
        healthInsuranceModule.process(person, time + timestep);
        encounterModule.process(person, time);
        Iterator<Module> iter = person.currentModules.iterator();
        while (iter.hasNext()) {
            Module module = iter.next();
            if (module.process(person, time)) {
                // this module has completed/terminated.
                iter.remove();
            }
        }
        encounterModule.endEncounterModuleEncounters(person, time);
        person.lastUpdated = time;
        HealthRecordEditors.getInstance().executeAll(person, person.record, time, timestep);
        time += timestep;
    }
    DeathModule.process(person, time);
}
Also used : HealthInsuranceModule(org.mitre.synthea.modules.HealthInsuranceModule) EncounterModule(org.mitre.synthea.modules.EncounterModule) HealthInsuranceModule(org.mitre.synthea.modules.HealthInsuranceModule) LifecycleModule(org.mitre.synthea.modules.LifecycleModule) EncounterModule(org.mitre.synthea.modules.EncounterModule) DeathModule(org.mitre.synthea.modules.DeathModule)

Example 2 with EncounterModule

use of org.mitre.synthea.modules.EncounterModule in project synthea by synthetichealth.

the class StateTest method the_dead_should_stay_dead.

@Test
public void the_dead_should_stay_dead() throws Exception {
    // Load all the static modules used in Generator.java
    EncounterModule encounterModule = new EncounterModule();
    List<Module> modules = new ArrayList<Module>();
    modules.add(new LifecycleModule());
    modules.add(new CardiovascularDiseaseModule());
    modules.add(new QualityOfLifeModule());
    // modules.add(new HealthInsuranceModule());
    modules.add(new WeightLossModule());
    // Make sure the patient dies...
    modules.add(TestHelper.getFixture("death_life_expectancy.json"));
    // And make sure the patient has weird delays that are between timesteps...
    modules.add(Module.getModuleByPath("dialysis"));
    // Set life signs at birth...
    long timeT = (long) person.attributes.get(Person.BIRTHDATE);
    LifecycleModule.birth(person, timeT);
    // Make sure the patient requires dialysis to use that module's
    // repeating delayed encounters...
    person.attributes.put("ckd", 5);
    long timestep = Long.parseLong(Config.get("generate.timestep"));
    long stop = time;
    while (person.alive(timeT) && timeT < stop) {
        encounterModule.process(person, timeT);
        Iterator<Module> iter = modules.iterator();
        while (iter.hasNext()) {
            Module module = iter.next();
            if (module.process(person, timeT)) {
                // this module has completed/terminated.
                iter.remove();
            }
        }
        encounterModule.endEncounterModuleEncounters(person, timeT);
        timeT += timestep;
    }
    DeathModule.process(person, time);
    // 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 : CardiovascularDiseaseModule(org.mitre.synthea.modules.CardiovascularDiseaseModule) ArrayList(java.util.ArrayList) QualityOfLifeModule(org.mitre.synthea.modules.QualityOfLifeModule) EncounterModule(org.mitre.synthea.modules.EncounterModule) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) WeightLossModule(org.mitre.synthea.modules.WeightLossModule) 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) LifecycleModule(org.mitre.synthea.modules.LifecycleModule) Test(org.junit.Test)

Aggregations

DeathModule (org.mitre.synthea.modules.DeathModule)2 EncounterModule (org.mitre.synthea.modules.EncounterModule)2 LifecycleModule (org.mitre.synthea.modules.LifecycleModule)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 CardiovascularDiseaseModule (org.mitre.synthea.modules.CardiovascularDiseaseModule)1 HealthInsuranceModule (org.mitre.synthea.modules.HealthInsuranceModule)1 QualityOfLifeModule (org.mitre.synthea.modules.QualityOfLifeModule)1 WeightLossModule (org.mitre.synthea.modules.WeightLossModule)1 Encounter (org.mitre.synthea.world.concepts.HealthRecord.Encounter)1