FHIR Chat · Getting Observation.component.value · fhirpath

Stream: fhirpath

Topic: Getting Observation.component.value


view this post on Zulip Yunwei Wang (Dec 07 2021 at 21:19):

Kindly new here. So I want to write FHIRPath to get Observation.component.value for certain code. For example, only get Diastolic blood pressure. I am not sure if this is correct

Observation.component.where(code.coding.code = '8462-4').value

I am not sure code.coding.code='8462-4' means any coding has code 8462-4 or the first coding has code 8462-4

Thanks!

view this post on Zulip Lloyd McKenzie (Dec 07 2021 at 21:29):

It means any of the codings equal that value. (To be safe, you should always check system too.)

view this post on Zulip Brian Postlethwaite (Dec 07 2021 at 21:32):

And needs to have a where on the code.coding.where() as nerds to be restricted at each collection point.
Will try getting the exact expression when I get to my desk.

view this post on Zulip Yuan Peng (Jan 06 2022 at 10:28):

Hi everybody! i'm quite new to the topic of FHIR Path. I'm having a similar problem with Patient resource.
I used identifier.where(type.coding.code='MR').value to find the identifier, it works fine if there is only one coding inside type. However if there are more codings exist in type, the FHIR Path returns null.
Can someone please help? Thanks!

view this post on Zulip Lee Surprenant (Jan 06 2022 at 14:49):

maybe try something like this? identifier.where(type.coding.where(code='MR')).value

view this post on Zulip Yuan Peng (Jan 07 2022 at 06:58):

I've tried that, but somehow it's still not working.

view this post on Zulip Lloyd McKenzie (Jan 07 2022 at 18:09):

What engine are you using?

view this post on Zulip Yuan Peng (Jan 10 2022 at 07:25):

Lloyd McKenzie said:

What engine are you using?

I'm using the FHIR Path in a Java application. In the application we use the newest versions of ca.uhn.fhir.fhirpath.IFhirPath and org.hl7.fhir.r4.hapi.fluentpath.FhirPathR4 packages. We defined a FHIR Path as String and then use the method evaluate(org.hl7.fhir.instance.model.api.IBase theInput, String thePath, Class<T> theReturnType).

view this post on Zulip Lloyd McKenzie (Jan 10 2022 at 15:51):

@James Agnew

view this post on Zulip James Agnew (Jan 10 2022 at 15:57):

The path expression you gave above works for me. See:

http://hapi.fhir.org/baseR4/Observation/1574881?_fhirpath=Observation.component.where(code.coding.code%20=%20%278462-4%27).value

view this post on Zulip James Agnew (Jan 10 2022 at 16:00):

If this isn't working, can you post your data to the HAPI FHIR server and produce a link similar to mine to show the non-working FP expression? It's nice and easy to troubleshoot that way

view this post on Zulip Paul Lynch (Jan 10 2022 at 16:04):

Is _fhirpath a HAPI-only thing, or is it defined in an IG somewhere? It looks really useful.

view this post on Zulip James Agnew (Jan 10 2022 at 16:19):

It's just a HAPI FHIR thing. There is an interceptor you can add that layers on this functionality... Agree it's super useful :)

view this post on Zulip Alexander Zautke (Jan 10 2022 at 17:09):

@James Agnew Just saw the operation for the first time, immediately want to implement it in Firely Server. Pretty cool.

view this post on Zulip Brian Postlethwaite (Jan 10 2022 at 20:26):

In the Telstra server it's called https://sqlonfhir-r4.azurewebsites.net/fhir/Patient/example/$extract?expression=name.first()
(though I'm no longer happy with the operation name as it clashes now)

view this post on Zulip Brian Postlethwaite (Jan 10 2022 at 20:27):

Funny that we both returned a parameters object!

view this post on Zulip Alexander Zautke (Jan 10 2022 at 20:38):

Sorry if it's too off-topic for the current thread... would there be interest in defining it as a core operation?

view this post on Zulip Yuan Peng (Jan 13 2022 at 07:14):

James Agnew said:

If this isn't working, can you post your data to the HAPI FHIR server and produce a link similar to mine to show the non-working FP expression? It's nice and easy to troubleshoot that way

I've tried it with my 'problematic' Patient resource, and it did not working:
https://hapi.fhir.org/baseR4/Patient/2782733?_fhirpath=Patient.identifier.where(type.coding.where(code=%27MR%27)).value
https://hapi.fhir.org/baseR4/Patient/2782733?_fhirpath=Patient.identifier.where(type.coding.code=%27MR%27).value

view this post on Zulip Brian Postlethwaite (Jan 14 2022 at 02:12):

That query looks good to me, and works on the fhirpathtester, and if I was doing that, you probably should also include the system too.
image.png
Maybe an issue with the java fhirpath implementation?

view this post on Zulip Brian Postlethwaite (Jan 14 2022 at 02:13):

To make this work with the HAPI engine, try this one:
https://hapi.fhir.org/baseR4/Patient/2782733?_fhirpath=Patient.identifier.where(type.coding.where(code=%27MR%27).exists()).value
the inclusion of the .exists() on the check for the coding seems to make that work nicely.

view this post on Zulip Yuan Peng (Jan 14 2022 at 08:33):

It works! Thanks a lot! @Brian Postlethwaite


Last updated: Apr 12 2022 at 19:14 UTC