Skip to content

feat(roster): add Nurse Roster SPA with auto-load, dialog, and past date protection#2

Merged
av-dev2 merged 20 commits intonurse-ot-modulefrom
feat_nurse_ot_module
Apr 7, 2026
Merged

feat(roster): add Nurse Roster SPA with auto-load, dialog, and past date protection#2
av-dev2 merged 20 commits intonurse-ot-modulefrom
feat_nurse_ot_module

Conversation

@av-dev2
Copy link
Copy Markdown
Owner

@av-dev2 av-dev2 commented Apr 7, 2026

Nurse Roster SPA (Task 6 - Design A)

Summary

Implements the Nurse Roster single-page application for managing nurse-to-ward/room assignments across dates. This is a complete frontend + backend feature built with Vue 3 (Composition API), Pinia, and Frappe UI.

Backend (roster.py)

  • get_roster_data: Fetches nurses (by company) and their schedule assignments for a date range
  • get_service_options: Returns service unit types and service units for dropdown population
  • save_roster_assignments: Batch processes add/edit/remove roster changes against Nursing Schedule documents
  • nursing_schedule_list.js: Adds "Open Roster" button to Nursing Schedule list view

Frontend SPA

  • Layout: CRM-style collapsible sidebar with Nurse Roster (active) and Nursing Schedule navigation
  • Auto-load: Roster auto-loads when all filter fields (Company, Frequency, Start Date, End Date) are populated — no button needed
  • Centered UI: Title, subtitle (light blue), and filter fields are centered
  • Field order: Company → Frequency → Start Date → End Date (auto-calculated from frequency)
  • Assignment Dialog: Clean Dialog component with searchable Autocomplete fields for Service Unit Type and Service Unit (handles 100+ options)
  • Past Date Protection: No edit icon or dialog for backdated assignments; past assignments retain same blue pill styling as current/future dates
  • Pending Changes: Save/Discard bar tracks unsaved changes before committing to server
  • State Management: Pinia store (rosterStore.js) centralizes filter state, data, and API calls

Testing

  • Site: neph at http://neph:8001/frontend/nurse-roster
  • Verified: auto-load, past date locking, dialog assignment, searchable dropdowns, sidebar order

av-dev2 and others added 20 commits April 4, 2026 12:43
…e differentiation

Add custom fields to Healthcare Practitioner doctype to support
distinguishing between Doctors, Nurses, and other practitioner types.
This is a foundational change that enables role-based filtering and
workflow separation across the healthcare modules.

New custom fields added via 28_healthcare_practitioner_nursing.json:

1. practitioner_role (Select: Doctor/Nurse/Other)
   - Required field inserted after healthcare_practitioner_type
   - Serves as the primary discriminator for role-based logic

2. nursing_specialization (Select)
   - Options: General Nursing, Critical Care (ICU), Surgical/Theater,
     Midwifery, Pediatric, Emergency
   - Conditionally visible only when practitioner_role is 'Nurse'
   - Inserted after practitioner_role

3. nursing_role (Select)
   - Options: Staff Nurse, Charge Nurse, Nurse Manager
   - Conditionally visible only when practitioner_role is 'Nurse'
   - Inserted after nursing_specialization

All fields follow the established hms_tz custom field patch pattern,
using a new sequential JSON file to avoid modifying existing patches.
…e differentiation

Add custom fields to Healthcare Practitioner doctype to support
distinguishing between Doctors, Nurses, and other practitioner types.
This is a foundational change that enables role-based filtering and
workflow separation across the healthcare modules.

New custom fields added via 28_healthcare_practitioner_nursing.json:

1. practitioner_role (Select: Doctor/Nurse/Other)
   - Required field inserted after healthcare_practitioner_type
   - Serves as the primary discriminator for role-based logic

2. nursing_specialization (Select)
   - Options: General Nursing, Critical Care (ICU), Surgical/Theater,
     Midwifery, Pediatric, Emergency
   - Conditionally visible only when practitioner_role is 'Nurse'
   - Inserted after practitioner_role

3. nursing_role (Select)
   - Options: Staff Nurse, Charge Nurse, Nurse Manager
   - Conditionally visible only when practitioner_role is 'Nurse'
   - Inserted after nursing_specialization

All fields follow the established hms_tz custom field patch pattern,
using a new sequential JSON file to avoid modifying existing patches.
…module

feat(healthcare-practitioner): add custom fields for practitioner role differentiation
Updated multiple doctype forms and API scripts to ensure that 'Healthcare Practitioner'
link fields are filtered to exclusively display practitioners with the 'Doctor' role.
This change enforces role differentiation across the system, preventing nurses or
other practitioners from being selected in fields specifically meant for doctors.

Modified files:
- episode_of_care.js
- healthcare_nursing_task.js
- healthcare_referral.js
- healthcare_service_order.js
- healthcare_service_request.js
- inpatient_record.js
- lab_test.js
- patient_appointment.js
- patient_encounter.js
- patient_referral.js
- practitioner_availability.js
- radiology_examination.js
- therapy_session.js
- clinical_procedure.js (NHIF API)
- patient_appointment.js (NHIF API)
…module

feat(nurse-ot): implement healthcare practitioner role filtering and custom fields
- Added Nursing Schedule DocType with submittable functionality
- Added Nurse Schedule Detail child table with revised fields for nurse assignment, shift type, and service unit
- Implemented validation logic in nursing_schedule.py for dates and duplicate assignments
- Implemented JS filtering for nurses (practitioner_role='Nurse') in nursing_schedule.js
- Configured field triggers for shift assignment targets
- Updated pre-commit config for development stages
…module

feat(nurse-ot): implement Nursing Schedule and Nurse Schedule Detail DocTypes
- Make end_date field read-only in Nursing Schedule DocType
- Add calculate_end_date() method in nursing_schedule.py using
  frappe.utils.add_to_date for server-side computation
- Add calculate_end_date() JS helper triggered by start_date and
  frequency field changes for instant client-side feedback
- Frequency mapping: Daily (same day), Weekly (+6 days),
  Monthly/Quarterly/Bi-Yearly (+N months -1 day), Yearly (+1 year -1 day)
- Add 'Get Nurses' button field in the Shifts section of Nursing Schedule
  (visible only when company is set and doctype is not submitted)
- Add get_nurses() client-side handler that calls the server method,
  skips nurses already in the child table, and shows count feedback
- Add get_nurses() @frappe.whitelist() server method that queries
  Healthcare Practitioner filtered by practitioner_role='Nurse',
  hms_tz_company=company, and status='Active'
- No duplicate nurses are added to the schedule (Task 4)
…module

feat(nursing-schedule): auto-calculate end_date from frequency and start_date
- Change shift_based_on default from 'Service Unit' to 'Service Unit Type'
  to match the first option in the select list
- Normalize JSON indentation to 4-space indent for consistency with
  the parent Nursing Schedule DocType
…module

fix: update Nurse Schedule Detail default and formatting
- Change default_stages from [pre-commit, pre-push, manual] to
  [pre-commit, manual] to remove unnecessary pre-push stage
- Update pre-commit-hooks from v4.5.0 to v5.0.0 to fix deprecated
  stage names (commit, push) used internally by the repo
- Update isort from 5.13.2 to 6.0.1 to fix deprecated stage names
  (commit, merge-commit, push) used internally by the repo

These changes eliminate all deprecation warnings when running
pre-commit run --all without changing hook behavior.
…ited#1129)

fix: resolve deprecated pre-commit stage name warnings
- Remove unused 'import frappe' from nurse_schedule_detail.py
  (autoflake: unused import removal)
- Reformat long frappe.msgprint line in nursing_schedule.js to comply
  with prettier print-width=79 rule (line wrapping)
…akvatech-Limited#1130)

refactor: apply pre-commit hook auto-fixes to nursing module files
…hedule

Nursing Schedule now focuses purely on location assignment (which
ward/room a nurse works in) rather than time-based shifts, since
shifts are managed through the HR Module (Shift Assignment, Shift
Request, Default Shift).

Nursing Schedule DocType:
- Rename section_break_shifts -> section_break_assignments
- Rename shifts -> assignments (Table field)
- Update section label from 'Shifts' to 'Assignments'

Nurse Schedule Detail (child table):
- Remove shift_type field entirely (handled by HR Module)
- Rename shift_based_on -> assign_based_on
- Add assignment_date (Date, required) field for specific date
  the nurse is assigned to that location
- Auto-populate assignment_date with end_date when frequency is
  Daily (on Get Nurses, Add Row, and frequency change)

Client-side (nursing_schedule.js):
- Update all shifts -> assignments references
- Update shift_based_on -> assign_based_on references
- Refactor set_query into dedicated trigger with enhanced filters:
  nurse (Active, Nurse role, company), service_unit_type (not disabled),
  service_unit (non-group, not disabled, same company)
- Add assignments_add handler and set_daily_assignment_dates helper
  for auto-filling assignment_date on Daily frequency

Server-side (nursing_schedule.py):
- Update self.shifts -> self.assignments references
- Update duplicate validation to check nurse+date+location
  instead of nurse+shift_type+location
Add property setter (27_healthcare_practitioner_nursing.json) that
sets mandatory_depends_on for the employee field on Healthcare
Practitioner to eval:doc.practitioner_role=='Nurse'.

This ensures every nurse is linked to an Employee record, enabling
integration with the HR Module for shift management (Default Shift,
Shift Assignment, Shift Request).

Also includes minor JS formatting cleanup (consistent double quotes,
condensed single-line function calls).
…d & past date protection

Backend:
- Add roster.py with whitelisted endpoints:
  - get_roster_data: fetches nurses and schedule assignments for date range
  - get_service_options: returns service unit types/units for company
  - save_roster_assignments: batch add/edit/remove roster changes
- Add nursing_schedule_list.js with 'Open Roster' button on list view

Frontend SPA (Design A):
- CRM-style collapsible sidebar (Nurse Roster → Nursing Schedule)
- Auto-load roster when all filter fields populated (no button needed)
- Centered title with light blue subtitle, centered filter fields
- Field order: Company → Frequency → Start Date → End Date (auto-calculated)
- Dialog-based assignment with searchable autocomplete for Service Unit
  Type and Service Unit (supports 100+ options)
- Past date protection: no edit icon, no dialog for backdated assignments
- Past assignments retain same blue pill color as current/future dates
- Pending changes tracked with save/discard bar
- Pinia store for state management (rosterStore.js)
- Vue Router route at /nurse-roster
- Vite config with correct hms_tz build paths
@av-dev2 av-dev2 merged commit cb371ef into nurse-ot-module Apr 7, 2026
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