View raw Markdown
type: resourceresource: EventDefinition

EventDefinition

Introduction

Scope and Usage

This resource is a definition resource from a FHIR workflow perspective - see Workflow, specifically Definition.

The EventDefinition resource provides a reusable description of an event. The resource supports describing different kinds of events, including named events, periodic events, and data-based events. For each of these, the resource also supports a formal description of the event. For example, a 'monitor-emergency-admissions' event can be a named event, but also provide a formal description of the event as monitoring for encounters that occur in emergency department locations.

Boundaries and Relationships

The EventDefinition resource is intended to be used to provide a reusable description of events for use by other resources that require event definition, such as MessageDefinition. The SubscriptionTopic resource is focused on supporting the definition of topics that can be used in Subscriptions. EventDefinition is a definition of an event that could occur, whereas Subscription is asking for notification of events when they occur.

The EventDefinition resource uses the TriggerDefinition data type to represent the description of an event as one of:

This allows an EventDefinition to be used to reference a SubscriptionTopic, enabling subscriptions to be used in MessageDefinition and PlanDefinition.

Background and Context

Provides additional detail on exactly how the resource is to be used

Notes

Examples

The following examples illustrate EventDefinition resources representing the event "3 consecutive negative stick tests" using the different approaches to event representation supported by the resource.

Named Event

The named event approach uses a name, or code to identify the event. In this approach, a unique code for the event is agreed upon by both sides of an integration. The Workflow and Task usage context types are another example. CDS Hooks hook names are another example of this approach.

The following example illustrates this approach for a three-consecutive-negative-stick-tests event:

<trigger>
  <type value="named-event"/>
  <code>
    <coding>
      <system value="http://example.org/CodeSystem/events"/>
      <code value="three-consecutive-negative-stick-tests"/>
    </coding>
  </code>
</trigger>

Data Event

Alternatively, a trigger may be identified as a data event. In this approach, a DataRequirement is used to identify the data change event:

<trigger>
  <type value="data-changed"/>
  <data>
    <type value="Observation"/>
    <codeFilter>
      <path value="code"/>
      <valueSet value="http://example.org/ValueSet/stick-test-codes"/>
    </codeFilter>
  </data>
  <condition>
    <language value="text/cql-expression"/>
    <expression value="StickTest.consecutivelyFrom(%context).take(3).negative().count() = 3"/>
  </condition>
</trigger>

This example indicates that the event should be triggered when Observations with a code matching a code in the http://example.org/ValueSet/stick-test-codes value set is created, updated, or deleted.

In addition, the example has a condition element providing an expression that is evaluated as part of determining whether or not the event is triggered. If the expression evaluates to true, the event is triggered.

The expression in this case:

StickTest.consecutivelyFrom(%context).take(3).negative().count() = 3

Relies on the fluent functions defined in the ExampleEventDefinitionLogic library:

define StickTest:
  [Observation: "Stick Test Codes"] O
    where O.status in { 'final', 'amended', 'corrected' }

define fluent function negative(observations List<Observation>):
  observations O
    where O.interpretation ~ "LA6577-6|http://loinc.org"

define fluent function during(observations List<Observation>, encounter Encounter):
  observations O
    where O.issued during minute of encounter.period

define fluent function within(observations List<Observation>, quantity Quantity):
  observations O
    where (O.issued + quantity) on or after minute of Now()

define fluent function consecutively(observations List<Observation>):
  observations O
    sort by issued

define fluent function consecutivelyFrom(observations List<Observation>, observation Observation):
  observations O
    where O.issued on or after observation.issued
    sort by issued

Alternatively, if a profile is available, it can be used to define the data requirement, as well as to provide the starting data element in the expression:

<trigger>
  <type value="data-changed"/>
  <data>
    <type value="Observation"/>
    <profile value="http://example.org/StructureDefinition/stick-test-profile"/>
  </data>
  <condition>
    <language value="text/cql-expression"/>
    <expression value="[StickTestProfile].consecutivelyFrom(%context).take(3).negative().count() = 3"/>
  </condition>
</trigger>

Periodic Event

And finally, the periodic approach can be used to indicate the event should occur on a timing:

<trigger>
  <type value="periodic"/>
  <timingTiming>
    <repeat>
      <frequency value="1"/>
      <period value="3"/>
      <periodUnit value="h"/>
    </repeat>
  </timingTiming>
  <condition>
    <language value="text/cql-expression"/>
    <expression value="StickTest.within(3 hours).consecutively.take(3).negative().count() = 3"/>
  </condition>
</trigger>

Use With RelativeTime

Once an event has been defined, it can be referenced as the context of a RelativeTime:

<Procedure>
  <occurrenceDateTime>
    <extension url="relativeTime">
      <valueRelativeTime>
        <contextDefinition value="http://example.org/EventDefinition/three-consecutive-negative-stick-tests"/>
        <offsetDuration>
          <value value="1"/>
          <code value="h"/>
          <system value="http://unitsofmeasure.org"/>
        </offsetDuration>
      </valueRelativeTime>
    </extension>
  </occurrenceDateTime>
</Procedure>

StructureDefinition

Elements (Simplified)

Mappings

Resource Packs

list-EventDefinition-packs.xml

<?xml version="1.0" encoding="UTF-8"?>

<List xmlns="http://hl7.org/fhir">
  <id value="EventDefinition-packs"/>
  <status value="current"/>
  <mode value="working"/>
</List>

Search Parameters

Full Search Parameters

Examples

Full Examples

Mapping Exceptions

eventdefinition-definition-mapping-exceptions.xml

Divergent Elements

The determination of when to create a new version of a resource (same url, new version) vs. defining a new artifact is up to the author. Considerations for making this decision are found in Technical and Business Versions.

In some cases, the resource can no longer be found at the stated url, but the url itself cannot change. Implementations can use the meta.source element to indicate where the current master source of the resource can be found. | resource=Can be a urn:uuid: or a urn:oid: but real http: addresses are preferred. Multiple instances may share the same URL if they have a distinct version.

The determination of when to create a new version of a resource (same url, new version) vs. defining a new artifact is up to the author. Considerations for making this decision are found in Technical and Business Versions.

In some cases, the resource can no longer be found at the stated url, but the url itself cannot change. Implementations can use the meta.source element to indicate where the current master source of the resource can be found.

Unknown does not represent 'other' - one of the defined statuses must apply. Unknown is used when the authoring system is not sure what the current status is. | resource=Allows filtering of event definitions that are appropriate for use versus not.

See guidance around (not) making local changes to elements here.

DEPRECATION NOTE: For consistency, implementations are encouraged to migrate to using the new 'jurisdiction' code in the useContext element. (I.e. useContext.code indicating http://terminology.hl7.org/CodeSystem/usage-context-type#jurisdiction and useContext.valueCodeableConcept indicating the jurisdiction.). | resource=It may be possible for the event definition to be used in jurisdictions other than those for which it was originally designed or intended.

DEPRECATION NOTE: For consistency, implementations are encouraged to migrate to using the new 'jurisdiction' code in the useContext element. (I.e. useContext.code indicating http://terminology.hl7.org/CodeSystem/usage-context-type#jurisdiction and useContext.valueCodeableConcept indicating the jurisdiction.)

See guidance around (not) making local changes to elements here.

Unmapped Elements

eventdefinition-fivews-mapping-exceptions.xml

Unmapped Elements