<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="test-digidot-Procedure-no" />
  <url value="http://novari.no/fhir/digidot/StructureDefinition/test-digidot-Procedure-no" />
  <version value="0.1.0-test" />
  <name value="TestDigidotProcedureNo" />
  <title value="TEST DigiDot Procedure (NO)" />
  <status value="draft" />
  <date value="2026-05-19" />
  <publisher value="Novari AS - DigiDOT" />
  <description value="TEST comparison draft. Not for production use." />
  <purpose value="Use this profile for performed, attempted, stopped or clinically relevant not-done dental work. Clinical SNOMED CT procedure coding must remain separate from tariff, fee and settlement coding." />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Procedure" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Procedure" />
  <derivation value="constraint" />
  <differential>
    <element id="Procedure">
      <path value="Procedure" />
      <constraint>
        <key value="proc-category-recommended" />
        <severity value="warning" />
        <human value="DigiDOT clinical dental procedures should include Procedure.category coding dental-procedure from the DigiDOT procedure category code system." />
        <expression value="category.coding.where(system = 'http://novari.no/fhir/digidot/CodeSystem/test-digidot-procedure-category' and code = 'dental-procedure').exists()" />
      </constraint>
      <constraint>
        <key value="proc-partof-encounter-recommended" />
        <severity value="warning" />
        <human value="DigiDOT sub-procedures that use Procedure.partOf should normally also reference the Encounter where the sub-procedure was performed." />
        <expression value="partOf.empty() or encounter.exists()" />
      </constraint>
      <constraint>
        <key value="proc-status-reason-recommended" />
        <severity value="warning" />
        <human value="Procedures with status stopped, not-done or on-hold should normally include statusReason." />
        <expression value="(status != 'stopped' and status != 'not-done' and status != 'on-hold') or statusReason.exists()" />
      </constraint>
    </element>
    <element id="Procedure.basedOn">
      <path value="Procedure.basedOn" />
      <short value="Planned/requested procedure that this performed procedure is based on." />
      <definition value="Use Procedure.basedOn to connect a performed procedure to a planned, proposed or ordered dental service. This supports procedures that are planned before they are performed and enables traceability from ServiceRequest to Procedure." />
      <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="Procedure.partOf">
      <path value="Procedure.partOf" />
      <short value="Larger performed procedure that this procedure is part of." />
      <definition value="Use Procedure.partOf for performed sub-procedures that are components or stages of a larger performed Procedure. For treatment spanning multiple visits, the default model can be several visit-level Procedures basedOn the same ServiceRequest and connected through Encounter/EpisodeOfCare. Add a parent Procedure only when a summarized overall performed procedure is clinically useful. Do not use Procedure.partOf for the plan/request relation; use Procedure.basedOn for ServiceRequest." />
      <type>
        <code value="Reference" />
        <targetProfile value="http://novari.no/fhir/digidot/StructureDefinition/test-digidot-Procedure-no" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-Procedure" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Procedure" />
      </type>
    </element>
    <element id="Procedure.status">
      <path value="Procedure.status" />
      <short value="Lifecycle status for this concrete procedure occurrence." />
      <definition value="Use Procedure.status for the lifecycle of this specific Procedure resource. For staged dental treatment, visit-level Procedures usually become completed, stopped or not-done. If an optional parent Procedure is used to summarize a larger performed procedure across contacts, it should normally be in-progress while active, on-hold only when genuinely paused, stopped if abandoned, and completed when the overall performed procedure is complete. Do not use Procedure.status as a general treatment plan status; use ServiceRequest.status for the plan/request lifecycle." />
      <min value="1" />
      <max value="1" />
    </element>
    <element id="Procedure.statusReason">
      <path value="Procedure.statusReason" />
      <short value="Why the procedure was stopped, not done or put on hold." />
      <definition value="Use Procedure.statusReason when status is not-done, stopped or on-hold. Prefer SNOMED CT or another agreed code system when a suitable code exists; otherwise use CodeableConcept.text until a DigiDOT reason value set has been agreed." />
      <min value="0" />
      <max value="1" />
    </element>
    <element id="Procedure.category">
      <path value="Procedure.category" />
      <short value="Coarse category for the DigiDOT procedure." />
      <definition value="Use Procedure.category as a coarse category marker for the Procedure resource. For DigiDOT clinical dental procedures this should be dental-procedure, but the profile only recommends this marker to avoid blocking migrated or vendor data where category is missing. The precise clinical meaning must be represented in Procedure.code using SNOMED CT; category must not be used as a replacement for the clinical procedure code." />
      <min value="0" />
      <max value="1" />
      <binding>
        <strength value="preferred" />
        <description value="DigiDOT procedure category. Clinical dental procedures should use dental-procedure when category is included." />
        <valueSet value="http://novari.no/fhir/digidot/ValueSet/test-digidot-procedure-category" />
      </binding>
    </element>
    <element id="Procedure.code">
      <path value="Procedure.code" />
      <min value="1" />
      <constraint>
        <key value="proc-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 intended clinical procedure. The value set represents the reportable/refset procedure values, including values relevant for KPR reporting. For clinical storage, procedures may also be coded with SNOMED CT concepts outside the refset when the refset does not cover the meaning. A postcoordinated SNOMED CT expression may be included as an additional coding for semantic precision." />
        <valueSet value="http://novari.no/fhir/digidot/ValueSet/dental-procedures" />
      </binding>
    </element>
    <element id="Procedure.code.coding">
      <path value="Procedure.code.coding" />
      <slicing>
        <discriminator>
          <type value="profile" />
          <path value="$this" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <min value="1" />
      <max value="2" />
    </element>
    <element id="Procedure.code.coding:SCTpre">
      <path value="Procedure.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 EHR implementations using this profile for storage of clinical data, the precoordinated SNOMED CT coding can contain relevant SNOMED CT concepts beyond the DigiDOT dental procedure refset when no refset code covers the meaning. For national reporting, KPR reporting or other constrained information exchange, the reportable code should be selected from the DigiDOT dental procedure value set/refset. A stricter KPR/reporting profile can later use required binding if validation must enforce only reportable refset values." />
        <valueSet value="http://novari.no/fhir/digidot/ValueSet/dental-procedures" />
      </binding>
    </element>
    <element id="Procedure.code.coding:SCTpost">
      <path value="Procedure.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="Procedure.subject">
      <path value="Procedure.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="Procedure.encounter">
      <path value="Procedure.encounter" />
      <short value="Encounter where the procedure was performed, when the procedure belongs to one concrete encounter." />
      <definition value="Use Procedure.encounter for visit-level procedures. Parent Procedures that summarize staged treatment across several encounters may omit encounter because FHIR Procedure can only point to one Encounter. The child Procedures should carry the concrete Encounter references." />
      <min value="0" />
      <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="Procedure.performed[x]">
      <path value="Procedure.performed[x]" />
      <short value="Time or period of the procedure." />
      <definition value="Use performedDateTime for simple visit-level procedures. Use performedPeriod for staged or long-running procedures; the parent Procedure can have a period from first clinical activity to final completion. Aligns with the HL7 Europe Procedure core pattern where performed[x] is required for exchange." />
      <min value="1" />
    </element>
    <element id="Procedure.performer">
      <path value="Procedure.performer" />
    </element>
    <element id="Procedure.performer.actor">
      <path value="Procedure.performer.actor" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-Practitioner" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Practitioner" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-PractitionerRole" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/PractitionerRole" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-Organization" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Organization" />
      </type>
    </element>
    <element id="Procedure.location">
      <path value="Procedure.location" />
      <max value="1" />
      <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="Procedure.reasonReference">
      <path value="Procedure.reasonReference" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://novari.no/fhir/digidot/StructureDefinition/test-digidot-Condition-no" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Condition" />
      </type>
    </element>
    <element id="Procedure.bodySite">
      <path value="Procedure.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="Procedure.bodySite.coding">
      <path value="Procedure.bodySite.coding" />
      <slicing>
        <discriminator>
          <type value="profile" />
          <path value="$this" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <min value="0" />
      <max value="*" />
    </element>
    <element id="Procedure.bodySite.coding:tooth">
      <path value="Procedure.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="Procedure.bodySite.coding:surface">
      <path value="Procedure.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="Procedure.bodySite.coding.system">
      <path value="Procedure.bodySite.coding.system" />
      <min value="1" />
      <fixedUri value="http://snomed.info/sct" />
    </element>
    <element id="Procedure.outcome">
      <path value="Procedure.outcome" />
      <short value="Procedure outcome when relevant." />
      <definition value="Use Procedure.outcome for clinically meaningful outcome of a completed, stopped or not-done procedure when this can be coded or described. Do not use outcome as a replacement for status; status remains the lifecycle state." />
    </element>
    <element id="Procedure.focalDevice.manipulated">
      <path value="Procedure.focalDevice.manipulated" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://novari.no/fhir/digidot/StructureDefinition/test-digidot-Device-no" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Device" />
      </type>
    </element>
    <element id="Procedure.usedReference">
      <path value="Procedure.usedReference" />
      <short value="Reference to material, substance, medication product or device used in the procedure." />
      <definition value="Use Procedure.usedReference when the material, substance, medication product or device needs its own resource representation. For medication products, prefer SFM medication profiles when the source is SFM." />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-Substance" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Substance" />
        <targetProfile value="http://ehelse.no/fhir/StructureDefinition/sfm-Medication" />
        <targetProfile value="http://ehelse.no/fhir/StructureDefinition/sfm-Magistrell-Medication" />
        <targetProfile value="http://hl7.no/fhir/StructureDefinition/no-basis-Medication" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Medication" />
        <targetProfile value="http://novari.no/fhir/digidot/StructureDefinition/test-digidot-Device-no" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Device" />
      </type>
    </element>
    <element id="Procedure.usedCode">
      <path value="Procedure.usedCode" />
      <short value="Material, substance or equipment used in the procedure." />
      <definition value="Use Procedure.usedCode for simple coding of dental materials, substances or devices used during the procedure when a separate resource is not needed." />
      <min value="0" />
      <max value="*" />
    </element>
  </differential>
</StructureDefinition>