Stream: fhirpath
Topic: tim-9
Michael Calderero (Feb 25 2020 at 02:58):
Hi All,
We're trying to validate the CarePlan below across all the public test servers. [baseurl]/CarePlan/$validate?profile=http://hl7.org/fhir/StructureDefinition/CarePlan
HAPI FHIR, Aegis WildFHIR, test.fhir.org all report that this resource is OK.
However, vonk says that
{
"severity": "error",
"code": "invariant",
"details": {
"coding": [
{
"system": "http://hl7.org/fhir/dotnet-api-operation-outcome",
"code": "1012"
}
],
"text": "Instance failed constraint tim-9 \"If there's an offset, there must be a when (and not C, CM, CD, CV)\""
},
"diagnostics": "offset.empty() or (when.exists() and ((when in ('C' | 'CM' | 'CD' | 'CV')).not()))",
"location": [
"CarePlan.activity[1].detail[0].scheduledTiming[0].repeat[0]"
]
}
I believe this is triggered by the when in ... part of the FHIRPath expression. I looked at the spec here: http://hl7.org/fhirpath/N1/index.html#in-membership and it says that "If the left operand has multiple items, an exception is thrown." I can verify this is the case since if I change when to only contain a single value, vonk reports the validation didn't find any errors.
Since when indeed contains multiple items in this case, I believe Vonk is right and the others wrong. Can anyone comment and confirm on what is the correct behavior?
Note: The description for the in operator seems to have been unchanged since version http://hl7.org/fhirpath/2018May/index.html#collections-2
This would mean FHIR STU3 and R4 are affected.
I would guess the implementations of contains operator are affected as well.
{
"resourceType": "CarePlan",
"id": "example",
"text": {
"status": "additional",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">test careplan</div>"
},
"status": "active",
"intent": "plan",
"subject": {
"reference": "Patient/123"
},
"activity": [
{
"reference": {
"display": "Prenatal vitamin MedicationRequest"
}
},
{
"detail": {
"kind": "Appointment",
"code": {
"coding": [
{
"system": "http://example.org/mySystem",
"code": "1an"
}
],
"text": "First Antenatal encounter"
},
"status": "scheduled",
"doNotPerform": false,
"scheduledTiming": {
"repeat": {
"boundsPeriod": {
"start": "2013-02-14",
"end": "2013-02-28"
},
"offset": 1,
"when": [
"ACM",
"AC"
]
}
},
"description": "The first antenatal encounter. This is where a detailed physical examination is performed. and the pregnanacy discussed with the mother-to-be."
}
}
]
}
Grahame Grieve (Feb 25 2020 at 03:19):
you're right. I don't think that the definition of opIn and opContains are correct, in that a set can still be in another set (@Bryn Rhodes) and that's how I implemented it. The invariant is definitely wrong given the FHIRPath definition. Added here: https://confluence.hl7.org/display/FHIR/Known+Issues+with+the+published+FHIR+Specifications
Bryn Rhodes (Feb 25 2020 at 03:49):
Hmmm... don't you still need to be able to ask if a list is in a list of lists? If we add an overload of in to take a list for both operands, we wouldn't be able to distinguish that case, right? We defined in(T, List<T>) and contains(List<T>, T). I think to properly support this use case, we'd need list-level operations: includedIn(List<T>, List<T>) and includes(List<T>, List<T>).
Grahame Grieve (Feb 25 2020 at 03:50):
I guess
Last updated: Apr 12 2022 at 19:14 UTC