View raw Markdown
type: operationresource: profile-vitalsignsoperation: lastn

observation $lastn

Last N Observations Query

Description: The lastn query meets the common need for searching for the most recent or last n=number of observations for a subject. For example, retrieving the last 5 temperatures for a patient to view trends or fetching the most recent laboratory results or vitals signs. To ask a server to return the last n=number of observations, the lastn query uses the normal search parameters defined for the Observation resource. However, rather than their normal use, they are interpreted as inputs - i.e.. instead of requiring that the resources literally contain the search parameters, they are passed to a server algorithm of some kind that uses them to determine the most appropriate matches.

The request for a lastn query SHALL include:

The request for a lastn query MAY include:

The response from a lastn query is a set of observations:

Note that the individual Observation.code values used for grouping might not be explicit in the request, for example if a category of Observations is requested, or if a code is specified with the :below modifier.

The set of returned observations should represent distinct real-world observations and not the same observation with changes in status or versions. If there are no matches, the lastn query SHALL return an empty search set with no error, but may include an operation outcome with further advice.

Comments: The key differences between this query operation and simply searching Observation using the combination of _count and _sort parameters are:

This operation cannot be performed on observations that the user is not authorized to see. It is assumed that the server has identified and secured the context appropriately, and can either associate the authorization context with a single patient, or determine whether the context has the rights to the nominated patient, if there is one. If there is no nominated patient (e.g. the operation is invoked at the system level) and the context is not associated with a single patient record, then the server should return an error. Specifying the relationship between the context, a user and patient records is outside the scope of this specification.

Affects State: false

System: false

Type: true

Instance: false

URL: http://hl7.org/fhir/build/OperationDefinition/Observation-lastn

Parameters