FHIR Chat · how to serarch for last results · implementers

Stream: implementers

Topic: how to serarch for last results


view this post on Zulip Eric Haas (Apr 07 2016 at 19:43):

On a call today question was asked how to search for last n results or most recent results?

view this post on Zulip Patrick Werner (Apr 07 2016 at 19:49):

query for the latest updated/inserted 30 observation resources:
http://fhirtest.uhn.ca/baseDstu2/Observation?_sort=date&_count=30

view this post on Zulip Eric Haas (Apr 07 2016 at 19:50):

thanks!

view this post on Zulip Patrick Werner (Apr 07 2016 at 19:51):

this one are the latest 30 observations by valueDateTime
http://fhirtest.uhn.ca/baseDstu2/Observation?_sort=value-date&_count=30

view this post on Zulip Patrick Werner (Apr 07 2016 at 19:52):

(or value-period)

view this post on Zulip Patrick Werner (Apr 07 2016 at 19:53):

*valuePeriod

view this post on Zulip Eric Haas (Apr 07 2016 at 19:59):

OK a little more complicated how to for the most recent result of each type = code in a category.?

view this post on Zulip Eric Haas (Apr 07 2016 at 19:59):

for example:

view this post on Zulip Eric Haas (Apr 07 2016 at 20:00):

GET [base]/Observation?patient=[id]&category=vital-signs& {last temp, weight, etc in the category}

view this post on Zulip Eric Haas (Apr 07 2016 at 20:01):

or

view this post on Zulip Eric Haas (Apr 07 2016 at 20:02):

GET [base]/Observation?patient=[id]&category=laboratory&{ last glucose, NA, K etc}

view this post on Zulip David Hay (Apr 07 2016 at 20:10):

order by date descending and ask for only 1 (too lazy to look up the actual query!)

view this post on Zulip Lloyd McKenzie (Apr 07 2016 at 22:06):

There's no "group by" in FHIR, so you'd need to do a custom query/operation or some sort of custom search parameter to do that.

view this post on Zulip Eric Haas (Apr 09 2016 at 07:56):

As a clinician I can see a lot of practical utility getting only the most recent n result of labs/vitals for a patient. On paper I only look back to the most recent visits and labs. This was brought up twice on a recent Argo call for Labs and Vitals. So since there doesn't seem to be a way to do this presently, I'll submit a tracker to create an operation for Observation. Anybody think this is a bad idea?

view this post on Zulip Lloyd McKenzie (Apr 09 2016 at 14:36):

Trying something is rarely a bad idea :)

view this post on Zulip David Hay (Apr 09 2016 at 18:15):

perhaps pass in a valueset with the codes that you would like the last value of?

view this post on Zulip Grahame Grieve (Apr 11 2016 at 04:36):

@Eric Haas I'm not sure what you can't do - get the last n results for labs and vitals should be straight forward....

view this post on Zulip Eric Haas (Apr 11 2016 at 05:56):

"get the last n results for labs and vitals should be straight forward...." Not for me. I want the most recent of each of the labs ( whatever they are - I don't know that ahead of time for a patient - ie a the last cbc, chem, ua , t4 and lipase panel and 16 more. ) So the category is 'laboratory' I know that, do I order by date and code?

view this post on Zulip Grahame Grieve (Apr 11 2016 at 06:01):

ok. name a panel, and get the last of the panel - you can name the panel by a code, yes?

view this post on Zulip Grahame Grieve (Apr 11 2016 at 06:01):

that's ok, so it's just a batch ith 14 requests

view this post on Zulip Eric Haas (Apr 11 2016 at 06:19):

If I knew what labs the patient had already. I could search by panel. Remember I'm doing a search on for never before seen patient and I want to review all the labs they ever had by starting with the most recent one of each. So I need to search through the entire master list of lab codes and return the most recent one for each unique lab. I don' t see how searching for a single panel solves that?

view this post on Zulip Grahame Grieve (Apr 11 2016 at 06:37):

I think this is amost hard thing to do. I want to search for something but I don't know what I'm searching by....

view this post on Zulip Eric Haas (Apr 11 2016 at 06:44):

You search by Observation.category = vitals or labs and return the latest and greatest of each code that exists.

view this post on Zulip Grahame Grieve (Apr 11 2016 at 08:15):

yes, that's a general recipe, but 'latest and greatest' is the loose point

view this post on Zulip Mat Coolidge (Apr 11 2016 at 13:20):

Wouldnt you search for the orders? There would be no labs/observations without someone submitting an order.

view this post on Zulip Mat Coolidge (Apr 11 2016 at 13:23):

We are modeling the order results, especially lab panels, as diagnostic reports

view this post on Zulip Mat Coolidge (Apr 11 2016 at 13:23):

but in the context of the application it looks first for the orders and lists them (including status)

view this post on Zulip Lloyd McKenzie (Apr 11 2016 at 15:50):

Actually, it's very common to have vital signs observations without orders. (And it's occasionally possible to have lab tests without orders too.)

view this post on Zulip Eric Haas (Apr 11 2016 at 15:53):

Whether search for Observations or DiagnosticReports same idea. I want to scan the breadth of whats been done.

view this post on Zulip Eric Haas (Apr 11 2016 at 15:54):

OK maybe not "latest and greatest" but at least "latest"

view this post on Zulip Eric Haas (Apr 11 2016 at 15:54):

I believe was called "lastknown" by one participant on call

view this post on Zulip Jenni Syed (Apr 11 2016 at 17:23):

We call it "last N" internally for Millennium. The _count parameter doesn't work because that's page size. EG: I want to see the last 2 of each vital result for this patient. Or I want the last 10 labs of these types (monitoring disease progression or therapy response). It's actually the most common way internally that we see used to find labs and vitals.

view this post on Zulip Jenni Syed (Apr 11 2016 at 17:23):

if you use count, you may get 100 heights before you even see 1 weight (and cross many pages)

view this post on Zulip Jenni Syed (Apr 11 2016 at 17:25):

I don't think this needs to be an operation - couldn't we just create another parameter? EG: maxPerCode or something? All other query params likely still apply

view this post on Zulip Rob Hausam (Apr 11 2016 at 17:40):

I agree that this is a common (maybe even the most common, as Jenni said) use case for labs and vitals, and it makes sense to support it. As Eric said, you would want to search by Observation.category (and that may be about the best use for category that I've seen). A parameter seems reasonable. The "PerCode" part seems a little clunky to me - could that instead be implicit? I don't think that "max" would actually be saying what we need here. Maybe it could be "lastN", or "lastNPerCode" (if we do need to include the latter bit)?

view this post on Zulip Grahame Grieve (Apr 11 2016 at 18:10):

Surely this is a proper use for a batch?

view this post on Zulip Jenni Syed (Apr 11 2016 at 19:21):

I hope not, from an API perspective, I would rather be able to get this straight from the "owning" resource given how common the use case is

view this post on Zulip Jenni Syed (Apr 11 2016 at 19:21):

I'm not sure how common this is outside of Observation

view this post on Zulip Jenni Syed (Apr 11 2016 at 19:22):

most others are usually all active or date range (at least in CCDS)

view this post on Zulip Jenni Syed (Apr 11 2016 at 19:23):

I could see something similar, i guess, on diagnosticReport given the relationship between them. EG: let me complare the last 2 reports from imaging scans

view this post on Zulip Grahame Grieve (Apr 11 2016 at 19:27):

well, if they have the same modality and body site...

view this post on Zulip Grahame Grieve (Apr 11 2016 at 19:28):

is this really a common use case though?

view this post on Zulip Grahame Grieve (Apr 11 2016 at 19:28):

there's variations on this above - is it latest in category, or latest by panel, or latest by actual observation value?

view this post on Zulip Jenni Syed (Apr 11 2016 at 19:38):

In our case, it's usually latest by code. Even if you queried at a category level, we would return latest by like code

view this post on Zulip Jenni Syed (Apr 11 2016 at 19:39):

eg: give me the last 1 of all vitals would return 1 height, 1 weight, 1 temp...

view this post on Zulip Eric Haas (Apr 11 2016 at 19:41):

latest in by observation code in Obs where category equal labs or vitals, and latest by results code in DR. I see the problem with panel vs atomic test codes in Obs. decision needed there .. maybe exclude those with no value or DAR

view this post on Zulip James Agnew (Apr 11 2016 at 20:31):

It's a bit heavyweight, but you could definitely accomplish this with a batch request

view this post on Zulip Grahame Grieve (Apr 11 2016 at 20:52):

well, thsis is one kind of 'please do some analysis for me'

view this post on Zulip Jenni Syed (Apr 11 2016 at 20:52):

How would this be done via batch? I think I'm missing some param documentation somewhere

view this post on Zulip James Agnew (Apr 11 2016 at 20:58):

It would be a transaction with a bunch of search operations in it. Like, one search operation for "give me the most recent weight", one for "give me the most recent BP", etc

view this post on Zulip Eric Haas (Apr 11 2016 at 21:01):

great for vitals for which may have a dozen codes. What about labs where you may have 2000+ codes? What if you are accessing another system and don't know what codes they use?

view this post on Zulip James Agnew (Apr 11 2016 at 21:03):

yeah, if you don't know the codes that wouldn't work....

view this post on Zulip Grahame Grieve (Apr 11 2016 at 21:04):

how would it work if you don't know the codes anyway?

view this post on Zulip Jenni Syed (Apr 11 2016 at 21:04):

and also, you would have to "hack" search by using page size as a max - which is not apparent. Nor is it obvious why you can't do this through Observation itself

view this post on Zulip Grahame Grieve (Apr 11 2016 at 21:04):

please give me something.... I don't know how to tell you what I want....

view this post on Zulip Jenni Syed (Apr 11 2016 at 21:04):

(for the batch approach)

view this post on Zulip Jenni Syed (Apr 11 2016 at 21:05):

@Grahame Grieve - /Observation?category=vital-signs&max=5

view this post on Zulip Grahame Grieve (Apr 11 2016 at 21:05):

well, it's obvious why you can't - we didn't define it. I think you meant, why shouldn't you...

view this post on Zulip Jenni Syed (Apr 11 2016 at 21:05):

(max being whatever param name we decided to call it, lastN, etc)

view this post on Zulip Jenni Syed (Apr 11 2016 at 21:06):

/Observation?category=hematology&lastN=5

view this post on Zulip Patrick Werner (Apr 11 2016 at 21:07):

why don't just query for the Observation.Category and and define a lab category to get the 2000 different lab observations and sort by date

view this post on Zulip Jenni Syed (Apr 11 2016 at 21:07):

or, if you *did* know the code, /Observation?code=http://loinc.org|8867-4&lastN=10

view this post on Zulip Jenni Syed (Apr 11 2016 at 21:08):

because if I have a lab that has 1000 results on its own (very recent), and I want 5, I have to page through all of that to get to the next lab?

view this post on Zulip Jenni Syed (Apr 11 2016 at 21:08):

more common for vitals or measurements that come in via machines per second

view this post on Zulip Grahame Grieve (Apr 11 2016 at 21:09):

we are working on defining an operation that allows you to ask for 'current vital signs status' and returns latest values along with stats (min, max, mean, trend) over a period of time

view this post on Zulip Jenni Syed (Apr 11 2016 at 21:09):

also, as the server that's going to impact my EHR and users to expose that massive amount of results when you only want 5 of each... ew :)
And if anyone charged by transaction a la Amazaon... ew...

view this post on Zulip Grahame Grieve (Apr 11 2016 at 21:10):

lab seems a slightly different case. It's still not clear to me what is proposed for the client to ask for, and how the server decides what to return

view this post on Zulip Jenni Syed (Apr 11 2016 at 21:11):

The operation won't help when the app is graphing the actual trend either - common for vitals

view this post on Zulip Hussain Chinoy (Apr 11 2016 at 21:12):

An unbounded last change since is definitely a large burden on the server.

view this post on Zulip Lloyd McKenzie (Apr 12 2016 at 03:07):

Retrieving most recent labs when you don't know the codes could still make sense in situations where you're expecting the data to be looked at by a human, not necessarily evaluated by decision support or something. I tend to agree that using batch where you know the codes is an ugly way to solve the problem and it's unworkable if you don't know all of the codes that could be relevant on the target system.

view this post on Zulip Lloyd McKenzie (Apr 12 2016 at 03:11):

I can also potentially envision "most recent by practitioner" or "most recent by location", though those wouldn't be as common. If we want to allow filtering of which elements can be used, the parameter would need to be a composite combining the name of the search criteria to "group" by and the number of records to return. If we restrict it to code, we'd need a piece of metadata to use to identify what attribute applied. We could probably leverage the w5 for this, but we'd need a rule that one and only one attribute per resource could have that w5 category.


Last updated: Apr 12 2022 at 19:14 UTC