{
  "resourceType": "StructureDefinition",
  "id": "KT2DeletePendingTask",
  "language": "nl-NL",
  "url": "http://koppeltaal.nl/fhir/StructureDefinition/KT2DeletePendingTask",
  "version": "0.1.0",
  "name": "KT2_DeletePendingTask",
  "status": "draft",
  "date": "2026-07-09",
  "publisher": "VZVZ",
  "contact": [
    {
      "name": "VZVZ",
      "telecom": [
        {
          "system": "email",
          "value": "standaardisatie@vzvz.nl",
          "use": "work"
        }
      ]
    }
  ],
  "description": "The KT2_DeletePendingTask profile represents the announcement that a patient's data within the Koppeltaal service is scheduled for definitive deletion. When the grace period starts, the Koppeltaal service creates one Task per (Patient × participating application); the Task is server-owned but readable by participating applications and carries the server-owned `kt2-delete-flow` security label (`meta.security`). The target application responds through the native Task lifecycle: `on-hold` as a temporary emergency brake and `accepted` as green light. The Task resides in the Patient compartment and is removed together with the Patient. See the page Opschoning Patient-data.",
  "jurisdiction": [
    {
      "coding": [
        {
          "code": "NL",
          "system": "urn:iso:std:iso:3166",
          "display": "Netherlands"
        }
      ]
    }
  ],
  "copyright": "VZVZ",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "Task",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Task",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Task",
        "path": "Task",
        "constraint": [
          {
            "key": "kt2-dpt-status-reason",
            "severity": "error",
            "human": "statusReason is mandatory when status is on-hold and must be absent for every other status",
            "expression": "(status = 'on-hold' implies statusReason.exists()) and (statusReason.exists() implies status = 'on-hold')",
            "source": "http://koppeltaal.nl/fhir/StructureDefinition/KT2DeletePendingTask"
          },
          {
            "key": "kt2-dpt-delete-flow-marker",
            "severity": "error",
            "human": "The Task must carry the server-owned kt2-delete-flow security label, because that marker is what grants applications access to the deletion flow",
            "expression": "meta.security.where(system = 'http://vzvz.nl/fhir/CodeSystem/koppeltaal-security-label' and code = 'kt2-delete-flow').exists()",
            "source": "http://koppeltaal.nl/fhir/StructureDefinition/KT2DeletePendingTask"
          },
          {
            "key": "kt2-dpt-grace-deadline",
            "severity": "error",
            "human": "The grace deadline must lie after the announcement, since the grace period starts at authoredOn",
            "expression": "restriction.period.end > authoredOn",
            "source": "http://koppeltaal.nl/fhir/StructureDefinition/KT2DeletePendingTask"
          }
        ]
      },
      {
        "id": "Task.extension",
        "path": "Task.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "ordered": false,
          "rules": "open"
        }
      },
      {
        "id": "Task.extension:resource-origin",
        "path": "Task.extension",
        "sliceName": "resource-origin",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://koppeltaal.nl/fhir/StructureDefinition/resource-origin"
            ]
          }
        ]
      },
      {
        "id": "Task.instantiatesUri",
        "path": "Task.instantiatesUri",
        "max": "0"
      },
      {
        "id": "Task.basedOn",
        "path": "Task.basedOn",
        "max": "0"
      },
      {
        "id": "Task.groupIdentifier",
        "path": "Task.groupIdentifier",
        "max": "0"
      },
      {
        "id": "Task.status",
        "path": "Task.status",
        "comment": "Native Task lifecycle. The Koppeltaal service sets `requested` (announcement), `cancelled` (renewed patient engagement) and `completed` (deletion executed). The target application only sets `on-hold` (temporary emergency brake) or `accepted` (green light); the server validates every transition.",
        "binding": {
          "strength": "required",
          "valueSet": "http://vzvz.nl/fhir/ValueSet/koppeltaal-delete-pending-task-status"
        }
      },
      {
        "id": "Task.statusReason",
        "path": "Task.statusReason",
        "short": "Reason for the emergency brake when `status = on-hold`",
        "comment": "Coded, from a closed list; `text` is closed off so the reason itself is not a free-text field. It must not be used to convey demographics. Set by the target application in the status write to `on-hold`; the server clears it when `on-hold` is left. The reason lives on the Task only (per application) and is not carried in the aggregated deletion lifecycle AuditEvents.",
        "binding": {
          "strength": "required",
          "valueSet": "http://vzvz.nl/fhir/ValueSet/koppeltaal-delete-hold-reason"
        }
      },
      {
        "id": "Task.statusReason.coding",
        "path": "Task.statusReason.coding",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Task.statusReason.coding.display",
        "path": "Task.statusReason.coding.display",
        "short": "Human-readable description of the emergency-brake reason"
      },
      {
        "id": "Task.statusReason.text",
        "path": "Task.statusReason.text",
        "max": "0"
      },
      {
        "id": "Task.businessStatus",
        "path": "Task.businessStatus",
        "max": "0"
      },
      {
        "id": "Task.intent",
        "path": "Task.intent",
        "fixedCode": "order"
      },
      {
        "id": "Task.code",
        "path": "Task.code",
        "short": "Type of the announcement Task",
        "min": 1,
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "delete-pending",
              "system": "http://vzvz.nl/fhir/CodeSystem/koppeltaal-task-code"
            }
          ]
        },
        "binding": {
          "strength": "required",
          "valueSet": "http://vzvz.nl/fhir/ValueSet/koppeltaal-task-code"
        }
      },
      {
        "id": "Task.description",
        "path": "Task.description",
        "max": "0"
      },
      {
        "id": "Task.focus",
        "path": "Task.focus",
        "max": "0"
      },
      {
        "id": "Task.for",
        "path": "Task.for",
        "short": "The Patient whose data is scheduled for deletion",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://koppeltaal.nl/fhir/StructureDefinition/KT2Patient"
            ]
          }
        ]
      },
      {
        "id": "Task.encounter",
        "path": "Task.encounter",
        "max": "0"
      },
      {
        "id": "Task.authoredOn",
        "path": "Task.authoredOn",
        "short": "Moment of the announcement; the grace period starts here",
        "min": 1
      },
      {
        "id": "Task.requester",
        "path": "Task.requester",
        "short": "The Koppeltaal service announcing the deletion",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://koppeltaal.nl/fhir/StructureDefinition/KT2Device"
            ]
          }
        ]
      },
      {
        "id": "Task.performerType",
        "path": "Task.performerType",
        "max": "0"
      },
      {
        "id": "Task.owner",
        "path": "Task.owner",
        "short": "The target application this announcement is directed at",
        "comment": "Always a Device. Never the Patient or a RelatedPerson, because a Task owned by the patient counts as patient engagement and would reset the retention clock.",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://koppeltaal.nl/fhir/StructureDefinition/KT2Device"
            ]
          }
        ]
      },
      {
        "id": "Task.location",
        "path": "Task.location",
        "max": "0"
      },
      {
        "id": "Task.reasonCode",
        "path": "Task.reasonCode",
        "max": "0"
      },
      {
        "id": "Task.reasonReference",
        "path": "Task.reasonReference",
        "max": "0"
      },
      {
        "id": "Task.insurance",
        "path": "Task.insurance",
        "max": "0"
      },
      {
        "id": "Task.note",
        "path": "Task.note",
        "max": "0"
      },
      {
        "id": "Task.relevantHistory",
        "path": "Task.relevantHistory",
        "max": "0"
      },
      {
        "id": "Task.restriction",
        "path": "Task.restriction",
        "min": 1
      },
      {
        "id": "Task.restriction.period",
        "path": "Task.restriction.period",
        "min": 1
      },
      {
        "id": "Task.restriction.period.end",
        "path": "Task.restriction.period.end",
        "short": "Grace deadline: the planned moment of definitive deletion",
        "comment": "Server-managed: on a grace reset the Koppeltaal service sets a new deadline; applications never modify this element.",
        "min": 1
      },
      {
        "id": "Task.input",
        "path": "Task.input",
        "max": "0"
      },
      {
        "id": "Task.output",
        "path": "Task.output",
        "max": "0"
      }
    ]
  }
}