<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="AppointmentMERT" />
  <url value="https://intrahealth.com/fhir/mert/StructureDefinition/AppointmentMERT" />
  <name value="AppointmentMERT" />
  <title value="Appointment (MERT)" />
  <status value="draft" />
  <description value="This profile describes the Appointment for MERT." />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Appointment" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Appointment" />
  <derivation value="constraint" />
  <differential>
    <element id="Appointment.status">
      <path value="Appointment.status" />
      <comment value="Appointment.status is required. MERT supports the base AppointmentStatus codes." />
      <mustSupport value="true" />
    </element>
    <element id="Appointment.cancelationReason">
      <path value="Appointment.cancelationReason" />
      <comment value="If appointment is cancelled, include cancelationReason when available (base example binding)." />
      <mustSupport value="true" />
    </element>
    <element id="Appointment.appointmentType">
      <path value="Appointment.appointmentType" />
      <comment value="Style of appointment (base preferred binding)." />
      <mustSupport value="true" />
    </element>
    <element id="Appointment.reasonCode">
      <path value="Appointment.reasonCode" />
      <comment value="Transport-first: include source reason coding when available; otherwise CodeableConcept.text may be used." />
      <mustSupport value="true" />
    </element>
    <element id="Appointment.start">
      <path value="Appointment.start" />
      <comment value="Appointment start time (instant). Required for MERT." />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Appointment.end">
      <path value="Appointment.end" />
      <comment value="Appointment end time (instant). Required for MERT." />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Appointment.comment">
      <path value="Appointment.comment" />
      <mustSupport value="true" />
    </element>
    <element id="Appointment.participant">
      <path value="Appointment.participant" />
      <slicing>
        <discriminator>
          <type value="profile" />
          <path value="actor" />
        </discriminator>
        <description value="Slice participants by actor type for MERT rules." />
        <rules value="open" />
      </slicing>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.participant.actor">
      <path value="Appointment.participant.actor" />
      <comment value="MERT requires a Patient participant. Provider and Location participants are optional when available." />
    </element>
    <element id="Appointment.participant:patient">
      <path value="Appointment.participant" />
      <sliceName value="patient" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Appointment.participant:patient.actor">
      <path value="Appointment.participant.actor" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://intrahealth.com/fhir/mert/StructureDefinition/PatientMERT" />
      </type>
    </element>
    <element id="Appointment.participant:patient.status">
      <path value="Appointment.participant.status" />
      <comment value="For MERT, the Patient participant status SHALL be 'accepted' (confirmed)." />
      <patternCode value="accepted" />
    </element>
    <element id="Appointment.participant:provider">
      <path value="Appointment.participant" />
      <sliceName value="provider" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Appointment.participant:provider.actor">
      <path value="Appointment.participant.actor" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://intrahealth.com/fhir/mert/StructureDefinition/PractitionerMERT" />
      </type>
    </element>
    <element id="Appointment.participant:provider.status">
      <path value="Appointment.participant.status" />
      <comment value="For MERT, the Provider participant status SHALL be 'accepted'." />
      <patternCode value="accepted" />
    </element>
    <element id="Appointment.participant:location">
      <path value="Appointment.participant" />
      <sliceName value="location" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Appointment.participant:location.actor">
      <path value="Appointment.participant.actor" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Location" />
      </type>
    </element>
    <element id="Appointment.participant:location.status">
      <path value="Appointment.participant.status" />
      <comment value="For MERT, the Location participant status SHALL be 'accepted'." />
      <patternCode value="accepted" />
    </element>
  </differential>
</StructureDefinition>