Stream: hapi
Topic: Query on extension
Dexter (Nov 25 2020 at 06:14):
Is there a way I can search for resources that have a certain extension value in them? For example, I'm storing a valueString in the Patient resource that can be YES or NO or MAYBE. How do I search for patients that have this value in the extension? The URL is 'baseURL/agree'
Marc Sandberg (Nov 25 2020 at 09:52):
I'm pretty sure you should build your own search parameter for this; https://hl7.org/fhir/domainresource.html#search
Patrick Werner (Nov 25 2020 at 14:39):
Marc Sandberg said:
I'm pretty sure you should build your own search parameter for this; https://hl7.org/fhir/domainresource.html#search
correct
Dexter (Nov 26 2020 at 04:25):
But I read that for a search extension, I'll need to modify the server code?
Dexter (Nov 26 2020 at 05:56):
I think I was successful in making a search extension, how do I use it now?
David Hay (Nov 26 2020 at 06:29):
IIRC You create a SearchParameter resource and save to hapi. After that it will recognise the new search.
Dexter (Nov 26 2020 at 06:38):
I did create a search parameter (thanks for pointing me to the right resource!), but not sure if it's correct, and how to use it. May I paste the request body here?
David Hay (Nov 26 2020 at 23:37):
sure....
Dexter (Nov 27 2020 at 04:21):
{
"resourceType" : "SearchParameter",
"name" : "Patient search by accept",
"status" : "active",
"description" : "Search by patient accepted parameter",
"purpose" : "Search by patient accepted parameter",
"code" : "PatientAcceptSearch",
"base" : ["Patient"],
"type" : "string",
"xpath" : "f:Patient/f:extension[@url='https://hapi.fhir.org/baseR4/Accepted']",
"xpathUsage" : "normal",
"target" : ["Patient"],
"comparator" : ["eq"],
"modifier" : ["exact"]
}
I used this to create the search parameter. How do I use this to search all patients that have "YES" in the extension?
David Hay (Nov 27 2020 at 17:22):
Have you tried [host]/Patient?PatientAcceptSearch=yes ? (after saving the resource on the server). Note that this is just the way that hapi works - the spec doesn't require it AFAIK...
David Hay (Nov 27 2020 at 17:39):
Oh, and the name shouldn't have spaces ('computer friendly')...
Dexter (Nov 30 2020 at 09:22):
Wow that works! Thank you!
Dexter (Dec 07 2020 at 10:25):
Well, erm, I tried to search for another extension, and this doesn't work. What am I doing wrong?
Search parameter here
{
"resourceType": "SearchParameter",
"name": "PractitionerRoleSearch",
"status": "active",
"description": "Search by Practitioner their role",
"purpose": "Search by Practitioner by their role",
"code": "PractitionerRoleSearch",
"base": ["Practitioner"],
"type": "string",
"expression": "Practitioner.extension('https://hapi.fhir.org/baseR4/Role')",
"xpath": "f:Practitioner/f:extension[@url='https://hapi.fhir.org/baseR4/Role']",
"xpathUsage": "normal",
"target": ["Practitioner"],
"comparator": ["eq"],
"modifier": ["exact" ]
}
I'm using it like so, GET http://hapi.fhir.org/baseR4/Practitioner?PractitionerRoleSearch=Care Manager
, but I get an error saying Unknown search parameter
.
Dexter (Dec 08 2020 at 09:29):
I played around with the JSON, still doesn't work, I'm not sure what I'm doing wrong
Dexter (Dec 08 2020 at 11:02):
Also, is there a way I can resolve references directly? Say I have a careteam I'm querying, is there a way I can resolve subject
reference directly, meaning instead of subject
having a reference, it just has the patient's data?
Mirjam Baltus (Dec 08 2020 at 13:37):
Dexter said:
Also, is there a way I can resolve references directly? Say I have a careteam I'm querying, is there a way I can resolve
subject
reference directly, meaning instead ofsubject
having a reference, it just has the patient's data?
No, you cannot put the patient's data in the subject field. That would not be valid FHIR.
You can however do a search and then include the Patient resource in the search result:
GET <base>/CareTeam?_id=<careteam_id>&_include=CareTeam:patient
Dexter (Dec 08 2020 at 15:48):
Okay, so that's not possible, yeah makes sense. Thanks!
Lin Zhang (Dec 09 2020 at 00:39):
In the model of CareTeam, the element subject has a type of Reference (Patient or Group).
Dexter (Dec 09 2020 at 04:27):
Any pointers on the search parameters?
David Hay (Dec 10 2020 at 00:09):
Not sure - @James Agnew - it used to be (I thought) that if you created a searchParameter on the hapi server that it would automatically enable that search - am I confused (again?)
David Hay (Dec 10 2020 at 00:27):
Or was that in SMILE server rather than the public test server...
Dexter (Dec 11 2020 at 09:36):
I can't seem to query on the existing search parameters defined by others on the server, I think they're okay too, what is it that is leading to the error? https://hapi.fhir.org/baseR4/SearchParameter
Traven (May 08 2021 at 18:39):
Hello
I'm struggling with the same problem as @Dexter
Based on the previous conversation in this topic I tried this:
1) Generate a new search parameter "PatientAcceptSearch" by following POST Command:
image.png
-> This seemed to work, since I found the ressource on the server:
image.png
2) Query for Patients with that extensions
http://hapi.fhir.org/baseR4/Patient?PatientAcceptSearch=yes
-> Not working, keep getting error "Unknown search parameter \"PatientAcceptSearch\" for resource type \"Patient\". Valid search parameters for this search are: [_id, _language,.... "
Could someone tell me what I got wrong?
Last updated: Apr 12 2022 at 19:14 UTC