FHIR Release 3 (STU)

This page is part of the FHIR Specification (v3.0.2: STU 3). The current version which supercedes this version is 5.0.0. For a full list of available versions, see the Directory of published versions . Page versions: R5 R4B R4 R3

Operation-observation-lastn.ttl

Orders and Observations Work GroupMaturity Level: N/ABallot Status: InformativeCompartments: Device, Encounter, Patient, Practitioner, RelatedPerson

Raw Turtle, JSON-LD

Operation Definition

@prefix fhir: <http://hl7.org/fhir/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

# - resource -------------------------------------------------------------------

[] a fhir:OperationDefinition;
  fhir:Resource.id [ fhir:value "Observation-lastn"];
  fhir:DomainResource.text [
     fhir:Narrative.status [ fhir:value "generated" ]
  ];
  fhir:OperationDefinition.url [ fhir:value "http://hl7.org/fhir/OperationDefinition/Observation-lastn"];
  fhir:OperationDefinition.name [ fhir:value "Last N Observations Query"];
  fhir:OperationDefinition.status [ fhir:value "draft"];
  fhir:OperationDefinition.kind [ fhir:value "operation"];
  fhir:OperationDefinition.date [ fhir:value "2019-10-24T11:53:00+11:00"];
  fhir:OperationDefinition.publisher [ fhir:value "HL7 (FHIR Project)"];
  fhir:OperationDefinition.contact [
     fhir:index 0;
     fhir:ContactDetail.telecom [
       fhir:index 0;
       fhir:ContactPoint.system [ fhir:value "url" ];
       fhir:ContactPoint.value [ fhir:value "http://hl7.org/fhir" ]
     ], [
       fhir:index 1;
       fhir:ContactPoint.system [ fhir:value "email" ];
       fhir:ContactPoint.value [ fhir:value "fhir@lists.hl7.org" ]
     ]
  ];
  fhir:OperationDefinition.description [ fhir:value "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* queryuses the [normal search parameters](observation.html#search) 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.\n\nThe response from an lastn query is a set of observations: \n\n*  filtered by additional parameters\n* 'GROUP BY' `Observation.code`\n* sorted from most recent to the oldest\n* limited to the number of requested responses per group specified by the optional max query parameter\n* If no maximum number is given then only the most recent Observation in each group is returned. \n\nThe 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."];
  fhir:OperationDefinition.code [ fhir:value "lastn"];
  fhir:OperationDefinition.comment [ fhir:value "The key differences between this query operation and simply searching Observation using the combination of `_count` and `_sort` parameters are:\n\n* The *lastn* query returns **only** the last N resource grouped by code.  Using the _count query method doesn't restrict the total mathches so you may need to page through several \"A\" Observations  before getting to Observation \"B\".\n* The server is responsible for grouping the observations by codes.  This frees the client from needing to determine which codes she should ask for.\n\nThis 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."];
  fhir:OperationDefinition.resource [
     fhir:value "Observation";
     fhir:index 0
  ];
  fhir:OperationDefinition.system [ fhir:value "false"];
  fhir:OperationDefinition.type [ fhir:value "true"];
  fhir:OperationDefinition.instance [ fhir:value "false"];
  fhir:OperationDefinition.parameter [
     fhir:index 0;
     fhir:OperationDefinition.name [ fhir:value "max" ];
     fhir:OperationDefinition.use [ fhir:value "in" ];
     fhir:OperationDefinition.min [ fhir:value "0" ];
     fhir:OperationDefinition.max [ fhir:value "1" ];
     fhir:OperationDefinition.documentation [ fhir:value "`max` is  an optional input parameter to the *lastn* query operation.  It is used to specify the maximum number of Observations to return from each group. For example for the query \"Fetch the last 3 results for all vitals for a patient\" `max` = 3." ];
     fhir:OperationDefinition.type [ fhir:value "positiveInt" ]
  ], [
     fhir:index 1;
     fhir:OperationDefinition.name [ fhir:value "return" ];
     fhir:OperationDefinition.use [ fhir:value "out" ];
     fhir:OperationDefinition.min [ fhir:value "1" ];
     fhir:OperationDefinition.max [ fhir:value "1" ];
     fhir:OperationDefinition.documentation [ fhir:value "The set of most recent N Observations that match the *lastn* query search criteria." ];
     fhir:OperationDefinition.type [ fhir:value "Bundle" ]
  ] .

# -------------------------------------------------------------------------------------


Usage note: every effort has been made to ensure that the examples are correct and useful, but they are not a normative part of the specification.