diff --git a/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/FhirMappingLanguageTests.java b/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/FhirMappingLanguageTests.java index 34e59b1b12..3da8caaf36 100644 --- a/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/FhirMappingLanguageTests.java +++ b/matchbox-engine/src/test/java/ch/ahdis/matchbox/engine/tests/FhirMappingLanguageTests.java @@ -1242,5 +1242,64 @@ void testTutorialStep13Json() throws FHIRException, IOException { CompareUtil.compare(getFileAsStringFromResources("/tutorial/step13/result/step13.source13.json"), result, false); } + @Test + void testBundleJson() throws FHIRException, IOException { + StringBuilder bundleBuilder = new StringBuilder(); + bundleBuilder.append(" {\n") + .append("\t\t\t\"resourceType\": \"Bundle\",\n") + .append("\t\t\t\"type\": \"collection\",\n") + .append("\t\t\t\"entry\": ["); + + for (int i=0; i < 10000; i++) { + if (i>0) { + bundleBuilder.append(","); + } + bundleBuilder.append(" {\n" + + " \"resource\": {\n" + + " \"resourceType\": \"Observation\",\n" + + " \"id\": \""+i+"\"\n" + + " \"component\": [\n" + + " {\n" + + " \"code\": {\n" + + " \"coding\": [\n" + + " {\n" + + " \"system\": \"http://loinc.org\",\n" + + " \"code\": \"8480-6\"\n" + + " }\n" + + " ]\n" + + " },\n" + + " \"valueQuantity\": {\n" + + " \"value\": " +i +"\n" + + " }\n" + // + " },\n" + // + " {\n" + // + " \"code\": {\n" + // + " \"coding\": [\n" + // + " {\n" + // + " \"system\": \"http://loinc.org\",\n" + // + " \"code\": \"8462-4\"\n" + // + " }\n" + // + " ]\n" + // + " },\n" + // + " \"valueQuantity\": {\n" + // + " \"value\": "+(i-1)+"\n" + // + " }\n" + // + " }\n" + // + " ]\n" + // + " }\n" + // + " }"); + } + bundleBuilder.append("]\n}"); + String bundle = bundleBuilder.toString(); + + StructureMap sm = engine.parseMap(getFileAsStringFromResources("/bundleobs.map")); + assertTrue(sm != null); + engine.addCanonicalResource(sm); + + String result = engine.transform(bundle, true, + "http://test.ch/DummyBundleToBundle", true); + assertTrue(result != null); + + } } diff --git a/matchbox-engine/src/test/resources/mapping-language/bundleobs.map b/matchbox-engine/src/test/resources/mapping-language/bundleobs.map new file mode 100644 index 0000000000..1bc3ad9618 --- /dev/null +++ b/matchbox-engine/src/test/resources/mapping-language/bundleobs.map @@ -0,0 +1,13 @@ +map "http://test.ch/DummyBundleToBundle" = "DummyBundleToBundle" + +uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as source +uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as target + +group bundleToBundle(source src : Bundle, target tgt: Bundle) { + src.entry as entry then { + entry.resource as obs where $this.ofType(FHIR.Observation) -> tgt.entry as e, + e.resource = create('Observation') as o, o.id = uuid() then { + obs.component as c -> o.component = c; + }; + }; +} \ No newline at end of file