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