27 KiB
name, description
| name | description |
|---|---|
| dyolink-lab-cases | Lab Cases tab — list, filters, detail panel, assignment, share QR, card UX. Use when changing CasesPage, cases API, CaseDetailPanel, or case list cards. |
Lab Cases tab
UI: frontend/src/components/ui/lab/CasesPage.tsx
Backend: backend/src/modules/cases/
List order: backend/src/common/lab-case-listed-at.ts (LAB_CASE_LIST_ORDER_BY)
Shared prosthesis rows: LabCaseProsthesisGroupsList.tsx (also used in Treatment lab shipments rail)
List behavior
- Default sort:
listedAtdesc viaLAB_CASE_LIST_ORDER_BY.listedAtisCOALESCE(startedAt, sentAt), kept by triggerlab_cases_listed_at_sync(do not useGENERATED ALWAYS— heap rewrite and AdminJS/Prisma writes 500). Do notorderBystartedAtthensentAt— PostgreSQL DESC is NULLS FIRST, so clinic-sent rows bury started lab-origin cases. Tasks grouped-by-date uses this same key. Unstarted lab-origin drafts live in a Drafts rail section (TreatmentRailSection, collapsed by default; expands on click or Add case). Main list is received + started cases only (GET /cases?drafts=exclude). Drafts:GET /cases?drafts=only. List/detail cards also show From clinic (CLINIC_DISPATCH), Generated (LAB_INTERNAL), or From lab (LAB_OUTSOURCE) viaLabCaseOriginBadge. - Task group headers / list cards: one mill-ticket line via
ProsthesisJobLineLabel—13 · Pontic - 14 · PFZ Crown. The Case Sheet draws that same line as an SVG box (do not mount the React label in the capture). No picker category. Colored Pontic + leaf (prosthesisTypeLabelStyleFromCatalogon screen; Case Sheet usesprosthesisTypePrintColorFromCatalog, the heaviest family swatch). Inherit the parent font size. Indirect keeps subcategory + leaf (Inlay · Layered ceramic). FDI chart paints pontic color on those teeth. - Page size:
PAGE_SIZE = 10inCasesPage.tsx. - Auto-select: On tab open / after filter reload, select first list item if none selected; keep selection when still in list;
?caseId=URL wins. - Add case:
TAB_CASES_EDIT—POST /casesthen replace the right pane withCaseCreatePanel(inline wizard, not a modal). One prosthesis plan per case (sourceKey= case id; noLabCaseLine).ProsthesisAssignChart(same picker/stacking as Treatment). Summary rows:LabCaseToothJobsList→ProsthesisJobLineLabel(same mill-ticket line as Treatment/Cases/Tasks). Underline tabs: Details, Files, Messages. Header: one origin combobox (linked clinic or lab, or a typed name), Dentist/Technician, patient name/mobile, due date (AppDateInput). Start (POST /cases/:id/start) generates one shared scan/model/pack set and, when a linked org is selected, notifies that org once (PARTNER_CASE_CREATED, share-link href). NoLabCaseSend, no clinicCASE_SENT. Start also rejects illegal stacks (PROSTHESIS_STACK_INVALID) and un-bridged or mixed pontics (PONTIC_BRIDGE_INVALID). Edit (POST /cases/:id/stop, buttoncases.stopCase) is only a started lab-origin case: completed tasks and a copy of the prosthesis lines go onLabCaseRound(roundIdset; in-progress tasks are deleted),startedAtclears, commissions and the stamped price stay. History still says “Stopped {date}”. Edit cancels open outsources that have no finished step, and is refused once an outsourced step is done (LAB_CASE_OUTSOURCE_OPEN). The case returns to the drafts rail and can be edited; the next Start first archives any leftover current-round tasks, then generates only the new round (generateLabCaseTasksignores tasks that already haveroundId). Outsource (POST /cases/:id/outsource, labelcases.sendCase) on a started or received case creates oneLAB_OUTSOURCEchild for one linked lab and the checked in-progress prosthesis steps, plus model design and model create. ChildsourceKeyis the child case id. When two selected steps share tooth, prosthesis type, and workflow step,outsourceChildSourceKey/collidingOutsourceSourceKeysusechildId:parentSourceKeyso the current-round unique index(labCaseId, sourceKey, tooth, prosthesisTypeCode, workflowStepCode)accepts both.dedupeToothJobskeys onsourceKey|tooth|type. The child stores the sending lab asreferringClinicNameand clears the dentist and partner clinic, so the receiver never sees the original clinic. The sender’s chart stays the full prosthesis plan; the child’s chart is the selected jobs plus pontics on that bridge, or that line’s teeth for a model step (the whole plan for a historical__case__model step). Scan, packing, and shipping stay on the owning lab. Those parent steps leave Tasks until the child lab completes them, which is mirrored onto the parent with no actor. The sender sees that direct lab’s step status and comments (eye on only); a further lab, and the original clinic, are omitted. Recall (POST /cases/:id/outsource/:childCaseId/recall) only before any of those steps is completed or sent onward. Received child cases have Outsource, not Start, Delete, or Edit. Active lists, progress, and Today counts useroundIdnull. Case detail and the draft editor show past rounds under Previous work (plan, then completed steps only). Delete (DELETE /cases/:id) only for unstarted lab-origin drafts (LAB_INTERNAL&&!startedAt); confirm in the create-panel header next to Start. Received clinic cases and started generated cases cannot be deleted. - Right panel: Draft lab-origin → wizard; started/received →
CaseDetailPanel. - Left rail layout: section is
flex flex-col+lg:min-h-[420px]/h-fullwithlg:items-stretchon the grid; case list wrapper isflex-1 min-h-0 overflow-y-auto(do not use a fixedmax-h-[55vh]— that leaves empty space above pagination).
List where: received clinic cases (sends + sentAt) OR origin = LAB_INTERNAL and destinationOrganizationId = lab. Map clinic/patient from treatment or snapshots / partner org. Search includes snapshot names.
Share QR is issued when a case is sent (sentAt) or a lab-origin case is started (startedAt). Clinic Treatment Lab dispatch shows the same QR after send (see lab-case-share-link skill). Lab comments on Cases use TAB_CASES_* or TAB_TASKS_* — lab owners have Cases by default and must not be blocked by Tasks opt-in.
Filters (GET /cases)
| Param | Behavior |
|---|---|
prosthesisTypeCode |
Cases with ≥1 task of that prosthesis type (tasks.some) — not treatment-type filter |
clinicOrganizationId |
From URL (Today case partners chart) or dropdown |
q, sentFrom, sentTo |
Search + date range |
Filter options: GET /cases/filter-options → clinics, prosthesisTypes (distinct codes from sent-case tasks, catalog-ordered).
List card UI
Match Treatment shipment cards: patient name, clinic, colored mill-ticket lines (LabCaseProsthesisGroupsList → ProsthesisJobLineLabel), sent date, progress bar, due-date badge, unread dot. No patient mobile on list cards. Line order: {pontic} · Pontic - {abutment} · {leaf} (pontic color on the pontic product, crown color on the abutment + leaf), then Connected badge when that group is a bridge. No category name.
List item shape: prosthesisGroups: { prosthesisTypeCode, teeth[], ponticTeeth? }[] from task teeth aggregation. Same-type teeth in one detail are one group (Connected badge only when every tooth is a real bridge). An extra type on some of those teeth is its own group. A crown+pontic span is that same group with ponticTeeth naming the pontic FDIs. Partial denture is one group whose teeth is every selected unit.
Detail panel
- Task assignment:
PATCH /cases/:caseId/tasks/:taskId/assign(TAB_CASES_EDIT). Current-round tasks only; a parent step currently delegated to another lab is tracked on the Case but cannot be assigned until the handoff resolves. - Reopen:
PATCH /cases/:id/tasks/:taskId/reopen(TAB_CASES_EDIT) sets a completed current-round task back toIN_PROGRESSand revokes that step’s commission. In-progress steps on the case stay a badge (Cases cannot complete a step).PATCH /tasks/:idrejects uncomplete withTASK_REOPEN_REQUIRES_CASE_EDIT. History tasks (roundIdset) cannot be reopened or assigned. - Comments: shared
LabCaseCommentsPanel+tasksApicomment routes (viewerSide="LAB"). Newest-first; sent/received use logical start/end alignment (RTL-safe). Compacth-9composer with primary send + visibility controls. Lab-origin cases (LAB_INTERNAL, including after Start) are visible to lab comments/mark-read — do not requiresentAt/LabCaseSend. Generated cases hide the eye until a linked clinic is selected; that eye publishes the comment to the clinic. A linked lab reads the thread on the share page and does not use the eye. Received cases use it for the clinic. Lab-to-lab cases use the same eye button for the sending lab: off keeps the comment on this lab, on shows it in that lab's handoff and notifies them. Comments that already existed on a lab-to-lab case stay shared. - Mark read:
POST /notifications/mark-case-readon select (Cases tab badge) - FDI chart (
CaseToothChartPanel): prosthesis colors + connected bridge dots from each savedselectionGroupId(buildCaseLinkedEdgesincaseDetailUtils.ts). A dot is only an arch-neighbor pair inside that one id — the same edges as the treatment chart (linkedEdgesFromGroups). Touching bridges stay separate. The case-sheet PDF uses that same edge set. - Important + external code (
TAB_CASES_EDIT): Mark as important is centered in the header onlg. Belowlgthe header is one compact stack: name and the desktop QR thumb (w-24 sm:w-32) on the first row, mobile / from / date on one wrapping line, the progress bar (no separate “tasks completed” sentence), important and billed on one row, and Edit / Outsource / Get PDF sharing one row (CaseLifecycleButtonresponsiveFill). External code is under the progress bar in the start column, same width as the bar (no title; placeholder only); billed price is under important onlg. Save code on blur →PATCH /cases/:id/external-code. Edit, Outsource, Get PDF, and Add files useCaseLifecycleButton(primary, no icon; Treatment Lab dispatch / Chart / Add detail width fromlgup). Add case is full width at New treatment size (px-6 py-3 text-base) and, when voice is available, splits like Add detail: label starts a blank draft, the mic records against the open draft (or creates one first). Apply still fills that case’s single plan. There is no second mic on the Details tab. There is no Comments button. Opening Messages does not scroll the page. Start and Delete on a draft use the lifecycle width. The sent-date line iscases.sentAt(“Outsource {date}”). File cards (CaseFilesPanel): name at the start and checkbox at the end, a clipped preview between them and the footer, then size over date at the start with the View/Download menu centered at the end. Each file being uploaded is its own card with a progress bar (one request per file). The job lives above the page, so leaving Files or Cases does not cancel it; coming back shows the same card. Finishing patches the open case from the upload response. It does not fetch the case again. A draft flushes once before the batch, then keeps the new file id locally so a later autosave does not unlink it. Remove one file from that menu after confirm (DELETE /cases/:id/attachments/:attachmentId): a clinic file still on a treatment is unlinked only; a lab upload withdetailIdnull and no other case link is deleted from the database and disk. Tasks stays view-only. - FDI chart (
CaseToothChartPanel): prosthesis colors + connected bridge dots fromselectionGroupId(buildCaseConnectedTeeth/buildCaseProsthesisRowsincaseDetailUtils.ts). - Important + external code (
TAB_CASES_EDIT): Mark as important and the billed price sit under the external code field. The header layout follows the detail panel width (Tailwind container query@container, not the viewport). From@2xl(42rem) it is two columns (info start, actions end). Narrower, including the split list/detail view on a small laptop and phones, it is one stack with the buttons under the info: name and the desktop QR thumb (w-24 sm:w-32) on the first row, mobile / from / date on one wrapping line, then the progress bar (no separate “tasks completed” sentence), external code, important, and billed, stacked. The action buttons (Edit, Outsource, Send to Exocad, Get PDF) are one equal-width grid (CaseLifecycleButtonresponsiveFill, truncating caption): 2 columns when the panel is narrow, one equal column per button from@xl, 2 columns again in the@2xlend column (@2xl:w-72), with the QR below. A lone last button spans both columns. Send to Exocad shows at every screen size, but only when the browser can overwrite the picked file (Chrome and Edge). External code is the same width as the progress bar (no title; placeholder only). Save code on blur →PATCH /cases/:id/external-code. Add files uses that button at the treatment action width. Add case is full width at New treatment size (px-6 py-3 text-base) and, when voice is available, splits like Add detail: label starts a blank draft, the mic records against the open draft (or creates one first). Apply still fills that case’s single plan. There is no second mic on the Details tab. There is no Comments button. Opening Messages does not scroll the page. Start and Delete on a draft use the lifecycle width. The sent-date line iscases.sentAt(“Outsource {date}”). File cards (CaseFilesPanel): name at the start and checkbox at the end, a clipped preview between them and the footer, then size over date at the start with the View/Download menu centered at the end. Each file being uploaded is its own card with a progress bar (one request per file). The job lives above the page, so leaving Files or Cases does not cancel it; coming back shows the same card. Finishing patches the open case from the upload response. It does not fetch the case again. A draft flushes once before the batch, then keeps the new file id locally so a later autosave does not unlink it. Remove one file from that menu after confirm (DELETE /cases/:id/attachments/:attachmentId): a clinic file still on a treatment is unlinked only; a lab upload withdetailIdnull and no other case link is deleted from the database and disk. Tasks stays view-only. - Section badges: Files counts
ATTACHMENT_ADDEDand Messages countsLAB_COMMENT/CLINIC_COMMENT, afterLabCaseSectionReadState, excluding the actor.GET /cases/:id/section-counts.POST /cases/:id/sections/:section/readonly when that tab is open and its count is greater than 0. Opening Details does not clear them. Uploads emitcase-section.changedto other lab members who can read Cases or Tasks (no inbox card). The existing socket turns that intotab-badges-changed.ATTACHMENT_ADDEDis not a sidebar Cases/Tasks/Treatment count.LabCaseSectionReadStatehas a composite id and stays off the AdminJS allowlist. - Attachment uploads: no size limit in multer, axios, or nginx
/api(client_max_body_size 0,client_body_timeout 3600s,send_timeout 3600s,proxy_request_buffering off, proxy read/send 3600s). The server-levelsend_timeout 10would cut a paused download, so/apioverrides it. JSON and urlencoded bodies stay on the Express limits; only multipart is unlimited. Files stream to disk viaorgDiskStorageunderuploads/lab-cases/{orgId}(treatment uploads useuploads/treatments). The attachment row and the case link are one transaction; the disk file is removed only after that transaction commits on delete, and only for a lab-owned upload. A failed activity row does not fail the upload. Do not buffer the file in memory and do not setContent-Type: multipart/form-datayourself — that drops the boundary. Releasing this needsprisma migrate deploy(the backend container runs it on start; Postgres 15) and a nginx recreate fromnginx.ssl.conf.template. Staging’s Windows host nginx is a separate paste-and-reload ofwindows-edge-http.conf; Docker alone leaves the 50MB edge. Uploaded bytes live on the backend container disk (/app/uploads, no volume) and can fill that disk. - Case Sheet PDF — see below.
- Share link (sent cases):
shareUrlon detail; attachment preview left + QR thumb right;LabCaseShareQrDialog(react-qr-code). Full flow:.cursor/skills/lab-case-share-link/SKILL.md.
Send to Exocad
Writes the open case into a DentalDB SQLite file on this computer. Nothing is uploaded to the Dyolink server. Close Exocad before writing, then open it again.
- Button
cases.sendToExocadon the case header at every screen size, every origin, for anyone who can open the case, only when the browser can overwrite the picked file (showOpenFilePicker: Chrome and Edge). It is separate from Outsource. Safari and other browsers do not show it. There is no local helper program and no download fallback. LocalDbSessionProviderholds the open file. The browser overwrites the picked file and remembers that file handle (IndexedDB) only after the file passes the DentalDB check. The next send reopens the saved file when it still exists and skips Browse. A missing file shows Browse again. A file that is not a usable DentalDB database is not remembered, and the connect dialog stays open so Browse can be used again.- The connect dialog warns that Send to Exocad is experimental, that the user must make a manual backup of the DentalDB file first, that Nudentic is not responsible for any issues, and that the user uses the feature on their own.
- Mapper:
frontend/src/components/local-db/exocadTransfer.ts. Lab id0. The client is the case clinic name (the sheet sender). Reuse an existing client only when exactly one client name contains every token. A new client is created only when that name has a first and last name; a single token that is not unique is not written, and the toast says Client could not be filled. Never use practice id2147483647. Match a patient of that client by the same tokens, ignoring order. DentalDB stores the family name infnameand the given name inlname. A new patient is created only when both parts exist. Otherwise nothing is written and the toast says Name could not be filled.t_Notesis the case comment bodies, or the detail comment when the thread is empty.Treatment.importedOrderIdis the Dyolink case id, so a second send updates that treatment and replaces itsToothWorkrows. One case is one transaction: a failed insert rolls the case back and the database is unchanged. WhenworkParamsSHAis empty, copy that hash onto a newWorkParamsInfoandWorkParamsInfoLocalfrom the newest saved case whose file name ends withWorkParamsDB.xml(notWorkParamsDB-EndoCrown.xml), then setworkParamsSHAandworkParamInfoId. Do not set treatmentflagsto 16. The CAD-Data project folder is still created by Exocad's own Save. - A tooth is written only when the catalog name has an obvious Exocad material and that exact
WorkTypeSN+MaterialSNalready exists on a saved tooth. Copy numeric and textual parameters and their dependents from the fullest saved tooth of that same pair. For a Coping, that donor is the fullest tooth whoseImplantTypealready matches. Do not copy shade. Do not copy a donor with no parameters, and do not copy one material's numbers onto another. Obvious pairs: Monolithic Zirconia and PFZ Crown =Coping/ZI; PFM =Coping/NP; Full Metal =AnatomicCrown/NP; PMMA =AnatomicCrown/PMMA; Glass Ceramic Crown =AnatomicCrown/GCER; pontic =ReducedPonticplus the connected crown material when that pontic pair exists; IPS Overlay =OverlayCrown/LS2. Pressed Ceramic / IPS e.max (AnatomicCrown/LS2), PEEK (AnatomicCrown/PEEK), Veneer Zirconia (Veneer/ZI), IPS veneers (Veneer/LS2), and Zirconia Overlay (AnatomicInlay/ZI) are the same rule: written only when the opened file already has that pair. Each written tooth also gets its FDI opposite asAntagonist/Healthywhen that pair exists and the opposite is not itself a restoration. When the file already stores them, the case scan mode isAntagonistTypeRegisteredJawsand the tooth shade is---. A file with exactly one technician assigns that technician. More than one technician is left unset. Temporary resin, veneer/inlay/onlay/overlay full-contour or layered with no material in the name, cast post, fiber post, and an abutment with no crown get no tooth row. The case header is still created.customized_abutment(Custom Abutment (Titanium)) on a Coping copiesImplantTypeCustomAbutmentfrom a saved tooth of that same pair when the file already has it. If it does not, that value is not invented and the crown is copied from aNonecoping when one exists. A plain Coping copiesImplantTypeNonewhen a saved coping has it, and does not takeCustomAbutmentfrom another tooth. Other abutment codes are not mapped. An abutment on a tooth that was written is not listed again. The skipped toast still lists teeth that were not written. - When the file is written and
externalCodeis empty, save the Exocadtreatment_idthroughPATCH /cases/:id/external-code(TAB_CASES_EDIT). - There is no Local database tab. Send to Exocad keeps
LocalDbSessionProvider,LocalDbConnectDialog, and the file open/write path.
Case Sheet PDF
Entry: Get PDF on CaseDetailPanel (primary, same width as Outsource, no icon) — menu chooses portrait or landscape. Organization name uses a 56px line box so the 28px glyphs are not clipped. The print root has top padding (16px portrait, 24px landscape) so the header QR is not clipped at the page edge. html2canvas uses scrollY: 0 (the host is position: fixed). The page stays LTR in every locale. On the Persian sheet that name is a shrink-wrapped inline-block (data-case-sheet-org-text, direction: ltr unless the name itself contains Arabic script, letter-spacing and word-spacing 0px) so html2canvas does not stretch the words across the header column. Party and meta values use printRtlValueStyle: Arabic script stays RTL; Latin stays LTR, isolated, and right-aligned under the Persian label. Section rules use a 12px gap and 8px padding so the line clears the values; FA_RULE_DROP (6px) is the only extra margin, for Persian descenders.
Builder: caseSheetPdf.ts → off-screen CaseSheetPrintLayout.tsx wrapped in NextIntlClientProvider → html2canvas → jspdf A4 (ISO √2 — prints cleanly onto A3–A6).
html2canvas + Tailwind v4 (required)
Stock html2canvas cannot parse lab() / oklch() from app CSS. Do not mount live FdiToothChart / Tailwind color classes into the capture tree.
| Do | Don't |
|---|---|
| Hex/rgb inline styles only in print layout | Tailwind color utilities / CSS variables in capture |
CaseSheetFdiChart (SVG, catalog hex colors) |
Reuse interactive FdiToothChart for PDF |
onclone: strip style + link[rel=stylesheet]; size the lockup SVGs and the org-name line box. Do not overwrite [data-case-sheet-org-text] direction |
Resize every SVG (blanks the QR and squashes prosthesis/number rows) |
Prosthesis type names from prosthesisJobPathParts (subcategory · leaf, never the picker category) |
Fallback code.replace(/_/g,' ') alone (breaks casing like ti base…) |
Layout conventions
- Portrait and landscape use this same tree; only the page pixel size changes. One A4 page, scaled to fit — never slice the canvas.
- Header is a flex row: title at the start, Nudentic lockup centered, share QR at the end (same row when there is no QR). The QR is
LabCaseShareQrCodefill={false}inside the padded frame. Do not put that SVG in a table cell — html2canvas then paints an empty box. Print-root top padding (16px portrait, 24px landscape) keeps the QR off the page edge. - Sections: meta → parties → Tooth Chart heading above the horizontal rule → chart → Prosthesis rows (SVG rect + text, so the border stays on the label; the chart stays above a long job list) → Comments.
- Prosthesis print ink and selected teeth use the heaviest family swatch (
prosthesisTypePrintColorFromCatalog), notprosthesisTypeLabelColorFromCatalog. Persian print labels and values useletter-spacingandword-spacing0px(notnormal). Positive letter-spacing makes html2canvas draw each letter alone, so the script stops joining. A full-widthdirection: rtlbox also inserts gaps between Latin words — keep RTL only on text that itself contains Arabic script. Prosthesis SVG text is anchored on the inline start for the locale (fastarts at the right padding withdirection: rtl). - Chart is
CaseSheetFdiChart: realistic FDI paths, hex fills, always-on Upper/Lower arch captions. An arch-level job (UA/LA) boxes that arch with a light tint and a border in the same swatch. Unselected teeth are outline only; a root prosthesis colors the root and a crown prosthesis colors the crown. Width is 85% of the page; glyph height stays capped; both arches share the upper column widths. The upper caption has a larger gap above the teeth. Tooth-to-number and number-to-midline gaps match on both arches. A bridge is the chart’s read-only mark: a 10px#009caedot on the column boundary in that tooth-to-number gap, plus a primary line across a middle tooth. - Connected badge: bold + underline inside the prosthesis SVG, with a gap (
dx) before the word so it does not sit on the job text. - Order number:
externalCode.trim()when set, else short case id (idwithout hyphens, first 8, uppercased). Download name iscase-sheet-{orderNumber}.pdf(caseSheetPdfFileName); filesystem-unsafe characters in the code are replaced with-. - Share QR when
shareUrlpresent.
API
LabCase.externalCode(optional string, max 64)PATCH /cases/:id/external-code{ externalCode: string | null }— same edit permission as important flag
Live soft refresh
Inbox Socket.IO notification.created → notifyTabBadgesChanged() → silent loadCases + selected loadDetail (keeps filters/selection; no full remount). Same event refreshes sidebar Cases badge via useTabBadgeCounts. See .cursor/skills/notifications-inbox/SKILL.md.
Permissions
TAB_CASES_READ / TAB_CASES_EDIT; owner always has Cases access. LabOrgGuard on routes.