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

<OperationDefinition xmlns="http://hl7.org/fhir">
  <id value="DocumentReference-docref"/>
  <text>
    <status value="extensions"/>
    <div xmlns="http://www.w3.org/1999/xhtml">
      <p>URL: [base]/DocumentReference/$docref</p>
      <p>Parameters</p>
      <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>patient</td>
          <td/>
          <td>1..1</td>
          <td>
            <a href="datatypes.html#id">id</a>
          </td>
          <td/>
          <td>
            <div>
              <p>The id of the patient resource located on the server on which this operation is executed.  If there is no match, an empty Bundle is returned</p>

            </div>
          </td>
        </tr>
        <tr>
          <td>IN</td>
          <td>start</td>
          <td/>
          <td>0..1</td>
          <td>
            <a href="datatypes.html#dateTime">dateTime</a>
          </td>
          <td/>
          <td>
            <div>
              <p>The date range relates to care dates, not record currency dates - e.g. all records relating to care provided in a certain date range. If no start date is provided, all documents prior to the end date are in scope.  If neither a start date nor an end date is provided, the most recent or current document is in scope.  The client 
                <strong>SHOULD</strong> provide values precise to the second + time offset.
              </p>

            </div>
          </td>
        </tr>
        <tr>
          <td>IN</td>
          <td>end</td>
          <td/>
          <td>0..1</td>
          <td>
            <a href="datatypes.html#dateTime">dateTime</a>
          </td>
          <td/>
          <td>
            <div>
              <p>The date range relates to care dates, not record currency dates - e.g. all records relating to care provided in a certain date range. If no end date is provided, all documents subsequent to the start date are in scope. If neither a start date nor an end date is provided, the most recent or current document is in scope.  The client 
                <strong>SHOULD</strong> provide values precise to the second + time offset.
              </p>

            </div>
          </td>
        </tr>
        <tr>
          <td>IN</td>
          <td>type</td>
          <td/>
          <td>0..1</td>
          <td>
            <a href="datatypes.html#CodeableConcept">CodeableConcept</a>
          </td>
          <td>
            <a href="valueset-doc-typecodes.html">FHIR Document Type Codes</a> (Required)
          </td>
          <td>
            <div>
              <p>The type relates to document type e.g. for the LOINC code for a C-CDA Clinical Summary of Care (CCD) is 34133-9 (Summary of episode note). If no type is provided, the CCD document, if available, SHALL be in scope and all other document types MAY be in scope</p>

            </div>
          </td>
        </tr>
        <tr>
          <td>IN</td>
          <td>on-demand</td>
          <td/>
          <td>0..1</td>
          <td>
            <a href="datatypes.html#boolean">boolean</a>
          </td>
          <td/>
          <td>
            <div>
              <p>This on-demand parameter allows client to dictate whether they are requesting only 'on-demand' or both 'on-demand' and 'stable' documents (or delayed/deferred assembly) that meet the query parameters</p>

            </div>
          </td>
        </tr>
        <tr>
          <td>OUT</td>
          <td>return</td>
          <td/>
          <td>1..1</td>
          <td>
            <a href="bundle.html">Bundle</a>
          </td>
          <td/>
          <td>
            <div>
              <p>The bundle type is &quot;searchset&quot;containing 
                <a href="documentreference.html">DocumentReference</a> resources.
              </p>

            </div>
          </td>
        </tr>
      </table>
      <div>
        <p>The server either returns a search result containing a single DocumentReference,
or it returns an error.</p>

      </div>
    </div>
  </text>
  <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-fmm">
    <valueInteger value="3"/>
  </extension>
  <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status">
    <valueCode value="trial-use"/>
  </extension>
  <url value="http://hl7.org/fhir/OperationDefinition/DocumentReference-docref"/>
  <version value="5.0.0"/>
  <name value="Docref"/>
  <title value="Fetch DocumentReference"/>
  <status value="draft"/>
  <kind value="operation"/>
  <experimental value="false"/>
  <date value="2023-03-26T15:21:02+11:00"/>
  <publisher value="HL7 (FHIR Project)"/>
  <contact>
    <telecom>
      <system value="url"/>
      <value value="http://hl7.org/fhir"/>
    </telecom>
    <telecom>
      <system value="email"/>
      <value value="fhir@lists.hl7.org"/>
    </telecom>
  </contact>
  <description value="This operation is used to return all the references to documents related to a patient. &#xA;&#xA; The operation requires a patient id and takes the optional input parameters: &#xA;  - start date&#xA;  - end date&#xA;  - document type &#xA;&#xA; and returns a [Bundle](bundle.html) of type &quot;searchset&quot; containing [DocumentReference](documentreference.html) resources for the patient. If the server has or can create documents that are related to the patient, and that are available for the given user, the server returns the DocumentReference resources needed to support the records.  The principle intended use for this operation is to provide a provider or patient with access to their available document information. &#xA;&#xA; This operation is *different* from a search by patient and type and date range because: &#xA;&#xA; 1. It is used to request a server to *generate* a document based on the specified parameters. &#xA;&#xA; 1. If no parameters are specified, the server SHALL return a DocumentReference to the patient's most current CCD &#xA;&#xA; 1. If the server cannot *generate* a document based on the specified parameters, the operation will return an empty search bundle. &#xA;&#xA; This operation is the *same* as a FHIR RESTful search by patient, type and date range because: &#xA;&#xA; 1. References for *existing* documents that meet the requirements of the request SHOULD also be returned unless the client indicates they are only interested in 'on-demand' documents using the *on-demand* parameter."/>
  <jurisdiction>
    <coding>
      <system value="http://unstats.un.org/unsd/methods/m49/m49.htm"/>
      <code value="001"/>
      <display value="World"/>
    </coding>
  </jurisdiction>
  <affectsState value="true"/>
  <code value="docref"/>
  <comment value="The server either returns a search result containing a single DocumentReference, &#xA;or it returns an error."/>
  <resource value="DocumentReference"/>
  <system value="false"/>
  <type value="true"/>
  <instance value="false"/>
  <parameter>
    <name value="patient"/>
    <use value="in"/>
    <min value="1"/>
    <max value="1"/>
    <documentation value="The id of the patient resource located on the server on which this operation is executed.  If there is no match, an empty Bundle is returned"/>
    <type value="id"/>
  </parameter>
  <parameter>
    <name value="start"/>
    <use value="in"/>
    <min value="0"/>
    <max value="1"/>
    <documentation value="The date range relates to care dates, not record currency dates - e.g. all records relating to care provided in a certain date range. If no start date is provided, all documents prior to the end date are in scope.  If neither a start date nor an end date is provided, the most recent or current document is in scope.  The client **SHOULD** provide values precise to the second + time offset."/>
    <type value="dateTime"/>
  </parameter>
  <parameter>
    <name value="end"/>
    <use value="in"/>
    <min value="0"/>
    <max value="1"/>
    <documentation value="The date range relates to care dates, not record currency dates - e.g. all records relating to care provided in a certain date range. If no end date is provided, all documents subsequent to the start date are in scope. If neither a start date nor an end date is provided, the most recent or current document is in scope.  The client **SHOULD** provide values precise to the second + time offset."/>
    <type value="dateTime"/>
  </parameter>
  <parameter>
    <name value="type"/>
    <use value="in"/>
    <min value="0"/>
    <max value="1"/>
    <documentation value="The type relates to document type e.g. for the LOINC code for a C-CDA Clinical Summary of Care (CCD) is 34133-9 (Summary of episode note). If no type is provided, the CCD document, if available, SHALL be in scope and all other document types MAY be in scope"/>
    <type value="CodeableConcept"/>
    <binding>
      <strength value="required"/>
      <valueSet value="http://hl7.org/fhir/ValueSet/doc-typecodes|5.0.0"/>
    </binding>
  </parameter>
  <parameter>
    <name value="on-demand"/>
    <use value="in"/>
    <min value="0"/>
    <max value="1"/>
    <documentation value="This on-demand parameter allows client to dictate whether they are requesting only 'on-demand' or both 'on-demand' and 'stable' documents (or delayed/deferred assembly) that meet the query parameters"/>
    <type value="boolean"/>
  </parameter>
  <parameter>
    <name value="return"/>
    <use value="out"/>
    <min value="1"/>
    <max value="1"/>
    <documentation value="The bundle type is &quot;searchset&quot;containing [DocumentReference](documentreference.html) resources."/>
    <type value="Bundle"/>
  </parameter>
</OperationDefinition>