<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="test-digidot-ServiceRequest-no" />
  <url value="https://novari.no/fhir/digidot/StructureDefinition/test-digidot-ServiceRequest-no" />
  <version value="0.1.4-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, including recall, treatment, diagnostic services and follow-up. Recall is represented in this same ServiceRequest profile with category = dental-recall, not with a separate recall profile. This is the planning/request layer that may later result in Appointment, Encounter and Procedure resources. Episode, patient safety, EHDS/Helse-NIM relevant context and selected external clinical context can be included with ServiceRequest.supportingInfo when the context directly affects the requested dental work." />
  <purpose value="Use this profile as the planning or request layer before dental activity is scheduled or performed. Use ServiceRequest.category to distinguish recall, treatment, diagnostic service and follow-up. For recall, set category = dental-recall and use occurrencePeriod or occurrenceTiming to express the due window or cadence; Appointment remains the scheduling resource for the actual proposed or booked time. Performed clinical work should link back to the request with Procedure.basedOn. Follow-up requests created during or after a contact should use ServiceRequest.encounter. Request-level episode context and selected decision context can be carried with ServiceRequest.supportingInfo, for example EpisodeOfCare, no-basis-AllergyIntolerance, relevant Condition, Flag, Consent, QuestionnaireResponse, SFM medication context, DeviceUseStatement, DocumentReference, DiagnosticReport, ImagingStudy or Composition. Do not copy a full patient history into every request." />
  <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" />
      <definition value="DigiDOT planning/request layer for proposed or ordered dental services, including recall. Recall is represented by ServiceRequest.category = dental-recall; Appointment and Encounter represent later workflow states." />
      <constraint>
        <key value="digidot-sr-recall-occurrence" />
        <severity value="error" />
        <human value="A ServiceRequest with category dental-recall SHALL have occurrence[x] to express the recall due date, due window or cadence. The exact booked time belongs on Appointment." />
        <expression value="category.coding.where(system = 'https://novari.no/fhir/digidot/CodeSystem/test-digidot-service-request-category' and code = 'dental-recall').empty() or occurrence.exists()" />
      </constraint>
      <constraint>
        <key value="digidot-sr-recall-plan" />
        <severity value="warning" />
        <human value="A ServiceRequest with category dental-recall SHOULD normally use intent = plan." />
        <expression value="category.coding.where(system = 'https://novari.no/fhir/digidot/CodeSystem/test-digidot-service-request-category' and code = 'dental-recall').empty() or intent = 'plan'" />
      </constraint>
      <constraint>
        <key value="digidot-sr-recall-code" />
        <severity value="warning" />
        <human value="Until DigiDOT terminology work agrees a more precise recall concept, dental-recall ServiceRequests SHOULD include SNOMED CT 185349003 |Encounter for check up (procedure)|." />
        <expression value="category.coding.where(system = 'https://novari.no/fhir/digidot/CodeSystem/test-digidot-service-request-category' and code = 'dental-recall').empty() or code.coding.where(system = 'http://snomed.info/sct' and code = '185349003').exists()" />
      </constraint>
    </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="https://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="https://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" />
      <definition value="Use SNOMED CT to represent what is being requested or planned. For dental-recall, use 185349003 |Encounter for check up (procedure)| until DigiDOT terminology work agrees a more precise dental recall concept. For treatment and diagnostic services, use a precoordinated SNOMED CT concept from the DigiDOT dental procedure value set when it covers the intended request, and optionally add a postcoordinated expression for dental precision." />
      <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="https://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="https://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="https://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="https://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="https://novari.no/fhir/digidot/StructureDefinition/test-digidot-Encounter-no" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Encounter" />
      </type>
    </element>
    <element id="ServiceRequest.supportingInfo">
      <path value="ServiceRequest.supportingInfo" />
      <short value="Episode, patient safety or other supporting context for the dental request." />
      <definition value="Use ServiceRequest.supportingInfo to reference the relevant DigiDOT EpisodeOfCare when the request should explicitly carry episode or course-of-care context. It may also reference selected patient safety, EHDS/Helse-NIM or clinical decision context that directly affects the requested dental work, such as no-basis-AllergyIntolerance, a relevant Condition, a Flag, Consent, QuestionnaireResponse, SFM medication context, DeviceUseStatement, DocumentReference, DiagnosticReport, ImagingStudy or Composition. For follow-up requests created during or after a visit, also populate ServiceRequest.encounter; the episode can then be resolved through Encounter.episodeOfCare. Do not copy the full patient history into every request; include only context that affects this request." />
      <type>
        <code value="Reference" />
        <targetProfile value="https://novari.no/fhir/digidot/StructureDefinition/test-digidot-EpisodeOfCare-no" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/EpisodeOfCare" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-AllergyIntolerance" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/AllergyIntolerance" />
        <targetProfile value="https://novari.no/fhir/digidot/StructureDefinition/test-digidot-Condition-no" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Condition" />
        <targetProfile value="https://novari.no/fhir/digidot/StructureDefinition/test-digidot-Observation-no" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Observation" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Flag" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" />
        <targetProfile value="http://ehelse.no/fhir/StructureDefinition/sfm-lib-List" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/List" />
        <targetProfile value="http://ehelse.no/fhir/StructureDefinition/sfm-MedicationStatement" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/MedicationStatement" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/DeviceUseStatement" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Consent" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/DocumentReference" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/DiagnosticReport" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/ImagingStudy" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Composition" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="ServiceRequest.occurrence[x]">
      <path value="ServiceRequest.occurrence[x]" />
      <short value="Requested timing, due window or cadence for the planned service." />
      <definition value="Use occurrenceDateTime, occurrencePeriod or occurrenceTiming when the planned work has a known or expected time window. For dental-recall, occurrence[x] is mandatory and represents the recall due date, due window or cadence; Appointment remains the scheduling resource for the actual proposed or booked time." />
      <mustSupport value="true" />
    </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="https://novari.no/fhir/digidot/StructureDefinition/test-digidot-Condition-no" />
        <targetProfile value="https://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>
      <mustSupport value="true" />
    </element>
    <element id="ServiceRequest.bodySite">
      <path value="ServiceRequest.bodySite" />
      <short value="Tooth, surface or other dental body site" />
      <definition value="Use bodySite to identify the relevant tooth or teeth and, when needed, tooth surface. Tooth and surface are represented as named slices on bodySite.coding, with required bindings to the DigiDOT teeth and tooth-surfaces ValueSets. If a surface coding is present, exactly one tooth coding must also be present in the same bodySite." />
      <min value="0" />
      <max value="*" />
      <constraint>
        <key value="single-tooth-required-if-surface" />
        <severity value="error" />
        <human value="If tooth surfaces are provided, exactly one tooth must also be provided in the same bodySite." />
        <expression value="coding.where(memberOf('https://novari.no/fhir/digidot/ValueSet/tooth-surfaces')).empty() or coding.where(memberOf('https://novari.no/fhir/digidot/ValueSet/teeth')).count() = 1" />
      </constraint>
      <mustSupport value="true" />
    </element>
    <element id="ServiceRequest.bodySite.coding">
      <path value="ServiceRequest.bodySite.coding" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="$this" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <short value="Tooth and surface codings" />
      <definition value="Open slicing of bodySite.coding. The named tooth and surface slices are identified by required ValueSet bindings, not by separate Coding profiles." />
      <min value="0" />
      <max value="*" />
    </element>
    <element id="ServiceRequest.bodySite.coding:tooth">
      <path value="ServiceRequest.bodySite.coding" />
      <sliceName value="tooth" />
      <short value="Tooth" />
      <definition value="One or more relevant teeth, coded with SNOMED CT and constrained by the DigiDOT teeth ValueSet." />
      <min value="0" />
      <max value="*" />
      <binding>
        <strength value="required" />
        <valueSet value="https://novari.no/fhir/digidot/ValueSet/teeth" />
      </binding>
    </element>
    <element id="ServiceRequest.bodySite.coding:tooth.system">
      <path value="ServiceRequest.bodySite.coding.system" />
      <min value="1" />
      <fixedUri value="http://snomed.info/sct" />
    </element>
    <element id="ServiceRequest.bodySite.coding:tooth.code">
      <path value="ServiceRequest.bodySite.coding.code" />
      <min value="1" />
    </element>
    <element id="ServiceRequest.bodySite.coding:surface">
      <path value="ServiceRequest.bodySite.coding" />
      <sliceName value="surface" />
      <short value="Tooth surface" />
      <definition value="One or more relevant tooth surfaces, coded with SNOMED CT and constrained by the DigiDOT tooth-surfaces ValueSet. A surface coding requires exactly one tooth coding on the same bodySite." />
      <min value="0" />
      <max value="*" />
      <binding>
        <strength value="required" />
        <valueSet value="https://novari.no/fhir/digidot/ValueSet/tooth-surfaces" />
      </binding>
    </element>
    <element id="ServiceRequest.bodySite.coding:surface.system">
      <path value="ServiceRequest.bodySite.coding.system" />
      <min value="1" />
      <fixedUri value="http://snomed.info/sct" />
    </element>
    <element id="ServiceRequest.bodySite.coding:surface.code">
      <path value="ServiceRequest.bodySite.coding.code" />
      <min value="1" />
    </element>
    <element id="ServiceRequest.category">
      <path value="ServiceRequest.category" />
      <short value="Request category: recall, treatment, diagnostic service or follow-up." />
      <definition value="Use category as the coarse DigiDOT workflow marker. Use dental-recall for recall need/next due window, dental-treatment for planned treatment, dental-diagnostic for diagnostic services such as imaging, and dental-follow-up for control/follow-up after a finding or treatment." />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <valueSet value="https://novari.no/fhir/digidot/ValueSet/test-digidot-service-request-category" />
      </binding>
    </element>
    <element id="ServiceRequest.authoredOn">
      <path value="ServiceRequest.authoredOn" />
      <short value="When the request was authored" />
    </element>
  </differential>
</StructureDefinition>