Stream: implementers
Topic: Unable to search for Patients on specific medications
Mike (Nov 13 2019 at 18:17):
Hi all!
I'm using the javascript fhirclient library (and currently the public sandbox for SMART on FHIR) to try and search for Patients with particular attributes. I'm currently wrestling with how to craft the search query for MedicationRequests for specific medications. For example, if I wanted to find Patients who were taking a 325 mg oral table of Acetaminophen, I know that has a code of: 313782. I've tried a couple things:
Doing this search:
client.request(/MedicationRequest?medication.code=313782
, {
pageLimit: 1,
flat: true
});
returns an empty list. So, it seems to be correctly crafted but the results are not what I expect. I know there are patients in the sandbox who have taken this pill.
And actually that's not the query I want. I want to use the name of the medication, not the code, so that I get ALL instances of someone taking Acetaminophen, not just the 325mg oral pill. So, I'd like to do something like this:
client.request(/MedicationRequest?medication.text=acetaminophen
, {
pageLimit: 1,
flat: true
})
But that returns an error: "Invalid parameter chain: medication.text"
So, how do I query for medication requests that involve a particular medication (e.g. acetaminophen)
Many thanks!
Lloyd McKenzie (Nov 13 2019 at 18:54):
medication:text should work better. ('text' is a qualifier that says to search the CodeableConcept.text and Coding.display elements)
Michele Mottini (Nov 13 2019 at 19:13):
The medication
search parameter targets medicationReference
. You should use code:text
to target medicationCodeableConcept
(but it won't work on most servers)
Mike (Nov 13 2019 at 19:14):
@Lloyd McKenzie Thank you for the help! Feels like I'm on the right track, but not quite there.
So, doing this returns an empty list:
client.request(`/MedicationRequest?medication:text=Acetaminophen`, { pageLimit: 1, resolveReferences: ["MedicationReference"], flat: true })
But if I were instead to not qualify my search at all, and just get ALL MedicationRequests back, I do see some that look like this:
authoredOn: "2017-07-03T05:38:05-04:00" dosageInstruction: [{…}] encounter: {reference: "Encounter/5530d672-fb57-4edd-85de-81af6c89930b"} id: "448595e7-fc3c-4a04-bef1-91483b8a4ea8" intent: "order" medicationCodeableConcept: coding: Array(1) 0: code: "313782" display: "Acetaminophen 325 MG Oral Tablet" system: "http://www.nlm.nih.gov/research/umls/rxnorm" __proto__: Object length: 1 __proto__: Array(0) text: "Acetaminophen 325 MG Oral Tablet" __proto__: Object meta: {versionId: "3", lastUpdated: "2019-06-06T02:59:27.248-04:00", tag: Array(1)} requester: {reference: "Practitioner/85aeca59-6261-4704-a2e4-1846ec5831a6"} resourceType: "MedicationRequest" status: "stopped" subject: {reference: "Patient/2c4e4abf-b81d-4791-9046-7cdff816061f"}
Screen-Shot-2019-11-13-at-11.10.13-AM.png
Any idea what I'm doing wrong? Thanks again!
Mike (Nov 13 2019 at 19:44):
@Michele Mottini Thanks for help! So, I've tried both ways, both this:
client.request(`/MedicationRequest?code:text=acetaminophen`, { pageLimit: 1, resolveReferences: ["MedicationReference"], flat: true })
and this
client.request(`/MedicationRequest?medication:text=acetaminophen`, { pageLimit: 1, resolveReferences: ["MedicationReference"], flat: true })
And both just return empty lists. Do you think this type of search is simply not supported? Seems like search for patients taking a specific medication would be a reasonable thing to do.
Thank you!
Michele Mottini (Nov 13 2019 at 20:03):
My guess would be that the server does not support :text
- can you find the MedicationRequest using the actual medication code instead than its display name? (medication:text is surely wrong - :text does not apply to reference search params)
Mike (Nov 13 2019 at 20:48):
@Michele Mottini Ooh, yes I can. Doing this:
client.request(`/MedicationRequest?code=313782`, { pageLimit: 1, resolveReferences: ["MedicationReference"], flat: true })
Returns a page of excellent results. It's just that the exact code is way too specific. I need ALL medication requests with a particular substring in the medication name.
Do you think search is simply not supported?
Many thanks!
Michele Mottini (Nov 13 2019 at 20:52):
Yes, :text
(that would be the way to do it) appear not t be supported. I do not know of any production server that implements it.
Mike (Nov 13 2019 at 21:02):
@Michele Mottini Ok, that's the info I needed. I'll find another way to get my users their data. Thank you so much!
Paul Church (Nov 14 2019 at 15:25):
We implemented :text
in the Google server but testing this example led me to discover a bug where the modifier doesn't trigger at the end of a chained search. So we can do code:text but not medication.code:text. :face_palm:
René Spronk (Nov 15 2019 at 04:45):
Does the server support medication._text (a text search over all text in the Medication resource?) Unlikely, but one never knows..
Last updated: Apr 12 2022 at 19:14 UTC