Skip to content

MOD ESS 008 WFL

Domain specifications / D10-ESS / 5. Detailed Functional Requirements / 5.8 Module Specification: Workflow Orchestration and Task Coordination

5.8 Module Specification: Workflow Orchestration and Task Coordination

5.8.1 Module Overview

Module ID: MOD-ESS-008 (module code WFL)

Purpose: Provide state machines, work queues, timers, escalations, task ownership and cross-domain saga coordination as a capability (Architecture 5.1). Each domain defines its own workflows and owns the resulting business records; this module runs the definitions, holds orchestration state and references, and makes stuck work visible.

Business Capabilities: - CAP-ESS-009 Workflow orchestration and task coordination

Primary Actors: - Calling domain service (ACT-ESS-013), workforce user (ACT-ESS-011), workflow and notification administrator (ACT-ESS-010), configuration administrator (ACT-ESS-008)

Dependencies: - MOD-ESS-001, MOD-ESS-002, MOD-ESS-007, MOD-ESS-006, MOD-ESS-012. - Domain 2 event backbone (durable events, outbox and inbox, replay).

5.8.2 Functional Area: Workflow Definition and Execution

Functional Area ID: FA-ESS-023

Description: Versioned workflow definitions and durable execution of instances with timers, retries and compensation.

Scope: - Included: definition registry, instance state, step dispatch through owning-domain APIs, compensation. - Excluded: the clinical or business logic of each step, which runs in the owning domain; pathway runtime (Domain 9), which may use this capability.

5.8.3 Functional Area: Task and Work-Queue Coordination

Functional Area ID: FA-ESS-024

Description: Human task creation, assignment, ownership, due states, queues, stuck-task detection and manual recovery.

Scope: - Included: generic tasks and queues, including Domain 10's own (stewardship, review, approval). - Excluded: domain worklists that are views of a domain's own records (for example nursing worklists in Domain 3, laboratory worklists in Domain 4), which remain in those domains and may register tasks here for cross-domain visibility.

5.8.4 Detailed Requirements

Requirement FR-ESS-WFL-001: Versioned Workflow Definitions and Durable Execution

Attribute Description
Requirement ID FR-ESS-WFL-001
Requirement Name Versioned workflow definitions and durable execution
Requirement Type Functional
Module Workflow Orchestration and Task Coordination
Functional Area FA-ESS-023 Workflow definition and execution
Priority Must
Criticality Critical
Requirement Status Draft
Source PRS section 5 (Enterprise services: workflow); PRS section 8.1; PRS section 8.2 (explicit orchestration / saga patterns and compensating actions); CFG-001 (workflows as governed configuration); SAFE-004; Architecture 5.1 (Workflow/orchestration) and 5.3
Related Business Rule BR-ESS-027, BR-ESS-031
Related Workflow WF-ESS-006, WF-ESS-007

1. Requirement Statement

The system shall execute versioned workflow definitions as durable instances with explicit accepted, pending, completed, failed, cancelled and compensated states, shall drive each step through the owning domain's published API or event, shall make each step idempotent and observable, shall retry under a defined policy, and shall support compensation and manual recovery.

2. Business Rationale

PRS 8.2 requires explicit orchestration and compensating actions where atomic transactions are impossible. Safety-critical and long-running cross-domain work needs explicit state so that nothing is left half done without being seen (REF-002 section 6).

3. Actors and Permissions

Actor Permission Conditions
Configuration administrator of the owning domain Create / Update workflow definitions Through configuration lifecycle with approval
Calling domain service Start, signal, cancel and query instances of its own definitions Registered service identity
Workflow and notification administrator Read all instances; retry, request skip under procedure, trigger compensation Each manual action requires a reason and is audited; a retry returns a Failed instance to Pending; a skip request sends an approval task to the owning domain's queue supervisor, and the instance is Awaiting Approval until it is decided
Queue supervisor of the owning domain Approve or refuse a skip request Approval marks the step skipped and returns the instance to Pending; refusal, with a reason, leaves it Failed

4. Preconditions - The workflow definition version is Active. - The APIs and events it calls are registered in the API catalogue.

5. Trigger - A start request or subscribed event; a timer; a step result; a signal.

6. Functional Behaviour

  1. The system stores workflow definitions as versioned configuration naming steps, the owning domain API or event for each step, timers, retry policy, compensation step and escalation.
  2. The system binds each instance to the definition version active at start and to a business key supplied by the caller; a second start with the same business key and definition returns the existing instance.
  3. The system persists instance state before acknowledging a start and before dispatching each step.
  4. The system dispatches each step with an idempotency key so that a retried step does not create a duplicate business effect.
  5. The system retries failed steps with bounded attempts and backoff, then marks the step Failed and raises it to the recovery worklist.
  6. The system runs timers durably and resumes them after restart.
  7. The system executes compensation steps in reverse order where the definition specifies them, and records the instance as Compensated.
  8. The system stores only orchestration state and references to domain records; it does not store or change the domain records themselves.
  9. The system propagates patient and encounter context, correlation identifier and the initiating actor to every step.
  10. The system emits a workflow-instance-state-changed event (EVT-ESS-014) on each instance state change.
  11. The system does not replay steps blindly after recovery into medication, billing or identity workflows; replay of such steps requires the owning domain's reconciliation rule (Architecture 12.3). The replay-sensitive targets are the one list of CFG-ISE-007 in Domain 2, and a permitted replay uses the same confirmation, with a second person in place, as the integration operations console (OV-112).

7. Input Requirements

Input Field Data Type Mandatory Validation Description
Workflow definition identifier Identifier Yes Active version exists What to run
Business key String Yes Unique per definition for open instances Duplicate-start protection
Context Structured Yes Includes correlation identifier; patient and encounter where applicable Carried to every step
Initiating actor Identity reference Yes Resolvable For authorization and audit
Input payload reference References No References only; no bulk clinical content Step inputs

8. Processing Rules

Rule ID Processing Rule Expected Result
PR-WFL-001-1 Duplicate start with same business key Existing instance returned
PR-WFL-001-2 Step fails after retries Step Failed; instance on recovery worklist; alert by criticality
PR-WFL-001-3 New definition version activated New instances use it; running instances continue on their version
PR-WFL-001-4 Step target unavailable (circuit open) Step waits and retries; instance stays Pending; age visible
PR-WFL-001-5 Step result arrives twice Second result ignored

9. Output Requirements

Output Format Recipient Description
Instance identifier and state API response Calling domain service Accepted, with identifier
Step commands API call / event to owning domain Owning domain service Idempotent command with context
Workflow-instance-state-changed event Event (EVT-ESS-014) Owning domain; Domain 8 State transitions
Recovery worklist Workspace (UI-ESS-009) Workflow administrator Failed and aged instances

10. Validation and Error Handling

Scenario Validation System Response User Message / Action
Unknown or inactive definition Registry check Reject start Error to caller.
Step references unregistered API Validation at approval Definition cannot be approved Listed in validation result.
Workflow service unavailable to caller Caller timeout Caller retains start request in outbox; critical clinical actions must not depend solely on the workflow service being reachable (section 11.2) Caller-specific.
Compensation step fails Step failure Instance Failed with "compensation incomplete"; manual recovery Recovery worklist item, high priority.

11. State and Lifecycle Behaviour

Instances follow Accepted, Pending, Completed, Failed, Cancelled and Compensated (section 4.3). Definitions follow the configuration version lifecycle.

12. Audit Requirements

  • Audited events: definition changes, instance start, cancel, manual retry, skip, compensation, and any administrator intervention with reason.

13. Security and Privacy Requirements

  • Steps execute under the workflow service identity on behalf of the initiating actor; the owning domain still makes its own authorization decision for each command.
  • Instance context is limited to identifiers and references.

14. Acceptance Criteria

  • AC-01: Given a running instance, when the workflow service is restarted, then the instance resumes from its persisted state without repeating completed steps.
  • AC-02: Given a step delivered twice, when the owning domain processes it, then one business effect exists (SAFE-004 support).
  • AC-03: Given a step that fails beyond its retry limit, when the limit is reached, then the instance appears on the recovery worklist with the failure reason.
  • AC-04: Given a definition with compensation, when a later step fails permanently, then compensation steps run in reverse order and the instance is Compensated.
  • AC-05: Given a new definition version, when activated, then running instances complete under their original version.

15. Dependencies and Integration

  • Upstream dependencies: FR-ESS-CFG-001; Domain 2 event backbone.
  • Downstream dependencies: Domains 1, 3, 4, 5, 6, 9 as definition owners and step targets.
  • Required events or APIs: IF-ESS-010; EVT-ESS-014.

16. Open Questions / Assumptions

  • The rule for choosing central orchestration or choreography is set by DEC-ESS-014 (REF-002 section 6), resolved 2026-11-17. The shared workflow engine is used for workflows that have human tasks, timers or escalation and run for hours or longer: approvals, identity stewardship, HIM deficiency and release of information, claim follow-up, referral and access requests. Events (choreography) are used for reactions: admission to bed board, order to ancillary work list, result to inbox, charge capture. Tier 1 closed loops (medication administration, transfusion verification, critical result acknowledgement) stay as state machines inside the owning domain, so that the engine can be operated at Tier 2. Each remaining workflow is decided with this rule by the owning domain and the Enterprise Architecture Board and recorded in a table.
  • Whether Domain 9's pathway runtime is built on this capability is a design decision for Domain 9.

Requirement FR-ESS-WFL-002: Task and Work-Queue Coordination with Stuck-Task Recovery

Attribute Description
Requirement ID FR-ESS-WFL-002
Requirement Name Task and work-queue coordination with stuck-task recovery
Requirement Type Functional
Module Workflow Orchestration and Task Coordination
Functional Area FA-ESS-024 Task and work-queue coordination
Priority Must
Criticality High
Requirement Status Draft
Source Architecture 5.1 (work queues, timers, escalations, task ownership, manual recovery); CFG-001 (queues); DAT-005 (stewardship items assigned, resolved and measured); contributes to NUR-004 and ORD-005 (primary Domain 3)
Related Business Rule BR-ESS-026
Related Workflow WF-ESS-007, WF-ESS-008

1. Requirement Statement

The system shall create, assign and track human tasks in configurable work queues with an owner, a due time and a state at all times, shall mark tasks overdue and escalate them, shall detect tasks and queues that are not progressing, and shall provide authorized manual reassignment and recovery.

2. Business Rationale

Review, approval, stewardship and cross-domain follow-up work must not be lost when its assignee leaves, a queue is unattended, or an automated step stalls.

3. Actors and Permissions

Actor Permission Conditions
Calling domain service Create / cancel / complete tasks of its own types Registered task types
Workforce user Read assigned and queue tasks; claim; complete; release Authorized for the queue and the subject
Queue supervisor Reassign; reprioritize For supervised queues
Workflow and notification administrator Read all; reassign; recover Reason required

4. Preconditions - The task type and queue are registered with owning domain, eligible roles and escalation rule.

5. Trigger - Workflow step; domain request; domain event (for example PathwayConflictDetected, part 6.11); timer; assignee state change.

6. Functional Behaviour

  1. The system creates a task with type, subject references, priority, queue or assignee, due time, originating workflow or record reference and required completion evidence.
  2. The system assigns tasks to a user, a role or a queue, and shows queue tasks to all eligible users.
  3. The system records claim, release, start and completion with user and time.
  4. The system marks a task Overdue at its due time and applies the escalation rule, using the notification service.
  5. The system returns to its queue, and flags, any task whose assignee account is suspended or whose role assignment is revoked.
  6. The system detects stuck work: tasks open beyond a configured age without state change, queues with no eligible active users, and queues whose oldest item exceeds a configured age.
  7. The system lists stuck work on the administration worklist and alerts the queue supervisor.
  8. The system records manual reassignment and recovery with reason.
  9. The system reports queue volume, age, completion time and overdue rate per task type.
  10. The system completes a task only when the owning domain confirms the business outcome where the task type requires confirmation; ticking a task does not by itself change a domain record.
  11. On PathwayConflictDetected (EVT-EBP-021) from Domain 9, the system creates a task of type "Pathway conflict review" (set 17 Nov 2026). The task names the patient, the encounter, the two pathway instances and the conflict. It is assigned to the attending practitioner of the encounter, as recorded by Domain 1. When no attending practitioner is recorded, or the attending practitioner has no active account, it goes to the unit supervisor on duty (CFG-EBP-015). The conflict identifier is the idempotency key, so a redelivered event creates no second task. Priority is High and the due time is 24 hours, after which the escalation rule applies. Domain 9 owns the task type and confirms completion when the clinician has recorded a decision on the conflict.

7. Input Requirements

Input Field Data Type Mandatory Validation Description
Task type Code Yes Registered Determines queue rules
Subject references References Yes Resolvable Patient, record or item concerned
Priority Code Yes Value set Ordering
Assignee or queue Reference Yes Active user, role or queue Ownership
Due time Date-time Yes In the future at creation, or explicit overdue flag Deadline
Completion evidence Structured Conditional Per task type What must be recorded

8. Processing Rules

Rule ID Processing Rule Expected Result
PR-WFL-002-1 Assignee becomes unavailable Task returned to queue and flagged
PR-WFL-002-2 Due time passes Overdue; escalation rule applied
PR-WFL-002-3 Queue has no eligible active user Stuck-queue alert to supervisor and administrator
PR-WFL-002-4 Duplicate create with same idempotency key Existing task returned
PR-WFL-002-5 PathwayConflictDetected received Pathway conflict review task to the attending practitioner; fallback the unit supervisor on duty; one task per conflict

9. Output Requirements

Output Format Recipient Description
Task API resource; workspace item Assignee, queue members Work to do
Task-state-changed event Event (EVT-ESS-010) Owning domain; Domain 8 Assignment, overdue, completion
Task and queue report Report (REP-ESS-012) Queue supervisors, owning domains Volume, age, overdue, stuck

10. Validation and Error Handling

Scenario Validation System Response User Message / Action
User not eligible for queue Authorization Deny claim "You are not eligible for this queue."
Task already claimed State check Inform "This task has been claimed by another user."
Completion evidence missing Type rule Refuse completion "Complete the required fields."

11. State and Lifecycle Behaviour

Tasks follow Created, Assigned, In Progress, Overdue, Escalated, Completed, Cancelled and Failed (section 4.3).

12. Audit Requirements

  • Audited events: creation, assignment, claim, release, completion, cancellation, reassignment and manual recovery with reason.

13. Security and Privacy Requirements

  • Task lists show the minimum subject information for the user's role; opening the subject triggers a normal authorization decision.

14. Acceptance Criteria

  • AC-01: Given a task assigned to a user whose account is suspended, when suspension takes effect, then the task returns to its queue and is flagged.
  • AC-02: Given an overdue task with an escalation rule, when the due time passes, then the supervisor is notified and the task shows as Overdue.
  • AC-03: Given a queue with no eligible active users, when the stuck-work check runs, then an alert is raised.
  • AC-04: Given a stewardship queue, when the report is produced, then items are shown as assigned, resolved and measured by age (DAT-005 acceptance).
  • AC-05: Given a manual reassignment, when performed, then the audit record contains actor, reason, previous and new assignee.
  • AC-06: Given a PathwayConflictDetected event for an encounter with an attending practitioner, when it is received twice, then one pathway conflict review task exists, assigned to that practitioner; for an encounter without an attending practitioner, the task goes to the unit supervisor on duty.

15. Dependencies and Integration

16. Open Questions / Assumptions

  • The boundary between shared tasks and domain-owned worklists follows the rule of DEC-ESS-014, resolved 2026-11-17. Clinical nursing tasks and order worklists remain in Domains 3 and 4, with task state in the Domain 3 service and the cross-domain work list provided here as a read view (DEC-CLI-007); HIM work items run on this capability, with HIM owning the definitions (DEC-HIM-004).
  • Stuck-work age thresholds are proposed configuration values (CFG-ESS-015).

← 5.7 Module Specification: Notification Service | Contents | Identifier index | 5.9 Module Specification: Document Service and Secure Document References →