Skip to content

Allow discontinued state transition for scheduled worklist items - #239

Merged
steventux merged 3 commits into
mainfrom
allow-discontinued-state-transition-for-scheduled-worklist-items
Sep 22, 2026
Merged

steventux merged 3 commits into
mainfrom
allow-discontinued-state-transition-for-scheduled-worklist-items

Conversation

@steventux

Copy link
Copy Markdown
Contributor

Description

Allow scheduled worklist items to be discontinued.

A worklist item is created in a scheduled state. If no C-STORE operation occurs the worklist item does not transition to in progress.
This prevents an appointment being discontinued before any images are stored. The real world case here is a failed identity check.
This PR eases the transition rules to allow multiple 'from' states. Specifically that scheduled and in progress worklist items can transition discontinued.

Jira link

https://nhsd-jira.digital.nhs.uk/browse/DTOSS-12567

Review notes

Review checklist

  • Check database queries are correctly scoped to current_provider

A worklist item is created in a scheduled state. If no C-STORE operation occurs the worklist items does not transition to in progress. This prevents an appointment/item being discontinued before any images are stored. This commit eases the transition rules to allow multiple 'from' states. Specifically that scheduled and in progress worklist items can be discontinued.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Add storage-level regression coverage for scheduled-to-discontinued updates.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Allows scheduled worklist items to transition directly to discontinued.

Changes:

  • Supports multiple valid source states.
  • Updates SQL status filtering.
  • Adds transition tests and SQLite connection cleanup.
File Summary
tests/​services/​test_storage.py Updates storage test setup and connection cleanup.
tests/​services/​mwl/​test_mwl_status_manager.py Tests transition mappings and validation.
src/​services/​storage.py Applies multi-state transition updates.
src/​services/​mwl/​__init__.py Allows scheduled items to become discontinued.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/services/storage.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved blocking issues were identified.

Review effort: Lite
Findings: None

Resolved since last review (1)

@carlosmartinez

Copy link
Copy Markdown
Contributor

Looks good.

Shall we ticket up a SCHEDULED → COMPLETED transition to go along with Rubie's "switch to manual" functionality?

MWLStatus.COMPLETED: MWLStatus.IN_PROGRESS,
MWLStatus.DISCONTINUED: MWLStatus.IN_PROGRESS,
REVERSED_TRANSITIONS = {
MWLStatus.IN_PROGRESS: [MWLStatus.SCHEDULED],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MWLStatus.IN_PROGRESS: [MWLStatus.SCHEDULED],
MWLStatus.IN_PROGRESS: [MWLStatus.SCHEDULED, IN_PROGRESS],

if we want same-state idempotency for an N-CREATE of the future

@carlosmartinez carlosmartinez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

@steventux
steventux merged commit a82ac11 into main Sep 22, 2026
10 checks passed
@steventux
steventux deleted the allow-discontinued-state-transition-for-scheduled-worklist-items branch September 22, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants