diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e69de29bb..a8ca2abe6 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -0,0 +1 @@ +add test for Observation conversion from 10 to 40 diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_40/Observation10_40Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_40/Observation10_40Test.java new file mode 100644 index 000000000..fdf964d80 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_40/Observation10_40Test.java @@ -0,0 +1,31 @@ +package org.hl7.fhir.convertors.conv10_40; + +import org.hl7.fhir.convertors.VersionConvertorAdvisor40; +import org.hl7.fhir.convertors.VersionConvertor_10_40; +import org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.io.InputStream; + +public class Observation10_40Test { + @Test + @DisplayName("Test 10_40 Observation conversion") + public void testObservationConversion() throws IOException { + InputStream dstu2_input = this.getClass().getResourceAsStream("/0_observation_10.json"); + InputStream r4_exepected_input = this.getClass().getResourceAsStream("/0_observation_40.json"); + + org.hl7.fhir.dstu2.model.Observation dstu2 = (org.hl7.fhir.dstu2.model.Observation) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input); + VersionConvertorAdvisor40 advisor = new IGR2ConvertorAdvisor(); + org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor); + + org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser(); + org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input); + + Assertions.assertTrue(r4_expected.equalsDeep(r4_actual), + "Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected)); + } + +} diff --git a/org.hl7.fhir.convertors/src/test/resources/0_observation_10.json b/org.hl7.fhir.convertors/src/test/resources/0_observation_10.json new file mode 100644 index 000000000..8017c88ae --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/resources/0_observation_10.json @@ -0,0 +1,42 @@ +{ + "resourceType": "Observation", + "id": "fobafoba", + "status": "final", + "category": { + "coding": [ + { + "system": "http://hl7.org/fhir/observation-category", + "code": "laboratory", + "display": "Laboratory" + } + ], + "text": "Laboratory" + }, + "code": { + "coding": [ + { + "system": "http://loinc.org", + "code": "2885-2", + "display": "Protein [Mass/volume] in Serum or Plasma" + } + ], + "text": "PROTEIN,TOTAL" + }, + "subject": { + "display": "Mr shoko", + "reference": "other subject" + }, + "effectiveDateTime": "2016-04-12T05:57:00Z", + "issued": "2016-04-12T05:57:00Z", + "valueQuantity": { + "value": 5.5, + "unit": "g/dL", + "system": "http://unitsofmeasure.org", + "code": "g/dL" + }, + "referenceRange": [ + { + "text": "6.0 - 8.2" + } + ] +} diff --git a/org.hl7.fhir.convertors/src/test/resources/0_observation_40.json b/org.hl7.fhir.convertors/src/test/resources/0_observation_40.json new file mode 100644 index 000000000..2bec31579 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/resources/0_observation_40.json @@ -0,0 +1,44 @@ +{ + "resourceType": "Observation", + "id": "fobafoba", + "status": "final", + "category": [ + { + "coding": [ + { + "system": "http://hl7.org/fhir/observation-category", + "code": "laboratory", + "display": "Laboratory" + } + ], + "text": "Laboratory" + } + ], + "code": { + "coding": [ + { + "system": "http://loinc.org", + "code": "2885-2", + "display": "Protein [Mass/volume] in Serum or Plasma" + } + ], + "text": "PROTEIN,TOTAL" + }, + "subject": { + "display": "Mr shoko", + "reference": "other subject" + }, + "effectiveDateTime": "2016-04-12T05:57:00Z", + "issued": "2016-04-12T05:57:00Z", + "valueQuantity": { + "value": 5.5, + "unit": "g/dL", + "system": "http://unitsofmeasure.org", + "code": "g/dL" + }, + "referenceRange": [ + { + "text": "6.0 - 8.2" + } + ] +}