<?xml version="1.0" encoding="UTF-8"?>
<!-- Incident Management (template incident-management).

     Started with: incidentTitle, reportedBy, affectedService.
     Deploy severity_classification.dmn with it: the business rule task evaluates it.

     Incident reported
       -> Triage                         user task; complete with impact and urgency,
                                         each "high", "medium" or "low"
       -> Classify severity              decision severity_classification: severity
                                         (SEV1 to SEV4) and majorIncident (SEV1, SEV2)
       -> Major incident?                yes -> Page the incident commander
       -> Resolve and restore service    user task
       -> Post-mortem needed?            yes (a major incident) -> Write the post-mortem
       -> Closed -->
<definitions
  xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
  xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
  xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
  xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:zeebe="http://camunda.org/schema/zeebe/1.0"
  targetNamespace="http://priostack.com/templates"
  id="def_incident_management">

  <process id="incident_management" name="Incident Management" isExecutable="true">
    <documentation>An IT incident from report to closure: triage, severity from severity_classification.dmn, the incident commander paged for a major incident, resolution, and a post-mortem for a major one.</documentation>

    <startEvent id="incident_reported" name="Incident reported"/>

    <userTask id="triage" name="Triage">
      <documentation>Assess the incident. Complete with impact and urgency, each "high", "medium" or "low".</documentation>
    </userTask>

    <businessRuleTask id="classify_severity" name="Classify severity">
      <extensionElements>
        <zeebe:calledDecision decisionId="severity_classification"/>
      </extensionElements>
    </businessRuleTask>

    <exclusiveGateway id="gw_major" name="Major incident?" default="f_not_major"/>

    <userTask id="page_commander" name="Page the incident commander">
      <documentation>SEV1 or SEV2: the incident commander takes charge, opens the incident channel and keeps stakeholders informed.</documentation>
    </userTask>

    <userTask id="resolve" name="Resolve and restore service">
      <documentation>Restore the service first, then fix the cause. Complete with resolution = what was done.</documentation>
    </userTask>

    <exclusiveGateway id="gw_post_mortem" name="Post-mortem needed?" default="f_no_post_mortem"/>

    <userTask id="post_mortem" name="Write the post-mortem">
      <documentation>Blameless: what happened, why, and the actions that stop it happening again, each with an owner.</documentation>
    </userTask>

    <endEvent id="closed" name="Closed"/>

    <sequenceFlow id="f_reported" sourceRef="incident_reported" targetRef="triage"/>
    <sequenceFlow id="f_triaged" sourceRef="triage" targetRef="classify_severity"/>
    <sequenceFlow id="f_classified" sourceRef="classify_severity" targetRef="gw_major"/>
    <sequenceFlow id="f_major" name="SEV1 or SEV2" sourceRef="gw_major" targetRef="page_commander">
      <conditionExpression xsi:type="tFormalExpression">majorIncident = true</conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="f_not_major" name="SEV3 or SEV4" sourceRef="gw_major" targetRef="resolve"/>
    <sequenceFlow id="f_commander_on" sourceRef="page_commander" targetRef="resolve"/>
    <sequenceFlow id="f_resolved" sourceRef="resolve" targetRef="gw_post_mortem"/>
    <sequenceFlow id="f_needs_post_mortem" name="major" sourceRef="gw_post_mortem" targetRef="post_mortem">
      <conditionExpression xsi:type="tFormalExpression">majorIncident = true</conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="f_no_post_mortem" name="not major" sourceRef="gw_post_mortem" targetRef="closed"/>
    <sequenceFlow id="f_post_mortem_done" sourceRef="post_mortem" targetRef="closed"/>
  </process>

  <bpmndi:BPMNDiagram id="diagram_incident_management">
    <bpmndi:BPMNPlane id="plane_incident_management" bpmnElement="incident_management">
      <bpmndi:BPMNShape id="shape_incident_reported" bpmnElement="incident_reported">
        <dc:Bounds x="82" y="102" width="36" height="36"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="shape_triage" bpmnElement="triage">
        <dc:Bounds x="215" y="80" width="110" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="shape_classify_severity" bpmnElement="classify_severity">
        <dc:Bounds x="385" y="80" width="110" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="shape_gw_major" bpmnElement="gw_major" isMarkerVisible="true">
        <dc:Bounds x="585" y="95" width="50" height="50"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="shape_page_commander" bpmnElement="page_commander">
        <dc:Bounds x="725" y="220" width="110" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="shape_resolve" bpmnElement="resolve">
        <dc:Bounds x="895" y="80" width="110" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="shape_gw_post_mortem" bpmnElement="gw_post_mortem" isMarkerVisible="true">
        <dc:Bounds x="1095" y="95" width="50" height="50"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="shape_post_mortem" bpmnElement="post_mortem">
        <dc:Bounds x="1235" y="220" width="110" height="80"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="shape_closed" bpmnElement="closed">
        <dc:Bounds x="1442" y="102" width="36" height="36"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="edge_f_reported" bpmnElement="f_reported">
        <di:waypoint x="118" y="120"/>
        <di:waypoint x="215" y="120"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="edge_f_triaged" bpmnElement="f_triaged">
        <di:waypoint x="325" y="120"/>
        <di:waypoint x="385" y="120"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="edge_f_classified" bpmnElement="f_classified">
        <di:waypoint x="495" y="120"/>
        <di:waypoint x="585" y="120"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="edge_f_major" bpmnElement="f_major">
        <di:waypoint x="610" y="145"/>
        <di:waypoint x="610" y="260"/>
        <di:waypoint x="725" y="260"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="edge_f_not_major" bpmnElement="f_not_major">
        <di:waypoint x="635" y="120"/>
        <di:waypoint x="895" y="120"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="edge_f_commander_on" bpmnElement="f_commander_on">
        <di:waypoint x="835" y="260"/>
        <di:waypoint x="865" y="260"/>
        <di:waypoint x="865" y="120"/>
        <di:waypoint x="895" y="120"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="edge_f_resolved" bpmnElement="f_resolved">
        <di:waypoint x="1005" y="120"/>
        <di:waypoint x="1095" y="120"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="edge_f_needs_post_mortem" bpmnElement="f_needs_post_mortem">
        <di:waypoint x="1120" y="145"/>
        <di:waypoint x="1120" y="260"/>
        <di:waypoint x="1235" y="260"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="edge_f_no_post_mortem" bpmnElement="f_no_post_mortem">
        <di:waypoint x="1145" y="120"/>
        <di:waypoint x="1442" y="120"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="edge_f_post_mortem_done" bpmnElement="f_post_mortem_done">
        <di:waypoint x="1345" y="260"/>
        <di:waypoint x="1394" y="260"/>
        <di:waypoint x="1394" y="120"/>
        <di:waypoint x="1442" y="120"/>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>
