@argusoft/medplat-product-management 1.0.3 → 1.0.4

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 (61) hide show
  1. package/dist/{BrandsPage-NSvaMXWg.js → BrandsPage-BE3kn-8b.js} +79 -78
  2. package/dist/{BrandsPage-NSvaMXWg.js.map → BrandsPage-BE3kn-8b.js.map} +1 -1
  3. package/dist/{CategoriesPage-aZBZrDOi.js → CategoriesPage-COqi3pMi.js} +70 -69
  4. package/dist/{CategoriesPage-aZBZrDOi.js.map → CategoriesPage-COqi3pMi.js.map} +1 -1
  5. package/dist/{DashboardPage-DjwlOhrd.js → DashboardPage-C_H1Jrey.js} +91 -90
  6. package/dist/{DashboardPage-DjwlOhrd.js.map → DashboardPage-C_H1Jrey.js.map} +1 -1
  7. package/dist/{FacilityPicker-Chh-ZaR0.js → FacilityPicker-Diq2hnYg.js} +2 -2
  8. package/dist/{FacilityPicker-Chh-ZaR0.js.map → FacilityPicker-Diq2hnYg.js.map} +1 -1
  9. package/dist/{InventoryPage-cy76UsMp.js → InventoryPage-Bjpw6vTz.js} +113 -112
  10. package/dist/{InventoryPage-cy76UsMp.js.map → InventoryPage-Bjpw6vTz.js.map} +1 -1
  11. package/dist/{MemberProfileCard-CinPt09F.js → MemberProfileCard-BLUVRILO.js} +6 -5
  12. package/dist/{MemberProfileCard-CinPt09F.js.map → MemberProfileCard-BLUVRILO.js.map} +1 -1
  13. package/dist/{PaymentCreatePage-BJe3LyFF.js → PaymentCreatePage-B5VOgTx9.js} +125 -124
  14. package/dist/{PaymentCreatePage-BJe3LyFF.js.map → PaymentCreatePage-B5VOgTx9.js.map} +1 -1
  15. package/dist/{PaymentsPage-DxHoKksN.js → PaymentsPage-DY6BclkN.js} +21 -20
  16. package/dist/{PaymentsPage-DxHoKksN.js.map → PaymentsPage-DY6BclkN.js.map} +1 -1
  17. package/dist/{PickupCreatePage-Cq8zJ62Y.js → PickupCreatePage-CCSiyFQF.js} +63 -62
  18. package/dist/{PickupCreatePage-Cq8zJ62Y.js.map → PickupCreatePage-CCSiyFQF.js.map} +1 -1
  19. package/dist/{PickupsPage-BOygBQAb.js → PickupsPage-DGi6T5Of.js} +42 -41
  20. package/dist/{PickupsPage-BOygBQAb.js.map → PickupsPage-DGi6T5Of.js.map} +1 -1
  21. package/dist/PmGuard-C90yhpsN.js +592 -0
  22. package/dist/PmGuard-C90yhpsN.js.map +1 -0
  23. package/dist/{PmTable-CCpaJEA_.js → PmTable-BkK65bJQ.js} +96 -96
  24. package/dist/{PmTable-CCpaJEA_.js.map → PmTable-BkK65bJQ.js.map} +1 -1
  25. package/dist/{ProductEditPage-DmdHO-fS.js → ProductEditPage-CQj9egzW.js} +130 -129
  26. package/dist/{ProductEditPage-DmdHO-fS.js.map → ProductEditPage-CQj9egzW.js.map} +1 -1
  27. package/dist/{ProductsPage-BglMe8EM.js → ProductsPage-i8QVw_Jm.js} +64 -63
  28. package/dist/{ProductsPage-BglMe8EM.js.map → ProductsPage-i8QVw_Jm.js.map} +1 -1
  29. package/dist/{PurchaseCreatePage-1tYk41RS.js → PurchaseCreatePage-Bp6bl9n8.js} +120 -119
  30. package/dist/{PurchaseCreatePage-1tYk41RS.js.map → PurchaseCreatePage-Bp6bl9n8.js.map} +1 -1
  31. package/dist/{PurchaseRequestDetailPage-BYLx3aBI.js → PurchaseRequestDetailPage-CNAqIFef.js} +216 -215
  32. package/dist/{PurchaseRequestDetailPage-BYLx3aBI.js.map → PurchaseRequestDetailPage-CNAqIFef.js.map} +1 -1
  33. package/dist/{PurchaseRequestsPage-D2yorc4s.js → PurchaseRequestsPage-BJqDlNrc.js} +57 -56
  34. package/dist/{PurchaseRequestsPage-D2yorc4s.js.map → PurchaseRequestsPage-BJqDlNrc.js.map} +1 -1
  35. package/dist/{PurchasesPage-CanQTjlw.js → PurchasesPage-BQEToymQ.js} +76 -75
  36. package/dist/{PurchasesPage-CanQTjlw.js.map → PurchasesPage-BQEToymQ.js.map} +1 -1
  37. package/dist/{SaleCreatePage-DxFvPvju.js → SaleCreatePage-DbfBK4PH.js} +89 -88
  38. package/dist/{SaleCreatePage-DxFvPvju.js.map → SaleCreatePage-DbfBK4PH.js.map} +1 -1
  39. package/dist/{SalesPage-CPMrdr5-.js → SalesPage-CTBJMxZe.js} +46 -45
  40. package/dist/{SalesPage-CPMrdr5-.js.map → SalesPage-CTBJMxZe.js.map} +1 -1
  41. package/dist/{SettingsPage-CEy922rW.js → SettingsPage-CiwVmzM3.js} +47 -46
  42. package/dist/{SettingsPage-CEy922rW.js.map → SettingsPage-CiwVmzM3.js.map} +1 -1
  43. package/dist/{StorageUnitsPage-DfLT6xC_.js → StorageUnitsPage-BV7nK_iE.js} +55 -54
  44. package/dist/{StorageUnitsPage-DfLT6xC_.js.map → StorageUnitsPage-BV7nK_iE.js.map} +1 -1
  45. package/dist/{TransactionsPage-KFUJ4O5g.js → TransactionsPage-Cocn4901.js} +54 -53
  46. package/dist/{TransactionsPage-KFUJ4O5g.js.map → TransactionsPage-Cocn4901.js.map} +1 -1
  47. package/dist/{TransferCreatePage-k1tsRGB3.js → TransferCreatePage-DbjcjuOg.js} +74 -73
  48. package/dist/{TransferCreatePage-k1tsRGB3.js.map → TransferCreatePage-DbjcjuOg.js.map} +1 -1
  49. package/dist/{TransfersPage-CDafSVO9.js → TransfersPage-BFVF7Xvc.js} +108 -107
  50. package/dist/{TransfersPage-CDafSVO9.js.map → TransfersPage-BFVF7Xvc.js.map} +1 -1
  51. package/dist/VialsPage-BNzYTLVd.js +321 -0
  52. package/dist/VialsPage-BNzYTLVd.js.map +1 -0
  53. package/dist/index.js +652 -34
  54. package/dist/index.js.map +1 -1
  55. package/dist/settingsStore-KW217unV.js +417 -0
  56. package/dist/settingsStore-KW217unV.js.map +1 -0
  57. package/package.json +1 -1
  58. package/dist/VialsPage-DPsYFgaQ.js +0 -897
  59. package/dist/VialsPage-DPsYFgaQ.js.map +0 -1
  60. package/dist/currency-bVQ7aEk2.js +0 -1007
  61. package/dist/currency-bVQ7aEk2.js.map +0 -1
@@ -1,897 +0,0 @@
1
- import { F as e, J as t, L as n, M as r, O as i, P as a, a as o, i as s, l as ee, n as c, o as te, p as l, r as ne, u } from "./currency-bVQ7aEk2.js";
2
- import { c as d, o as f, s as p, t as m } from "./PmTable-CCpaJEA_.js";
3
- import { m as h, t as g, u as _ } from "./validation-Ba7puFIO.js";
4
- import { t as v } from "./useFieldErrors-hDG8ox_x.js";
5
- import { n as y, r as b, t as re } from "./format-UOyOu75i.js";
6
- import { d as ie, f as ae, p as oe } from "./constants-5ZCZo-Zm.js";
7
- import { useMemo as se, useState as x } from "react";
8
- import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
9
- import { v4 as ce } from "uuid";
10
- import { Alert as T, Box as E, Button as D, Chip as O, Dialog as le, DialogActions as ue, DialogContent as de, DialogTitle as fe, LinearProgress as pe, Radio as me, Stack as k, Table as he, TableBody as A, TableCell as j, TableContainer as ge, TableHead as M, TableRow as N, TextField as _e, Tooltip as ve, Typography as P } from "@mui/material";
11
- import ye from "@mui/icons-material/RefreshRounded";
12
- import { showToast as F } from "@/common/toaster/toaster";
13
- import I from "@mui/icons-material/VaccinesRounded";
14
- //#region src/views/VialsPage.jsx
15
- function L(e) {
16
- let t = e.expiresAt ? new Date(e.expiresAt).getTime() : Infinity, n = Infinity;
17
- if (e.batchExpiryDate) {
18
- let t = new Date(e.batchExpiryDate);
19
- t.setHours(23, 59, 59, 999), n = t.getTime();
20
- }
21
- return Math.min(t, n);
22
- }
23
- function be(e) {
24
- return e.expiryDate ? new Date(e.expiryDate).getTime() : Infinity;
25
- }
26
- var R = {
27
- open: !1,
28
- step: "product",
29
- mode: "use-existing",
30
- productId: "",
31
- ownerType: "",
32
- ownerId: "",
33
- personalSource: "",
34
- allVials: [],
35
- allBatches: [],
36
- sources: [],
37
- vialCandidates: [],
38
- batchCandidates: [],
39
- selectedVialId: "",
40
- selectedBatchId: "",
41
- volumeMl: "",
42
- loading: !1
43
- };
44
- function xe() {
45
- let xe = o().has("update.manage.productManagement.vial"), [z, Se] = x([]), [Ce, we] = x([]), [B, Te] = x([]), [Ee, De] = x([]), [V, Oe] = x([]), ke = ee()?.allowPersonalPurchase !== !1, [H, Ae] = x(!1), [je, Me] = x(""), [U, W] = x({
46
- open: !1,
47
- vial: null,
48
- reason: "TIME_EXPIRATION",
49
- comments: ""
50
- }), [G, K] = x(R), q = v(), J = v();
51
- async function Y() {
52
- Ae(!0), Me("");
53
- try {
54
- let [t, o, s, ee, c] = await Promise.all([
55
- n(),
56
- r(),
57
- i(),
58
- a().catch(() => []),
59
- e().catch(() => [])
60
- ]);
61
- Se(t), we(o), Te(s), De(ee), Oe(c);
62
- } catch (e) {
63
- Me(e?.response?.data?.message ?? e?.message ?? "Failed to load"), F({
64
- message: e?.message || "Failed to load",
65
- type: "error"
66
- });
67
- } finally {
68
- Ae(!1);
69
- }
70
- }
71
- s("view.manage.productManagement.vial", () => {
72
- Y();
73
- }, []);
74
- let Ne = se(() => B.filter((e) => e.categoryCode === "VACCINES" && e.isActive).sort((e, t) => e.name.localeCompare(t.name)), [B]), Pe = { wastageReason: h(U.reason, "Reason") }, Fe = g(Pe);
75
- async function Ie() {
76
- if (U.vial) {
77
- if (!Fe) {
78
- q.markAllTouched();
79
- return;
80
- }
81
- try {
82
- await l({
83
- id: ce(),
84
- openVialId: U.vial.id,
85
- wastageReason: U.reason,
86
- comments: U.comments || null
87
- }), F({
88
- message: "Vial closed.",
89
- type: "success"
90
- }), W({
91
- open: !1,
92
- vial: null,
93
- reason: "TIME_EXPIRATION",
94
- comments: ""
95
- }), await Y();
96
- } catch (e) {
97
- F({
98
- message: e?.response?.data?.message ?? e?.message ?? "Failed",
99
- type: "error"
100
- });
101
- }
102
- }
103
- }
104
- function Le() {
105
- J.reset(), K(R);
106
- }
107
- function Re(e, t = Ce) {
108
- let n = (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0);
109
- return t.filter((t) => t.productId === e && t.qtyRemaining > 0 && !t.isQuarantined && (!t.expiryDate || new Date(t.expiryDate).getTime() >= n)).sort((e, t) => be(e) - be(t));
110
- }
111
- async function ze() {
112
- if (!G.productId) {
113
- J.markAllTouched();
114
- return;
115
- }
116
- K((e) => ({
117
- ...e,
118
- loading: !0
119
- }));
120
- try {
121
- let [e, n, i] = await Promise.all([
122
- t(G.productId),
123
- r().catch(() => Ce),
124
- a().catch(() => Ee)
125
- ]);
126
- we(n), De(i);
127
- let o = Date.now(), s = e.filter((e) => e.status === "OPEN" && !e.expired && L(e) > o && Number(e.volumeRemainingMl) > 0).sort((e, t) => L(e) - L(t)), ee = e.reduce((e, t) => (t.status === "OPEN" && (e[t.batchId] = (e[t.batchId] || 0) + 1), e), {}), c = B.find((e) => e.id === G.productId)?.vaccineConfig, te = c?.maxConcurrentOpenVials ?? 2, l = Re(G.productId, n).filter((e) => (ee[e.id] || 0) < te), ne = /* @__PURE__ */ new Set(), u = [];
128
- function d(e, t, n, r = "") {
129
- let i = `${e}::${t ?? ""}::${r ?? ""}`;
130
- ne.has(i) || (ne.add(i), u.push({
131
- key: i,
132
- ownerType: e,
133
- ownerId: t ?? null,
134
- personalSource: r || null,
135
- label: n
136
- }));
137
- }
138
- (s.some((e) => e.ownerType === "USER" && e.batchSourceType === "PICKUP") || l.some((e) => e.ownerType === "USER" && e.sourceType === "PICKUP")) && d("USER", null, "Personal (Outreach)", "OUTREACH");
139
- let f = s.some((e) => e.ownerType === "USER" && e.batchSourceType === "PURCHASE") || l.some((e) => e.ownerType === "USER" && e.sourceType === "PURCHASE");
140
- ke && f && d("USER", null, "Personal (Purchase)", "PURCHASE");
141
- let p = /* @__PURE__ */ new Set();
142
- s.forEach((e) => {
143
- e.ownerType === "FACILITY" && e.ownerId && p.add(e.ownerId);
144
- }), l.forEach((e) => {
145
- e.ownerType === "FACILITY" && e.ownerId && p.add(e.ownerId);
146
- }), p.forEach((e) => {
147
- d("FACILITY", e, `Facility — ${i.find((t) => t.id === e)?.name ?? e}`);
148
- });
149
- let m = u.length === 1 ? u[0] : null, h = m?.ownerType ?? "", g = m?.ownerId ?? "", _ = m?.personalSource ?? "", v = Be(s, l, h, g, _), y = v.vials.length > 0 ? "use-existing" : "open-new";
150
- K((e) => ({
151
- ...e,
152
- loading: !1,
153
- step: "select",
154
- mode: y,
155
- ownerType: h,
156
- ownerId: g,
157
- personalSource: _,
158
- allVials: s,
159
- allBatches: l,
160
- sources: u,
161
- vialCandidates: v.vials,
162
- batchCandidates: v.batches,
163
- selectedVialId: v.vials[0]?.id ?? "",
164
- selectedBatchId: v.batches[0]?.id ?? "",
165
- volumeMl: y === "use-existing" ? v.vials[0]?.adultDoseMl ?? c?.adultDoseMl ?? "" : c?.adultDoseMl ?? ""
166
- }));
167
- } catch (e) {
168
- K((e) => ({
169
- ...e,
170
- loading: !1
171
- })), F({
172
- message: e?.response?.data?.message ?? e?.message ?? "Failed to load vials",
173
- type: "error"
174
- });
175
- }
176
- }
177
- function Be(e, t, n, r, i) {
178
- if (!n) return {
179
- vials: [],
180
- batches: []
181
- };
182
- let a = n === "USER" && i ? i === "OUTREACH" ? "PICKUP" : "PURCHASE" : null;
183
- return {
184
- vials: e.filter((e) => e.ownerType === n && (n === "USER" ? !a || e.batchSourceType === a : e.ownerId === r)),
185
- batches: t.filter((e) => e.ownerType === n && (n === "USER" ? !a || e.sourceType === a : e.ownerId === r))
186
- };
187
- }
188
- function Ve(e) {
189
- let t = G.sources.find((t) => t.key === e);
190
- if (!t) return;
191
- let n = Be(G.allVials, G.allBatches, t.ownerType, t.ownerId, t.personalSource), r = B.find((e) => e.id === G.productId)?.vaccineConfig, i = n.vials.length > 0 ? "use-existing" : "open-new";
192
- K((e) => ({
193
- ...e,
194
- ownerType: t.ownerType,
195
- ownerId: t.ownerId ?? "",
196
- personalSource: t.personalSource ?? "",
197
- mode: i,
198
- vialCandidates: n.vials,
199
- batchCandidates: n.batches,
200
- selectedVialId: n.vials[0]?.id ?? "",
201
- selectedBatchId: n.batches[0]?.id ?? "",
202
- volumeMl: i === "use-existing" ? n.vials[0]?.adultDoseMl ?? r?.adultDoseMl ?? "" : r?.adultDoseMl ?? ""
203
- }));
204
- }
205
- function X(e) {
206
- K((t) => ({
207
- ...t,
208
- mode: e
209
- }));
210
- }
211
- let Z = G.vialCandidates.find((e) => e.id === G.selectedVialId), He = G.batchCandidates.find((e) => e.id === G.selectedBatchId), Q = B.find((e) => e.id === G.productId)?.vaccineConfig, $ = (() => {
212
- if (G.step === "product") return { productId: h(G.productId, "Vaccine") };
213
- let e = {
214
- ownerType: h(G.ownerType, "Source"),
215
- volumeMl: _(G.volumeMl, "Volume", { required: !0 })
216
- };
217
- if (G.mode === "use-existing") {
218
- if (e.selectedVialId = h(G.selectedVialId, "Vial"), !e.volumeMl && Z) {
219
- let t = Number(G.volumeMl), n = Number(Z.volumeRemainingMl);
220
- t > n && (e.volumeMl = G.batchCandidates.length > 0 ? `Only ${n.toFixed(2)} ml remaining in this vial — open another vial instead.` : `Only ${n.toFixed(2)} ml remaining in this vial.`);
221
- }
222
- } else if (e.selectedBatchId = h(G.selectedBatchId, "Batch"), !e.volumeMl && Q?.vialVolumeMl) {
223
- let t = Number(G.volumeMl), n = Number(Q.vialVolumeMl);
224
- t > n && (e.volumeMl = `A fresh vial holds ${n.toFixed(2)} ml`);
225
- }
226
- return e;
227
- })(), Ue = g($);
228
- async function We() {
229
- if (!Ue) {
230
- J.markAllTouched();
231
- return;
232
- }
233
- try {
234
- let e = {
235
- id: ce(),
236
- productId: G.productId,
237
- volumeMl: Number(G.volumeMl),
238
- ownerType: G.ownerType,
239
- ownerId: G.ownerType === "FACILITY" && G.ownerId || null,
240
- personalSource: G.ownerType === "USER" && G.personalSource || null
241
- };
242
- G.mode === "use-existing" ? e.openVialId = Z.id : e.batchId = He.id, await u(e), F({
243
- message: G.mode === "use-existing" ? "Dose administered." : "New vial opened and dose administered.",
244
- type: "success"
245
- }), Le(), await Y();
246
- } catch (e) {
247
- F({
248
- message: e?.response?.data?.message ?? e?.message ?? "Failed",
249
- type: "error"
250
- });
251
- }
252
- }
253
- return /* @__PURE__ */ w(E, { children: [/* @__PURE__ */ C(ne, {}), /* @__PURE__ */ w(c, {
254
- perm: "view.manage.productManagement.vial",
255
- children: [
256
- /* @__PURE__ */ w(te, {
257
- title: "Open Vials",
258
- subtitle: "Open vaccine vials in use. Close them at the end of the day and record any waste.",
259
- chips: ["Vaccine"],
260
- actions: /* @__PURE__ */ w(k, {
261
- direction: "row",
262
- spacing: 1,
263
- children: [/* @__PURE__ */ C(D, {
264
- variant: "outlined",
265
- startIcon: /* @__PURE__ */ C(ye, {}),
266
- onClick: () => void Y(),
267
- children: "Refresh"
268
- }), /* @__PURE__ */ C(D, {
269
- variant: "contained",
270
- startIcon: /* @__PURE__ */ C(I, {}),
271
- onClick: () => {
272
- J.reset(), K({
273
- ...R,
274
- open: !0
275
- });
276
- },
277
- children: "Administer Vaccine"
278
- })]
279
- }),
280
- children: [
281
- je ? /* @__PURE__ */ C(T, {
282
- severity: "error",
283
- sx: { mb: 2 },
284
- children: je
285
- }) : null,
286
- H ? /* @__PURE__ */ C(pe, { sx: { mb: 2 } }) : null,
287
- /* @__PURE__ */ C(d, {
288
- eyebrow: "In use",
289
- title: "Open vials",
290
- subtitle: H ? "Loading…" : `${z.length} ${z.length === 1 ? "vial" : "vials"} currently in use`,
291
- children: /* @__PURE__ */ w(p, {
292
- dense: !0,
293
- children: [/* @__PURE__ */ C(M, { children: /* @__PURE__ */ w(N, { children: [
294
- /* @__PURE__ */ C(j, { children: "Product" }),
295
- /* @__PURE__ */ C(j, { children: "Lot" }),
296
- /* @__PURE__ */ C(j, { children: "Owner" }),
297
- /* @__PURE__ */ C(j, { children: "Opened" }),
298
- /* @__PURE__ */ C(j, { children: "Expires" }),
299
- /* @__PURE__ */ C(j, { children: "Volume remaining" }),
300
- /* @__PURE__ */ C(j, { children: "Status" }),
301
- /* @__PURE__ */ C(j, {
302
- align: "right",
303
- children: "Action"
304
- })
305
- ] }) }), /* @__PURE__ */ C(A, { children: z.length === 0 && !H ? /* @__PURE__ */ C(m, {
306
- colSpan: 8,
307
- icon: I,
308
- title: "No open vials",
309
- hint: "Use Administer Vaccine to open and dose a vial."
310
- }) : z.map((e) => {
311
- let t = e.volumeTotalMl ? (1 - Number(e.volumeRemainingMl) / Number(e.volumeTotalMl)) * 100 : 0;
312
- return /* @__PURE__ */ w(N, {
313
- hover: !0,
314
- children: [
315
- /* @__PURE__ */ C(j, { children: /* @__PURE__ */ C(P, {
316
- variant: "body2",
317
- sx: { fontWeight: 700 },
318
- children: e.productName
319
- }) }),
320
- /* @__PURE__ */ C(j, { children: e.lotNumber ? /* @__PURE__ */ C(E, {
321
- component: "span",
322
- sx: {
323
- display: "inline-flex",
324
- px: .7,
325
- py: .1,
326
- borderRadius: 1,
327
- bgcolor: "grey.100",
328
- fontFamily: "monospace",
329
- fontSize: "0.72rem",
330
- fontWeight: 700
331
- },
332
- children: e.lotNumber
333
- }) : /* @__PURE__ */ C(P, {
334
- variant: "caption",
335
- color: "text.disabled",
336
- children: "—"
337
- }) }),
338
- /* @__PURE__ */ w(j, { children: [/* @__PURE__ */ C(P, {
339
- variant: "body2",
340
- sx: { fontWeight: 700 },
341
- children: e.ownerName || (e.ownerType === "USER" ? "Personal" : "Facility")
342
- }), /* @__PURE__ */ C(P, {
343
- variant: "caption",
344
- color: "text.secondary",
345
- children: e.ownerType ?? "—"
346
- })] }),
347
- /* @__PURE__ */ C(j, { children: /* @__PURE__ */ C(P, {
348
- variant: "caption",
349
- sx: { fontWeight: 600 },
350
- children: y(e.openedAt)
351
- }) }),
352
- /* @__PURE__ */ C(j, { children: /* @__PURE__ */ C(ve, {
353
- title: e.expired ? "Expired — close out immediately" : "",
354
- children: /* @__PURE__ */ C(O, {
355
- size: "small",
356
- color: e.expired ? "error" : "success",
357
- label: y(e.expiresAt),
358
- sx: {
359
- fontWeight: 700,
360
- borderRadius: 1.5,
361
- height: 22
362
- }
363
- })
364
- }) }),
365
- /* @__PURE__ */ C(j, { children: /* @__PURE__ */ w(k, {
366
- direction: "row",
367
- alignItems: "center",
368
- spacing: 1,
369
- children: [/* @__PURE__ */ w(P, {
370
- variant: "body2",
371
- sx: {
372
- fontWeight: 800,
373
- fontVariantNumeric: "tabular-nums",
374
- minWidth: 80
375
- },
376
- children: [
377
- b(e.volumeRemainingMl),
378
- " /",
379
- " ",
380
- b(e.volumeTotalMl),
381
- " ml"
382
- ]
383
- }), /* @__PURE__ */ C(E, {
384
- sx: { width: 80 },
385
- children: /* @__PURE__ */ C(pe, {
386
- variant: "determinate",
387
- value: t,
388
- sx: {
389
- height: 4,
390
- borderRadius: 2
391
- },
392
- color: t > 75 ? "warning" : "primary"
393
- })
394
- })]
395
- }) }),
396
- /* @__PURE__ */ C(j, { children: /* @__PURE__ */ C(O, {
397
- size: "small",
398
- color: e.expired ? "error" : "info",
399
- label: e.expired ? "Expired" : oe(ie, e.status),
400
- sx: {
401
- fontWeight: 700,
402
- borderRadius: 1.5,
403
- height: 22
404
- }
405
- }) }),
406
- /* @__PURE__ */ C(j, {
407
- align: "right",
408
- children: xe ? /* @__PURE__ */ C(D, {
409
- size: "small",
410
- variant: "outlined",
411
- color: "error",
412
- onClick: () => {
413
- q.reset(), W({
414
- open: !0,
415
- vial: e,
416
- reason: "TIME_EXPIRATION",
417
- comments: ""
418
- });
419
- },
420
- children: "Close"
421
- }) : null
422
- })
423
- ]
424
- }, e.id);
425
- }) })]
426
- })
427
- })
428
- ]
429
- }),
430
- /* @__PURE__ */ w(le, {
431
- open: G.open,
432
- onClose: Le,
433
- fullWidth: !0,
434
- maxWidth: "md",
435
- children: [
436
- /* @__PURE__ */ C(fe, { children: G.step === "product" ? "Administer Vaccine — Select Vaccine" : G.mode === "use-existing" ? "Administer Vaccine — Select Open Vial" : "Administer Vaccine — Open & Administer" }),
437
- /* @__PURE__ */ C(de, {
438
- dividers: !0,
439
- children: G.step === "product" ? /* @__PURE__ */ C(E, {
440
- sx: { mt: 1 },
441
- children: /* @__PURE__ */ C(f, {
442
- label: "Vaccine",
443
- required: !0,
444
- value: G.productId,
445
- onChange: (e) => K({
446
- ...G,
447
- productId: e
448
- }),
449
- onBlur: J.onBlur("productId"),
450
- error: J.show("productId") && !!$.productId,
451
- options: Ne.map((e) => ({
452
- value: e.id,
453
- label: `${e.name}${e.vaccineConfig?.vaccineCode ? ` · ${e.vaccineConfig.vaccineCode}` : ""}`
454
- })),
455
- noOptionsText: "No active vaccine products",
456
- helperText: J.show("productId") && $.productId ? $.productId : "Open vials for this vaccine will be shown next. If none are open, a fresh vial can be opened on the same screen."
457
- })
458
- }) : /* @__PURE__ */ w(k, {
459
- spacing: 2,
460
- sx: { pt: 1 },
461
- children: [
462
- G.loading ? /* @__PURE__ */ C(pe, {}) : null,
463
- G.sources.length === 0 ? /* @__PURE__ */ C(T, {
464
- severity: "warning",
465
- children: "No stock available for this vaccine — neither in your personal stock nor at an assigned facility."
466
- }) : G.sources.length > 1 ? /* @__PURE__ */ C(f, {
467
- label: "Administer from",
468
- required: !0,
469
- value: G.ownerType ? `${G.ownerType}::${G.ownerId ?? ""}::${G.personalSource ?? ""}` : "",
470
- onChange: (e) => Ve(e),
471
- onBlur: J.onBlur("ownerType"),
472
- error: J.show("ownerType") && !!$.ownerType,
473
- options: G.sources.map((e) => ({
474
- value: e.key,
475
- label: e.label
476
- })),
477
- helperText: J.show("ownerType") && $.ownerType ? $.ownerType : "Personal (outreach), personal (purchase) and facility stock are separate vial pools — pick which one this dose comes from."
478
- }) : /* @__PURE__ */ w(T, {
479
- severity: "info",
480
- children: [
481
- "Administering from",
482
- " ",
483
- /* @__PURE__ */ C("strong", { children: G.sources[0]?.label }),
484
- "."
485
- ]
486
- }),
487
- G.ownerType === "USER" && G.personalSource === "OUTREACH" && V[0] ? /* @__PURE__ */ w(E, {
488
- sx: {
489
- p: 1.5,
490
- borderRadius: 2,
491
- border: "1px solid",
492
- borderColor: "divider",
493
- bgcolor: (e) => e.palette.action.hover
494
- },
495
- children: [
496
- /* @__PURE__ */ C(P, {
497
- variant: "overline",
498
- sx: {
499
- fontWeight: 800,
500
- letterSpacing: .6,
501
- color: "text.secondary"
502
- },
503
- children: "Outreach session"
504
- }),
505
- /* @__PURE__ */ C(P, {
506
- variant: "body2",
507
- sx: { fontWeight: 800 },
508
- children: V[0].sessionName || "—"
509
- }),
510
- V[0].sessionSite ? /* @__PURE__ */ w(P, {
511
- variant: "caption",
512
- color: "text.secondary",
513
- sx: { display: "block" },
514
- children: ["Site: ", V[0].sessionSite]
515
- }) : null,
516
- /* @__PURE__ */ w(P, {
517
- variant: "caption",
518
- color: "text.secondary",
519
- sx: { display: "block" },
520
- children: [V[0].sessionStartTime ? y(V[0].sessionStartTime) : "—", V[0].sessionExpectedEndTime ? ` → ${y(V[0].sessionExpectedEndTime)}` : ""]
521
- }),
522
- V[0].sessionDescription ? /* @__PURE__ */ C(P, {
523
- variant: "caption",
524
- color: "text.secondary",
525
- sx: {
526
- display: "block",
527
- mt: .5,
528
- whiteSpace: "pre-wrap"
529
- },
530
- children: V[0].sessionDescription
531
- }) : null
532
- ]
533
- }) : null,
534
- G.mode === "use-existing" ? /* @__PURE__ */ w(S, { children: [G.ownerType ? (() => {
535
- let e = Number(G.volumeMl), t = !Number.isNaN(e) && e > 0 && G.vialCandidates.some((t) => Number(t.volumeRemainingMl) >= e);
536
- return /* @__PURE__ */ C(T, {
537
- severity: "info",
538
- action: t ? null : /* @__PURE__ */ C(D, {
539
- color: "inherit",
540
- size: "small",
541
- onClick: () => X("open-new"),
542
- children: "Open another vial instead"
543
- }),
544
- children: t ? "Pick an open vial — earliest-expiry-first is preselected. An existing vial can hold the requested dose, so no new vial is needed." : "Pick an open vial — earliest-expiry-first is preselected. The requested dose does not fit in any open vial; you can open another vial from stock."
545
- });
546
- })() : /* @__PURE__ */ C(T, {
547
- severity: "info",
548
- children: "Pick an administration source above to see the available open vials."
549
- }), /* @__PURE__ */ C(ge, { children: /* @__PURE__ */ w(he, {
550
- size: "small",
551
- children: [/* @__PURE__ */ C(M, { children: /* @__PURE__ */ w(N, { children: [
552
- /* @__PURE__ */ C(j, {}),
553
- /* @__PURE__ */ C(j, {
554
- sx: { fontWeight: 800 },
555
- children: "Lot"
556
- }),
557
- /* @__PURE__ */ C(j, {
558
- sx: { fontWeight: 800 },
559
- children: "Vial expires"
560
- }),
561
- /* @__PURE__ */ C(j, {
562
- sx: { fontWeight: 800 },
563
- children: "Batch expires"
564
- }),
565
- /* @__PURE__ */ C(j, {
566
- sx: { fontWeight: 800 },
567
- align: "right",
568
- children: "Remaining (ml)"
569
- })
570
- ] }) }), /* @__PURE__ */ C(A, { children: G.vialCandidates.length === 0 ? /* @__PURE__ */ C(N, { children: /* @__PURE__ */ C(j, {
571
- colSpan: 5,
572
- sx: {
573
- py: 4,
574
- textAlign: "center"
575
- },
576
- children: /* @__PURE__ */ w(k, {
577
- alignItems: "center",
578
- spacing: 1,
579
- children: [
580
- /* @__PURE__ */ C(I, { sx: {
581
- fontSize: 36,
582
- color: "text.disabled",
583
- opacity: .7
584
- } }),
585
- /* @__PURE__ */ C(P, {
586
- variant: "body2",
587
- sx: { fontWeight: 700 },
588
- children: "No usable open vials for this vaccine"
589
- }),
590
- G.batchCandidates.length > 0 ? /* @__PURE__ */ C(D, {
591
- size: "small",
592
- variant: "outlined",
593
- onClick: () => X("open-new"),
594
- children: "Open a new vial instead"
595
- }) : /* @__PURE__ */ C(P, {
596
- variant: "caption",
597
- color: "text.secondary",
598
- children: "No stock available either — receive a purchase first."
599
- })
600
- ]
601
- })
602
- }) }) : G.vialCandidates.map((e, t) => {
603
- let n = G.selectedVialId === e.id;
604
- return /* @__PURE__ */ w(N, {
605
- hover: !0,
606
- selected: n,
607
- onClick: () => K({
608
- ...G,
609
- selectedVialId: e.id,
610
- volumeMl: e.adultDoseMl ?? G.volumeMl
611
- }),
612
- sx: { cursor: "pointer" },
613
- children: [
614
- /* @__PURE__ */ C(j, {
615
- padding: "checkbox",
616
- children: /* @__PURE__ */ C(me, { checked: n })
617
- }),
618
- /* @__PURE__ */ w(j, {
619
- sx: { fontFamily: "monospace" },
620
- children: [e.lotNumber || "—", t === 0 ? /* @__PURE__ */ C(O, {
621
- size: "small",
622
- color: "primary",
623
- label: "Use first",
624
- sx: { ml: 1 }
625
- }) : null]
626
- }),
627
- /* @__PURE__ */ C(j, { children: y(e.expiresAt) }),
628
- /* @__PURE__ */ C(j, { children: e.batchExpiryDate ? re(e.batchExpiryDate) : "—" }),
629
- /* @__PURE__ */ w(j, {
630
- align: "right",
631
- sx: { fontWeight: 700 },
632
- children: [
633
- b(e.volumeRemainingMl),
634
- " /",
635
- " ",
636
- b(e.volumeTotalMl)
637
- ]
638
- })
639
- ]
640
- }, e.id);
641
- }) })]
642
- }) })] }) : /* @__PURE__ */ C(S, { children: G.ownerType ? G.batchCandidates.length === 0 ? /* @__PURE__ */ C(T, {
643
- severity: "error",
644
- action: G.vialCandidates.length > 0 ? /* @__PURE__ */ C(D, {
645
- color: "inherit",
646
- size: "small",
647
- onClick: () => X("use-existing"),
648
- children: "Use an open vial"
649
- }) : null,
650
- children: "No batches available — every batch is either out of stock, expired, or already at the maximum concurrent open vials. Receive a purchase or finish the open vials first."
651
- }) : /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(T, {
652
- severity: "warning",
653
- action: G.vialCandidates.length > 0 ? /* @__PURE__ */ C(D, {
654
- color: "inherit",
655
- size: "small",
656
- onClick: () => X("use-existing"),
657
- children: "Use an open vial instead"
658
- }) : null,
659
- children: G.vialCandidates.length > 0 ? "Opening a new vial from stock. Existing open vials are still available if the dose fits." : "No open vials for this vaccine. A new vial will be opened from the selected batch and the dose recorded in one step."
660
- }), /* @__PURE__ */ C(ge, { children: /* @__PURE__ */ w(he, {
661
- size: "small",
662
- children: [/* @__PURE__ */ C(M, { children: /* @__PURE__ */ w(N, { children: [
663
- /* @__PURE__ */ C(j, {}),
664
- /* @__PURE__ */ C(j, {
665
- sx: { fontWeight: 800 },
666
- children: "Lot"
667
- }),
668
- /* @__PURE__ */ C(j, {
669
- sx: { fontWeight: 800 },
670
- children: "Batch expires"
671
- }),
672
- /* @__PURE__ */ C(j, {
673
- sx: { fontWeight: 800 },
674
- align: "right",
675
- children: "Qty available"
676
- }),
677
- /* @__PURE__ */ C(j, {
678
- sx: { fontWeight: 800 },
679
- children: "Storage"
680
- })
681
- ] }) }), /* @__PURE__ */ C(A, { children: G.batchCandidates.map((e, t) => {
682
- let n = G.selectedBatchId === e.id;
683
- return /* @__PURE__ */ w(N, {
684
- hover: !0,
685
- selected: n,
686
- onClick: () => K({
687
- ...G,
688
- selectedBatchId: e.id
689
- }),
690
- sx: { cursor: "pointer" },
691
- children: [
692
- /* @__PURE__ */ C(j, {
693
- padding: "checkbox",
694
- children: /* @__PURE__ */ C(me, { checked: n })
695
- }),
696
- /* @__PURE__ */ w(j, {
697
- sx: { fontFamily: "monospace" },
698
- children: [e.lotNumber || "—", t === 0 ? /* @__PURE__ */ C(O, {
699
- size: "small",
700
- color: "primary",
701
- label: "Use first",
702
- sx: { ml: 1 }
703
- }) : null]
704
- }),
705
- /* @__PURE__ */ C(j, { children: e.expiryDate ? re(e.expiryDate) : "—" }),
706
- /* @__PURE__ */ C(j, {
707
- align: "right",
708
- sx: { fontWeight: 700 },
709
- children: e.qtyRemaining
710
- }),
711
- /* @__PURE__ */ C(j, { children: e.storageUnitName || "—" })
712
- ]
713
- }, e.id);
714
- }) })]
715
- }) })] }) : /* @__PURE__ */ C(T, {
716
- severity: "info",
717
- children: "Pick an administration source above to see the available batches."
718
- }) }),
719
- G.mode === "use-existing" && Z || G.mode === "open-new" && He ? /* @__PURE__ */ w(k, {
720
- direction: "row",
721
- spacing: 1,
722
- alignItems: "center",
723
- flexWrap: "wrap",
724
- children: [G.mode === "use-existing" ? /* @__PURE__ */ w(S, { children: [Z.adultDoseMl ? /* @__PURE__ */ w(D, {
725
- size: "small",
726
- onClick: () => K({
727
- ...G,
728
- volumeMl: Z.adultDoseMl
729
- }),
730
- children: [
731
- "Adult dose (",
732
- Z.adultDoseMl,
733
- " ml)"
734
- ]
735
- }) : null, Z.childDoseMl ? /* @__PURE__ */ w(D, {
736
- size: "small",
737
- onClick: () => K({
738
- ...G,
739
- volumeMl: Z.childDoseMl
740
- }),
741
- children: [
742
- "Child dose (",
743
- Z.childDoseMl,
744
- " ml)"
745
- ]
746
- }) : null] }) : /* @__PURE__ */ w(S, { children: [Q?.adultDoseMl ? /* @__PURE__ */ w(D, {
747
- size: "small",
748
- onClick: () => K({
749
- ...G,
750
- volumeMl: Q.adultDoseMl
751
- }),
752
- children: [
753
- "Adult dose (",
754
- Q.adultDoseMl,
755
- " ml)"
756
- ]
757
- }) : null, Q?.childDoseMl ? /* @__PURE__ */ w(D, {
758
- size: "small",
759
- onClick: () => K({
760
- ...G,
761
- volumeMl: Q.childDoseMl
762
- }),
763
- children: [
764
- "Child dose (",
765
- Q.childDoseMl,
766
- " ml)"
767
- ]
768
- }) : null] }), /* @__PURE__ */ C(_e, {
769
- required: !0,
770
- label: "Volume (ml)",
771
- size: "small",
772
- type: "number",
773
- inputProps: {
774
- step: "0.01",
775
- min: 0,
776
- max: G.mode === "use-existing" ? Z?.volumeRemainingMl : Q?.vialVolumeMl
777
- },
778
- value: G.volumeMl,
779
- onChange: (e) => K({
780
- ...G,
781
- volumeMl: e.target.value
782
- }),
783
- onBlur: J.onBlur("volumeMl"),
784
- error: J.show("volumeMl") && !!$.volumeMl,
785
- helperText: J.show("volumeMl") ? $.volumeMl : ""
786
- })]
787
- }) : null
788
- ]
789
- })
790
- }),
791
- /* @__PURE__ */ w(ue, { children: [
792
- /* @__PURE__ */ C(D, {
793
- onClick: Le,
794
- children: "Cancel"
795
- }),
796
- G.step === "select" ? /* @__PURE__ */ C(D, {
797
- onClick: () => K({
798
- ...R,
799
- open: !0,
800
- productId: G.productId
801
- }),
802
- children: "Back"
803
- }) : null,
804
- G.step === "product" ? /* @__PURE__ */ C(D, {
805
- variant: "contained",
806
- disabled: !G.productId || G.loading,
807
- onClick: () => void ze(),
808
- children: "Next"
809
- }) : /* @__PURE__ */ C(D, {
810
- variant: "contained",
811
- disabled: !Ue,
812
- onClick: () => void We(),
813
- children: G.mode === "use-existing" ? "Administer" : "Open & Administer"
814
- })
815
- ] })
816
- ]
817
- }),
818
- /* @__PURE__ */ w(le, {
819
- open: U.open,
820
- onClose: () => W({
821
- open: !1,
822
- vial: null,
823
- reason: "TIME_EXPIRATION",
824
- comments: ""
825
- }),
826
- fullWidth: !0,
827
- maxWidth: "sm",
828
- children: [
829
- /* @__PURE__ */ C(fe, { children: "Close Vial (record remaining as wastage)" }),
830
- /* @__PURE__ */ C(de, {
831
- dividers: !0,
832
- children: /* @__PURE__ */ w(k, {
833
- spacing: 2,
834
- sx: { pt: 1 },
835
- children: [
836
- /* @__PURE__ */ w(P, {
837
- variant: "body2",
838
- children: [
839
- U.vial?.productName,
840
- " ·",
841
- " ",
842
- b(U.vial?.volumeRemainingMl),
843
- " ml will be marked as wasted."
844
- ]
845
- }),
846
- /* @__PURE__ */ C(f, {
847
- label: "Reason",
848
- required: !0,
849
- value: U.reason,
850
- onChange: (e) => W({
851
- ...U,
852
- reason: e
853
- }),
854
- onBlur: q.onBlur("wastageReason"),
855
- error: q.show("wastageReason") && !!Pe.wastageReason,
856
- options: ae,
857
- helperText: q.show("wastageReason") && Pe.wastageReason || ""
858
- }),
859
- /* @__PURE__ */ C(_e, {
860
- label: "Comments",
861
- size: "small",
862
- multiline: !0,
863
- minRows: 2,
864
- fullWidth: !0,
865
- value: U.comments,
866
- onChange: (e) => W({
867
- ...U,
868
- comments: e.target.value
869
- })
870
- })
871
- ]
872
- })
873
- }),
874
- /* @__PURE__ */ w(ue, { children: [/* @__PURE__ */ C(D, {
875
- onClick: () => W({
876
- open: !1,
877
- vial: null,
878
- reason: "TIME_EXPIRATION",
879
- comments: ""
880
- }),
881
- children: "Cancel"
882
- }), /* @__PURE__ */ C(D, {
883
- variant: "contained",
884
- color: "error",
885
- disabled: !Fe,
886
- onClick: () => void Ie(),
887
- children: "Close Vial"
888
- })] })
889
- ]
890
- })
891
- ]
892
- })] });
893
- }
894
- //#endregion
895
- export { xe as default };
896
-
897
- //# sourceMappingURL=VialsPage-DPsYFgaQ.js.map