ModelResolver class abstract
The boundary between FHIR-version-specific code and the CQL engine.
Implementations of this interface are the only place in fhir_cql
where package:fhir_r4 / package:fhir_r5 / package:fhir_r6 (and the
matching _path packages) may be imported. The engine itself works
exclusively in CQL System types (see lib/engine/types/) plus raw
Map<String, dynamic> FHIR JSON — never typed FHIR classes.
This mirrors the ModelResolver interface from the canonical Java
reference implementation
cqframework/clinical_quality_language
(Src/java/engine/src/commonMain/kotlin/org/opencds/cqf/cql/engine/model/ModelResolver.kt)
and the FHIRWrapper pattern from the JavaScript reference
cqframework/cql-exec-fhir.
Rules for implementers
-
Use the modern FHIRPath entry point only:
FHIRPathEngine.create(WorkerContext(), hostServices).parse(expr) .evaluateWithContext(...). Never use or referencewalkFhirPath/executeFhirPath— these are legacy petitparser-era shims that silently mis-handle host-services and lazy variable scenarios. Seefeedback_no_walkfhirpathin memory. -
Convert FHIR-typed values to CQL System types eagerly at the boundary. Once a value flows into the engine via resolvePath or toCqlSystemType, it must be either a CQL System type, a plain
Map<String, dynamic>FHIR JSON, or a primitiveString/num/bool. The engine must not seefhir_r4.FhirDateTimeetc. -
Handle FHIR polymorphic field resolution (
effective→effectiveDateTime/effectivePeriod/effectiveTiming/effectiveInstant,value→valueQuantity/valueString/ …,onset→onsetDateTime/onsetAge/ …, etc.) inside resolvePath. The set of polymorphic prefixes is documented per FHIR version in the model_info files.
Constructors
Properties
- fhirVersion → String
-
FHIR version targeted, matching the CQL
using FHIR versiondeclaration. Examples:'4.0.1','5.0.0','6.0.0-ballot2'.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
-
packageNames
→ List<
String> -
Type-system namespace URI(s) this resolver answers for. CQL type
specifiers carry a
namespace.namespaceURI; the engine dispatches to the resolver whose packageNames includes that URI.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
as_(
dynamic value, String typeName, {bool isStrict = false}) → dynamic -
Returns
valuecast totypeNameif compatible, otherwise: -
createInstance(
String typeName) → dynamic -
Creates an empty instance of the type named
typeName. Used by CQL's instance-construction expression ({ field1: ..., field2: ... }typed to a named type) and by the parameter system. -
fromCqlSystemType(
dynamic value, [String? fhirTypeName]) → dynamic - Inverse of toCqlSystemType: convert a CQL System value back to a FHIR-typed value (or FHIR JSON Map) for return to user code.
-
getContextPath(
String? contextType, String? targetType) → String? -
Returns the path on a resource of
targetTypethat links it to a resource ofcontextType(the CQLcontextdeclaration's anchor). -
is_(
dynamic value, String typeName) → bool? -
Returns
trueifvalueis an instance of the FHIR or System type namedtypeNamein this resolver's package(s). -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
objectEqual(
dynamic left, dynamic right) → bool? -
Three-valued deep equality. Returns
true/falsewhen comparable;nullwhen either operand is null and the spec demands propagation. -
objectEquivalent(
dynamic left, dynamic right) → bool? -
CQL
~operator on FHIR-typed values. Type-aware equivalence per the FHIR datatypes specification (e.g.Quantityignores comparator/unit canonicalization;Periodis start-exclusive/end-inclusive). -
resolveId(
dynamic target) → String? -
Returns the resource id of
targetif it's a FHIR resource, elsenull. -
resolvePath(
dynamic source, String path) → Future - Resolves a single property path on a source object.
-
resolveType(
String typeName) → Type? -
Resolves
typeName(in this resolver's namespace) to a DartTypesuitable for reflection / instance creation. Returnsnullif unknown. -
resolveTypeOf(
dynamic value) → String? -
Returns the type name for
valuein this resolver's namespace, e.g.'Patient'for a FHIR Patient resource,'DateTime'for a CqlDateTime. Returnsnullifvaluedoesn't map. -
resolveTypePath(
String path) → ({bool isList, String type})? -
Resolves the static type of a dotted model path such as
Observation.valueorPatient.name, for return-type inference (used by the engine'sProperty.getReturnTypes). -
setValue(
dynamic target, String path, dynamic value) → dynamic -
Sets the value at
pathontargettovalue, returning the modified target. Used by the engine forset/ output-parameter scenarios. -
toCqlSystemType(
dynamic value) → dynamic - Converts a FHIR-typed value (or raw FHIR JSON Map) to its corresponding CQL System type at the engine boundary.
-
toElementMap(
dynamic value) → Map< String, dynamic> ? -
Decomposes a model object into its child elements as a FHIR-JSON
name → valuemap, or returnsnullifvalueis not a model object. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited