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

<OperationDefinition xmlns="http://hl7.org/fhir">
  <id value="BookAppointment"/>
  <text>
    <status value="generated"/><div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: OperationDefinition BookAppointment</b></p><a name="BookAppointment"> </a><a name="hcBookAppointment"> </a><p>URL: [base]/Appointment/$book</p><p>Output parameters Profile:<a href="StructureDefinition-portal-find-appointment-bundle.html">Portal Find Appointment response</a></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>appointment</td><td/><td>1..1</td><td><a href="http://hl7.org/fhir/R4/appointment.html">Appointment</a> (<a href="StructureDefinition-portal-appointment.html" title="https://canonical.fhir.link/servicewell/wof-portal/StructureDefinition/portal-appointment">Appointment Portal</a>)</td><td/><td><div><p>The Appointment to be created, modified, or cancelled.</p>
<ul>
<li>CREATE:
<ul>
<li>Appointment.id is absent or refers to a non-existing appointment</li>
<li>Appointment.status is 'pending'</li>
</ul>
</li>
<li>MODIFY:
<ul>
<li>Appointment.id identifies an existing appointment</li>
<li>Appointment.status is 'booked' and details (time, participants, etc.) are updated</li>
</ul>
</li>
<li>CANCEL:
<ul>
<li>Appointment.id identifies an existing appointment</li>
<li>Appointment.status is 'cancelled'</li>
</ul>
</li>
</ul>
</div></td></tr><tr><td>IN</td><td>appointment-reference</td><td/><td>0..1</td><td><a href="http://hl7.org/fhir/R4/references.html#Reference">Reference</a> (<a href="StructureDefinition-portal-appointment.html" title="https://canonical.fhir.link/servicewell/wof-portal/StructureDefinition/portal-appointment">Appointment Portal</a>)</td><td/><td><div><p>A resource id for one of proposed Appointments returned by a prior $find operation (e.g., Resource/1234).  References can be to an absolute URL, but servers only perform this operation on their own appointments.</p>
</div></td></tr><tr><td>IN</td><td>patient-identifier</td><td/><td>1..*</td><td><a href="http://hl7.org/fhir/R4/datatypes.html#Identifier">Identifier</a></td><td/><td><div><p>The Patient is identified by their personal number.  | SHOULD be an identifier system from a national FHIR Patient profile.</p>
</div></td></tr><tr><td>IN</td><td>comment</td><td/><td>0..1</td><td><a href="http://hl7.org/fhir/R4/datatypes.html#string">string</a></td><td/><td><div><p>The optional comment can be added for additional notes that could be useful for booking, canceling, or modifying an appointment</p>
</div></td></tr><tr><td>OUT</td><td>return</td><td/><td>1..1</td><td><a href="http://hl7.org/fhir/R4/bundle.html">Bundle</a></td><td/><td><div><p>On success, returns a Bundle that SHALL conform to ihe-sched-avail-bundle, containing the resulting Appointment:</p>
<ul>
<li>status 'booked' for created or modified appointments</li>
<li>status 'cancelled' for cancelled appointments</li>
</ul>
<p>On error, an OperationOutcome is returned instead of this parameter.</p>
</div></td></tr></table></div>
  </text>
  <url value="https://canonical.fhir.link/servicewell/wof-portal/OperationDefinition/BookAppointment"/>
  <version value="1.0.0"/>
  <name value="BookAppointment"/>
  <title value="Book / Modify / Cancel Appointment"/>
  <status value="active"/>
  <kind value="operation"/>
  <date value="2026-04-20T08:10:56+00:00"/>
  <publisher value="Service Well AB"/>
  <contact>
    <name value="Service Well AB"/>
    <telecom>
      <system value="url"/>
      <value value="https://servicewell.se"/>
    </telecom>
    <telecom>
      <system value="email"/>
      <value value="info@servicewell.se"/>
    </telecom>
  </contact>
  <contact>
    <name value="Service well"/>
    <telecom>
      <system value="email"/>
      <value value="info@servicewell.se"/>
      <use value="work"/>
    </telecom>
  </contact>
  <description value="Creates, modifies, or cancels an Appointment based on the supplied Appointment resource.&#xA;&#xA;This operation corresponds to the IHE ITI Scheduling $book operation and:&#xA;- CREATES a new Appointment when a new, schedulable Appointment is supplied&#xA;- MODIFIES an existing Appointment when an updated Appointment is supplied&#xA;- CANCELS an existing Appointment when a cancellation Appointment is supplied&#xA;&#xA;On success, the operation returns the finalized Appointment in an IHE Scheduled Availability Bundle."/>
  <affectsState value="true"/>
  <code value="book"/>
  <base value="https://profiles.ihe.net/ITI/Scheduling/OperationDefinition/appointment-book"/>
  <resource value="Appointment"/>
  <system value="false"/>
  <type value="true"/>
  <instance value="false"/>
  <outputProfile value="https://canonical.fhir.link/servicewell/wof-portal/StructureDefinition/portal-find-appointment-bundle"/>
  <parameter>
    <name value="appointment"/>
    <use value="in"/>
    <min value="1"/>
    <max value="1"/>
    <documentation value="The Appointment to be created, modified, or cancelled.&#xA;&#xA;- CREATE:&#xA;  - Appointment.id is absent or refers to a non-existing appointment&#xA;  - Appointment.status is 'pending'&#xA;- MODIFY:&#xA;  - Appointment.id identifies an existing appointment&#xA;  - Appointment.status is 'booked' and details (time, participants, etc.) are updated&#xA;- CANCEL:&#xA;  - Appointment.id identifies an existing appointment&#xA;  - Appointment.status is 'cancelled'"/>
    <type value="Appointment"/>
    <targetProfile value="https://canonical.fhir.link/servicewell/wof-portal/StructureDefinition/portal-appointment"/>
  </parameter>
  <parameter>
    <name value="appointment-reference"/>
    <use value="in"/>
    <min value="0"/>
    <max value="1"/>
    <documentation value="A resource id for one of proposed Appointments returned by a prior $find operation (e.g., Resource/1234).  References can be to an absolute URL, but servers only perform this operation on their own appointments."/>
    <type value="Reference"/>
    <targetProfile value="https://canonical.fhir.link/servicewell/wof-portal/StructureDefinition/portal-appointment"/>
  </parameter>
  <parameter>
    <name value="patient-identifier"/>
    <use value="in"/>
    <min value="1"/>
    <max value="*"/>
    <documentation value="The Patient is identified by their personal number.  | SHOULD be an identifier system from a national FHIR Patient profile. "/>
    <type value="Identifier"/>
  </parameter>
  <parameter>
    <name value="comment"/>
    <use value="in"/>
    <min value="0"/>
    <max value="1"/>
    <documentation value="The optional comment can be added for additional notes that could be useful for booking, canceling, or modifying an appointment"/>
    <type value="string"/>
  </parameter>
  <parameter>
    <name value="return"/>
    <use value="out"/>
    <min value="1"/>
    <max value="1"/>
    <documentation value="On success, returns a Bundle that SHALL conform to ihe-sched-avail-bundle, containing the resulting Appointment:&#xA;- status 'booked' for created or modified appointments&#xA;- status 'cancelled' for cancelled appointments&#xA;&#xA;On error, an OperationOutcome is returned instead of this parameter."/>
    <type value="Bundle"/>
  </parameter>
</OperationDefinition>