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