{
  "resourceType": "StructureDefinition",
  "id": "KPI-dotbase",
  "url": "https://simplifier.net/kpi-dotbase/KPI",
  "version": "0.0.1",
  "name": "KPI",
  "title": "KPI Definition",
  "status": "draft",
  "experimental": true,
  "date": "2024-03-09",
  "publisher": "dotbase",
  "description": "This profile defines KPI as a profile of the FHIR Observation",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "type": "Observation",
  "abstract": false,
  "derivation": "constraint",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Observation",
  "differential": {
    "element": [
      {
        "id": "Observation.basedOn",
        "path": "Observation.basedOn",
        "max": "0"
      },
      {
        "id": "Observation.partOf",
        "path": "Observation.partOf",
        "max": "0"
      },
      {
        "id": "Observation.category",
        "path": "Observation.category",
        "min": 1,
        "max": "*",
        "comment": "A category for a general KPI should be provided. Additionally more sub-categories of the KPI can be added.",
        "constraint": [
          {
            "key": "Observation-category",
            "severity": "error",
            "human": "At least one category code must be 'Observation'",
            "expression": "category.where(coding.code='Observation').exists()"
          }
        ]
      },
      {
        "id": "Observation.subject",
        "path": "Observation.subject",
        "max": "0",
        "comment": "FHIR R4 does not support organization references in \"subject\", this changes with R5."
      },
      {
        "id": "Observation.focus",
        "path": "Observation.focus",
        "comment": "Used to reference the organization in regard to the KPI. FHIR R4 does not support organization references in \"subject\", this changes with R5.",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/Organization"
            ]
          }
        ],
        "min": 1,
        "max": "1"
      },
      {
        "id": "Observation.encounter",
        "path": "Observation.encounter",
        "max": "0"
      },
      {
        "id": "Observation.effective[x]",
        "path": "Observation.effective[x]",
        "min": 1,
        "max": "1",
        "comment": "Observation period of the KPI",
        "type": [
          {
            "code": "Period"
          }
        ]
      },
      {
        "id": "Observation.effective[x].start",
        "path": "Observation.effective[x].start",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Observation.performer",
        "path": "Observation.performer",
        "comment": "If the observing organization of the KPI differs to the one provided in \"focus\", an observing organization can be referenced.",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/Organization"
            ]
          }
        ],
        "min": 0,
        "max": "1"
      },
      {
        "id": "Observation.value[x]",
        "path": "Observation.value[x]",
        "min": 0,
        "max": "1",
        "comment": "Value of type valueQuantity of the KPI",
        "type": [
          {
            "code": "Quantity"
          }
        ],
        "constraint": [
          {
            "key": "value-or-dataAbsentReason",
            "severity": "error",
            "human": "Either valueQuantity or dataAbsentReason should be present",
            "expression": "exists(%resource.valueQuantity) or exists(%resource.dataAbsentReason)"
          }
        ]
      },
      {
        "id": "Observation.dataAbsentReason",
        "path": "Observation.dataAbsentReason",
        "min": 0,
        "max": "1",
        "comment": "If value creation failed, a reason for the absent must be provided"
      },
      {
        "id": "Observation.bodySite",
        "path": "Observation.bodySite",
        "max": "0"
      },
      {
        "id": "Observation.specimen",
        "path": "Observation.specimen",
        "max": "0"
      },
      {
        "id": "Observation.device",
        "path": "Observation.device",
        "max": "0"
      },
      {
        "id": "Observation.referenceRange",
        "path": "Observation.referenceRange",
        "min": 0,
        "max": "*",
        "comment": "In context of KPIs this property provides information about key values or ranges of the KPI"
      },
      {
        "id": "Observation.referenceRange.type",
        "path": "Observation.referenceRange.type",
        "min": 1,
        "max": "1",
        "comment": "Type of the referenceRange, e.g. range, baseline, target"
      },
      {
        "id": "Observation.referenceRange.text",
        "path": "Observation.referenceRange.text",
        "min": 0,
        "max": "1",
        "comment": "Description about the referenceRange"
      },
      {
        "id": "Observation.component",
        "path": "Observation.component",
        "max": "0"
      }
    ]
  }
}