<StructureDefinition xmlns="http://hl7.org/fhir">
  <url value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-Appointment" />
  <name value="NHSDigitalAppointment" />
  <status value="draft" />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Appointment" />
  <baseDefinition value="https://fhir.hl7.org.uk/StructureDefinition/UKCore-Appointment" />
  <derivation value="constraint" />
  <differential>
    <element id="Appointment.extension">
      <path value="Appointment.extension" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="url" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <min value="0" />
    </element>
    <element id="Appointment.extension:requester">
      <path value="Appointment.extension" />
      <sliceName value="requester" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="https://fhir.nhs.uk/StructureDefinition/Extension-Provenance-agent" />
      </type>
    </element>
    <element id="Appointment.identifier">
      <path value="Appointment.identifier" />
      <mustSupport value="true" />
    </element>
    <element id="Appointment.identifier.system">
      <path value="Appointment.identifier.system" />
      <min value="1" />
    </element>
    <element id="Appointment.identifier.value">
      <path value="Appointment.identifier.value" />
      <min value="1" />
    </element>
    <element id="Appointment.status">
      <path value="Appointment.status" />
      <definition value="The overall status of the Appointment. Each of the participants has their own participation status which indicates their involvement in the process, however this status indicates the shared status.&#xD;&#xA;&#xD;&#xA;**e-RS**&#xD;&#xA;&#xD;&#xA;Will default to `booked`" />
      <mustSupport value="true" />
    </element>
    <element id="Appointment.serviceCategory">
      <path value="Appointment.serviceCategory" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="coding.system" />
        </discriminator>
        <rules value="open" />
      </slicing>
    </element>
    <element id="Appointment.serviceCategory.coding.system">
      <path value="Appointment.serviceCategory.coding.system" />
      <min value="1" />
    </element>
    <element id="Appointment.serviceCategory.coding.code">
      <path value="Appointment.serviceCategory.coding.code" />
      <min value="1" />
    </element>
    <element id="Appointment.serviceCategory:NHSDataDictionaryTreatmentFunction">
      <path value="Appointment.serviceCategory" />
      <sliceName value="NHSDataDictionaryTreatmentFunction" />
    </element>
    <element id="Appointment.serviceCategory:NHSDataDictionaryTreatmentFunction.coding">
      <path value="Appointment.serviceCategory.coding" />
      <binding>
        <strength value="required" />
        <valueSet value="https://fhir.nhs.uk/ValueSet/NHSDigital-CareSettingType" />
      </binding>
    </element>
    <element id="Appointment.serviceCategory:NHSDataDictionaryTreatmentFunction.coding.system">
      <path value="Appointment.serviceCategory.coding.system" />
      <fixedUri value="https://fhir.nhs.uk/CodeSystem/NHSDataModelAndDictionary-treatment-function" />
    </element>
    <element id="Appointment.serviceCategory:eRSClinicType">
      <path value="Appointment.serviceCategory" />
      <sliceName value="eRSClinicType" />
      <max value="1" />
    </element>
    <element id="Appointment.serviceCategory:eRSClinicType.coding">
      <path value="Appointment.serviceCategory.coding" />
      <binding>
        <strength value="required" />
        <valueSet value="https://fhir.nhs.uk/ValueSet/NHSDigital-eRS-ClinicType" />
      </binding>
    </element>
    <element id="Appointment.serviceCategory:eRSClinicType.coding.system">
      <path value="Appointment.serviceCategory.coding.system" />
      <fixedUri value="https://fhir.nhs.uk/CodeSystem/NHSDigital-ClinicType" />
    </element>
    <element id="Appointment.serviceType">
      <path value="Appointment.serviceType" />
      <definition value="UKCore will probably use this ValueSet https://fhir.hl7.org.uk/ValueSet/UKCore-CareSettingType&#xD;&#xA;&#xD;&#xA;At present we will base this on NHS Data Dictionary ValueSet" />
      <binding>
        <strength value="required" />
        <valueSet value="https://fhir.nhs.uk/ValueSet/NHSDigital-CareSettingType" />
      </binding>
    </element>
    <element id="Appointment.specialty">
      <path value="Appointment.specialty" />
      <binding>
        <strength value="required" />
        <description value="NHS Dictionary Main Specialty" />
        <valueSet value="https://fhir.nhs.uk/ValueSet/NHSDataModelAndDictionary-clinical-specialty" />
      </binding>
    </element>
    <element id="Appointment.reasonCode">
      <path value="Appointment.reasonCode" />
      <mustSupport value="true" />
    </element>
    <element id="Appointment.start">
      <path value="Appointment.start" />
      <short value="Appointment Start Date Time" />
      <definition value="Date time of the current appointment booking (if there is a current appointment booking to a Directly Bookable Service)&#xD;&#xA;&#xD;&#xA;```json&#xD;&#xA; &quot;start&quot;: &quot;2021-06-13T12:30:00+00:00&quot;,&#xD;&#xA;```" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Appointment.end">
      <path value="Appointment.end" />
      <short value="Appointment End Date Time" />
      <definition value="Date/Time that the appointment is to conclude.&#xD;&#xA;&#xD;&#xA;```json&#xD;&#xA;&quot;end&quot;: &quot;2021-06-13T12:45:00+00:00&quot;,&#xD;&#xA;```" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Appointment.slot">
      <path value="Appointment.slot" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="identifier.system" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.slot:alternativeSlot">
      <path value="Appointment.slot" />
      <sliceName value="alternativeSlot" />
      <definition value="```json&#xD;&#xA; &quot;slot&quot;: [&#xD;&#xA;                    {&#xD;&#xA;                        &quot;identifier&quot;: {&#xD;&#xA;                            &quot;system&quot;: &quot;https://fhir.nhs.uk/CodeSystem/unique-slot-reference-number&quot;,&#xD;&#xA;                            &quot;value&quot;: &quot;USRN-12000001&quot;&#xD;&#xA;                        }&#xD;&#xA;                    }&#xD;&#xA;                ],&#xD;&#xA;```" />
      <max value="1" />
    </element>
    <element id="Appointment.slot:alternativeSlot.identifier.system">
      <path value="Appointment.slot.identifier.system" />
      <fixedUri value="https://fhir.nhs.uk/CodeSystem/unique-slot-reference-number" />
    </element>
    <element id="Appointment.basedOn">
      <path value="Appointment.basedOn" />
      <definition value="The service request this appointment is allocated to assess (e.g. incoming referral or procedure request).&#xD;&#xA;&#xD;&#xA;```json&#xD;&#xA;&quot;basedOn&quot;: [&#xD;&#xA;                    {&#xD;&#xA;                        &quot;reference&quot;: &quot;https://server.fire.ly/ServiceRequest/6c2a1f9b-2517-419d-9099-591ba63f176c&quot;&#xD;&#xA;                    }&#xD;&#xA;                ],&#xD;&#xA;```" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-ServiceRequest" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.basedOn.identifier">
      <path value="Appointment.basedOn.identifier" />
      <mustSupport value="true" />
    </element>
    <element id="Appointment.basedOn.identifier.system">
      <path value="Appointment.basedOn.identifier.system" />
      <min value="1" />
    </element>
    <element id="Appointment.basedOn.identifier.value">
      <path value="Appointment.basedOn.identifier.value" />
      <min value="1" />
    </element>
    <element id="Appointment.participant">
      <path value="Appointment.participant" />
      <definition value="List of participants involved in the appointment.&#xD;&#xA;&#xD;&#xA;This should include a Patient and a HealthcareService&#xD;&#xA;&#xD;&#xA;```json&#xD;&#xA; &quot;participant&quot;: [&#xD;&#xA;                    {&#xD;&#xA;                        &quot;actor&quot;: {&#xD;&#xA;                            &quot;identifier&quot;: {&#xD;&#xA;                                &quot;system&quot;: &quot;https://fhir.nhs.uk/Id/ers-service&quot;,&#xD;&#xA;                                &quot;value&quot;: &quot;11002&quot;&#xD;&#xA;                            }&#xD;&#xA;                        },&#xD;&#xA;                        &quot;status&quot;: &quot;accepted&quot;&#xD;&#xA;                    },&#xD;&#xA;                    {&#xD;&#xA;                        &quot;actor&quot;: {&#xD;&#xA;                            &quot;identifier&quot;: {&#xD;&#xA;                                &quot;system&quot;: &quot;https://fhir.nhs.uk/Id/nhs-number&quot;,&#xD;&#xA;                                &quot;value&quot;: &quot;9912003888&quot;&#xD;&#xA;                            }&#xD;&#xA;                        },&#xD;&#xA;                        &quot;status&quot;: &quot;accepted&quot;&#xD;&#xA;                    }&#xD;&#xA;                ]&#xD;&#xA;```" />
      <mustSupport value="true" />
    </element>
    <element id="Appointment.participant.actor">
      <path value="Appointment.participant.actor" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-HealthcareService" />
        <targetProfile value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-PractitionerRole-Minimal" />
        <targetProfile value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-Patient" />
        <targetProfile value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-Location" />
        <targetProfile value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-Practitioner" />
        <aggregation value="contained" />
        <aggregation value="referenced" />
      </type>
      <constraint>
        <key value="participant" />
        <severity value="error" />
        <human value="An identifier reference or resource reference must be provided" />
        <expression value="(reference.exists() or identifier.exists())" />
        <source value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-Appointment" />
      </constraint>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.participant.actor.identifier.system">
      <path value="Appointment.participant.actor.identifier.system" />
      <min value="1" />
    </element>
    <element id="Appointment.participant.actor.identifier.value">
      <path value="Appointment.participant.actor.identifier.value" />
      <min value="1" />
    </element>
  </differential>
</StructureDefinition>