<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="hn-basis-appointment" />
  <url value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
  <version value="2.5.5" />
  <name value="HnBasisAppointment" />
  <title value="hn-basis-appointment" />
  <status value="active" />
  <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 the appointment is not partOf another appointment" />
        <expression value="(status = 'cancelled' and partOf.empty()) implies cancelationReason.exists()" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
      </constraint>
      <constraint>
        <key value="contained-location-must-have-managingorganization" />
        <severity value="error" />
        <human value="When serviceCategory is 27 or 30, every contained Location must have managingOrganization." />
        <expression value="serviceCategory.coding.where(code = '27' or code = '30').empty() or      contained.ofType(Location).all(managingOrganization.exists())" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
      </constraint>
      <constraint>
        <key value="hn-app-primary-2" />
        <severity value="error" />
        <human value="If serviceCategory is 7, basedOn must not be used" />
        <expression value="serviceCategory.coding.where(code = '7').empty() or basedOn.empty()" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
      </constraint>
      <constraint>
        <key value="start-required-inv" />
        <severity value="error" />
        <human value="start is required unless the appointment uses requestedPeriod and status is proposed, cancelled, or entered-in-error." />
        <expression value="start.exists() or (requestedPeriod.exists() and (status = 'proposed' or status = 'cancelled' or status = 'entered-in-error'))" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
      </constraint>
      <constraint>
        <key value="hn-app-reqperiod-1" />
        <severity value="error" />
        <human value="If status is proposed, requestedPeriod must exist. If requestedPeriod is present, each requestedPeriod must have both start and end." />
        <expression value="(status != 'proposed' or requestedPeriod.exists()) and (requestedPeriod.empty() or requestedPeriod.all(start.exists() and end.exists()))" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
      </constraint>
      <constraint>
        <key value="hn-app-reqperiod-2" />
        <severity value="error" />
        <human value="If requestedPeriod is present, status must be proposed, cancelled, or entered-in-error." />
        <expression value="requestedPeriod.empty() or (status = 'proposed' or status = 'cancelled' or status = 'entered-in-error')" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
      </constraint>
      <constraint>
        <key value="hn-app-primary-4" />
        <severity value="error" />
        <human value="If serviceCategory is 7, partOf must not be used" />
        <expression value="serviceCategory.coding.where(code = '7').empty() or partOf.empty()" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
      </constraint>
      <constraint>
        <key value="hn-app-primary-5" />
        <severity value="error" />
        <human value="postponementReason cannot be used when serviceCategory is 7" />
        <expression value="serviceCategory.coding.where(code = '7').empty() or postponementReason.empty()" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
      </constraint>
      <constraint>
        <key value="serviceCategory-location-type" />
        <severity value="error" />
        <human value="If serviceCategory is 7 and virtualService is not present, every contained Location must have type PTRES or OF. If serviceCategory is 27 or 30, every contained Location must have type HU or HOSP, and at least one HU and one HOSP Location must be present." />
        <expression value="(serviceCategory.coding.where(code='7').empty() or extension('http://helsenorge.no/fhir/StructureDefinition/hn-basis-virtual-service').exists() or contained.ofType(Location).all(type.coding.where(system='http://terminology.hl7.org/CodeSystem/v3-RoleCode' and (code='PTRES' or code='OF')).exists())) and (serviceCategory.coding.where(code='27' or code='30').empty() or (contained.ofType(Location).all(type.coding.where(system='http://terminology.hl7.org/CodeSystem/v3-RoleCode' and (code='HU' or code='HOSP')).exists()) and contained.ofType(Location).where(type.coding.where(system='http://terminology.hl7.org/CodeSystem/v3-RoleCode' and code='HU').exists()).exists() and contained.ofType(Location).where(type.coding.where(system='http://terminology.hl7.org/CodeSystem/v3-RoleCode' and code='HOSP').exists()).exists()))" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
      </constraint>
      <constraint>
        <key value="serviceCategory-7-location-requires-ptres-or-of" />
        <severity value="error" />
        <human value="When serviceCategory is 7, the appointment is not partOf another appointment, and virtualService is not present, contained Location must include PTRES or OF." />
        <expression value="serviceCategory.coding.where(code = '7').empty() or partOf.exists() or extension('http://helsenorge.no/fhir/StructureDefinition/hn-basis-virtual-service').exists() or contained.ofType(Location).where(type.coding.where(system = 'http://terminology.hl7.org/CodeSystem/v3-RoleCode' and (code = 'PTRES' or code = 'OF')).exists()).exists()" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
      </constraint>
      <constraint>
        <key value="serviceCategory-7-location-not-both-ptres-and-of" />
        <severity value="error" />
        <human value="When serviceCategory is 7, the appointment is not partOf another appointment, and virtualService is not present, contained Location must not include both PTRES and OF." />
        <expression value="serviceCategory.coding.where(code = '7').empty() or partOf.exists() or extension('http://helsenorge.no/fhir/StructureDefinition/hn-basis-virtual-service').exists() or (contained.ofType(Location).where(type.coding.where(system = 'http://terminology.hl7.org/CodeSystem/v3-RoleCode' and code = 'PTRES').exists()).exists() and contained.ofType(Location).where(type.coding.where(system = 'http://terminology.hl7.org/CodeSystem/v3-RoleCode' and code = 'OF').exists()).exists()).not()" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
      </constraint>
      <constraint>
        <key value="serviceCategory-7-contained-flag-rules" />
        <severity value="error" />
        <human value="When serviceCategory is 7, contained Flag resources must not use the codes canAcknowledge, canChangeAppointmentDialog, canHaveAppointmentDetails, or canInitiateDialog." />
        <expression value="serviceCategory.coding.where(code = '7').empty() or contained.ofType(Flag).all(code.coding.where(code in ('canAcknowledge' | 'canChangeAppointmentDialog' | 'canHaveAppointmentDetails' | 'canInitiateDialog')).empty())" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
      </constraint>
      <constraint>
        <key value="contained-flag-allowed-codes" />
        <severity value="error" />
        <human value="When contained Flag resources are used, only canAcknowledge, canChangeAppointmentDialog, canHaveAppointmentDetails, canInitiateDialog, cancel, cancelWithComment, canCancelServiceRequest, and canChangeAppointment are allowed, and each code may only occur once." />
        <expression value="contained.ofType(Flag).code.coding.all(code in ('canAcknowledge' | 'canChangeAppointmentDialog' | 'canHaveAppointmentDetails' | 'canInitiateDialog' | 'cancel' | 'cancelWithComment' | 'canCancelServiceRequest' | 'canChangeAppointment')) and contained.ofType(Flag).code.coding.where(code = 'canAcknowledge').count() &lt;= 1 and contained.ofType(Flag).code.coding.where(code = 'canChangeAppointmentDialog').count() &lt;= 1 and contained.ofType(Flag).code.coding.where(code = 'canHaveAppointmentDetails').count() &lt;= 1 and contained.ofType(Flag).code.coding.where(code = 'canInitiateDialog').count() &lt;= 1 and contained.ofType(Flag).code.coding.where(code = 'cancel').count() &lt;= 1 and contained.ofType(Flag).code.coding.where(code = 'cancelWithComment').count() &lt;= 1 and contained.ofType(Flag).code.coding.where(code = 'canCancelServiceRequest').count() &lt;= 1 and contained.ofType(Flag).code.coding.where(code = 'canChangeAppointment').count() &lt;= 1" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
      </constraint>
      <constraint>
        <key value="serviceCategory-7-no-varsling-or-paminnelse" />
        <severity value="error" />
        <human value="When serviceCategory is 7, meta.tag varsling and paminnelse must not be used." />
        <expression value="serviceCategory.coding.where(code = '7').empty() or meta.tag.where(system = 'http://helsenorge.no/fhir/varsling' or system = 'http://helsenorge.no/fhir/paminnelse').empty()" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
      </constraint>
      <constraint>
        <key value="supportinginformation-organization-partof" />
        <severity value="error" />
        <human value="Every non-kommunikasjonspart Organization referenced from supportingInformation must have a HER-id level 2 identifier and must have partOf referencing an Organization with a HER-id level 1 identifier." />
        <expression value="supportingInformation.resolve().ofType(Organization).where(meta.profile != 'http://helsenorge.no/fhir/StructureDefinition/kommunikasjonspart-Organization').all(identifier.where(system = 'urn:oid:2.16.578.1.12.4.1.4.102').exists() and partOf.exists() and partOf.resolve().ofType(Organization).exists() and partOf.resolve().ofType(Organization).all(identifier.where(system = 'urn:oid:2.16.578.1.12.4.1.4.101').exists()))" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
      </constraint>
      <constraint>
        <key value="serviceCategory-7-requires-kommunikasjonspart-organization" />
        <severity value="error" />
        <human value="When serviceCategory is 7, supportingInformation[kommunikasjonspart] must reference an Organization using HER-id level 2 identifier system." />
        <expression value="serviceCategory.coding.where(code = '7').empty() or supportingInformation.resolve().ofType(Organization).where(identifier.where(system = 'urn:oid:2.16.578.1.12.4.1.4.102').exists()).exists()" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
      </constraint>
      <constraint>
        <key value="virtualservice-or-location-required" />
        <severity value="error" />
        <human value="If virtualService extension is not present, at least one contained Location resource must be present." />
        <expression value="extension('http://helsenorge.no/fhir/StructureDefinition/hn-basis-virtual-service').exists() or contained.ofType(Location).exists()" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
      </constraint>
      <constraint>
        <key value="hn-app-proposed-only-servicecategory-7" />
        <severity value="error" />
        <human value="status proposed is only allowed when serviceCategory is 7." />
        <expression value="status != 'proposed' or serviceCategory.coding.where(code = '7').exists()" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
      </constraint>
      <constraint>
        <key value="hn-app-entered-in-error-requires-start-and-end" />
        <severity value="error" />
        <human value="When status is entered-in-error, start and end SHALL be populated. If explicit start and end are not available, they SHALL be derived from requestedPeriod before submission." />
        <expression value="status != 'entered-in-error' or (start.exists() and end.exists())" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
      </constraint>
    </element>
    <element id="Appointment.meta">
      <path value="Appointment.meta" />
      <short value="Metadata used for Appointment in Helsenorge" />
      <definition value="Appointment-specific use of generic Helsenorge FHIR metadata. See generic description of metadata mechanisms: &lt;https://helsenorge.atlassian.net/wiki/spaces/HELSENORGE/pages/743014401/Meta+informasjon+som+kan+benyttes+for+alle+FHIR+ressurser&gt;. This profile constrains selected metadata elements relevant for Appointment, including conditional access restriction, notification handling, and reminder handling." />
    </element>
    <element id="Appointment.meta.lastUpdated">
      <path value="Appointment.meta.lastUpdated" />
      <short value="Last updated timestamp for the resource" />
      <definition value="If present, indicates when the resource was created or last changed." />
      <comment value="This value is typically populated by the server/resource manager." />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Appointment.meta.security">
      <path value="Appointment.meta.security" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="system" />
        </discriminator>
        <rules value="open" />
      </slicing>
    </element>
    <element id="Appointment.meta.security:tilgangsbegrensning">
      <path value="Appointment.meta.security" />
      <sliceName value="tilgangsbegrensning" />
      <short value="Betinget tilgangsbegrensning metadata" />
      <definition value="Metadata for conditional access restriction for Appointment in Helsenorge." />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <valueSet value="http://helsenorge.no/fhir/ValueSet/hn-tilgangsbegrensning-vs" />
      </binding>
    </element>
    <element id="Appointment.meta.security:tilgangsbegrensning.system">
      <path value="Appointment.meta.security.system" />
      <min value="1" />
      <fixedUri value="urn:oid:2.16.578.1.12.4.1.1.9603" />
    </element>
    <element id="Appointment.meta.security:tilgangsbegrensning.code">
      <path value="Appointment.meta.security.code" />
      <min value="1" />
    </element>
    <element id="Appointment.meta.tag">
      <path value="Appointment.meta.tag" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="system" />
        </discriminator>
        <rules value="open" />
      </slicing>
    </element>
    <element id="Appointment.meta.tag:varsling">
      <path value="Appointment.meta.tag" />
      <sliceName value="varsling" />
      <short value="Varsling metadata" />
      <definition value="Metadata used to control notification behaviour for the Appointment in Helsenorge, including optional sender organization name." />
      <min value="0" />
      <max value="*" />
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <valueSet value="http://helsenorge.no/fhir/ValueSet/hn-varsling-vs" />
      </binding>
    </element>
    <element id="Appointment.meta.tag:varsling.extension:varselorganisasjon">
      <path value="Appointment.meta.tag.extension" />
      <sliceName value="varselorganisasjon" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://helsenorge.no/fhir/StructureDefinition/hn-extension-varselorganisasjon" />
      </type>
    </element>
    <element id="Appointment.meta.tag:varsling.system">
      <path value="Appointment.meta.tag.system" />
      <min value="1" />
      <fixedUri value="http://helsenorge.no/fhir/varsling" />
    </element>
    <element id="Appointment.meta.tag:varsling.code">
      <path value="Appointment.meta.tag.code" />
      <min value="1" />
    </element>
    <element id="Appointment.meta.tag:paminnelse">
      <path value="Appointment.meta.tag" />
      <sliceName value="paminnelse" />
      <short value="Påminnelse metadata" />
      <definition value="Metadata used to control reminder behaviour for the Appointment in Helsenorge." />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <valueSet value="http://helsenorge.no/fhir/ValueSet/hn-paminnelse-vs" />
      </binding>
    </element>
    <element id="Appointment.meta.tag:paminnelse.system">
      <path value="Appointment.meta.tag.system" />
      <min value="1" />
      <fixedUri value="http://helsenorge.no/fhir/paminnelse" />
    </element>
    <element id="Appointment.meta.tag:paminnelse.code">
      <path value="Appointment.meta.tag.code" />
      <min value="1" />
    </element>
    <element id="Appointment.implicitRules">
      <path value="Appointment.implicitRules" />
      <max value="0" />
    </element>
    <element id="Appointment.language">
      <path value="Appointment.language" />
      <max value="0" />
    </element>
    <element id="Appointment.text">
      <path value="Appointment.text" />
      <max value="0" />
    </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.extension:recurring">
      <path value="Appointment.extension" />
      <sliceName value="recurring" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-Recurring" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Appointment.extension:postponementReason">
      <path value="Appointment.extension" />
      <sliceName value="postponementReason" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-postponementreason" />
      </type>
    </element>
    <element id="Appointment.extension:consultationType">
      <path value="Appointment.extension" />
      <sliceName value="consultationType" />
      <min value="0" />
      <max value="0" />
      <type>
        <code value="Extension" />
        <profile value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-consultationType" />
      </type>
      <mustSupport value="true" />
    </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.status">
      <path value="Appointment.status" />
      <binding>
        <strength value="required" />
        <valueSet value="http://helsenorge.no/fhir/ValueSet/hn-appointment-status-vs" />
      </binding>
    </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="required" />
        <valueSet value="http://helsenorge.no/fhir/ValueSet/hn-cancellation-reason-vs" />
      </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" />
      </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" />
      </constraint>
    </element>
    <element id="Appointment.serviceType">
      <path value="Appointment.serviceType" />
      <max value="0" />
    </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" />
      </constraint>
    </element>
    <element id="Appointment.specialty">
      <path value="Appointment.specialty" />
      <max value="0" />
    </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" />
      </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" />
      </constraint>
    </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">
      <path value="Appointment.reasonCode" />
      <max value="0" />
    </element>
    <element id="Appointment.reasonReference">
      <path value="Appointment.reasonReference" />
      <max value="0" />
    </element>
    <element id="Appointment.priority">
      <path value="Appointment.priority" />
      <max value="0" />
    </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" />
      </constraint>
    </element>
    <element id="Appointment.supportingInformation">
      <path value="Appointment.supportingInformation" />
      <slicing>
        <discriminator>
          <type value="type" />
          <path value="resolve()" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <min value="1" />
    </element>
    <element id="Appointment.supportingInformation:kommunikasjonspart">
      <path value="Appointment.supportingInformation" />
      <sliceName value="kommunikasjonspart" />
      <short value="Kommunikasjonspart" />
      <definition value="Kommunikasjonspart organization used to transfer HER-id level 2 for the communication partner when serviceCategory is not 7. Else base organization is used tranfering both level 1 and level 2." />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Organization" />
      </type>
    </element>
    <element id="Appointment.supportingInformation:documentReference">
      <path value="Appointment.supportingInformation" />
      <sliceName value="documentReference" />
      <short value="Document reference" />
      <definition value="DocumentReference resource with supporting documentation for the appointment." />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-DocumentReference" />
      </type>
    </element>
    <element id="Appointment.supportingInformation:flag">
      <path value="Appointment.supportingInformation" />
      <sliceName value="flag" />
      <short value="Flag" />
      <definition value="Flag resource with supporting flag information for the appointment." />
      <min value="0" />
      <max value="4" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-Flag" />
      </type>
    </element>
    <element id="Appointment.slot">
      <path value="Appointment.slot" />
      <max value="0" />
    </element>
    <element id="Appointment.comment">
      <path value="Appointment.comment" />
      <max value="0" />
    </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" />
      </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" />
      </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) MUST not be used" />
        <expression value="(actor.type = 'Patient') implies actor.reference.exists().not()" />
        <source value="http://helsenorge.no/fhir/StructureDefinition/hn-basis-appointment" />
      </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" />
      </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-Location" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-PractitionerRole" />
      </type>
    </element>
    <element id="Appointment.requestedPeriod">
      <path value="Appointment.requestedPeriod" />
      <max value="1" />
    </element>
  </differential>
</StructureDefinition>