@bahmni/admin-app 0.0.1-dev.457 → 0.0.1-dev.459

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bahmni/admin-app",
3
- "version": "0.0.1-dev.457",
3
+ "version": "0.0.1-dev.459",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -1,23 +0,0 @@
1
- import { jsx as a, jsxs as e } from "react/jsx-runtime";
2
- import { u as d, F as o } from "./index-C_3VFMYg.js";
3
- const t = "CsvUpload-module_page__AxMNv", i = {
4
- page: t
5
- }, n = () => {
6
- const { t: s } = d();
7
- return /* @__PURE__ */ a(o, { children: /* @__PURE__ */ e(
8
- "div",
9
- {
10
- id: "admin-csv-upload-page",
11
- "data-testid": "admin-csv-upload-page-test-id",
12
- "aria-label": "CSV Upload Page",
13
- className: i.page,
14
- children: [
15
- /* @__PURE__ */ a("h1", { children: s("ADMIN_CSV_UPLOAD_TITLE") }),
16
- /* @__PURE__ */ a("p", { children: s("ADMIN_CSV_UPLOAD_DESCRIPTION") })
17
- ]
18
- }
19
- ) });
20
- };
21
- export {
22
- n as CsvUpload
23
- };
@@ -1,439 +0,0 @@
1
- import { jsx as a, jsxs as T, Fragment as Ee } from "react/jsx-runtime";
2
- import { d as ge, u as Ne, z as Ce, w as fe, N as be, a as ye, K as Ae, h as De, T as Ie, b as Le, j as Q, E as Oe, c as we, I as ve, n as Ue, A as Se, e as J, U as te, _ as Me, x as Re } from "./index-C_3VFMYg.js";
3
- import { useQuery as $e } from "@tanstack/react-query";
4
- import { useState as _, useRef as ke, useEffect as g, useMemo as N, useCallback as p } from "react";
5
- const Be = "DocumentsTable-module_documentsTableBody__6iR3w", He = "DocumentsTable-module_viewAttachmentsLink__aQ1on", xe = "DocumentsTable-module_documentViewerContainer__F5m8D", ze = "DocumentsTable-module_printContainer__rtarJ", Fe = "DocumentsTable-module_attachmentItem__17KA7", Pe = "DocumentsTable-module_attachmentCounter__WFiI3", Ve = "DocumentsTable-module_attachmentError__RI4U2", We = "DocumentsTable-module_documentIframe__ptq5I", qe = "DocumentsTable-module_attachmentContent__IaCEe", Ge = "DocumentsTable-module_attachmentLoading__FAR6p", je = "DocumentsTable-module_hiddenWhileLoading__IxocW", Ke = "DocumentsTable-module_documentImage__KQVgS", Ye = "DocumentsTable-module_header__345GY", Qe = "DocumentsTable-module_documentTypeCell__uWGM8", Je = "DocumentsTable-module_printAllButton__IVYUW", Xe = "DocumentsTable-module_attachmentHeader__yI2xn", d = {
6
- documentsTableBody: Be,
7
- viewAttachmentsLink: He,
8
- documentViewerContainer: xe,
9
- printContainer: ze,
10
- attachmentItem: Fe,
11
- attachmentCounter: Pe,
12
- attachmentError: Ve,
13
- documentIframe: We,
14
- attachmentContent: qe,
15
- attachmentLoading: Ge,
16
- hiddenWhileLoading: je,
17
- documentImage: Ke,
18
- header: Ye,
19
- documentTypeCell: Qe,
20
- printAllButton: Je,
21
- attachmentHeader: Xe
22
- }, Ze = {
23
- documentIdentifier: "DOCUMENTS_DOCUMENT_IDENTIFIER",
24
- documentType: "DOCUMENTS_TYPE",
25
- uploadedOn: "DOCUMENTS_UPLOADED_ON",
26
- uploadedBy: "DOCUMENTS_UPLOADED_BY",
27
- attachments: "DOCUMENTS_ATTACHMENTS"
28
- };
29
- function et(n) {
30
- if (!n)
31
- return "document";
32
- const i = n.toLowerCase();
33
- return i.includes("pdf") ? "pdf" : i.includes("image") ? "image" : "document";
34
- }
35
- function I(n) {
36
- return !n || n.includes(":") ? "#" : `/openmrs/auth?requested_document=/document_images/${n}`;
37
- }
38
- function tt(n, i) {
39
- return n.map((l) => ({
40
- key: l,
41
- header: i(Ze[l])
42
- }));
43
- }
44
- const nt = {
45
- "&": "&",
46
- "<": "&lt;",
47
- ">": "&gt;",
48
- '"': "&quot;",
49
- "'": "&#39;"
50
- }, z = (n) => n.replace(/[&<>"']/g, (i) => nt[i]), at = "body{margin:0}img{max-width:100%;max-height:100vh;object-fit:contain;display:block;margin:0 auto}", ot = ({
51
- contentType: n
52
- }) => et(n) === "pdf", ne = (n) => new URL(I(n), globalThis.location.origin).href;
53
- function rt({ url: n }, i) {
54
- const l = z(ne(n));
55
- return `<!DOCTYPE html><html><head><meta charset="utf-8" /><title>${z(
56
- i
57
- )}</title><style>${at}</style></head><body><img src="${l}" alt="${z(
58
- i
59
- )}" /></body></html>`;
60
- }
61
- async function dt(n, i, {
62
- container: l,
63
- signal: b
64
- }) {
65
- const r = { container: l, focus: !1, signal: b };
66
- for (const C of n) {
67
- if (b.aborted) break;
68
- ot(C) ? await Me(ne(C.url), r) : await Re(
69
- rt(C, i),
70
- r
71
- );
72
- }
73
- }
74
- const st = "startConsultation", lt = "add", it = "documents", X = "document-print-container", Z = () => /* @__PURE__ */ a(te, {}), ct = /* @__PURE__ */ new Set([
75
- "ArrowUp",
76
- "ArrowDown",
77
- "PageUp",
78
- "PageDown",
79
- "Home",
80
- "End",
81
- " "
82
- ]), ut = 15e3, mt = [
83
- "documentType",
84
- "documentIdentifier",
85
- "attachments",
86
- "uploadedOn",
87
- "uploadedBy"
88
- ], ht = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, ee = (n) => n.attachments.length > 0 ? n.attachments : n.documentUrl ? [{ url: n.documentUrl, contentType: n.contentType }] : [], gt = ({ config: n, encounterUuids: i }) => {
89
- const [l, b] = _(!1), [r, C] = _(
90
- null
91
- ), [L, S] = _(
92
- /* @__PURE__ */ new Set()
93
- ), [O, M] = _(
94
- /* @__PURE__ */ new Set()
95
- ), y = ke(null), [R, F] = _(
96
- null
97
- ), P = R !== null;
98
- g(() => () => y.current?.abort(), []);
99
- const f = ge(), { t: o } = Ne(), { addNotification: w } = Ce(), m = N(
100
- () => n?.actions?.find(
101
- (e) => e.type === lt
102
- ),
103
- [n?.actions]
104
- ), ae = fe(m?.requiredPrivilege), oe = !!m && ae, re = Number(n?.pageSize) || 5, [$, k] = _(1), [A, de] = _(re), [se, B] = _(void 0), V = p((e) => {
105
- C(e), b(!0);
106
- }, []), le = p(() => {
107
- y.current?.abort(), M(/* @__PURE__ */ new Set()), b(!1), C(null), S(/* @__PURE__ */ new Set());
108
- }, []), W = p((e) => {
109
- M((t) => new Set(t).add(e));
110
- }, []), q = p((e) => {
111
- S((t) => new Set(t).add(e));
112
- }, []), ie = p(() => {
113
- m && globalThis.dispatchEvent(
114
- new CustomEvent(st, {
115
- detail: {
116
- encounterType: m.encounterType,
117
- editOnly: m.editOnly ?? it,
118
- ...m.editTitle ? { editTitle: m.editTitle } : {}
119
- }
120
- })
121
- );
122
- }, [m]), { data: D, isLoading: ce, isError: H, error: x, refetch: G } = $e({
123
- queryKey: [
124
- "documents",
125
- f,
126
- i,
127
- $,
128
- A
129
- ],
130
- enabled: !!f,
131
- queryFn: () => be(
132
- f,
133
- i,
134
- A,
135
- $
136
- )
137
- });
138
- ye(
139
- (e) => {
140
- e.patientUUID === f && e.updatedResources.documents && G();
141
- },
142
- [f, G]
143
- ), g(() => {
144
- D && B(D.total);
145
- }, [D]), g(() => {
146
- k(1), B(void 0);
147
- }, [f]), g(() => {
148
- H && w({
149
- title: o("ERROR_DEFAULT_TITLE"),
150
- message: x?.message ?? "",
151
- type: "error"
152
- });
153
- }, [H, x, w, o]), g(() => {
154
- const e = new AbortController();
155
- return (async () => {
156
- if (!l || !r) return;
157
- const t = /* @__PURE__ */ new Set(), s = ee(r);
158
- for (let c = 0; c < s.length; c++) {
159
- const h = I(s[c].url);
160
- try {
161
- (await fetch(h, {
162
- method: "HEAD",
163
- signal: e.signal
164
- })).ok || t.add(c);
165
- } catch (E) {
166
- E instanceof Error && E.name !== "AbortError" && t.add(c);
167
- }
168
- }
169
- e.signal.aborted || S(t);
170
- })(), () => e.abort();
171
- }, [l, r]), g(() => {
172
- if (!l || !r) return;
173
- const e = document.querySelector(
174
- '[data-testid="document-view-modal"] .cds--modal-content'
175
- );
176
- if (!e) return;
177
- let t = !1;
178
- const s = () => {
179
- t = !0;
180
- }, c = (U) => {
181
- U.target === e && s();
182
- }, h = (U) => {
183
- const pe = U.target;
184
- ct.has(U.key) && !pe?.closest("button, input, textarea, select, a") && s();
185
- }, E = () => {
186
- !t && e.scrollTop !== 0 && (e.scrollTop = 0);
187
- };
188
- return e.addEventListener("wheel", s, { passive: !0 }), e.addEventListener("touchmove", s, { passive: !0 }), e.addEventListener("mousedown", c), e.addEventListener("keydown", h), e.addEventListener("scroll", E), () => {
189
- e.removeEventListener("wheel", s), e.removeEventListener("touchmove", s), e.removeEventListener("mousedown", c), e.removeEventListener("keydown", h), e.removeEventListener("scroll", E);
190
- };
191
- }, [l, r]);
192
- const ue = p(
193
- (e, t) => {
194
- t !== A ? (de(t), k(1), B(void 0)) : k(e);
195
- },
196
- [A]
197
- ), v = N(
198
- () => n?.fields ?? mt,
199
- [n?.fields]
200
- ), me = N(() => [...D?.documents ?? []].sort((e, t) => !e.uploadedOn && !t.uploadedOn ? 0 : e.uploadedOn ? t.uploadedOn ? new Date(t.uploadedOn).getTime() - new Date(e.uploadedOn).getTime() : -1 : 1), [D]), he = N(() => tt(v, o), [v, o]), Te = N(
201
- () => v.map((e) => ({
202
- key: e,
203
- sortable: e !== "attachments"
204
- })),
205
- [v]
206
- ), u = N(
207
- () => r ? ee(r) : [],
208
- [r]
209
- ), j = u.every(
210
- (e, t) => O.has(t) || L.has(t) || I(e.url) === "#"
211
- );
212
- g(() => {
213
- if (!l || u.length === 0) return;
214
- const e = setTimeout(
215
- () => M(new Set(u.keys())),
216
- ut
217
- );
218
- return () => clearTimeout(e);
219
- }, [l, u]);
220
- const K = p(
221
- async (e, t) => {
222
- if (!r || y.current) return;
223
- const s = new AbortController(), { signal: c } = s;
224
- y.current = s, F(t);
225
- const h = document.getElementById(X);
226
- try {
227
- await dt(
228
- e,
229
- r.documentIdentifier,
230
- { container: h, signal: c }
231
- );
232
- } catch {
233
- c.aborted || w({
234
- title: o("ERROR_DEFAULT_TITLE"),
235
- message: o("DOCUMENTS_ERROR_LOADING_ATTACHMENT"),
236
- type: "error"
237
- });
238
- } finally {
239
- y.current = null, F(null);
240
- }
241
- },
242
- [r, w, o]
243
- ), Y = N(
244
- () => u.filter(
245
- (e, t) => I(e.url) !== "#" && !L.has(t)
246
- ),
247
- [u, L]
248
- ), _e = p(
249
- (e, t) => {
250
- switch (t) {
251
- case "documentIdentifier":
252
- return /* @__PURE__ */ a("span", { children: e.documentIdentifier?.trim() || "-" });
253
- case "documentType":
254
- return /* @__PURE__ */ T("div", { className: d.documentTypeCell, children: [
255
- /* @__PURE__ */ a("span", { children: e.documentType ?? o("DOCUMENTS_NOT_AVAILABLE") }),
256
- e.description && /* @__PURE__ */ a(
257
- Ie,
258
- {
259
- iconName: "fa-file-lines",
260
- content: e.description,
261
- ariaLabel: e.description,
262
- testId: `document-notes-${e.id}`
263
- }
264
- )
265
- ] });
266
- case "uploadedOn":
267
- return De(
268
- e.uploadedOn,
269
- o,
270
- !0
271
- ).formattedResult || o("DOCUMENTS_NOT_AVAILABLE");
272
- case "uploadedBy":
273
- return e.uploadedBy ?? o("DOCUMENTS_NOT_AVAILABLE");
274
- case "attachments":
275
- return e.attachments.length > 0 || e.documentUrl ? /* @__PURE__ */ a(
276
- Ae,
277
- {
278
- onClick: () => V(e),
279
- className: d.viewAttachmentsLink,
280
- "data-testid": `view-attachments-${e.id}`,
281
- children: o("DOCUMENTS_VIEW_ATTACHMENTS")
282
- }
283
- ) : "--";
284
- default:
285
- return null;
286
- }
287
- },
288
- [V, o]
289
- );
290
- return /* @__PURE__ */ T(Ee, { children: [
291
- oe && /* @__PURE__ */ T(Le, { className: d.header, testId: "documents-header", children: [
292
- /* @__PURE__ */ a("p", { children: o("DOCUMENTS_TABLE_HEADING") }),
293
- /* @__PURE__ */ a(
294
- Q,
295
- {
296
- autoAlign: !0,
297
- size: "lg",
298
- kind: "ghost",
299
- label: o(m.label),
300
- testId: "documents-add-button",
301
- onClick: ie,
302
- children: /* @__PURE__ */ a(Oe, { id: "documents-add-icon", name: "fa-plus", size: we.LG })
303
- }
304
- )
305
- ] }),
306
- /* @__PURE__ */ a("div", { "data-testid": "documents-table", children: /* @__PURE__ */ a(
307
- ve,
308
- {
309
- headers: he,
310
- ariaLabel: o("DOCUMENTS_TABLE_HEADING"),
311
- rows: me,
312
- loading: ce,
313
- errorStateMessage: H ? x?.message : null,
314
- sortable: Te,
315
- emptyStateMessage: o("DOCUMENTS_NO_RECORDS"),
316
- renderCell: _e,
317
- className: d.documentsTableBody,
318
- dataTestId: "documents-table",
319
- pageSize: A,
320
- totalItems: se,
321
- page: $,
322
- onPageChange: ue
323
- }
324
- ) }),
325
- l && r && /* @__PURE__ */ a(
326
- Ue,
327
- {
328
- id: "modalIdForActionAreaLayout",
329
- portalId: "main-display-area",
330
- open: l,
331
- onRequestClose: le,
332
- modalHeading: r.documentIdentifier,
333
- passiveModal: !0,
334
- size: "lg",
335
- testId: "document-view-modal",
336
- children: /* @__PURE__ */ T("div", { className: d.documentViewerContainer, children: [
337
- Y.length > 1 && /* @__PURE__ */ a(
338
- Se,
339
- {
340
- kind: "tertiary",
341
- size: "sm",
342
- className: d.printAllButton,
343
- renderIcon: R === "all" ? Z : J,
344
- disabled: P || !j,
345
- testId: "print-all-attachments",
346
- onClick: () => K(Y, "all"),
347
- children: o("DOCUMENTS_PRINT_ALL")
348
- }
349
- ),
350
- u.map((e, t) => {
351
- const s = I(e.url), c = e.contentType?.toLowerCase().includes("pdf"), h = (e.contentType?.toLowerCase().includes("image") ?? !1) || ht.test(e.url ?? ""), E = L.has(t);
352
- return s === "#" || E ? /* @__PURE__ */ T(
353
- "div",
354
- {
355
- className: d.attachmentError,
356
- "data-testid": `attachment-error-${t}`,
357
- children: [
358
- u.length > 1 && /* @__PURE__ */ a("p", { className: d.attachmentCounter, children: o("DOCUMENTS_ATTACHMENT_COUNTER", {
359
- current: t + 1,
360
- total: u.length
361
- }) }),
362
- /* @__PURE__ */ a("p", { children: o("DOCUMENTS_ERROR_LOADING_ATTACHMENT") })
363
- ]
364
- },
365
- `${r.id}-${e.url}`
366
- ) : /* @__PURE__ */ T(
367
- "div",
368
- {
369
- className: d.attachmentItem,
370
- "data-testid": `attachment-item-${t}`,
371
- children: [
372
- /* @__PURE__ */ T("div", { className: d.attachmentHeader, children: [
373
- u.length > 1 ? /* @__PURE__ */ a("p", { className: d.attachmentCounter, children: o("DOCUMENTS_ATTACHMENT_COUNTER", {
374
- current: t + 1,
375
- total: u.length
376
- }) }) : /* @__PURE__ */ a("span", {}),
377
- /* @__PURE__ */ a(
378
- Q,
379
- {
380
- kind: "ghost",
381
- size: "sm",
382
- label: o("DOCUMENTS_PRINT_ATTACHMENT", {
383
- index: t + 1
384
- }),
385
- disabled: P || !j,
386
- testId: `print-attachment-${t}`,
387
- onClick: () => K([e], t),
388
- children: R === t ? /* @__PURE__ */ a(Z, {}) : /* @__PURE__ */ a(J, {})
389
- }
390
- )
391
- ] }),
392
- /* @__PURE__ */ T("div", { className: d.attachmentContent, children: [
393
- !O.has(t) && /* @__PURE__ */ a(
394
- "div",
395
- {
396
- className: d.attachmentLoading,
397
- "data-testid": `attachment-loading-${t}`,
398
- children: /* @__PURE__ */ a(
399
- te,
400
- {
401
- description: o("DOCUMENTS_LOADING_ATTACHMENT")
402
- }
403
- )
404
- }
405
- ),
406
- h ? /* @__PURE__ */ a(
407
- "img",
408
- {
409
- src: s,
410
- alt: r.documentIdentifier,
411
- className: `${d.documentImage} ${O.has(t) ? "" : d.hiddenWhileLoading}`,
412
- onLoad: () => W(t),
413
- onError: () => q(t)
414
- }
415
- ) : /* @__PURE__ */ a(
416
- "iframe",
417
- {
418
- src: c ? `${s}#toolbar=0` : s,
419
- className: `${d.documentIframe} ${O.has(t) ? "" : d.hiddenWhileLoading}`,
420
- title: r.documentIdentifier,
421
- onLoad: () => W(t),
422
- onError: () => q(t)
423
- }
424
- )
425
- ] })
426
- ]
427
- },
428
- `${r.id}-${e.url}`
429
- );
430
- }),
431
- /* @__PURE__ */ a("div", { id: X, className: d.printContainer })
432
- ] })
433
- }
434
- )
435
- ] });
436
- };
437
- export {
438
- gt as default
439
- };