{
  "resourceType": "StructureDefinition",
  "id": "pilot-digidot-Condition-no",
  "url": "https://novari.no/fhir/digidot/StructureDefinition/pilot-digidot-Condition-no",
  "version": "0.2.2",
  "name": "PilotDigidotConditionNo",
  "title": "Pilot DigiDOT Condition (NO)",
  "status": "draft",
  "date": "2025-09-17",
  "publisher": "Novari AS - DigiDot",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "Condition",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Condition",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Condition",
        "path": "Condition"
      },
      {
        "id": "Condition.clinicalStatus",
        "path": "Condition.clinicalStatus",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Condition.code",
        "path": "Condition.code",
        "min": 1,
        "constraint": [
          {
            "key": "cond-sct-min1",
            "severity": "warning",
            "human": "At least one SNOMED CT code (pre- or postcoordinated) should be present.",
            "expression": "coding.where(system = 'http://snomed.info/sct').exists()"
          }
        ]
      },
      {
        "id": "Condition.code.coding",
        "path": "Condition.code.coding",
        "slicing": {
          "discriminator": [
            {
              "type": "profile",
              "path": "$this"
            }
          ],
          "rules": "open"
        },
        "min": 1,
        "max": "2"
      },
      {
        "id": "Condition.code.coding:SCTpre",
        "path": "Condition.code.coding",
        "sliceName": "SCTpre",
        "min": 1,
        "max": "1",
        "type": [
          {
            "code": "Coding",
            "profile": [
              "https://novari.no/fhir/digidot/StructureDefinition/pilot-digidot-Coding-SCTpre-no"
            ]
          }
        ],
        "binding": {
          "strength": "required",
          "valueSet": "https://novari.no/fhir/digidot/ValueSet/pilot-digidot-ValueSet-conditions"
        }
      },
      {
        "id": "Condition.code.coding:SCTpost",
        "path": "Condition.code.coding",
        "sliceName": "SCTpost",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Coding",
            "profile": [
              "https://novari.no/fhir/digidot/StructureDefinition/pilot-digidot-Coding-SCTpost-no"
            ]
          }
        ]
      },
      {
        "id": "Condition.bodySite",
        "path": "Condition.bodySite",
        "min": 0,
        "max": "*",
        "constraint": [
          {
            "key": "single-tooth-required-if-surface",
            "severity": "error",
            "human": "If tooth surfaces are provided, exactly one tooth must also be provided in the same bodySite.",
            "expression": "coding.where(memberOf('https://novari.no/fhir/digidot/ValueSet/pilot-digidot-ValueSet-tooth-surfaces')).empty() or coding.where(memberOf('https://novari.no/fhir/digidot/ValueSet/pilot-digidot-ValueSet-teeth')).count() = 1"
          }
        ],
        "short": "Tooth, surface or other dental body site",
        "definition": "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."
      },
      {
        "id": "Condition.bodySite.coding",
        "path": "Condition.bodySite.coding",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "$this"
            }
          ],
          "rules": "open"
        },
        "min": 0,
        "max": "*",
        "short": "Tooth and surface codings",
        "definition": "Open slicing of bodySite.coding. The named tooth and surface slices are identified by required ValueSet bindings, not by separate Coding profiles."
      },
      {
        "id": "Condition.bodySite.coding:tooth",
        "path": "Condition.bodySite.coding",
        "sliceName": "tooth",
        "min": 0,
        "max": "*",
        "short": "Tooth",
        "definition": "One or more relevant teeth, coded with SNOMED CT and constrained by the DigiDOT teeth ValueSet.",
        "binding": {
          "strength": "required",
          "valueSet": "https://novari.no/fhir/digidot/ValueSet/pilot-digidot-ValueSet-teeth"
        }
      },
      {
        "id": "Condition.bodySite.coding:tooth.system",
        "path": "Condition.bodySite.coding.system",
        "min": 1,
        "fixedUri": "http://snomed.info/sct"
      },
      {
        "id": "Condition.bodySite.coding:tooth.code",
        "path": "Condition.bodySite.coding.code",
        "min": 1
      },
      {
        "id": "Condition.bodySite.coding:surface",
        "path": "Condition.bodySite.coding",
        "sliceName": "surface",
        "min": 0,
        "max": "*",
        "short": "Tooth surface",
        "definition": "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.",
        "binding": {
          "strength": "required",
          "valueSet": "https://novari.no/fhir/digidot/ValueSet/pilot-digidot-ValueSet-tooth-surfaces"
        }
      },
      {
        "id": "Condition.bodySite.coding:surface.system",
        "path": "Condition.bodySite.coding.system",
        "min": 1,
        "fixedUri": "http://snomed.info/sct"
      },
      {
        "id": "Condition.bodySite.coding:surface.code",
        "path": "Condition.bodySite.coding.code",
        "min": 1
      },
      {
        "id": "Condition.subject",
        "path": "Condition.subject",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.no/fhir/StructureDefinition/no-basis-Patient",
              "http://hl7.org/fhir/StructureDefinition/Patient"
            ]
          }
        ]
      },
      {
        "id": "Condition.encounter",
        "path": "Condition.encounter",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://novari.no/fhir/digidot/StructureDefinition/pilot-digidot-Encounter-no",
              "http://hl7.org/fhir/StructureDefinition/Encounter"
            ]
          }
        ]
      },
      {
        "id": "Condition.asserter",
        "path": "Condition.asserter",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.no/fhir/StructureDefinition/no-basis-Practitioner",
              "http://hl7.org/fhir/StructureDefinition/Practitioner"
            ]
          },
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.no/fhir/StructureDefinition/no-basis-PractitionerRole",
              "http://hl7.org/fhir/StructureDefinition/PractitionerRole"
            ]
          }
        ]
      },
      {
        "id": "Condition.note",
        "path": "Condition.note",
        "min": 0,
        "max": "1"
      }
    ]
  }
}