improvements: some unnecessary interuptions fixed when exporting a case to exocad.
This commit is contained in:
@@ -14,7 +14,7 @@ alwaysApply: false
|
||||
- **Comments:** a generated case hides 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. A received case uses the eye for the clinic. A lab-to-lab case uses it for the sending lab; the sender's handoff lists only comments with that control on.
|
||||
- **Outsource** (`POST /cases/:id/outsource`, label `cases.sendCase`): one linked lab, checked in-progress prosthesis-job steps plus `model_design` / `model_create`, one `LAB_OUTSOURCE` child case. The child stores the sending lab as `referringClinicName` and clears dentist and partner clinic. Those parent steps leave Tasks until the child completes them (written back with no actor). Sender detail shows only that direct lab. The sender chart stays the full plan; the child 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). Recall before any of those steps is completed. Received child cases have Outsource, not Start, Delete, or Edit. Scan, packing, and shipping stay on the owning lab. Child `sourceKey` is the child case id. When two selected steps share tooth, prosthesis type, and workflow step, `outsourceChildSourceKey` uses `childId:parentSourceKey` so the current-round unique index accepts both. `dedupeToothJobs` includes `sourceKey`.
|
||||
- **Share link:** QR + URL when the case is sent **or** a lab-origin case is started; token API + focus page — see `.cursor/skills/lab-case-share-link/SKILL.md`.
|
||||
- **Send to Exocad:** local DentalDB SQLite write from the case header, every origin, at every screen size, only in Chrome and Edge (`showOpenFilePicker`). Other browsers do not show the button. There is no local helper and no download fallback. A second send updates the same treatment (`importedOrderId`). An empty `externalCode` becomes that Exocad id when the file is written. The browser remembers the file handle only after the DentalDB check. The next send reopens that file when it still exists and skips Browse. A missing file shows Browse again. A file that is not a DentalDB database is not remembered, and Browse stays available. An empty `workParamsSHA` is copied from the newest saved case whose file name ends with `WorkParamsDB.xml` (not `WorkParamsDB-EndoCrown.xml`) onto a new `WorkParamsInfo` and `WorkParamsInfoLocal`. Do not set treatment `flags` to 16. The connect dialog says the feature is experimental and asks for a manual backup; Nudentic is not responsible. A tooth is written only when that work type and material already exist. Monolithic zirconia and PFZ are `Coping`, a pontic is `ReducedPontic`, and the FDI opposite is `Antagonist`/`Healthy` when that pair exists. Parameters come from the fullest saved tooth of the same pair, without shade. A Coping donor is the fullest tooth whose `ImplantType` already matches. `customized_abutment` on that Coping copies `CustomAbutment` only when a saved tooth of the same pair already has it; otherwise that value is not invented. A plain Coping copies `None` when a saved coping has it. Other abutment codes are not mapped. More than one technician is left unset. Client and Name reuse one existing match, or a complete first and last name; otherwise the case is not written and the toast says why. Notes are the comment body. There is no Local database tab. Keep `LocalDbSessionProvider`, the connect dialog, and the file open/write path.
|
||||
- **Send to Exocad:** local DentalDB SQLite write from the case header, every origin, at every screen size, only in Chrome and Edge (`showOpenFilePicker`). Other browsers do not show the button. There is no local helper and no download fallback. A second send updates the same treatment (`importedOrderId`). An empty `externalCode` becomes that Exocad id when the file is written. The browser remembers the file handle only after the DentalDB check. The next send reopens that file when it still exists and skips Browse. A missing file shows Browse again. A file that is not a DentalDB database is not remembered, and Browse stays available. An empty `workParamsSHA` is copied from the newest saved case whose file name ends with `WorkParamsDB.xml` (not `WorkParamsDB-EndoCrown.xml`) onto a new `WorkParamsInfo` and `WorkParamsInfoLocal`. Do not set treatment `flags` to 16. The connect dialog says the feature is experimental and asks for a manual backup; Nudentic is not responsible. A tooth is written only when that work type and material already exist. Monolithic zirconia and PFZ are `Coping`, a pontic is `ReducedPontic`, and the FDI opposite is `Antagonist`/`Healthy` when that pair exists. Parameters come from the fullest saved tooth of the same pair, without shade. A Coping donor is the fullest tooth whose `ImplantType` already matches. `customized_abutment` on that Coping copies `CustomAbutment` only when a saved tooth of the same pair already has it; otherwise that value is not invented. A plain Coping copies `None` when a saved coping has it. Other abutment codes are not mapped. More than one technician is left unset. Client is an exact name, one unique token match, or a new client with the given name, including one word. An empty clinic name still writes the case. A patient name that cannot be split is not written and the toast says why. A new case gets the next `t_schaleId` for that client. After the write, the user can grant the CAD-Data folder so the empty `{date}_{practice}-{tray}` directory is created; cancelling that grant leaves the case in the database. Notes are the comment body. There is no Local database tab. Keep `LocalDbSessionProvider`, the connect dialog, and the file open/write path.
|
||||
- **One plan:** a live case has one prosthesis plan. Clinic send still uses `treatmentDetailId` as `sourceKey`. Lab-origin cases use the case id. Outsource children use the child case id, or `childId:parentSourceKey` when two selected steps would collide (see Outsource). `LabCaseLine` is gone. Detail and New case use `UnderlineTabs`: Details, Files, Messages. Files and Messages show unread counts (`LabCaseSectionReadState`); opening Details does not clear them. `ATTACHMENT_ADDED` is not a sidebar badge. Origin is one combobox of linked clinics and labs, or a typed name. Dentist/Technician stays optional. Arch jobs (`UA`/`LA`) highlight the read-only FDI chart.
|
||||
- **Case Sheet PDF:** same layout for portrait and landscape (Download PDF menu). One A4 page, scaled to fit — the chart is never split. Header is a flex row: current organization name (one line, 56px line box so html2canvas does not clip the 28px glyphs), Nudentic lockup aligned with that text, share QR at 88px inside a 96px frame with `fill` off (a stretched SVG is dropped by html2canvas; not a table cell). Print root top padding is 16px portrait / 24px landscape so the QR is not clipped; `html2canvas` `scrollY` is 0. The page stays LTR in every locale. On `fa`, the org name is a shrink-wrapped `inline-block` (`direction: ltr` unless the name itself contains Arabic script) with `letter-spacing` and `word-spacing` `0px` — a full-width RTL box gaps Latin words. Party and meta values use `printRtlValueStyle` (Arabic script stays RTL; Latin stays LTR and right-aligned). Section rules keep a 12px gap and 8px padding so the line clears the values; `FA_RULE_DROP` (6px) clears Persian descenders. `onclone` must not overwrite the name span’s direction. Print ink is `prosthesisTypePrintColorFromCatalog` (heaviest family swatch). Prosthesis rows are SVG boxes. Chart is 85% of the page width with capped glyph height, shared upper column widths, outline-only unselected teeth, root vs crown fills, a larger gap under the upper caption, and matching tooth/number/midline gaps on both arches. Bridge marks match the FDI chart: 10px `#009cae` dots on the column boundary in the tooth-to-number gap. `onclone` sizes the lockup SVGs and the organization-name line box. Hex inline styles only. Optional `externalCode` replaces the printed order number and the `case-sheet-{orderNumber}.pdf` filename.
|
||||
- **Detail chrome:** The header follows the detail panel width (`@container`, not the viewport): two columns (info start, actions end) from `@2xl`, otherwise one stack with the buttons under the info: name and the same QR thumb (`w-24 sm:w-32`) on the first row, mobile/from/date on one wrapping line, then progress bar, external code, **Mark as important**, and billed, stacked and left aligned. Edit / Outsource / Send to Exocad / Get PDF are one equal-width grid (`responsiveFill`, truncating caption): 2 columns when narrow, one column per button from `@xl`, 2 columns in the `@2xl` end column with the QR below. Get PDF is a primary `CaseLifecycleButton` with no icon. Add files uses that button at the treatment action width. **Add case** is a full-width `px-6 py-3 text-base` split (label + mic) matching New treatment and Add detail voice. There is no Comments button, and opening Messages does not scroll the page. File cards: name at the start and checkbox at the end, then a clipped preview, then size over date at the start with the View/Download menu centered at the end. Remove is on that menu (`DELETE /cases/:id/attachments/:attachmentId`, confirm first). An in-progress upload is its own card with a progress bar. The sent-date line reads “Outsource {date}”.
|
||||
|
||||
@@ -62,7 +62,7 @@ Writes the open case into a DentalDB SQLite file on this computer. Nothing is up
|
||||
- Button `cases.sendToExocad` on 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.
|
||||
- `LocalDbSessionProvider` holds 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 id `0`. 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 id `2147483647`. Match a patient of that client by the same tokens, ignoring order. DentalDB stores the family name in `fname` and the given name in `lname`. A new patient is created only when both parts exist. Otherwise nothing is written and the toast says Name could not be filled. `t_Notes` is the case comment bodies, or the detail comment when the thread is empty. `Treatment.importedOrderId` is the Dyolink case id, so a second send updates that treatment and replaces its `ToothWork` rows. One case is one transaction: a failed insert rolls the case back and the database is unchanged. When `workParamsSHA` is empty, copy that hash onto a new `WorkParamsInfo` and `WorkParamsInfoLocal` from the newest saved case whose file name ends with `WorkParamsDB.xml` (not `WorkParamsDB-EndoCrown.xml`), then set `workParamsSHA` and `workParamInfoId`. Do not set treatment `flags` to 16. The CAD-Data project folder is still created by Exocad's own Save.
|
||||
- Mapper: `frontend/src/components/local-db/exocadTransfer.ts`. Lab id `0`. The client is the case clinic name (the sheet sender). Reuse a client when the trimmed name matches one client, ignoring case, or when exactly one client name contains every token. Otherwise create a client with the name as given, including one word. Several partial matches do not pick a client. An empty clinic name still writes the case on one empty-named client. Never use practice id `2147483647`. Match a patient of that client by the same tokens, ignoring order. DentalDB stores the family name in `fname` and the given name in `lname`. A new patient is created only when both parts exist. Otherwise nothing is written and the toast says Name could not be filled. `t_Notes` is the case comment bodies, or the detail comment when the thread is empty. `Treatment.importedOrderId` is the Dyolink case id, so a second send updates that treatment and replaces its `ToothWork` rows. A new case sets `t_schaleId` to one more than that client's highest tray, or 1. An update keeps a tray that is already set. The project directory is `{date}_{practice}-{tray}` from the stored treatment date. After the database write, the user grants the `CAD-Data` folder once; that handle is remembered and only the empty project directory is created. If that grant is cancelled, the case stays in the database and the toast says Save can still fail. One case is one transaction: a failed insert rolls the case back and the database is unchanged. When `workParamsSHA` is empty, copy that hash onto a new `WorkParamsInfo` and `WorkParamsInfoLocal` from the newest saved case whose file name ends with `WorkParamsDB.xml` (not `WorkParamsDB-EndoCrown.xml`), then set `workParamsSHA` and `workParamInfoId`. Do not set treatment `flags` to 16.
|
||||
- A tooth is written only when the catalog name has an obvious Exocad material and that exact `WorkTypeSN` + `MaterialSN` already 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 whose `ImplantType` already 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 = `ReducedPontic` plus 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 as `Antagonist`/`Healthy` when that pair exists and the opposite is not itself a restoration. When the file already stores them, the case scan mode is `AntagonistType` `RegisteredJaws` and 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 copies `ImplantType` `CustomAbutment` from 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 a `None` coping when one exists. A plain Coping copies `ImplantType` `None` when a saved coping has it, and does not take `CustomAbutment` from 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 `externalCode` is empty, save the Exocad `treatment_id` through `PATCH /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.
|
||||
|
||||
@@ -74,7 +74,7 @@ frontend/src/
|
||||
|
||||
**Lab Tasks tab:** Newest case first (`listedAt`); grouping only for date sort; filters include completed step, origin, due date, assignment, and prosthesis. New tasks are plan-scoped: one scan → prosthesis sections → optional Model design/creation (when any type has `requiresModelSteps`) → packing/shipping. `lineCount` stays 1. `__line__` tasks are independently completable. A type with both dry milling and sintering generates `milling_dry_sinter`; both wet milling and sintering generate `milling_wet_sinter`; both stain and glaze generate `stain_glaze`. A type with only one half keeps that half, and existing task rows are not rewritten. Model design and model create can be outsourced with that line’s teeth, or the whole plan for a historical `__case__` model step; scan, packing, and shipping cannot. Historical `__case__` scan keeps whole-case fan-out. Same-type exclusive steps coalesce across matching teeth; duplicate non-model steps for stacked types become `typeA+typeB` sections. Pontics fold into connected crown/indirect sections. Task identity includes source, first tooth, section type, and workflow code because one section may produce different tooth sets across steps. Job titles use `ProsthesisJobLineLabel`; task assignment is in Cases; only assignee/unassigned pool can update status in Tasks. `CASE_COMPLETED` drives inbox/tab badges only after all case tasks finish. See `.cursor/skills/lab-tasks/SKILL.md`.
|
||||
|
||||
**Lab Cases tab:** Filter by **prosthesis type** (not treatment type); auto-select newest case on open; list **10 per page**; left rail list fills column height (`flex-1 overflow-y-auto`). Unstarted lab-origin **drafts** sit in a collapsed expandable rail section (opens on click or **Add case**); received + started cases list below, newest first by send or start time (`listedAt`, same key as Tasks). List cards use `LabCaseProsthesisGroupsList` (colored type + teeth, shared with Treatment rail) plus **From clinic** / **Generated** / **From lab** origin badges. Job titles use `ProsthesisJobLineLabel` the same as Treatment/Tasks (`13 · Pontic - 14 · PFZ Crown`; no category; indirect keeps Inlay · Layered ceramic). Deep link: `?caseId=`, `?clinicOrganizationId=`. **Share link:** QR + URL on sent cases **and** started lab-origin cases (attachment left, QR right); opens `/lab-case/[token]` focus page. **Case Sheet PDF:** same portrait/landscape layout, one A4 page (`jspdf`/`html2canvas`, scaled to fit); realistic FDI chart; hex-only print layout; share QR stays in the flex header; optional `externalCode` replaces the printed order number and the `case-sheet-{orderNumber}.pdf` filename. The page stays LTR; on Persian sheets the org name is shrink-wrapped (RTL only when the name itself is Arabic script) and labels use `0px` letter-spacing. Lab-origin Start has no clinic send and notifies the linked org once (`PARTNER_CASE_CREATED`, share link); generated-case comments have no visibility toggle. A lab-to-lab case uses the eye button so the sending lab can see that comment. Comments use Cases **or** Tasks permission. Unstarted generated drafts can be deleted (`DELETE /cases/:id`). **Edit** (`POST /cases/:id/stop`) returns a started generated case to that drafts rail: completed steps and the previous prosthesis plan stay as history, in-progress steps are dropped, and the case can be edited and started again. Open outsources with no finished step are cancelled; a finished outsourced step blocks Edit. **Outsource** gives selected in-progress prosthesis steps, plus model design and model create, to one linked lab as a child case. Child `sourceKey` stays the child case id unless two selected steps share tooth, type, and workflow (`childId:parentSourceKey`). The child shows only that sending lab (no original clinic or dentist). Those steps leave Tasks until that lab completes them, and only the sending lab sees that direct handoff. The sender chart stays the full plan; the receiver chart is the selected jobs plus pontics on that bridge. **Live:** inbox Socket.IO → `notifyTabBadgesChanged()` soft-refreshes list + selected detail (no remount). A file upload emits `case-section.changed` on that socket (no inbox card) so Files and Messages unread counts refresh the same way. **Add case** is a full-width split button with the lab mic. One file can be removed from its card menu. An upload keeps running after leaving Files or Cases; the open case adds the file from the upload response without another fetch. Attachments have no size cap; production must recreate nginx from the SSL template or `/api` stays at 50MB. **Send to Exocad** (Chrome and Edge only, any screen size; no helper program or download) writes the open case into a DentalDB SQLite file on that computer. The browser remembers the file only after the DentalDB check and reopens it while it still exists; an invalid file is not remembered, so Browse stays available. Monolithic zirconia and PFZ are Coping, a pontic is a reduced pontic, and the opposite tooth is an antagonist, only when that pair already exists in the file. A titanium custom abutment on that Coping copies ImplantType CustomAbutment from a saved tooth of the same pair when the file already has it. The connect dialog says the feature is experimental, asks for a manual backup, says Nudentic is not responsible, and says the user uses it on their own. A clinic or patient name that cannot fill Client or Name is not written, and the toast says which name failed. A failed case rolls back. There is no Local database tab. See `.cursor/skills/lab-cases/SKILL.md` and `.cursor/skills/lab-case-share-link/SKILL.md`.
|
||||
**Lab Cases tab:** Filter by **prosthesis type** (not treatment type); auto-select newest case on open; list **10 per page**; left rail list fills column height (`flex-1 overflow-y-auto`). Unstarted lab-origin **drafts** sit in a collapsed expandable rail section (opens on click or **Add case**); received + started cases list below, newest first by send or start time (`listedAt`, same key as Tasks). List cards use `LabCaseProsthesisGroupsList` (colored type + teeth, shared with Treatment rail) plus **From clinic** / **Generated** / **From lab** origin badges. Job titles use `ProsthesisJobLineLabel` the same as Treatment/Tasks (`13 · Pontic - 14 · PFZ Crown`; no category; indirect keeps Inlay · Layered ceramic). Deep link: `?caseId=`, `?clinicOrganizationId=`. **Share link:** QR + URL on sent cases **and** started lab-origin cases (attachment left, QR right); opens `/lab-case/[token]` focus page. **Case Sheet PDF:** same portrait/landscape layout, one A4 page (`jspdf`/`html2canvas`, scaled to fit); realistic FDI chart; hex-only print layout; share QR stays in the flex header; optional `externalCode` replaces the printed order number and the `case-sheet-{orderNumber}.pdf` filename. The page stays LTR; on Persian sheets the org name is shrink-wrapped (RTL only when the name itself is Arabic script) and labels use `0px` letter-spacing. Lab-origin Start has no clinic send and notifies the linked org once (`PARTNER_CASE_CREATED`, share link); generated-case comments have no visibility toggle. A lab-to-lab case uses the eye button so the sending lab can see that comment. Comments use Cases **or** Tasks permission. Unstarted generated drafts can be deleted (`DELETE /cases/:id`). **Edit** (`POST /cases/:id/stop`) returns a started generated case to that drafts rail: completed steps and the previous prosthesis plan stay as history, in-progress steps are dropped, and the case can be edited and started again. Open outsources with no finished step are cancelled; a finished outsourced step blocks Edit. **Outsource** gives selected in-progress prosthesis steps, plus model design and model create, to one linked lab as a child case. Child `sourceKey` stays the child case id unless two selected steps share tooth, type, and workflow (`childId:parentSourceKey`). The child shows only that sending lab (no original clinic or dentist). Those steps leave Tasks until that lab completes them, and only the sending lab sees that direct handoff. The sender chart stays the full plan; the receiver chart is the selected jobs plus pontics on that bridge. **Live:** inbox Socket.IO → `notifyTabBadgesChanged()` soft-refreshes list + selected detail (no remount). A file upload emits `case-section.changed` on that socket (no inbox card) so Files and Messages unread counts refresh the same way. **Add case** is a full-width split button with the lab mic. One file can be removed from its card menu. An upload keeps running after leaving Files or Cases; the open case adds the file from the upload response without another fetch. Attachments have no size cap; production must recreate nginx from the SSL template or `/api` stays at 50MB. **Send to Exocad** (Chrome and Edge only, any screen size; no helper program or download) writes the open case into a DentalDB SQLite file on that computer. The browser remembers the file only after the DentalDB check and reopens it while it still exists; an invalid file is not remembered, so Browse stays available. Monolithic zirconia and PFZ are Coping, a pontic is a reduced pontic, and the opposite tooth is an antagonist, only when that pair already exists in the file. A titanium custom abutment on that Coping copies ImplantType CustomAbutment from a saved tooth of the same pair when the file already has it. The connect dialog says the feature is experimental, asks for a manual backup, says Nudentic is not responsible, and says the user uses it on their own. A one-word clinic name still fills Client, and an empty clinic name still writes the case. A patient name that cannot fill Name is not written, and the toast says so. Each new case gets the next tray for that client. After the write, the user can grant the CAD-Data folder so the empty project directory is created. A failed case rolls back. There is no Local database tab. See `.cursor/skills/lab-cases/SKILL.md` and `.cursor/skills/lab-case-share-link/SKILL.md`.
|
||||
|
||||
**Lab case share link (quick ref):**
|
||||
- Token on first ship **or** lab-origin Start → `/{locale}/lab-case/{token}` after login. Editing a generated case keeps that token. The page reads the current round and the live patient/clinic snapshots. Cases, Treatment lab dispatch, and the Case Sheet QR all use this URL.
|
||||
|
||||
@@ -561,6 +561,7 @@
|
||||
"sendToExocadSaved": "Sent to Exocad as case {id}. Open Exocad again to see the case.",
|
||||
"sendToExocadUpdated": "Updated Exocad case {id}. Open Exocad again to see the case.",
|
||||
"sendToExocadSkipped": "Not sent: {lines}.",
|
||||
"sendToExocadFolderMissing": "The case was written. The Exocad project folder was not created, so Save in Exocad can still fail until you choose the CAD-Data folder.",
|
||||
"sendToExocadConnectTitle": "Connect Exocad database",
|
||||
"sendToExocadCloseHint": "Close Exocad before sending. Open it again afterwards to see the case.",
|
||||
"sendToExocadExperimentalWarning": "This is an experimental feature. Make a manual backup of the Exocad database before using it. Nudentic is not responsible for any issues. You use this feature on your own.",
|
||||
@@ -1449,7 +1450,6 @@
|
||||
"applyFailed": "Could not write the file.",
|
||||
"conflict": "That record conflicts with a row already in the table.",
|
||||
"notExocad": "That file is not an Exocad database.",
|
||||
"clientNameIncomplete": "Not sent. The clinic name needs a last name so Exocad can fill Client. Edit the clinic name and try again. The Exocad database was not changed.",
|
||||
"patientNameIncomplete": "Not sent. The patient name needs a last name so Exocad can fill Name. Edit the patient and try again. The Exocad database was not changed.",
|
||||
"sendRolledBack": "Not sent. The Exocad database was not changed."
|
||||
},
|
||||
|
||||
@@ -561,6 +561,7 @@
|
||||
"sendToExocadSaved": "به Exocad به عنوان پرونده {id} فرستاده شد. Exocad را دوباره باز کنید تا پرونده را ببینید.",
|
||||
"sendToExocadUpdated": "پرونده {id} در Exocad بهروز شد. Exocad را دوباره باز کنید تا پرونده را ببینید.",
|
||||
"sendToExocadSkipped": "فرستاده نشد: {lines}.",
|
||||
"sendToExocadFolderMissing": "پرونده نوشته شد. پوشه پروژه Exocad ساخته نشد، بنابراین ذخیره در Exocad تا وقتی پوشه CAD-Data را انتخاب نکنید میتواند ناموفق بماند.",
|
||||
"sendToExocadConnectTitle": "اتصال پایگاه داده Exocad",
|
||||
"sendToExocadCloseHint": "پیش از ارسال Exocad را ببندید. بعد از ارسال آن را دوباره باز کنید تا پرونده را ببینید.",
|
||||
"sendToExocadExperimentalWarning": "این قابلیت آزمایشی است. پیش از استفاده، یک نسخه پشتیبان دستی از پایگاه داده Exocad بگیرید. نودنتیک مسئول هیچ مشکلی نیست. استفاده از این قابلیت بر عهده خود شماست.",
|
||||
@@ -1450,7 +1451,6 @@
|
||||
"applyFailed": "نوشتن فایل انجام نشد.",
|
||||
"conflict": "این رکورد با ردیفی که از قبل در جدول است تداخل دارد.",
|
||||
"notExocad": "این فایل پایگاه داده Exocad نیست.",
|
||||
"clientNameIncomplete": "ارسال نشد. نام کلینیک نام خانوادگی ندارد، بنابراین Client در Exocad پر نمیشود. نام کلینیک را اصلاح کنید و دوباره بفرستید. پایگاه داده Exocad تغییر نکرد.",
|
||||
"patientNameIncomplete": "ارسال نشد. نام بیمار نام خانوادگی ندارد، بنابراین Name در Exocad پر نمیشود. نام بیمار را اصلاح کنید و دوباره بفرستید. پایگاه داده Exocad تغییر نکرد.",
|
||||
"sendRolledBack": "ارسال نشد. پایگاه داده Exocad تغییر نکرد."
|
||||
},
|
||||
|
||||
@@ -561,6 +561,7 @@
|
||||
"sendToExocadSaved": "Naar Exocad gestuurd als casus {id}. Open Exocad opnieuw om de casus te zien.",
|
||||
"sendToExocadUpdated": "Exocad-casus {id} bijgewerkt. Open Exocad opnieuw om de casus te zien.",
|
||||
"sendToExocadSkipped": "Niet gestuurd: {lines}.",
|
||||
"sendToExocadFolderMissing": "De casus is opgeslagen. De Exocad-projectmap is niet aangemaakt, dus Opslaan in Exocad kan nog mislukken totdat u de map CAD-Data kiest.",
|
||||
"sendToExocadConnectTitle": "Exocad-database koppelen",
|
||||
"sendToExocadCloseHint": "Sluit Exocad voordat u verstuurt. Open het daarna opnieuw om de casus te zien.",
|
||||
"sendToExocadExperimentalWarning": "Dit is een experimentele functie. Maak een handmatige back-up van de Exocad-database voordat u deze gebruikt. Nudentic is niet aansprakelijk voor eventuele problemen. U gebruikt deze functie op eigen verantwoordelijkheid.",
|
||||
@@ -1449,7 +1450,6 @@
|
||||
"applyFailed": "Het bestand kon niet worden geschreven.",
|
||||
"conflict": "Dat record botst met een rij die al in de tabel staat.",
|
||||
"notExocad": "Dat bestand is geen Exocad-database.",
|
||||
"clientNameIncomplete": "Niet verzonden. De klinieknaam heeft geen achternaam, dus Exocad kan Client niet invullen. Pas de klinieknaam aan en probeer het opnieuw. De Exocad-database is niet gewijzigd.",
|
||||
"patientNameIncomplete": "Niet verzonden. De patiëntnaam heeft geen achternaam, dus Exocad kan Name niet invullen. Pas de patiënt aan en probeer het opnieuw. De Exocad-database is niet gewijzigd.",
|
||||
"sendRolledBack": "Niet verzonden. De Exocad-database is niet gewijzigd."
|
||||
},
|
||||
|
||||
@@ -206,3 +206,110 @@ export async function openWithBrowserPicker(): Promise<DatabaseSink> {
|
||||
});
|
||||
return sinkFromBrowserHandle(handle);
|
||||
}
|
||||
|
||||
type DirectoryHandle = {
|
||||
queryPermission?: (descriptor: { mode: 'readwrite' }) => Promise<FilePermission>;
|
||||
requestPermission?: (descriptor: { mode: 'readwrite' }) => Promise<FilePermission>;
|
||||
getDirectoryHandle: (name: string, options?: { create?: boolean }) => Promise<unknown>;
|
||||
};
|
||||
|
||||
type OpenDirectoryPicker = (options?: {
|
||||
mode?: 'readwrite';
|
||||
id?: string;
|
||||
}) => Promise<DirectoryHandle>;
|
||||
|
||||
const CAD_DATA_KEY = 'cad-data';
|
||||
|
||||
let cachedDirectory: DirectoryHandle | null = null;
|
||||
|
||||
function directoryPicker(): OpenDirectoryPicker | null {
|
||||
if (typeof window === 'undefined') return null;
|
||||
const picker = (window as Window & { showDirectoryPicker?: OpenDirectoryPicker }).showDirectoryPicker;
|
||||
return picker ?? null;
|
||||
}
|
||||
|
||||
async function loadDirectoryHandle(): Promise<DirectoryHandle | null> {
|
||||
if (cachedDirectory) return cachedDirectory;
|
||||
if (typeof indexedDB === 'undefined') return null;
|
||||
try {
|
||||
const db = await handleDb();
|
||||
const handle = await new Promise<DirectoryHandle | null>((resolve, reject) => {
|
||||
const tx = db.transaction(HANDLE_STORE, 'readonly');
|
||||
const request = tx.objectStore(HANDLE_STORE).get(CAD_DATA_KEY);
|
||||
request.onsuccess = () => resolve((request.result as DirectoryHandle | undefined) ?? null);
|
||||
request.onerror = () => reject(request.error);
|
||||
});
|
||||
db.close();
|
||||
cachedDirectory = handle;
|
||||
return handle;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function saveDirectoryHandle(handle: DirectoryHandle): Promise<void> {
|
||||
cachedDirectory = handle;
|
||||
if (typeof indexedDB === 'undefined') return;
|
||||
const db = await handleDb();
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
const tx = db.transaction(HANDLE_STORE, 'readwrite');
|
||||
tx.objectStore(HANDLE_STORE).put(handle, CAD_DATA_KEY);
|
||||
tx.oncomplete = () => resolve();
|
||||
tx.onerror = () => reject(tx.error);
|
||||
});
|
||||
db.close();
|
||||
}
|
||||
|
||||
async function clearDirectoryHandle(): Promise<void> {
|
||||
cachedDirectory = null;
|
||||
if (typeof indexedDB === 'undefined') return;
|
||||
try {
|
||||
const db = await handleDb();
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
const tx = db.transaction(HANDLE_STORE, 'readwrite');
|
||||
tx.objectStore(HANDLE_STORE).delete(CAD_DATA_KEY);
|
||||
tx.oncomplete = () => resolve();
|
||||
tx.onerror = () => reject(tx.error);
|
||||
});
|
||||
db.close();
|
||||
} catch {
|
||||
cachedDirectory = null;
|
||||
}
|
||||
}
|
||||
|
||||
async function grantedDirectory(handle: DirectoryHandle): Promise<DirectoryHandle | null> {
|
||||
const permission = handle.queryPermission ? await handle.queryPermission(READ_WRITE) : 'prompt';
|
||||
if (permission === 'granted') return handle;
|
||||
if (!handle.requestPermission) return null;
|
||||
return (await handle.requestPermission(READ_WRITE)) === 'granted' ? handle : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create one empty project directory inside the CAD-Data folder the user grants.
|
||||
* The database file permission cannot create that folder. Cancel leaves the case in the database.
|
||||
*/
|
||||
export async function ensureExocadProjectDirectory(folderName: string): Promise<boolean> {
|
||||
const safe = folderName.trim();
|
||||
if (!safe || /[\\/]/.test(safe)) return false;
|
||||
try {
|
||||
const remembered = await loadDirectoryHandle();
|
||||
const ready = remembered ? await grantedDirectory(remembered) : null;
|
||||
if (ready) {
|
||||
await ready.getDirectoryHandle(safe, { create: true });
|
||||
return true;
|
||||
}
|
||||
} catch (error) {
|
||||
if (isMissingFileError(error)) await clearDirectoryHandle();
|
||||
else return false;
|
||||
}
|
||||
const picker = directoryPicker();
|
||||
if (!picker) return false;
|
||||
try {
|
||||
const handle = await picker({ mode: 'readwrite', id: 'dyolink-exocad-cad-data' });
|
||||
await saveDirectoryHandle(handle);
|
||||
await handle.getDirectoryHandle(safe, { create: true });
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ const SCHEMA = [
|
||||
practice_lab_id INT, practice_pr_id INT,
|
||||
patient_lab_id INT, patient_practice_id INT, patient_patient_id INT,
|
||||
t_date DATETIME, t_Notes TEXT, flags BIGINT, projectGUID TEXT,
|
||||
importedOrderId TEXT, t_duedate TEXT,
|
||||
importedOrderId TEXT, t_duedate TEXT, t_schaleId INT,
|
||||
foreign key (practice_lab_id, practice_pr_id) references clients(lab_id, practice_id),
|
||||
foreign key (patient_lab_id, patient_practice_id, patient_patient_id)
|
||||
references patients(lab_id, practice_id, patient_id)
|
||||
@@ -494,18 +494,27 @@ describe('transferCaseToExocad', () => {
|
||||
db.close();
|
||||
});
|
||||
|
||||
it('does not write when the clinic name has no last name', async () => {
|
||||
it('writes the case when the clinic name is one word or empty', async () => {
|
||||
const db = await openSql();
|
||||
const query = seed(db);
|
||||
expect(() => transferCaseToExocad(query, sampleCase({ clinicName: ' ' }), options)).toThrow(ExocadTransferError);
|
||||
try {
|
||||
transferCaseToExocad(query, sampleCase({ clinicName: 'yavari' }), options);
|
||||
} catch (error) {
|
||||
expect(error).toBeInstanceOf(ExocadTransferError);
|
||||
expect((error as ExocadTransferError).code).toBe('CLIENT_NAME_INCOMPLETE');
|
||||
}
|
||||
expect(query.all("SELECT treatment_id FROM Treatment WHERE importedOrderId = 'case-1'")).toEqual([]);
|
||||
expect(query.all('SELECT COUNT(*) FROM clients')).toEqual([[2]]);
|
||||
const blank = transferCaseToExocad(query, sampleCase({ clinicName: ' ' }), options);
|
||||
const again = transferCaseToExocad(
|
||||
query,
|
||||
sampleCase({ caseId: 'case-blank-2', clinicName: ' ' }),
|
||||
{ ...options, projectGuid: 'guid-blank' },
|
||||
);
|
||||
expect(query.all('SELECT name, practice_id FROM clients WHERE TRIM(name) = ?', [''])).toEqual([['', 2]]);
|
||||
expect(query.all('SELECT practice_pr_id FROM Treatment WHERE treatment_id = ?', [blank.treatmentId])).toEqual([[2]]);
|
||||
expect(query.all('SELECT practice_pr_id FROM Treatment WHERE treatment_id = ?', [again.treatmentId])).toEqual([[2]]);
|
||||
|
||||
const named = transferCaseToExocad(
|
||||
query,
|
||||
sampleCase({ caseId: 'case-yavari', clinicName: 'yavari' }),
|
||||
{ ...options, projectGuid: 'guid-yavari' },
|
||||
);
|
||||
expect(query.all('SELECT name FROM clients WHERE practice_id = (SELECT practice_pr_id FROM Treatment WHERE treatment_id = ?)', [named.treatmentId])).toEqual([
|
||||
['yavari'],
|
||||
]);
|
||||
db.close();
|
||||
});
|
||||
|
||||
@@ -533,7 +542,7 @@ describe('transferCaseToExocad', () => {
|
||||
db.close();
|
||||
});
|
||||
|
||||
it('does not guess between clients that share one name token', async () => {
|
||||
it('reuses an exact client name before a partial match', async () => {
|
||||
const db = await openSql();
|
||||
const query = seed(db);
|
||||
for (const [id, name] of [
|
||||
@@ -547,12 +556,36 @@ describe('transferCaseToExocad', () => {
|
||||
[id, name],
|
||||
);
|
||||
}
|
||||
expect(() => transferCaseToExocad(query, sampleCase({ clinicName: 'yavari' }), options)).toThrow(ExocadTransferError);
|
||||
expect(query.all("SELECT treatment_id FROM Treatment WHERE importedOrderId = 'case-1'")).toEqual([]);
|
||||
const exact = transferCaseToExocad(query, sampleCase({ clinicName: 'yavari' }), options);
|
||||
expect(query.all('SELECT practice_pr_id FROM Treatment WHERE treatment_id = ?', [exact.treatmentId])).toEqual([[189]]);
|
||||
expect(query.all('SELECT COUNT(*) FROM clients WHERE name = ?', ['yavari'])).toEqual([[1]]);
|
||||
db.close();
|
||||
});
|
||||
|
||||
it('creates a client instead of choosing among several partial matches', async () => {
|
||||
const db = await openSql();
|
||||
const query = seed(db);
|
||||
for (const [id, name] of [
|
||||
[120, 'Yavari Hoseinali'],
|
||||
[178, 'Yavari,Tehran'],
|
||||
] as const) {
|
||||
query.run(
|
||||
`INSERT INTO clients (lab_id, practice_id, name, language, country, city, zip, street, email, flags)
|
||||
VALUES (0, ?, ?, '', '', '', '', '', '', 0)`,
|
||||
[id, name],
|
||||
);
|
||||
}
|
||||
const created = transferCaseToExocad(query, sampleCase({ clinicName: 'yavari' }), options);
|
||||
const row = query.all(
|
||||
'SELECT clients.name, clients.practice_id FROM clients JOIN Treatment ON Treatment.practice_pr_id = clients.practice_id WHERE Treatment.treatment_id = ?',
|
||||
[created.treatmentId],
|
||||
);
|
||||
expect(row).toEqual([['yavari', 179]]);
|
||||
expect(row[0][1]).not.toBe(120);
|
||||
expect(row[0][1]).not.toBe(178);
|
||||
db.close();
|
||||
});
|
||||
|
||||
it('does not write when the patient name has no last name', async () => {
|
||||
const db = await openSql();
|
||||
const query = seed(db);
|
||||
@@ -568,6 +601,29 @@ describe('transferCaseToExocad', () => {
|
||||
db.close();
|
||||
});
|
||||
|
||||
it('assigns the next tray and keeps it when the same case is sent again', async () => {
|
||||
const db = await openSql();
|
||||
const query = seed(db);
|
||||
seedSavedPair(query, 'Coping', 'ZI');
|
||||
const first = transferCaseToExocad(query, sampleCase(), options);
|
||||
expect(query.all('SELECT t_schaleId FROM Treatment WHERE treatment_id = ?', [first.treatmentId])).toEqual([[1]]);
|
||||
expect(first.projectFolder).toBe('2026-10-16_00002-001');
|
||||
|
||||
const second = transferCaseToExocad(
|
||||
query,
|
||||
sampleCase({ caseId: 'case-2' }),
|
||||
{ ...options, projectGuid: 'guid-2', now: '2026-10-17T09:00:00.000Z' },
|
||||
);
|
||||
expect(query.all('SELECT t_schaleId FROM Treatment WHERE treatment_id = ?', [second.treatmentId])).toEqual([[2]]);
|
||||
expect(second.projectFolder).toBe('2026-10-17_00002-002');
|
||||
|
||||
const updated = transferCaseToExocad(query, sampleCase(), { ...options, now: '2026-11-01T09:00:00.000Z' });
|
||||
expect(updated.treatmentId).toBe(first.treatmentId);
|
||||
expect(query.all('SELECT t_schaleId FROM Treatment WHERE treatment_id = ?', [updated.treatmentId])).toEqual([[1]]);
|
||||
expect(updated.projectFolder).toBe('2026-11-01_00002-001');
|
||||
db.close();
|
||||
});
|
||||
|
||||
it('writes coping, reduced pontic, and the opposite antagonist without a shade', async () => {
|
||||
const db = await openSql();
|
||||
const query = seed(db);
|
||||
|
||||
@@ -40,10 +40,7 @@ const MATERIAL_MATCH: Record<string, { workType: string; material: string }> = {
|
||||
ips_overlay: { workType: 'OverlayCrown', material: 'LS2' },
|
||||
};
|
||||
|
||||
export type ExocadTransferFailure =
|
||||
| 'NOT_EXOCAD'
|
||||
| 'CLIENT_NAME_INCOMPLETE'
|
||||
| 'PATIENT_NAME_INCOMPLETE';
|
||||
export type ExocadTransferFailure = 'NOT_EXOCAD' | 'PATIENT_NAME_INCOMPLETE';
|
||||
|
||||
export class ExocadTransferError extends Error {
|
||||
constructor(readonly code: ExocadTransferFailure) {
|
||||
@@ -88,6 +85,8 @@ export type ExocadTransferResult = {
|
||||
treatmentId: number;
|
||||
created: boolean;
|
||||
skipped: ExocadSkippedLine[];
|
||||
/** `{date}_{practice}-{tray}` under the Exocad CAD-Data directory. */
|
||||
projectFolder: string;
|
||||
};
|
||||
|
||||
export type ExocadTransferOptions = {
|
||||
@@ -121,6 +120,14 @@ export function exocadDueDate(value: string | null | undefined): string | null {
|
||||
return match ? match[1] : null;
|
||||
}
|
||||
|
||||
/** Directory Exocad Save lists: `2026-11-12_00120-006`. */
|
||||
export function exocadProjectFolder(dateValue: string, practiceId: number, schaleId: number): string {
|
||||
const date = exocadDueDate(dateValue) ?? '0000-00-00';
|
||||
const practice = String(practiceId).padStart(5, '0');
|
||||
const tray = String(schaleId).padStart(3, '0');
|
||||
return `${date}_${practice}-${tray}`;
|
||||
}
|
||||
|
||||
function buildNotes(comment: string): string | null {
|
||||
const text = comment.trim();
|
||||
return text.length > 0 ? text : null;
|
||||
@@ -305,19 +312,21 @@ function insertClient(db: SqliteQuery, name: string): number {
|
||||
return practiceId;
|
||||
}
|
||||
|
||||
type ClientChoice =
|
||||
| { practiceId: number }
|
||||
| { createName: string }
|
||||
| { failure: 'CLIENT_NAME_INCOMPLETE' };
|
||||
type ClientChoice = { practiceId: number } | { createName: string };
|
||||
|
||||
function decideClient(rows: Array<{ practiceId: number; name: string }>, clinicName: string): ClientChoice {
|
||||
const wanted = clinicName.trim();
|
||||
if (!wanted) {
|
||||
const blank = rows.find((row) => row.name.trim() === '');
|
||||
if (blank) return { practiceId: blank.practiceId };
|
||||
return { createName: '' };
|
||||
}
|
||||
const exact = rows.filter((row) => row.name.trim().toLocaleLowerCase() === wanted.toLocaleLowerCase());
|
||||
if (exact.length === 1) return { practiceId: exact[0].practiceId };
|
||||
const tokens = nameTokens(wanted);
|
||||
if (tokens.length === 0) return { failure: 'CLIENT_NAME_INCOMPLETE' };
|
||||
const matches = rows.filter((row) => coversTokens(row.name, tokens));
|
||||
if (matches.length === 1) return { practiceId: matches[0].practiceId };
|
||||
if (tokens.length >= 2) return { createName: wanted };
|
||||
return { failure: 'CLIENT_NAME_INCOMPLETE' };
|
||||
return { createName: wanted };
|
||||
}
|
||||
|
||||
function matchingPatientId(
|
||||
@@ -354,13 +363,12 @@ function insertPatient(
|
||||
return patientId;
|
||||
}
|
||||
|
||||
/** Match an existing client and patient, or create both only when each name has two parts. */
|
||||
/** Match or create a client, including a one-word or empty clinic name. The patient still needs two name parts. */
|
||||
function resolveParties(
|
||||
db: SqliteQuery,
|
||||
input: ExocadCaseInput,
|
||||
): { practiceId: number; patientId: number } {
|
||||
const decision = decideClient(clientRows(db), input.clinicName);
|
||||
if ('failure' in decision) throw new ExocadTransferError(decision.failure);
|
||||
const parts = personParts(input.patientFirstName, input.patientLastName);
|
||||
const tokens = nameTokens(`${input.patientFirstName} ${input.patientLastName}`);
|
||||
|
||||
@@ -714,6 +722,27 @@ function embedMaterialConfiguration(db: SqliteQuery, treatmentId: number): void
|
||||
);
|
||||
}
|
||||
|
||||
function nextSchaleId(db: SqliteQuery, practiceId: number): number {
|
||||
if (!treatmentHasColumn(db, 't_schaleId')) return 1;
|
||||
const rows = db.all(
|
||||
'SELECT MAX(t_schaleId) FROM Treatment WHERE practice_lab_id = ? AND practice_pr_id = ?',
|
||||
[EXOCAD_LAB_ID, practiceId],
|
||||
);
|
||||
return numberValue(rows[0]?.[0]) + 1;
|
||||
}
|
||||
|
||||
function storedSchaleId(db: SqliteQuery, treatmentId: number): number | null {
|
||||
if (!treatmentHasColumn(db, 't_schaleId')) return null;
|
||||
const rows = db.all('SELECT t_schaleId FROM Treatment WHERE treatment_id = ?', [treatmentId]);
|
||||
const value = numberValue(rows[0]?.[0]);
|
||||
return value > 0 ? value : null;
|
||||
}
|
||||
|
||||
function writeSchaleId(db: SqliteQuery, treatmentId: number, schaleId: number): void {
|
||||
if (!treatmentHasColumn(db, 't_schaleId')) return;
|
||||
db.run('UPDATE Treatment SET t_schaleId = ? WHERE treatment_id = ?', [schaleId, treatmentId]);
|
||||
}
|
||||
|
||||
function writeCase(db: SqliteQuery, input: ExocadCaseInput, options: ExocadTransferOptions): ExocadTransferResult {
|
||||
const { practiceId, patientId } = resolveParties(db, input);
|
||||
const due = exocadDueDate(input.dueDate);
|
||||
@@ -735,6 +764,8 @@ function writeCase(db: SqliteQuery, input: ExocadCaseInput, options: ExocadTrans
|
||||
const existing = db.all('SELECT treatment_id FROM Treatment WHERE importedOrderId = ?', [input.caseId]);
|
||||
if (existing.length > 0) {
|
||||
const treatmentId = numberValue(existing[0][0]);
|
||||
const keptSchale = storedSchaleId(db, treatmentId);
|
||||
const schaleId = keptSchale ?? nextSchaleId(db, practiceId);
|
||||
db.run(
|
||||
`UPDATE Treatment SET
|
||||
practice_lab_id = ?,
|
||||
@@ -748,14 +779,16 @@ function writeCase(db: SqliteQuery, input: ExocadCaseInput, options: ExocadTrans
|
||||
WHERE treatment_id = ?`,
|
||||
[...header, treatmentId],
|
||||
);
|
||||
if (keptSchale == null) writeSchaleId(db, treatmentId, schaleId);
|
||||
deleteToothWork(db, treatmentId);
|
||||
insertTeeth(db, treatmentId, writes, snapshots);
|
||||
copyConfirmedCaseParameters(db, treatmentId);
|
||||
assignSoleTechnician(db, treatmentId);
|
||||
embedMaterialConfiguration(db, treatmentId);
|
||||
return { treatmentId, created: false, skipped };
|
||||
return { treatmentId, created: false, skipped, projectFolder: exocadProjectFolder(now, practiceId, schaleId) };
|
||||
}
|
||||
|
||||
const schaleId = nextSchaleId(db, practiceId);
|
||||
const projectGuid = options.projectGuid ?? crypto.randomUUID();
|
||||
db.run(
|
||||
`INSERT INTO Treatment (
|
||||
@@ -766,11 +799,12 @@ function writeCase(db: SqliteQuery, input: ExocadCaseInput, options: ExocadTrans
|
||||
[...header, projectGuid, input.caseId],
|
||||
);
|
||||
const treatmentId = numberValue(db.all('SELECT last_insert_rowid()')[0]?.[0]);
|
||||
writeSchaleId(db, treatmentId, schaleId);
|
||||
insertTeeth(db, treatmentId, writes, snapshots);
|
||||
copyConfirmedCaseParameters(db, treatmentId);
|
||||
assignSoleTechnician(db, treatmentId);
|
||||
embedMaterialConfiguration(db, treatmentId);
|
||||
return { treatmentId, created: true, skipped };
|
||||
return { treatmentId, created: true, skipped, projectFolder: exocadProjectFolder(now, practiceId, schaleId) };
|
||||
}
|
||||
|
||||
/** Insert or update one DentalDB case. Disk stays unchanged until the caller exports the database. */
|
||||
|
||||
@@ -10,7 +10,6 @@ export function localDbErrorText(
|
||||
fallback: 'openFailed' | 'applyFailed' | 'loadFailed' | 'sendRolledBack',
|
||||
): string {
|
||||
if (error instanceof ExocadTransferError) {
|
||||
if (error.code === 'CLIENT_NAME_INCOMPLETE') return t('clientNameIncomplete');
|
||||
if (error.code === 'PATIENT_NAME_INCOMPLETE') return t('patientNameIncomplete');
|
||||
return t('notExocad');
|
||||
}
|
||||
|
||||
@@ -491,6 +491,12 @@ export function CaseDetailPanel({
|
||||
})
|
||||
: '';
|
||||
toast.showSuccess(saved);
|
||||
try {
|
||||
const folderReady = await localDb.ensureProjectFolder(result.projectFolder);
|
||||
if (!folderReady) toast.showInfo(t('sendToExocadFolderMissing'));
|
||||
} catch {
|
||||
toast.showInfo(t('sendToExocadFolderMissing'));
|
||||
}
|
||||
if (skipped) toast.showInfo(skipped);
|
||||
} catch (caught) {
|
||||
toast.showError(localDbErrorText(caught, tLocal, 'applyFailed'));
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
import {
|
||||
browserCanWriteLocalFile,
|
||||
browserDatabaseStillExists,
|
||||
ensureExocadProjectDirectory,
|
||||
forgetBrowserDatabase,
|
||||
preloadBrowserHandle,
|
||||
reopenStoredBrowserFile,
|
||||
@@ -39,6 +40,8 @@ export type LocalDbSessionValue = {
|
||||
abandon: () => Promise<void>;
|
||||
requestConnection: () => Promise<boolean>;
|
||||
transferCase: (input: ExocadCaseInput) => ExocadTransferResult;
|
||||
/** Create the empty CAD-Data project directory. False when the folder was not granted. */
|
||||
ensureProjectFolder: (folderName: string) => Promise<boolean>;
|
||||
};
|
||||
|
||||
const LocalDbSessionContext = createContext<LocalDbSessionValue | null>(null);
|
||||
@@ -108,6 +111,11 @@ export function LocalDbSessionProvider({ children }: { children: ReactNode }) {
|
||||
return session.execute((query) => transferCaseToExocad(query, input));
|
||||
}, []);
|
||||
|
||||
const ensureProjectFolder = useCallback(
|
||||
(folderName: string) => ensureExocadProjectDirectory(folderName),
|
||||
[],
|
||||
);
|
||||
|
||||
const finishConnect = useCallback((connected: boolean) => {
|
||||
setConnectOpen(false);
|
||||
connectResolveRef.current?.(connected);
|
||||
@@ -145,8 +153,8 @@ export function LocalDbSessionProvider({ children }: { children: ReactNode }) {
|
||||
}, [dropSession, replaceWithSink]);
|
||||
|
||||
const value = useMemo<LocalDbSessionValue>(
|
||||
() => ({ apply, abandon, requestConnection, transferCase }),
|
||||
[abandon, apply, requestConnection, transferCase],
|
||||
() => ({ apply, abandon, requestConnection, transferCase, ensureProjectFolder }),
|
||||
[abandon, apply, ensureProjectFolder, requestConnection, transferCase],
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user