Files
docs-piam/references/warehouse-implementation-todo.md
2025-11-10 13:55:48 +07:00

1766 lines
68 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Warehouse Module Implementation - TODO List
**Based on:** Gap Analysis (warehouse-gap-analysis.md)
**Document Version:** 1.0
**Created:** 2025-10-29
**Overall Completion:** 13/158 tasks (8.2%)
---
## 📊 Progress Summary
| Phase | Status | Completion | Priority |
|-------|--------|------------|----------|
| Phase 1: Core Operations | 🟡 In Progress | 13/52 (25%) | CRITICAL |
| Phase 2: Compliance & Reporting | 🔴 Not Started | 0/45 | HIGH |
| Phase 3: Pharmacy Enhancements | 🔴 Not Started | 0/31 | HIGH (if hospital) |
| Phase 4: Advanced Features | 🔴 Not Started | 0/30 | MEDIUM |
---
## 🔴 Phase 1: Core Operations (CRITICAL) - 12 weeks
### 1.1 Internal Requisition Module (3 weeks) - 13/16 (81%)
#### Backend Development
- [x] Create `InternalRequisition` entity in Domain layer
- [x] Add properties: RequisitionNumber, RequestDate, RequiredDate, Status, Priority (Normal/Urgent)
- [x] Add navigation properties: RequestingDepartment, RequestedByEmployee, ApprovedByEmployee
- [x] Add timestamps: SubmittedDate, ApprovedDate
- [x] Create `InternalRequisitionLine` entity in Domain layer
- [x] Add properties: Item, RequestedQuantity, UnitOfMeasure, ApprovedQuantity
- [x] Add notes field for line item remarks
- [x] Create `InternalRequisitionStatus` enum
- [x] Values: Draft, Submitted, Approved, Rejected, PartiallyFulfilled, Fulfilled, Cancelled
- [x] Create `InternalRequisitionPriority` enum
- [x] Values: Normal, Urgent
- [x] Create EF Core configuration classes
- [x] InternalRequisitionConfiguration.cs
- [x] InternalRequisitionLineConfiguration.cs
- [x] Create and run database migration
- [x] Create DTOs in Application layer
- [x] InternalRequisitionSummaryDto (for workbench list)
- [x] InternalRequisitionDetailDto (for full details)
- [x] InternalRequisitionLineDto (for line items)
- [x] InternalRequisitionLineUpsertDto (for create/update line items)
- [x] CreateInternalRequisitionDto
- [x] UpdateInternalRequisitionDto
- [x] SubmitInternalRequisitionDto
- [x] ApproveInternalRequisitionDto (with optional line-level approvals)
- [x] RejectInternalRequisitionDto
- [ ] Create `IInternalRequisitionRepository` interface
- [ ] Implement `InternalRequisitionRepository` in Infrastructure layer
- [ ] Create `IInternalRequisitionService` interface
- [ ] Implement `InternalRequisitionService` in Application layer
- [ ] CreateRequisition method
- [ ] UpdateRequisition method
- [ ] SubmitForApproval method
- [ ] ApproveRequisition method
- [ ] RejectRequisition method
- [ ] CreateTransferFromRequisition method (integration with InternalTransferOrder)
- [ ] LoadItemsBelowSafetyLevel method
- [ ] LoadItemsBelowMaxLevel method
- [ ] Create `InternalRequisitionController` in API layer
- [ ] GET /api/requisitions/workbench - List requisitions with filtering
- [ ] GET /api/requisitions/{id} - Get requisition details
- [ ] POST /api/requisitions - Create new requisition
- [ ] PUT /api/requisitions/{id} - Update draft requisition
- [ ] POST /api/requisitions/{id}/submit - Submit for approval
- [ ] POST /api/requisitions/{id}/approve - Approve requisition
- [ ] POST /api/requisitions/{id}/reject - Reject requisition
- [ ] POST /api/requisitions/{id}/create-transfer - Convert to transfer order
- [ ] GET /api/requisitions/items-below-safety - Load items below safety level
- [ ] GET /api/requisitions/items-below-max - Load items below max level
- [ ] Add document numbering service for requisitions
- [ ] Add approval authority/permission configuration
- [ ] Write unit tests for InternalRequisitionService
- [ ] Write integration tests for InternalRequisitionController
#### Frontend Development
- [ ] Update `warehouse-requisitions` module (currently mock)
- [ ] Create TypeScript models/interfaces
- [ ] InternalRequisition interface
- [ ] InternalRequisitionLine interface
- [ ] InternalRequisitionStatus enum
- [ ] Create `InternalRequisitionService` (HTTP client)
- [ ] Create requisition workbench component
- [ ] Filtering panel (status, date range, department, keyword)
- [ ] Data grid with requisitions
- [ ] Action buttons (create, view, edit, submit, approve, reject)
- [ ] Create requisition form component
- [ ] Header section (department, required date, priority, notes)
- [ ] Line items grid with add/remove functionality
- [ ] Item search and selection
- [ ] Load items below safety/max level buttons
- [ ] Save draft / Submit for approval buttons
- [ ] Create requisition detail view component
- [ ] Display requisition header information
- [ ] Display line items
- [ ] Show approval status and audit trail
- [ ] Approve/Reject buttons (for approvers)
- [ ] Create transfer button (for fulfilled requisitions)
- [ ] Add translation keys to i18n files (en.json, th.json)
- [ ] Add routing configuration
- [ ] Add navigation menu item
#### Integration & Testing
- [ ] Test requisition creation workflow
- [ ] Test approval workflow
- [ ] Test integration with transfer order creation
- [ ] Test load items below safety/max level functionality
- [ ] Test permissions and authorization
- [ ] Test document numbering sequence
---
### 1.2 Stock Issue/Dispense Module (2 weeks) - 0/14
#### Backend Development
- [ ] Create `StockIssueNote` entity in Domain layer
- [ ] Add properties: IssueNumber, IssueDate, Status, IssuedToLocation, IssuedToDepartment
- [ ] Add reference to InternalRequisition (optional)
- [ ] Add navigation: IssuedByEmployee, ApprovedByEmployee
- [ ] Create `StockIssueNoteLine` entity in Domain layer
- [ ] Add properties: Item, RequestedQuantity, IssuedQuantity, UnitOfMeasure
- [ ] Add lot and location tracking
- [ ] Create `StockIssueStatus` enum (Draft, Approved, Posted, Cancelled)
- [ ] Create EF Core configuration classes
- [ ] Create and run database migration
- [ ] Create DTOs
- [ ] StockIssueSummaryDto
- [ ] StockIssueDetailDto
- [ ] CreateStockIssueDto
- [ ] UpdateStockIssueDto
- [ ] PostStockIssueDto
- [ ] Create `IStockIssueRepository` interface
- [ ] Implement `StockIssueRepository`
- [ ] Create `IStockIssueService` interface
- [ ] Implement `StockIssueService`
- [ ] CreateIssue method
- [ ] CreateIssueFromRequisition method
- [ ] UpdateIssue method
- [ ] ApproveIssue method
- [ ] PostIssue method (create inventory transactions and reduce stock)
- [ ] CancelIssue method
- [ ] Create `StockIssueController`
- [ ] GET /api/stock-issues/workbench
- [ ] GET /api/stock-issues/{id}
- [ ] POST /api/stock-issues
- [ ] POST /api/stock-issues/from-requisition/{requisitionId}
- [ ] PUT /api/stock-issues/{id}
- [ ] POST /api/stock-issues/{id}/approve
- [ ] POST /api/stock-issues/{id}/post
- [ ] POST /api/stock-issues/{id}/cancel
- [ ] Add document numbering for issue notes
- [ ] Update InventoryTransaction creation on issue posting
- [ ] Write unit tests
- [ ] Write integration tests
#### Frontend Development
- [ ] Update `warehouse-issues` module (currently mock)
- [ ] Create TypeScript models
- [ ] Create `StockIssueService` (HTTP client)
- [ ] Create issue workbench component
- [ ] Create issue form component
- [ ] Header section
- [ ] Line items with lot selection
- [ ] Quantity adjustment (requested vs issued)
- [ ] Submit/approve/post buttons
- [ ] Create issue detail view
- [ ] Add translation keys
- [ ] Add routing and navigation
#### Integration & Testing
- [ ] Test issue creation from requisition
- [ ] Test standalone issue creation
- [ ] Test approval and posting workflow
- [ ] Test stock deduction on posting
- [ ] Test inventory transaction creation
- [ ] Test document copy functionality
---
### 1.3 Stock Adjustment Module (2 weeks) - 0/13
#### Backend Development
- [ ] Create `StockAdjustment` entity in Domain layer
- [ ] Add properties: AdjustmentNumber, AdjustmentDate, Status, AdjustmentType (Increase/Decrease)
- [ ] Add navigation: Location, CreatedByEmployee, ApprovedByEmployee
- [ ] Create `StockAdjustmentLine` entity
- [ ] Add properties: Item, Lot, ExpiryDate, CurrentQuantity, AdjustmentQuantity, NewQuantity
- [ ] Add ReasonCode (FK to StockAdjustmentReason)
- [ ] Add UnitCost for cost adjustments
- [ ] Add notes field
- [ ] Create `StockAdjustmentReason` entity (master data)
- [ ] Predefined reasons: Internal Use, Damaged, Expired, Stock Count Adjustment, Theft/Loss, Found/Surplus
- [ ] Create `StockAdjustmentStatus` enum (Draft, Posted)
- [ ] Create EF Core configuration classes
- [ ] Create and run database migration
- [ ] Seed initial adjustment reasons
- [ ] Create DTOs
- [ ] StockAdjustmentSummaryDto
- [ ] StockAdjustmentDetailDto
- [ ] CreateStockAdjustmentDto
- [ ] UpdateStockAdjustmentDto
- [ ] PostStockAdjustmentDto
- [ ] StockAdjustmentReasonDto
- [ ] Create `IStockAdjustmentRepository` interface
- [ ] Implement `StockAdjustmentRepository`
- [ ] Create `IStockAdjustmentService` interface
- [ ] Implement `StockAdjustmentService`
- [ ] CreateAdjustment method
- [ ] UpdateAdjustment method
- [ ] PostAdjustment method (create InventoryTransaction, update InventoryBalance)
- [ ] GetAdjustmentReasons method
- [ ] ManageAdjustmentReasons method (CRUD for reasons)
- [ ] Create `StockAdjustmentController`
- [ ] GET /api/stock-adjustments/workbench
- [ ] GET /api/stock-adjustments/{id}
- [ ] POST /api/stock-adjustments
- [ ] PUT /api/stock-adjustments/{id}
- [ ] POST /api/stock-adjustments/{id}/post
- [ ] GET /api/stock-adjustments/reasons
- [ ] POST /api/stock-adjustments/reasons (admin only)
- [ ] Add permission controls for adjustment creation and posting
- [ ] Add approval workflow for large adjustments (configurable threshold)
- [ ] Write unit tests
- [ ] Write integration tests
#### Frontend Development
- [ ] Update `warehouse-adjustments` module (currently mock)
- [ ] Create TypeScript models
- [ ] Create `StockAdjustmentService` (HTTP client)
- [ ] Create adjustment workbench component
- [ ] Create adjustment form component
- [ ] Search and select items from warehouse
- [ ] Display current quantity (read-only)
- [ ] Lot selection dropdown
- [ ] Adjustment type (increase/decrease)
- [ ] Adjustment quantity input (with + or - sign)
- [ ] Calculated new quantity (display)
- [ ] Reason dropdown
- [ ] Notes textarea
- [ ] Save draft / Post buttons
- [ ] Create adjustment detail view
- [ ] Create adjustment reasons management UI (admin)
- [ ] Add translation keys
- [ ] Add routing and navigation
#### Integration & Testing
- [ ] Test positive adjustment (increase stock)
- [ ] Test negative adjustment (decrease stock)
- [ ] Test adjustment with different reasons
- [ ] Test cost adjustment
- [ ] Test approval workflow for large adjustments
- [ ] Test inventory transaction creation
- [ ] Test balance update
- [ ] Test permission controls
---
### 1.4 Sub-Warehouse Receipt Confirmation (2 weeks) - 0/12
#### Backend Development
- [ ] Create `SubWarehouseReceiptNote` entity
- [ ] Add properties: ReceiptNumber, ReceiptDate, Status
- [ ] Add reference to InternalTransferOrder
- [ ] Add navigation: ReceivedByEmployee, ReceivingLocation
- [ ] Create `SubWarehouseReceiptNoteLine` entity
- [ ] Add properties: Item, Lot, ExpectedQuantity, ReceivedQuantity, DiscrepancyReason
- [ ] Create `SubWarehouseReceiptStatus` enum (Draft, Posted)
- [ ] Create EF Core configuration classes
- [ ] Create and run database migration
- [ ] Create DTOs
- [ ] SubWarehouseReceiptSummaryDto
- [ ] SubWarehouseReceiptDetailDto
- [ ] PostSubWarehouseReceiptDto
- [ ] Create `ISubWarehouseReceiptRepository` interface
- [ ] Implement `SubWarehouseReceiptRepository`
- [ ] Create `ISubWarehouseReceiptService` interface
- [ ] Implement `SubWarehouseReceiptService`
- [ ] GetPendingReceipts method (for receiving location)
- [ ] CreateReceiptFromTransfer method (auto-create when transfer reaches InTransit)
- [ ] UpdateReceivedQuantities method
- [ ] PostReceipt method (create inventory transaction, update transfer status to Completed)
- [ ] RecordDiscrepancy method
- [ ] Update InternalTransferService to auto-create receipt note when status changes to InTransit
- [ ] Create `SubWarehouseReceiptController`
- [ ] GET /api/sub-warehouse-receipts/pending (for current user's location)
- [ ] GET /api/sub-warehouse-receipts/{id}
- [ ] PUT /api/sub-warehouse-receipts/{id}/quantities
- [ ] POST /api/sub-warehouse-receipts/{id}/post
- [ ] Write unit tests
- [ ] Write integration tests
#### Frontend Development
- [ ] Update `warehouse-sub-receipts` module (currently mock)
- [ ] Create TypeScript models
- [ ] Create `SubWarehouseReceiptService` (HTTP client)
- [ ] Create pending receipts queue component
- [ ] Show transfers awaiting receipt
- [ ] Filter by date, source warehouse
- [ ] Action: Open receipt
- [ ] Create receipt confirmation component
- [ ] Display transfer details (read-only)
- [ ] Display expected quantities per item/lot
- [ ] Input fields for received quantities
- [ ] Discrepancy reason field (if received != expected)
- [ ] Post receipt button
- [ ] Print receipt document button
- [ ] Create receipt detail view (for posted receipts)
- [ ] Add translation keys
- [ ] Add routing and navigation
#### Integration & Testing
- [ ] Test auto-creation of receipt note from transfer
- [ ] Test receipt confirmation with matching quantities
- [ ] Test receipt confirmation with discrepancies
- [ ] Test inventory transaction creation
- [ ] Test transfer status update to Completed
- [ ] Test stock increase in receiving location
- [ ] Test pending receipts queue filtering
- [ ] Test permissions (only receiving location can post)
---
### 1.5 Essential Reports (Tier 1) (3 weeks) - 0/9
#### Report Infrastructure Setup
- [ ] Choose reporting approach (QuestPDF / Crystal Reports / SSRS / Custom)
- [ ] Set up report generation service in Application layer
- [ ] Create `IReportService` interface
- [ ] Implement `ReportService`
- [ ] Create `ReportController` in API layer
- [ ] Create report templates/layouts
- [ ] Add PDF generation capability
- [ ] Add Excel export capability
- [ ] Add report download endpoints
#### Report #1: Stock Balance Report (Current)
- [ ] Create StockBalanceReportDto
- [ ] Create data query method in repository
- [ ] Create report template/layout
- [ ] Add filters: warehouse, item category, item, date
- [ ] Add grouping: by warehouse, by category
- [ ] Add columns: Item Code, Item Name, UOM, Quantity on Hand, Min Level, Max Level, Value
- [ ] Add totals and subtotals
- [ ] Test report generation
- [ ] Create frontend report viewer/downloader
#### Report #2: Stock Card Report
- [ ] Create StockCardReportDto
- [ ] Create data query method (get all transactions for item/location)
- [ ] Create report template
- [ ] Add filters: item, warehouse, date range
- [ ] Add columns: Date, Transaction Type, Document Number, Lot, In Qty, Out Qty, Balance, Unit Cost
- [ ] Add running balance calculation
- [ ] Test report generation
- [ ] Create frontend interface
#### Report #3: Goods Receipt Report
- [ ] Create GoodsReceiptReportDto
- [ ] Create data query method
- [ ] Create report template
- [ ] Add filters: date range, supplier, warehouse, status
- [ ] Add columns: Receipt Number, Date, Supplier, PO Number, Items, Total Qty, Total Value, Status
- [ ] Add drill-down to receipt details
- [ ] Test report generation
- [ ] Create frontend interface
#### Report #4: Stock Issue Report
- [ ] Create StockIssueReportDto
- [ ] Create data query method
- [ ] Create report template
- [ ] Add filters: date range, issuing warehouse, receiving department
- [ ] Add columns: Issue Number, Date, Department, Items, Total Qty, Total Value
- [ ] Add grouping by department
- [ ] Test report generation
- [ ] Create frontend interface
#### Report #5: Low Stock Alert Report
- [ ] Create LowStockAlertReportDto
- [ ] Create data query method (items where quantity < reorder point)
- [ ] Create report template
- [ ] Add filters: warehouse, category
- [ ] Add columns: Item Code, Item Name, Current Qty, Min Level, Reorder Point, Recommended Order Qty
- [ ] Add severity indicators (below min, below reorder, approaching min)
- [ ] Test report generation
- [ ] Create frontend interface
#### Report #6: Near-Expiry Report (7 months)
- [ ] Create NearExpiryReportDto
- [ ] Create data query method (items expiring within X months)
- [ ] Create report template
- [ ] Add filters: warehouse, expiry within (1, 3, 6, 7, 12 months)
- [ ] Add columns: Item Code, Item Name, Lot Number, Expiry Date, Days to Expiry, Quantity, Location
- [ ] Add sorting by expiry date (nearest first)
- [ ] Add color coding (red <30 days, yellow <90 days, orange <180 days)
- [ ] Test report generation
- [ ] Create frontend interface
#### Frontend Report Module
- [ ] Update `warehouse-reports` module (currently mock)
- [ ] Create report catalog/menu component
- [ ] Create report parameter selection component (filters)
- [ ] Create report viewer component (display PDF/Excel)
- [ ] Add report scheduling functionality (future enhancement)
- [ ] Add favorite reports feature
- [ ] Add translation keys
- [ ] Add routing and navigation
#### Testing
- [ ] Test all 6 reports with various filter combinations
- [ ] Test report performance with large datasets
- [ ] Test PDF and Excel export formats
- [ ] Test report permissions (who can view which reports)
- [ ] User acceptance testing with stakeholders
---
## 🟡 Phase 2: Compliance & Reporting (HIGH) - 10 weeks
### 2.1 Operational Reports (Tier 2) (4 weeks) - 0/14
#### Report #7: Stock Movement Summary
- [ ] Create query aggregating receipts, issues, adjustments, transfers by period
- [ ] Create report template with opening balance, receipts, issues, adjustments, closing balance
- [ ] Add filters: date range, warehouse, item category
- [ ] Test and deploy
#### Report #8: Stock Value Report
- [ ] Create query calculating total inventory value (quantity × unit cost)
- [ ] Create report with breakdown by category and warehouse
- [ ] Add comparison with previous period
- [ ] Add chart visualization
- [ ] Test and deploy
#### Report #9: Receipt by Vendor
- [ ] Create query grouping receipts by vendor
- [ ] Create report template
- [ ] Add filters: date range, vendor
- [ ] Add columns: Vendor Name, Receipt Count, Total Items, Total Value, Average Lead Time
- [ ] Test and deploy
#### Report #10: Issue by Department
- [ ] Create query grouping issues by department
- [ ] Create report template
- [ ] Add filters: date range, department, item category
- [ ] Add columns: Department, Item Count, Total Qty, Total Value
- [ ] Add trend analysis (comparison with previous period)
- [ ] Test and deploy
#### Report #11: Monthly Stock Report
- [ ] Create query for end-of-month snapshots
- [ ] Create report template with monthly comparisons
- [ ] Add filters: year, warehouse
- [ ] Add columns: Month, Opening Stock, Receipts, Issues, Adjustments, Closing Stock, Value
- [ ] Add year-over-year comparison
- [ ] Test and deploy
#### Report #12: Stock at Date Report
- [ ] Create query to calculate stock at any historical date
- [ ] Create report template
- [ ] Add date parameter
- [ ] Add warehouse and category filters
- [ ] Add columns: Item, Quantity at Date, Value at Date
- [ ] Test and deploy
#### Report #13: Pending Receipt Report
- [ ] Create query for goods in transit (POs not fully received)
- [ ] Create report template
- [ ] Add filters: date range, vendor, warehouse
- [ ] Add columns: PO Number, Vendor, Items, Ordered Qty, Received Qty, Pending Qty, Expected Date
- [ ] Add aging analysis (overdue vs on-time)
- [ ] Test and deploy
#### Report #14: Material Movement Report
- [ ] Create detailed transaction log report
- [ ] Add filters: date range, item, warehouse, transaction type
- [ ] Add columns: Date, Time, Transaction Type, Document Number, Item, Lot, Quantity, Location, Employee
- [ ] Add export to Excel for further analysis
- [ ] Test and deploy
#### Report #15: Inventory by Category and Warehouse
- [ ] Create summary report with matrix layout (categories × warehouses)
- [ ] Add quantity and value totals
- [ ] Add percentage of total inventory
- [ ] Add chart visualization
- [ ] Test and deploy
#### Report #16: Over-Standard Requisition Report
- [ ] Create query finding requisitions exceeding standard/budget amounts
- [ ] Create report template
- [ ] Add filters: date range, department
- [ ] Add columns: Requisition Number, Department, Item, Requested Qty, Standard Qty, Over Qty, Approval Status
- [ ] Add justification notes
- [ ] Test and deploy
#### Report #17: Vendor Invoice Receipt Report
- [ ] Create reconciliation report (GRN vs Invoice)
- [ ] Add filters: date range, vendor
- [ ] Add columns: Invoice Number, GRN Number, Invoice Date, Receipt Date, Variance
- [ ] Add status: Matched, Partially Matched, Not Matched
- [ ] Test and deploy
#### Report #18: Receipt Inspection Report
- [ ] Create quality inspection tracking report
- [ ] Add filters: date range, inspector, status
- [ ] Add columns: Receipt Number, Date, Supplier, Items, Inspection Result, Quality Issues
- [ ] Test and deploy
#### Report #19: Inventory Summary Report
- [ ] Create comprehensive summary with key metrics
- [ ] Add sections: Stock Value, Turnover Rate, Slow-Moving Items, Stock-Out Items
- [ ] Add KPI dashboard style layout
- [ ] Add chart visualizations
- [ ] Test and deploy
#### Report #20: Equipment Inventory and Balance Report
- [ ] Create specialized report for equipment/assets
- [ ] Add filters: equipment category, location, status
- [ ] Add columns: Equipment Code, Name, Category, Location, Quantity, Status, Value
- [ ] Test and deploy
---
### 2.2 Document Printing (2 weeks) - 0/8
#### Print Templates
- [ ] Create print template for Internal Requisition form
- [ ] Company header/logo
- [ ] Requisition details section
- [ ] Line items table
- [ ] Approval signatures section
- [ ] Footer with terms/notes
- [ ] Create print template for Stock Issue Note
- [ ] Issue note header
- [ ] Issued to/from information
- [ ] Items table with lot numbers
- [ ] Receiver signature section
- [ ] Create print template for Stock Adjustment Note
- [ ] Adjustment header
- [ ] Adjustment reason
- [ ] Items table with before/after quantities
- [ ] Approval signatures
- [ ] Create print template for Sub-Warehouse Receipt Note
- [ ] Receipt header
- [ ] Transfer reference
- [ ] Items with expected vs received quantities
- [ ] Discrepancy notes
- [ ] Receiver signature
- [ ] Create print template for Transfer Order
- [ ] Transfer details
- [ ] Pick list format
- [ ] Items with locations
- [ ] Picker and receiver signatures
- [ ] Create print template for Borrow/Return Slip
- [ ] Borrowing party information
- [ ] Items borrowed/returned
- [ ] Expected return date (for borrow)
- [ ] Condition notes
- [ ] Signatures
- [ ] Create print template for Stock Balance Sheet
- [ ] Balance as of date
- [ ] Items grouped by category
- [ ] Quantity and value columns
- [ ] Totals and subtotals
- [ ] Create print template for Material Withdrawal Slip
- [ ] Withdrawal details
- [ ] Purpose/project reference
- [ ] Items list
- [ ] Approval and receipt signatures
#### Barcode/QR Code Labels
- [ ] Set up barcode generation library (e.g., ZXing, Barcode.NET)
- [ ] Create label template for items (Code128 barcode)
- [ ] Item code barcode
- [ ] Item name
- [ ] Item code (human readable)
- [ ] Size: standard label (e.g., 50mm x 30mm)
- [ ] Create label template for locations (QR code)
- [ ] Location QR code (encodes location ID)
- [ ] Location code (human readable)
- [ ] Location name
- [ ] Size: larger label (e.g., 75mm x 75mm)
- [ ] Create label template for lot tracking
- [ ] Lot number barcode
- [ ] Item code
- [ ] Expiry date
- [ ] Received date
- [ ] Create bulk label printing functionality
- [ ] Print labels for multiple items at once
- [ ] Print labels for all locations in warehouse
- [ ] Configurable label layout and printer settings
- [ ] Add API endpoints for label generation
- [ ] POST /api/labels/items - Generate item labels
- [ ] POST /api/labels/locations - Generate location labels
- [ ] POST /api/labels/lots - Generate lot labels
- [ ] Create frontend label printing interface
- [ ] Select items/locations for label printing
- [ ] Preview labels before printing
- [ ] Configure printer settings
- [ ] Print or download as PDF
#### Integration & Testing
- [ ] Test all print templates with sample data
- [ ] Test printing from different browsers
- [ ] Test PDF generation and download
- [ ] Test direct printing to network printers
- [ ] Test barcode/QR code scanning with actual devices
- [ ] User acceptance testing for print layouts
---
### 2.3 Alert System (2 weeks) - 0/12
#### Backend Alert Infrastructure
- [ ] Create `WarehouseAlert` entity
- [ ] AlertType (LowStock, OutOfStock, NearExpiry, OverStock, etc.)
- [ ] Severity (Info, Warning, Critical)
- [ ] Item, Location references
- [ ] AlertDate, ResolvedDate
- [ ] IsResolved flag
- [ ] Message, Details
- [ ] Create `AlertConfiguration` entity
- [ ] AlertType, IsEnabled
- [ ] Threshold settings (e.g., alert when stock < X% of reorder point)
- [ ] Notification channels (Email, In-App, SMS)
- [ ] Recipients (users, roles)
- [ ] Create EF Core configuration classes
- [ ] Create and run database migration
- [ ] Create `IAlertService` interface
- [ ] Implement `AlertService`
- [ ] CheckLowStockConditions method (runs periodically)
- [ ] CheckExpiryDates method
- [ ] CheckOverStockConditions method
- [ ] GenerateAlert method
- [ ] ResolveAlert method
- [ ] GetActiveAlerts method
- [ ] GetAlertHistory method
- [ ] Create background job/scheduled task for alert checking
- [ ] Use Hangfire, Quartz.NET, or BackgroundService
- [ ] Run daily or configurable interval
- [ ] Check all alert conditions
- [ ] Generate new alerts as needed
- [ ] Create `INotificationService` interface
- [ ] Implement `NotificationService`
- [ ] SendEmail method
- [ ] SendInAppNotification method
- [ ] (Future) SendSMS method
- [ ] Integrate alert generation with stock transactions
- [ ] Trigger alert check on stock update
- [ ] Immediate alert for stock-out conditions
- [ ] Create `AlertController`
- [ ] GET /api/alerts/active - Get current active alerts
- [ ] GET /api/alerts/history - Get alert history
- [ ] POST /api/alerts/{id}/resolve - Resolve alert
- [ ] GET /api/alerts/configuration - Get alert settings
- [ ] PUT /api/alerts/configuration - Update alert settings
- [ ] Write unit tests
- [ ] Write integration tests
#### Alert Types Implementation
##### Low Stock Alert
- [ ] Define low stock condition (quantity < reorder point)
- [ ] Create alert check logic
- [ ] Create alert message template
- [ ] Add configuration: alert threshold (e.g., 80% of reorder point)
- [ ] Test alert generation
##### Out of Stock Alert
- [ ] Define out of stock condition (quantity = 0 and item is active)
- [ ] Create alert check logic
- [ ] Create alert message template (critical severity)
- [ ] Test alert generation
##### Near Expiry Alert
- [ ] Define near expiry conditions (expiry within 7 months, 3 months, 1 month)
- [ ] Create alert check logic for each threshold
- [ ] Create alert message templates
- [ ] Add configuration: expiry alert thresholds
- [ ] Test alert generation
##### Over Stock Alert
- [ ] Define over stock condition (quantity > max level)
- [ ] Create alert check logic
- [ ] Create alert message template
- [ ] Add configuration: over stock threshold (e.g., 110% of max level)
- [ ] Test alert generation
##### Slow-Moving Item Alert
- [ ] Define slow-moving condition (no movement in X days and quantity > 0)
- [ ] Create alert check logic
- [ ] Create alert message template
- [ ] Add configuration: slow-moving threshold (e.g., 90 days, 180 days)
- [ ] Test alert generation
#### Frontend Alert Features
- [ ] Create alert notification component (bell icon in header)
- [ ] Badge showing active alert count
- [ ] Dropdown showing recent alerts
- [ ] Click to view full alert details
- [ ] Mark as resolved
- [ ] Create alerts dashboard/workbench
- [ ] List active alerts grouped by severity
- [ ] Filter by alert type, warehouse, date
- [ ] Action buttons: resolve, view details, generate report
- [ ] Visual indicators (color coding by severity)
- [ ] Create alert configuration page (admin)
- [ ] Enable/disable alert types
- [ ] Configure thresholds
- [ ] Configure notification channels
- [ ] Configure recipients
- [ ] Add alert widgets to warehouse dashboard
- [ ] Critical alerts widget (prominent display)
- [ ] Alert summary chart (by type)
- [ ] Alert trends graph
- [ ] Add translation keys
- [ ] Test alert UI/UX
#### Email Notifications
- [ ] Set up email templates for alerts
- [ ] Low stock email template
- [ ] Out of stock email template
- [ ] Near expiry email template
- [ ] Daily digest template (summary of all alerts)
- [ ] Configure SMTP settings
- [ ] Test email delivery
- [ ] Add unsubscribe functionality
- [ ] Add email scheduling (immediate vs digest)
#### Testing
- [ ] Test alert generation for each alert type
- [ ] Test alert threshold configurations
- [ ] Test alert notifications (email, in-app)
- [ ] Test alert resolution workflow
- [ ] Test alert dashboard and filtering
- [ ] Test background job execution
- [ ] Load testing for alert checking on large datasets
- [ ] User acceptance testing
---
### 2.4 Approval Workflow Engine (2 weeks) - 0/11
#### Backend Workflow Infrastructure
- [ ] Create `ApprovalWorkflow` entity
- [ ] WorkflowName, DocumentType (Requisition, Adjustment, Issue, etc.)
- [ ] IsActive flag
- [ ] Approval levels collection
- [ ] Create `ApprovalWorkflowLevel` entity
- [ ] LevelNumber (1, 2, 3, ...)
- [ ] ApprovalType (Role-based, User-specific, Amount-based)
- [ ] ApproverRole or ApproverUser
- [ ] AmountThreshold (optional, for value-based routing)
- [ ] IsParallel flag (multiple approvers at same level)
- [ ] RequireAll flag (for parallel approvals)
- [ ] Create `ApprovalRequest` entity
- [ ] DocumentType, DocumentId
- [ ] WorkflowId reference
- [ ] CurrentLevel, OverallStatus
- [ ] RequestDate, RequestedBy
- [ ] Create `ApprovalRequestLevel` entity
- [ ] ApprovalRequestId reference
- [ ] LevelNumber
- [ ] AssignedTo (user)
- [ ] Status (Pending, Approved, Rejected, Delegated)
- [ ] ActionDate, ActionBy
- [ ] Comments
- [ ] Create `ApprovalDelegation` entity
- [ ] DelegatedFrom, DelegatedTo users
- [ ] StartDate, EndDate
- [ ] IsActive flag
- [ ] Reason
- [ ] Create EF Core configuration classes
- [ ] Create and run database migration
- [ ] Create `IApprovalWorkflowService` interface
- [ ] Implement `ApprovalWorkflowService`
- [ ] InitiateApproval method (create approval request, assign first level)
- [ ] ApproveRequest method
- [ ] RejectRequest method
- [ ] DelegateApproval method
- [ ] GetPendingApprovals method (for user)
- [ ] GetApprovalHistory method (for document)
- [ ] GetApplicableWorkflow method (determine workflow based on document type and amount)
- [ ] Create `IApprovalWorkflowRepository` interface
- [ ] Implement `ApprovalWorkflowRepository`
- [ ] Create `ApprovalWorkflowController`
- [ ] GET /api/approval-workflows - List all workflows (admin)
- [ ] POST /api/approval-workflows - Create workflow (admin)
- [ ] PUT /api/approval-workflows/{id} - Update workflow (admin)
- [ ] DELETE /api/approval-workflows/{id} - Delete workflow (admin)
- [ ] GET /api/approval-requests/pending - Get pending approvals for current user
- [ ] POST /api/approval-requests/{id}/approve - Approve
- [ ] POST /api/approval-requests/{id}/reject - Reject
- [ ] POST /api/approval-requests/{id}/delegate - Delegate to another user
- [ ] GET /api/approval-requests/{id}/history - Get approval history
- [ ] Integrate approval workflow with documents
- [ ] Update InternalRequisitionService to initiate approval on submit
- [ ] Update StockAdjustmentService to initiate approval (if threshold exceeded)
- [ ] Update StockIssueService to initiate approval
- [ ] Add approval status checks before allowing further actions
- [ ] Add email notifications for approval requests
- [ ] Email to approver when approval is assigned
- [ ] Email to requester when approved/rejected
- [ ] Reminder emails for pending approvals
- [ ] Write unit tests
- [ ] Write integration tests
#### Frontend Workflow Features
- [ ] Create approval workflow configuration page (admin)
- [ ] List all workflows
- [ ] Create new workflow wizard
- [ ] Select document type
- [ ] Define approval levels
- [ ] Assign approvers (roles or users)
- [ ] Set amount thresholds
- [ ] Configure parallel approvals
- [ ] Edit existing workflows
- [ ] Activate/deactivate workflows
- [ ] Preview workflow diagram
- [ ] Create approval delegation page
- [ ] Set up delegation (date range, delegatee)
- [ ] View active delegations
- [ ] Revoke delegation
- [ ] Create pending approvals workbench
- [ ] List all pending approval requests for current user
- [ ] Filter by document type, age, requester
- [ ] Sort by date, priority
- [ ] Action buttons: approve, reject, view document
- [ ] Bulk actions (approve/reject multiple)
- [ ] Create approval detail modal/page
- [ ] Display document details (read-only)
- [ ] Show approval history/audit trail
- [ ] Approval action form (approve/reject with comments)
- [ ] Delegation option
- [ ] Add approval status indicators to document lists
- [ ] Status badge (Pending Approval, Approved, Rejected)
- [ ] Approval level indicator (e.g., "Level 2 of 3")
- [ ] Approver information
- [ ] Add approval history section to document detail views
- [ ] Timeline view of approval actions
- [ ] Approver name, action, date, comments
- [ ] Color coding (green for approved, red for rejected)
- [ ] Add approval workflow visualization
- [ ] Flowchart showing approval levels
- [ ] Highlight current level
- [ ] Show approvers at each level
- [ ] Add translation keys
- [ ] Test approval UI/UX
#### Testing
- [ ] Test single-level approval workflow
- [ ] Test multi-level approval workflow
- [ ] Test parallel approvals (multiple approvers at same level)
- [ ] Test amount-based routing
- [ ] Test approval delegation
- [ ] Test rejection flow (document returned to requester)
- [ ] Test approval notifications
- [ ] Test bulk approval actions
- [ ] Test approval permissions (only assigned approver can approve)
- [ ] User acceptance testing
---
## 🟠 Phase 3: Pharmacy Enhancements (HIGH if hospital) - 12 weeks
### 3.1 Pharmacy Master Data Enhancement (3 weeks) - 0/10
#### Backend Development
- [ ] Extend `Item` entity with pharmacy-specific fields
- [ ] TradeNameThai, TradeNameEnglish
- [ ] GenericName
- [ ] GovernmentAccountingCode
- [ ] IsControlledSubstance, IsDangerousDrug, IsNarcotic
- [ ] DrugCategory (enum or FK to category table)
- [ ] DosageForm (Tablet, Capsule, Injection, Syrup, etc.)
- [ ] Strength (e.g., "500mg", "10mg/ml")
- [ ] RouteOfAdministration (Oral, IV, IM, Topical, etc.)
- [ ] PharmacologicalCategory, SubCategory, SubMinorCategory
- [ ] StorageCondition (Room temp, Refrigerated, Frozen, etc.)
- [ ] RequiresPrescription flag
- [ ] Create `DrugPriceScheme` entity
- [ ] SchemeName (OPD, IPD, Employee, Central Drug Price, Cash)
- [ ] EffectiveDate, ExpiryDate
- [ ] IsActive flag
- [ ] Create `DrugPrice` entity
- [ ] ItemId (FK to Item)
- [ ] PriceSchemeId (FK to DrugPriceScheme)
- [ ] UnitPrice
- [ ] MarkupPercentage
- [ ] EffectiveDate
- [ ] Create `InsuranceScheme` entity
- [ ] SchemeCode, SchemeName
- [ ] CoverageType
- [ ] ReimbursementRate
- [ ] Create `DrugInsuranceCoverage` entity (many-to-many: Drug × Insurance)
- [ ] ItemId, InsuranceSchemeId
- [ ] IsCovered, CoverageLimit
- [ ] RequiresPriorAuthorization
- [ ] Create `PharmacologicalCategory` entity (hierarchical)
- [ ] Code, Name, Level (Category, SubCategory, SubMinor)
- [ ] ParentCategoryId (self-referencing for hierarchy)
- [ ] Create `ControlledSubstanceLog` entity (for narcotic tracking)
- [ ] ItemId, TransactionType
- [ ] Quantity, Date, Time
- [ ] PatientId (if applicable), PrescriptionId
- [ ] RecordedBy, ApprovedBy
- [ ] SpecialRemarks
- [ ] Create EF Core configuration classes for all new entities
- [ ] Create and run database migration
- [ ] Create DTOs for pharmacy master data
- [ ] MedicalItemDto (with all pharmacy fields)
- [ ] DrugPriceSchemeDto
- [ ] DrugPriceDto
- [ ] InsuranceSchemeDto
- [ ] PharmacologicalCategoryDto
- [ ] Create `IMedicalItemService` interface (extends base item service)
- [ ] Implement `MedicalItemService`
- [ ] CreateMedicalItem method
- [ ] UpdateMedicalItem method
- [ ] GetMedicalItemWithPrices method
- [ ] GetPriceByScheme method
- [ ] ManageDrugPrices method
- [ ] CheckControlledSubstance method
- [ ] Create `IPharmacyCategoryService` interface
- [ ] Implement `PharmacyCategoryService` (CRUD for categories)
- [ ] Create `MedicalItemController`
- [ ] GET /api/medical-items - List with pharmacy-specific filters
- [ ] GET /api/medical-items/{id} - Get full details including prices
- [ ] POST /api/medical-items - Create medical item
- [ ] PUT /api/medical-items/{id} - Update medical item
- [ ] GET /api/medical-items/{id}/prices - Get all price schemes for item
- [ ] PUT /api/medical-items/{id}/prices - Update prices
- [ ] GET /api/medical-items/controlled-substances - List controlled substances
- [ ] Create `PharmacyCategoryController`
- [ ] GET /api/pharmacy-categories/tree - Get category hierarchy
- [ ] POST /api/pharmacy-categories - Create category
- [ ] PUT /api/pharmacy-categories/{id} - Update category
- [ ] Seed initial data
- [ ] Common dosage forms
- [ ] Routes of administration
- [ ] Pharmacological categories (based on ATC classification or similar)
- [ ] Default price schemes (OPD, IPD, etc.)
- [ ] Write unit tests
- [ ] Write integration tests
#### Frontend Development
- [ ] Create medical item master form (enhanced item form)
- [ ] Basic item information section
- [ ] Pharmacy-specific fields section
- [ ] Trade names (Thai, English)
- [ ] Generic name
- [ ] Government accounting code
- [ ] Checkboxes: Controlled substance, Dangerous drug, Narcotic, Requires prescription
- [ ] Drug properties section
- [ ] Dosage form dropdown
- [ ] Strength input
- [ ] Route of administration
- [ ] Storage condition
- [ ] Classification section
- [ ] Pharmacological category tree selector
- [ ] Pricing section
- [ ] Grid for multiple price schemes
- [ ] Columns: Scheme, Unit Price, Markup %, Effective Date, Actions
- [ ] Add/remove price rows
- [ ] Insurance coverage section
- [ ] Checkboxes for covered schemes
- [ ] Coverage limits
- [ ] Save and validation
- [ ] Create pharmacological category management UI
- [ ] Tree view of categories
- [ ] Add/edit/delete categories
- [ ] Drag-and-drop to reorganize
- [ ] Create drug price scheme management UI
- [ ] List all schemes
- [ ] Create new scheme
- [ ] Activate/deactivate schemes
- [ ] Set effective dates
- [ ] Create controlled substance registry UI
- [ ] List all controlled substances
- [ ] Filter by category (narcotic, dangerous drug, etc.)
- [ ] Quick view of quantity on hand
- [ ] Link to transaction log
- [ ] Update medical item inquiry with pharmacy filters
- [ ] Filter by trade name, generic name
- [ ] Filter by pharmacological category
- [ ] Filter by controlled substance status
- [ ] Filter by price scheme
- [ ] Display pharmacy-specific columns in results
- [ ] Add translation keys (Thai and English medical terminology)
- [ ] Add routing and navigation
#### Testing
- [ ] Test medical item creation with all pharmacy fields
- [ ] Test drug pricing by scheme
- [ ] Test category hierarchy
- [ ] Test controlled substance flagging
- [ ] Test insurance coverage configuration
- [ ] Test validation (e.g., controlled substances must have special tracking)
- [ ] User acceptance testing with pharmacists
---
### 3.2 Pharmacy Workflows (3 weeks) - 0/11
#### Pharmacy Requisition (different from general requisition)
- [ ] Create `PharmacyRequisition` entity (extends or separate from InternalRequisition)
- [ ] Add pharmacy-specific fields
- [ ] PrescribingPhysician (for patient-specific requests)
- [ ] PatientId (if applicable)
- [ ] DepartmentType (Outpatient, Inpatient, Emergency, etc.)
- [ ] UrgencyLevel (Routine, Urgent, Stat)
- [ ] RequiresPharmacistReview flag
- [ ] Add controlled substance approval requirement
- [ ] Narcotic requisitions require dual approval
- [ ] Special approval form for controlled substances
- [ ] Create `IPharmacyRequisitionService` interface
- [ ] Implement `PharmacyRequisitionService`
- [ ] CheckControlledSubstanceLimits method
- [ ] RequireDualApproval method
- [ ] ValidatePrescription method (if linked to prescription)
- [ ] Create `PharmacyRequisitionController`
- [ ] Pharmacy-specific endpoints
- [ ] Controlled substance requisition workflow
- [ ] Update approval workflow to handle dual approvals for narcotics
- [ ] Add controlled substance quantity limits check
- [ ] Add prescription validation (if integrated with HIS)
- [ ] Create frontend pharmacy requisition form
- [ ] Add pharmacy-specific fields
- [ ] Warning indicators for controlled substances
- [ ] Prescription attachment (future)
- [ ] Dual approval status display
- [ ] Test pharmacy requisition workflow
- [ ] Test controlled substance requisition and dual approval
- [ ] User acceptance testing with pharmacy staff
#### Pharmacy Issue with Prescription Tracking
- [ ] Create `PharmacyDispensing` entity (extends or separate from StockIssue)
- [ ] PrescriptionId (link to HIS or internal prescription system)
- [ ] PatientId
- [ ] PrescribingPhysician
- [ ] DispensedBy (pharmacist)
- [ ] VerifiedBy (second pharmacist for controlled substances)
- [ ] DispenseDate, DispenseTime
- [ ] DispensingInstructions
- [ ] PatientCounseling (notes from pharmacist)
- [ ] Create `IPharmacyDispensingService` interface
- [ ] Implement `PharmacyDispensingService`
- [ ] DispenseFromPrescription method
- [ ] RequireSecondCheck method (for high-alert drugs)
- [ ] RecordCounseling method
- [ ] LogControlledSubstanceDispensing method
- [ ] Integrate with ControlledSubstanceLog for narcotic dispensing
- [ ] Add second pharmacist verification for controlled substances
- [ ] Require signature/approval from second pharmacist
- [ ] Record both pharmacists in transaction
- [ ] Add patient counseling documentation
- [ ] Free text field for counseling notes
- [ ] Standard counseling points checklist
- [ ] Create `PharmacyDispensingController`
- [ ] GET /api/pharmacy/dispensing/pending-prescriptions
- [ ] POST /api/pharmacy/dispensing/dispense
- [ ] POST /api/pharmacy/dispensing/{id}/verify (second check)
- [ ] GET /api/pharmacy/dispensing/history (patient drug history)
- [ ] Create frontend pharmacy dispensing interface
- [ ] Prescription queue (pending dispensing)
- [ ] Dispense form with prescription details
- [ ] Drug interaction checker (placeholder for future)
- [ ] Patient counseling form
- [ ] Second pharmacist verification interface
- [ ] Print prescription label
- [ ] Test pharmacy dispensing workflow
- [ ] Test controlled substance double-check
- [ ] Test patient counseling documentation
- [ ] User acceptance testing
#### Controlled Substance Tracking
- [ ] Implement controlled substance transaction logging
- [ ] Auto-log all receipt, issue, adjustment of controlled substances
- [ ] Include all required details (date, time, quantity, patient, physician, pharmacists)
- [ ] Create controlled substance reconciliation report
- [ ] Daily balance verification
- [ ] Compare physical count vs system balance
- [ ] Require dual signature on reconciliation
- [ ] Create controlled substance register/logbook
- [ ] Traditional logbook format (required by regulations)
- [ ] Printable format with all transactions
- [ ] Running balance
- [ ] Signature columns
- [ ] Add special approval workflow for controlled substance orders
- [ ] Require authorization from director/chief pharmacist
- [ ] Document approval reason
- [ ] Implement quantity limits for controlled substance dispensing
- [ ] Daily limits per patient
- [ ] Monthly limits per patient
- [ ] Alert when limits exceeded
- [ ] Override mechanism with justification
- [ ] Create `ControlledSubstanceController`
- [ ] GET /api/controlled-substances/transactions
- [ ] GET /api/controlled-substances/balance
- [ ] POST /api/controlled-substances/reconcile
- [ ] GET /api/controlled-substances/register (logbook view)
- [ ] Create frontend controlled substance management
- [ ] Transaction log viewer
- [ ] Daily reconciliation interface
- [ ] Register/logbook view and print
- [ ] Discrepancy reporting
- [ ] Test controlled substance logging
- [ ] Test reconciliation workflow
- [ ] Test quantity limits and alerts
- [ ] Compliance review with pharmacy regulations
- [ ] User acceptance testing
---
### 3.3 Pharmacy Alerts and Compliance (2 weeks) - 0/6
#### Near-Expiry Alerts for Pharmacy
- [ ] Create pharmacy-specific expiry alert thresholds
- [ ] 12 months (for long-lead items)
- [ ] 7 months (standard alert)
- [ ] 3 months (urgent action required)
- [ ] 1 month (critical, consider disposal)
- [ ] Enhance near-expiry alert service for pharmacy
- [ ] Group by urgency level
- [ ] Calculate potential loss value
- [ ] Suggest return to supplier options
- [ ] Create near-expiry action tracking
- [ ] Record actions taken (returned to vendor, transferred, used in campaigns, disposed)
- [ ] Track outcome (recovered value, loss)
- [ ] Add near-expiry dashboard widget for pharmacy
- [ ] Summary by urgency level
- [ ] Chart showing items by expiry month
- [ ] Quick actions (return, transfer, dispose)
- [ ] Test pharmacy expiry alerts
- [ ] User acceptance testing
#### Narcotic/Controlled Substance Reporting
- [ ] Create monthly controlled substance usage report
- [ ] Summary of receipts, dispensing, balance by controlled substance
- [ ] Comparison with previous months
- [ ] Variance analysis
- [ ] Create controlled substance audit trail report
- [ ] Detailed transaction log for audit
- [ ] Filter by date range, substance, transaction type
- [ ] Include all regulatory required fields
- [ ] Create discrepancy report
- [ ] List any discrepancies found during reconciliation
- [ ] Investigation notes
- [ ] Resolution status
- [ ] Create controlled substance disposal report
- [ ] Items disposed (expired, damaged, recalled)
- [ ] Disposal method, date, witnesses
- [ ] Regulatory compliance documentation
- [ ] Add export to PDF/Excel for submission to authorities
- [ ] Test all controlled substance reports
- [ ] Compliance review with regulations
- [ ] User acceptance testing
#### Dangerous Drug Storage Tracking
- [ ] Create `DangerousGoodStorageLocation` entity
- [ ] SpecialStorageType (Controlled temp, Flammable, Refrigerated, etc.)
- [ ] TemperatureLog (if applicable)
- [ ] AccessControl (who can access)
- [ ] ComplianceChecklist
- [ ] Add storage compliance checking
- [ ] Verify dangerous drugs stored in approved locations only
- [ ] Alert if dangerous drug in non-compliant location
- [ ] Create temperature monitoring for refrigerated drugs
- [ ] Log temperature readings
- [ ] Alert if temperature out of range
- [ ] Integrate with IoT temperature sensors (future)
- [ ] Create storage compliance report
- [ ] List all dangerous drugs and their storage locations
- [ ] Compliance status
- [ ] Temperature logs for refrigerated items
- [ ] Test storage tracking
- [ ] Compliance review
- [ ] User acceptance testing
---
### 3.4 Pharmacy Reports (3 weeks) - 0/14
#### Implement all pharmacy-specific reports from requirements 3.9.7
##### Report P1: Drug/Medical Receipt-Issue Inspection Report
- [ ] Create query combining receipts and issues for pharmacy
- [ ] Create report template with details for audit
- [ ] Add filters: date range, item, lot
- [ ] Test and deploy
##### Report P2: Near-Expiry Drug Report (Enhanced)
- [ ] Extend existing near-expiry report with pharmacy-specific fields
- [ ] Add columns: Trade name, Generic name, Dosage form, Strength
- [ ] Add suggested actions column
- [ ] Add potential loss value calculation
- [ ] Test and deploy
##### Report P3: Drug Receipt Report
- [ ] Create query for pharmacy goods receipts
- [ ] Add pharmacy-specific columns
- [ ] Add grouping by vendor and drug category
- [ ] Test and deploy
##### Report P4: Pending Receipt Report (Pharmacy)
- [ ] Create pharmacy-specific pending receipt report
- [ ] Add critical drug indicators
- [ ] Add stock-out risk analysis
- [ ] Test and deploy
##### Report P5: Vendor Invoice Report
- [ ] Create invoice matching report
- [ ] Add price variance analysis
- [ ] Add drug-specific columns
- [ ] Test and deploy
##### Report P6: Drug/Medical Inventory Summary
- [ ] Create comprehensive inventory summary for pharmacy
- [ ] Add sections: by category, by storage location, controlled substances
- [ ] Add value breakdown by price scheme (OPD, IPD, etc.)
- [ ] Add KPIs: turnover rate, days of supply, stock-out rate
- [ ] Test and deploy
##### Report P7: Drug Receipt to Warehouse Report
- [ ] Create detailed receipt transaction report
- [ ] Add columns: Receipt number, Date, Vendor, PO reference, Items, Quantities, Costs
- [ ] Add lot and expiry tracking
- [ ] Test and deploy
##### Report P8: Medical Supplies Pending Delivery Report
- [ ] Create report showing items in transit
- [ ] Add expected delivery dates
- [ ] Add aging analysis (overdue deliveries)
- [ ] Test and deploy
##### Report P9: Purchase Requisition Forms (Pharmacy)
- [ ] Create pharmacy-formatted purchase requisition
- [ ] Add drug-specific fields (trade name, generic name, dosage form)
- [ ] Add regulatory information
- [ ] Add approval signature sections
- [ ] Test and deploy
##### Report P10: Purchase Order Form (Pharmacy)
- [ ] Create pharmacy-formatted PO
- [ ] Add vendor drug license verification
- [ ] Add special handling instructions
- [ ] Add storage requirements
- [ ] Test and deploy
##### Report P11: Receipt Memo and Accounting Record
- [ ] Create accounting format receipt document
- [ ] Add GL account information
- [ ] Add cost center allocation
- [ ] Add authorization signatures
- [ ] Test and deploy
##### Report P12: Controlled Substance Register (Logbook)
- [ ] Create traditional logbook format report
- [ ] Add all regulatory required columns
- [ ] Add running balance
- [ ] Add signature sections
- [ ] Ensure printable format matches regulatory requirements
- [ ] Test and deploy
##### Report P13: Pharmacy KPI Dashboard Report
- [ ] Create executive summary report
- [ ] Add KPIs: Stock value, Turnover rate, Near-expiry items, Controlled substance balance
- [ ] Add trend charts
- [ ] Add comparison with targets
- [ ] Test and deploy
##### Report P14: Drug Utilization Report
- [ ] Create report showing usage patterns by drug
- [ ] Add analysis by department, diagnosis (if available from HIS)
- [ ] Add ABC analysis
- [ ] Add cost analysis
- [ ] Test and deploy
---
### 3.5 HIS Integration (3 weeks) - 0/5
#### Integration Architecture
- [ ] Design integration approach (API, Message Queue, Database sync)
- [ ] Create `IHISIntegrationService` interface
- [ ] Implement authentication/authorization for HIS API
- [ ] Create data mapping between PIAM and HIS models
- [ ] Implement error handling and retry logic
- [ ] Create integration logging and monitoring
- [ ] Write integration tests with HIS sandbox/test environment
#### Prescription Orders Integration
- [ ] Create `Prescription` entity (or sync from HIS)
- [ ] PrescriptionId, PatientId, PhysicianId
- [ ] PrescriptionDate, Items
- [ ] Status (New, Filled, PartiallyFilled, Cancelled)
- [ ] Implement ReceivePrescription method
- [ ] Receive prescription orders from HIS
- [ ] Validate drug availability
- [ ] Create pharmacy dispensing task
- [ ] Send acknowledgment to HIS
- [ ] Implement GetPendingPrescriptions method
- [ ] Query HIS for new prescriptions
- [ ] Sync to PIAM pharmacy queue
- [ ] Implement UpdatePrescriptionStatus method
- [ ] Notify HIS when prescription filled
- [ ] Send dispensed quantity and pharmacist information
- [ ] Test prescription order flow end-to-end
#### Dispensing Records Integration
- [ ] Implement SendDispensingRecord method
- [ ] Send dispensing details to HIS
- [ ] Include drug, quantity, pharmacist, counseling notes
- [ ] Update patient medication administration record (MAR)
- [ ] Implement GetDispenseHistory method
- [ ] Retrieve patient's medication history from HIS
- [ ] Display in PIAM for drug interaction checking
- [ ] Display for refill validation
- [ ] Test dispensing record synchronization
#### Patient Drug History Integration
- [ ] Implement GetPatientDrugHistory method
- [ ] Retrieve patient's complete drug history from HIS
- [ ] Display allergies, adverse reactions
- [ ] Display current medications
- [ ] Implement drug interaction checking (basic)
- [ ] Check current prescription against patient history
- [ ] Alert for potential interactions
- [ ] Alert for duplicate therapy
- [ ] Alert for allergies
- [ ] Create patient drug history viewer in frontend
- [ ] Test patient history retrieval and display
#### Stock Level Integration (Bi-directional)
- [ ] Implement SendStockLevel method
- [ ] Send pharmacy stock levels to HIS
- [ ] Real-time or scheduled sync
- [ ] Implement ReceiveStockLevelRequest method
- [ ] HIS queries PIAM for drug availability
- [ ] Return current quantity on hand
- [ ] Test stock level synchronization
#### Testing & Go-Live
- [ ] Integration testing with HIS test environment
- [ ] End-to-end testing (prescription → dispensing → patient record)
- [ ] Performance testing (throughput, latency)
- [ ] Failover testing (handle HIS downtime gracefully)
- [ ] Security and compliance testing
- [ ] User acceptance testing
- [ ] Production deployment coordination with HIS team
- [ ] Post-go-live monitoring and support
---
## 🟢 Phase 4: Advanced Features (MEDIUM) - 10 weeks
### 4.1 General Warehouse Enhancements (2 weeks) - 0/8
#### Stock Level Alerting Enhancements
- [ ] Add reorder point automatic calculation
- [ ] Based on historical usage
- [ ] Lead time consideration
- [ ] Safety stock calculation
- [ ] Add seasonal adjustment for reorder points
- [ ] Add demand forecasting (simple moving average or exponential smoothing)
- [ ] Add automated purchase requisition generation
- [ ] Auto-create PR when stock below reorder point
- [ ] Suggest order quantity (EOQ formula)
- [ ] Test automated reorder functionality
#### Return Receipt Flows
- [ ] Implement receipt return from departments
- [ ] Create `DepartmentReturn` document type
- [ ] Link to original issue
- [ ] Capture return reason
- [ ] Return to stock or quarantine
- [ ] Implement inter-warehouse return flow
- [ ] Create reverse transfer
- [ ] Track return reasons
- [ ] Add return authorization workflow
- [ ] Require approval for returns
- [ ] Quality check before returning to stock
- [ ] Create return receipt frontend
- [ ] Test return workflows
---
### 4.2 Budget & Accounting Integration (3 weeks) - 0/11
#### GL Account Mapping
- [ ] Create `WarehouseGLMapping` entity
- [ ] Map Warehouse + ItemCategory → GL Accounts
- [ ] InventoryAccount (asset), CostOfGoodsAccount (expense), VarianceAccount, ReturnAccount
- [ ] Create `IGLIntegrationService` interface
- [ ] Implement `GLIntegrationService`
- [ ] GetGLAccountForTransaction method
- [ ] GenerateGLEntry method
- [ ] PostToGL method (integration with accounting system)
- [ ] Create GL mapping configuration UI
- [ ] Test GL account mapping
#### Accounting Voucher Generation
- [ ] Implement voucher generation on inventory transactions
- [ ] Receipt: Debit Inventory, Credit Accounts Payable
- [ ] Issue: Debit COGS, Credit Inventory
- [ ] Adjustment: Debit/Credit Variance Account and Inventory
- [ ] Transfer: No GL impact (inter-account transfer)
- [ ] Create `AccountingVoucher` entity (or integrate with existing accounting module)
- [ ] Create voucher batch processing
- [ ] Daily batch job to generate vouchers
- [ ] Manual trigger for immediate posting
- [ ] Create voucher review and approval workflow
- [ ] Test voucher generation for all transaction types
#### Budget Tracking
- [ ] Create `BudgetAllocation` entity
- [ ] By ItemCategory or Item, By Department, By Fiscal year
- [ ] AllocatedAmount, CommittedAmount, ActualAmount, AvailableAmount
- [ ] Create `IBudgetService` interface
- [ ] Implement `BudgetService`
- [ ] CheckBudgetAvailability method
- [ ] CommitBudget method (on requisition approval)
- [ ] PostBudget method (on goods receipt or issue)
- [ ] ReleaseBudget method (on requisition cancellation)
- [ ] GetBudgetUtilization method
- [ ] Integrate budget checking into requisition approval
- [ ] Reject requisition if budget insufficient
- [ ] Allow override with special approval
- [ ] Create budget allocation configuration UI
- [ ] Set up budgets by department, category, fiscal year
- [ ] Import budget from Excel
- [ ] Adjust budgets (with approval)
- [ ] Create budget utilization dashboard
- [ ] Show allocated vs committed vs actual
- [ ] Show available budget
- [ ] Alert when approaching limit (e.g., 80% utilized)
- [ ] Test budget checking and commitment workflow
#### Cost Accounting Reports
- [ ] Create Cost of Goods Issued report
- [ ] Calculate COGS by department, category, time period
- [ ] Create Inventory Valuation report
- [ ] Total inventory value by warehouse, category
- [ ] Aging analysis
- [ ] Comparison with previous period
- [ ] Create Budget vs Actual report
- [ ] Compare budget allocation, committed, actual
- [ ] Variance analysis
- [ ] Forecast year-end position
- [ ] Create Variance Analysis report
- [ ] Price variance (PO price vs actual receipt price)
- [ ] Quantity variance (ordered vs received)
- [ ] Usage variance (expected vs actual consumption)
- [ ] Test all cost accounting reports
---
### 4.3 ASN (Advanced Ship Notice) (2 weeks) - 0/8
#### Backend Development
- [ ] Create `AdvancedShipNotice` entity
- [ ] ASN Number, ASN Date, Expected Arrival Date
- [ ] Link to PurchaseOrder
- [ ] VendorReference, Carrier, TrackingNumber
- [ ] Status (Sent, In Transit, Arrived, Received, Closed)
- [ ] Lines collection
- [ ] Create `AdvancedShipNoticeLine` entity
- [ ] Item, OrderedQuantity, ShippedQuantity
- [ ] Lot numbers, Expiry dates (from vendor)
- [ ] Box/Pallet information (packaging details)
- [ ] Weight, Dimensions
- [ ] Create EF Core configuration classes
- [ ] Create and run database migration
- [ ] Create DTOs
- [ ] Create `IASNService` interface
- [ ] Implement `ASNService`
- [ ] ImportASN method (EDI, API, manual entry)
- [ ] CreateGoodsReceiptFromASN method
- [ ] CompareASNvsActual method (discrepancy detection)
- [ ] CloseASN method
- [ ] Create `ASNController`
- [ ] GET /api/asn - List ASNs
- [ ] POST /api/asn/import - Import ASN
- [ ] GET /api/asn/{id} - Get ASN details
- [ ] POST /api/asn/{id}/create-grn - Create GRN from ASN
- [ ] Implement EDI integration for ASN (if vendor supports)
- [ ] Parse EDI 856 Advance Ship Notice
- [ ] Map to ASN entity
- [ ] Implement email parsing for ASN
- [ ] Parse vendor shipping notification emails
- [ ] Extract ASN data
- [ ] Write unit tests
- [ ] Write integration tests
#### Frontend Development
- [ ] Update `warehouse-asn` module (currently mock)
- [ ] Create TypeScript models
- [ ] Create `ASNService` (HTTP client)
- [ ] Create ASN import page
- [ ] Manual entry form
- [ ] File upload (EDI, Excel)
- [ ] Email integration (future)
- [ ] Create ASN workbench
- [ ] List all ASNs with status
- [ ] Filter by date, vendor, status
- [ ] Action: Create GRN from ASN
- [ ] Create ASN detail view
- [ ] Display ASN header and lines
- [ ] Show expected vs actual quantities (for closed ASNs)
- [ ] Discrepancy highlights
- [ ] Create ASN-to-GRN wizard
- [ ] Pre-populate GRN form with ASN data
- [ ] Allow adjustments
- [ ] Quick receive workflow
- [ ] Add translation keys
- [ ] Add routing and navigation
#### Testing
- [ ] Test ASN import (manual, EDI, file)
- [ ] Test GRN creation from ASN
- [ ] Test discrepancy detection
- [ ] Test ASN status workflow
- [ ] Test with sample vendor ASN data
- [ ] User acceptance testing
---
### 4.4 Tier 3-4 Reports & Analytics (3 weeks) - 0/8
#### Tier 3: Compliance and Audit Reports
##### Report A1: Receipt Inspection Report (Enhanced)
- [ ] Add quality inspection details
- [ ] Add acceptance/rejection criteria
- [ ] Add inspector signatures
- [ ] Add photos/attachments support (future)
- [ ] Test and deploy
##### Report A2: Adjustment Report with Reasons
- [ ] Create detailed adjustment report
- [ ] Group by reason code
- [ ] Add value impact analysis
- [ ] Add approver information
- [ ] Add trend analysis (frequent adjustments by item/location)
- [ ] Test and deploy
##### Report A3: Cycle Count Results (Enhanced)
- [ ] Extend existing cycle count report
- [ ] Add variance analysis by employee, location, item
- [ ] Add accuracy metrics
- [ ] Add trend over time
- [ ] Test and deploy
##### Report A4: Item Master Change Log
- [ ] Create audit trail report for item master changes
- [ ] Add columns: Date, User, Field Changed, Old Value, New Value, Reason
- [ ] Add filters: date range, item, user, field
- [ ] Test and deploy
##### Report A5: Transaction Audit Trail
- [ ] Create comprehensive transaction log report
- [ ] Add columns: Date, Time, Transaction Type, Document, User, Item, Quantity, Location, Before/After values
- [ ] Add filters for forensic analysis
- [ ] Test and deploy
#### Tier 4: Analytics Reports
##### Report A6: ABC Analysis
- [ ] Create ABC classification report
- [ ] Classify items by value (A: top 80%, B: next 15%, C: remaining 5%)
- [ ] Classify items by quantity
- [ ] Classify items by movement frequency
- [ ] Add visualization (Pareto chart)
- [ ] Add recommendations (e.g., "Focus cycle counting on Class A items")
- [ ] Test and deploy
##### Report A7: Slow-Moving and Non-Moving Items
- [ ] Create query for items with no movement in X days (configurable: 90, 180, 365 days)
- [ ] Calculate carrying cost for slow-moving inventory
- [ ] Add recommendations (dispose, discount, return to vendor)
- [ ] Test and deploy
##### Report A8: Stock Turnover Report
- [ ] Calculate turnover rate by item, category, warehouse
- [ ] Turnover Rate = COGS / Average Inventory Value
- [ ] Days of Supply = Average Inventory / Average Daily Usage
- [ ] Add trend analysis
- [ ] Add comparison with target turnover rates
- [ ] Add benchmarking (industry standards)
- [ ] Test and deploy
##### Report A9: Demand Forecasting Report
- [ ] Implement simple forecasting model (moving average or exponential smoothing)
- [ ] Generate forecast for next 1, 3, 6, 12 months
- [ ] Add confidence intervals
- [ ] Add comparison with actual demand (forecast accuracy)
- [ ] Add seasonal adjustment
- [ ] Test and deploy
##### Report A10: Price Comparison Report
- [ ] Compare prices across vendors for same items
- [ ] Show price history over time
- [ ] Identify best price opportunities
- [ ] Add cost savings analysis (if switched vendors)
- [ ] Test and deploy
#### Analytics Dashboard
- [ ] Create warehouse analytics dashboard
- [ ] KPI widgets (stock value, turnover rate, accuracy, fill rate)
- [ ] Charts (inventory trend, ABC distribution, movement analysis)
- [ ] Top lists (top moving items, top value items, top discrepancies)
- [ ] Alerts summary
- [ ] Add drill-down capabilities (click widget to see detailed report)
- [ ] Add date range selector
- [ ] Add export to PDF/PowerPoint
- [ ] Test dashboard with real data
- [ ] User acceptance testing
---
### 4.5 Configuration Management UI (2 weeks) - 0/5
#### Warehouse Settings Management
- [ ] Create `WarehouseSettings` entity
- [ ] Document numbering formats (patterns and sequences)
- [ ] Default warehouses for user roles
- [ ] Auto-approval thresholds (by document type and amount)
- [ ] Alert configurations (thresholds, channels, recipients)
- [ ] Email notification settings (SMTP config, templates)
- [ ] Reporting settings (logo, headers, footers)
- [ ] Integration settings (HIS endpoints, credentials)
- [ ] Create `ISettingsService` interface
- [ ] Implement `SettingsService` (CRUD for settings)
- [ ] Create `SettingsController`
- [ ] Create settings management UI (admin panel)
- [ ] Tabs for different setting categories
- [ ] Document numbering configuration
- [ ] Define patterns with placeholders (e.g., REQ-{YYYY}-{MM}-{####})
- [ ] Set current sequence numbers
- [ ] Reset sequences
- [ ] Default values configuration
- [ ] Auto-approval thresholds
- [ ] Alert configuration (link to existing alert config from Phase 2)
- [ ] Email settings
- [ ] Report customization (logo upload, header/footer text)
- [ ] Save and validate settings
- [ ] Test settings management
- [ ] User acceptance testing
#### Master Data Management UIs
##### Adjustment Reasons
- [ ] Create CRUD UI for adjustment reasons
- [ ] List all reasons with active/inactive status
- [ ] Add/edit/delete reasons
- [ ] Set default reason
- [ ] Test and deploy
##### Transfer Types
- [ ] Create `TransferType` enum or entity (if not exists)
- [ ] StandardTransfer, BorrowOut, BorrowReturn, Emergency, Replenishment, Redistribution
- [ ] Create CRUD UI for transfer types
- [ ] Associate transfer types with workflow rules (e.g., borrow requires return date)
- [ ] Test and deploy
##### Document Types
- [ ] Create master list of document types (if not already exists)
- [ ] Create CRUD UI for document type configuration
- [ ] Define numbering pattern per document type
- [ ] Define required approvals per document type
- [ ] Define permissions per document type
- [ ] Test and deploy
##### Storage Location Types
- [ ] Create CRUD UI for location types
- [ ] List all location types (Warehouse, Sub-Store, Bin, Quarantine, etc.)
- [ ] Add/edit/delete location types
- [ ] Associate location types with properties (e.g., requires temperature control)
- [ ] Test and deploy
##### Unit of Measure (UOM)
- [ ] Create CRUD UI for UOM management
- [ ] List all UOMs with conversion factors
- [ ] Add/edit/delete UOMs
- [ ] Define base UOM per item
- [ ] Test UOM conversions
#### User Role Management (Warehouse-Specific)
- [ ] Extend existing user/role management with warehouse-specific permissions
- [ ] Create warehouse permission matrix
- [ ] Permissions: View Stock, Receive Goods, Issue Stock, Adjust Stock, Approve Requisitions, Manage Settings, etc.
- [ ] Roles: Warehouse Manager, Warehouse Clerk, Pharmacist, Department Requester, etc.
- [ ] Create role assignment UI
- [ ] Assign users to warehouse roles
- [ ] Assign users to specific warehouses (location-based access control)
- [ ] Test role-based access control
- [ ] User acceptance testing
---
## 📋 Additional Tasks (Ongoing)
### Documentation - 0/8
- [ ] Write user manuals for all new modules
- [ ] Write administrator guides (settings, master data, workflows)
- [ ] Create video tutorials for key workflows
- [ ] Document API endpoints (Swagger/OpenAPI)
- [ ] Create database schema documentation
- [ ] Write deployment and configuration guides
- [ ] Create troubleshooting guides
- [ ] Maintain change log
### Testing - 0/6
- [ ] Conduct security testing (penetration testing, vulnerability scanning)
- [ ] Conduct performance testing (load testing, stress testing)
- [ ] Conduct usability testing with end users
- [ ] Conduct accessibility testing (WCAG compliance)
- [ ] Conduct browser compatibility testing
- [ ] Conduct mobile responsiveness testing
### Training - 0/4
- [ ] Develop training materials
- [ ] Conduct train-the-trainer sessions
- [ ] Conduct end-user training sessions
- [ ] Create training assessment and certification
### Deployment - 0/5
- [ ] Set up production environment
- [ ] Conduct data migration (if needed)
- [ ] Perform production deployment
- [ ] Conduct post-deployment verification
- [ ] Provide hypercare support (1-2 weeks post-deployment)
---
## Priority Matrix Quick Reference
### 🔴 CRITICAL (Implement Immediately)
1. Internal Requisition Module
2. Stock Issue/Dispense Module
3. Stock Adjustment Module
4. Essential Reports (Tier 1)
### 🟡 HIGH (Implement Soon)
1. Operational Reports (Tier 2)
2. Document Printing & Labels
3. Alert System
4. Approval Workflow Engine
5. Pharmacy Enhancements (if hospital)
### 🟠 MEDIUM (Implement Later)
1. Budget & Accounting Integration
2. Configuration Management UI
3. Tier 3-4 Reports & Analytics
### 🟢 LOW (Enhancement/Optimization)
1. ASN Implementation
2. Transfer Order Creation UI
3. Cycle Count Enhancements
---
**End of TODO List**