Skip to content

feat: offline IndexedDB formulary, smart drug ranking, clinical safety guardrails & WCAG fixes - #3

Open
refat247 wants to merge 1 commit into
eabgitbd:mainfrom
refat247:fix/offline-pwa-clinical-safety-uiux
Open

refat247 wants to merge 1 commit into
eabgitbd:mainfrom
refat247:fix/offline-pwa-clinical-safety-uiux

Conversation

@refat247

Copy link
Copy Markdown

Summary of Changes

Fixes #2

This Pull Request addresses the critical offline persistence, clinical safety, autocomplete ranking, UI/UX interaction, and WCAG accessibility defects identified during our comprehensive audit of PrescribePro-Rx (Version 3.0 Pro).


Key Implementations

1. 100% Offline 41k Formulary Engine (IndexedDB + Service Worker)

  • IndexedDB Store (PrescribeProDB / drugs_cache): Added an IndexedDB layer in scripts.js to store data/drugs.json. Bypasses the 5 MB browser localStorage quota and enables instant 0ms startup without throwing QuotaExceededError.
  • True PWA Service Worker (sw.js): Added a standards-compliant Service Worker pre-caching the application shell and formulary assets with a stale-while-revalidate strategy.
  • PWA Manifest Fix: Corrected UTF-8 mojibake in manifest.json.

2. Clinical Drug Search & Autocomplete Ranking

  • Intelligent Tiered Ranking: Prioritizes exact brand prefix matches, boosts major trusted national manufacturers (Square, Beximco, Renata, Incepta, ACI, Healthcare, Eskayef, Acme, etc.), and matches generic molecules. Searching "Paracetamol" now surfaces Napa, Ace, Fast, and Renova directly at the top.
  • API & Chemical Filtering: Filters out non-clinical raw industrial commodities ((API), Pellets, Kg, Liter).
  • Veterinary Badge: Adds a distinct 🐾 Vet badge for veterinary drugs in search results.
  • Automatic Dosage Strength Extraction: Extracts dosage strength directly from generic combinations (e.g. "Paracetamol 500 mg" $\rightarrow$ "500 mg") and auto-populates ddose-${id} on selection.

3. Clinical Safety Guardrails

  • Real-Time Patient Allergy Warnings: Cross-checks prescribed drugs and generics against patient allergy records (checkDrugSafety(rowId)), highlighting the drug card in red with a prominent warning banner.
  • Duplicate Molecule Interception: Warns the doctor if the same active generic molecule is already prescribed in another row during the current consultation.

4. UI / UX & A4 Print Engine

  • Global Escape Key Handler: Allows dismissing active autocomplete dropdowns and top-level modals via the Esc key.
  • Single-Page A4 Print Engine (Ctrl+P): Upgraded @media print in styles.css so that pressing browser Ctrl+P cleanly isolates #rx-a4 at 210mm × 296.8mm without printing the dashboard and background.
  • Patient Draft Isolation: Prevents draft notes from silently leaking across different patients when opening + New Prescription.
  • Corrupted Screenshot: Replaced 2-byte corrupted screenshots/Create login.jpg with a valid screenshot asset.

5. Web Accessibility (WCAG 2.1 AA)

  • Associated explicit for="..." attributes on all 30+ form <label> tags matching their respective input ids across the application.

Verification & Testing

  • ✅ Passed JavaScript syntax validation via node -c scripts.js and node -c sw.js.
  • ✅ Verified IndexedDB storage and offline fallback behavior.
  • ✅ Verified autocomplete ranking: Paracetamol immediately returns Napa and Ace in top results.
  • ✅ Verified real-time allergy warning banner on penicillin / sulfa / NSAID test cases.
  • ✅ Verified Escape key closes modals.
  • ✅ Zero external npm dependencies added; completely vanilla ES6+.

This branch has not been deployed

No deployments
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.

[Audit & Fixes] Offline 41k Formulary Persistence, Drug Autocomplete Ranking, Clinical Safety Guardrails & WCAG A11y

1 participant