feat/cases/add-voice-input-for-lab-case-line #82

Merged
admin merged 10 commits from feat/cases/add-voice-input-for-lab-case-line into master 2026-09-22 14:12:25 +03:30

10 Commits

Author SHA1 Message Date
af10e7f1a0 fix(docs): correct link path for voice treatment entry spec 2026-09-21 13:01:49 +08:00
39bfec1d3f docs(voice): one flat spec file, no progress note
Amin's call: specs live at docs/specs/<slug>.md, and the repo does not carry a
progress ledger. The ledger was an /orchestrate requirement, not something the
codebase needs to keep.

The link to voice-treatment-entry is repointed — that spec still sits in its own
folder on master.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-21 13:01:49 +08:00
c3d6581d2a fix(cases): tell an edit denial from an access denial
assertCanEditCases checks TAB_CASES_EDIT but threw PERMISSION_ACCESS_CASES —
"you do not have access to cases" — at a member who holds TAB_CASES_READ and can
open and read every case. It sent them to the wrong setting. Nine call sites:
start, delete, assign, external code, important flag and the rest.

assertCanReadCases (:1378) keeps PERMISSION_ACCESS_CASES, which is accurate
there, and so do both lab-case-activity.service.ts sites — those check READ.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-21 13:01:49 +08:00
5565dba604 feat(errors): add PERMISSION_EDIT_CASES and use it for the lab voice denial
Cases was the one feature with no edit-specific error code, so cases.service.ts
throws PERMISSION_ACCESS_CASES for a failed read check (:1375) and for a failed
edit check (:1391) alike. The lab voice branch checks TAB_CASES_EDIT, so reusing
it told a member holding TAB_CASES_READ "you do not have access to cases" — false,
and it points them at the wrong setting.

All three layers: the code in error-codes.ts, the throw in assertCanDictate, and
errors.PERMISSION_EDIT_CASES in en, fa and nl.

The two voice.service.spec cases asserting the old code failed on the change and
were updated — they are the guard that caught it.

cases.service.ts:1391 has the same mismatch and is left alone; it is an existing
endpoint's message, not this task's.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-21 13:01:49 +08:00
b2f2825beb fix(voice): say so when a dictation lands nothing on the line
buildLabLineFromVoice returns null whenever no prosthesis job survives — bare
teeth with no material, an out-of-catalog code, every code refused by the stack
rules. applyVoice then closed the sheet and returned in silence.

Dictate "دندون ۱۲ و ۱۴" with no material: lab mode forces labDependent, so the
merged row is available and ticked and the button reads Apply (1). Tapping it
changed nothing and said nothing.

It now raises voiceNothingExtracted through the panel's existing toast, unless a
due date landed — a due-date-only dictation did do something and must stay quiet.

Found by /code-review.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-21 13:00:45 +08:00
beba7bb4d4 docs(voice): record the blank-line fix and the decision to leave lint red
Amin's call: the repo-wide lint gate stays red. Both commands fail identically
on origin/master and no error is in a file this branch touched. The repair means
restructuring auth, realtime and toast effects with no component tests to catch
a regression, so it is its own attended task.

Notes the consequence: the Stop guard blocks on this ledger and every future
/orchestrate here inherits the same red.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-21 13:00:45 +08:00
0584b79472 fix(voice): never append a blank line from a dictation that built none
Found by the /orchestrate correctness critic, verified by hand.

applyVoice checked isBlankLine on the TARGET line but never on the line it had
just built. A dictation carrying no line content — a due date on its own, or one
whose codes were all refused — returned a blank newLine(), fell past the
blank-target branch and appended it. The panel then made it active and autosaved
it, and start only requires that SOME line carries jobs (cases.service.ts:549),
so the empty line shipped to the lab floor. That is what decision 9 exists to
prevent; the decision only covered filling a blank target, not appending one.

The spec's own manual step 7 triggers it: dictate «تا پنجشنبه» with line 1
already filled.

buildLabLineFromVoice now returns line: null for a blank line, so the rule sits
in the pure function a test can reach rather than in a component nothing renders.
The due date still lands — it belongs to the case header, not the line.

Six tests that asserted an empty line now assert null, and one new test covers a
due date riding along with real work. Reverting the guard fails five of them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-21 13:00:45 +08:00
d557d92669 feat(voice): extend voice extraction to lab case line entry
Adds a lab-mode narrowing of the catalog for voice extraction,
lab case line draft/apply helpers, and a shared review sheet reused
by both treatment and lab case flows.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-21 13:00:45 +08:00
54044e44e6 docs(voice): add the lab-case-entry progress ledger
Every /orchestrate stop path writes here, and preflight aborts without it.
Records the two preflight blockers: no merge request template, and the repo
being on Gitea while /orchestrate ends in GitLab-shaped merge requests.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-21 13:00:01 +08:00
6bfa5ade78 docs(voice): spec voice entry for a lab case line
One dictation fills one case line — teeth, prosthesis stack, comment — plus the
case due date. The header's identity fields stay typed, which is what keeps every
extracted field free of a patient name and leaves the transcript decision in
voice-treatment-entry §10 closed.

Lab mode is an empty treatmentTypes and labs catalog, not a second prompt. The
prompt already renders both as empty, so the model cannot emit a field it has no
list for and no prompt text changes.

Four findings from reading the code shaped it:

- voice.controller.ts:22 puts ClinicOrgGuard on the whole controller, so a LAB
  org gets 403 on both voice routes today.
- listLinkedLabs (voice.service.ts:272) does not filter by org type. For a LAB
  org it returns the linked CLINICS, and the prompt labels them "LABS THIS CLINIC
  CAN SEND TO". Emptying the list is what stops a referring clinic coming back as
  labId.
- The lab write validates only the prosthesis code (cases.service.ts:481) because
  the line and its jobs arrive in one transaction. Nothing rejects a teeth/jobs
  mismatch, so the apply keeps decision 40 itself.
- TAB_TREATMENT_EDIT is clinic-only (organization-type.ts:14), so reusing it for
  the lab side would 403 every lab member including the owner. TAB_CASES_EDIT is
  the one that already gates Add Case.

Mode is derived from the org type, never sent by the client. The save model needs
no refs: CaseCreatePanel autosaves one PUT carrying header, lines and jobs
together, so the ref coupling behind three of the five clinic defects cannot
occur here.

14 decisions and a verification list in §10. No code yet.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-21 13:00:01 +08:00