<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="Appointment-verto" />
  <url value="http://verto.ca/fhir/StructureDefinition/Appointment-verto" />
  <version value="1.0.0" />
  <name value="Appointment" />
  <title value="Verto's Appointment Profile" />
  <status value="active" />
  <experimental value="true" />
  <date value="2025-01-13" />
  <publisher value="Verto Health" />
  <description value="Appointment Profile constrained by Verto's Digital Twin" />
  <fhirVersion value="5.0.0" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Appointment" />
  <baseDefinition value="http://hl7.org/fhir/R5/StructureDefinition/Appointment" />
  <derivation value="constraint" />
  <differential>
    <element id="Appointment">
      <path value="Appointment" />
      <short value="Verto's Appointment Profile" />
      <definition value="A booking of a healthcare event among patient(s), practitioner(s), etc." />
    </element>
    <element id="Appointment.identifier">
      <path value="Appointment.identifier" />
      <short value="External Ids for this appointment" />
      <min value="0" />
      <max value="*" />
      <type>
        <code value="Identifier" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.status">
      <path value="Appointment.status" />
      <short value="proposed | pending | booked | arrived | fulfilled | cancelled | noshow | entered-in-error | checked-in | waitlist" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="code" />
      </type>
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <valueSet value="http://hl7.org/fhir/ValueSet/appointmentstatus" />
      </binding>
    </element>
    <element id="Appointment.cancellationReason">
      <path value="Appointment.cancellationReason" />
      <short value="The reason for appointment cancellation" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="CodeableConcept" />
      </type>
      <mustSupport value="true" />
      <binding>
        <strength value="preferred" />
        <valueSet value="http://hl7.org/fhir/ValueSet/appointment-cancellation-reason" />
      </binding>
    </element>
    <element id="Appointment.class">
      <path value="Appointment.class" />
      <short value="Classification of service" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="CodeableConcept" />
      </type>
      <mustSupport value="true" />
      <binding>
        <strength value="example" />
        <valueSet value="http://hl7.org/fhir/ValueSet/appointment-service-class" />
      </binding>
    </element>
    <element id="Appointment.serviceCategory">
      <path value="Appointment.serviceCategory" />
      <short value="A broad categorization of the service" />
      <min value="0" />
      <max value="*" />
      <type>
        <code value="CodeableConcept" />
      </type>
      <mustSupport value="true" />
      <binding>
        <strength value="preferred" />
        <valueSet value="http://hl7.org/fhir/ValueSet/service-category" />
      </binding>
    </element>
    <element id="Appointment.serviceType">
      <path value="Appointment.serviceType" />
      <short value="Specific service" />
      <min value="0" />
      <max value="*" />
      <type>
        <code value="CodeableConcept" />
      </type>
      <mustSupport value="true" />
      <binding>
        <strength value="preferred" />
        <valueSet value="http://hl7.org/fhir/ValueSet/service-type" />
      </binding>
    </element>
    <element id="Appointment.appointmentType">
      <path value="Appointment.appointmentType" />
      <short value="The type of appointment" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="CodeableConcept" />
      </type>
      <mustSupport value="true" />
      <binding>
        <strength value="preferred" />
        <valueSet value="http://hl7.org/fhir/ValueSet/appointment-type" />
      </binding>
    </element>
    <element id="Appointment.reason">
      <path value="Appointment.reason" />
      <short value="Reason for appointment" />
      <min value="0" />
      <max value="*" />
      <type>
        <code value="CodeableReference" />
        <targetProfile value="http://verto.ca/fhir/StructureDefinition/Condition-verto" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Procedure" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Observation" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/ImmunizationRecommendation" />
      </type>
      <mustSupport value="true" />
      <binding>
        <strength value="preferred" />
        <valueSet value="http://hl7.org/fhir/ValueSet/encounter-reason" />
      </binding>
    </element>
    <element id="Appointment.priority">
      <path value="Appointment.priority" />
      <short value="Appointment priority" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="unsignedInt" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.description">
      <path value="Appointment.description" />
      <short value="Additional appointment notes or comments" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="string" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.replaces">
      <path value="Appointment.replaces" />
      <short value="Appointment that this appointment replaces" />
      <min value="0" />
      <max value="*" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://verto.ca/fhir/StructureDefinition/Appointment-verto" />
      </type>
      <mustSupport value="true" />
    </element>
    <!-- VirtualService -->
    <element id="Appointment.virtualService">
      <path value="Appointment.virtualService" />
      <short value="Virtual service details" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="VirtualServiceDetail" />
        <profile value="http://verto.ca/fhir/StructureDefinition/VirtualServiceDetail-verto" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.previousAppointment">
      <path value="Appointment.previousAppointment" />
      <short value="Previous appointment that this appointment follows" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://verto.ca/fhir/StructureDefinition/Appointment-verto" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.originatingAppointment">
      <path value="Appointment.originatingAppointment" />
      <short value="The original appointment that this one is based on" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Appointment-verto" />
      </type>
      <mustSupport value="true" />
    </element>
    <!-- Time elements -->
    <element id="Appointment.start">
      <path value="Appointment.start" />
      <short value="Start time of appointment" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="instant" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.end">
      <path value="Appointment.end" />
      <short value="End time of appointment" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="instant" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.minutesDuration">
      <path value="Appointment.minutesDuration" />
      <short value="Duration in minutes" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="positiveInt" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.requestedPeriod">
      <path value="Appointment.requestedPeriod" />
      <short value="Requested time period for appointment" />
      <min value="0" />
      <max value="*" />
      <type>
        <code value="Period" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.slot">
      <path value="Appointment.slot" />
      <short value="The slots that this appointment is filling" />
      <min value="0" />
      <max value="*" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://verto.ca/fhir/StructureDefinition/Slot-verto" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.created">
      <path value="Appointment.created" />
      <short value="Creation time" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="dateTime" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.cancellationDate">
      <path value="Appointment.cancellationDate" />
      <short value="When appointment was cancelled" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="dateTime" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.subject">
      <path value="Appointment.subject" />
      <short value="The patient for the appointment" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://verto.ca/fhir/StructureDefinition/Verto's Patient Profile" />
      </type>
      <mustSupport value="true" />
    </element>
    <!-- Participant -->
    <element id="Appointment.participant">
      <path value="Appointment.participant" />
      <short value="Participants involved in appointment" />
      <min value="0" />
      <max value="*" />
      <type>
        <code value="BackboneElement" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.participant.actor">
      <path value="Appointment.participant.actor" />
      <short value="Person, Location or Resource" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Verto's Patient Profile" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Practitioner" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/PractitionerRole" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/RelatedPerson" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Device" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/HealthcareService" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Location" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.recurrenceId">
      <path value="Appointment.recurrenceId" />
      <short value="Identifier of recurring appointment" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="string" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.occurrenceChanged">
      <path value="Appointment.occurrenceChanged" />
      <short value="Indicates if occurrence was changed" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="boolean" />
      </type>
      <mustSupport value="true" />
    </element>
    <!-- RecurrenceTemplate -->
    <element id="Appointment.recurrenceTemplate">
      <path value="Appointment.recurrenceTemplate" />
      <short value="Recurring appointment template" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="BackboneElement" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.recurrenceTemplate.recurrenceType">
      <path value="Appointment.recurrenceTemplate.recurrenceType" />
      <short value="Type of recurrence" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="code" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.recurrenceTemplate.lastOccurrenceDate">
      <path value="Appointment.recurrenceTemplate.lastOccurrenceDate" />
      <short value="Date of last occurrence" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="dateTime" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.recurrenceTemplate.occurrenceCount">
      <path value="Appointment.recurrenceTemplate.occurrenceCount" />
      <short value="Number of occurrences" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="positiveInt" />
      </type>
      <mustSupport value="true" />
    </element>
  </differential>
</StructureDefinition>