use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class ExporterTest method testExportFilterShouldKeepOldActiveMedication.
@Test
public void testExportFilterShouldKeepOldActiveMedication() {
Code code = new Code("SNOMED-CT", "705129", "Fake Code");
record.encounterStart(time - years(10), EncounterType.AMBULATORY);
record.medicationStart(time - years(10), "fakeitol", true);
record.encounterStart(time - years(8), EncounterType.AMBULATORY);
Medication med = record.medicationStart(time - years(8), "placebitol", true);
med.codes.add(code);
record.medicationEnd(time - years(6), "placebitol", DUMMY_CODE);
Person filtered = Exporter.filterForExport(patient, yearsToKeep, endTime);
Encounter encounter = filtered.record.currentEncounter(time);
assertEquals(1, encounter.medications.size());
assertEquals("fakeitol", encounter.medications.get(0).type);
assertEquals(time - years(10), encounter.medications.get(0).start);
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class StateTest method imaging_study_during_encounter.
@Test
public void imaging_study_during_encounter() throws Exception {
Module module = TestHelper.getFixture("imaging_study.json");
// First, onset the injury
State kneeInjury = module.getState("Knee_Injury");
assertTrue(kneeInjury.process(person, time));
person.history.add(kneeInjury);
// An ImagingStudy must occur during an Encounter
State encounterState = module.getState("ED_Visit");
assertTrue(encounterState.process(person, time));
person.history.add(encounterState);
// Run the imaging study
State mri = module.getState("Knee_MRI");
assertTrue(mri.process(person, time));
// Verify that the ImagingStudy was added to the record
HealthRecord.Encounter encounter = person.record.encounters.get(0);
HealthRecord.ImagingStudy study = encounter.imagingStudies.get(0);
assertEquals(time, study.start);
assertEquals(1, study.series.size());
HealthRecord.ImagingStudy.Series series = study.series.get(0);
assertEquals(1, series.instances.size());
Code bodySite = series.bodySite;
assertEquals("SNOMED-CT", bodySite.system);
assertEquals("6757004", bodySite.code);
assertEquals("Right knee", bodySite.display);
Code modality = series.modality;
assertEquals("DICOM-DCM", modality.system);
assertEquals("MR", modality.code);
assertEquals("Magnetic Resonance", modality.display);
HealthRecord.ImagingStudy.Instance instance = series.instances.get(0);
assertEquals("Image of right knee", instance.title);
Code sopClass = instance.sopClass;
assertEquals("DICOM-SOP", sopClass.system);
assertEquals("1.2.840.10008.5.1.4.1.1.4", sopClass.code);
assertEquals("MR Image Storage", sopClass.display);
// Verify that the equivalent Procedure was also added to the patient's record
HealthRecord.Procedure procedure = encounter.procedures.get(0);
assertEquals(time, procedure.start);
Code procCode = procedure.codes.get(0);
assertEquals("2491000087104", procCode.code);
assertEquals("Magnetic resonance imaging of right knee", procCode.display);
assertEquals("SNOMED-CT", procCode.system);
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class StateTest method ed_visit_encounter.
@Test
public void ed_visit_encounter() throws Exception {
Module module = TestHelper.getFixture("encounter.json");
// Non-wellness encounters happen immediately
// First, onset the Diabetes!
State diabetes = module.getState("Diabetes");
assertTrue(diabetes.process(person, time));
person.history.add(diabetes);
State encounter = module.getState("ED_Visit");
assertTrue(encounter.process(person, time));
// Verify that the Encounter was added to the record
HealthRecord.Encounter enc = person.record.encounters.get(0);
assertEquals(time, enc.start);
assertEquals(time + TimeUnit.MINUTES.toMillis(60), enc.stop);
Code code = enc.codes.get(0);
assertEquals("50849002", code.code);
assertEquals("Emergency Room Admission", code.display);
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter 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);
}
}
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class StateTest method testDeviceEndByCode.
@Test
public void testDeviceEndByCode() throws Exception {
Module module = TestHelper.getFixture("artificial_heart_device.json");
State encounterState = module.getState("Encounter");
assertTrue(encounterState.process(person, time));
State deviceState = module.getState("Artificial_Heart");
assertTrue(deviceState.process(person, time));
State deviceEndState = module.getState("Remove_Device_By_Code");
assertTrue(deviceEndState.process(person, time));
Encounter encounter = person.getCurrentEncounter(module);
List<HealthRecord.Device> devices = encounter.devices;
HealthRecord.Device device = devices.get(0);
assertEquals(time, device.stop);
}
Aggregations