From f36067c058c68483ced0e02fe40a328a7c0af9d4 Mon Sep 17 00:00:00 2001 From: Jason Walonoski Date: Fri, 24 Jun 2022 16:09:24 -0400 Subject: [PATCH] Update US Core v4 export and enforce physiology usage more consistently. --- config/simulations/ecg.yml | 4 ++-- .../org/mitre/synthea/engine/Components.java | 2 +- .../java/org/mitre/synthea/export/FhirR4.java | 2 +- .../mitre/synthea/helpers/TimeSeriesData.java | 3 ++- .../synthea/modules/LifecycleModule.java | 2 +- src/main/resources/us_core_mapping.csv | 19 +++++++++---------- .../java/org/mitre/synthea/TestHelper.java | 9 ++++++++- .../synthea/export/FHIRDSTU2ExporterTest.java | 14 +++++++------- .../synthea/export/FHIRR4ExporterTest.java | 15 +++++++-------- .../synthea/export/FHIRSTU3ExporterTest.java | 14 +++++++------- 10 files changed, 45 insertions(+), 39 deletions(-) diff --git a/config/simulations/ecg.yml b/config/simulations/ecg.yml index c0ff188309..e02a2077c7 100755 --- a/config/simulations/ecg.yml +++ b/config/simulations/ecg.yml @@ -37,7 +37,7 @@ charts: axisParamX: time axisLabelX: time (s) axisLabelY: Current (A) - lowerBoundY: -0.05 - upperBoundY: 0.15 + #lowerBoundY: -0.05 + #upperBoundY: 0.15 series: - param: zf diff --git a/src/main/java/org/mitre/synthea/engine/Components.java b/src/main/java/org/mitre/synthea/engine/Components.java index c4c47eaa33..366820233f 100644 --- a/src/main/java/org/mitre/synthea/engine/Components.java +++ b/src/main/java/org/mitre/synthea/engine/Components.java @@ -101,7 +101,7 @@ public static class SampledData implements Serializable { public Double lowerLimit; // Lower limit of detection public Double upperLimit; // Upper limit of detection public List attributes; // Person attributes containing TimeSeriesData objects - public transient List series; // List of actual series data collections + public List series; // List of actual series data collections // Format for the output decimal numbers // See https://docs.oracle.com/javase/8/docs/api/java/text/DecimalFormat.html diff --git a/src/main/java/org/mitre/synthea/export/FhirR4.java b/src/main/java/org/mitre/synthea/export/FhirR4.java index ce93760d5d..c535f166f9 100644 --- a/src/main/java/org/mitre/synthea/export/FhirR4.java +++ b/src/main/java/org/mitre/synthea/export/FhirR4.java @@ -1654,7 +1654,7 @@ private static BundleEntryComponent observation(RandomNumberGenerator rand, if (codeMappingUri != null) { meta.addProfile(codeMappingUri); if (!codeMappingUri.contains("/us/core/") && observation.category.equals("vital-signs")) { - meta.addProfile("http://hl7.org/fhir/StructureDefinition/vitalsigns"); + meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-vital-signs"); } } else if (observation.report != null && observation.category.equals("laboratory")) { meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-observation-lab"); diff --git a/src/main/java/org/mitre/synthea/helpers/TimeSeriesData.java b/src/main/java/org/mitre/synthea/helpers/TimeSeriesData.java index 0de7eddf4a..af6bfeb88c 100755 --- a/src/main/java/org/mitre/synthea/helpers/TimeSeriesData.java +++ b/src/main/java/org/mitre/synthea/helpers/TimeSeriesData.java @@ -1,9 +1,10 @@ package org.mitre.synthea.helpers; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; -public class TimeSeriesData { +public class TimeSeriesData implements Serializable { /** Provides a collection of time series values as well as sampling metadata * concerning those values. */ diff --git a/src/main/java/org/mitre/synthea/modules/LifecycleModule.java b/src/main/java/org/mitre/synthea/modules/LifecycleModule.java index abe0904b32..3462d93a37 100644 --- a/src/main/java/org/mitre/synthea/modules/LifecycleModule.java +++ b/src/main/java/org/mitre/synthea/modules/LifecycleModule.java @@ -849,7 +849,7 @@ private static double reverseCalculateCreatinine(Person person, double crcl, lon Config.getAsBoolean("lifecycle.death_by_natural_causes"); protected static boolean ENABLE_DEATH_BY_LOSS_OF_CARE = Config.getAsBoolean("lifecycle.death_by_loss_of_care"); - protected static boolean ENABLE_PHYSIOLOGY_GENERATORS = + public static boolean ENABLE_PHYSIOLOGY_GENERATORS = Config.getAsBoolean("physiology.generators.enabled", false); // Death From Natural Causes SNOMED Code diff --git a/src/main/resources/us_core_mapping.csv b/src/main/resources/us_core_mapping.csv index 7ffa8cc5ec..99a5e6b588 100644 --- a/src/main/resources/us_core_mapping.csv +++ b/src/main/resources/us_core_mapping.csv @@ -4,13 +4,12 @@ SYSTEM,CODE,URL "http://loinc.org","72166-2","http://hl7.org/fhir/us/core/StructureDefinition/us-core-smokingstatus" "http://loinc.org","2708-6","http://hl7.org/fhir/us/core/StructureDefinition/us-core-pulse-oximetry" "http://loinc.org","59408-5","http://hl7.org/fhir/us/core/StructureDefinition/us-core-pulse-oximetry" -"http://loinc.org","85353-1","http://hl7.org/fhir/StructureDefinition/vitalspanel" -"http://loinc.org","9279-1","http://hl7.org/fhir/StructureDefinition/resprate" -"http://loinc.org","8867-4","http://hl7.org/fhir/StructureDefinition/heartrate" -"http://loinc.org","8310-5","http://hl7.org/fhir/StructureDefinition/bodytemp" -"http://loinc.org","8331-1","http://hl7.org/fhir/StructureDefinition/bodytemp" -"http://loinc.org","8302-2","http://hl7.org/fhir/StructureDefinition/bodyheight" -"http://loinc.org","9843-4","http://hl7.org/fhir/StructureDefinition/headcircum" -"http://loinc.org","29463-7","http://hl7.org/fhir/StructureDefinition/bodyweight" -"http://loinc.org","39156-5","http://hl7.org/fhir/StructureDefinition/bmi" -"http://loinc.org","85354-9","http://hl7.org/fhir/StructureDefinition/bp" \ No newline at end of file +"http://loinc.org","9279-1","http://hl7.org/fhir/us/core/StructureDefinition/us-core-respiratory-rate" +"http://loinc.org","8867-4","http://hl7.org/fhir/us/core/StructureDefinition/us-core-heart-rate" +"http://loinc.org","8310-5","http://hl7.org/fhir/us/core/StructureDefinition/us-core-body-temperature" +"http://loinc.org","8302-2","http://hl7.org/fhir/us/core/StructureDefinition/us-core-body-height" +"http://loinc.org","9843-4","http://hl7.org/fhir/us/core/StructureDefinition/us-core-head-circumference" +"http://loinc.org","8289-1","http://hl7.org/fhir/us/core/StructureDefinition/head-occipital-frontal-circumference-percentile" +"http://loinc.org","29463-7","http://hl7.org/fhir/us/core/StructureDefinition/us-core-body-weight" +"http://loinc.org","39156-5","http://hl7.org/fhir/us/core/StructureDefinition/us-core-bmi" +"http://loinc.org","85354-9","http://hl7.org/fhir/us/core/StructureDefinition/us-core-blood-pressure" \ No newline at end of file diff --git a/src/test/java/org/mitre/synthea/TestHelper.java b/src/test/java/org/mitre/synthea/TestHelper.java index 9f24aee5fa..5afb1cedfa 100644 --- a/src/test/java/org/mitre/synthea/TestHelper.java +++ b/src/test/java/org/mitre/synthea/TestHelper.java @@ -18,6 +18,7 @@ import org.mitre.synthea.engine.Generator; import org.mitre.synthea.engine.Module; +import org.mitre.synthea.engine.State; import org.mitre.synthea.helpers.Config; import org.mitre.synthea.helpers.Utilities; import org.mitre.synthea.world.agents.Person; @@ -149,6 +150,10 @@ public static long years(long numYears) { public static synchronized Person[] getGeneratedPeople() throws IOException, ClassNotFoundException { if (serializedPatients == null) { + // Ensure Physiology state is enabled + boolean physStateEnabled = State.ENABLE_PHYSIOLOGY_STATE; + State.ENABLE_PHYSIOLOGY_STATE = true; + int numberOfPeople = 10; Generator generator = new Generator(numberOfPeople); generator.options.overflow = false; @@ -162,6 +167,9 @@ public static synchronized Person[] getGeneratedPeople() throws IOException, oos.writeObject(people); oos.close(); serializedPatients = baos.toByteArray(); + + // Reset state after exporter test. + State.ENABLE_PHYSIOLOGY_STATE = physStateEnabled; } ByteArrayInputStream bais = new ByteArrayInputStream(serializedPatients); ObjectInputStream ois = new ObjectInputStream(bais); @@ -169,5 +177,4 @@ public static synchronized Person[] getGeneratedPeople() throws IOException, ois.close(); return rehydrated; } - } \ No newline at end of file diff --git a/src/test/java/org/mitre/synthea/export/FHIRDSTU2ExporterTest.java b/src/test/java/org/mitre/synthea/export/FHIRDSTU2ExporterTest.java index 6beab88288..a6418e09e7 100644 --- a/src/test/java/org/mitre/synthea/export/FHIRDSTU2ExporterTest.java +++ b/src/test/java/org/mitre/synthea/export/FHIRDSTU2ExporterTest.java @@ -23,8 +23,8 @@ import org.apache.commons.codec.binary.Base64; import org.hl7.fhir.dstu3.model.DiagnosticReport; -import org.junit.After; -import org.junit.Before; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -46,7 +46,7 @@ * Uses HAPI FHIR project to validate FHIR export. http://hapifhir.io/doc_validation.html */ public class FHIRDSTU2ExporterTest { - private boolean physStateEnabled; + private static boolean physStateEnabled; /** * Temporary folder for any exported files, guaranteed to be deleted at the end of the test. @@ -57,8 +57,8 @@ public class FHIRDSTU2ExporterTest { /** * Setup state for exporter test. */ - @Before - public void setup() { + @BeforeClass + public static void setup() { // Ensure Physiology state is enabled physStateEnabled = State.ENABLE_PHYSIOLOGY_STATE; State.ENABLE_PHYSIOLOGY_STATE = true; @@ -67,8 +67,8 @@ public void setup() { /** * Reset state after exporter test. */ - @After - public void tearDown() { + @AfterClass + public static void tearDown() { State.ENABLE_PHYSIOLOGY_STATE = physStateEnabled; } diff --git a/src/test/java/org/mitre/synthea/export/FHIRR4ExporterTest.java b/src/test/java/org/mitre/synthea/export/FHIRR4ExporterTest.java index 9998317fd9..f560b6e5a6 100644 --- a/src/test/java/org/mitre/synthea/export/FHIRR4ExporterTest.java +++ b/src/test/java/org/mitre/synthea/export/FHIRR4ExporterTest.java @@ -18,13 +18,12 @@ import org.apache.commons.codec.binary.Base64; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent; -import org.hl7.fhir.r4.model.DocumentReference; import org.hl7.fhir.r4.model.Media; import org.hl7.fhir.r4.model.Observation; import org.hl7.fhir.r4.model.Quantity; import org.hl7.fhir.r4.model.SampledData; -import org.junit.After; -import org.junit.Before; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -47,7 +46,7 @@ * Uses HAPI FHIR project to validate FHIR export. http://hapifhir.io/doc_validation.html */ public class FHIRR4ExporterTest { - private boolean physStateEnabled; + private static boolean physStateEnabled; /** * Temporary folder for any exported files, guaranteed to be deleted at the end of the test. @@ -58,8 +57,8 @@ public class FHIRR4ExporterTest { /** * Setup state for exporter test. */ - @Before - public void setup() { + @BeforeClass + public static void setup() { // Ensure Physiology state is enabled physStateEnabled = State.ENABLE_PHYSIOLOGY_STATE; State.ENABLE_PHYSIOLOGY_STATE = true; @@ -68,8 +67,8 @@ public void setup() { /** * Reset state after exporter test. */ - @After - public void tearDown() { + @AfterClass + public static void tearDown() { State.ENABLE_PHYSIOLOGY_STATE = physStateEnabled; } diff --git a/src/test/java/org/mitre/synthea/export/FHIRSTU3ExporterTest.java b/src/test/java/org/mitre/synthea/export/FHIRSTU3ExporterTest.java index 1bed72e3ec..7a2511bc09 100644 --- a/src/test/java/org/mitre/synthea/export/FHIRSTU3ExporterTest.java +++ b/src/test/java/org/mitre/synthea/export/FHIRSTU3ExporterTest.java @@ -23,9 +23,9 @@ import org.hl7.fhir.dstu3.model.Observation; import org.hl7.fhir.dstu3.model.Quantity; import org.hl7.fhir.dstu3.model.SampledData; -import org.junit.After; +import org.junit.AfterClass; import org.junit.Assert; -import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -48,7 +48,7 @@ * Uses HAPI FHIR project to validate FHIR export. http://hapifhir.io/doc_validation.html */ public class FHIRSTU3ExporterTest { - private boolean physStateEnabled; + private static boolean physStateEnabled; /** * Temporary folder for any exported files, guaranteed to be deleted at the end of the test. @@ -59,8 +59,8 @@ public class FHIRSTU3ExporterTest { /** * Setup state for exporter test. */ - @Before - public void setup() { + @BeforeClass + public static void setup() { // Ensure Physiology state is enabled physStateEnabled = State.ENABLE_PHYSIOLOGY_STATE; State.ENABLE_PHYSIOLOGY_STATE = true; @@ -69,8 +69,8 @@ public void setup() { /** * Reset state after exporter test. */ - @After - public void tearDown() { + @AfterClass + public static void tearDown() { State.ENABLE_PHYSIOLOGY_STATE = physStateEnabled; }