Skip to content

Add practical support workflow with status tracking#3552

Open
Rolling2405 wants to merge 6 commits into
DARIAEngineering:mainfrom
Rolling2405:feature/practical-support-workflow
Open

Add practical support workflow with status tracking#3552
Rolling2405 wants to merge 6 commits into
DARIAEngineering:mainfrom
Rolling2405:feature/practical-support-workflow

Conversation

@Rolling2405

@Rolling2405 Rolling2405 commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

I rule and have completed some work on Case Manager that's ready for review!

This replaces the simple confirmed/fulfilled checkboxes on practical supports with a full status workflow (requested → in progress → approved → completed → cancelled), plus automatic overdue alerts. Case managers can now track practical support requests through their full lifecycle.

This pull request makes the following changes:

  • Add status enum to practical supports (requested, in_progress, approved, completed, cancelled) with status_updated_at timestamp
  • Migrate existing data: fulfilled: true → completed, confirmed: true → approved, neither → requested
  • Replace confirmed/fulfilled checkboxes with a status dropdown and color-coded badges in views
  • Update patient scopes and export logic to use the new status enum
  • Add OverdueSupportAlertJob recurring job that creates notifications for overdue supports

Notes:

  • Data migration included: Converts existing boolean values to the new status enum. The migration is reversible — rollback recreates the boolean columns and backfills from status values.
  • Depends on Add notification center with bell dropdown and real-time delivery #3538 (notification center) for notification delivery in the overdue alert job.
  • Merge order: #3538#3552.

(If there are changes to the views, please include a screenshot so we know what to look for!)

For reviewer:

  • Adjust the title to explain what it does for the notification email to the listserv.
  • Tag this PR:
    • feature if it contains a feature, fix, or similar. This is anything that contains a user-facing fix in some way, such as frontend changes, alterations to backend behavior, or bug fixes.
    • dependencies if it contains library upgrades or similar. This is anything that upgrades any dependency, such as a Gemfile update or npm package upgrade.
  • If it contains neither, no need to tag this PR.

Rolling2405 and others added 3 commits April 7, 2026 18:45
Status workflow:
- 5 statuses: Requested → In Progress → Confirmed → Completed + Cancelled
- Default: Requested (integer enum, 0)
- Any status can transition to Cancelled
- status_updated_at tracks when status last changed
- confirmed_at records when support was confirmed

Color-coded badges:
- Requested: gray (bg-secondary)
- In Progress: cyan (bg-info)
- Confirmed: blue (bg-primary)
- Completed: green (bg-success)
- Cancelled: red (bg-danger)

Views:
- Status badge column added to practical support entries table
- Status dropdown added to practical support edit form
- Status included in permitted params

Overdue detection:
- PracticalSupport.overdue scope: requested/in_progress for >7 days
- PracticalSupport.active scope: excludes completed/cancelled
- OverdueSupportAlertJob runs daily at 7am via Solid Queue
- Notifies admins about overdue supports via notification center

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Change 'type:' to 'notification_type:' and 'related:' to 'link:' in
  OverdueSupportAlertJob to match Notification.notify! API signature
- Replace nonexistent 'related_type'/'related_id' column queries with
  'link'-based duplicate check
- Use BS4 'badge-*' classes instead of BS5 'bg-*' for proper text color

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ensive tests

- Rename enum value 'confirmed' → 'approved' to avoid collision with
  boolean confirmed column (which is removed in the migration)
- Expand→contract migration: add status column, backfill data from
  confirmed/fulfilled booleans, then drop both boolean columns
- Fix overdue scope to use status_updated_at instead of created_at
- Remove confirmed/fulfilled checkboxes from views (replaced by status dropdown)
- Remove confirmed/fulfilled from strong params
- Update Patient.unconfirmed_practical_support to use status enum
- Update Exportable concern to use status instead of booleans
- Update practical_support_display_text helper
- Update factory, controller tests, model tests, helper tests, system tests,
  and exportable tests to use new status enum instead of booleans
- Add comprehensive model tests: enum values, default status, transitions,
  overdue scope, badge_color, track_status_change callback, active scope
- Fix migration version [8.0] → [8.1]
- Fix overdue job to use status_updated_at with fallback to created_at

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rolling2405 and others added 3 commits April 9, 2026 18:06
New records with default status='requested' may have NULL
status_updated_at (from migration or edge cases). COALESCE falls back
to created_at so they aren't silently excluded from overdue detection.

Also initialize status_updated_at on new records via after_initialize
callback for better data consistency going forward.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Two fixes:

1. OverdueSupportAlertJob references the Notification model from the
   unmerged feature/notification-center branch. Add a defined?(Notification)
   guard so the job gracefully skips when the model is unavailable.

2. The AddStatusToPracticalSupports migration violated expand-contract
   by adding new columns and removing old ones in a single migration.
   Split into two migrations:
   - 20250101000006: expand phase (add status enum, backfill data)
   - 20250101000007: contract phase (remove confirmed/fulfilled columns)
   Add self.ignored_columns to PracticalSupport model so ActiveRecord
   ignores the legacy columns between deploy phases.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add OverdueSupportAlertJob tests (guard clause, notification creation, dedup, admin targeting)
- Add cancelled-from-any-state and invalid status enum tests to model
- Add overdue scope boundary tests (in_progress, 7-day boundary, cancelled exclusion)
- Add controller test for status param update via PATCH

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

1 participant