@alfadocs/ui-kit 1.145.0 → 1.147.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/_chunks/prescription-history-CFs3JMIE.js +1773 -0
  2. package/dist/_chunks/registry-connection-panel-BEAkwivy.js +503 -0
  3. package/dist/agent-catalog.json +115 -1
  4. package/dist/agent-i18n/en.json +12 -0
  5. package/dist/browser-support.js +1 -1
  6. package/dist/components/_shared/medication.d.ts +4 -0
  7. package/dist/components/index.d.ts +1 -0
  8. package/dist/components/registry-connection-panel/index.d.ts +3 -0
  9. package/dist/components/registry-connection-panel/index.js +5 -0
  10. package/dist/components/registry-connection-panel/registry-connection-panel.agent.d.ts +4 -0
  11. package/dist/components/registry-connection-panel/registry-connection-panel.d.ts +67 -0
  12. package/dist/i18n/locales/ar.d.ts +31 -0
  13. package/dist/i18n/locales/ar.js +32 -1
  14. package/dist/i18n/locales/de.d.ts +31 -0
  15. package/dist/i18n/locales/de.js +32 -1
  16. package/dist/i18n/locales/el.d.ts +31 -0
  17. package/dist/i18n/locales/el.js +32 -1
  18. package/dist/i18n/locales/en.d.ts +31 -0
  19. package/dist/i18n/locales/en.js +32 -1
  20. package/dist/i18n/locales/es.d.ts +31 -0
  21. package/dist/i18n/locales/es.js +32 -1
  22. package/dist/i18n/locales/fr.d.ts +31 -0
  23. package/dist/i18n/locales/fr.js +32 -1
  24. package/dist/i18n/locales/hi.d.ts +31 -0
  25. package/dist/i18n/locales/hi.js +32 -1
  26. package/dist/i18n/locales/it.d.ts +31 -0
  27. package/dist/i18n/locales/it.js +32 -1
  28. package/dist/i18n/locales/ja.d.ts +31 -0
  29. package/dist/i18n/locales/ja.js +32 -1
  30. package/dist/i18n/locales/nl.d.ts +31 -0
  31. package/dist/i18n/locales/nl.js +32 -1
  32. package/dist/i18n/locales/pl.d.ts +31 -0
  33. package/dist/i18n/locales/pl.js +32 -1
  34. package/dist/i18n/locales/pt.d.ts +31 -0
  35. package/dist/i18n/locales/pt.js +32 -1
  36. package/dist/i18n/locales/ro.d.ts +31 -0
  37. package/dist/i18n/locales/ro.js +32 -1
  38. package/dist/i18n/locales/ru.d.ts +31 -0
  39. package/dist/i18n/locales/ru.js +32 -1
  40. package/dist/i18n/locales/sq.d.ts +31 -0
  41. package/dist/i18n/locales/sq.js +32 -1
  42. package/dist/i18n/locales/sv.d.ts +31 -0
  43. package/dist/i18n/locales/sv.js +32 -1
  44. package/dist/i18n/locales/tr.d.ts +31 -0
  45. package/dist/i18n/locales/tr.js +32 -1
  46. package/dist/i18n/locales/zh.d.ts +31 -0
  47. package/dist/i18n/locales/zh.js +32 -1
  48. package/dist/index.js +859 -857
  49. package/dist/locales/ar.json +32 -1
  50. package/dist/locales/de.json +32 -1
  51. package/dist/locales/el.json +32 -1
  52. package/dist/locales/en.json +32 -1
  53. package/dist/locales/es.json +32 -1
  54. package/dist/locales/fr.json +32 -1
  55. package/dist/locales/hi.json +32 -1
  56. package/dist/locales/it.json +32 -1
  57. package/dist/locales/ja.json +32 -1
  58. package/dist/locales/nl.json +32 -1
  59. package/dist/locales/pl.json +32 -1
  60. package/dist/locales/pt.json +32 -1
  61. package/dist/locales/ro.json +32 -1
  62. package/dist/locales/ru.json +32 -1
  63. package/dist/locales/sq.json +32 -1
  64. package/dist/locales/sv.json +32 -1
  65. package/dist/locales/tr.json +32 -1
  66. package/dist/locales/zh.json +32 -1
  67. package/dist/patterns/prescription/index.js +1 -1
  68. package/dist/patterns/prescription/prescription-composer.d.ts +2 -0
  69. package/dist/patterns/prescription/prescription-sheet.d.ts +7 -1
  70. package/dist/patterns/prescription/prescription-validation.d.ts +7 -3
  71. package/package.json +5 -1
  72. package/dist/_chunks/prescription-history-CD3e3U3I.js +0 -1719
@@ -0,0 +1,1773 @@
1
+ import { jsxs as v, jsx as r, Fragment as _e } from "react/jsx-runtime";
2
+ import { forwardRef as Oe, useId as ye, useState as Y, useRef as x, useEffect as $e, useCallback as P, useMemo as je, useImperativeHandle as Et } from "react";
3
+ import { c as j } from "./index-D2ZczOXr.js";
4
+ import { useTranslation as ve } from "react-i18next";
5
+ import { A as be } from "./alert-C4WKViaS.js";
6
+ import { B as ze } from "./button-Dp4j9ygh.js";
7
+ import { E as Qt } from "./empty-state-5REM7oDM.js";
8
+ import { E as Yt } from "./error-summary-DxNhwf_G.js";
9
+ import { F as Ut } from "./field-array-kwUgFOIr.js";
10
+ import { F as pe } from "./form-field-CyHfOVKF.js";
11
+ import { S as Nt } from "./select-Bw5FvGJ7.js";
12
+ import { S as De } from "./skeleton-tTWJpvAq.js";
13
+ import { P as Xt } from "./patient-picker-Dm74jHIk.js";
14
+ import { p as ct } from "./privacy-mask-text-B8YfzB7L.js";
15
+ import { u as Jt } from "./use-controllable-state-BiY4xTzM.js";
16
+ import { u as we } from "./use-isomorphic-layout-effect-BGfaCOP1.js";
17
+ import { u as Zt, a as er } from "./use-error-summary-CecJZo6w.js";
18
+ import { C as tr } from "./checkbox-DV4sNDeB.js";
19
+ import { N as rr } from "./number-input-Bi5Yk6PX.js";
20
+ import { T as nt } from "./text-input-B6iAgCr3.js";
21
+ import { M as ir } from "./medication-search-CTUtXuPT.js";
22
+ import { a as sr, S as nr } from "./suggestion-chip-BNRWZL51.js";
23
+ import { V as lt } from "./visually-hidden-BHxEUGyT.js";
24
+ import { T as ar } from "./timestamp-UMF1llBs.js";
25
+ import { I as or } from "./icon-button-u9VMQn3x.js";
26
+ import { B as cr } from "./button-group-N60L3HMa.js";
27
+ import { D as Fe } from "./dropdown-menu-Bm1KALnk.js";
28
+ import { K as lr, a as ne, S as St } from "./key-value-pair-BykhMTcP.js";
29
+ import { a as dr, M as pr } from "./medication-line-DFa5oFhf.js";
30
+ import { P as ur } from "./print-sheet-gaxObGcm.js";
31
+ import { a as mr } from "./whatsapp-button-XbozeDl_.js";
32
+ import { f as He } from "./intl-locale-FWh-Y5_3.js";
33
+ import { A as qt } from "./avatar-Dp5apm1d.js";
34
+ import { P as Ct } from "./printer-rkK0T1gi.js";
35
+ import { D as fr } from "./download-CfYKJO_j.js";
36
+ import { M as hr } from "./mail-BqXVF2zH.js";
37
+ import { M as br } from "./message-square-Bye4ATvx.js";
38
+ import { C as gr } from "./chevron-down-DWE7GSq9.js";
39
+ import { I as yr } from "./icon-button-group-DEAx9M5v.js";
40
+ import { T as vr } from "./tag-BNlcEJfE.js";
41
+ import { R as Ir } from "./row-actions-CA938TAd.js";
42
+ import { e as Nr } from "./data-grid-CujX-2tF.js";
43
+ import { D as de } from "./toolbar-z_6tE7zG.js";
44
+ import { B as Sr } from "./badge-BUk4RjTS.js";
45
+ import { C as kr } from "./check-DrFSN__t.js";
46
+ import { L as xr } from "./loader-circle-BECIU_8N.js";
47
+ import { C as Tr } from "./circle-alert-rGDZ73Wh.js";
48
+ import { E as wr } from "./eye-BjhN2nYf.js";
49
+ function $r(e, n) {
50
+ const a = {};
51
+ if (e.patientId && n.patientId && (a.patientId = e.patientId), e.prescriberId && n.prescriberId && (a.prescriberId = e.prescriberId), e.treatmentId && n.treatmentId === e.treatmentId && (a.treatmentId = e.treatmentId), e.items && n.items && (a.items = e.items), e.itemErrors) {
52
+ const h = e.itemErrors.map(
53
+ (u, S) => {
54
+ var N;
55
+ const g = (N = n.itemErrors) == null ? void 0 : N[S];
56
+ if (!u || !g) return;
57
+ const o = {};
58
+ return u.medicationId && g.medicationId && (o.medicationId = u.medicationId), u.dosage && g.dosage && (o.dosage = u.dosage), u.quantity && g.quantity && (o.quantity = u.quantity), Object.keys(o).length > 0 ? o : void 0;
59
+ }
60
+ );
61
+ h.some((u) => u !== void 0) && (a.itemErrors = h);
62
+ }
63
+ return a;
64
+ }
65
+ const Er = 5, qr = j(
66
+ "ds:@container/rxline ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
67
+ {
68
+ variants: {
69
+ separated: {
70
+ true: "ds:border-t ds:border-[color:var(--border)] ds:pt-[var(--spacing-lg)]",
71
+ false: "ds:pt-[var(--spacing-xs)]"
72
+ }
73
+ },
74
+ defaultVariants: { separated: !1 }
75
+ }
76
+ );
77
+ function Cr({
78
+ index: e,
79
+ item: n,
80
+ medication: a,
81
+ medicationFieldId: h,
82
+ dosageFieldId: u,
83
+ quantityFieldId: S,
84
+ medicationError: g,
85
+ dosageError: o,
86
+ quantityError: N,
87
+ announceMedicationError: q,
88
+ announceDosageError: k,
89
+ announceQuantityError: G,
90
+ searchMedications: L,
91
+ codeLabel: ae,
92
+ catalogueStatus: d,
93
+ onCatalogueRetry: X,
94
+ suggestions: F,
95
+ onMedicationChange: $,
96
+ onDosageChange: O,
97
+ onNotesChange: oe,
98
+ onQuantityChange: H,
99
+ onDurationChange: f,
100
+ onNotSubstitutableChange: T,
101
+ medicationSearchId: z,
102
+ medicationRef: A,
103
+ dosageInputRef: J,
104
+ onSuggestionChosen: Z
105
+ }) {
106
+ const { t: w } = ve("ui"), c = e + 1, ee = `${h}-legend`, m = F.slice(0, Er), s = `${h}-hint`;
107
+ return /* @__PURE__ */ v(
108
+ "div",
109
+ {
110
+ role: "group",
111
+ "aria-labelledby": ee,
112
+ "data-slot": "prescription-item",
113
+ "data-index": e,
114
+ className: qr({ separated: e > 0 }),
115
+ children: [
116
+ /* @__PURE__ */ r("p", { id: ee, className: "type-label ds:text-foreground", children: w("prescription.composer.medicationLegend", { number: c }) }),
117
+ /* @__PURE__ */ r(
118
+ pe,
119
+ {
120
+ id: h,
121
+ label: w("prescription.composer.medication"),
122
+ required: !0,
123
+ error: g,
124
+ announceError: q,
125
+ children: /* @__PURE__ */ r(
126
+ ir,
127
+ {
128
+ ref: A,
129
+ id: z,
130
+ loadOptions: L,
131
+ value: a,
132
+ onValueChange: $,
133
+ codeLabel: ae,
134
+ status: d,
135
+ onRetry: X
136
+ }
137
+ )
138
+ }
139
+ ),
140
+ /* @__PURE__ */ r(
141
+ pe,
142
+ {
143
+ id: u,
144
+ label: w("prescription.composer.dosage"),
145
+ required: !0,
146
+ error: o,
147
+ announceError: k,
148
+ children: /* @__PURE__ */ r(
149
+ nt,
150
+ {
151
+ ref: J,
152
+ dir: "auto",
153
+ value: n.dosage,
154
+ onChange: (b) => O(b.target.value)
155
+ }
156
+ )
157
+ }
158
+ ),
159
+ a && m.length > 0 ? /* @__PURE__ */ v(
160
+ "div",
161
+ {
162
+ "data-slot": "dosage-suggestions",
163
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]",
164
+ children: [
165
+ /* @__PURE__ */ r("p", { id: s, className: "type-body-sm ds:text-muted-foreground", children: w("prescription.composer.dosageSuggestionsHint") }),
166
+ /* @__PURE__ */ r(
167
+ sr,
168
+ {
169
+ label: w("prescription.composer.dosageSuggestions"),
170
+ "aria-describedby": s,
171
+ children: m.map((b) => /* @__PURE__ */ r(
172
+ nr,
173
+ {
174
+ value: b,
175
+ dir: "auto",
176
+ keepOnSelect: !0,
177
+ onSelect: Z,
178
+ children: b
179
+ },
180
+ b
181
+ ))
182
+ }
183
+ )
184
+ ]
185
+ }
186
+ ) : null,
187
+ /* @__PURE__ */ v("div", { className: "ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-sm)] ds:@[576px]/rxline:grid-cols-[minmax(8rem,10rem)_minmax(0,1fr)_minmax(0,1fr)]", children: [
188
+ /* @__PURE__ */ r(
189
+ pe,
190
+ {
191
+ id: S,
192
+ label: w("prescription.composer.quantity"),
193
+ required: !0,
194
+ description: a == null ? void 0 : a.packsHint,
195
+ error: N,
196
+ announceError: G,
197
+ children: /* @__PURE__ */ r(
198
+ rr,
199
+ {
200
+ min: 1,
201
+ max: a == null ? void 0 : a.maxPacks,
202
+ step: 1,
203
+ value: Number.isFinite(n.quantity) ? n.quantity : null,
204
+ onChange: (b) => H(b ?? Number.NaN)
205
+ }
206
+ )
207
+ }
208
+ ),
209
+ /* @__PURE__ */ r(pe, { label: w("prescription.composer.notes"), optional: !0, children: /* @__PURE__ */ r(
210
+ nt,
211
+ {
212
+ dir: "auto",
213
+ value: n.notes,
214
+ onChange: (b) => oe(b.target.value)
215
+ }
216
+ ) }),
217
+ /* @__PURE__ */ r(pe, { label: w("prescription.composer.duration"), optional: !0, children: /* @__PURE__ */ r(
218
+ nt,
219
+ {
220
+ dir: "auto",
221
+ value: n.duration,
222
+ onChange: (b) => f(b.target.value)
223
+ }
224
+ ) })
225
+ ] }),
226
+ /* @__PURE__ */ r(
227
+ tr,
228
+ {
229
+ label: w("prescription.composer.notSubstitutable"),
230
+ checked: n.notSubstitutable,
231
+ disabled: !(a != null && a.code) && !n.notSubstitutable,
232
+ disabledReason: w("prescription.composer.notSubstitutableNeedsCode"),
233
+ onCheckedChange: (b) => T(b === !0)
234
+ }
235
+ )
236
+ ]
237
+ }
238
+ );
239
+ }
240
+ const Pr = /^(\d{4})-(\d{2})-(\d{2})$/;
241
+ function Ar(e, n) {
242
+ const a = Pr.exec(e);
243
+ if (!a) return e;
244
+ const h = Number(a[1]), u = Number(a[2]), S = Number(a[3]), g = new Date(2e3, u - 1, S);
245
+ return g.setFullYear(h), Number.isNaN(g.getTime()) || g.getMonth() !== u - 1 || g.getDate() !== S ? e : new Intl.DateTimeFormat(He(n), {
246
+ dateStyle: "long"
247
+ }).format(g);
248
+ }
249
+ function Re(e) {
250
+ return e !== void 0 && e.trim() !== "";
251
+ }
252
+ const Mr = j("ds:@container/pblock ds:flex ds:items-start", {
253
+ variants: {
254
+ density: {
255
+ default: "ds:gap-[var(--spacing-md)]",
256
+ compact: "ds:gap-[var(--spacing-sm)]"
257
+ }
258
+ },
259
+ defaultVariants: { density: "default" }
260
+ }), dt = Oe(
261
+ ({
262
+ patient: e,
263
+ privacyMode: n = !1,
264
+ density: a = "default",
265
+ showAvatar: h = !1,
266
+ className: u,
267
+ ...S
268
+ }, g) => {
269
+ const { t: o, i18n: N } = ve("ui"), q = () => /* @__PURE__ */ v(_e, { children: [
270
+ /* @__PURE__ */ r(lt, { children: o("calendarWorkspace.privacy.hidden") }),
271
+ /* @__PURE__ */ r("span", { "aria-hidden": "true", children: ct() })
272
+ ] }), k = [];
273
+ Re(e.firstName) && k.push({
274
+ key: "firstName",
275
+ label: o("prescription.patient.firstName"),
276
+ value: n ? q() : /* @__PURE__ */ r("span", { dir: "auto", children: e.firstName })
277
+ }), Re(e.lastName) && k.push({
278
+ key: "lastName",
279
+ label: o("prescription.patient.lastName"),
280
+ value: n ? q() : /* @__PURE__ */ r("span", { dir: "auto", children: e.lastName })
281
+ }), Re(e.dateOfBirth) && k.push({
282
+ key: "dateOfBirth",
283
+ label: o("prescription.patient.dateOfBirth"),
284
+ value: n ? q() : Ar(e.dateOfBirth, N.language)
285
+ }), Re(e.fiscalCode) && k.push({
286
+ key: "fiscalCode",
287
+ label: o("prescription.patient.fiscalCode"),
288
+ value: n ? q() : e.fiscalCode,
289
+ mono: !0
290
+ });
291
+ const G = `${e.firstName} ${e.lastName}`.trim();
292
+ return /* @__PURE__ */ v(
293
+ "div",
294
+ {
295
+ ...S,
296
+ ref: g,
297
+ role: "group",
298
+ "aria-label": o("prescription.patient.details"),
299
+ className: Mr({ density: a, className: u }),
300
+ "data-component": "prescription-patient-block",
301
+ "data-density": a,
302
+ "data-privacy": n ? "masked" : void 0,
303
+ children: [
304
+ h ? (
305
+ /* Under privacy mode the avatar shows no initials: an empty name
306
+ gives the Avatar's own neutral icon, at the same size. */
307
+ /* @__PURE__ */ r(
308
+ qt,
309
+ {
310
+ name: n ? "" : G,
311
+ size: "md",
312
+ className: "ds:shrink-0",
313
+ "aria-hidden": "true",
314
+ role: "presentation",
315
+ "aria-label": void 0
316
+ }
317
+ )
318
+ ) : null,
319
+ /* @__PURE__ */ r(
320
+ lr,
321
+ {
322
+ semantic: !0,
323
+ rowGap: a === "compact" ? "sm" : "md",
324
+ className: "ds:min-w-0 ds:flex-1 ds:@[448px]/pblock:grid-cols-[repeat(2,auto_fit-content(40%)_minmax(0,1fr))]",
325
+ children: k.map((L) => /* @__PURE__ */ r(
326
+ ne,
327
+ {
328
+ label: L.label,
329
+ value: L.value,
330
+ mono: L.mono,
331
+ "data-field": L.key
332
+ },
333
+ L.key
334
+ ))
335
+ }
336
+ )
337
+ ]
338
+ }
339
+ );
340
+ }
341
+ );
342
+ dt.displayName = "PrescriptionPatientBlock";
343
+ const Ge = Object.freeze({
344
+ medicationId: "",
345
+ dosage: "",
346
+ notes: "",
347
+ quantity: 1,
348
+ notSubstitutable: !1,
349
+ duration: ""
350
+ });
351
+ function Lr(e = "") {
352
+ return {
353
+ patientId: "",
354
+ prescriberId: e,
355
+ treatmentId: "",
356
+ items: [{ ...Ge }]
357
+ };
358
+ }
359
+ function U(e) {
360
+ return e == null || e.trim() === "";
361
+ }
362
+ function ot(e) {
363
+ return U(e.medicationId) && U(e.dosage) && U(e.notes) && U(e.duration) && !e.notSubstitutable;
364
+ }
365
+ function Vr(e, n) {
366
+ if (typeof e != "number" || Number.isNaN(e)) return "required";
367
+ if (!Number.isInteger(e) || e < 1) return "invalid";
368
+ if (n !== void 0 && e > n) return "tooMany";
369
+ }
370
+ function Dr(e, {
371
+ treatmentOptions: n,
372
+ treatmentOptionsPatientId: a
373
+ }) {
374
+ if (U(e.treatmentId)) return "required";
375
+ if (a !== void 0 && a !== e.patientId || n && !n.some((h) => h.id === e.treatmentId))
376
+ return "invalid";
377
+ }
378
+ function kt(e, n = {}) {
379
+ const a = {};
380
+ U(e.patientId) && (a.patientId = "required"), U(e.prescriberId) && (a.prescriberId = "required");
381
+ const h = Dr(e, n);
382
+ h && (a.treatmentId = h);
383
+ const u = e.items ?? [];
384
+ if (u.filter((o) => !ot(o)).length === 0)
385
+ return a.items = "required", u.length > 0 && (a.itemErrors = u.map(
386
+ (o, N) => N === 0 ? { medicationId: "required" } : void 0
387
+ )), a;
388
+ const g = u.map((o) => {
389
+ var k;
390
+ if (ot(o)) return;
391
+ const N = {};
392
+ U(o.medicationId) && (N.medicationId = "required"), U(o.dosage) && (N.dosage = "required");
393
+ const q = Vr(
394
+ o.quantity,
395
+ U(o.medicationId) || (k = n.maxPacksFor) == null ? void 0 : k.call(n, o.medicationId.trim())
396
+ );
397
+ return q && (N.quantity = q), Object.keys(N).length > 0 ? N : void 0;
398
+ });
399
+ return g.some((o) => o !== void 0) && (a.itemErrors = g), a;
400
+ }
401
+ function xt(e) {
402
+ return Object.keys(e).length === 0;
403
+ }
404
+ function Fr(e) {
405
+ return {
406
+ patientId: e.patientId.trim(),
407
+ prescriberId: e.prescriberId.trim(),
408
+ treatmentId: e.treatmentId.trim(),
409
+ items: e.items.filter((n) => !ot(n)).map((n) => ({
410
+ medicationId: n.medicationId.trim(),
411
+ dosage: n.dosage.trim(),
412
+ notes: n.notes.trim(),
413
+ quantity: n.quantity,
414
+ notSubstitutable: n.notSubstitutable,
415
+ duration: (n.duration ?? "").trim()
416
+ }))
417
+ };
418
+ }
419
+ const Rr = j(
420
+ "ds:flex ds:w-full ds:flex-col ds:gap-[var(--spacing-lg)]"
421
+ );
422
+ function at(e) {
423
+ return `${e.firstName} ${e.lastName}`.trim();
424
+ }
425
+ function Tt(e) {
426
+ return e.items.length > 0 ? e : { ...e, items: [{ ...Ge }] };
427
+ }
428
+ const zr = Oe(function({
429
+ patients: n,
430
+ searchPatients: a,
431
+ treatmentOptions: h,
432
+ treatmentOptionsPatientId: u,
433
+ prescribers: S,
434
+ defaultPrescriberId: g,
435
+ searchMedications: o,
436
+ resolveMedication: N,
437
+ suggestDosages: q,
438
+ codeLabel: k,
439
+ catalogueStatus: G = "ready",
440
+ onCatalogueRetry: L,
441
+ value: ae,
442
+ defaultValue: d,
443
+ onChange: X,
444
+ onSubmit: F,
445
+ onPatientChange: $,
446
+ loading: O = !1,
447
+ error: oe,
448
+ privacyMode: H = !1,
449
+ lockPatient: f = !1,
450
+ editing: T = !1,
451
+ submitLabel: z,
452
+ id: A,
453
+ className: J,
454
+ ...Z
455
+ }, w) {
456
+ const { t: c } = ve("ui"), ee = ye(), m = A ?? ee, [s] = Y(
457
+ () => d ?? Lr(
458
+ g && S.some((t) => t.id === g) ? g : ""
459
+ )
460
+ ), [b, V] = Jt({
461
+ value: ae,
462
+ defaultValue: s,
463
+ onChange: X
464
+ }), B = Tt(b ?? s), E = x(B);
465
+ we(() => {
466
+ E.current = B;
467
+ });
468
+ const [R, K] = Y({}), [Ee, te] = Y(!1), [Ie, re] = Y(!1), ue = x(!1), D = x(!0);
469
+ $e(() => (D.current = !0, () => {
470
+ D.current = !1;
471
+ }), []);
472
+ const [Ke, We] = Y(() => /* @__PURE__ */ new Map()), [W, qe] = Y(() => /* @__PURE__ */ new Map()), Ne = x(/* @__PURE__ */ new Map()), me = x(N);
473
+ we(() => {
474
+ me.current = N;
475
+ });
476
+ const fe = P(
477
+ (t) => {
478
+ var i, l;
479
+ return (l = Ne.current.get(t) ?? ((i = me.current) == null ? void 0 : i.call(me, t))) == null ? void 0 : l.maxPacks;
480
+ },
481
+ []
482
+ ), y = P(
483
+ (t) => {
484
+ for (const i of t) Ne.current.set(i.id, i);
485
+ qe((i) => {
486
+ if (t.every((p) => i.get(p.id) === p)) return i;
487
+ const l = new Map(i);
488
+ for (const p of t) l.set(p.id, p);
489
+ return l;
490
+ });
491
+ },
492
+ []
493
+ ), he = x(o);
494
+ we(() => {
495
+ he.current = o;
496
+ });
497
+ const Se = P(
498
+ async (t, i) => {
499
+ const l = await he.current(t, i);
500
+ return i.signal.aborted || y(l), l;
501
+ },
502
+ [y]
503
+ ), ke = x(a);
504
+ we(() => {
505
+ ke.current = a;
506
+ });
507
+ const Ce = a !== void 0, At = je(() => {
508
+ if (Ce)
509
+ return async (t, i) => {
510
+ const l = ke.current, p = l ? await l(t, i) : [];
511
+ return i.signal.aborted || We((M) => {
512
+ const Q = new Map(M);
513
+ for (const le of p) Q.set(le.id, le);
514
+ return Q;
515
+ }), p.map((M) => ({ id: M.id, name: at(M) }));
516
+ };
517
+ }, [Ce]), ce = B.patientId, xe = ce ? (n == null ? void 0 : n.find((t) => t.id === ce)) ?? Ke.get(ce) : void 0, C = P(
518
+ (t) => {
519
+ E.current = t, V(t), K(
520
+ (i) => Object.keys(i).length === 0 ? i : $r(
521
+ i,
522
+ kt(t, {
523
+ treatmentOptions: h,
524
+ treatmentOptionsPatientId: u,
525
+ maxPacksFor: fe
526
+ })
527
+ )
528
+ );
529
+ },
530
+ [V, h, u, fe]
531
+ ), Qe = P(
532
+ (t) => {
533
+ const i = E.current;
534
+ t !== i.patientId && (K({}), te(!1), C({
535
+ patientId: t,
536
+ prescriberId: i.prescriberId,
537
+ treatmentId: "",
538
+ items: [{ ...Ge }]
539
+ }), $ == null || $(t));
540
+ },
541
+ [C, $]
542
+ ), pt = x(!1), Ye = P(
543
+ (t) => {
544
+ pt.current = !0, C({ ...E.current, prescriberId: t });
545
+ },
546
+ [C]
547
+ ), ut = x(!1);
548
+ $e(() => {
549
+ if (ut.current || pt.current || !g || !S.some((i) => i.id === g))
550
+ return;
551
+ ut.current = !0;
552
+ const t = E.current;
553
+ t.prescriberId === "" && C({ ...t, prescriberId: g });
554
+ }, [g, S, C]);
555
+ const Ue = P(
556
+ (t) => C({ ...E.current, treatmentId: t }),
557
+ [C]
558
+ ), ie = P(
559
+ (t, i) => {
560
+ const l = E.current;
561
+ t < 0 || t >= l.items.length || C({
562
+ ...l,
563
+ items: l.items.map((p, M) => {
564
+ if (M !== t) return p;
565
+ const Q = i.medicationId !== void 0 && i.medicationId !== p.medicationId;
566
+ return {
567
+ ...p,
568
+ ...Q ? { notSubstitutable: !1 } : {},
569
+ ...i
570
+ };
571
+ })
572
+ });
573
+ },
574
+ [C]
575
+ ), Xe = P(
576
+ (t) => {
577
+ const i = E.current;
578
+ return C({
579
+ ...i,
580
+ items: [...i.items, { ...Ge, ...t }]
581
+ }), i.items.length;
582
+ },
583
+ [C]
584
+ ), Je = P(
585
+ (t) => {
586
+ const i = E.current;
587
+ i.items.length <= 1 || t < 0 || t >= i.items.length || C({
588
+ ...i,
589
+ items: i.items.filter((l, p) => p !== t)
590
+ });
591
+ },
592
+ [C]
593
+ ), mt = x(null), Ze = x(/* @__PURE__ */ new Map()), et = x(/* @__PURE__ */ new Map()), [ge, Pe] = Y(null);
594
+ $e(() => {
595
+ var t, i, l, p;
596
+ ge && (ge.kind === "medication" ? (t = Ze.current.get(ge.index)) == null || t.focus() : ge.kind === "dosage" ? (i = et.current.get(ge.index)) == null || i.focus() : (p = (l = document.getElementById(`${m}-items`)) == null ? void 0 : l.querySelector(":scope > button")) == null || p.focus(), Pe(null));
597
+ }, [ge, m]);
598
+ const Mt = (t) => {
599
+ const i = E.current.items.length;
600
+ Je(t), !(i <= 1) && Pe(
601
+ i - 1 === 1 ? { kind: "add" } : { kind: "medication", index: Math.min(t, i - 2) }
602
+ );
603
+ }, ft = (t) => {
604
+ var i;
605
+ return c("prescription.composer.errors.quantityMax", {
606
+ max: fe(((i = B.items[t]) == null ? void 0 : i.medicationId) ?? "")
607
+ });
608
+ }, se = (t) => {
609
+ var M;
610
+ if (t === "patient")
611
+ return R.patientId ? c("prescription.composer.errors.patient") : void 0;
612
+ if (t === "prescriber")
613
+ return R.prescriberId ? c("prescription.composer.errors.prescriber") : void 0;
614
+ if (t === "treatment")
615
+ return R.treatmentId ? R.treatmentId === "invalid" ? c("prescription.composer.errors.treatmentInvalid") : c("prescription.composer.errors.treatment") : void 0;
616
+ if (t === "items")
617
+ return R.items ? c("prescription.composer.errors.items") : void 0;
618
+ const [i, l] = t.split(":"), p = (M = R.itemErrors) == null ? void 0 : M[Number(l)];
619
+ return i === "medication" ? p != null && p.medicationId && !R.items ? c("prescription.composer.errors.medication") : void 0 : i === "quantity" ? p != null && p.quantity ? p.quantity === "tooMany" ? ft(Number(l)) : p.quantity === "invalid" ? c("prescription.composer.errors.quantityInvalid") : c("prescription.composer.errors.quantity") : void 0 : p != null && p.dosage ? c("prescription.composer.errors.dosage") : void 0;
620
+ }, Lt = [
621
+ "patient",
622
+ "treatment",
623
+ "prescriber",
624
+ "items",
625
+ ...B.items.flatMap((t, i) => [
626
+ `medication:${i}`,
627
+ `dosage:${i}`,
628
+ `quantity:${i}`
629
+ ])
630
+ ], _ = Zt(Lt, se), ht = _.listed.length > 0, Vt = (t) => {
631
+ if (t === "items") return `${m}-medication-0`;
632
+ const [i, l] = t.split(":");
633
+ return l === void 0 ? `${m}-${t}` : `${m}-${i}-${l}`;
634
+ }, Dt = (t) => {
635
+ var p, M, Q, le;
636
+ const [i, l] = t.split(":");
637
+ return i === "medication" ? c("prescription.composer.errors.medicationLine", {
638
+ number: Number(l) + 1
639
+ }) : i === "dosage" ? c("prescription.composer.errors.dosageLine", {
640
+ number: Number(l) + 1
641
+ }) : i === "quantity" ? ((M = (p = R.itemErrors) == null ? void 0 : p[Number(l)]) == null ? void 0 : M.quantity) === "tooMany" ? ft(Number(l)) : ((le = (Q = R.itemErrors) == null ? void 0 : Q[Number(l)]) == null ? void 0 : le.quantity) === "invalid" ? c("prescription.composer.errors.quantityInvalidLine", {
642
+ number: Number(l) + 1
643
+ }) : c("prescription.composer.errors.quantityLine", {
644
+ number: Number(l) + 1
645
+ }) : se(t) ?? "";
646
+ }, Ae = P(
647
+ (t) => {
648
+ K(t), _.open();
649
+ },
650
+ // eslint-disable-next-line react-hooks/exhaustive-deps
651
+ [_.open]
652
+ ), Me = P(
653
+ () => kt(E.current, {
654
+ treatmentOptions: h,
655
+ treatmentOptionsPatientId: u,
656
+ maxPacksFor: fe
657
+ }),
658
+ [h, u, fe]
659
+ ), bt = x(F);
660
+ we(() => {
661
+ bt.current = F;
662
+ });
663
+ const tt = P(async () => {
664
+ if (ue.current) return;
665
+ const t = Me();
666
+ if (!xt(t)) {
667
+ Ae(t);
668
+ return;
669
+ }
670
+ K({}), te(!1), ue.current = !0, re(!0);
671
+ try {
672
+ return await bt.current(
673
+ Fr(E.current)
674
+ ) ?? void 0;
675
+ } catch {
676
+ D.current && te(!0);
677
+ return;
678
+ } finally {
679
+ ue.current = !1, D.current && re(!1);
680
+ }
681
+ }, [Me, Ae]), gt = P(() => {
682
+ const t = E.current;
683
+ K({}), te(!1), C(Tt(s)), t.patientId !== s.patientId && ($ == null || $(s.patientId));
684
+ }, [C, s, $]);
685
+ Et(
686
+ w,
687
+ () => ({
688
+ getDraft: () => E.current,
689
+ setPatient: Qe,
690
+ setPrescriber: Ye,
691
+ setTreatment: Ue,
692
+ addItem: Xe,
693
+ updateItem: ie,
694
+ removeItem: Je,
695
+ validate: () => {
696
+ const t = Me();
697
+ return xt(t) ? K({}) : Ae(t), t;
698
+ },
699
+ submit: tt,
700
+ reset: gt,
701
+ focusTitle: () => {
702
+ var t;
703
+ return (t = mt.current) == null ? void 0 : t.focus();
704
+ }
705
+ }),
706
+ [
707
+ Qe,
708
+ Ye,
709
+ Ue,
710
+ Xe,
711
+ ie,
712
+ Je,
713
+ Me,
714
+ Ae,
715
+ tt,
716
+ gt
717
+ ]
718
+ );
719
+ const Le = oe ?? (Ee ? c("prescription.composer.errors.submit") : void 0), Ft = er(Le, ht), Rt = f && xe !== void 0, yt = `${m}-message`, [zt, Bt] = Y("");
720
+ $e(() => {
721
+ Bt(O ? c("prescription.composer.loading") : "");
722
+ }, [O, c]);
723
+ const _t = {
724
+ ...Z,
725
+ "data-component": "prescription-composer",
726
+ "data-component-id": A,
727
+ "data-has-patient": ce !== "" ? !0 : void 0,
728
+ "data-submitting": Ie ? !0 : void 0
729
+ }, jt = Rr({ className: J }), Gt = (n ?? []).map((t) => ({
730
+ id: t.id,
731
+ name: at(t)
732
+ })), Ot = !H && xe ? at(xe) : void 0, rt = u !== void 0 && u !== ce, Ve = rt ? [] : h ?? [], Te = [];
733
+ for (const t of Ve)
734
+ t.carePlan && !Te.some((i) => {
735
+ var l;
736
+ return i.id === ((l = t.carePlan) == null ? void 0 : l.id);
737
+ }) && Te.push(t.carePlan);
738
+ const Ht = (t) => {
739
+ const i = Te.filter((p) => p.label === t.label), l = i.length > 1 ? `${t.label} (${i.findIndex((p) => p.id === t.id) + 1})` : t.label;
740
+ return c("prescription.composer.carePlanGroup", {
741
+ label: `⁨${l}⁩`
742
+ });
743
+ }, it = (t, i) => ({
744
+ value: t.id,
745
+ label: t.label,
746
+ group: i,
747
+ dir: "auto"
748
+ }), vt = Te.length === 0 ? Ve.map((t) => it(t, void 0)) : [
749
+ ...Te.flatMap(
750
+ (t) => Ve.filter((i) => {
751
+ var l;
752
+ return ((l = i.carePlan) == null ? void 0 : l.id) === t.id;
753
+ }).map((i) => it(i, Ht(t)))
754
+ ),
755
+ ...Ve.filter((t) => !t.carePlan).map(
756
+ (t) => it(
757
+ t,
758
+ c("prescription.composer.treatmentsStandalone")
759
+ )
760
+ )
761
+ ], Kt = S.map((t) => ({
762
+ value: t.id,
763
+ label: t.name,
764
+ description: t.specialty,
765
+ dir: "auto"
766
+ })), Wt = (t) => {
767
+ t.preventDefault(), tt();
768
+ }, It = Le ? /* @__PURE__ */ r(be, { id: yt, variant: "error", announce: Ft, children: /* @__PURE__ */ r(be.Description, { children: Le }) }) : null;
769
+ return /* @__PURE__ */ v("div", { ..._t, className: jt, children: [
770
+ /* @__PURE__ */ r("div", { role: "status", className: "ds:sr-only", children: zt }),
771
+ O ? /* @__PURE__ */ v(
772
+ "div",
773
+ {
774
+ "aria-hidden": "true",
775
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]",
776
+ children: [
777
+ /* @__PURE__ */ r(De, { variant: "rounded", size: "sm" }),
778
+ /* @__PURE__ */ r(De, { variant: "text", lines: 3 }),
779
+ /* @__PURE__ */ r(De, { variant: "rounded", size: "sm" }),
780
+ /* @__PURE__ */ r(De, { variant: "rounded", size: "lg" })
781
+ ]
782
+ }
783
+ ) : /* @__PURE__ */ v(
784
+ "form",
785
+ {
786
+ noValidate: !0,
787
+ onSubmit: Wt,
788
+ "aria-labelledby": `${m}-title`,
789
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]",
790
+ children: [
791
+ /* @__PURE__ */ r(
792
+ "h2",
793
+ {
794
+ ref: mt,
795
+ id: `${m}-title`,
796
+ tabIndex: -1,
797
+ className: "type-title-section ds:m-0 ds:focus:outline-none",
798
+ children: c(T ? "prescription.composer.editTitle" : "prescription.composer.title")
799
+ }
800
+ ),
801
+ ht ? /* @__PURE__ */ r(
802
+ Yt,
803
+ {
804
+ ref: _.ref,
805
+ title: c("prescription.composer.errorTitle"),
806
+ headingLevel: 3,
807
+ "aria-describedby": Le ? yt : void 0,
808
+ errors: _.listed.map((t) => ({
809
+ field: t,
810
+ message: Dt(t),
811
+ targetId: Vt(t)
812
+ }))
813
+ }
814
+ ) : null,
815
+ Rt ? null : /* @__PURE__ */ r(
816
+ pe,
817
+ {
818
+ id: `${m}-patient`,
819
+ label: c("prescription.composer.patient"),
820
+ required: !0,
821
+ description: H && ce !== "" ? c("calendarWorkspace.privacy.hidden") : void 0,
822
+ error: se("patient"),
823
+ announceError: !_.lists("patient"),
824
+ children: /* @__PURE__ */ r(
825
+ Xt,
826
+ {
827
+ value: ce,
828
+ onValueChange: Qe,
829
+ patients: Gt,
830
+ searchPatients: At,
831
+ selectedLabel: Ot,
832
+ privacyMask: H ? ct() : void 0,
833
+ placeholder: c("prescription.composer.patientPlaceholder")
834
+ }
835
+ )
836
+ }
837
+ ),
838
+ ce === "" ? /* @__PURE__ */ v(_e, { children: [
839
+ /* @__PURE__ */ r(
840
+ Qt,
841
+ {
842
+ variant: "first-use",
843
+ size: "sm",
844
+ title: c("prescription.composer.choosePatientTitle"),
845
+ description: c("prescription.composer.choosePatientBody")
846
+ }
847
+ ),
848
+ It
849
+ ] }) : /* @__PURE__ */ v(_e, { children: [
850
+ xe ? /* @__PURE__ */ r(
851
+ dt,
852
+ {
853
+ patient: xe,
854
+ privacyMode: H,
855
+ showAvatar: !0
856
+ }
857
+ ) : null,
858
+ /* @__PURE__ */ r(
859
+ pe,
860
+ {
861
+ id: `${m}-treatment`,
862
+ label: c("prescription.composer.treatment"),
863
+ required: !0,
864
+ description: vt.length === 0 && !rt ? c("prescription.composer.treatmentEmpty") : void 0,
865
+ error: se("treatment"),
866
+ announceError: !_.lists("treatment"),
867
+ children: /* @__PURE__ */ r(
868
+ Nt,
869
+ {
870
+ options: vt,
871
+ value: B.treatmentId,
872
+ onValueChange: Ue,
873
+ id: `${m}-treatment-select`,
874
+ disabled: rt,
875
+ placeholder: c("prescription.composer.treatmentPlaceholder")
876
+ }
877
+ )
878
+ }
879
+ ),
880
+ /* @__PURE__ */ r(
881
+ pe,
882
+ {
883
+ id: `${m}-prescriber`,
884
+ label: c("prescription.composer.prescriber"),
885
+ required: !0,
886
+ error: se("prescriber"),
887
+ announceError: !_.lists("prescriber"),
888
+ children: /* @__PURE__ */ r(
889
+ Nt,
890
+ {
891
+ options: Kt,
892
+ value: B.prescriberId,
893
+ onValueChange: Ye,
894
+ id: `${m}-prescriber-select`,
895
+ placeholder: c("prescription.composer.prescriberPlaceholder"),
896
+ showDescriptions: !0
897
+ }
898
+ )
899
+ }
900
+ ),
901
+ /* @__PURE__ */ r(
902
+ Ut,
903
+ {
904
+ id: `${m}-items`,
905
+ className: "ds:gap-[var(--spacing-lg)] ds:[&>legend]:[--type-label-size:var(--type-title-item-size)] ds:[&>legend]:[--type-label-weight:var(--type-title-item-weight)] ds:[&>legend]:[--type-label-line-height:var(--type-title-item-line-height)]",
906
+ legend: c("prescription.composer.medications"),
907
+ items: B.items,
908
+ min: 1,
909
+ addLabel: c("prescription.composer.addMedication"),
910
+ removeItemLabel: (t) => c("prescription.composer.removeMedication", {
911
+ number: t + 1
912
+ }),
913
+ onAdd: () => {
914
+ const t = Xe();
915
+ Pe({ kind: "medication", index: t });
916
+ },
917
+ onRemove: Mt,
918
+ renderItem: (t, i) => {
919
+ const l = t.medicationId ? W.get(t.medicationId) ?? (N == null ? void 0 : N(t.medicationId)) ?? null : null, p = `medication:${i}`, M = `dosage:${i}`, Q = `quantity:${i}`, le = i === 0 ? se("items") : void 0;
920
+ return /* @__PURE__ */ r(
921
+ Cr,
922
+ {
923
+ index: i,
924
+ item: t,
925
+ medication: l,
926
+ medicationFieldId: `${m}-medication-${i}`,
927
+ dosageFieldId: `${m}-dosage-${i}`,
928
+ quantityFieldId: `${m}-quantity-${i}`,
929
+ medicationError: le ?? se(p),
930
+ dosageError: se(M),
931
+ quantityError: se(Q),
932
+ announceMedicationError: !_.lists(le ? "items" : p),
933
+ announceDosageError: !_.lists(M),
934
+ announceQuantityError: !_.lists(Q),
935
+ searchMedications: Se,
936
+ codeLabel: k,
937
+ catalogueStatus: G,
938
+ onCatalogueRetry: L,
939
+ suggestions: l && q ? q(l) : [],
940
+ onMedicationChange: (I) => {
941
+ I && y([I]);
942
+ const st = I == null ? void 0 : I.maxPacks;
943
+ ie(i, {
944
+ medicationId: (I == null ? void 0 : I.id) ?? "",
945
+ ...st !== void 0 && t.quantity > st ? { quantity: st } : {}
946
+ });
947
+ },
948
+ onDosageChange: (I) => ie(i, { dosage: I }),
949
+ onNotesChange: (I) => ie(i, { notes: I }),
950
+ onQuantityChange: (I) => ie(i, { quantity: I }),
951
+ onDurationChange: (I) => ie(i, { duration: I }),
952
+ onNotSubstitutableChange: (I) => ie(i, { notSubstitutable: I }),
953
+ medicationSearchId: `${m}-medication-${i}-search`,
954
+ medicationRef: (I) => {
955
+ I ? Ze.current.set(i, I) : Ze.current.delete(i);
956
+ },
957
+ dosageInputRef: (I) => {
958
+ I ? et.current.set(i, I) : et.current.delete(i);
959
+ },
960
+ onSuggestionChosen: (I) => {
961
+ ie(i, { dosage: I }), Pe({ kind: "dosage", index: i });
962
+ }
963
+ }
964
+ );
965
+ }
966
+ }
967
+ ),
968
+ It,
969
+ /* @__PURE__ */ r(
970
+ ze,
971
+ {
972
+ type: "submit",
973
+ loading: Ie,
974
+ className: "ds:self-start ds:min-h-[var(--min-target-size)]",
975
+ children: z ?? c("prescription.composer.save")
976
+ }
977
+ )
978
+ ] })
979
+ ]
980
+ }
981
+ )
982
+ ] });
983
+ });
984
+ zr.displayName = "PrescriptionComposer";
985
+ const Br = {
986
+ sent: "success",
987
+ sending: "info",
988
+ failed: "error"
989
+ };
990
+ function Pt({
991
+ status: e
992
+ }) {
993
+ const { t: n } = ve("ui"), a = e === "sent" ? /* @__PURE__ */ r(kr, { "aria-hidden": "true" }) : e === "sending" ? /* @__PURE__ */ r(
994
+ xr,
995
+ {
996
+ "aria-hidden": "true",
997
+ className: "ds:animate-spin ds:motion-reduce:animate-none"
998
+ }
999
+ ) : /* @__PURE__ */ r(Tr, { "aria-hidden": "true" });
1000
+ return /* @__PURE__ */ r(Sr, { size: "sm", variant: Br[e], leading: a, children: n(e === "sent" ? "prescription.status.sent" : e === "sending" ? "prescription.status.sending" : "prescription.status.failed") });
1001
+ }
1002
+ const _r = j("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]"), jr = j("ds:flex ds:flex-col", {
1003
+ variants: {
1004
+ density: {
1005
+ default: "ds:gap-[var(--spacing-lg)]",
1006
+ compact: "ds:gap-[var(--spacing-md)]"
1007
+ }
1008
+ },
1009
+ defaultVariants: { density: "default" }
1010
+ });
1011
+ function Gr(e) {
1012
+ if (typeof globalThis.reportError == "function") {
1013
+ globalThis.reportError(e);
1014
+ return;
1015
+ }
1016
+ setTimeout(() => {
1017
+ throw e;
1018
+ }, 0);
1019
+ }
1020
+ function Or({
1021
+ label: e,
1022
+ items: n,
1023
+ blocked: a,
1024
+ describedBy: h,
1025
+ ...u
1026
+ }) {
1027
+ const [S, g] = Y(!1);
1028
+ return /* @__PURE__ */ v(
1029
+ Fe.Root,
1030
+ {
1031
+ open: S && !a,
1032
+ onOpenChange: (o) => g(o && !a),
1033
+ children: [
1034
+ /* @__PURE__ */ r(Fe.Trigger, { asChild: !0, children: /* @__PURE__ */ r(
1035
+ or,
1036
+ {
1037
+ ...u,
1038
+ icon: /* @__PURE__ */ r(gr, { "aria-hidden": "true" }),
1039
+ "aria-label": e,
1040
+ "aria-haspopup": "menu",
1041
+ "aria-disabled": a || void 0,
1042
+ "aria-describedby": h,
1043
+ "data-action": "moreActions",
1044
+ className: "ds:min-h-[var(--min-target-size)] ds:min-w-[var(--min-target-size)]"
1045
+ }
1046
+ ) }),
1047
+ /* @__PURE__ */ r(Fe.Content, { align: "end", children: n.map((o) => /* @__PURE__ */ r(
1048
+ Fe.Item,
1049
+ {
1050
+ startIcon: o.icon,
1051
+ "data-action": o.action,
1052
+ "aria-busy": o.busy || void 0,
1053
+ onSelect: () => {
1054
+ o.busy || o.run();
1055
+ },
1056
+ children: o.label
1057
+ },
1058
+ o.action
1059
+ )) })
1060
+ ]
1061
+ }
1062
+ );
1063
+ }
1064
+ function Hr(e) {
1065
+ return typeof e == "object" && e !== null && typeof e.then == "function";
1066
+ }
1067
+ const Kr = Oe(
1068
+ ({
1069
+ record: e,
1070
+ practiceHeader: n,
1071
+ size: a = "a4",
1072
+ density: h = "default",
1073
+ codeLabel: u,
1074
+ privacyMode: S = !1,
1075
+ isolateBrowserPrint: g = !1,
1076
+ numberLabel: o,
1077
+ pinLabel: N,
1078
+ printMode: q,
1079
+ onPrint: k,
1080
+ onDownloadPdf: G,
1081
+ onSendEmail: L,
1082
+ onSendSms: ae,
1083
+ onSendWhatsApp: d,
1084
+ onResend: X,
1085
+ onEdit: F,
1086
+ id: $,
1087
+ className: O,
1088
+ ...oe
1089
+ }, H) => {
1090
+ const { t: f, i18n: T } = ve("ui"), z = He(T.language), A = x(null), J = ye(), Z = ye(), w = ye(), c = ye(), ee = ye(), m = e.sendStatus, s = m === "sending" || m === "failed", V = (q ?? (m ? "host" : "sheet")) === "host", B = x(() => {
1091
+ }), E = x(V);
1092
+ E.current = V;
1093
+ const R = x(s);
1094
+ R.current = s;
1095
+ const K = x(e);
1096
+ K.current = e;
1097
+ const Ee = je(
1098
+ () => ({
1099
+ print: () => {
1100
+ var y;
1101
+ R.current || (E.current ? B.current() : (y = A.current) == null || y.print());
1102
+ },
1103
+ getRecordId: () => K.current.id,
1104
+ focusTitle: () => {
1105
+ var y;
1106
+ return (y = A.current) == null ? void 0 : y.focusTitle();
1107
+ }
1108
+ }),
1109
+ []
1110
+ );
1111
+ Et(H, () => Ee, [Ee]);
1112
+ const [te, Ie] = Y(() => /* @__PURE__ */ new Set()), re = x(/* @__PURE__ */ new Set()), ue = x(!0);
1113
+ $e(() => (ue.current = !0, () => {
1114
+ ue.current = !1;
1115
+ }), []);
1116
+ const D = P(
1117
+ (y, he) => {
1118
+ if (!he || re.current.has(y) || R.current && y !== "resend" && y !== "edit")
1119
+ return;
1120
+ let Se;
1121
+ try {
1122
+ Se = he(K.current);
1123
+ } catch (Ce) {
1124
+ Gr(Ce);
1125
+ return;
1126
+ }
1127
+ if (!Hr(Se)) return;
1128
+ re.current.add(y), Ie(new Set(re.current));
1129
+ const ke = () => {
1130
+ re.current.delete(y), ue.current && Ie(new Set(re.current));
1131
+ };
1132
+ Se.then(ke, ke);
1133
+ },
1134
+ []
1135
+ ), Ke = P(() => {
1136
+ var y;
1137
+ re.current.has("print") || (V || (y = A.current) == null || y.print(), D("print", k));
1138
+ }, [D, k, V]);
1139
+ B.current = () => D("print", k);
1140
+ const We = [
1141
+ k && {
1142
+ action: "print",
1143
+ label: f("prescription.sheet.print"),
1144
+ icon: /* @__PURE__ */ r(Ct, { "aria-hidden": "true" }),
1145
+ run: Ke
1146
+ },
1147
+ G && {
1148
+ action: "downloadPdf",
1149
+ label: f("prescription.sheet.downloadPdf"),
1150
+ icon: /* @__PURE__ */ r(fr, { "aria-hidden": "true" }),
1151
+ run: () => D("downloadPdf", G)
1152
+ },
1153
+ L && {
1154
+ action: "sendEmail",
1155
+ label: f("prescription.sheet.sendEmail"),
1156
+ icon: /* @__PURE__ */ r(hr, { "aria-hidden": "true" }),
1157
+ run: () => D("sendEmail", L)
1158
+ },
1159
+ ae && {
1160
+ action: "sendSms",
1161
+ label: f("prescription.sheet.sendSms"),
1162
+ icon: /* @__PURE__ */ r(br, { "aria-hidden": "true" }),
1163
+ run: () => D("sendSms", ae)
1164
+ },
1165
+ d && {
1166
+ action: "sendWhatsApp",
1167
+ label: f("prescription.sheet.sendWhatsApp"),
1168
+ icon: /* @__PURE__ */ r(mr, {}),
1169
+ run: () => D("sendWhatsApp", d)
1170
+ }
1171
+ ].filter((y) => !!y), [W, ...qe] = We, Ne = W ? /* @__PURE__ */ r(
1172
+ ze,
1173
+ {
1174
+ type: "button",
1175
+ intent: "outline",
1176
+ startIcon: W.icon,
1177
+ loading: te.has(W.action),
1178
+ "aria-disabled": s || void 0,
1179
+ "aria-describedby": [
1180
+ s ? c : void 0,
1181
+ V && W.action === "print" ? ee : void 0
1182
+ ].filter(Boolean).join(" ") || void 0,
1183
+ onClick: s ? void 0 : W.run,
1184
+ "data-action": W.action,
1185
+ className: "ds:min-h-[var(--min-target-size)]",
1186
+ children: W.label
1187
+ }
1188
+ ) : null, me = W && qe.length > 0 ? /* @__PURE__ */ v(cr, { label: f("prescription.sheet.shareActions"), children: [
1189
+ Ne,
1190
+ /* @__PURE__ */ r(
1191
+ Or,
1192
+ {
1193
+ blocked: s,
1194
+ describedBy: s ? c : void 0,
1195
+ label: f("prescription.sheet.moreActions"),
1196
+ items: qe.map((y) => ({
1197
+ ...y,
1198
+ busy: te.has(y.action)
1199
+ }))
1200
+ }
1201
+ )
1202
+ ] }) : Ne, fe = me !== null;
1203
+ return /* @__PURE__ */ v(
1204
+ "div",
1205
+ {
1206
+ ...oe,
1207
+ id: $,
1208
+ className: _r({ className: O }),
1209
+ "data-component": "prescription-sheet",
1210
+ "data-component-id": $,
1211
+ "data-prescription-id": e.id,
1212
+ children: [
1213
+ m ? /* @__PURE__ */ r(
1214
+ "div",
1215
+ {
1216
+ id: c,
1217
+ "data-slot": "send-status",
1218
+ "data-send-status": m,
1219
+ className: "ds:mx-auto ds:flex ds:w-full ds:max-w-3xl ds:justify-center ds:print:hidden",
1220
+ children: m === "sent" ? /* @__PURE__ */ v("p", { className: "ds:m-0 ds:flex ds:flex-wrap ds:items-center ds:justify-center ds:gap-[var(--spacing-sm)] type-body-sm", children: [
1221
+ /* @__PURE__ */ r(Pt, { status: "sent" }),
1222
+ e.sentAt ? /* @__PURE__ */ v("span", { children: [
1223
+ f("prescription.sheet.sentAt"),
1224
+ " ",
1225
+ /* @__PURE__ */ r(
1226
+ ar,
1227
+ {
1228
+ locale: z,
1229
+ value: e.sentAt,
1230
+ format: "absolute",
1231
+ shape: "bare",
1232
+ absoluteFormat: {
1233
+ dateStyle: "medium",
1234
+ timeStyle: "short"
1235
+ }
1236
+ }
1237
+ )
1238
+ ] }) : null
1239
+ ] }) : m === "sending" ? /* @__PURE__ */ r(be, { variant: "info", announce: "polite", className: "ds:w-full", children: /* @__PURE__ */ r(be.Title, { as: "p", children: f("prescription.sheet.sendingTitle") }) }) : /* @__PURE__ */ v(be, { variant: "error", className: "ds:w-full", children: [
1240
+ /* @__PURE__ */ r(be.Title, { as: "p", children: f("prescription.sheet.sendFailedTitle") }),
1241
+ /* @__PURE__ */ r(be.Description, { children: e.sendError ?? f("prescription.sheet.sendFailedBody") }),
1242
+ X || F ? /* @__PURE__ */ v(
1243
+ "div",
1244
+ {
1245
+ "data-slot": "failed-actions",
1246
+ className: "ds:mt-[var(--spacing-sm)] ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)]",
1247
+ children: [
1248
+ X ? /* @__PURE__ */ r(
1249
+ ze,
1250
+ {
1251
+ type: "button",
1252
+ intent: "primary",
1253
+ loading: te.has("resend"),
1254
+ onClick: () => D("resend", X),
1255
+ "data-action": "resend",
1256
+ className: "ds:min-h-[var(--min-target-size)]",
1257
+ children: f("prescription.sheet.resend")
1258
+ }
1259
+ ) : null,
1260
+ F ? /* @__PURE__ */ r(
1261
+ ze,
1262
+ {
1263
+ type: "button",
1264
+ intent: "secondary",
1265
+ loading: te.has("edit"),
1266
+ onClick: () => D("edit", F),
1267
+ "data-action": "edit",
1268
+ className: "ds:min-h-[var(--min-target-size)]",
1269
+ children: f("prescription.sheet.edit")
1270
+ }
1271
+ ) : null
1272
+ ]
1273
+ }
1274
+ ) : null
1275
+ ] })
1276
+ }
1277
+ ) : null,
1278
+ fe ? /* @__PURE__ */ r(
1279
+ "div",
1280
+ {
1281
+ role: "group",
1282
+ "aria-label": f("prescription.sheet.actions"),
1283
+ "data-slot": "actions",
1284
+ className: "ds:flex ds:flex-wrap ds:items-center ds:justify-center ds:gap-[var(--spacing-sm)] ds:print:hidden",
1285
+ children: me
1286
+ }
1287
+ ) : null,
1288
+ V ? (
1289
+ /* Not print:hidden: when the page itself is printed (Ctrl or Cmd+P),
1290
+ the summary prints with its note, right above the sheet. */
1291
+ /* @__PURE__ */ r(
1292
+ "p",
1293
+ {
1294
+ id: ee,
1295
+ "data-slot": "summary-note",
1296
+ className: "ds:m-0 ds:text-center type-body-sm ds:text-[color:var(--muted-foreground)]",
1297
+ children: f("prescription.sheet.summaryNote")
1298
+ }
1299
+ )
1300
+ ) : null,
1301
+ /* @__PURE__ */ r(
1302
+ ur,
1303
+ {
1304
+ ref: A,
1305
+ registerAgent: !1,
1306
+ id: $ ? `${$}-sheet` : void 0,
1307
+ size: a,
1308
+ density: h,
1309
+ isolateBrowserPrint: V ? !1 : g,
1310
+ header: n,
1311
+ title: f("prescription.sheet.title"),
1312
+ date: e.createdAt,
1313
+ signature: {
1314
+ name: e.prescriber.name,
1315
+ detail: e.prescriber.specialty
1316
+ },
1317
+ children: /* @__PURE__ */ v("div", { className: jr({ density: h }), children: [
1318
+ /* @__PURE__ */ v(St, { children: [
1319
+ e.number ? /* @__PURE__ */ r(
1320
+ ne,
1321
+ {
1322
+ label: o ?? f("prescription.sheet.number"),
1323
+ value: /* @__PURE__ */ r("span", { dir: "ltr", children: e.number }),
1324
+ mono: !0,
1325
+ "data-field": "number"
1326
+ }
1327
+ ) : null,
1328
+ e.pin ? /* @__PURE__ */ r(
1329
+ ne,
1330
+ {
1331
+ label: N ?? f("prescription.sheet.pin"),
1332
+ value: S ? /* @__PURE__ */ v(_e, { children: [
1333
+ /* @__PURE__ */ r(lt, { children: f("calendarWorkspace.privacy.hidden") }),
1334
+ /* @__PURE__ */ r("span", { "aria-hidden": "true", children: ct() })
1335
+ ] }) : /* @__PURE__ */ r("span", { dir: "ltr", children: e.pin }),
1336
+ mono: !0,
1337
+ "data-field": "pin"
1338
+ }
1339
+ ) : null,
1340
+ /* @__PURE__ */ r(
1341
+ ne,
1342
+ {
1343
+ label: f("prescription.sheet.treatment"),
1344
+ value: /* @__PURE__ */ r("span", { dir: "auto", children: e.treatment.label }),
1345
+ "data-field": "treatment"
1346
+ }
1347
+ ),
1348
+ e.treatment.carePlan ? /* @__PURE__ */ r(
1349
+ ne,
1350
+ {
1351
+ label: f("prescription.sheet.carePlan"),
1352
+ value: /* @__PURE__ */ r("span", { dir: "auto", children: e.treatment.carePlan.label }),
1353
+ "data-field": "carePlan"
1354
+ }
1355
+ ) : null
1356
+ ] }),
1357
+ /* @__PURE__ */ v(
1358
+ "section",
1359
+ {
1360
+ "aria-labelledby": J,
1361
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
1362
+ children: [
1363
+ /* @__PURE__ */ r(
1364
+ "h3",
1365
+ {
1366
+ id: J,
1367
+ className: "ds:m-0 type-title-item ds:break-after-avoid",
1368
+ children: f("prescription.sheet.patient")
1369
+ }
1370
+ ),
1371
+ /* @__PURE__ */ r(
1372
+ dt,
1373
+ {
1374
+ patient: e.patient,
1375
+ privacyMode: S,
1376
+ density: h
1377
+ }
1378
+ )
1379
+ ]
1380
+ }
1381
+ ),
1382
+ /* @__PURE__ */ v(
1383
+ "section",
1384
+ {
1385
+ "aria-labelledby": Z,
1386
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
1387
+ children: [
1388
+ /* @__PURE__ */ r(
1389
+ "h3",
1390
+ {
1391
+ id: Z,
1392
+ className: "ds:m-0 type-title-item ds:break-after-avoid",
1393
+ children: f("prescription.sheet.medications")
1394
+ }
1395
+ ),
1396
+ /* @__PURE__ */ r(
1397
+ dr,
1398
+ {
1399
+ density: h,
1400
+ "aria-labelledby": Z,
1401
+ children: e.items.map((y, he) => /* @__PURE__ */ r(
1402
+ pr,
1403
+ {
1404
+ as: "li",
1405
+ medication: y.medication,
1406
+ dosage: y.dosage,
1407
+ notes: y.notes,
1408
+ quantity: y.quantity,
1409
+ duration: y.duration,
1410
+ notSubstitutable: y.notSubstitutable,
1411
+ codeLabel: u
1412
+ },
1413
+ `${y.medication.id}-${he}`
1414
+ ))
1415
+ }
1416
+ )
1417
+ ]
1418
+ }
1419
+ ),
1420
+ /* @__PURE__ */ v(
1421
+ "section",
1422
+ {
1423
+ "aria-labelledby": w,
1424
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]",
1425
+ children: [
1426
+ /* @__PURE__ */ r(
1427
+ "h3",
1428
+ {
1429
+ id: w,
1430
+ className: "ds:m-0 type-title-item ds:break-after-avoid",
1431
+ children: f("prescription.sheet.prescriber")
1432
+ }
1433
+ ),
1434
+ /* @__PURE__ */ v(St, { children: [
1435
+ /* @__PURE__ */ r(
1436
+ ne,
1437
+ {
1438
+ label: f("prescription.sheet.prescriberName"),
1439
+ value: /* @__PURE__ */ r("span", { dir: "auto", children: e.prescriber.name }),
1440
+ "data-field": "prescriber"
1441
+ }
1442
+ ),
1443
+ e.prescriber.specialty ? /* @__PURE__ */ r(
1444
+ ne,
1445
+ {
1446
+ label: f("prescription.history.specialty"),
1447
+ value: /* @__PURE__ */ r("span", { dir: "auto", children: e.prescriber.specialty }),
1448
+ "data-field": "specialty"
1449
+ }
1450
+ ) : null,
1451
+ e.prescriber.fiscalCode ? /* @__PURE__ */ r(
1452
+ ne,
1453
+ {
1454
+ label: f("prescription.sheet.prescriberFiscalCode"),
1455
+ value: /* @__PURE__ */ r("span", { dir: "ltr", children: e.prescriber.fiscalCode }),
1456
+ mono: !0,
1457
+ "data-field": "prescriberFiscalCode"
1458
+ }
1459
+ ) : null,
1460
+ e.prescriber.registrationNumber ? /* @__PURE__ */ r(
1461
+ ne,
1462
+ {
1463
+ label: f("prescription.sheet.registrationNumber"),
1464
+ value: /* @__PURE__ */ r("span", { dir: "ltr", children: e.prescriber.registrationNumber }),
1465
+ mono: !0,
1466
+ "data-field": "registrationNumber"
1467
+ }
1468
+ ) : null
1469
+ ] })
1470
+ ]
1471
+ }
1472
+ )
1473
+ ] })
1474
+ }
1475
+ )
1476
+ ]
1477
+ }
1478
+ );
1479
+ }
1480
+ );
1481
+ Kr.displayName = "PrescriptionSheet";
1482
+ const Wr = j("ds:block ds:min-w-0 ds:w-full"), Qr = j(
1483
+ "ds:inline-flex ds:min-w-0 ds:items-center ds:gap-[var(--spacing-xs)]"
1484
+ ), Be = j("ds:min-w-0 ds:break-words"), Yr = j("ds:flex ds:flex-wrap ds:gap-[var(--spacing-2xs)]"), Ur = "11rem", Xr = j(
1485
+ "ds:min-w-0 ds:break-words ds:text-[color:var(--muted-foreground)]"
1486
+ ), Jr = j("ds:font-mono ds:tabular-nums"), Zr = [
1487
+ { colId: "date", sort: "desc" }
1488
+ ], ei = {
1489
+ dateStyle: "medium",
1490
+ timeStyle: "short"
1491
+ };
1492
+ function wt(e, n) {
1493
+ const a = new Date(e.createdAt);
1494
+ return Number.isNaN(a.getTime()) ? e.createdAt : new Intl.DateTimeFormat(He(n), ei).format(
1495
+ a
1496
+ );
1497
+ }
1498
+ function $t({ name: e }) {
1499
+ return /* @__PURE__ */ v("span", { className: Qr(), children: [
1500
+ /* @__PURE__ */ r(
1501
+ qt,
1502
+ {
1503
+ name: e,
1504
+ size: "xs",
1505
+ className: "ds:shrink-0",
1506
+ "aria-hidden": "true",
1507
+ role: "presentation",
1508
+ "aria-label": void 0
1509
+ }
1510
+ ),
1511
+ /* @__PURE__ */ r("span", { dir: "auto", className: Be(), children: e })
1512
+ ] });
1513
+ }
1514
+ const Yi = Oe(function({
1515
+ records: n,
1516
+ status: a = "ready",
1517
+ onOpen: h,
1518
+ onReprint: u,
1519
+ onRetry: S,
1520
+ caption: g,
1521
+ showPatient: o = !1,
1522
+ privacyMode: N = !1,
1523
+ showSendStatus: q,
1524
+ id: k,
1525
+ className: G,
1526
+ ...L
1527
+ }, ae) {
1528
+ const { t: d, i18n: X } = ve("ui"), F = X.language || "en", $ = h !== void 0 || u !== void 0, O = q ?? n.some((T) => T.sendStatus !== void 0), oe = je(() => {
1529
+ const T = [];
1530
+ return h && T.push({
1531
+ id: "open",
1532
+ icon: /* @__PURE__ */ r(wr, {}),
1533
+ label: d("prescription.history.open"),
1534
+ onClick: h
1535
+ }), u && T.push({
1536
+ id: "reprint",
1537
+ icon: /* @__PURE__ */ r(Ct, {}),
1538
+ label: d("prescription.history.reprint"),
1539
+ onClick: u
1540
+ }), T;
1541
+ }, [d, h, u]), H = je(() => {
1542
+ const T = new Intl.Collator(He(F)), z = (s) => wt(s, F), A = (s) => `${s.patient.lastName} ${s.patient.firstName}`.trim(), J = (s) => d(s === "sent" ? "prescription.status.sent" : s === "sending" ? "prescription.status.sending" : "prescription.status.failed"), Z = /* @__PURE__ */ r("span", { className: Xr(), children: d("prescription.history.noCarePlan") }), w = 3, c = 2, ee = o ? 2 : 1, m = [
1543
+ {
1544
+ id: "date",
1545
+ header: d("prescription.history.date"),
1546
+ headerLabel: d("prescription.history.date"),
1547
+ rowHeader: !0,
1548
+ sort: "date",
1549
+ sortDescFirst: !0,
1550
+ value: (s) => new Date(s.createdAt),
1551
+ exportValue: z,
1552
+ filter: { kind: "dateRange" },
1553
+ search: !1,
1554
+ size: 124,
1555
+ wrap: !0,
1556
+ cell: (s) => /* @__PURE__ */ r("time", { dateTime: s.createdAt, children: z(s) })
1557
+ }
1558
+ ];
1559
+ if (O && (m.push({
1560
+ id: "number",
1561
+ header: d("prescription.history.number"),
1562
+ headerLabel: d("prescription.history.number"),
1563
+ responsiveTier: c,
1564
+ sort: "text",
1565
+ value: (s) => s.number ?? null,
1566
+ exportValue: (s) => s.number ?? "",
1567
+ filter: { kind: "text" },
1568
+ size: 124,
1569
+ cell: (s) => s.number ? /* @__PURE__ */ r("span", { dir: "ltr", className: Jr(), children: s.number }) : null
1570
+ }), m.push({
1571
+ id: "status",
1572
+ header: d("prescription.history.status"),
1573
+ headerLabel: d("prescription.history.status"),
1574
+ responsiveTier: ee,
1575
+ sort: "text",
1576
+ value: (s) => s.sendStatus ?? null,
1577
+ exportValue: (s) => s.sendStatus ? J(s.sendStatus) : "",
1578
+ filter: {
1579
+ kind: "select",
1580
+ options: ["sent", "sending", "failed"].map((s) => ({
1581
+ value: s,
1582
+ label: J(s)
1583
+ }))
1584
+ },
1585
+ search: !1,
1586
+ size: 108,
1587
+ cell: (s) => s.sendStatus ? /* @__PURE__ */ r(Pt, { status: s.sendStatus }) : null
1588
+ })), o && m.push({
1589
+ id: "patient",
1590
+ header: d("prescription.history.patient"),
1591
+ headerLabel: d("prescription.history.patient"),
1592
+ responsiveTier: 1,
1593
+ wrap: !0,
1594
+ privacy: "mask",
1595
+ sort: (s, b) => T.compare(A(s), A(b)),
1596
+ value: A,
1597
+ exportValue: A,
1598
+ filter: { kind: "text" },
1599
+ size: 144,
1600
+ cell: (s) => /* @__PURE__ */ r($t, { name: A(s) })
1601
+ }), m.push(
1602
+ {
1603
+ id: "treatment",
1604
+ header: d("prescription.history.treatment"),
1605
+ headerLabel: d("prescription.history.treatment"),
1606
+ responsiveTier: w,
1607
+ wrap: !0,
1608
+ sort: "text",
1609
+ value: (s) => s.treatment.label,
1610
+ exportValue: (s) => s.treatment.label,
1611
+ filter: { kind: "text" },
1612
+ size: 136,
1613
+ cell: (s) => /* @__PURE__ */ r("span", { dir: "auto", className: Be(), children: s.treatment.label })
1614
+ },
1615
+ {
1616
+ id: "carePlan",
1617
+ header: d("prescription.history.carePlan"),
1618
+ headerLabel: d("prescription.history.carePlan"),
1619
+ responsiveTier: w,
1620
+ wrap: !0,
1621
+ sort: "text",
1622
+ value: (s) => {
1623
+ var b;
1624
+ return ((b = s.treatment.carePlan) == null ? void 0 : b.label) ?? null;
1625
+ },
1626
+ exportValue: (s) => {
1627
+ var b;
1628
+ return ((b = s.treatment.carePlan) == null ? void 0 : b.label) ?? "";
1629
+ },
1630
+ filter: { kind: "select" },
1631
+ size: 128,
1632
+ cell: (s) => s.treatment.carePlan ? /* @__PURE__ */ r("span", { dir: "auto", className: Be(), children: s.treatment.carePlan.label }) : Z
1633
+ },
1634
+ {
1635
+ id: "medications",
1636
+ header: d("prescription.history.medications"),
1637
+ headerLabel: d("prescription.history.medications"),
1638
+ wrap: !0,
1639
+ value: (s) => s.items.map((b) => b.medication.name).join("; "),
1640
+ exportValue: (s) => s.items.map((b) => b.medication.name).join("; "),
1641
+ /* The grid's filters read one scalar per row, so the drug filter is
1642
+ a text "contains" on the names, not a list of drugs. */
1643
+ filter: { kind: "text" },
1644
+ size: 216,
1645
+ cell: (s) => /* @__PURE__ */ r("span", { className: Yr(), children: s.items.map((b, V) => /* @__PURE__ */ r(
1646
+ vr,
1647
+ {
1648
+ label: b.medication.name,
1649
+ size: "sm",
1650
+ variant: "neutral",
1651
+ maxInlineSize: Ur
1652
+ },
1653
+ `${b.medication.id}-${V}`
1654
+ )) })
1655
+ },
1656
+ {
1657
+ id: "prescriber",
1658
+ header: d("prescription.history.prescriber"),
1659
+ headerLabel: d("prescription.history.prescriber"),
1660
+ responsiveTier: o ? w : c,
1661
+ wrap: !0,
1662
+ sort: "text",
1663
+ value: (s) => s.prescriber.name,
1664
+ exportValue: (s) => s.prescriber.name,
1665
+ filter: { kind: "select" },
1666
+ search: !0,
1667
+ size: 136,
1668
+ cell: (s) => /* @__PURE__ */ r($t, { name: s.prescriber.name })
1669
+ },
1670
+ {
1671
+ id: "specialty",
1672
+ header: d("prescription.history.specialty"),
1673
+ headerLabel: d("prescription.history.specialty"),
1674
+ defaultHidden: !0,
1675
+ wrap: !0,
1676
+ sort: "text",
1677
+ value: (s) => s.prescriber.specialty ?? null,
1678
+ exportValue: (s) => s.prescriber.specialty ?? "",
1679
+ filter: { kind: "select" },
1680
+ size: 140,
1681
+ cell: (s) => s.prescriber.specialty ? /* @__PURE__ */ r("span", { dir: "auto", className: Be(), children: s.prescriber.specialty }) : null
1682
+ }
1683
+ ), $) {
1684
+ const s = d("prescription.history.actions");
1685
+ m.push({
1686
+ id: "actions",
1687
+ header: /* @__PURE__ */ r(lt, { children: s }),
1688
+ headerLabel: s,
1689
+ pin: "end",
1690
+ size: 64,
1691
+ hideable: !1,
1692
+ reorderable: !1,
1693
+ pinnable: !1,
1694
+ resizable: !1,
1695
+ exportable: !1,
1696
+ printable: !1,
1697
+ search: !1,
1698
+ /* The kit RowActions leaf, menu only: one "Actions" button per row,
1699
+ named by reference with the row's own name. */
1700
+ cell: (b, V) => /* @__PURE__ */ r(
1701
+ Ir,
1702
+ {
1703
+ row: b,
1704
+ actions: oe,
1705
+ maxInline: 0,
1706
+ "aria-labelledby": V.inputLabelledBy
1707
+ }
1708
+ )
1709
+ });
1710
+ }
1711
+ return m;
1712
+ }, [d, F, $, o, O, oe]), f = /* @__PURE__ */ v(de, { children: [
1713
+ /* @__PURE__ */ v(de.FilterBar, { children: [
1714
+ /* @__PURE__ */ r(de.QuickSearch, {}),
1715
+ /* @__PURE__ */ r(de.FilterChips, {})
1716
+ ] }),
1717
+ /* @__PURE__ */ r(de.Actions, { children: /* @__PURE__ */ v(yr, { "aria-label": d("dataTable.tableActions"), children: [
1718
+ /* @__PURE__ */ r(de.ExportMenu, {}),
1719
+ /* @__PURE__ */ r(de.Print, {}),
1720
+ /* @__PURE__ */ r(de.ColumnToggle, {})
1721
+ ] }) })
1722
+ ] });
1723
+ return /* @__PURE__ */ r(
1724
+ "div",
1725
+ {
1726
+ ...L,
1727
+ ref: ae,
1728
+ "data-component": "prescription-history",
1729
+ "data-component-id": k,
1730
+ className: Wr({ className: G }),
1731
+ children: /* @__PURE__ */ r(
1732
+ Nr,
1733
+ {
1734
+ columns: H,
1735
+ rows: n,
1736
+ getRowId: (T) => T.id,
1737
+ getRowLabel: (T) => {
1738
+ const z = d("prescription.history.rowLabel", {
1739
+ date: wt(T, F)
1740
+ });
1741
+ return o ? `${z}, ${T.patient.lastName} ${T.patient.firstName}` : z;
1742
+ },
1743
+ privacyMode: N,
1744
+ toolbar: f,
1745
+ caption: g ?? d("prescription.history.caption"),
1746
+ defaultSorting: Zr,
1747
+ status: a,
1748
+ gridId: k ? `${k}-grid` : void 0,
1749
+ empty: {
1750
+ title: d("prescription.history.emptyTitle"),
1751
+ description: d("prescription.history.emptyBody")
1752
+ },
1753
+ error: {
1754
+ title: d("prescription.history.errorTitle"),
1755
+ onRetry: S
1756
+ }
1757
+ }
1758
+ )
1759
+ }
1760
+ );
1761
+ });
1762
+ export {
1763
+ Ge as E,
1764
+ zr as P,
1765
+ Yi as a,
1766
+ Kr as b,
1767
+ Lr as c,
1768
+ xt as d,
1769
+ ot as i,
1770
+ Fr as n,
1771
+ kt as v
1772
+ };
1773
+ //# sourceMappingURL=prescription-history-CFs3JMIE.js.map