Search in sources :

Example 1 with SampledData

use of org.mitre.synthea.engine.Components.SampledData in project synthea by synthetichealth.

the class StateTest method setAttribute_with_seriesData_Module.

@Test
public void setAttribute_with_seriesData_Module() throws Exception {
    Module module = TestHelper.getFixture("series_data.json");
    assertTrue(module.process(person, time));
    TimeSeriesData data = (TimeSeriesData) person.attributes.get("series_data");
    assertEquals(12, data.getValues().size());
    assertEquals(1, data.getValues().get(0), 0.0001);
    HealthRecord.Observation obs = person.record.getLatestObservation("1234");
    assertNotNull(obs);
    assertTrue(obs.value instanceof Components.SampledData);
    Components.SampledData sampledData = (Components.SampledData) obs.value;
    String value = ExportHelper.sampledDataToValueString(sampledData);
    assertEquals("1 2 3 4 4 3 2 1 1 2 3 4", value);
}
Also used : HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) SampledData(org.mitre.synthea.engine.Components.SampledData) SampledData(org.mitre.synthea.engine.Components.SampledData) 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) TimeSeriesData(org.mitre.synthea.helpers.TimeSeriesData) Test(org.junit.Test)

Example 2 with SampledData

use of org.mitre.synthea.engine.Components.SampledData in project synthea by synthetichealth.

the class StateTest method observation.

@Test
public void observation() throws Exception {
    Module module = TestHelper.getFixture("observation.json");
    State vitalsign = module.getState("VitalSign");
    assertTrue(vitalsign.process(person, time));
    person.history.add(vitalsign);
    State encounter = module.getState("SomeEncounter");
    assertTrue(encounter.process(person, time));
    person.history.add(encounter);
    State physiology = module.getState("Simulate_CVS");
    assertTrue(physiology.process(person, time));
    person.history.add(physiology);
    State vitalObs = module.getState("VitalSignObservation");
    assertTrue(vitalObs.process(person, time));
    State codeObs = module.getState("CodeObservation");
    assertTrue(codeObs.process(person, time));
    State sampleObs = module.getState("SampledDataObservation");
    assertTrue(sampleObs.process(person, time));
    State chartObs = module.getState("ChartObservation");
    assertTrue(chartObs.process(person, time));
    State urlObs = module.getState("UrlObservation");
    assertTrue(urlObs.process(person, time));
    HealthRecord.Observation vitalObservation = person.record.encounters.get(0).observations.get(0);
    assertEquals(120.0, vitalObservation.value);
    assertEquals("vital-signs", vitalObservation.category);
    assertEquals("mm[Hg]", vitalObservation.unit);
    Code vitalObsCode = vitalObservation.codes.get(0);
    assertEquals("8480-6", vitalObsCode.code);
    assertEquals("Systolic Blood Pressure", vitalObsCode.display);
    HealthRecord.Observation codeObservation = person.record.encounters.get(0).observations.get(1);
    assertEquals("procedure", codeObservation.category);
    // assertEquals("LOINC", codeObservation.value.system);
    // assertEquals("25428-4", codeObservation.value.code);
    // assertEquals("Glucose [Presence] in Urine by Test strip", codeObservation.value.system);
    Code testCode = new Code("LOINC", "25428-4", "Glucose [Presence] in Urine by Test strip");
    assertEquals(testCode.toString(), codeObservation.value.toString());
    Code codeObsCode = codeObservation.codes.get(0);
    assertEquals("24356-8", codeObsCode.code);
    assertEquals("Urinalysis complete panel - Urine", codeObsCode.display);
    HealthRecord.Observation sampleObservation = person.record.encounters.get(0).observations.get(2);
    assertEquals("procedure", sampleObservation.category);
    assertEquals("mm[Hg]", sampleObservation.unit);
    assertTrue(sampleObservation.value instanceof SampledData);
    SampledData sampledData = (SampledData) sampleObservation.value;
    assertEquals("P_ao", sampledData.attributes.get(0));
    assertEquals("P_lv", sampledData.attributes.get(1));
    assertEquals("P_rv", sampledData.attributes.get(2));
    assertEquals(3, sampledData.series.size());
    HealthRecord.Observation chartObservation = person.record.encounters.get(0).observations.get(3);
    assertTrue(chartObservation.value instanceof Attachment);
    Attachment obsAttachment = (Attachment) chartObservation.value;
    assertEquals("Media Test", obsAttachment.title);
    assertEquals(400, obsAttachment.width);
    assertEquals(200, obsAttachment.height);
    assertEquals("image/png", obsAttachment.contentType);
    assertTrue(Base64.isBase64(obsAttachment.data));
    HealthRecord.Observation urlObservation = person.record.encounters.get(0).observations.get(4);
    assertTrue(urlObservation.value instanceof Attachment);
    Attachment urlAttachment = (Attachment) urlObservation.value;
    assertEquals("Test Image URL", urlAttachment.title);
    assertEquals("66bb1cb31c9b502daa7081ae36631f9df9c6d16a", urlAttachment.hash);
    assertEquals("en-US", urlAttachment.language);
    assertEquals("https://example.com/image/12498596132", urlAttachment.url);
}
Also used : HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) SampledData(org.mitre.synthea.engine.Components.SampledData) Attachment(org.mitre.synthea.engine.Components.Attachment) 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 3 with SampledData

use of org.mitre.synthea.engine.Components.SampledData in project synthea by synthetichealth.

the class ExportHelper method getObservationValue.

/**
 * Helper to get a readable string representation of an Observation's value.
 * Units are not included.
 *
 * @param observation The observation to get the value from
 * @return A human-readable string representation of observation.value
 */
public static String getObservationValue(Observation observation) {
    String value = null;
    if (observation.value instanceof Condition) {
        Code conditionCode = ((HealthRecord.Entry) observation.value).codes.get(0);
        value = conditionCode.display;
    } else if (observation.value instanceof Code) {
        value = ((Code) observation.value).display;
    } else if (observation.value instanceof String) {
        value = (String) observation.value;
    } else if (observation.value instanceof Double) {
        // round to 1 decimal place for display
        value = String.format(Locale.US, "%.1f", observation.value);
    } else if (observation.value instanceof SampledData) {
        value = sampledDataToValueString((SampledData) observation.value);
    } else if (observation.value instanceof Attachment) {
        value = attachmentToValueString((Attachment) observation.value);
    } else if (observation.value != null) {
        value = observation.value.toString();
    }
    return value;
}
Also used : Condition(org.hl7.fhir.dstu3.model.Condition) HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) SampledData(org.mitre.synthea.engine.Components.SampledData) Attachment(org.mitre.synthea.engine.Components.Attachment) Code(org.mitre.synthea.world.concepts.HealthRecord.Code)

Aggregations

SampledData (org.mitre.synthea.engine.Components.SampledData)3 HealthRecord (org.mitre.synthea.world.concepts.HealthRecord)3 Test (org.junit.Test)2 Attachment (org.mitre.synthea.engine.Components.Attachment)2 CardiovascularDiseaseModule (org.mitre.synthea.modules.CardiovascularDiseaseModule)2 DeathModule (org.mitre.synthea.modules.DeathModule)2 EncounterModule (org.mitre.synthea.modules.EncounterModule)2 LifecycleModule (org.mitre.synthea.modules.LifecycleModule)2 QualityOfLifeModule (org.mitre.synthea.modules.QualityOfLifeModule)2 WeightLossModule (org.mitre.synthea.modules.WeightLossModule)2 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)2 Condition (org.hl7.fhir.dstu3.model.Condition)1 TimeSeriesData (org.mitre.synthea.helpers.TimeSeriesData)1