Commit Graph

48 Commits

Author SHA1 Message Date
9ec23d0a58 fix: stop voice entry posting an unsaved detail id, and name failures right
Review findings on this branch.

The lab-case save could be posted against a detail the server has never
seen. persistDraft returns a *preview* treatment instead of saving when any
detail lacks a treatment type — the blank one the workspace opens with is
enough — and a preview's detail id falls back to the client id. Recording
straight after opening a visit and confirming a result with a lab or due
date would send that id and fail the whole save. It now checks what came
back rather than the precondition, so it holds for every early return
persistDraft has.

stop() optional-chained into a no-op when the recorder was already gone,
leaving the bar recording forever with a live timer and only Cancel as a
way out.

Three "this browser cannot record" paths reported VOICE_MIC_DENIED — no
MediaRecorder at all, no container the API accepts, and a recorder that
throws after permission was already granted. Telling clinicians their
microphone was denied sends them hunting for a permission nothing asked
for; they now report VOICE_UNSUPPORTED_FORMAT.

The voice route's large-body match stripped every trailing slash while
Express ignores exactly one, so '/api/voice/extract//' bought a 10 MB
buffer for a request that then 404s.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 17:44:51 +08:00
5d8393c1eb fix(frontend): stop the remembered prosthesis default rewriting the map
Dictating "12 روکش PFM, 13 روکش PFZ" previewed correctly and then landed in
the form as PFM on both teeth.

The stored data was never wrong — the dev database holds 12 → pfm_crown and
13 → pfz_crown with selectionGroupIds matching the detail's groups exactly,
and a page reload renders it correctly. The damage was live client state:
the dispatch panel's "last type used for this lab" default rebuilt the
*entire* map from one code, so a single row reading as unfilled destroyed
every type already set.

Two changes:

- It fills blanks now, and leaves every entry that already carries a type
  alone. The bulk "apply to all" select only pre-sets itself when the fill
  really did cover every tooth, instead of claiming one type while the rows
  below disagree.
- A lab case created by confirming a voice result is exempt from the
  default entirely. The review sheet is a contract: topping the case up
  with a type for a tooth the preview never showed makes the confirmation
  step a lie about what it was going to fill.

The exemption is tracked in workspace state rather than on LabCaseDraft
because a draft field is dropped by mapLabCaseDraftFromApi on the first
server round-trip — exactly the window this failure lives in.

isProsthesisMapComplete is deliberately untouched: its strict
selectionGroupId match succeeds on the real data, so loosening it would
have been a blind change to a working path.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 17:16:46 +08:00
d226a2b294 fix(frontend): persist the lab case a voice result creates
applyVoiceResult put the lab draft in state and stopped there. Every other
path that creates a LabCaseDraft — handleContinueToLab, handleLabCasesChange
— immediately runs persistDraft + persistLabCases, and the autosave effect
only watches `details`. So applying a voice result carrying a lab, a due
date and a prosthesis map, then reloading, kept the detail and silently
dropped all three: the surviving detail made it look like the save worked.

applyVoiceResult moves below persistDraft/persistLabCases so it can call
them, and writes detailsRef itself before persisting — persistDraft reads
that ref, and setDetails has not rendered by the time the save runs. The
ref is already written imperatively elsewhere for the same reason.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 05:04:15 +08:00
54e4fa8628 feat(frontend): let the clinician pick the tooth from the candidates
An under-specified tooth was a dead end: the sheet said what was missing
and the clinician had to leave and hunt for it on the chart. The readings
are enumerable, so the review sheet now renders them as chips — the one
interactive part of an otherwise read-only confirmation step.

A pick is folded into the result by withChosenTeeth() rather than tracked
alongside it, so the rows, the mini chart, the prosthesis warning and
applyVoiceResult all keep reading a single VoiceExtractionResult and none
of them has to know the chips exist. It unions rather than toggles: a
candidate can coincidentally be a tooth the recording already produced, and
tapping it must not deselect that one.

Two things that would otherwise make the chips look functional while
applying nothing: the teeth row is ticked on the first pick (it starts
unticked when the recording produced no teeth of its own), and the apply
count is now intersected with row availability so it cannot promise to
apply a row with nothing in it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 04:54:31 +08:00
56d413944a feat: wire voice entry into the treatment workspace
Makes the feature reachable end to end: availability is fetched alongside the
catalogs, the capture hook drives the segmented control, and confirming the
review sheet appends a new detail.

Confirm always appends — it never edits an existing detail and never calls
onAddDetail. Ticked rows land on top of the seeded defaults, so unticking the
type row leaves the appointment-purpose default rather than a blank. Lab-side
rows ride on a lab case draft keyed by the detail's *client* id, so a brand-new
unsaved detail can carry a lab, due date and per-tooth prosthesis map.

Availability comes from the API rather than a NEXT_PUBLIC_* var, since those are
baked in at build time; a failure fetching it degrades to no microphone rather
than taking the treatment tab down.

From review of this commit:

- Unticking "teeth" while leaving "prosthesis" ticked attached prosthesis rows
  for teeth the detail does not contain. Nothing downstream filters them —
  assertCompleteToothProsthesisMap only checks detail-teeth ⊆ map, never the
  reverse — so they would have reached task generation as lab work for teeth
  nobody is treating. The map is now filtered to the detail's own teeth.
- The microphone was gated on the URL locale while the server resolved
  everything from req.user.language. Those diverge (a bookmarked /fa/ URL, a
  language toggle whose save failed), which would transcribe Persian with an
  English hint and anchor "next Thursday" to a Monday week instead of a Saturday
  one — or 403 from a visibly-enabled button. The client now sends the locale the
  microphone was offered in, so the gate and the request agree by construction.

Also fixed from the previous review: a civil YYYY-MM-DD date rendered a day
early west of Greenwich (parsed as UTC midnight); the missing-teeth list
hardcoded the Arabic comma for all locales; and voiceApply had no ICU plural, so
the common single-field case read "Apply 1 fields".

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 20:22:42 +03:30
d2f07c0ed3 improvement: treatments UI/UX updated again to minimize clicking and scrolling. 2026-08-19 23:59:37 +03:30
96f698be98 improvement: UI/UX improved for v1 standalone treatments/cases feature. 2026-08-19 16:07:32 +03:30
8bfa8c88fe improvement: v1 standalone treatment/case creation made possible. 2026-08-19 15:05:58 +03:30
6d90787c13 improvement: FDI tooth chart overhauled. 2026-08-19 00:06:21 +03:30
9f6ec193d2 feature: version one notification feature implemented. 2026-07-18 01:09:54 +03:30
0740493384 improvement: fdi tooth chart selection modes polished. bugs related to teeth selecyion fixed. 2026-07-18 00:02:40 +03:30
4b2349228a improvement: treatment preview wizard optimized. comments component updated and unified accross the app. 2026-07-17 12:30:43 +03:30
58676f702e improvement: FDI chart tool selection modes updated. shift+ and crtl+ both are assigned with a selection mode. 2026-07-17 11:36:02 +03:30
d2ad1fd7b6 improvement: loading state added to buttons who interact with backend. 2026-07-17 10:58:04 +03:30
68fc9d5d6d improvement: treatment plan turned into a wizard. shift+click control added to FDI tooth chart for cunnected prosthesises. 2026-07-17 00:39:32 +03:30
cf07b4d8a8 improvement: delete action added for unsent treatment details. some edit controls added to details and shipments. 2026-07-16 22:45:37 +03:30
b7682a2d1c fix(treatment): show only past plans in history rail and refresh after lab send.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-14 15:09:10 +03:30
ec2b23f4b1 improvement: rtl direction, solar calendar and persian formatting added for persian users. 2026-07-14 01:27:11 +03:30
27eae25f61 improvement: lab/clinic commiunication flow completely overhauled. no more shit. 2026-07-13 22:53:23 +03:30
2ad572f4c8 improvement: notify counter badge added to treatment and tasks tabs for upadted and edited cases. 2026-07-13 17:44:44 +03:30
08a1f34c4f improvement: duedate added for shipped cases. cases and tasks ui and ux updated accordingly. 2026-07-13 16:30:36 +03:30
f28cd06615 improvement: treatment UX fully overhauled. 2026-07-13 01:03:26 +03:30
53b43f2cdb improvement: updated toasts. no invisible toast anymore. 2026-07-12 21:30:28 +03:30
0d3fb0a51d improvement: some files replaced, lots of them i shall say. AGENT.MD file created. some rules and skills added for cursor agent. 2026-07-12 21:08:29 +03:30
fab5111aa8 improvement: error handeling structure changed and unified all across the app. user no longer sees inappropriate messages. 2026-07-12 18:27:38 +03:30
732565b7b4 Merge branch 'master' into feature/mobile-responsive 2026-07-12 10:02:58 +03:30
2f7df312c1 app now responsive for mobile and small devices. 2026-07-11 17:10:02 +03:30
ed8ff61205 Shitty gadgets removed. Some useful gadgets added. 2026-07-11 03:12:56 +03:30
be4ac3426e Merge branch 'master' into feature/cases 2026-07-10 15:26:36 +03:30
8d334833ff improvement: all demo bugs fixed. give me more baby. 2026-07-08 02:53:47 +03:30
86b1e3afff improvement: attachment selection for lab dispatch added. attachment preview added to cases feature. 2026-07-07 18:43:10 +03:30
b2d40b3e97 improvement: users can now comment on a case and it's details and have an option to make it visible for clinics too. 2026-07-07 17:14:31 +03:30
cb63ced4e3 improvement: tasks and cases feature updated based on the new prosthesis types and their steps. the whole assignment proccess removed from the flow. 2026-07-07 15:31:09 +03:30
ed7e7b1d8f improvement: all clinic side ui components related to treatment types updated based on the new real world data. 2026-07-07 13:13:04 +03:30
667b08ed0c TreatmentType and ProsthesisType database shcema and data updated. Lab dispatch wired through new data. 2026-07-06 20:40:19 +03:30
feb0b26ad0 improvement: treatment preview and treatment history components overhauled. draft & completed status for treatment plan completely removed from the flow. 2026-06-28 21:45:33 +03:30
7b8ed48fa0 improvement: treatment plan now save on debounce. save treatment button removed. 2026-06-28 18:08:29 +03:30
7b19d6953c feature: Phase4 - Clinic two-step treatment UI 2026-06-28 17:14:02 +03:30
8b4ef6195d feature: Phase 2- splitting the treatment schema into TreatmentDetail and LabCase. 2026-06-28 15:34:56 +03:30
b2f4dfa4ca feature: localization's first implmentation done. all frontend hardcoded text is now localized. 2026-06-20 14:51:43 +03:30
633c939560 feature: treatment frontend wired with the newly implemented backend. no mocked data no more. 2026-05-19 23:43:43 +03:30
f743046b38 feature: a minimal v1 backend implemented for treatments feature. 2026-05-19 22:29:29 +03:30
7dba7cc144 bugfix: organization sidebar icon updated like organization switch feature. 2026-05-18 14:08:07 +03:30
3b12c52fd3 bugfix: selecting past dates is now possible in appointment and treatment features. bur, add, edit and delete actions are disabled for past dates. 2026-05-18 12:50:25 +03:30
eb636db653 bugfix: a small refactor done in folder structure and naming conventions. 2026-05-18 12:31:21 +03:30
a0348e4079 improvement: toast component created and used every where in the app. 2026-05-08 14:07:21 +03:30
c2d490a5e7 feature: Preview added for treatments. 2026-05-07 14:20:50 +03:30
58cb35e26d feature: a minor refactor in folder structure done. 2026-05-07 03:46:18 +03:30