Pick the pack a tablet dose comes out of - #132
Merged
Merged
Conversation
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.
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:applyProtocol, when a protocol is applied or the compound changeschooseRoute, when the route is changed by handTablets 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.vialIdstayed empty,vialwas 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)incalc/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 --noEmitclean,npx next lintclean, 1688 tests pass (4 new). de, sl and pl written for every new key.