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

<OperationDefinition xmlns="http://hl7.org/fhir">
  <id value="DHOAppointmentBackfill"/>
  <text>
    <status value="generated"/><div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: OperationDefinition DHOAppointmentBackfill</b></p><a name="DHOAppointmentBackfill"> </a><a name="hcDHOAppointmentBackfill"> </a><p>URL: [base]/Appointment/$backfill</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>mode</td><td/><td>1..1</td><td><a href="http://hl7.org/fhir/R4/datatypes.html#code">code</a></td><td/><td><div><p>location-correction, patient-instruction or touch</p>
</div></td></tr><tr><td>IN</td><td>lastUpdated</td><td/><td>0..1</td><td><a href="http://hl7.org/fhir/R4/datatypes.html#date">date</a></td><td/><td><div><p>Select Appointments updated on or after this date. Not with apptDate or identifier.</p>
</div></td></tr><tr><td>IN</td><td>apptDate</td><td/><td>0..1</td><td><a href="http://hl7.org/fhir/R4/datatypes.html#date">date</a></td><td/><td><div><p>Select Appointments starting on or after this date. Not with lastUpdated or identifier.</p>
</div></td></tr><tr><td>IN</td><td>apptDateTo</td><td/><td>0..1</td><td><a href="http://hl7.org/fhir/R4/datatypes.html#date">date</a></td><td/><td><div><p>With apptDate: select Appointments starting from apptDate to this date, both included.</p>
</div></td></tr><tr><td>IN</td><td>identifier</td><td/><td>0..*</td><td><a href="http://hl7.org/fhir/R4/datatypes.html#string">string</a></td><td/><td><div><p>An appointment id value to select, under any appointment-id system. Not with a date.</p>
</div></td></tr><tr><td>IN</td><td>audit</td><td/><td>0..1</td><td><a href="http://hl7.org/fhir/R4/datatypes.html#boolean">boolean</a></td><td/><td><div><p>true: look everything up and report what would change, but write nothing. Not for touch.</p>
</div></td></tr><tr><td>OUT</td><td>job</td><td/><td>1..1</td><td><a href="http://hl7.org/fhir/R4/datatypes.html#string">string</a></td><td/><td><div><p>The job id, for $backfill-status and $backfill-cancel</p>
</div></td></tr><tr><td>OUT</td><td>status</td><td/><td>1..1</td><td><a href="http://hl7.org/fhir/R4/datatypes.html#code">code</a></td><td/><td><div><p>accepted</p>
</div></td></tr></table></div>
  </text>
  <url value="https://fhir-ig.digital.health.nz/shared-care/OperationDefinition/DHOAppointmentBackfill"/>
  <version value="0.4.7"/>
  <name value="DHOAppointmentBackfill"/>
  <title value="Start an Appointment backfill"/>
  <status value="active"/>
  <kind value="operation"/>
  <date value="2026-10-13T01:26:02+00:00"/>
  <publisher value="Te Whatu Ora"/>
  <contact>
    <name value="Te Whatu Ora"/>
    <telecom>
      <system value="url"/>
      <value value="https://www.tewhatuora.govt.nz/"/>
    </telecom>
  </contact>
  <contact>
    <name value="Te Whatu Ora Integration Team"/>
    <telecom>
      <system value="email"/>
      <value value="integration@tewhatuora.govt.nz"/>
      <use value="work"/>
    </telecom>
  </contact>
  <description value="Starts a backfill of DHO Appointments in FHIR CDR and returns straight away with a job id. The run carries on in the&#xA;background. Follow it with $backfill-status and stop it with $backfill-cancel.&#xA;&#xA;Select Appointments with one of:&#xA;- a date: `lastUpdated` (updated on or after it) or `apptDate` (starting on or after it, or from `apptDate` to&#xA;  `apptDateTo` inclusive)&#xA;- one or more `identifier` values (SIPICS, legacy or Karisma SO appointment ids)&#xA;&#xA;Modes:&#xA;- `location-correction` corrects each Appointment's location from SIPICS, or cancels it. Identifiers FHIR CDR&#xA;  doesn't have are created from SIPICS.&#xA;- `patient-instruction` replaces each Appointment's patientInstruction from SIPICS.&#xA;- `touch` re-saves each Appointment unchanged, so its meta.lastUpdated moves on."/>
  <jurisdiction>
    <coding>
      <system value="urn:iso:std:iso:3166"/>
      <code value="NZ"/>
      <display value="New Zealand"/>
    </coding>
  </jurisdiction>
  <affectsState value="true"/>
  <code value="backfill"/>
  <resource value="Appointment"/>
  <system value="false"/>
  <type value="true"/>
  <instance value="false"/>
  <parameter>
    <name value="mode"/>
    <use value="in"/>
    <min value="1"/>
    <max value="1"/>
    <documentation value="location-correction, patient-instruction or touch"/>
    <type value="code"/>
  </parameter>
  <parameter>
    <name value="lastUpdated"/>
    <use value="in"/>
    <min value="0"/>
    <max value="1"/>
    <documentation value="Select Appointments updated on or after this date. Not with apptDate or identifier."/>
    <type value="date"/>
  </parameter>
  <parameter>
    <name value="apptDate"/>
    <use value="in"/>
    <min value="0"/>
    <max value="1"/>
    <documentation value="Select Appointments starting on or after this date. Not with lastUpdated or identifier."/>
    <type value="date"/>
  </parameter>
  <parameter>
    <name value="apptDateTo"/>
    <use value="in"/>
    <min value="0"/>
    <max value="1"/>
    <documentation value="With apptDate: select Appointments starting from apptDate to this date, both included."/>
    <type value="date"/>
  </parameter>
  <parameter>
    <name value="identifier"/>
    <use value="in"/>
    <min value="0"/>
    <max value="*"/>
    <documentation value="An appointment id value to select, under any appointment-id system. Not with a date."/>
    <type value="string"/>
  </parameter>
  <parameter>
    <name value="audit"/>
    <use value="in"/>
    <min value="0"/>
    <max value="1"/>
    <documentation value="true: look everything up and report what would change, but write nothing. Not for touch."/>
    <type value="boolean"/>
  </parameter>
  <parameter>
    <name value="job"/>
    <use value="out"/>
    <min value="1"/>
    <max value="1"/>
    <documentation value="The job id, for $backfill-status and $backfill-cancel"/>
    <type value="string"/>
  </parameter>
  <parameter>
    <name value="status"/>
    <use value="out"/>
    <min value="1"/>
    <max value="1"/>
    <documentation value="accepted"/>
    <type value="code"/>
  </parameter>
</OperationDefinition>