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