{
  "resourceType": "http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/ViewDefinition",
  "resource": "Bundle",
  "id": "ViewDefinition-Flag",
  "title": "Alerts / Waarschuwingen",
  "profile": "http://nictiz.nl/fhir/StructureDefinition/zib-Alert",
  "select": [
    {
      "column": [
        {
          "path": "meta.extension('http://hl7.org/fhir/4.0/StructureDefinition/extension-Meta.source').valueUri",
          "name": "Bron",
          "description": "Lookup adhv uri (AGB-Z of OID) <code>&lt;adressering-base&gt;/Organization?identifier=&lt;.meta.tag.code&gt;</code> en gebruik dan <code>Organization.name</code>",
          "type": "string",
          "tag": [ { "name": "Zib element", "value": "nvt" } ]
        },
        {
          "path": "period.start",
          "name": "Datum",
          "type": "dateTime",
          "tag": [ { "name": "Zib element", "value": "BeginDatumTijd" } ]
        },
        {
          "path": "extension.where('http://hl7.org/fhir/StructureDefinition/flag-detail').valueReference.resolve().code.text",
          "name": "Voor(1)",
          "description": "Als geen Voor(1), dan Voor(2), als geen Voor(2) dan Voor(3).<br/><i>De flag-detail Condition opzoeken in de resultaat Bundle.</i>",
          "type": "string",
          "tag": [ { "name": "Zib element", "value": "Conditie::Probleem" } ]
        },
        {
          "path": "code.text | code.coding[0].display",
          "name": "Voor(2)",
          "type": "string",
          "tag": [ { "name": "Zib element", "value": "AlertNaam" } ]
        },
        {
          "path": "extension('http://hl7.org/fhir/StructureDefinition/flag-detail').valueReference.display",
          "name": "Voor(3)",
          "type": "string",
          "tag": [ { "name": "Zib element", "value": "Conditie::Probleem" } ]
        },
        {
          "path": "iif(exists(category.text),category.text,category.coding.display)",
          "name": "Categorie",
          "type": "string",
          "tag": [ { "name": "Zib element", "value": "AlertType" } ]
        },
        {
          "path": "extension('http://hl7.org/fhir/StructureDefinition/flag-detail').valueReference.resolve().clinicalStatus",
          "name": "Status(1)",
          "description": "Logica: als geen Status(1), dan Status(2)<br/>Mapping: <code>active,recurrence</code> naar <code>Actueel</code>; <code>inactive,remission</code> naar <code>Niet actueel</code>",
          "type": "code",
          "tag": [ { "name": "Zib element", "value": "Conditie::Probleem/ProbleemStatus" } ]
        },
        {
          "path": "status",
          "name": "Status(2)",
          "description": "Mapping: <code>active</code> naar <code>Actueel</code>; <code>inactive</code> naar <code>Niet actueel</code> Uitgefilterd: <code>entered-in-error</code> wordt niet getoond in de Zorgviewer, omdat het om foutief ingevoerde data gaat.",
          "type": "code",
          "tag": [ { "name": "Zib element", "value": "nvt" } ]
        }
      ],
      "forEach": "entry.resource.where(resourceType='Flag' and status!='entered-in-error')"
    }
  ]
}