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