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

<OperationDefinition xmlns="http://hl7.org/fhir">
  <id value="cql-group-evaluate"/>
  <language value="en"/>
  <text>
    <status value="generated"/><div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: OperationDefinition cql-group-evaluate</b></p><a name="cql-group-evaluate"> </a><a name="hccql-group-evaluate"> </a><p>URL: [base]/Group/$evaluate</p><p>URL: [base]/Group/[id]/$evaluate</p><h3>Parameters</h3><table class="grid"><tr><td><b>Use</b></td><td><b>Name</b></td><td><b>Scope</b></td><td><b>Cardinality</b></td><td><b>Type</b></td><td><b>Binding</b></td><td><b>Documentation</b></td></tr><tr><td>IN</td><td>url</td><td/><td>0..1</td><td><a href="http://hl7.org/fhir/R4/datatypes.html#canonical">canonical</a></td><td/><td><div><p>The canonical url (with optional version) of the group to be evaluated. This parameter is only used when the operation is invoked at the type level, and is exclusive with the group parameter.</p>
</div></td></tr><tr><td>IN</td><td>group</td><td/><td>0..1</td><td><a href="http://hl7.org/fhir/R4/group.html">Group</a></td><td/><td><div><p>The group to be evaluated, provided as an input. This parameter is only used when the operation is invoked at the type level, and is exclusive with the url parameter.</p>
</div></td></tr><tr><td>IN</td><td>subject</td><td/><td>0..1</td><td><a href="http://hl7.org/fhir/R4/datatypes.html#string">string</a><br/>(<a href="https://hl7.org/fhir/R4/search.html#reference">reference</a>)</td><td/><td><div><p>Subject(s) for which the group definition will be evaluated. This corresponds to the context in which the group will be evaluated and is represented as a relative FHIR id (e.g. Patient/123), which establishes both the context and context value for the evaluation. This MAY be a reference to a Group, in which case the membership criteria is evaluated for every member of the subject group. This parameter cannot be used with the subjectGroup parameter. If no subject or subjectGroup is provided, the group definition is evaluated for all potential subjects.</p>
</div></td></tr><tr><td>IN</td><td>subjectGroup</td><td/><td>0..1</td><td><a href="http://hl7.org/fhir/R4/group.html">Group</a></td><td/><td><div><p>A Group of subjects for which the group definition will be evaluated, provided directly as a Group resource. This parameter cannot be used with the subject parameter. If no subject or subjectGroup is provided, the group definition is evaluated for all potential subjects.</p>
</div></td></tr><tr><td>IN</td><td>parameters</td><td/><td>0..1</td><td><a href="http://hl7.org/fhir/R4/parameters.html">Parameters</a></td><td/><td><div><p>Any input parameters to the evaluation. The Parameters resource provided in this input <strong>SHALL</strong> conform to the <a href="StructureDefinition-cql-parameters.html">CQLParameters</a> profile. Parameters defined in this input will be bound by name to the evaluation context. If the membership criteria is a CQL expression, these parameters will be available to the expression. If the membership criteria is a CQL identifier, these parameters will be bound by name to the parameters defined in the CQL library (or included libraries, recursively). 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. Note that parameters may be arbitrarily nested, for example, a list of tuples, or tuples that have list or interval valued elements. If parameter names are qualified, the parameter will be bound only to parameters in the library with the qualifier name, and the qualifier name must be the name of a library included by the library being evaluated (or an included library, recursively).</p>
</div></td></tr><tr><td>IN</td><td>artifactEndpointConfiguration</td><td/><td>0..*</td><td/><td/><td><div><p>Configuration information to resolve canonical artifacts</p>
<ul>
<li><code>artifactRoute</code>: 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)</li>
<li><code>endpointUri</code>: The URI of the endpoint, exclusive with the <code>endpoint</code> parameter</li>
<li><code>endpoint</code>: An Endpoint resource describing the endpoint, exclusive with the <code>endpointUri</code> parameter</li>
</ul>
<p><strong>Processing semantics</strong>:</p>
<p>Create a canonical-like reference (e.g.
<code>{canonical.url}|{canonical.version}</code> or similar extensions for non-canonical artifacts).</p>
<ul>
<li>Given a single <code>artifactEndpointConfiguration</code>
<ul>
<li>When <code>artifactRoute</code> is present
<ul>
<li>And canonical or artifact reference <em>starts with</em> <code>artifactRoute</code></li>
<li>Then attempt to resolve with <code>endpointUri</code> or <code>endpoint</code></li>
</ul>
</li>
<li>When <code>artifactRoute</code> is not present
<ul>
<li>Then attempt to resolve with <code>endpointUri</code> or <code>endpoint</code></li>
</ul>
</li>
</ul>
</li>
<li>Given multiple <code>artifactEndpointConfiguration</code>s
<ul>
<li>Then rank order each configuration (see below)</li>
<li>And attempt to resolve with <code>endpointUri</code> or <code>endpoint</code> in order until resolved</li>
</ul>
</li>
</ul>
<p>Rank each <code>artifactEndpointConfiguration</code> such that:</p>
<ul>
<li>if <code>artifactRoute</code> is present <em>and</em> canonical or artifact reference <em>starts with</em> <code>artifactRoute</code>: rank based on number of matching characters</li>
<li>if <code>artifactRoute</code> is <em>not</em> present: include but rank lower</li>
</ul>
<p>NOTE: For evenly ranked <code>artifactEndpointConfiguration</code>s, order as defined in the
OperationDefinition.</p>
</div></td></tr><tr><td>IN</td><td>artifactEndpointConfiguration.artifactRoute</td><td/><td>0..1</td><td><a href="http://hl7.org/fhir/R4/datatypes.html#uri">uri</a></td><td/><td/></tr><tr><td>IN</td><td>artifactEndpointConfiguration.endpointUri</td><td/><td>0..1</td><td><a href="http://hl7.org/fhir/R4/datatypes.html#uri">uri</a></td><td/><td/></tr><tr><td>IN</td><td>artifactEndpointConfiguration.endpoint</td><td/><td>0..1</td><td><a href="http://hl7.org/fhir/R4/endpoint.html">Endpoint</a></td><td/><td/></tr><tr><td>IN</td><td>timestamp</td><td/><td>0..1</td><td><a href="http://hl7.org/fhir/R4/datatypes.html#dateTime">dateTime</a></td><td/><td><div><p>The timestamp of the evaluation request.</p>
</div></td></tr><tr><td>OUT</td><td>return</td><td/><td>1..1</td><td><a href="http://hl7.org/fhir/R4/group.html">Group</a></td><td/><td><div><p>The results of the group evaluation, returned as an actual Group resource with members as determined by the evaluation of the membership criteria against the data present in the server.</p>
</div></td></tr></table></div>
  </text>
  <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-fmm">
    <valueInteger value="1"/>
  </extension>
  <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-wg">
    <valueCode value="cds"/>
  </extension>
  <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status">
    <valueCode value="trial-use"/>
  </extension>
  <url value="http://hl7.org/fhir/uv/cql/OperationDefinition/cql-group-evaluate"/>
  <version value="3.0.0-ballot"/>
  <name value="CQLGroupEvaluate"/>
  <title value="CQL Group Evaluate"/>
  <status value="active"/>
  <kind value="operation"/>
  <experimental value="false"/>
  <date value="2023-11-27T16:26:11+00:00"/>
  <publisher value="HL7 International / Clinical Decision Support"/>
  <contact>
    <telecom>
      <system value="url"/>
      <value value="http://www.hl7.org/Special/committees/dss"/>
    </telecom>
  </contact>
  <description value="Evaluates the membership criteria of a group definition returns the results as an actual Group resource. The Group is expected to use the characteristicsExpression extension to define membership criteria."/>
  <jurisdiction>
    <coding>
      <system value="http://unstats.un.org/unsd/methods/m49/m49.htm"/>
      <code value="001"/>
      <display value="World"/>
    </coding>
  </jurisdiction>
  <purpose value="This operation is defined to support evaluating the membership criteria of a group definition directly via an operation"/>
  <affectsState value="false"/>
  <code value="evaluate"/>
  <resource value="Group"/>
  <system value="false"/>
  <type value="true"/>
  <instance value="true"/>
  <parameter>
    <name value="url"/>
    <use value="in"/>
    <min value="0"/>
    <max value="1"/>
    <documentation value="The canonical url (with optional version) of the group to be evaluated. This parameter is only used when the operation is invoked at the type level, and is exclusive with the group parameter."/>
    <type value="canonical"/>
  </parameter>
  <parameter>
    <name value="group"/>
    <use value="in"/>
    <min value="0"/>
    <max value="1"/>
    <documentation value="The group to be evaluated, provided as an input. This parameter is only used when the operation is invoked at the type level, and is exclusive with the url parameter."/>
    <type value="Group"/>
  </parameter>
  <parameter>
    <name value="subject"/>
    <use value="in"/>
    <min value="0"/>
    <max value="1"/>
    <documentation value="Subject(s) for which the group definition will be evaluated. This corresponds to the context in which the group will be evaluated and is represented as a relative FHIR id (e.g. Patient/123), which establishes both the context and context value for the evaluation. This MAY be a reference to a Group, in which case the membership criteria is evaluated for every member of the subject group. This parameter cannot be used with the subjectGroup parameter. If no subject or subjectGroup is provided, the group definition is evaluated for all potential subjects."/>
    <type value="string"/>
    <searchType value="reference"/>
  </parameter>
  <parameter>
    <name value="subjectGroup"/>
    <use value="in"/>
    <min value="0"/>
    <max value="1"/>
    <documentation value="A Group of subjects for which the group definition will be evaluated, provided directly as a Group resource. This parameter cannot be used with the subject parameter. If no subject or subjectGroup is provided, the group definition is evaluated for all potential subjects."/>
    <type value="Group"/>
  </parameter>
  <parameter>
    <name value="parameters"/>
    <use value="in"/>
    <min value="0"/>
    <max value="1"/>
    <documentation value="Any input parameters to the evaluation. The Parameters resource provided in this input **SHALL** conform to the [CQLParameters](StructureDefinition-cql-parameters.html) profile. Parameters defined in this input will be bound by name to the evaluation context. If the membership criteria is a CQL expression, these parameters will be available to the expression. If the membership criteria is a CQL identifier, these parameters will be bound by name to the parameters defined in the CQL library (or included libraries, recursively). 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. Note that parameters may be arbitrarily nested, for example, a list of tuples, or tuples that have list or interval valued elements. If parameter names are qualified, the parameter will be bound only to parameters in the library with the qualifier name, and the qualifier name must be the name of a library included by the library being evaluated (or an included library, recursively)."/>
    <type value="Parameters"/>
  </parameter>
  <parameter>
    <name value="artifactEndpointConfiguration"/>
    <use value="in"/>
    <min value="0"/>
    <max value="*"/>
    <documentation value="Configuration information to resolve canonical artifacts&#xA;* `artifactRoute`: 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)&#xA;* `endpointUri`: The URI of the endpoint, exclusive with the `endpoint` parameter&#xA;* `endpoint`: An Endpoint resource describing the endpoint, exclusive with the `endpointUri` parameter&#xA;&#xA;**Processing semantics**:&#xA;&#xA;Create a canonical-like reference (e.g.&#xA;`{canonical.url}|{canonical.version}` or similar extensions for non-canonical artifacts).&#xA;&#xA;* Given a single `artifactEndpointConfiguration`&#xA;  * When `artifactRoute` is present&#xA;    * And canonical or artifact reference *starts with* `artifactRoute`&#xA;    * Then attempt to resolve with `endpointUri` or `endpoint`&#xA;  * When `artifactRoute` is not present&#xA;    * Then attempt to resolve with `endpointUri` or `endpoint`&#xA;* Given multiple `artifactEndpointConfiguration`s&#xA;  * Then rank order each configuration (see below)&#xA;  * And attempt to resolve with `endpointUri` or `endpoint` in order until resolved&#xA;&#xA;Rank each `artifactEndpointConfiguration` such that:&#xA;* if `artifactRoute` is present *and* canonical or artifact reference *starts with* `artifactRoute`: rank based on number of matching characters &#xA;* if `artifactRoute` is *not* present: include but rank lower&#xA;&#xA;NOTE: For evenly ranked `artifactEndpointConfiguration`s, order as defined in the&#xA;OperationDefinition."/>
    <part>
      <name value="artifactRoute"/>
      <use value="in"/>
      <min value="0"/>
      <max value="1"/>
      <type value="uri"/>
    </part>
    <part>
      <name value="endpointUri"/>
      <use value="in"/>
      <min value="0"/>
      <max value="1"/>
      <type value="uri"/>
    </part>
    <part>
      <name value="endpoint"/>
      <use value="in"/>
      <min value="0"/>
      <max value="1"/>
      <type value="Endpoint"/>
    </part>
  </parameter>
  <parameter>
    <name value="timestamp"/>
    <use value="in"/>
    <min value="0"/>
    <max value="1"/>
    <documentation value="The timestamp of the evaluation request."/>
    <type value="dateTime"/>
  </parameter>
  <parameter>
    <name value="return"/>
    <use value="out"/>
    <min value="1"/>
    <max value="1"/>
    <documentation value="The results of the group evaluation, returned as an actual Group resource with members as determined by the evaluation of the membership criteria against the data present in the server."/>
    <type value="Group"/>
  </parameter>
</OperationDefinition>