From 6ea6748b9ec635245509975dc9811b0d695b3c26 Mon Sep 17 00:00:00 2001 From: John Grimes Date: Thu, 17 Jan 2019 08:03:09 +1000 Subject: [PATCH] Support OID data type --- .../bunsen/stu3/Stu3DataTypeMappings.scala | 1 + .../cerner/bunsen/stu3/FhirEncodersTest.java | 17 +++++++++++++ .../java/com/cerner/bunsen/stu3/TestData.java | 25 +++++++++++++++++++ python/tests/test_bunsen_r4.py | 1 + python/tests/test_bunsen_stu3.py | 1 + 5 files changed, 45 insertions(+) diff --git a/bunsen-stu3/src/main/scala/com/cerner/bunsen/stu3/Stu3DataTypeMappings.scala b/bunsen-stu3/src/main/scala/com/cerner/bunsen/stu3/Stu3DataTypeMappings.scala index 8435c8a5..4855dfc6 100644 --- a/bunsen-stu3/src/main/scala/com/cerner/bunsen/stu3/Stu3DataTypeMappings.scala +++ b/bunsen-stu3/src/main/scala/com/cerner/bunsen/stu3/Stu3DataTypeMappings.scala @@ -39,6 +39,7 @@ class Stu3DataTypeMappings extends DataTypeMappings { classOf[CodeType] -> DataTypes.StringType, classOf[StringType] -> DataTypes.StringType, classOf[UriType] -> DataTypes.StringType, + classOf[OidType] -> DataTypes.StringType, classOf[IntegerType] -> DataTypes.IntegerType, classOf[UnsignedIntType] -> DataTypes.IntegerType, classOf[PositiveIntType] -> DataTypes.IntegerType, diff --git a/bunsen-stu3/src/test/java/com/cerner/bunsen/stu3/FhirEncodersTest.java b/bunsen-stu3/src/test/java/com/cerner/bunsen/stu3/FhirEncodersTest.java index 0387baba..606d46ec 100644 --- a/bunsen-stu3/src/test/java/com/cerner/bunsen/stu3/FhirEncodersTest.java +++ b/bunsen-stu3/src/test/java/com/cerner/bunsen/stu3/FhirEncodersTest.java @@ -18,6 +18,7 @@ import org.hl7.fhir.dstu3.model.Coding; import org.hl7.fhir.dstu3.model.Condition; import org.hl7.fhir.dstu3.model.DateTimeType; +import org.hl7.fhir.dstu3.model.ImagingStudy; import org.hl7.fhir.dstu3.model.IntegerType; import org.hl7.fhir.dstu3.model.Medication; import org.hl7.fhir.dstu3.model.MedicationRequest; @@ -60,6 +61,10 @@ public class FhirEncodersTest { private static Dataset medDataset; private static MedicationRequest decodedMedRequest; + private static ImagingStudy imagingStudy = TestData.newImagingStudy(); + private static Dataset imagingStudyDataset; + private static ImagingStudy decodedImagingStudy; + /** * Set up Spark. */ @@ -85,6 +90,10 @@ public static void setUp() { medDataset = spark.createDataset(ImmutableList.of(medRequest), encoders.of(MedicationRequest.class, Medication.class, Provenance.class)); decodedMedRequest = medDataset.head(); + + imagingStudyDataset = spark + .createDataset(ImmutableList.of(imagingStudy), encoders.of(ImagingStudy.class)); + decodedImagingStudy = imagingStudyDataset.head(); } /** @@ -333,4 +342,12 @@ public void testEncoderCached() throws IOException { Assert.assertSame(encoders.of(Patient.class), encoders.of(Patient.class)); } + + @Test + public void testOid() { + Assert.assertEquals(imagingStudy.getUid(), + imagingStudyDataset.select("uid").head().get(0)); + Assert.assertEquals(imagingStudy.getUid(), + decodedImagingStudy.getUid()); + } } diff --git a/bunsen-stu3/src/test/java/com/cerner/bunsen/stu3/TestData.java b/bunsen-stu3/src/test/java/com/cerner/bunsen/stu3/TestData.java index 681467fb..52868934 100644 --- a/bunsen-stu3/src/test/java/com/cerner/bunsen/stu3/TestData.java +++ b/bunsen-stu3/src/test/java/com/cerner/bunsen/stu3/TestData.java @@ -1,11 +1,16 @@ package com.cerner.bunsen.stu3; import com.google.common.collect.ImmutableList; +import java.util.ArrayList; +import java.util.List; import org.hl7.fhir.dstu3.model.Annotation; import org.hl7.fhir.dstu3.model.CodeableConcept; +import org.hl7.fhir.dstu3.model.Coding; import org.hl7.fhir.dstu3.model.Condition; import org.hl7.fhir.dstu3.model.DateTimeType; import org.hl7.fhir.dstu3.model.Identifier; +import org.hl7.fhir.dstu3.model.ImagingStudy; +import org.hl7.fhir.dstu3.model.ImagingStudy.ImagingStudySeriesComponent; import org.hl7.fhir.dstu3.model.IntegerType; import org.hl7.fhir.dstu3.model.Medication; import org.hl7.fhir.dstu3.model.Medication.MedicationIngredientComponent; @@ -13,6 +18,7 @@ import org.hl7.fhir.dstu3.model.MedicationRequest; import org.hl7.fhir.dstu3.model.Narrative; import org.hl7.fhir.dstu3.model.Observation; +import org.hl7.fhir.dstu3.model.OidType; import org.hl7.fhir.dstu3.model.Patient; import org.hl7.fhir.dstu3.model.Procedure; import org.hl7.fhir.dstu3.model.Provenance; @@ -192,4 +198,23 @@ public static MedicationRequest newMedRequest() { return medReq; } + + /** + * Returns a FHIR ImagingStudy resource for testing purposes. + */ + public static ImagingStudy newImagingStudy() { + ImagingStudy imagingStudy = new ImagingStudy(); + + imagingStudy.setId("test-imaging-study"); + imagingStudy.setUid("1.3.12.2.1107.5.1.4.45533.30000008102706401187500000052"); + imagingStudy.setPatient(new Reference("Patient/test-patient")); + List series = new ArrayList<>(); + ImagingStudySeriesComponent seriesComponent = new ImagingStudySeriesComponent( + new OidType("1.3.12.2.1107.5.1.4.45533.30000008102706401187500000053"), + new Coding("http://dicom.nema.org/resources/ontology/DCM", "HD", "Hemodynamic Waveform")); + series.add(seriesComponent); + imagingStudy.setSeries(series); + + return imagingStudy; + } } diff --git a/python/tests/test_bunsen_r4.py b/python/tests/test_bunsen_r4.py index 1bc33dee..068b868c 100644 --- a/python/tests/test_bunsen_r4.py +++ b/python/tests/test_bunsen_r4.py @@ -50,6 +50,7 @@ def spark_session(request): spark = SparkSession.builder \ .appName('bunsen-test') \ .master('local[2]') \ + .config('spark.driver.host', 'localhost') \ .config('spark.jars', shaded_jar) \ .config('hive.exec.dynamic.partition.mode', 'nonstrict') \ .config('spark.sql.warehouse.dir', mkdtemp()) \ diff --git a/python/tests/test_bunsen_stu3.py b/python/tests/test_bunsen_stu3.py index 31a99570..49aa3296 100644 --- a/python/tests/test_bunsen_stu3.py +++ b/python/tests/test_bunsen_stu3.py @@ -50,6 +50,7 @@ def spark_session(request): spark = SparkSession.builder \ .appName('bunsen-test') \ .master('local[2]') \ + .config('spark.driver.host', 'localhost') \ .config('spark.jars', shaded_jar) \ .config('hive.exec.dynamic.partition.mode', 'nonstrict') \ .config('spark.sql.warehouse.dir', mkdtemp()) \