hplx-feature-library 1.0.59 → 1.0.60

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.
@@ -1,4 +1,830 @@
1
- import { P as f } from "../PediatricsCalculatorTable-Ca-lFjJ8.js";
1
+ import { j as e, M as k, L as ge, c as Q, g as xe, C as g, a as ye, Z as oe, A as _e } from "../CustomDropdown-Di-tVTdd.js";
2
+ import le, { createContext as be, useContext as we, useState as W, useEffect as J, useMemo as Y, useCallback as G, forwardRef as je, useImperativeHandle as ve } from "react";
3
+ import { C_MedicineCalculatorList as ae, C_FrequencyDosageMap as ce, C_MedicineTypeList as te, C_MedicineFrequencyList as de, C_DefaultMgKgFields as Ce, C_DefaultMlKgFields as Ie, C_Table_Column_Name as Ne } from "../constants/PediatricsCalculatorConstants/index.js";
4
+ const fe = be(null), he = () => {
5
+ const i = we(fe);
6
+ if (!i) throw new Error("usePediatricsCalculatorTableContext must be used inside a MedicineTableProvider");
7
+ return i;
8
+ }, Me = ({
9
+ effectiveEditMode: i,
10
+ rowData: a,
11
+ isSavedToLibrary: x,
12
+ onSave: _,
13
+ onCancel: b,
14
+ onEdit: w,
15
+ onCheckboxToggle: o
16
+ }) => {
17
+ const { variant: j, externallyTriggeredEditMode: A, setRowToDelete: v, openPopupForRow: E } = he();
18
+ return j === "standard" ? i ? /* @__PURE__ */ e.jsxs("div", { className: "hfl-grid hfl-grid-cols-[1fr_1fr] hfl-border-1 hfl-border-Gray-200 hfl-rounded-lg ", children: [
19
+ /* @__PURE__ */ e.jsx(
20
+ "button",
21
+ {
22
+ className: "hfl-px-3 hfl-py-1 hfl-text-Blue_gray-800 hfl-border-r-1 hover:hfl-bg-Primary-50",
23
+ onClick: _,
24
+ children: /* @__PURE__ */ e.jsx(k, { variant: "Medium", type: "Text xs", className: "hfl-text-Blue_gray-800", children: "Save" })
25
+ }
26
+ ),
27
+ /* @__PURE__ */ e.jsx("button", { className: "hfl-px-3 hfl-py-2 hfl-text-Error-600 hover:hfl-bg-Error-50", onClick: b, children: /* @__PURE__ */ e.jsx(k, { variant: "Medium", type: "Text xs", className: "", children: "Cancel" }) })
28
+ ] }) : /* @__PURE__ */ e.jsxs("div", { className: "hfl-grid hfl-grid-cols-[1fr_1fr_1fr] hfl-border-1 hfl-border-Gray-200 hfl-rounded-lg", children: [
29
+ /* @__PURE__ */ e.jsx("button", { className: "hfl-px-3 hfl-py-1 hfl-text-Blue_gray-800 hover:hfl-bg-Primary-50", onClick: w, children: /* @__PURE__ */ e.jsx(k, { variant: "Medium", type: "Text xs", className: "", children: "Edit" }) }),
30
+ /* @__PURE__ */ e.jsx(
31
+ "button",
32
+ {
33
+ className: "hfl-px-3 hfl-py-2 hfl-text-Blue_gray-800 hfl-border-x-1 hover:hfl-bg-Primary-50",
34
+ onClick: () => E?.(a),
35
+ children: /* @__PURE__ */ e.jsx(k, { variant: "Medium", type: "Text xs", className: "", children: "Copy" })
36
+ }
37
+ ),
38
+ /* @__PURE__ */ e.jsx(
39
+ "button",
40
+ {
41
+ className: "hx_delete hfl-px-3 hfl-py-2 hfl-text-Error-500 hover:hfl-bg-Error-50",
42
+ onClick: () => v?.(a.rowId)
43
+ }
44
+ )
45
+ ] }) : /* @__PURE__ */ e.jsx(
46
+ ge,
47
+ {
48
+ disabled: !A,
49
+ text: "Save this to Pediatric Calculator Library ",
50
+ id: a.rowId,
51
+ size: "md",
52
+ onClick: o,
53
+ isMarked: x ?? !1,
54
+ checkboxClasses: "hfl-mt-2",
55
+ checkBoxInnerDivClasses: "hfl-text-Blue-600 hfl-bg-Blue-50"
56
+ },
57
+ a.rowId
58
+ );
59
+ };
60
+ var ne, ue;
61
+ function Te() {
62
+ if (ue) return ne;
63
+ ue = 1;
64
+ var i = "Expected a function", a = NaN, x = "[object Symbol]", _ = /^\s+|\s+$/g, b = /^[-+]0x[0-9a-f]+$/i, w = /^0b[01]+$/i, o = /^0o[0-7]+$/i, j = parseInt, A = typeof Q == "object" && Q && Q.Object === Object && Q, v = typeof self == "object" && self && self.Object === Object && self, E = A || v || Function("return this")(), F = Object.prototype, $ = F.toString, O = Math.max, n = Math.min, d = function() {
65
+ return E.Date.now();
66
+ };
67
+ function M(s, p, f) {
68
+ var u, D, I, r, t, N, y = 0, q = !1, R = !1, l = !0;
69
+ if (typeof s != "function")
70
+ throw new TypeError(i);
71
+ p = z(p) || 0, T(f) && (q = !!f.leading, R = "maxWait" in f, I = R ? O(z(f.maxWait) || 0, p) : I, l = "trailing" in f ? !!f.trailing : l);
72
+ function c(m) {
73
+ var K = u, U = D;
74
+ return u = D = void 0, y = m, r = s.apply(U, K), r;
75
+ }
76
+ function h(m) {
77
+ return y = m, t = setTimeout(P, p), q ? c(m) : r;
78
+ }
79
+ function S(m) {
80
+ var K = m - N, U = m - y, re = p - K;
81
+ return R ? n(re, I - U) : re;
82
+ }
83
+ function L(m) {
84
+ var K = m - N, U = m - y;
85
+ return N === void 0 || K >= p || K < 0 || R && U >= I;
86
+ }
87
+ function P() {
88
+ var m = d();
89
+ if (L(m))
90
+ return se(m);
91
+ t = setTimeout(P, S(m));
92
+ }
93
+ function se(m) {
94
+ return t = void 0, l && u ? c(m) : (u = D = void 0, r);
95
+ }
96
+ function pe() {
97
+ t !== void 0 && clearTimeout(t), y = 0, u = N = D = t = void 0;
98
+ }
99
+ function me() {
100
+ return t === void 0 ? r : se(d());
101
+ }
102
+ function ee() {
103
+ var m = d(), K = L(m);
104
+ if (u = arguments, D = this, N = m, K) {
105
+ if (t === void 0)
106
+ return h(N);
107
+ if (R)
108
+ return t = setTimeout(P, p), c(N);
109
+ }
110
+ return t === void 0 && (t = setTimeout(P, p)), r;
111
+ }
112
+ return ee.cancel = pe, ee.flush = me, ee;
113
+ }
114
+ function T(s) {
115
+ var p = typeof s;
116
+ return !!s && (p == "object" || p == "function");
117
+ }
118
+ function C(s) {
119
+ return !!s && typeof s == "object";
120
+ }
121
+ function Z(s) {
122
+ return typeof s == "symbol" || C(s) && $.call(s) == x;
123
+ }
124
+ function z(s) {
125
+ if (typeof s == "number")
126
+ return s;
127
+ if (Z(s))
128
+ return a;
129
+ if (T(s)) {
130
+ var p = typeof s.valueOf == "function" ? s.valueOf() : s;
131
+ s = T(p) ? p + "" : p;
132
+ }
133
+ if (typeof s != "string")
134
+ return s === 0 ? s : +s;
135
+ s = s.replace(_, "");
136
+ var f = w.test(s);
137
+ return f || o.test(s) ? j(s.slice(2), f ? 2 : 8) : b.test(s) ? a : +s;
138
+ }
139
+ return ne = M, ne;
140
+ }
141
+ var De = Te();
142
+ const Se = /* @__PURE__ */ xe(De), ie = (i, a) => {
143
+ const x = parseFloat(i), _ = parseFloat(a);
144
+ if (!i || !a || isNaN(x) || isNaN(_) || _ === 0)
145
+ return "";
146
+ const b = x / _;
147
+ return Number.isInteger(b) ? b.toString(10) : b.toFixed(3).replace(/\.?0+$/, "");
148
+ }, V = (i) => /^(\d+)?(\.)?(\d*)?$/.test(i), B = ({ label: i, children: a }) => /* @__PURE__ */ e.jsxs(
149
+ k,
150
+ {
151
+ variant: "Regular",
152
+ type: "Text sm",
153
+ className: "hfl-grid hfl-grid-cols-2 hfl-items-center hfl-text-Blue_gray-800 hfl-justify-between hfl-gap-8",
154
+ children: [
155
+ /* @__PURE__ */ e.jsxs("span", { className: "hfl-flex-shrink-0", children: [
156
+ i,
157
+ ":"
158
+ ] }),
159
+ /* @__PURE__ */ e.jsx("div", { className: "hfl-flex-1 hfl-min-w-0", children: a })
160
+ ]
161
+ }
162
+ ), H = ({ label: i, value: a }) => /* @__PURE__ */ e.jsxs(k, { variant: "Regular", type: "Text sm", className: "hfl-flex hfl-text-Blue_gray-800 hfl-gap-1", children: [
163
+ /* @__PURE__ */ e.jsxs("span", { className: "hfl-flex-shrink-0", children: [
164
+ i,
165
+ ":"
166
+ ] }),
167
+ /* @__PURE__ */ e.jsx(k, { variant: "Bold", type: "Text sm", className: "hfl-text-Blue_gray-800 hfl-break-words hfl-min-w-0", children: a || "--" })
168
+ ] }), X = ({ children: i, className: a = "" }) => /* @__PURE__ */ e.jsx(
169
+ k,
170
+ {
171
+ variant: "Regular",
172
+ type: "Text sm",
173
+ className: `hfl-text-Blue_gray-800 hfl-px-2 hfl-break-words hfl-overflow-wrap-anywhere hfl-min-w-0 ${a}`,
174
+ children: i
175
+ }
176
+ ), ke = le.memo(
177
+ function({ rowData: a, isEditing: x, setIsEditing: _, onSaveRow: b, allowCustomMedicineInput: w }) {
178
+ const {
179
+ variant: o,
180
+ externallyTriggeredEditMode: j,
181
+ externallyTriggeredEditRowIds: A,
182
+ getMedicineOptions: v,
183
+ onRowChange: E,
184
+ onRowDelete: F
185
+ } = he(), [$, O] = W([]), [n, d] = W(a), [M, T] = W(a.medicine_name);
186
+ J(() => {
187
+ x || T(a.medicine_name);
188
+ }, [a.medicine_name, x]), J(() => {
189
+ x || d(a);
190
+ }, [a, x]);
191
+ const C = async (l) => (await v?.(l))?.map((h) => ({
192
+ label: h.doctorMedicineName,
193
+ value: h
194
+ })) || [], z = j || A?.includes(a.rowId) || x, s = Y(() => n.out_of_range || a.out_of_range, [n.out_of_range, a.out_of_range]), p = Y(() => n?.isDosageMismatch || a?.isDosageMismatch, [n?.isDosageMismatch, a?.isDosageMismatch]), f = le.useMemo(() => n.calculation_type === ae[0] ? n.calculation_fields : null, [n.calculation_fields, n.calculation_type]), u = le.useMemo(() => n.calculation_type === ae[1] ? n.calculation_fields : null, [n.calculation_fields, n.calculation_type]), D = (l, c) => {
195
+ let h;
196
+ if (l === "calculation_type") {
197
+ const S = c, L = {
198
+ frequency: n.calculation_fields.frequency,
199
+ pedia_dosage: o === "standard" ? n.calculation_fields.pedia_dosage : n.pedia_dosage
200
+ };
201
+ h = {
202
+ ...n,
203
+ calculation_type: S,
204
+ calculation_fields: S === "mg/kg/dose" ? { ...Ce, ...L } : { ...Ie, ...L }
205
+ };
206
+ } else
207
+ h = {
208
+ ...n,
209
+ [l]: c
210
+ };
211
+ d(h), o === "prescription" && I(h, l);
212
+ }, I = Y(
213
+ () => Se((l, c) => {
214
+ E?.(l, c || void 0);
215
+ }, 500),
216
+ [E]
217
+ ), r = Y(() => /* @__PURE__ */ e.jsxs("div", { className: "hfl-mb-1 hfl-flex hfl-w-max hfl-items-center hfl-rounded hfl-border-1 hfl-border-Warning-400 hfl-bg-Warning-50 hfl-p-1 hfl-px-2", children: [
218
+ /* @__PURE__ */ e.jsx("div", { className: "hx_warning hfl-text-Error-400" }),
219
+ /* @__PURE__ */ e.jsx(k, { variant: "Regular", type: "Text sm", className: "hfl-px-2 hfl-text-1 hfl-text-Error-500", children: "Dosage exceed safety limits" })
220
+ ] }), []);
221
+ J(() => () => {
222
+ I.cancel();
223
+ }, [I]);
224
+ const t = G(
225
+ (l, c) => {
226
+ d((h) => {
227
+ let S = { ...h.calculation_fields, [l]: c };
228
+ if (l === "frequency" && o === "standard") {
229
+ const P = ce[c] || [];
230
+ P.length > 0 && (S = {
231
+ ...S,
232
+ pedia_dosage: P[0]
233
+ });
234
+ }
235
+ const L = {
236
+ ...h,
237
+ calculation_fields: S
238
+ };
239
+ return o === "prescription" && I(L, l), L;
240
+ });
241
+ },
242
+ [I, o]
243
+ ), N = async () => {
244
+ const l = {
245
+ ...n,
246
+ calculation_fields: { ...n.calculation_fields }
247
+ };
248
+ await b?.(l) && I({ ...l, isNewlyAdded: !1, isEditing: !1 });
249
+ }, y = async () => {
250
+ if (!a.medicine_name || a.medicine_name.trim() === "") {
251
+ F?.(a.rowId);
252
+ return;
253
+ }
254
+ d(a), o === "standard" && _(!1);
255
+ }, q = (l) => o === "prescription" && (l === "medicine_name" || l === "generic_name" || l === "type" || l === "calculation_type") ? !1 : z, R = () => {
256
+ const l = !(n?.isSavedToLibrary ?? !1), c = { ...n, isSavedToLibrary: l };
257
+ d(c), I(c, "isSavedToLibrary");
258
+ };
259
+ return /* @__PURE__ */ e.jsxs(
260
+ "div",
261
+ {
262
+ className: `medicine-row hfl-grid hfl-grid-cols-[1.36fr_1.36fr_1.02fr_1.25fr_2.27fr_1.36fr_1.36fr] hfl-gap-2 hfl-px-2 hfl-py-1 hfl-border-b-1 hfl-border-Gray-200 ${z ? "hfl-bg-gradient-to-b hfl-from-White_20 hfl-to-Primary-50" : ""} ${o === "prescription" && !n.pedia_data_available ? "hfl-hidden" : ""}`,
263
+ children: [
264
+ /* @__PURE__ */ e.jsx("div", { className: "hfl-w-full hfl-py-2.5 hfl-min-w-0", children: q("medicine_name") ? /* @__PURE__ */ e.jsx(
265
+ g,
266
+ {
267
+ wrapperClass: "hfl-w-full",
268
+ btnClassName: "hfl-w-full",
269
+ inputClassName: "hfl-w-full",
270
+ inputValue: n.medicine_name,
271
+ showInput: !0,
272
+ disableInputAutoSize: !0,
273
+ inputChangeHandler: async (l) => {
274
+ if (D("medicine_name", l), l.trim()) {
275
+ const c = await C(l);
276
+ O(c);
277
+ } else
278
+ O([]);
279
+ },
280
+ onInputFocus: async () => {
281
+ const l = await C(n.medicine_name);
282
+ O(l);
283
+ },
284
+ onChangeHandler: (l) => {
285
+ const c = l.value, h = te.find((S) => S.val === c.medicineType);
286
+ d((S) => ({
287
+ ...S,
288
+ medicine_name: c.doctorMedicineName,
289
+ medicine_id: c.medicineId,
290
+ generic_name: c.doctorGenericName,
291
+ type: h?.type ?? ""
292
+ })), T(c.doctorMedicineName);
293
+ },
294
+ options: $,
295
+ isSearchable: !0,
296
+ placeholder: "Search medicine",
297
+ disabled: !n?.isNewlyAdded,
298
+ inputProps: {
299
+ onBlur: (l) => {
300
+ const c = l.relatedTarget;
301
+ if (!(c && c.closest(".custom-dropdown-menu")) && !w) {
302
+ const h = n.medicine_name?.trim() || "";
303
+ $.some((L) => L.label === h) || d((L) => ({ ...L, medicine_name: M }));
304
+ }
305
+ }
306
+ }
307
+ }
308
+ ) : /* @__PURE__ */ e.jsx(X, { children: a.medicine_name }) }),
309
+ /* @__PURE__ */ e.jsx("div", { className: "hfl-w-full hfl-py-2.5 hfl-min-w-0", children: q("generic_name") ? /* @__PURE__ */ e.jsx(
310
+ g,
311
+ {
312
+ wrapperClass: "hfl-w-full",
313
+ inputClassName: "hfl-w-full",
314
+ btnClassName: "hfl-w-full",
315
+ inputValue: n.generic_name,
316
+ showInput: !0,
317
+ disableInputAutoSize: !0,
318
+ inputChangeHandler: (l) => D("generic_name", l),
319
+ hideDropdownIcon: !0
320
+ }
321
+ ) : /* @__PURE__ */ e.jsx(X, { children: a.generic_name }) }),
322
+ /* @__PURE__ */ e.jsx("div", { className: "hfl-w-full hfl-py-2.5 hfl-min-w-0", children: q("type") ? /* @__PURE__ */ e.jsx(
323
+ g,
324
+ {
325
+ wrapperClass: "hfl-w-full",
326
+ btnClassName: "hfl-w-full",
327
+ placeholder: "Select",
328
+ showInput: !1,
329
+ disableInputAutoSize: !0,
330
+ selectedOption: (() => {
331
+ const l = te.find((c) => c.type === n.type);
332
+ return l ? { label: l.type, value: l.type } : void 0;
333
+ })(),
334
+ options: te.map((l) => ({
335
+ label: l.type,
336
+ value: l.type
337
+ })),
338
+ onChangeHandler: (l) => D("type", l.value)
339
+ }
340
+ ) : /* @__PURE__ */ e.jsx(X, { children: a.type || "" }) }),
341
+ /* @__PURE__ */ e.jsx("div", { className: "hfl-w-full hfl-py-2.5 hfl-min-w-0", children: q("calculation_type") ? /* @__PURE__ */ e.jsx(
342
+ g,
343
+ {
344
+ wrapperClass: "hfl-w-full",
345
+ btnClassName: "hfl-w-full",
346
+ placeholder: "Select",
347
+ showInput: !1,
348
+ disableInputAutoSize: !0,
349
+ selectedOption: { label: n.calculation_type, value: n.calculation_type },
350
+ options: ae.map((l) => ({ label: l, value: l })),
351
+ onChangeHandler: (l) => D("calculation_type", l.value)
352
+ }
353
+ ) : /* @__PURE__ */ e.jsx(X, { children: a.calculation_type }) }),
354
+ /* @__PURE__ */ e.jsx("div", { className: "hfl-flex hfl-w-full hfl-flex-col hfl-gap-2 hfl-py-2.5 hfl-px-2", children: q("calculation_fields") ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
355
+ f && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
356
+ /* @__PURE__ */ e.jsx(B, { label: "Drug Strength", children: /* @__PURE__ */ e.jsx(
357
+ g,
358
+ {
359
+ wrapperClass: "hfl-w-full",
360
+ placeholder: "e.g., 250",
361
+ showInput: !0,
362
+ hideDropdownIcon: !0,
363
+ disableInputAutoSize: !0,
364
+ inputType: "text",
365
+ inputValue: f.drug_strength || "",
366
+ inputChangeHandler: (l) => {
367
+ V(l) && t("drug_strength", l);
368
+ }
369
+ }
370
+ ) }),
371
+ /* @__PURE__ */ e.jsx(B, { label: "Dose/mg/kg", children: /* @__PURE__ */ e.jsx(
372
+ g,
373
+ {
374
+ wrapperClass: "hfl-w-full",
375
+ placeholder: "e.g., 15",
376
+ showInput: !0,
377
+ hideDropdownIcon: !0,
378
+ disableInputAutoSize: !0,
379
+ inputType: "text",
380
+ inputValue: f.dose_mg_kg || "",
381
+ inputChangeHandler: (l) => {
382
+ V(l) && t("dose_mg_kg", l);
383
+ }
384
+ }
385
+ ) }),
386
+ /* @__PURE__ */ e.jsx(B, { label: "Frequency", children: /* @__PURE__ */ e.jsx(
387
+ g,
388
+ {
389
+ wrapperClass: "hfl-w-full",
390
+ placeholder: "Frequency",
391
+ showInput: !1,
392
+ selectedOption: n.calculation_fields.frequency ? {
393
+ label: n.calculation_fields.frequency,
394
+ value: n.calculation_fields.frequency
395
+ } : void 0,
396
+ options: de.map((l) => ({ label: l, value: l })),
397
+ onChangeHandler: (l) => {
398
+ t("frequency", l.value);
399
+ }
400
+ }
401
+ ) }),
402
+ /* @__PURE__ */ e.jsx(B, { label: "Max Dose (mg)", children: /* @__PURE__ */ e.jsx(
403
+ g,
404
+ {
405
+ wrapperClass: "hfl-w-full",
406
+ placeholder: "Max mg/dose",
407
+ showInput: !0,
408
+ hideDropdownIcon: !0,
409
+ disableInputAutoSize: !0,
410
+ inputType: "text",
411
+ inputValue: f.max_mg_dose || "",
412
+ inputChangeHandler: (l) => {
413
+ V(l) && t("max_mg_dose", l);
414
+ }
415
+ }
416
+ ) }),
417
+ /* @__PURE__ */ e.jsx(B, { label: "Max Day (mg)", children: /* @__PURE__ */ e.jsx(
418
+ g,
419
+ {
420
+ wrapperClass: "hfl-w-full",
421
+ placeholder: "Max mg/day",
422
+ showInput: !0,
423
+ hideDropdownIcon: !0,
424
+ disableInputAutoSize: !0,
425
+ inputType: "text",
426
+ inputValue: f.max_mg_day || "",
427
+ inputChangeHandler: (l) => {
428
+ V(l) && t("max_mg_day", l);
429
+ }
430
+ }
431
+ ) })
432
+ ] }),
433
+ u && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
434
+ /* @__PURE__ */ e.jsx(B, { label: "Drug Strength/mL", children: /* @__PURE__ */ e.jsx(
435
+ g,
436
+ {
437
+ wrapperClass: "hfl-w-full",
438
+ placeholder: "e.g., 250",
439
+ showInput: !0,
440
+ hideDropdownIcon: !0,
441
+ disableInputAutoSize: !0,
442
+ inputType: "text",
443
+ inputValue: u.drug_strength || "",
444
+ inputChangeHandler: (l) => {
445
+ V(l) && (t("drug_strength", l), t("dose_ml_kg", ie(u.dose_mg_kg, l)));
446
+ }
447
+ }
448
+ ) }),
449
+ /* @__PURE__ */ e.jsx(B, { label: "Dose/mg/kg", children: /* @__PURE__ */ e.jsx(
450
+ g,
451
+ {
452
+ wrapperClass: "hfl-w-full",
453
+ placeholder: "e.g., 15",
454
+ showInput: !0,
455
+ hideDropdownIcon: !0,
456
+ disableInputAutoSize: !0,
457
+ inputType: "text",
458
+ inputValue: u.dose_mg_kg || "",
459
+ inputChangeHandler: (l) => {
460
+ V(l) && (t("dose_mg_kg", l), t("dose_ml_kg", ie(l, u.drug_strength)));
461
+ }
462
+ }
463
+ ) }),
464
+ /* @__PURE__ */ e.jsx(B, { label: "Dose/mL/kg", children: /* @__PURE__ */ e.jsx(
465
+ g,
466
+ {
467
+ wrapperClass: "hfl-w-full",
468
+ disabled: !0,
469
+ placeholder: "e.g., 5",
470
+ showInput: !0,
471
+ hideDropdownIcon: !0,
472
+ disableInputAutoSize: !0,
473
+ inputType: "text",
474
+ inputValue: ie(u.dose_mg_kg, u.drug_strength) || "",
475
+ inputChangeHandler: (l) => {
476
+ V(l) && t("dose_ml_kg", l);
477
+ }
478
+ }
479
+ ) }),
480
+ /* @__PURE__ */ e.jsx(B, { label: "Frequency", children: /* @__PURE__ */ e.jsx(
481
+ g,
482
+ {
483
+ wrapperClass: "hfl-w-full",
484
+ placeholder: "Frequency",
485
+ showInput: !1,
486
+ selectedOption: n.calculation_fields.frequency ? {
487
+ label: n.calculation_fields.frequency,
488
+ value: n.calculation_fields.frequency
489
+ } : void 0,
490
+ options: de.map((l) => ({ label: l, value: l })),
491
+ onChangeHandler: (l) => {
492
+ t("frequency", l.value);
493
+ }
494
+ }
495
+ ) }),
496
+ /* @__PURE__ */ e.jsx(B, { label: "Max Dose (mL)", children: /* @__PURE__ */ e.jsx(
497
+ g,
498
+ {
499
+ wrapperClass: "hfl-w-full",
500
+ placeholder: "Max mL/dose",
501
+ showInput: !0,
502
+ hideDropdownIcon: !0,
503
+ disableInputAutoSize: !0,
504
+ inputType: "text",
505
+ inputValue: u.max_ml_dose || "",
506
+ inputChangeHandler: (l) => {
507
+ V(l) && t("max_ml_dose", l);
508
+ }
509
+ }
510
+ ) }),
511
+ /* @__PURE__ */ e.jsx(B, { label: "Max Day (mL)", children: /* @__PURE__ */ e.jsx(
512
+ g,
513
+ {
514
+ wrapperClass: "hfl-w-full",
515
+ placeholder: "Max mL/day",
516
+ showInput: !0,
517
+ hideDropdownIcon: !0,
518
+ disableInputAutoSize: !0,
519
+ inputType: "text",
520
+ inputValue: u.max_ml_day || "",
521
+ inputChangeHandler: (l) => {
522
+ V(l) && t("max_ml_day", l);
523
+ }
524
+ }
525
+ ) })
526
+ ] })
527
+ ] }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
528
+ f && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
529
+ /* @__PURE__ */ e.jsx(H, { label: "Drug Strength", value: f.drug_strength }),
530
+ /* @__PURE__ */ e.jsx(H, { label: "Dose/mg/kg", value: f.dose_mg_kg }),
531
+ /* @__PURE__ */ e.jsx(H, { label: "Frequency", value: f.frequency }),
532
+ /* @__PURE__ */ e.jsx(H, { label: "Max Dose (mg)", value: f.max_mg_dose }),
533
+ /* @__PURE__ */ e.jsx(H, { label: "Max Day (mg)", value: f.max_mg_day })
534
+ ] }),
535
+ u && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
536
+ /* @__PURE__ */ e.jsx(H, { label: "Drug Strength/mL", value: u.drug_strength }),
537
+ /* @__PURE__ */ e.jsx(H, { label: "Dose/mg/kg", value: u.dose_mg_kg }),
538
+ /* @__PURE__ */ e.jsx(H, { label: "Dose/mL/kg", value: u.dose_ml_kg }),
539
+ /* @__PURE__ */ e.jsx(H, { label: "Frequency", value: u.frequency }),
540
+ /* @__PURE__ */ e.jsx(H, { label: "Max Dose (mL)", value: u.max_ml_dose }),
541
+ /* @__PURE__ */ e.jsx(H, { label: "Max Day (mL)", value: u.max_ml_day })
542
+ ] })
543
+ ] }) }),
544
+ /* @__PURE__ */ e.jsx("div", { className: "hfl-w-full hfl-py-2.5 hfl-min-w-0", children: q("pedia_dosage") ? (() => {
545
+ const l = n.calculation_fields.frequency, c = ce[l] || [];
546
+ return /* @__PURE__ */ e.jsx(e.Fragment, { children: /* @__PURE__ */ e.jsx(
547
+ g,
548
+ {
549
+ wrapperClass: "hfl-w-full",
550
+ btnClassName: "hfl-w-full",
551
+ inputClassName: "hfl-w-full",
552
+ placeholder: "Select",
553
+ showInput: o !== "standard",
554
+ disableInputAutoSize: !0,
555
+ inputValue: o === "standard" ? n.calculation_fields.pedia_dosage : n.pedia_dosage,
556
+ inputChangeHandler: (h) => o === "prescription" ? D("pedia_dosage", h) : t("pedia_dosage", h),
557
+ selectedOption: o === "standard" ? {
558
+ label: n.calculation_fields.pedia_dosage,
559
+ value: n.calculation_fields.pedia_dosage
560
+ } : void 0,
561
+ options: o !== "prescription" ? c.map((h) => ({ label: h, value: h })) : void 0,
562
+ onChangeHandler: o !== "prescription" ? (h) => t("pedia_dosage", h.value) : void 0,
563
+ hideDropdownIcon: o === "prescription",
564
+ showEmptyDropdownPopup: o !== "prescription",
565
+ showErrorMsg: o === "prescription" ? s || p : !1,
566
+ errorMsg: o === "prescription" && s ? "Dosage Exceeds Safety Limits" : o === "prescription" && p ? "Dosage is in mismatch with selected type of Frequency" : ""
567
+ }
568
+ ) });
569
+ })() : /* @__PURE__ */ e.jsxs("div", { className: "hfl-flex hfl-flex-col hfl-h-full hfl-justify-between hfl-min-w-0", children: [
570
+ /* @__PURE__ */ e.jsx(X, { children: o === "prescription" ? a.pedia_dosage : a.calculation_fields.pedia_dosage }),
571
+ s && r
572
+ ] }) }),
573
+ /* @__PURE__ */ e.jsx("div", { className: "hfl-w-full hfl-py-2.5 hfl-min-w-0", children: /* @__PURE__ */ e.jsx(
574
+ Me,
575
+ {
576
+ effectiveEditMode: z,
577
+ rowData: a,
578
+ isSavedToLibrary: n.isSavedToLibrary ?? !1,
579
+ onSave: N,
580
+ onCancel: y,
581
+ onEdit: () => _(!0),
582
+ onCheckboxToggle: R
583
+ }
584
+ ) })
585
+ ]
586
+ }
587
+ );
588
+ },
589
+ (i, a) => i.isEditing === a.isEditing && i.rowData.rowId === a.rowData.rowId && i.rowData.isEditing === a.rowData.isEditing && i.rowData.medicine_name === a.rowData.medicine_name && i.rowData.generic_name === a.rowData.generic_name && i.rowData.type === a.rowData.type && i.rowData.pedia_dosage === a.rowData.pedia_dosage && i.rowData.calculation_type === a.rowData.calculation_type && JSON.stringify(i.rowData.calculation_fields) === JSON.stringify(a.rowData.calculation_fields) && i.rowData.out_of_range === a.rowData.out_of_range && i.rowData.isDosageMismatch === a.rowData.isDosageMismatch && i.rowData.calculation_fields.pedia_dosage === a.rowData.calculation_fields.pedia_dosage && i.rowData?.isNewlyAdded === a.rowData?.isNewlyAdded && i.rowData?.pedia_data_available === a.rowData?.pedia_data_available
590
+ ), Ee = ({ open: i, onCancel: a, onCopySave: x, rowMedicineData: _, getMedicineOptions: b }) => {
591
+ const [w, o] = W([]), [j, A] = W(""), [v, E] = W([]), F = G(
592
+ async (d) => {
593
+ const T = (await b?.(d))?.map(
594
+ (C) => ({
595
+ label: C.doctorMedicineName,
596
+ value: C
597
+ })
598
+ );
599
+ E(T || []);
600
+ },
601
+ [b]
602
+ );
603
+ J(() => {
604
+ i && F(j);
605
+ }, [j, F, i]);
606
+ const $ = (d) => {
607
+ const M = d.value;
608
+ w.some(
609
+ (C) => C.medicineId === M.medicineId && C.doctorMedicineName.trim().toLowerCase() === M.doctorMedicineName.trim().toLowerCase()
610
+ ) || o((C) => [...C, M]), A(""), E([]);
611
+ }, O = (d) => {
612
+ o((M) => M.filter((T) => T.medicineId !== d));
613
+ }, n = async () => {
614
+ j.trim() || await F("");
615
+ };
616
+ return /* @__PURE__ */ e.jsxs(
617
+ ye,
618
+ {
619
+ isOpen: i,
620
+ onRequestClose: a,
621
+ shouldCloseOnOverlayClick: !1,
622
+ style: {
623
+ overlay: {
624
+ backgroundColor: "rgba(52, 64, 84, 0.5)",
625
+ zIndex: 1030
626
+ },
627
+ content: {
628
+ zIndex: 1031,
629
+ maxWidth: "600px",
630
+ maxHeight: "50vh",
631
+ height: "auto",
632
+ margin: "auto",
633
+ borderRadius: "12px",
634
+ padding: "0px",
635
+ display: "flex",
636
+ flexDirection: "column"
637
+ }
638
+ },
639
+ children: [
640
+ /* @__PURE__ */ e.jsx(
641
+ k,
642
+ {
643
+ variant: "Bold",
644
+ type: "Text lg",
645
+ className: "hfl-text-White hfl-bg-gradient_primary_600_500_90 hfl-px-6 hfl-py-2",
646
+ children: "Please select medicine to copy"
647
+ }
648
+ ),
649
+ /* @__PURE__ */ e.jsxs("div", { className: "hfl-px-6 hfl-py-5 hfl-flex hfl-flex-col hfl-gap-6 hfl-overflow-y-auto hfl-flex-1", children: [
650
+ /* @__PURE__ */ e.jsx(
651
+ g,
652
+ {
653
+ inputValue: j,
654
+ showInput: !0,
655
+ isSearchable: !0,
656
+ disableInputAutoSize: !0,
657
+ inputChangeHandler: A,
658
+ onChangeHandler: $,
659
+ onInputFocus: n,
660
+ options: v,
661
+ placeholder: "Search for medicines"
662
+ }
663
+ ),
664
+ /* @__PURE__ */ e.jsx("div", { className: "hfl-flex hfl-flex-wrap hfl-gap-2", children: w.map((d) => /* @__PURE__ */ e.jsxs(
665
+ "div",
666
+ {
667
+ className: "hfl-flex hfl-items-center hfl-bg-Gray-100 hfl-px-2 hfl-py-0.5 hfl-rounded-md hfl-gap-1",
668
+ children: [
669
+ /* @__PURE__ */ e.jsx(k, { variant: "Regular", type: "Text sm", className: "hfl-text-nowrap", children: d.doctorMedicineName }),
670
+ /* @__PURE__ */ e.jsx("button", { className: "hfl-text-Blue_gray-800", onClick: () => O(d.medicineId), children: /* @__PURE__ */ e.jsx("i", { className: "hx_close" }) })
671
+ ]
672
+ },
673
+ d.doctorMedicineName + d.medicineId
674
+ )) })
675
+ ] }),
676
+ /* @__PURE__ */ e.jsxs("div", { className: "hfl-flex hfl-justify-end hfl-gap-2.5 hfl-bg-Gray-50 hfl-px-7 hfl-py-3 hfl-border-t hfl-border-Gray-200", children: [
677
+ /* @__PURE__ */ e.jsx(oe, { size: "md", textField: "Cancel", onClick: a, hierarchy: "Secondary-Grey" }),
678
+ /* @__PURE__ */ e.jsx(
679
+ oe,
680
+ {
681
+ size: "md",
682
+ textField: "Save",
683
+ disabled: !w || w.length == 0,
684
+ onClick: async () => {
685
+ await x(_, w) && a();
686
+ },
687
+ className: "hfl-bg-Primary-600 hfl-text-White disabled:hfl-opacity-50 disabled:hfl-cursor-not-allowed",
688
+ hierarchy: "Primary"
689
+ }
690
+ )
691
+ ] })
692
+ ]
693
+ }
694
+ );
695
+ }, Ae = je(
696
+ ({
697
+ data: i = [],
698
+ variant: a,
699
+ externallyTriggeredEditRowIds: x = [],
700
+ externallyTriggeredEditMode: _ = !1,
701
+ allowCustomMedicineInput: b = !0,
702
+ getMedicineOptions: w,
703
+ onRowChange: o,
704
+ onRowDelete: j,
705
+ onRowCopy: A,
706
+ onSaveRow: v,
707
+ externalSaveTrigger: E,
708
+ setSearchDisabled: F
709
+ }, $) => {
710
+ const [O, n] = W(null), [d, M] = W(!1), [T, C] = W(), Z = G(
711
+ (r, t, N) => {
712
+ const y = i.find((R) => R.rowId === r);
713
+ if (!y) return;
714
+ const q = { ...y, ...t };
715
+ o?.(q, N || void 0);
716
+ },
717
+ [i, o]
718
+ ), z = G(async () => {
719
+ const r = i.filter((t) => t.isEditing && t.medicine_name);
720
+ if (r.length !== 0)
721
+ try {
722
+ await v?.(r) && r.forEach((N) => {
723
+ o?.({ ...N, isEditing: !1 });
724
+ });
725
+ } catch (t) {
726
+ console.error("Bulk save failed", t);
727
+ } finally {
728
+ F?.(!1);
729
+ }
730
+ }, [i, v, o, F]);
731
+ J(() => {
732
+ E && z();
733
+ }, [E, z]), J(() => {
734
+ const r = i.some((t) => t.isEditing);
735
+ F?.(r);
736
+ }, [i, F]);
737
+ const s = G((r) => {
738
+ C(r), M(!0);
739
+ }, []), p = G(async () => {
740
+ if (O)
741
+ try {
742
+ await j?.(O);
743
+ } catch (r) {
744
+ console.error("Delete failed", r);
745
+ } finally {
746
+ n(null);
747
+ }
748
+ }, [O, j]), f = G(() => {
749
+ n(null);
750
+ }, []), u = G(
751
+ async (r) => {
752
+ try {
753
+ return await v?.([r]) ? (o?.({ ...r, isEditing: !1 }), !0) : !1;
754
+ } catch (t) {
755
+ return console.error("Save row failed", t), !1;
756
+ }
757
+ },
758
+ [v, o]
759
+ ), D = G(async () => {
760
+ const r = i.filter((t) => t.isEditing && t.medicine_name);
761
+ if (r.length === 0) return !0;
762
+ try {
763
+ const t = await v?.(r);
764
+ return t && i.map((y) => y.isEditing ? { ...y, isEditing: !1 } : y).forEach((y) => o?.(y)), !!t;
765
+ } catch (t) {
766
+ return console.error("External bulk save failed", t), !1;
767
+ }
768
+ }, [i, v, o]);
769
+ ve($, () => ({
770
+ triggerExternalSave: D
771
+ }));
772
+ const I = {
773
+ variant: a,
774
+ externallyTriggeredEditMode: _,
775
+ externallyTriggeredEditRowIds: x,
776
+ getMedicineOptions: w,
777
+ onRowChange: (r, t) => {
778
+ Z(r.rowId, r, t), o?.(r, t);
779
+ },
780
+ onRowDelete: j,
781
+ onRowCopy: A,
782
+ setRowToDelete: n,
783
+ openPopupForRow: s
784
+ };
785
+ return /* @__PURE__ */ e.jsxs("div", { className: "hfl-border-1 hfl-border-Gray-200", children: [
786
+ /* @__PURE__ */ e.jsx("div", { className: "table-header hfl-grid hfl-grid-cols-[1.36fr_1.36fr_1.02fr_1.25fr_2.27fr_1.36fr_1.36fr] hfl-gap-2 hfl-py-2 hfl-px-2 hfl-font-bold hfl-border-b-1 hfl-border-Gray-200 hfl-bg-Blue_gray-50", children: Ne.map((r) => /* @__PURE__ */ e.jsx(k, { variant: "Medium", type: "Text sm", className: "hfl-text-Blue_gray-600", children: r }, r)) }),
787
+ /* @__PURE__ */ e.jsxs(fe.Provider, { value: I, children: [
788
+ /* @__PURE__ */ e.jsx("div", { className: "table-body", children: i.length === 0 ? /* @__PURE__ */ e.jsx(k, { variant: "Medium", type: "Text sm", className: "hfl-text-Blue_gray-600 hfl-px-2 hfl-py-3", children: "No medicines added" }) : i.map((r) => /* @__PURE__ */ e.jsx(
789
+ ke,
790
+ {
791
+ rowData: r,
792
+ isEditing: r.isEditing || !1,
793
+ setIsEditing: (t) => Z(r.rowId, { isEditing: t }),
794
+ onSaveRow: u,
795
+ allowCustomMedicineInput: b
796
+ },
797
+ r.rowId
798
+ )) }),
799
+ /* @__PURE__ */ e.jsx(
800
+ _e,
801
+ {
802
+ headingText: "Delete Medicine",
803
+ subHeadingText: "Are you sure you want to delete this medicine?",
804
+ openState: !!O,
805
+ positiveButtonText: "Delete",
806
+ negativeButtonText: "Cancel",
807
+ positiveActionCallback: p,
808
+ negativeActionCallback: f,
809
+ classNameNegativeBtn: "hfl-bg-Blue-600",
810
+ classNamePositiveBtn: "hfl-bg-Error-500 hover:hfl-bg-Error-700 hfl-text-White",
811
+ closePopupCallback: f
812
+ }
813
+ ),
814
+ /* @__PURE__ */ e.jsx(
815
+ Ee,
816
+ {
817
+ open: d,
818
+ onCancel: () => M(!1),
819
+ onCopySave: A,
820
+ rowMedicineData: T,
821
+ getMedicineOptions: w
822
+ }
823
+ )
824
+ ] })
825
+ ] });
826
+ }
827
+ );
2
828
  export {
3
- f as default
829
+ Ae as default
4
830
  };