# Changelog — Swapnapuri Nursing Home HMIS

All notable changes and architectural milestones for **Swapnapuri Nursing Home — Hospital Management Information System** are documented in this file.

---

## [1.0.0] — 2026-09-30 (Initial Production Release)

### 🏥 System Foundations & Runtime Architecture
* **Framework:** Initialized clean Laravel 10.50.3 project structure with full vendor dependencies.
* **Portable Execution Engine:** Implemented self-healing `artisan` trampoline runner and project-local `php.ini` with auto-loaded `pdo_sqlite`, `pdo_mysql`, `gd`, `intl`, `mbstring`, and `curl` extensions.
* **Dual-Engine Schema Parity:** Designed ANSI SQL schema natively compatible with enterprise MySQL 8.0+ / MariaDB 10.5+ and local development/testing SQLite (`database/database.sqlite`).
* **Health Check API:** Registered zero-auth operational health endpoint at `/health` returning JSON telemetry.

---

### 🗄️ Database Architecture (21 Migrations)
* `2019_12_14_000001_create_personal_access_tokens_table.php` — API authentication tokens.
* `2024_01_01_000001_create_users_and_roles_table.php` — Hospital RBAC matrix with 20 distinct medical and administrative roles.
* `2024_01_01_000002_create_hospital_settings_and_masters_table.php` — Departments, clinical specialities, service tariff master.
* `2024_01_01_000003_create_doctors_table.php` — Doctor consultant profiles, OPD schedules, and leave tracking.
* `2024_01_01_000004_create_patients_table.php` — Master patient index with permanent `SNH-XXXXXXXX` IDs, UHID, Indian address schema, and duplicate detection.
* `2024_01_01_000005_create_opd_and_appointments_table.php` — Walk-in tokens, appointments, triage vitals, and queue statuses.
* `2024_01_01_000006_create_clinical_records_and_prescriptions_table.php` — SOAP notes, ICD diagnoses, prescription items, and templates.
* `2024_01_01_000007_create_pharmacy_and_inventory_table.php` — Item catalog, suppliers, FEFO inventory batches, and transactions.
* `2024_01_01_000008_create_pharmacy_pos_table.php` — POS sales receipts, line items, returns, and cashier reconciliation.
* `2024_01_01_000009_create_laboratory_tables.php` — LIS categories, test directory, reference ranges, vacutainer barcodes, and results.
* `2024_01_01_000010_create_radiology_tables.php` — RIS modalities, imaging procedures, PACS/DICOM accession numbers, and reports.
* `2024_01_01_000011_create_wards_and_beds_table.php` — Wards, rooms, color-coded bed statuses, and bed transfer audit trail.
* `2024_01_01_000012_create_ipd_admissions_table.php` — Inpatient admissions, MLC tagging, daily progress notes, and discharge summaries.
* `2024_01_01_000013_create_nursing_station_table.php` — Bedside nursing assessments, MAR medication charts, and fluid intake/output.
* `2024_01_01_000014_create_operation_theatre_table.php` — OT rooms, surgical schedules, WHO surgical safety checklists, and PAC notes.
* `2024_01_01_000015_create_billing_and_payments_table.php` — Centralized invoices, line items, payments, refunds, and packages.
* `2024_01_01_000016_create_insurance_and_tpa_table.php` — Insurance providers, TPA pre-authorizations, claims, and documents.
* `2024_01_01_000017_create_blood_bank_table.php` — Blood donors, barcoded bags, compatibility cross-matching, and transfusions.
* `2024_01_01_000018_create_ambulance_and_ancillary_table.php` — Ambulances, trips, housekeeping cleaning logs, laundry, and biomedical equipment.
* `2024_01_01_000019_create_hr_and_payroll_table.php` — Staff profiles, biometric attendance, leaves, and salary payroll runs.
* `2024_01_01_000020_create_audit_logs_and_notifications_table.php` — Immutable audit ledger and SMS/Email/WhatsApp notification log.

---

### 🌱 Seeders & Master Data (10 Seeders)
* Seeded 14 hospital staff users with BCrypt credentials across all key roles.
* Seeded 11 clinical departments (General Medicine, General Surgery, Gynae & Obs, Paediatrics, Orthopaedics, Cardiology, etc.).
* Seeded 6 consultant doctors with qualifications, MCI registration numbers, OPD consulting fees, and weekly schedule slots.
* Seeded 36 beds across 5 wards (Male Medical, Female Surgical, ICU/CCU, Maternity, Deluxe Private).
* Seeded standard hospital services catalog (OPD Consultation, Emergency Casualty, ECG, Minor OT, Dressing, Nursing).
* Seeded central pharmacy stock: 7 essential medicines with FEFO batches, MRP, selling price, and expiry dates.
* Seeded diagnostic laboratory test catalog: Complete Blood Count (CBC), Liver Function Test (LFT), Kidney Function Test (KFT) with 20+ reference intervals and critical limits.
* Seeded radiology modalities (X-Ray, Ultrasound, CT Scan) and procedures.
* Seeded 2 demo patients (`SNH-00000001` and `SNH-00000002`) with active OPD queue tokens and triage vitals.

---

### ⚙️ Domain Services
* `BarcodeService`: Pure-PHP SVG Code 128 barcode and QR vector generator (zero-GD/Imagick binary dependency).
* `PatientService`: Thread-safe sequential `SNH-XXXXXXXX` generation, UHID generation, and fuzzy duplicate detection.
* `BillingService`: Multi-department invoice generation, taxes, discounts, receipts, and transactional balance settlement.
* `PharmacyService`: First-Expiry-First-Out (FEFO) batch deduction and stock audit.
* `LaboratoryService`: Sample accessioning with barcode scanning, result validation, and pathologist sign-off.
* `NotificationService`: Multi-channel dispatch abstraction (In-app, SMS, Email, WhatsApp).

---

### 🖥️ User Interface & Blade Templates (21 Views)
* Responsive layouts with Tailwind CSS, Alpine.js, and FontAwesome 6 icons.
* Global USB laser/CCD barcode scanner listener in navigation header with auto-redirect to patient summary.
* 80mm thermal printable slips for OPD tokens and Pharmacy receipts.
* A4 printable clinical e-prescriptions, diagnostic laboratory reports, inpatient discharge summaries, and tax invoices.
* Interactive Bed Matrix with color-coded bed status badges and 1-click modal patient transfer.

---

### 🧪 Automated Testing Suite (PHPUnit 10)
* 17 automated test suites with 58 assertions verifying:
  * Health check operational response
  * Unauthenticated access redirection
  * Admin login & Dashboard analytics
  * Barcode & QR SVG vector generation
  * Patient registration, sequential ID assignment, and duplicate prevention
  * Global barcode lookup API
  * OPD visit creation & token queue issuance
  * Doctor consultation SOAP notes, diagnoses, and e-prescription generation
  * Pharmacy POS FEFO stock deduction
  * Bed matrix visual census & availability
  * Laboratory sample accessioning and result verification
  * Inpatient (IPD) admission, bed occupancy, and discharge summary generation
  * Billing invoice generation and payment receipt settlement
  * Hospital analytics and financial census calculations
  * Tamper-evident audit trail explorer
* **Result:** 100% Passing.
