Implement conformsTo - #109
Conversation
| The `conformsTo()` function supports the base FHIR profiles | ||
| (`http://hl7.org/fhir/StructureDefinition/<Type>`): the input element's type is compared to the | ||
| type named by the structure. Custom profiles (e.g. US Core) would require profile validation, | ||
| which is not implemented. Passing a custom profile URL results in an error, consistent with the |
There was a problem hiding this comment.
The spec does say this:
If the input is not a single item, the structure is empty, or the structure cannot be resolved to a valid profile, the result is empty.
so does it not mean we should return emtpy collection rather than throwing an error?
There was a problem hiding this comment.
Let me clarify, that's the current spec text, but R4 says:
If the structure cannot be resolved to a valid profile, an error is thrown
https://hl7.org/fhir/R4/fhirpath.html#functions
and testConformsTo3 expects an execution error for conformsTo('http://trash')
<test name="testConformsTo3" inputfile="patient-example.xml"><expression invalid="execution">conformsTo('http://trash')</expression></test>
so returning empty would fail conformance.
The doc link was pointing at the versionless (current, https://hl7.org/fhir/fhirpath.html#functions) spec though, which is misleading. I can fix the R4 link.
But main point is, do we want to follow the latest spec, or refer to R4?
We might want to refer to the latest spec, since it's the up to date spec.
Or, we might pick R4 bcz our test case refers to tests-fhir-r4.xml
There was a problem hiding this comment.
very good question - one thing to note is that this part of the spec is part of FHIR and not actually part of FHIRPath... and we DO have FHIR version specific implementations - we have FhirEngine.forR4 forR4B and forR5... so if we're to be really serious about this, we can actually implement different behaviors for different verions... but I'm not sure if it's worth the effort.
I don't have a super strong view here - but if we're not going to diverge between different fhir versions, it seems to make sense to implement the latest version.
Implements the FHIR-specific
conformsTo(structure)function (https://hl7.org/fhir/R4/fhirpath.html#functions) for the base FHIR profiles: a structure of the formhttp://hl7.org/fhir/StructureDefinition/<Type>is resolved to the type and compared against the input element's type.true/falsefor resolvable structures.Custom profiles would need profile validation, which is not implemented, this is documented in the readme.