Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Support OID data type #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -60,6 +61,10 @@ public class FhirEncodersTest {
private static Dataset<MedicationRequest> medDataset;
private static MedicationRequest decodedMedRequest;

private static ImagingStudy imagingStudy = TestData.newImagingStudy();
private static Dataset<ImagingStudy> imagingStudyDataset;
private static ImagingStudy decodedImagingStudy;

/**
* Set up Spark.
*/
Expand All @@ -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();
}

/**
Expand Down Expand Up @@ -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());
}
}
25 changes: 25 additions & 0 deletions bunsen-stu3/src/test/java/com/cerner/bunsen/stu3/TestData.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
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;
import org.hl7.fhir.dstu3.model.Medication.MedicationStatus;
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;
Expand Down Expand Up @@ -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<ImagingStudySeriesComponent> 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;
}
}
1 change: 1 addition & 0 deletions python/tests/test_bunsen_r4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()) \
Expand Down
1 change: 1 addition & 0 deletions python/tests/test_bunsen_stu3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()) \
Expand Down