Clinical Practice Guidelines
2.0.0-draft - draft International flag

Clinical Practice Guidelines, published by HL7 International / Clinical Decision Support. This guide is not an authorized publication; it is the continuous build for version 2.0.0-draft built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of and changes regularly. See the Directory of published versions

OperationDefinition: CPG PlanDefinition Apply

Official URL: Version: 2.0.0-draft
Standards status: Trial-use Maturity Level: 2 Computable Name: CPGPlanDefinitionApply

The apply operation applies a PlanDefinition to a given context

URL: [base]/PlanDefinition/$apply

URL: [base]/PlanDefinition/[id]/$apply



Canonical URL of the PlanDefinition when invoked at the resource type level. This is exclusive with the planDefinition parameter.


Version of the PlanDefinition when invoked at the resource type level. This is exclusive with the planDefinition parameter.


The plan definition to be applied. If the operation is invoked at the instance level, this parameter is not allowed; if the operation is invoked at the type level, either this parameter or url (and optionally version) must be supplied.


The subject(s) that is/are the target of the plan to be applied. The subject may be a Patient, Practitioner, Organization, Location, Device, or Group. Subjects provided in this parameter will be resolved as the subject of the PlanDefinition based on the type of the subject. If multiple subjects of the same type are provided, the behavior is implementation-defined


The encounter in context, if any


The practitioner applying the plan definition


The organization applying the plan definition


The type of user initiating the request, e.g. patient, healthcare provider, or specific type of healthcare provider (physician, nurse, etc.)


Preferred language of the person using the system


The task the system user is performing, e.g. laboratory results review, medication list review, etc. This information can be used to tailor decision support outputs, such as recommended information resources


The current setting of the request (inpatient, outpatient, etc.)


Additional detail about the setting of the request, if any


True if the result of any nested PlanDefinitions should be merged into the final care plan, false if they should be preserved as nested CarePlans in the output. If this parameter is not specified, the default behavior is to preserve nested care plans in the output.


Any input parameters defined in libraries referenced by the PlanDefinition. Parameter types are mapped to CQL as specified in the Using CQL section of this implementation guide. If a parameter appears more than once in the input Parameters resource, it is represented with a List in the input CQL. If a parameter has parts, it is represented as a Tuple in the input CQL.


Whether to use data from the server performing the evaluation. If this parameter is true (the default), then the operation will use data first from any bundles provided as parameters (through the data and prefetch parameters), second data from the server performing the operation, and third, data from the dataEndpoint parameter (if provided). If this parameter is false, the operation will use data first from the bundles provided in the data or prefetch parameters, and second from the dataEndpoint parameter (if provided).


Data to be made available to the PlanDefinition evaluation. This parameter is exclusive with the prefetchData parameter (i.e. either provide all data as a single bundle, or provide data using multiple bundles with prefetch descriptions).


Data to be made available to the PlanDefinition evaluation, organized as prefetch response bundles. Each prefetchData parameter specifies either the name of the prefetchKey it is satisfying, a DataRequirement describing the prefetch, or both.


The key of the prefetch item. This typically corresponds to the name of a parameter in a library, or the name of a prefetch item in a CDS Hooks discovery response


A DataRequirement describing the content of the prefetch item.


The prefetch data as a Bundle. If the prefetchData has no prefetchResult part, it indicates there is no data associated with this prefetch item.


An endpoint to use to access data referenced by retrieve operations in libraries referenced by the PlanDefinition. If provided, this endpoint is used after the data or prefetchData bundles, and the server, if the useServerData parameter is true.


Configuration information to resolve canonical artifacts

Processing Semantics:

Create a canonical-like reference (e.g. {canonical.url}|{canonical.version} or similar extensions for non-canonical artifacts).

  • Given a single artifactEndpointConfiguration
    • When artifactRoute is present
      • And artifactRoute starts with canonical or artifact reference
      • Then attempt to resolve with endpointUri or endpoint
    • When artifactRoute is not present
      • Then attempt to resolve with endpointUri or endpoint
  • Given multiple artifactEndpointConfigurations
    • Then rank order each configuration (see below)
    • And attempt to resolve with endpointUri or endpoint in order until resolved

Rank each artifactEndpointConfiguration such that:

  • if artifactRoute is present and artifactRoute starts with canonical or artifact reference: rank based on number of matching characters
  • if artifactRoute is not present: include but rank lower

NOTE: For evenly ranked artifactEndpointConfigurations, order as defined in the OperationDefinition.


An optional route used to determine whether this endpoint is expected to be able to resolve artifacts that match the route (i.e. start with the route, up to and including the entire url)


The URI of the endpoint, exclusive with the endpoint parameter


An Endpoint resource describing the endpoint, exclusive with the endpointUri parameter


An endpoint to use to access terminology (i.e. valuesets, codesystems, and membership testing) referenced by the PlanDefinition. If no terminology endpoint is supplied, the evaluation will attempt to use the server on which the operation is being performed as the terminology server.


The RequestGroup that is the result of applying the PlanDefinition

The result of this operation is a RequestGroup resource.

The RequestGroup will have actions for each of the applicable actions in the plan based on evaluating the applicability condition in context. For each applicable action, the definition is applied as described in the $apply operation of the ActivityDefinition resource, and the resulting resource is added as an activity to the RequestGroup.

If the ActivityDefinition includes library references, those libraries will be available to the evaluated expressions. If those libraries have parameters, those parameters will be bound by name to the parameters given to the operation. In addition, parameters to the $apply operation are available within dynamicValue expressions as context variables, accessible by the name of the parameter, prefixed with a percent (%) symbol.

For a more detailed description, refer to the PlanDefinition and ActivityDefinition resource documentation. Note that result of this operation is transient (i.e. none of the resources created by the operation are persisted in the server, they are all returned as contained resources in the result). The result effectively represents a proposed set of activities, and it is up to the caller to determine whether and how those activities are actually carried out.