Search in sources :

Example 21 with Encounter

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

Example 22 with Encounter

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

Example 23 with Encounter

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

Example 24 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.

@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)

Example 25 with Encounter

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

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