Repository navigation
Description
Overview & Clinical Appreciation
Dear Dr. Gazi Md Emran Ahmed (@eabgitbd),
First of all, congratulations and sincere appreciation on building PrescribePro-Rx! As general practitioners and medical software developers practicing in Bangladesh, an open-source, local-first digital prescription pad designed specifically around ISO 216 A4 physical dimensions and the BMDC workflow is a tremendous service to our medical community.
After a deep architectural, clinical safety, and UI/UX audit of the codebase (v3.0 Pro), we identified several key clinical, offline, and accessibility defects that affect real-world practice. We have already developed, tested, and pushed a complete, non-breaking Pull Request fixing every single one of these items.
Here is the comprehensive breakdown of the issues identified and addressed:
1. 🚨 Offline Architecture & 41k Drug Catalog Persistence Failure
- The Issue:
data/drugs.jsonis 5.42 MB (stringified in UTF-8). Standard browserlocalStorageenforces a strict 5 MB origin quota.- In
scripts.js,localStorage.setItem('prescribepro_cached_drugs', ...)throws an unhandledQuotaExceededErroron every session and fails silently. - Crucially, there is no Service Worker registered (
sw.jsdid not exist in the repo). - Clinical Consequence: If a doctor opens the app offline or reloads with no internet connection, the
fetch('data/drugs.json')fails, and the formulary silently collapses from 41,249 medicines down to only 58 fallback items (a 99.86% data drop).
- The Fix:
- Implemented a lightweight native IndexedDB storage engine (
PrescribeProDB / drugs_cache) inscripts.jsthat bypasses the 5 MBlocalStoragequota and instantly loads the 41k catalog in ~0ms offline. - Added a standards-compliant Service Worker (
sw.js) pre-caching the application shell and formulary, turning PrescribePro-Rx into a true, installable PWA. - Fixed UTF-8 character encoding mojibake in
manifest.json.
- Implemented a lightweight native IndexedDB storage engine (
2. 🚨 Clinical Drug Autocomplete & Search Ranking Defects
- The Issue:
- Top Brands Hidden:
drugSearch()performs a linear scan throughgetActiveDrugs()and truncates immediately after finding 30 matches (matches.length < 30). Becausedrugs.jsonis ordered alphabetically by manufacturer (starting withAB Life Science,APC,Ablation,ACI,Acme), typing a generic like"Paracetamol"stops after 30 matches from companies starting with "A".- Napa (Beximco — Appreciation & Feature Suggestions for Clinical Workflow. #1 prescribed Paracetamol in BD) never appears.
- Ace (Square — [Audit & Fixes] Offline 41k Formulary Persistence, Drug Autocomplete Ranking, Clinical Safety Guardrails & WCAG A11y #2 prescribed Paracetamol in BD) never appears.
- Veterinary & Raw API Pollution: The 41k formulary contains 1,061 veterinary drugs (e.g.
Adpara Bolus Vet,Acitamol Vet) and 53 raw industrial APIs/pellets (e.g.Acetone BP (API) 1000 ml,Boric Acid 500 gm,Omeprazole Pellets 8.5%/kg). These appear in clinical autocomplete alongside human medications. - Blank Dose Attribute: 100% of records in
drugs.jsonhave"dose": "", leaving the dose field blank on drug selection unless manually typed.
- Top Brands Hidden:
- The Fix:
- Implemented intelligent tiered search ranking:
- Brand name prefix matches.
- Major trusted pharmaceutical manufacturer boost (Square, Beximco, Renata, Incepta, ACI, Healthcare, Eskayef, Acme, Opsonin, Aristopharma).
- Generic molecule prefix matches.
- Filtered out industrial bulk chemical raw materials (
(API),Pellets,Kg,Liter). - Added a distinct
🐾 Vetbadge for veterinary products. - Added automatic dosage strength extraction from the generic string (e.g.
"Paracetamol 500 mg"automatically populates"500 mg"intoddose-${id}).
- Implemented intelligent tiered search ranking:
3. 🛡️ Clinical Safety & Guardrails (Allergies & Duplicates)
-
The Issue:
-
Passive Allergy Display: Documented patient allergies (e.g. Penicillin) are merely displayed as a static text string at the top of the A4 paper. Prescribing
Amoxil(Amoxicillin) to a penicillin-allergic patient triggers zero warning or alert. -
No Duplicate Molecule Check: Doctors can accidentally prescribe duplicate active ingredients (e.g.
Napa+Ace) concurrently without detection.
-
Passive Allergy Display: Documented patient allergies (e.g. Penicillin) are merely displayed as a static text string at the top of the A4 paper. Prescribing
-
The Fix:
- Implemented real-time Allergy Checking (
checkDrugSafety(rowId)): Cross-references prescribed brand names and generic molecules against patient allergy tokens (including Penicillin$\leftrightarrow$ Amoxicillin/Ampicillin, Sulfa$\leftrightarrow$ Cotrimoxazole, NSAID$\leftrightarrow$ Ibuprofen/Diclofenac/Naproxen) and highlights the card in red with a prominent warning banner. - Implemented Duplicate Molecule Checking: Warns if the same active generic molecule is already prescribed in another row during the consultation.
- Implemented real-time Allergy Checking (
4. 🖥️ UI / UX & Print Engine Improvements
- The Issue:
- No Escape Key Handler: Modals cannot be dismissed with the
Esckey; doctors must manually click the✕button. - Native Print Isolation (
Ctrl+P): PressingCtrl+Pin the browser printed the entire dashboard UI, buttons, and background instead of isolating the clean prescription pad. - Draft Leakage: Opening "+ New Prescription" from the dashboard silently restored any previous patient's draft without checking patient ID.
- Corrupted Screenshot:
screenshots/Create login.jpgwas a corrupted 2-byte file.
- No Escape Key Handler: Modals cannot be dismissed with the
- The Fix:
- Added a global
Escapekey event listener that dismisses autocomplete dropdowns and top-level modals. - Enhanced
@media printinstyles.cssto cleanly isolate#rx-a4at210mm × 296.8mmonCtrl+P. - Isolated unsaved drafts so they only restore when opening the specific patient they were drafted for.
- Replaced the 2-byte corrupted screenshot with a valid image asset.
- Added a global
5. ♿ Web Accessibility Compliance (WCAG 2.1 AA)
- The Issue: Zero out of 42
<label>tags in the application had aforattribute linking to inputids, failing WCAG 2.1 Success Criterion 1.3.1. - The Fix: Associated explicit
for="..."attributes on all 30+ form labels across patient demographics, doctor profile, pad settings, and consultation forms.
Accompanying Pull Request
We have submitted an accompanying Pull Request linking to this issue with all the above fixes cleanly implemented, zero external dependencies, and fully backward-compatible with Version 3.0 Pro.
Activity