Stream: fhirpath
Topic: fhirpath bug or bad expression
Jens Villadsen (Nov 01 2019 at 13:26):
I've written a fhirpath expression that works on https://hl7.github.io/fhirpath.js/ but not in the java FhirPath engine implementation. More specifically the following should evaluate to true (and does so on https://hl7.github.io/fhirpath.js/):
extension.where('http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-responsible').valueReference in participant.extension.where('http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-ext-careteam').valueReference or extension.where('http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-responsible').valueReference in participant.actor.reference
applied on
{ "resourceType":"Appointment", "meta":{ "profile":[ "http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-videoappointment" ] }, "extension":[ { "url":"http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-responsible", "valueReference":{ "reference":"http://organization.inttest.ehealth.sundhed.dk/fhir/CareTeam/63d82214-ee30-4e3c-a5d7-efa1a77acb06" } } ], "status":"booked", "appointmentType":{ "coding":[ { "system":"http://ehealth.sundhed.dk/cs/appointmenttype-codes", "code":"CHECKUP" } ] }, "reason":[ { "coding":[ { "system":"http://snomed.info/sct", "code":"219006" } ] } ], "description":"124ba7e4-558e-4cb1-b497-9e78bab45a7a", "start":"2019-11-01T14:07:20.901+01:00", "end":"2019-11-01T14:07:20.901+01:00", "participant":[ { "actor":{ "reference":"http://organization.inttest.ehealth.sundhed.dk/fhir/Practitioner/dc8a1213-99ff-4553-879d-295a0a431e8d" }, "status":"accepted" }, { "actor":{ "reference":"http://organization.inttest.ehealth.sundhed.dk/fhir/Practitioner/54283316-077e-4d71-8280-92256de1ab2c" }, "status":"accepted" }, { "extension":[ { "url":"http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-ext-careteam", "valueReference":{ "reference":"http://organization.inttest.ehealth.sundhed.dk/fhir/CareTeam/63d82214-ee30-4e3c-a5d7-efa1a77acb06" } } ] } ] }
Is my expression malformed or is it a bug in the Java implementation?
Jens Villadsen (Nov 01 2019 at 14:13):
apparently rewriting it to
(extension('http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-responsible').first().value.reference in participant.extension('http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-ext-careteam').first().value.reference) or (extension('http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-responsible').first().value.reference in participant.actor.reference)
made it work ... I can't however say how .... ?
Bryn Rhodes (Nov 01 2019 at 14:44):
This bit seems incorrect to me: extension.where('http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-responsible')
, because what this is saying is "extensions where _the string value 'http://...'", which depending on the strictness of your evaluator will either be interpreted as just "true", or a type error. The expressed passed to the where function is expected to evaluate to a boolean. The rewrite is actually using the extension()
function to access the extension.
Jens Villadsen (Nov 01 2019 at 14:45):
the rewrite also encapsulates both sides of the 'or' in parentheses which also seemed necessary
Bryn Rhodes (Nov 01 2019 at 14:49):
That bit doesn't seem right to me, you shouldn't need to put that in parentheses to get it to evaluate.
Jens Villadsen (Nov 01 2019 at 15:21):
removing 'first()' was also needed as soon as my test data was expanded
Paul Lynch (Nov 01 2019 at 16:26):
For the extension.where, I think you need "url=" in front of the URL in the "where" call, like:
extension.where(url = 'http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-responsible')...
Grahame Grieve (Nov 01 2019 at 20:26):
you can use either extension.where(url = '') or extension(''') as a short cut. won't work if you mix them. Also, valueReference is not a valid in FHIR Path - it's just value. So value.reference works
Paul Lynch (Nov 01 2019 at 20:31):
Also, valueReference is not a valid in FHIR Path - it's just value.
True, and that is an issue we haven't addressed yet in fhirpath.js, for which valueReference is still necessary.
Last updated: Apr 12 2022 at 19:14 UTC