<?xml version="1.0" encoding="UTF-8"?>
<!-- Audit investigation case (template audit-workflow): the evidence and findings of an
     internal audit, run from the step "Collect the evidence" of audit_workflow.bpmn.

     Started with: auditType, period (the same as the audit's) and findingsSeverity
     as null, as the template's sample variables do.

     Stage Evidence collection         required
       Request the documents           human task, required
       Test a sample of transactions   human task, required
       Evidence complete               milestone, once both tasks are complete
     Stage Findings                    required; opens when the evidence is complete
       Document the findings           human task, required; complete with
                                       findingsSeverity = "none", "minor" or "major"
       Findings documented             milestone
     Escalate to the audit committee   human task, offered and required only when the
                                       findings were documented as "major"

     The case completes when everything it requires is done, so it waits for the
     escalation when there is one and for nothing else when there is not. The
     escalation sits on the case plan rather than in the Findings stage: this
     engine evaluates a conditional requiredRule when it completes the case, but
     inside a stage it counts any item that has one as required. A case started
     with no findingsSeverity at all keeps the escalation required and waits. -->
<definitions
  xmlns="http://www.omg.org/spec/CMMN/20151109/MODEL"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:cmmndi="http://www.omg.org/spec/CMMN/20151109/CMMNDI"
  xmlns:dc="http://www.omg.org/spec/CMMN/20151109/DC"
  targetNamespace="http://priostack.com/templates"
  id="def_audit_investigation">
  <case id="audit_investigation" name="Audit Investigation">
    <casePlanModel id="cpm_audit" name="Audit Investigation">
      <sentry id="sentry_findings_entry">
        <planItemOnPart sourceRef="evidence_complete">
          <standardEvent>occur</standardEvent>
        </planItemOnPart>
      </sentry>
      <sentry id="sentry_major_finding">
        <planItemOnPart sourceRef="document_findings">
          <standardEvent>complete</standardEvent>
        </planItemOnPart>
        <ifPart><condition><body>findingsSeverity = "major"</body></condition></ifPart>
      </sentry>
      <planItem id="stage_evidence" name="Evidence collection" definitionRef="stage_evidence_def">
        <itemControl>
          <requiredRule><condition><body>true</body></condition></requiredRule>
        </itemControl>
      </planItem>
      <planItem id="stage_findings" name="Findings" definitionRef="stage_findings_def">
        <itemControl>
          <requiredRule><condition><body>true</body></condition></requiredRule>
        </itemControl>
        <entryCriterion id="crit_findings_entry" sentryRef="sentry_findings_entry"/>
      </planItem>
      <planItem id="escalate_to_committee" name="Escalate to the audit committee" definitionRef="escalate_to_committee_def">
        <itemControl>
          <requiredRule><condition><body>findingsSeverity = "major"</body></condition></requiredRule>
        </itemControl>
        <entryCriterion id="crit_major_finding" sentryRef="sentry_major_finding"/>
      </planItem>

      <stage id="stage_evidence_def" name="Evidence collection" autoComplete="true">
        <sentry id="sentry_evidence_complete">
          <planItemOnPart sourceRef="request_documents">
            <standardEvent>complete</standardEvent>
          </planItemOnPart>
          <planItemOnPart sourceRef="test_sample">
            <standardEvent>complete</standardEvent>
          </planItemOnPart>
        </sentry>
        <planItem id="request_documents" name="Request the documents" definitionRef="request_documents_def">
          <itemControl>
            <requiredRule><condition><body>true</body></condition></requiredRule>
          </itemControl>
        </planItem>
        <planItem id="test_sample" name="Test a sample of transactions" definitionRef="test_sample_def">
          <itemControl>
            <requiredRule><condition><body>true</body></condition></requiredRule>
          </itemControl>
        </planItem>
        <planItem id="evidence_complete" name="Evidence complete" definitionRef="evidence_complete_def">
          <entryCriterion id="crit_evidence_complete" sentryRef="sentry_evidence_complete"/>
        </planItem>
        <humanTask id="request_documents_def" name="Request the documents" isBlocking="true">
          <documentation>Ask the process owners for the ledgers, policies and approvals in scope for the period.</documentation>
        </humanTask>
        <humanTask id="test_sample_def" name="Test a sample of transactions" isBlocking="true">
          <documentation>Pick a sample of the period's transactions and check each against its evidence and the controls.</documentation>
        </humanTask>
        <milestone id="evidence_complete_def" name="Evidence complete"/>
      </stage>

      <stage id="stage_findings_def" name="Findings" autoComplete="true">
        <sentry id="sentry_findings_documented">
          <planItemOnPart sourceRef="document_findings">
            <standardEvent>complete</standardEvent>
          </planItemOnPart>
        </sentry>
        <planItem id="document_findings" name="Document the findings" definitionRef="document_findings_def">
          <itemControl>
            <requiredRule><condition><body>true</body></condition></requiredRule>
          </itemControl>
        </planItem>
        <planItem id="findings_documented" name="Findings documented" definitionRef="findings_documented_def">
          <entryCriterion id="crit_findings_documented" sentryRef="sentry_findings_documented"/>
        </planItem>
        <humanTask id="document_findings_def" name="Document the findings" isBlocking="true">
          <documentation>Write each finding with its evidence and risk. Complete with findingsSeverity = "none", "minor" or "major".</documentation>
        </humanTask>
        <milestone id="findings_documented_def" name="Findings documented"/>
      </stage>

      <humanTask id="escalate_to_committee_def" name="Escalate to the audit committee" isBlocking="true">
        <documentation>A major finding: brief the audit committee before the report is written.</documentation>
      </humanTask>
    </casePlanModel>
    <caseFileModel>
      <caseFileItem id="cf_scope" name="Audit scope"/>
      <caseFileItem id="cf_evidence" name="Evidence"/>
      <caseFileItem id="cf_findings" name="Findings"/>
    </caseFileModel>
  </case>

  <cmmndi:CMMNDI>
    <cmmndi:CMMNDiagram id="CMMNDiagram_audit">
      <cmmndi:CMMNShape id="DI_cpm_audit" cmmnElementRef="cpm_audit">
        <dc:Bounds x="30" y="30" width="900" height="420"/>
      </cmmndi:CMMNShape>
      <cmmndi:CMMNShape id="DI_stage_evidence" cmmnElementRef="stage_evidence">
        <dc:Bounds x="70" y="90" width="360" height="300"/>
      </cmmndi:CMMNShape>
      <cmmndi:CMMNShape id="DI_request_documents" cmmnElementRef="request_documents">
        <dc:Bounds x="100" y="150" width="140" height="80"/>
      </cmmndi:CMMNShape>
      <cmmndi:CMMNShape id="DI_test_sample" cmmnElementRef="test_sample">
        <dc:Bounds x="260" y="150" width="140" height="80"/>
      </cmmndi:CMMNShape>
      <cmmndi:CMMNShape id="DI_evidence_complete" cmmnElementRef="evidence_complete">
        <dc:Bounds x="175" y="300" width="150" height="50"/>
      </cmmndi:CMMNShape>
      <cmmndi:CMMNShape id="DI_stage_findings" cmmnElementRef="stage_findings">
        <dc:Bounds x="470" y="90" width="250" height="300"/>
      </cmmndi:CMMNShape>
      <cmmndi:CMMNShape id="DI_document_findings" cmmnElementRef="document_findings">
        <dc:Bounds x="525" y="150" width="140" height="80"/>
      </cmmndi:CMMNShape>
      <cmmndi:CMMNShape id="DI_findings_documented" cmmnElementRef="findings_documented">
        <dc:Bounds x="530" y="300" width="150" height="50"/>
      </cmmndi:CMMNShape>
      <cmmndi:CMMNShape id="DI_escalate_to_committee" cmmnElementRef="escalate_to_committee">
        <dc:Bounds x="760" y="200" width="140" height="80"/>
      </cmmndi:CMMNShape>
    </cmmndi:CMMNDiagram>
  </cmmndi:CMMNDI>
</definitions>
