From ca7a2ba4e4a30093abd3ea4a8be06ff300ec72f6 Mon Sep 17 00:00:00 2001 From: oliveregger Date: Mon, 8 Jul 2024 23:20:32 +0200 Subject: [PATCH] add testcase for #1583 --- .../java/org/hl7/fhir/r5/test/CDARoundTripTests.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/CDARoundTripTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/CDARoundTripTests.java index 555a21bc5..444bf66a1 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/CDARoundTripTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/CDARoundTripTests.java @@ -1,5 +1,7 @@ package org.hl7.fhir.r5.test; +import static org.junit.Assert.assertEquals; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -26,10 +28,10 @@ public class CDARoundTripTests { @BeforeAll public static void setUp() throws Exception { FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager.Builder().build(); - context = new SimpleWorkerContext(TestingUtilities.getWorkerContext(pcm.loadPackage("hl7.fhir.r4.core", "4.0.1"))); + context = new SimpleWorkerContext(TestingUtilities.getWorkerContext(pcm.loadPackage("hl7.fhir.r5.core", "5.0.0"))); fp = new FHIRPathEngine(context); - NpmPackage npm = new FilesystemPackageCacheManager.Builder().build().loadPackage("hl7.cda.uv.core", "current"); + NpmPackage npm = new FilesystemPackageCacheManager.Builder().build().loadPackage("hl7.cda.uv.core", "2.0.0-sd"); context.loadFromPackage(npm, null); } @@ -186,6 +188,7 @@ public class CDARoundTripTests { Assertions.assertEquals("LOINC", fp.evaluateToString(null, cdaExample, cdaExample, cdaExample, fp.parse("ClinicalDocument.code.codeSystemName"))); Assertions.assertEquals("Episode Note", fp.evaluateToString(null, cdaExample, cdaExample, cdaExample, fp.parse("ClinicalDocument.title.xmlText"))); Assertions.assertEquals("Episode Note", fp.evaluateToString(null, cdaExample, cdaExample, cdaExample, fp.parse("ClinicalDocument.title.ofType(CDA.ST).xmlText"))); + Assertions.assertEquals("Levin", fp.evaluateToString(null, cdaExample, cdaExample, cdaExample, fp.parse("ClinicalDocument.recordTarget.patientRole.patient.name.item.family.xmlText"))); } @Test @@ -203,6 +206,9 @@ public class CDARoundTripTests { ByteArrayOutputStream baosXml = new ByteArrayOutputStream(); Manager.compose(context, cda, baosXml, FhirFormat.XML, OutputStyle.PRETTY, null); + String result = baosXml.toString(); + // https://github.com/hapifhir/org.hl7.fhir.core/issues/1583 + assertEquals(-1,result.indexOf("")); Element cdaXmlRoundtrip = Manager.parseSingle(context, new ByteArrayInputStream(baosXml.toString().getBytes()), FhirFormat.XML); assertsExample(cdaXmlRoundtrip); }