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