Search code examples
hl7-fhirhapi-fhirsmart-on-fhirgoogle-cloud-healthcare

Most Recent Encounter Search in FHIR


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?


Solution

  • 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:

    1. If the server provides a operation to pull the most recent encounter (or last X number of encounters), you can use that.
    2. 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 the period/actualPeriod element.