Commit Graph

199 Commits

Author SHA1 Message Date
a1a999a884 fix(backend): correct "next weekday" and harden resolvers against model output
Four defects found by review of the preceding commits.

"next <weekday>" was occurrence-anchored ("this" plus seven) rather than week-
anchored. Said on a Thursday, "Thursday next week" resolved to +14 instead of
+7: next week runs Sat 10-18 to Fri 10-24, so its Thursday is 10-23, not 10-30.
A lab case a week late. "next" now counts from the start of the following
Saturday-start week, which also lets "this" and "next" correctly coincide —
said on a Thursday, "the coming Saturday" and "Saturday next week" are the same
day. "this" stays occurrence-anchored so it can never resolve into the past.

The other three all come from the same root cause: exported functions that are
reachable from untrusted model output must degrade, not throw or drop.

- a non-object `due` (the model emitting a bare string) was treated as "no
  deadline spoken" and silently discarded; only null/undefined mean absent now,
  anything else is flagged so the clinician sees something was heard and lost
- isJalaliLeapYear / jalaliDaysInMonth threw for years outside the conversion
  table, contradicting the module's own "degrade to null" contract; they now
  return false / 0, which also makes isValidJalaliDate's day check naturally
  false
- civilDateInZone passed a client-supplied zone straight to Intl, which raises
  RangeError before any fallback; it now validates and backstops to UTC, so a
  bad zone costs at most a day rather than a 500

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-23 23:05:30 +03:30
70092e932d feat(backend): resolve spoken deadlines to ISO dates
Jalali conversion is arithmetic here, not inference. A model asked to turn
"۲۵ مهر" into ISO answers confidently and is often wrong, and @IsDateString()
accepts the wrong answer — so the model emits a date intent and this decides
what it means.

Deviation from the spec, deliberately: the resolver takes todayIso rather than
an IANA zone. Working in civil dates means nothing here reasons about instants.
The zone is used one level up, where civilDateInZone() derives "today" from the
actor's zone server-side — better than the spec's client-supplied date, which
the client could set arbitrarily.

Conventions pinned by tests:
- "this <weekday>" is the soonest occurrence strictly after today, so "by
  Thursday" said on a Thursday means the next one; a deadline of today is
  almost never what was meant. "next" adds a further week.
- month offsets clamp to the end of shorter months (31 Jan + 1 = 28/29 Feb)
- a resolved date in the past, or more than five years out, is treated as
  unresolved however it was arrived at — an absolute date the model invented
  can land anywhere
- no due date at all is not an error; an unparseable one is, and echoes what
  was heard so the review sheet can show it

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-23 23:05:30 +03:30
1076c13472 feat(backend): voice intent contract and tooth-intent resolver
The extraction model emits intents, never resolved values — no FDI codes, no
ISO dates. This adds the contract it must satisfy and the resolver that turns
spoken tooth references into FDI, so quadrant mirroring is a unit test rather
than a hope.

resolveToothIntent never guesses and never clamps: position 9, a deciduous
tooth, or a malformed shape resolve to null and are reported as unresolved with
the transcript span that produced them, so the review sheet can show the
clinician exactly which words were not understood.

Everything here parses untrusted model output, so nothing may throw:

- a non-array where a list was expected degrades like any other malformed shape
- explicit codes are trimmed, for parity with normalizeTeeth
- '51' reports as not_permanent_tooth (a real primary tooth the chart cannot
  show) while '99' reports as malformed — the clinician should not be told a
  deciduous tooth was heard when nothing tooth-shaped was
- unresolved items only dedupe when they carry a spoken span; without one,
  collapsing them would hide a lost tooth behind a single blank review row

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-23 23:05:30 +03:30
4b4c197c03 feat(backend): extract shared FDI tooth geometry
Voice extraction needs quadrant mapping and adjacency server-side, and
treatment.utils.ts already held a private copy of the tooth set. Lift it into
common/fdi.ts rather than create a second source of truth; treatment.utils now
imports it, behaviour unchanged (existing suites still pass).

toFdi() is the single place the patient-right convention lives: quadrant 1 is
the patient's upper right, so upper+patient_right -> 1x, upper+patient_left ->
2x, lower+patient_left -> 3x, lower+patient_right -> 4x. Getting this backwards
mirrors every quadrant and yields a valid-looking code for the wrong tooth,
which no schema check can catch — so all four quadrants are pinned by tests,
along with out-of-range positions never being clamped and deciduous teeth being
rejected outright (the chart is permanent dentition only).

Adjacency mirrors the frontend's arch-order rule, so the midline pairs 11-21
and 41-31 count as neighbours exactly as the chart treats them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-23 23:05:30 +03:30
80ffa37edd feat(backend): port Jalali calendar arithmetic with tests
Voice extraction resolves spoken Jalali dates into ISO dates server-side, so
the backend needs the conversion the frontend already had. The resolvers live
here rather than in the frontend precisely because this half of the repo has a
test runner.

Ported from frontend/src/lib/i18n/persianCalendar.ts and verified faithful by
differential test: every day from 1900-2100 (73,414 days), zero mismatches on
conversion, leap years and month lengths.

Two deliberate divergences from the original:

- jalaliToIsoDate() returns null instead of throwing. It is fed model-supplied
  values, which may be nonsense, and an invalid date must degrade to
  "unresolved" rather than a 500. The year guard runs before jalaliDaysInMonth
  so the throwing jalCal is unreachable from it.
- toLatinDigits() also handles the Arabic-Indic block (U+0660-U+0669), not just
  Persian (U+06F0-U+06F9). ASR output can carry either, sometimes mixed with
  ASCII in one transcript; the frontend version only parses keystrokes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-23 23:05:30 +03:30
648e8ed1f2 docs: spec for voice-driven treatment detail entry
Design spec for filling a TreatmentDetail by voice, settled across three
grilling sessions (30 decisions, logged in the spec).

Key shape:
- two-stage pipeline: OpenRouter whisper-1 -> gemini-3.7-flash
- the LLM emits *intents*, never FDI codes or ISO dates; pure Jest-tested
  backend resolvers own quadrant mapping and Jalali conversion
- provider registry keyed by locale so fa can diverge from en/nl
- review sheet confirms before anything touches the form
- audio and transcripts are never persisted

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-23 23:05:30 +03:30
b4832cd663 Merge pull request 'bugfix/treatment-bugs' (#66) from bugfix/treatment-bugs into master
All checks were successful
Registry — build, push, deploy / temp-success (push) Successful in 2s
Reviewed-on: http://178.131.50.201:3000/admin/dyolink/pulls/66
Reviewed-by: aminmsvi <amn.mousavi@gmail.com>
2026-08-23 12:44:44 +03:30
8d34def001 improvement: the last flow improved a little. 2026-08-22 20:33:11 +03:30
7f02a84ebf improvement: a flow added to create treatment plan for searched patients with no treatment history. 2026-08-22 20:25:11 +03:30
b1405b22b1 improvement: patient search moved to the top of treatment feature. 2026-08-22 20:11:43 +03:30
50725b7b3f bugfix: no-detail treatment ui made some confusion. it is improved. at least to a degree. 2026-08-22 19:36:37 +03:30
f52ad6b84a bugfix: Treatment detail auto-fill bug fixed. 2026-08-22 18:51:57 +03:30
de46da216f bugfix: FDI tooth chart is now compatible with RTL direction. 2026-08-22 17:49:38 +03:30
94b010ccfc Merge pull request 'improvement/v1-demo-improvements' (#64) from improvement/v1-demo-improvements into master
Some checks failed
Registry — build, push, deploy / temp-success (push) Has been cancelled
Reviewed-on: http://178.131.50.201:3000/admin/dyolink/pulls/64
Reviewed-by: rameen <rameen.naghdi@gmail.com>
2026-08-20 11:26:39 +03:30
d2f07c0ed3 improvement: treatments UI/UX updated again to minimize clicking and scrolling. 2026-08-19 23:59:37 +03:30
29c639f5a1 improvement: logo and name svgs updated and replaced. 2026-08-19 19:39:27 +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
e5c39c6b7e bugfix: site renamed. Name component created. 2026-08-19 02:41:05 +03:30
80167c622c bugfix: appointment hours now use the client timezone on UTC servers.
Logical API errors throw stable codes so users see translated messages instead of a generic bad request.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-19 01:43:50 +03:30
d6958b2e48 bugfix: the flow for trial and accept invitation (org + staff)is now unified. all navigate to dshboard if succesfull. 2026-08-19 00:39:31 +03:30
6d90787c13 improvement: FDI tooth chart overhauled. 2026-08-19 00:06:21 +03:30
0dc21ab700 Merge pull request 'improvement: DockerFiles updated to avoid some deployment issues.' (#63) from improvement/v1-demo-improvements into master
All checks were successful
Registry — build, push, deploy / temp-success (push) Successful in 1s
Reviewed-on: http://178.131.50.201:3000/admin/dyolink/pulls/63
Reviewed-by: rameen <rameen.naghdi@gmail.com>
2026-07-20 21:37:27 +03:30
245a238d1a improvement: DockerFiles updated to avoid some deployment issues. 2026-07-20 21:11:08 +03:30
c3a4083003 Merge pull request 'improvement/v1-demo-improvements.' (#62) from improvement/v1-demo-improvements into master
All checks were successful
Registry — build, push, deploy / temp-success (push) Successful in 1s
Reviewed-on: http://178.131.50.201:3000/admin/dyolink/pulls/62
Reviewed-by: rameen <rameen.naghdi@gmail.com>
2026-07-20 11:54:33 +03:30
db515f9630 improvement: time period dropdown added to appropriate dashboard charts. 2026-07-19 00:37:59 +03:30
538121d653 improvement: pdf generation added to cases feature. 2026-07-18 22:00:44 +03:30
408b2c3329 improvement: task assignment notif added to notifications feature. 2026-07-18 17:23:47 +03:30
9941dca849 improvement: notification feature polished. feature tabs following the same notification socket emmited data to be updated. 2026-07-18 16:57:13 +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
1b63bfff00 improvement: some improvement done for appointment and treatment shared components. 2026-07-17 11:21:08 +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
334b7841ae improvement: treatment exits contoll adde to appoinment remove action. 2026-07-16 22:35:02 +03:30
e8e00e2911 Merge pull request 'improvement/ux-overhaul up' (#61) from improvement/ux-overhaul into master
All checks were successful
Registry — build, push, deploy / temp-success (push) Successful in 1s
Reviewed-on: http://178.131.50.201:3000/admin/dyolink/pulls/61
Reviewed-by: rameen <rameen.naghdi@gmail.com>
2026-07-14 22:46:16 +03:30
08df2f71ea improvement: QRcode and shared link added to cases inorder to make it possible for staff users to share a case info with other staffs or other clinics. 2026-07-14 21:07:05 +03:30
953e609fb8 fix(ui): restore native date panel selects with wider compact layout.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-14 15:09:11 +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
a7ba33fb68 bugfix: clinic owner user access to other (dentist)staff's treatment plans terminated. 2026-07-14 03:39:42 +03:30
8de15ecdb5 improvement: billing and report tabs turned invisible. removed from permissions dialog too. this is temporary. 2026-07-14 03:17:57 +03:30
d383a4abc3 improvement: some new gadgets added to dashboard. some new functionality added to existed gadgets. 2026-07-14 03:06:56 +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
547457d637 improvement: tasks UI responsivness improved for mobile devices. 2026-07-13 16:49:24 +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