Skip to content

Commit

Permalink
FML performance testcase #264
Browse files Browse the repository at this point in the history
  • Loading branch information
oliveregger committed Oct 16, 2024
1 parent 2af3b1c commit c35274e
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}

}
13 changes: 13 additions & 0 deletions matchbox-engine/src/test/resources/mapping-language/bundleobs.map
Original file line number Diff line number Diff line change
@@ -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;
};
};
}

0 comments on commit c35274e

Please sign in to comment.