<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="test-digidot-ServiceRequest-no" />
  <url value="http://novari.no/fhir/digidot/StructureDefinition/test-digidot-ServiceRequest-no" />
  <version value="0.1.1-test" />
  <name value="TestDigidotServiceRequestNo" />
  <title value="TEST DigiDot ServiceRequest (NO)" />
  <status value="draft" />
  <date value="2026-05-19" />
  <publisher value="Novari AS - DigiDOT" />
  <description value="TEST comparison draft. Not for production use. DigiDOT profile for planned, proposed or ordered dental services and procedures. This is the planning/request layer that may later result in Appointment, Encounter and Procedure resources." />
  <purpose value="Use this profile as the planning or request layer before dental activity is scheduled or performed. Performed clinical work should link back to the request with Procedure.basedOn." />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="ServiceRequest" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/ServiceRequest" />
  <derivation value="constraint" />
  <differential>
    <element id="ServiceRequest">
      <path value="ServiceRequest" />
    </element>
    <element id="ServiceRequest.basedOn">
      <path value="ServiceRequest.basedOn" />
      <short value="Higher-level plan or request that this plan is based on." />
      <definition value="Use ServiceRequest.basedOn only when this request fulfils or refines another plan/request. Do not use it to link performed procedures; performed procedures should point back with Procedure.basedOn." />
      <type>
        <code value="Reference" />
        <targetProfile value="http://novari.no/fhir/digidot/StructureDefinition/test-digidot-ServiceRequest-no" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/ServiceRequest" />
      </type>
    </element>
    <element id="ServiceRequest.replaces">
      <path value="ServiceRequest.replaces" />
      <short value="Previous plan/request that this plan replaces." />
      <definition value="Use ServiceRequest.replaces when the treatment plan changes because the clinical situation is different than first assumed, for example when a procedure becomes more complex and a revised plan is created. The old ServiceRequest should normally be completed or revoked according to local workflow." />
      <type>
        <code value="Reference" />
        <targetProfile value="http://novari.no/fhir/digidot/StructureDefinition/test-digidot-ServiceRequest-no" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/ServiceRequest" />
      </type>
    </element>
    <element id="ServiceRequest.status">
      <path value="ServiceRequest.status" />
      <short value="Status of the plan/request, not the status of a performed procedure." />
      <definition value="Use ServiceRequest.status for the lifecycle of the planned/requested dental service. Keep it active while the plan can still be fulfilled, use on-hold when the plan is paused, completed when the planned work is fulfilled or closed, and revoked when the plan is cancelled before fulfilment. Use Procedure.status for what actually happened clinically." />
      <min value="1" />
      <max value="1" />
    </element>
    <element id="ServiceRequest.intent">
      <path value="ServiceRequest.intent" />
      <min value="1" />
      <max value="1" />
    </element>
    <element id="ServiceRequest.code">
      <path value="ServiceRequest.code" />
      <min value="1" />
      <constraint>
        <key value="sr-sct-min1" />
        <severity value="warning" />
        <human value="At least one SNOMED CT code (pre- or postcoordinated) should be present." />
        <expression value="coding.where(system = 'http://snomed.info/sct').exists()" />
      </constraint>
      <binding>
        <strength value="extensible" />
        <description value="Use a code from the DigiDOT dental procedure value set when it covers the requested service or planned procedure. The value set represents reportable/refset procedure values, including values relevant for KPR reporting. For clinical planning and storage, a broader SNOMED CT concept may be used when the refset does not cover the intended meaning. A postcoordinated SNOMED CT expression may be included as additional semantic precision." />
        <valueSet value="http://novari.no/fhir/digidot/ValueSet/dental-procedures" />
      </binding>
    </element>
    <element id="ServiceRequest.code.coding">
      <path value="ServiceRequest.code.coding" />
      <slicing>
        <discriminator>
          <type value="profile" />
          <path value="$this" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <min value="1" />
      <max value="2" />
    </element>
    <element id="ServiceRequest.code.coding:SCTpre">
      <path value="ServiceRequest.code.coding" />
      <sliceName value="SCTpre" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="Coding" />
        <profile value="http://novari.no/fhir/digidot/StructureDefinition/test-digidot-Coding-SCTpre-no" />
      </type>
      <binding>
        <strength value="extensible" />
        <description value="For planned dental services, use a precoordinated SNOMED CT concept from the DigiDOT dental procedure refset when it covers the intended request. Broader SNOMED CT concepts are allowed for clinical planning when the refset does not cover the meaning. Stricter KPR/reporting validation should be handled by a reporting-specific profile or extraction rule." />
        <valueSet value="http://novari.no/fhir/digidot/ValueSet/dental-procedures" />
      </binding>
    </element>
    <element id="ServiceRequest.code.coding:SCTpost">
      <path value="ServiceRequest.code.coding" />
      <sliceName value="SCTpost" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Coding" />
        <profile value="http://novari.no/fhir/digidot/StructureDefinition/test-digidot-Coding-SCTpost-no" />
      </type>
    </element>
    <element id="ServiceRequest.subject">
      <path value="ServiceRequest.subject" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-Patient" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Patient" />
      </type>
    </element>
    <element id="ServiceRequest.encounter">
      <path value="ServiceRequest.encounter" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://novari.no/fhir/digidot/StructureDefinition/test-digidot-Encounter-no" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Encounter" />
      </type>
    </element>
    <element id="ServiceRequest.occurrence[x]">
      <path value="ServiceRequest.occurrence[x]" />
      <short value="Requested time or period for the planned service." />
      <definition value="Use occurrenceDateTime, occurrencePeriod or occurrenceTiming when the planned work has a known or expected time window. Appointment remains the scheduling resource; occurrence is the clinical/request timing on the plan." />
    </element>
    <element id="ServiceRequest.requester">
      <path value="ServiceRequest.requester" />
      <type>
        <code value="Reference" />
        <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-Organization" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-Patient" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-RelatedPerson" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Practitioner" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/PractitionerRole" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Organization" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Patient" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/RelatedPerson" />
      </type>
    </element>
    <element id="ServiceRequest.performer">
      <path value="ServiceRequest.performer" />
      <type>
        <code value="Reference" />
        <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-Organization" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-HealthcareService" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Practitioner" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/PractitionerRole" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Organization" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/HealthcareService" />
      </type>
    </element>
    <element id="ServiceRequest.locationReference">
      <path value="ServiceRequest.locationReference" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-Location" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Location" />
      </type>
    </element>
    <element id="ServiceRequest.reasonReference">
      <path value="ServiceRequest.reasonReference" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://novari.no/fhir/digidot/StructureDefinition/test-digidot-Condition-no" />
        <targetProfile value="http://novari.no/fhir/digidot/StructureDefinition/test-digidot-Observation-no" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Condition" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Observation" />
      </type>
    </element>
    <element id="ServiceRequest.bodySite">
      <path value="ServiceRequest.bodySite" />
      <min value="0" />
      <max value="*" />
      <constraint>
        <key value="tooth-required-if-surface" />
        <severity value="error" />
        <human value="If tooth surfaces are provided, a tooth must also be provided." />
        <expression value="coding.where(memberOf('http://novari.no/fhir/digidot/ValueSet/tooth-surfaces')).empty() or coding.where(memberOf('http://novari.no/fhir/digidot/ValueSet/teeth')).exists()" />
      </constraint>
    </element>
    <element id="ServiceRequest.bodySite.coding">
      <path value="ServiceRequest.bodySite.coding" />
      <slicing>
        <discriminator>
          <type value="profile" />
          <path value="$this" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <min value="0" />
      <max value="*" />
    </element>
    <element id="ServiceRequest.bodySite.coding:tooth">
      <path value="ServiceRequest.bodySite.coding" />
      <sliceName value="tooth" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Coding" />
        <profile value="http://novari.no/fhir/digidot/StructureDefinition/test-digidot-Coding-tooth-no" />
      </type>
      <binding>
        <strength value="required" />
        <valueSet value="http://novari.no/fhir/digidot/ValueSet/teeth" />
      </binding>
    </element>
    <element id="ServiceRequest.bodySite.coding:surface">
      <path value="ServiceRequest.bodySite.coding" />
      <sliceName value="surface" />
      <min value="0" />
      <max value="*" />
      <type>
        <code value="Coding" />
        <profile value="http://novari.no/fhir/digidot/StructureDefinition/test-digidot-Coding-tooth-surface-no" />
      </type>
      <binding>
        <strength value="required" />
        <valueSet value="http://novari.no/fhir/digidot/ValueSet/tooth-surfaces" />
      </binding>
    </element>
    <element id="ServiceRequest.bodySite.coding.system">
      <path value="ServiceRequest.bodySite.coding.system" />
      <min value="1" />
      <fixedUri value="http://snomed.info/sct" />
    </element>
  </differential>
</StructureDefinition>