hplx-feature-library 1.0.69 → 1.0.70

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