fml-engine
A StructureMap engine for the FHIR Mapping Language: runs maps over FHIR JSON, the way the HL7 reference engine does.
- Passes the reference tests. Every JSON structure-mapping test of the FHIR test cases (12 of 12, R4B and R5).
- Converts FHIR versions. With the HL7 cross-version maps
and their ConceptMaps, it converts 2,863 of the 2,881 R4 specification examples that have a
map to R5: R4
medicationReferencebecomes the R5 CodeableReference, Encounterclassbecomes a list of CodeableConcepts, and so on. A code a ConceptMap does not know is left out, as the reference engine does, and reported inwarnings. - The whole language. Groups and
extends, source filters (type,where,check,log, list modes,default), targets that create or reuse elements (repeating, choice elements written asvalueReference,share), dependent groups, default groups chosen by type, imported maps, primitives with theiridand extensions, and rules with several sources. - Transforms:
create,copy,evaluate,truncate,cast,append,translate,reference,pointer,uuid,cc,c,id,cp,qty,escape(html, xml, json), and the IG's date and time transforms:toDateTime,toDate,toTimewith format patterns (dd/MM/yyyy HH:mm,MMMM d, yyyy, …) andunixToDateTime,unixToDate,unixToTime. Not yet:dateOp, which the IG lists without defining. - Produced resources. Resources a map creates outside the target (a
createwith no target element) come back inproduced, ready for a Bundle. - Follows the IG where it says more than the reference engine. Named groups and nested rules
after
thenboth run; a source'smin..maxis enforced;evaluatewith several values makes one target per value; a group name in several imported maps is an error;casttakesFHIR.andSystem.types and checks the value. - Debug trace.
with_trace(true)records the trace of the IG's debug page for$transform?debug=true:enter/step/exitevents with their depth, the position in the StructureMap (StructureMap.group[0].rule[2]) and the variables in scope.debug_parameterswrites theParametersresponse withtraceStatus(complete,truncated,stopped), the text range of each event (rows and UTF-16 columns, fromfml_model::Locations), and anoutcomewith the failure and where it happened, why events were left out, and values left out of the result. - Safe to run on maps you did not write.
Limitsbound the group depth, the rules run, the values created and the size of the trace; a flag cancels a run. Failures say what kind they are (ErrorKind) and where (position). - Pluggable. Structure definitions come from fml-check's
Definitions, FHIRPath from anExpressionsimplementation (thefhirpathfeature uses octofhir-fhirpath), imported maps from aMapResolver, ConceptMaps from aConceptMapResolver, and any other ConceptMap through aTranslateService($translateon a terminology server). ConceptMaps are found by URL and by the canonical URLs they replace.uuid()and new ids come from anIdGenerator(SequentialIdsmakes runs repeatable).
use ;
use ;
let definitions = new;
let expressions = new.await?;
let output = new
.with_maps // MapSet: StructureMaps for `imports`
.with_concept_maps // ConceptMapSet: for translate()
.with_limits // depth, rules, values, trace size
.transform
.await?;
println!; // also: output.produced, output.warnings
Part of fml-rs. Licensed under MIT or Apache-2.0.