-
Type:
Technical Correction
-
Resolution: Persuasive
-
Priority:
Medium
-
FHIR Core (FHIR)
-
R5
-
FHIR Infrastructure
-
DomainResource
-
Correction
The current Schematron implementation of dom-3 is technically invalid.
The fhirPath expression says:
contained.where((('#'+id in (%resource.descendants().reference | %resource.descendants().as(canonical) | %resource.descendants().as(uri) | %resource.descendants().as(url))) or descendants().where(reference = '#').exists() or descendants().where(as(canonical) = '#').exists() or descendants().where(as(canonical) = '#').exists()).not()).trace('unmatched', id).empty()
And the Schematron expression says:
not(exists(for $id in f:contained/*/f:id/@value return $contained[not(parent::*/descendant::f:reference/@value=concat('#', $contained/*/id/@value) or descendant::f:reference[@value='#'])]))
It declares $id as variable and then tries to use $contained. The correct statement would be:
not(exists(for $id in f:contained/*/f:id/@value return $id[not(parent::*/descendant::f:reference/@value=concat('#', $id/*/id/@value) or descendant::f:reference[@value='#'])]))