{
  "resourceType": "StructureDefinition",
  "id": "KjFlag",
  "meta": {
    "lastUpdated": "2020-10-18T13:38:32.418+00:00"
  },
  "url": "http://nhn.no/kj/fhir/StructureDefinition/KjFlag",
  "name": "KjFlag",
  "status": "active",
  "date": "2020-10-18T13:34:09.4865509+00:00",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "Flag",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Flag",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Flag",
        "path": "Flag",
        "constraint": [
          {
            "key": "kj-fla-1",
            "human": "Except for blood treatment reservations, note shall be present",
            "source": "http://nhn.no/kj/fhir/StructureDefinition/KjFlag",
            "severity": "error",
            "expression": "(code.coding.where(system='http://nhn.no/kj/fhir/CodeSystem/OtherProceduralChanges' and code = '1').exists()) or (code.coding.where(system='http://nhn.no/kj/fhir/CodeSystem/OtherProceduralChanges' and code != '1').exists() and extension.where(url='http://nhn.no/kj/fhir/StructureDefinition/KjText').exists())"
          }
        ]
      },
      {
        "id": "Flag.extension",
        "path": "Flag.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Flag.extension:note",
        "path": "Flag.extension",
        "sliceName": "note",
        "short": "Field for additional comments",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://nhn.no/kj/fhir/StructureDefinition/KjText"
            ]
          }
        ],
        "constraint": [
          {
            "key": "kj-fla-3",
            "human": "If note is present, then text must be between 4 and 500 characters.",
            "source": "http://nhn.no/kj/fhir/StructureDefinition/KjFlag",
            "severity": "error",
            "expression": "empty() or (first().value.length() >=4 and first().value.length() <= 500)"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Flag.extension:note.value[x]",
        "extension": [
          null,
          {
            "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version",
            "valueCode": "4.0.0"
          }
        ],
        "path": "Flag.extension.value[x]",
        "slicing": {
          "discriminator": [
            {
              "type": "type",
              "path": "$this"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Flag.extension:updatedDateTime",
        "path": "Flag.extension",
        "sliceName": "updatedDateTime",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://nhn.no/kj/fhir/StructureDefinition/KjUpdatedDateTime"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Flag.extension:updatedDateTime.value[x]",
        "extension": [
          null,
          {
            "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version",
            "valueCode": "4.0.0"
          }
        ],
        "path": "Flag.extension.value[x]",
        "slicing": {
          "discriminator": [
            {
              "type": "type",
              "path": "$this"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Flag.extension:updater",
        "path": "Flag.extension",
        "sliceName": "updater",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://nhn.no/kj/fhir/StructureDefinition/KjUpdater"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Flag.extension:updater.value[x]",
        "extension": [
          null,
          {
            "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version",
            "valueCode": "4.0.0"
          }
        ],
        "path": "Flag.extension.value[x]",
        "slicing": {
          "discriminator": [
            {
              "type": "type",
              "path": "$this"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Flag.status",
        "extension": [
          null,
          {
            "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version",
            "valueCode": "4.0.0"
          }
        ],
        "path": "Flag.status",
        "definition": "Normal = active, slettet = entered-in-error, avkreftet = inactive",
        "mustSupport": true
      },
      {
        "id": "Flag.category",
        "path": "Flag.category",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "coding.system"
            }
          ],
          "rules": "open"
        },
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Flag.category:KjCategory",
        "path": "Flag.category",
        "sliceName": "KjCategory",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Flag.category:KjCategory.coding",
        "path": "Flag.category.coding",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Flag.category:KjCategory.coding.system",
        "extension": [
          null,
          {
            "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version",
            "valueCode": "4.0.0"
          }
        ],
        "path": "Flag.category.coding.system",
        "min": 1,
        "fixedUri": "http://nhn.no/kj/fhir/CodeSystem/SubcategoriesOfCriticalInformation"
      },
      {
        "id": "Flag.category:KjCategory.coding.code",
        "extension": [
          null,
          {
            "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version",
            "valueCode": "4.0.0"
          }
        ],
        "path": "Flag.category.coding.code",
        "min": 1,
        "fixedCode": "9"
      },
      {
        "id": "Flag.code",
        "path": "Flag.code",
        "constraint": [
          {
            "key": "kj-fla-2",
            "human": "Except for blood treatment reservations, text shall be present",
            "source": "http://nhn.no/kj/fhir/StructureDefinition/KjFlag",
            "severity": "error",
            "expression": "(coding.where(system='http://nhn.no/kj/fhir/CodeSystem/OtherProceduralChanges' and code = '1').exists() and text.empty()) or (coding.where(system='http://nhn.no/kj/fhir/CodeSystem/OtherProceduralChanges' and code != '1').exists() and text.exists())"
          }
        ],
        "mustSupport": true,
        "binding": {
          "strength": "extensible",
          "valueSet": "http://nhn.no/kj/fhir/ValueSet/FlagCode"
        }
      },
      {
        "id": "Flag.code.coding",
        "path": "Flag.code.coding",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "system"
            }
          ],
          "rules": "open"
        },
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Flag.code.coding:OtherProceduralChanges",
        "path": "Flag.code.coding",
        "sliceName": "OtherProceduralChanges",
        "min": 1,
        "max": "1",
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "http://nhn.no/kj/fhir/ValueSet/FlagCode"
        }
      },
      {
        "id": "Flag.code.coding:OtherProceduralChanges.system",
        "extension": [
          null,
          {
            "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version",
            "valueCode": "4.0.0"
          }
        ],
        "path": "Flag.code.coding.system",
        "min": 1,
        "fixedUri": "http://nhn.no/kj/fhir/CodeSystem/OtherProceduralChanges"
      },
      {
        "id": "Flag.code.text",
        "extension": [
          {
            "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-translatable",
            "valueBoolean": true
          },
          {
            "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version",
            "valueCode": "4.0.0"
          }
        ],
        "path": "Flag.code.text",
        "short": "Additional text",
        "constraint": [
          {
            "key": "kj-fla-4",
            "human": "Text can be maximum 80 characters",
            "source": "http://nhn.no/kj/fhir/StructureDefinition/KjFlag",
            "severity": "error",
            "expression": "value.length() <= 80"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Flag.subject",
        "path": "Flag.subject",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.no/fhir/StructureDefinition/no-basis-Patient"
            ],
            "aggregation": [
              "referenced"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Flag.period",
        "path": "Flag.period",
        "definition": "Period.start = When created\r\nPeriod.end = When ended",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Flag.period.start",
        "extension": [
          null,
          {
            "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version",
            "valueCode": "4.0.0"
          }
        ],
        "path": "Flag.period.start",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Flag.period.end",
        "extension": [
          null,
          {
            "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version",
            "valueCode": "4.0.0"
          }
        ],
        "path": "Flag.period.end",
        "mustSupport": true
      },
      {
        "id": "Flag.author",
        "path": "Flag.author",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://nhn.no/kj/fhir/StructureDefinition/KjPractitionerRole"
            ],
            "aggregation": [
              "contained"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Flag.author.reference",
        "extension": [
          null,
          {
            "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version",
            "valueCode": "4.0.0"
          }
        ],
        "path": "Flag.author.reference",
        "min": 1
      }
    ]
  }
}