FHIR Chat · search: all ServiceRequests with no Task · implementers

Stream: implementers

Topic: search: all ServiceRequests with no Task


view this post on Zulip Patrick Werner (Feb 27 2019 at 11:15):

Is there a possibility for doing such a search in one request?:
All ServiceRequests which don't have a Task.basedOn pointing to them

view this post on Zulip Patrick Werner (Feb 27 2019 at 11:18):

i think i need a search filter (which our hapi doesn't support)

view this post on Zulip nicola (RIO/SS) (Feb 27 2019 at 12:18):

In aidbox you can use SQL on FHIR for that :)

view this post on Zulip Alexander Zautke (Feb 27 2019 at 19:32):

I don't see a way of creating such a query. _has in the regular search api does not accept any modifiers, like :not, therefore is not an option. In my opinion not even _filter would solve your issue. It is still an open question how to combine _filter and _has (See https://chat.fhir.org/#narrow/stream/179166-implementers/topic/_has.20.26.20_filter)

view this post on Zulip Alexander Zautke (Feb 27 2019 at 19:33):

@nicola (RIO/SS) Which parameter do you use for the sql statement? I'm interested in the solution!

view this post on Zulip nicola (RIO/SS) (Feb 28 2019 at 05:17):

select s.* from ServiceRequest s
left join Task t on s.id = t.resource#>>'{basedOn, id}'
where t.id is null;

view this post on Zulip Alexander Zautke (Feb 28 2019 at 06:17):

Sorry, I meant how do you pass this query from the client to the server in the REST API?

view this post on Zulip nicola (RIO/SS) (Feb 28 2019 at 09:18):

In aidbox you can create a stored query, which will be exposed as custom search parameter or custom operation

view this post on Zulip Christiaan Knaap (Feb 28 2019 at 09:20):

Sounds like _query

view this post on Zulip Patrick Werner (Feb 28 2019 at 16:29):

I don't see a way of creating such a query. _has in the regular search api does not accept any modifiers, like :not

_has with a :not modifier sounds great. Is there a strong argument against _has with a :not modifier?

view this post on Zulip Patrick Werner (Feb 28 2019 at 16:37):

i stumbled today on a related _has question:
How to query only Patients which have a Task pointing to them?
We ended up with: {{baseurl}}/Patient?_has:Task:patient:code=[some_code], which works fine. But how to get all Patients with a referencing Task without independent of a code or other criteria? {{baseurl}}/Patient?_has:Task:patientdoesn't work

view this post on Zulip Abbie Watson (Feb 28 2019 at 18:53):

You’re asking that joins be included in the API. Is that reasonable? Why not fetch all the Tasks, create an array of patientIds from them, and then fetch that array of Patients? You’re wanting the API to do something that it’s not really designed to do.

view this post on Zulip Alexander Zautke (Mar 01 2019 at 09:56):

@Patrick Werner You can always reverse chain on _id:missing=false. That's a criteria which should work without being an restriction to which resources to include. {{BASE_URL}}/Patient?_has:Task:patient:_id:missing=false

view this post on Zulip Alexander Zautke (Mar 01 2019 at 10:02):

Regarding your other question: As much as I would like to have a way of expressing these queries in FHIR, I am not in favour of adding more complexity to the current way reverse chaining is handled. It's hard enough to handle the current modifiers. I would guess that it would not be completely sufficient to 'just' have a :not modifier on _has, but that you want to go one more level deeper and even restrict this result set, e.g. '_has:Task:patient:not=false' + another condition.

view this post on Zulip Alexander Zautke (Mar 01 2019 at 10:04):

We should rather explore on how to make _filter work and start implementing it. Or follow @nicola (RIO/SS) idea of using SQL on FHIR.

view this post on Zulip Alexander Zautke (Mar 21 2019 at 10:37):

(deleted)

view this post on Zulip Marcelo Cabello (Aug 01 2019 at 12:14):

Hi, I'd created a query to retrieve the patients which have a DiagnosticReport where the code of diagnosis is XXX. So it's really simple to do following the examples, But it doesnt'work. The spec shows two search parameters to reference the Patient resource. So I tried that;
url/Patient?_has:DiagnosticReport:subject:code=[snomedCode]
url/Patient?_has:DiagnosticReport:patient:code=[snomedCode]

Some hint?

view this post on Zulip Grahame Grieve (Aug 01 2019 at 12:23):

what does doesn't work mean? which server?

view this post on Zulip Marcelo Cabello (Aug 01 2019 at 12:37):

I was trying on a local server based on hapi-fhir-jpaserver-starter.
I replied the same request on UHN/HAPI Server (both DSTU3 & R4) and works well!!
I notice the difference that Patients are in another server, wich maybe the references didn't resolved. I'll try again with local Patients to see what happens.
Thanks!!!

view this post on Zulip Marcelo Cabello (Aug 01 2019 at 16:02):

After move the Patients resources to my local endpoint and then update the references to patients in DiagnosticReport, the search works fine!


Last updated: Apr 12 2022 at 19:14 UTC