We have a use case where I need to pull the most recent Encounter using FHIR but all I have is the MRN of the patient to go off of. What parameters should I use to ensure I get the most recent encounter of a patient?
How you solve this will depend on the capabilities of the FHIR server you are connecting to. Assuming that the MRN is sufficient for identifying the right patient, there are some options for getting the most recent encounter:
- If the server provides a operation to pull the most recent encounter (or last X number of encounters), you can use that.
- If the server supports
_sort
, you could sort by date in descending order and take the first Encounter. Be sure to understand how the server handles sorting when there is pagination and how it handles the fact that encounter dates are nested within theperiod
/actualPeriod
element.
“Most recent encounter” can be a tricky thing. For example, if a patient has an active admission, and then has a child encounter in radiology, then the “most recent” encounter might be the child radiology encounter. And if your use case is unrelated to radiology, you probably want the admission instead.
Also, if a patient had an active admission that is about to be discharged, there maybe a subsequent encounter being “planned” that may have some active dates.
Also, if a patient is admitted, but on a leave of absence, but then ends up at urgent care while on leave you’ll need to figure out if you want the admission (which the patient is on leave from) or the urgent care visit.
1