Skip to content

Pick the pack a tablet dose comes out of - #132

Merged
suskozaver merged 1 commit into
ArunNGun:betafrom
suskozaver:tablet-pack-never-picked
Sep 17, 2026
Merged

suskozaver merged 1 commit into
ArunNGun:betafrom
suskozaver:tablet-pack-never-picked

Conversation

@suskozaver

Copy link
Copy Markdown
Collaborator

Still could not enter a number of tablets. The form said No pack of this in stock, with the pack in stock, the compound marked as tablets, and the dropdown listing it.

What was wrong

Which container a dose comes out of was written three times in LogDoseSheet.tsx:

  1. the list of containers to choose from
  2. applyProtocol, when a protocol is applied or the compound changes
  3. chooseRoute, when the route is changed by hand

Tablets taught the first one. The other two went on reading route === "intranasal" ? "spray" : "vial", so the list offered the pack and nothing ever selected it. vialId stayed empty, vial was undefined, and every sentence downstream of it reported an empty shelf.

Sprays had survived the same shape only by luck: a nasal dose is picked by route, and all three copies already knew about the route.

The fix

containerForDose(preparation, route) in calc/inventory.ts, tested, asked by all three call sites. The route decides first and the preparation second, which is the order the two facts deserve: a nasal dose comes out of a bottle whatever the library says, while "oral" covers a solution swallowed out of a syringe as well as a tablet and so cannot decide anything on its own.

The words around the picker were the same omission. Nothing is drawn out of a box of tablets and no pack is filled, so the label, the hint and the empty-shelf notice each gained their third case: Taken from, "comes off the chosen pack", and a notice that names a pack rather than a vial.

Written down

document/06-traps.md: a rule with three call sites and no name has no place to add a case to. When a third value joins a two-value decision, grep for the ternary rather than for the function, because there is no function yet, and that is the problem.

Checks

npx tsc --noEmit clean, npx next lint clean, 1688 tests pass (4 new). de, sl and pl written for every new key.

Reported as still unable to enter Tablets, with the form saying no pack
was in stock. The pack was in stock, the compound was marked as
tablets, and the dropdown listed it.

Which container a dose comes out of was written three times in
LogDoseSheet: once for the list to choose from, once when a protocol is
applied, once when the route is changed by hand. Tablets taught the
first and left the other two reading route === "intranasal" ? "spray" :
"vial". So the list offered the pack and nothing ever selected it,
vialId stayed empty, and everything downstream reported an empty shelf.
Sprays had survived the same shape only because a nasal dose is picked
by route, which both copies already knew about.

The rule now has a name, containerForDose(preparation, route), in
calc/inventory.ts with a test, and the three call sites ask it. The
route decides first and the preparation second, which is the order the
two facts deserve: a nasal dose comes out of a bottle whatever the
library says, while oral covers a solution swallowed out of a syringe
as well as a tablet and cannot decide anything on its own.

The words around the picker were the same omission. Nothing is drawn
out of a box of tablets and no pack is filled, so the label, the hint
and the empty-shelf notice each gained their third case.

Written into 06-traps.md: a rule with three call sites and no name has
no place to add a case to.
@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Arun's projects Team on Vercel.

A member of the Team first needs to authorize it.

@suskozaver
suskozaver merged commit 45b820b into ArunNGun:beta Sep 17, 2026
1 of 2 checks passed
@suskozaver
suskozaver deleted the tablet-pack-never-picked branch September 17, 2026 17:55
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.

1 participant