Bug #815
openSchedule H1 Register loses the patient's name, even when the sale was linked to a real patient
0%
Description
Where: Pharmacy -> Compliance -> Schedule H1 Register
How bad: High -- this register is legally required for drug inspectors to check controlled-medicine sales. Missing patient names here is a real compliance problem, not just a display glitch.
Where tested: nssh.test.clinq.health, San Jose St. Bonaventure Hospital
What I did:
- Started a new Counter Sale and typed in a phone number that matched an existing patient. The system correctly recognized her -- it showed "Existing patient - MRN SBH-000181" for a patient named Kavitha Nair.
- Added a Schedule H1 medicine (a controlled drug that needs extra tracking) to the sale, generated the bill, took payment, and completed the sale.
- Opened the Schedule H1 Register for that day to check the entry.
What should happen: Since the system clearly recognized and linked the real patient during the sale, her name and age/gender should show up in the register for that entry.
What actually happens: The register -- both on screen and in the printed PDF -- shows a dash ("-") instead of the patient's name and age/gender. On top of that, the bill for this same sale printed a completely different name ("Vikram Nathan", whatever was typed into a text box) instead of the matched patient's real name. So the system matches the patient correctly at the start, but somewhere along the way to the bill and the register, that link gets dropped.
Makes it worse: The register has its own built-in check that's supposed to count "Patient details missing" entries and warn about them. For this exact entry -- which is clearly missing the patient's details -- that counter showed 0. So the one safeguard meant to catch this problem isn't catching it either.
How often it happens: Every time, tried once and it failed.
Real example: Bill BILL-1-00252, Sale CS-20261111-44308C, Counter Sale #67.
What devs should check: Whether the patient's ID actually gets carried through the whole chain (counter sale -> bill -> H1 register), and whether the "missing details" warning is even looking at the right field.
SV Updated by Sravan V S about 18 hours ago
- Assignee changed from Sravan V S to Roshni Harish.
Root cause (investigated on 12 Nov, reproduced locally and on nssh.test).
What happens: a counter sale stores only the name and phone typed on the Counter Sale screen. The phone lookup matches the registered patient (for example Kavitha Nair, SBH-000181) and fills the name box, but the sale does not save which patient it was. When the sale is completed, the H1 register row is created with no patient, and the register finds names through the patient. So the Patient and Age/gender columns show "-" on screen and in the PDF, and the bill shows only the typed name.
Why the "Patient details missing" card shows 0: it only counts rows where a patient lookup was tried and failed. A counter-sale row never gets a lookup, so it is never counted.
Reproduced on nssh.test with a fresh sale, CS-20261112-4407BC (BILL-1-00267), with the patient picked from the suggestion: the register and its PDF show "-" for the patient while the card says 0. Your sale CS-20261111-44308C shows the same. The NDPS register uses the same code (not tested).
Not caused by the document template work: the rule that gives counter-sale register rows no patient has been in the Pharmacy code since 8 Sep 2026 (counter sale checkout flow), and the old browser print used the same rule before the PDF change on 8 Nov. A row with no patient printed "-" then too.
The fix is in the Pharmacy counter sale and register code, not in a document template. It is not made yet.
Test data my reproduction left on nssh.test: sale CS-20261112-4407BC, bill BILL-1-00267, payment PAY-1-00190, one H1 register entry for Arya 120 (witness name entered: Test Witness). Arya 120 stock is down by 1.
RH Updated by Roshni Harish. about 17 hours ago
- Status changed from New to Feedback
- Assignee changed from Roshni Harish. to Arya M.
AM Updated by Arya M. about 15 hours ago
- Status changed from Feedback to In Progress
In progress: fixed in nuvita-pharmacy dev (commit d3bbf62c, merged bdc1e612). CounterSale now stores the matched PatientId (cleared automatically if the Name field is edited away from the match), RegisterAttribution.ForCounterSale carries it through to the H1/NDPS register instead of hardcoding 0, the register gets the same post-commit EMR enrichment a dispense gets, and the bill now resolves and prints the matched patient's real name instead of whatever was typed. Migration AddPatientIdToCounterSales needs to run on each tenant (--migrate --fqdn ) before this is live. Full backend (4310 tests) and portal (3474 tests) suites green. Next: deploying to nssh.test.clinq.health for verification.
AM Updated by Arya M. about 13 hours ago
- Status changed from In Progress to Resolved
- Resolved By set to Arya M.
Resolved: fix merged to nuvita-pharmacy dev (commit d3bbf62c, merge bdc1e612) and pushed. Backend (4310/4310) and portal (3474/3474) suites green. Not yet verified live on nssh.test.clinq.health - that tenant's deploy/migration will come through Sravan's release cut, not a separate ad-hoc deploy.
AM Updated by Arya M. about 13 hours ago
- Assignee changed from Arya M. to Jessin J