{
  "version": "1.0",
  "methods": [
    {
      "code": "generalize:ageGroup",
      "description": "Replaces a birthDate (or age value) with a coarse age-group label. Protects quasi-identifying precision without discarding analytical utility.",
      "params": {
        "buckets": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[0-9]+-[0-9]+$|^[0-9]+\\+$"
          },
          "description": "Ordered list of age-range strings. Each entry is either a closed range (e.g. 18-30) or an open upper bound (e.g. 81+). Ranges must be non-overlapping and together cover 0–∞.",
          "defaults": {
            "llm-anonymized": [
              "0-17",
              "18-30",
              "31-50",
              "51-65",
              "66-80",
              "81+"
            ],
            "analytics": [
              "0-4",
              "5-9",
              "10-14",
              "15-19",
              "20-24",
              "25-29",
              "30-34",
              "35-39",
              "40-44",
              "45-49",
              "50-54",
              "55-59",
              "60-64",
              "65-69",
              "70-74",
              "75-79",
              "80-84",
              "85-89",
              "90-94",
              "95-99",
              "100+"
            ]
          }
        }
      },
      "errorSemantics": [
        {
          "condition": "birthDate is null or absent",
          "result": "output is null; no error raised"
        },
        {
          "condition": "birthDate cannot be parsed as a date",
          "result": "consumer raises ProcessingError with code=invalid-date"
        },
        {
          "condition": "computed age falls in no bucket",
          "result": "consumer raises ProcessingError with code=age-out-of-range"
        }
      ]
    },
    {
      "code": "generalize:relativeDate",
      "description": "Replaces an absolute date with a relative offset (integer days) computed from a specified reference point within the same FHIR resource context.",
      "params": {
        "referencePoint": {
          "type": "string",
          "enum": [
            "encounter.start",
            "encounter.end",
            "today",
            "request-time",
            "condition.recordedDate"
          ],
          "default": "encounter.start",
          "description": "Closed enumeration of reference points. The consumer realuates the chosen reference point against the resource context. Free-form FHIRPath is not permitted (AW-4)."
        }
      },
      "errorSemantics": [
        {
          "condition": "date field is null or absent",
          "result": "output is null; no error raised"
        },
        {
          "condition": "referencePoint value is not in the closed enum",
          "result": "consumer raises ConfigurationError with code=unknown-reference-point"
        },
        {
          "condition": "referencePoint is in enum but unresolvable in resource context (e.g. encounter.start when no Encounter linked)",
          "result": "consumer raises ProcessingError with code=unresolvable-reference-point"
        }
      ]
    },
    {
      "code": "generalize:icdCategory",
      "description": "Truncates an ICD-10-GM code to a coarser category level, reducing diagnostic precision while retaining broad clinical context.",
      "params": {
        "level": {
          "type": "string",
          "enum": [
            "3char",
            "1char"
          ],
          "default": "3char",
          "description": "3char keeps the first three characters of the ICD code (e.g. J45); 1char keeps only the chapter letter (e.g. J)."
        }
      },
      "errorSemantics": [
        {
          "condition": "code is null or absent",
          "result": "output is null; no error raised"
        },
        {
          "condition": "code does not match ICD-10-GM pattern (letter + digits)",
          "result": "consumer raises ProcessingError with code=invalid-icd-code"
        },
        {
          "condition": "level is not 3char or 1char",
          "result": "consumer raises ConfigurationError with code=unknown-level"
        }
      ]
    },
    {
      "code": "generalize:plzPrefix",
      "description": "Truncates a German postal code (PLZ) to its leading N digits, reducing geographic precision to district or regional level.",
      "params": {
        "length": {
          "type": "integer",
          "minimum": 1,
          "maximum": 4,
          "default": 2,
          "description": "Number of leading digits to retain. 2 = Leitregion (approx. district), 1 = broad regional cluster. Must be between 1 and 4 inclusive."
        }
      },
      "errorSemantics": [
        {
          "condition": "postalCode is null or absent",
          "result": "output is null; no error raised"
        },
        {
          "condition": "postalCode is shorter than length digits",
          "result": "consumer raises ProcessingError with code=plz-too-short"
        },
        {
          "condition": "postalCode contains non-digit characters",
          "result": "consumer raises ProcessingError with code=invalid-plz-format"
        },
        {
          "condition": "length is outside 1–4",
          "result": "consumer raises ConfigurationError with code=invalid-length"
        }
      ]
    }
  ]
}