<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="hn-basis-appointment-test" />
  <url value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment-test" />
  <version value="1.0.0" />
  <name value="HnBasisAppointmenttest" />
  <title value="hn-basis-appointment" />
  <status value="draft" />
  <date value="2025-06-05T14:31:57+02:00" />
  <publisher value="Example Publisher" />
  <contact>
    <name value="Example Publisher" />
    <telecom>
      <system value="url" />
      <value value="http://example.org/example-publisher" />
    </telecom>
  </contact>
  <description value="Base profile for Helsenorge Appointment information. Defined by Helsenorge based on national profile." />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Appointment" />
  <baseDefinition value="http://hl7.no/fhir/StructureDefinition/no-basis-Appointment" />
  <derivation value="constraint" />
  <differential>
    <element id="Appointment">
      <path value="Appointment" />
      <constraint>
        <key value="cancelationReason-inv" />
        <severity value="error" />
        <human value="Cancelation reason MUST be set when status=cancelled and serviceCategory=27 (that is Specialist Medical)" />
        <expression value="(status='canceled' and serviceCategory.coding.code='27') implies cancelationReason.exists()" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment-test" />
      </constraint>
      <constraint>
        <key value="contained-location-must-have-managingorganization" />
        <severity value="error" />
        <human value="Contained location must have managing organization" />
        <expression value="Appointment.contained.where($this is Location).empty() or Appointment.contained.where($this is Location).all(managingOrganization.exists())" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment-test" />
      </constraint>
    </element>
    <element id="Appointment.meta">
      <path value="Appointment.meta" />
      <short value="Information about use of metadata in FHIR resources in helsenorge:" />
      <definition value="Information about use of metadata in FHIR resources in helsenorge: &lt;https://helsenorge.atlassian.net/wiki/spaces/HELSENORGE/pages/743014401/Meta+informasjon+som+kan+benyttes+for+alle+FHIR+ressurser&gt;. Se list of metadata that is to be used in context of an appointment:&lt;https://helsenorge.atlassian.net/wiki/spaces/HELSENORGE/pages/2052685825/Draft+-+Timenotifikasjon.+Ny+nasjonal+timel+sning#Appointment%3A-Metadata&gt;. &#xA; suppressNotification: Use for suppressing notification &#xA; reminder: Used to define if reminders is active. &#xA; hasAppointmentDetail: Tels if there is more information available regarding the appointment. If used Helsenorge will try to get the details from communication part. CommunicationPart must support that the details can be pulled. &#xA; supportPatientDialog: Patient dialog supported &#xA; and childParentRestrictons: setting posible restriction if parents are to get information about the appointment or only the child." />
    </element>
    <element id="Appointment.meta.lastUpdated">
      <path value="Appointment.meta.lastUpdated" />
      <short value="LastUpdated should always be present" />
      <definition value="LastUpdated should always be present to show when the resource was created or changed" />
      <comment value="This value is always populated. The server / resource manager sets this value; what a client provides is irrelevant. This is equivalent to the HTTP Last-Modified and SHOULD have the same value on a read interaction." />
      <min value="1" />
    </element>
    <element id="Appointment.extension:virtualService">
      <path value="Appointment.extension" />
      <sliceName value="virtualService" />
    </element>
    <element id="Appointment.extension:virtualService.extension:channelType">
      <path value="Appointment.extension.extension" />
      <sliceName value="channelType" />
    </element>
    <element id="Appointment.extension:virtualService.extension:channelType.value[x]">
      <path value="Appointment.extension.extension.value[x]" />
      <binding>
        <strength value="required" />
        <valueSet value="http://helsenorge.no/fhir/ValueSet/hn-basis-virtual-service-type.valueset" />
      </binding>
    </element>
    <element id="Appointment.identifier">
      <path value="Appointment.identifier" />
      <min value="1" />
      <max value="1" />
    </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.identifier.assigner">
      <path value="Appointment.identifier.assigner" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Organization" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-Organization" />
      </type>
    </element>
    <element id="Appointment.cancelationReason">
      <path value="Appointment.cancelationReason" />
      <short value="Reason for cancelation" />
      <definition value="Volven 8445 is a preferred code system but other code systems as Volven 9179 can also be used" />
      <binding>
        <strength value="preferred" />
        <valueSet value="urn:oid:2.16.578.1.12.4.1.1.8445" />
      </binding>
    </element>
    <element id="Appointment.cancelationReason.coding">
      <path value="Appointment.cancelationReason.coding" />
      <constraint>
        <key value="inv-4" />
        <severity value="error" />
        <human value="If code is used in a codable consept the system must be used" />
        <expression value="code &gt; '' implies (system &gt; '' )" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment-test" />
      </constraint>
    </element>
    <element id="Appointment.serviceCategory">
      <path value="Appointment.serviceCategory" />
      <min value="1" />
      <max value="1" />
      <binding>
        <strength value="required" />
        <valueSet value="http://helsenorge.no/fhir/ValueSet/hn-appointment-ServiceCategory-code-vs" />
      </binding>
    </element>
    <element id="Appointment.serviceCategory.coding">
      <path value="Appointment.serviceCategory.coding" />
      <constraint>
        <key value="inv-4" />
        <severity value="error" />
        <human value="If code is used in a codable consept the system must be used" />
        <expression value="code &gt; '' implies (system &gt; '' )" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment-test" />
      </constraint>
    </element>
    <element id="Appointment.serviceType.coding">
      <path value="Appointment.serviceType.coding" />
      <constraint>
        <key value="inv-4" />
        <severity value="error" />
        <human value="If code is used in a codable consept the system must be used" />
        <expression value="code &gt; '' implies (system &gt; '' )" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment-test" />
      </constraint>
    </element>
    <element id="Appointment.specialty.coding">
      <path value="Appointment.specialty.coding" />
      <constraint>
        <key value="inv-4" />
        <severity value="error" />
        <human value="If code is used in a codable consept the system must be used" />
        <expression value="code &gt; '' implies (system &gt; '' )" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment-test" />
      </constraint>
    </element>
    <element id="Appointment.appointmentType">
      <path value="Appointment.appointmentType" />
      <min value="1" />
    </element>
    <element id="Appointment.appointmentType.coding">
      <path value="Appointment.appointmentType.coding" />
      <constraint>
        <key value="inv-4" />
        <severity value="error" />
        <human value="If code is used in a codable consept the system must be used" />
        <expression value="code &gt; '' implies (system &gt; '' )" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment-test" />
      </constraint>
    </element>
    <element id="Appointment.appointmentType.coding:omsorgsNiva">
      <path value="Appointment.appointmentType.coding" />
      <sliceName value="omsorgsNiva" />
      <max value="0" />
    </element>
    <element id="Appointment.appointmentType.coding:helsenorge">
      <path value="Appointment.appointmentType.coding" />
      <sliceName value="helsenorge" />
      <short value="Codes from value set" />
      <definition value="Codes from value set" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <valueSet value="http://helsenorge.no/fhir/ValueSet/hn-appointment-AppointmentType-code-vs" />
      </binding>
    </element>
    <element id="Appointment.reasonCode.coding">
      <path value="Appointment.reasonCode.coding" />
      <constraint>
        <key value="inv-4" />
        <severity value="error" />
        <human value="If code is used in a codable consept the system must be used" />
        <expression value="code &gt; '' implies (system &gt; '' )" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment-test" />
      </constraint>
    </element>
    <element id="Appointment.description">
      <path value="Appointment.description" />
      <constraint>
        <key value="must-be-max-1000-chars" />
        <severity value="error" />
        <human value="Length MUST be &lt;= 1000" />
        <expression value="$this.length() &lt;= 1000" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment-test" />
      </constraint>
    </element>
    <element id="Appointment.supportingInformation">
      <path value="Appointment.supportingInformation" />
      <short value="Spesial instructions for use." />
      <definition value="Spesial instructions for use: Se &lt;https://helsenorge.atlassian.net/wiki/spaces/HELSENORGE/pages/2052685825/Draft+-+Timenotifikasjon.+Ny+nasjonal+timel+sning&gt; SuportingInformation MUST at least refer to communication part (herid level 2) using Organization profile kommunikasjonspart-Organization (&lt;https://simplifier.net/hl7norwayno-basis/kommunikasjonspart-organization&gt;)" />
      <min value="1" />
    </element>
    <element id="Appointment.patientInstruction">
      <path value="Appointment.patientInstruction" />
      <constraint>
        <key value="must-be-max-1000-chars" />
        <severity value="error" />
        <human value="Length MUST be &lt;= 1000" />
        <expression value="$this.length() &lt;= 1000" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment-test" />
      </constraint>
    </element>
    <element id="Appointment.participant">
      <path value="Appointment.participant" />
      <constraint>
        <key value="appointment-participant-actor-patient-reference-identifier" />
        <severity value="warning" />
        <human value="When actor is a Patient logical reference MUST be used" />
        <expression value="actor.type = 'Patient' implies actor.identifier.exists()" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment-test" />
      </constraint>
      <constraint>
        <key value="appointment-participant-actor-patient-reference-reference" />
        <severity value="warning" />
        <human value="When actor is a Patient literal reference (relative, internal or absolute) reference MUST not be used" />
        <expression value="(actor.type = 'Patient') implies actor.reference.exists().not()" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment-test" />
      </constraint>
    </element>
    <element id="Appointment.participant.type.coding">
      <path value="Appointment.participant.type.coding" />
      <constraint>
        <key value="inv-4" />
        <severity value="error" />
        <human value="If code is used in a codable consept the system must be used" />
        <expression value="code &gt; '' implies (system &gt; '' )" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment-test" />
      </constraint>
    </element>
    <element id="Appointment.participant.actor">
      <path value="Appointment.participant.actor" />
      <short value="When actor is a Patient logical reference MUST be used" />
      <definition value="When actor is a Patient only logical reference MUST be used. In all other cases Logical, Literal reference, Relative, internal or absolute URL can be used" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-Patient" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-Practitioner" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-PractitionerRole" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-Location" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-RelatedPerson" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Device" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-HealthcareService" />
      </type>
    </element>
  </differential>
</StructureDefinition>