--- type: "datatype" title: "RelativeTime" datatype: "RelativeTime" --- # RelativeTime - [Datatypes](/datatypes) - [Definitions](/datatypes-definitions#RelativeTime) - [Examples](/datatypes-examples#RelativeTime) - [Mappings](/datatypes-mappings#RelativeTime) - [Profiles](/datatypes-profiles#RelativeTime) ## Overview See also [Examples](datatypes-examples#RelativeTime), [Detailed Descriptions](datatypes-definitions#RelativeTime), [Mappings](datatypes-mappings#RelativeTime), [Profiles](datatypes-profiles#RelativeTime) and [Extensions]([%extensions-location%]extensions-datatypes#RelativeTime) RelativeTime expresses a time or time period as relative to the time of an event defined in data types other than dateTime. For example, "within 30 days of hospital discharge" is an interval of time (from 0 days to 30 days) and it is described as occurring after an event (hospital discharge). \[%dt RelativeTime 14%\] Methods to express the "event" or "context" that is reference point for time relative to that point include any of: 1. Describing the event fully with a CodeableConcept, in which case contextCode element is used. 2. Describing the event with a reference to an applicable FHIR Resource for which the Resource defines or implies a moment in time, in which case contextReference element is used, or contextDefinition element may be used instead if the Resource is ActivityDefinition, EventDefinition, PlanDefinition, or ObservationDefinition. 3. Describing the event with a reference to an applicable FHIR Resource (using contextReference or contextDefinition) and additional data to express which element in the Resource defines or implies the moment in time, using either or both of contextPath (for the literal path to the element) or contextCode (for the CodeableConcept describing the property that is expected to be found in the Resource). Methods to express the time or interval ("offset") relative to the "event" include any of: 1. Describing an exact duration (quantity with a numerical value and time-specific unit), in which case offsetDuration is used. 2. Describing a one-sided interval, in which case offsetDuration is used and includes offsetDuration.comparator with an appropriate code (>, >=, <, or <=). 3. Describing a two-sided interval, in which case offsetRange is used, and the Quantity datatype within the low and high values are limited to Duration datatype (i.e., limited to time-specific units). 4. Describing the same moment of time as the relevant event (offset = 0), in which case offsetDuration.value = 0 and units are unnecessary. The method to express a natural language description of the RelativeTime value is to use the text element. RelativeTime is used in the following places: \[%dtusage RelativeTime%\] ## Elements - **[RelativeTime.contextReference](/datatypes-definitions#RelativeTime.contextReference)** [0..1]: Reference(Any) The specific event occurrence or resource context used as a base point (reference point) in time. This establishes the context in which the 'path' is evaluated. - **[RelativeTime.contextDefinition](/datatypes-definitions#RelativeTime.contextDefinition)** [0..1]: canonical(ActivityDefinition|EventDefinition|PlanDefinition|ObservationDefinition) The type of event used as a base point. Instances of this definition will establish the context for evaluating the path to determine the base time for the offset. - **[RelativeTime.contextPath](/datatypes-definitions#RelativeTime.contextPath)** [0..1]: [string](/string) Path to the element defining the basis for the relative time. Any valid FHIRPath expression. - **[RelativeTime.contextCode](/datatypes-definitions#RelativeTime.contextCode)** [0..1]: [CodeableConcept](/CodeableConcept) Coded representation of the event used as a base point (reference point) in time. - **[RelativeTime.offset[x]](/datatypes-definitions#RelativeTime.offset%5Bx%5D)** [0..1]: Duration | Range An offset or offset range before (negative values) or after (positive values) the event. Range is limited to time-valued quantities (Durations). - **[RelativeTime.text](/datatypes-definitions#RelativeTime.text)** [0..1]: [string](/string) Free-text (human-readable) description ## Bindings - **RelativeTime.contextCode**: `RelativeTimeCodes` | strength: value set | reference: valueset-relativetime-codes