clqms-fe1/docs/MVP_IMPLEMENTATION_PLAN.md
mahdahar f7a884577f feat: Add ADT history, specimens API, and enhance master data pages
- Add VisitADTHistoryModal for ADT tracking
- Create specimens API client
- Add HelpTooltip component
- Enhance all master data pages with improved UI
- Update patient pages and visit management
- Add implementation plans and API docs
2026-02-15 17:58:42 +07:00

7.0 KiB

MVP Implementation Plan - CLQMS Frontend

Goal: Deliver core functionality for daily laboratory operations within shortest timeframe. Estimated Time: 2-3 weeks Priority: Critical features for production use


Phase 1: Test Ordering System (Week 1)

Use Cases: UC-5a, UC-5b Priority: HIGHEST - Core lab functionality

API Endpoints Needed (Backend)

POST   /api/orders              # Create new test order
GET    /api/orders/:oid         # Get order details
PATCH  /api/orders/:oid         # Update order
GET    /api/orders              # List/search orders
POST   /api/specimens           # Create specimen records
GET    /api/specimens/:sid      # Get specimen details
GET    /api/orders/:oid/specimens # List specimens for order

Frontend Implementation

1.1 Create Order Management Module

New Files:

  • src/routes/(app)/orders/+page.svelte - Order list/search page
  • src/routes/(app)/orders/new/+page.svelte - New order creation
  • src/routes/(app)/orders/[oid]/+page.svelte - Order detail/edit
  • src/lib/api/orders.js - Order API client
  • src/lib/api/specimens.js - Specimen API client

1.2 Order List Page Features

  • Search by OID, Patient ID, Patient Name
  • Filter by status (SC, IP, CM, CL)
  • Date range filter
  • Quick actions: View, Edit, Print labels
  • Table columns: OID, Patient, Date, Tests, Status

1.3 New Order Page Features

  • Patient/PVID selection (search existing or quick admit)
  • Test selection with search
  • Specimen requirements display
  • Comments/attachments
  • Print label options (checkboxes):
    • Print Patient Label
    • Print Order Label
    • Print Specimen Label
  • Auto-generate OID and SID on save

1.4 Order Status Validation

  • Prevent editing if status = CL (Closed)
  • Prevent editing if status = AC (Archived)
  • Prevent editing if status = DL (Deleted)
  • Prevent removing tests that have results

1.5 Specimen Management

  • Auto-create specimen records per test
  • Display SID list after order creation
  • Basic specimen tracking view

Phase 2: Patient Discharge (Week 1-2)

Use Cases: UC-04a, UC-04b Priority: HIGH - Essential for visit lifecycle

API Endpoints Needed (Backend)

POST /api/patvisit/:pvid/discharge        # Create discharge ADT (A03)
POST /api/patvisit/:pvid/cancel-discharge # Cancel discharge (A13)
GET  /api/orders/pvid/:pvid/open          # Check for open orders

Frontend Implementation

2.1 Update Visit Management

Modify:

  • src/routes/(app)/patients/+page.svelte - Add discharge actions
  • src/routes/(app)/patients/VisitFormModal.svelte - Add discharge button

New Files:

  • src/routes/(app)/patients/DischargeModal.svelte - Discharge confirmation
  • src/routes/(app)/patients/CancelDischargeModal.svelte - Cancel discharge

2.2 Discharge Features

  • Discharge button on active visits
  • Validation: Check for open test orders (status: A, IP, SC, HD)
  • If open orders exist: Show warning, block discharge
  • ADT Code: A03 (Discharge)
  • Required fields: Discharge date
  • After discharge: Visit marked as closed (no more edits)

2.3 Cancel Discharge Features

  • Available only for Supervisor Lab, Manajer Lab
  • ADT Code: A13 (Cancel Discharge)
  • Re-opens visit for editing
  • Available in visit actions menu

Phase 3: Patient Transfer (Week 2)

Use Cases: UC-04 Priority: MEDIUM-HIGH - Common daily operation

API Endpoints Needed (Backend)

POST /api/patvisit/:pvid/transfer  # Create transfer ADT (A02)

Frontend Implementation

3.1 Transfer Feature

Modify:

  • src/routes/(app)/patients/VisitFormModal.svelte - Add transfer section

New Files:

  • src/routes/(app)/patients/TransferModal.svelte - Location transfer

3.2 Transfer Features

  • Transfer button on active visits
  • Location dropdown (from master data)
  • ADT Code: A02 (Patient Transfer)
  • Update visit LocationID
  • Track location history via ADT

Use Cases: UC-02b Priority: MEDIUM - Data quality improvement

API Endpoints Needed (Backend)

GET    /api/patient/search-duplicates  # Find potential duplicates
POST   /api/patient/link               # Link patients (A24)
GET    /api/patient/:pid/linked        # Get linked patients

Frontend Implementation

New Files:

  • src/routes/(app)/patients/link/+page.svelte - Patient link page
  • src/lib/api/patient-links.js - Link API client
  • Search by: Identifier (KTP/Passport), Name + DOB + Address
  • Display matching patients
  • Select destination (surviving) PID
  • Select source PID(s) to link
  • Confirmation dialog
  • ADT Code: A24 (Link Patient)
  • Validation: Prevent multi-level links, prevent linking already-linked sources

4.3 Visual Indicator

  • Show "Linked" badge on patient records
  • Display linked PIDs in patient detail

Navigation Updates

Sidebar Changes

Add to Laboratory section:

Laboratory
├── Patients (existing)
├── Orders (NEW)
├── Specimens (NEW)
└── Patient Links (NEW)

Database Schema Requirements (Backend)

Orders Table

ordertest:
  - OrderID (OID)
  - InternalOID
  - PVID
  - EffDate (future orders)
  - EndDate (closed)
  - ArchiveDate
  - DelDate
  - Comments
  - CreatedBy, CreatedDate

orderstatus:
  - InternalOID
  - OrderStatus (SC, IP, CM, CL, AC, DL)
  - StatusDate

ordertestdetail:
  - InternalOID
  - TestSiteID
  - TestSequence

Specimens Table

specimens:
  - SpecimenID (SID)
  - InternalSID
  - InternalOID
  - TestSiteID
  - CollectionDate
  - ReceivedDate
  - ContainerID
  - Status

Testing Checklist

Test Ordering

  • Create new order with multiple tests
  • Search orders by patient name
  • Edit pending order (SC status)
  • Attempt to edit closed order (should fail)
  • Print labels (UI only)
  • View specimen list

Discharge

  • Discharge patient with no open orders
  • Attempt discharge with open orders (should block)
  • Cancel discharge (supervisor only)
  • Verify visit locked after discharge

Transfer

  • Transfer patient to new location
  • Verify location history updated
  • Search duplicates by identifier
  • Link two patients
  • Verify destination patient shows cumulative data
  • Verify source patient marked as linked

Out of Scope (MVP)

The following features are NOT included in MVP but documented for future phases:

  • Multi-site authentication (UC-01 enhancements)
  • Password expiration/lockout
  • Patient Unlink (UC-02c)
  • Cancel Admission (UC-03b)
  • Change Attending/Consulting Doctor (UC-03c, UC-03d)
  • Advanced duplicate detection with address matching
  • Audit log viewing
  • Specimen label printing integration
  • Result entry integration

Success Criteria

  1. Users can create test orders linked to patients
  2. Users can discharge patients (when no open orders)
  3. Users can transfer patients between locations
  4. Users can link duplicate patient records
  5. Order status validation prevents invalid edits
  6. All operations create proper ADT audit records