FHIR
FHIR copied to clipboard
Support for the "exists" discriminator type
Is your feature request related to a problem? Please describe. In the LinuxForHealth "common data model" IG, they use a discriminator type that I don't think we've seen yet: "exists"
From https://linuxforhealth.github.io/cdm-fhir-ig/StructureDefinition-cdm-practitioner-role.html
Currently, we fail to generate an "antecedent" for this discriminator type which leads to invalid constraints.
Describe the solution you'd like Add support for the "exists" discriminator type so that the generated constraints for these slices work as expected
Describe alternatives you've considered
Acceptance Criteria
- GIVEN [a precondition] AND [another precondition] WHEN [test step] AND [test step] THEN [verification step] AND [verification step]
Additional context From https://build.fhir.org/valueset-discriminator-type.html
Code | System | Display | Definition |
---|---|---|---|
exists | http://hl7.org/fhir/discriminator-type | Exists | The slices are differentiated by the presence or absence of the nominated element. There SHALL be no more than two slices. The slices are differentiated by the fact that one must have a max of 0 and the other must have a min of 1 (or more). The order in which the slices are declared doesn't matter. |
currently an "exists" discriminator leads us to generate constraints with a missing antecendent: .exists() implies ...
after the proposed change in #4073 to generate exists and negated exists checks for the path that is given in the slice definition. for the CDM screenshot above, that now generates constraints like the following:
code.where(coding.exists()).exists() implies (code.where(coding.exists()).count() = 1 and code.where(coding.exists()).all((coding.where(system = 'http://nucc.org/provider-taxonomy').exists() implies (coding.where(system = 'http://nucc.org/provider-taxonomy').count() = 1 and coding.where(system = 'http://nucc.org/provider-taxonomy').all(system = 'http://nucc.org/provider-taxonomy' and code.exists()))) and (coding.where(system = 'http://linuxforhealth.org/fhir/cdm/CodeSystem/nucc-provider-taxonomy-type').exists() implies (coding.where(system = 'http://linuxforhealth.org/fhir/cdm/CodeSystem/nucc-provider-taxonomy-type').count() = 1 and coding.where(system = 'http://linuxforhealth.org/fhir/cdm/CodeSystem/nucc-provider-taxonomy-type').all(system = 'http://linuxforhealth.org/fhir/cdm/CodeSystem/nucc-provider-taxonomy-type' and code.exists()))) and (coding.where(system = 'http://linuxforhealth.org/fhir/cdm/CodeSystem/payer-provider-type').exists() implies (coding.where(system = 'http://linuxforhealth.org/fhir/cdm/CodeSystem/payer-provider-type').count() = 1 and coding.where(system = 'http://linuxforhealth.org/fhir/cdm/CodeSystem/payer-provider-type').all(system = 'http://linuxforhealth.org/fhir/cdm/CodeSystem/payer-provider-type' and code.exists() and code.all(memberOf('http://linuxforhealth.org/fhir/cdm/ValueSet/practitioner-role-type', 'preferred')))))))
code.where(coding.exists().not()).exists() implies (code.where(coding.exists().not()).count() = 1 and code.where(coding.exists().not()).all(coding.exists().not() and text.exists()))