@bahmni/widgets 0.0.1-dev.408 → 0.0.1-dev.409
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-BsUJ7e2o.js → DocumentsTable-3e5FtduO.js} +14 -14
- package/dist/{FormsTable-DjR1N9v4.js → FormsTable-BIU_KzCJ.js} +35 -35
- package/dist/Observations-w_KOlyBd.js +247 -0
- package/dist/{index-pfbCZxrx.js → index-CxgzK6B5.js} +2664 -2631
- package/dist/index.css +1 -1
- package/dist/index.js +25 -25
- package/dist/observations/Observations.d.ts +2 -1
- package/dist/observations/Observations.d.ts.map +1 -1
- package/dist/observations/__mocks__/observationTestData.d.ts +2 -0
- package/dist/observations/__mocks__/observationTestData.d.ts.map +1 -1
- package/dist/observations/components/ObsByEncounter.d.ts.map +1 -1
- package/dist/observations/utils.d.ts +9 -1
- package/dist/observations/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/Observations-DQHY-eMz.js +0 -214
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as r, jsxs as T, Fragment as Y } from "react/jsx-runtime";
|
|
2
|
-
import { u as
|
|
2
|
+
import { u as W, a as X, F as J, V as Z, Q as x, b as ee, c as te } from "./index-CxgzK6B5.js";
|
|
3
3
|
import { useQuery as ne } from "@tanstack/react-query";
|
|
4
4
|
import { useState as l, useCallback as _, useEffect as I, useMemo as p } from "react";
|
|
5
5
|
import { useTranslation as ae } from "react-i18next";
|
|
@@ -35,14 +35,14 @@ const Te = [
|
|
|
35
35
|
"uploadedOn",
|
|
36
36
|
"uploadedBy"
|
|
37
37
|
], _e = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, B = (n) => n.attachments.length > 0 ? n.attachments : n.documentUrl ? [{ url: n.documentUrl, contentType: n.contentType }] : [], Ie = ({ config: n, encounterUuids: f }) => {
|
|
38
|
-
const [d,
|
|
38
|
+
const [d, L] = l(!1), [s, U] = l(
|
|
39
39
|
null
|
|
40
40
|
), [V, A] = l(
|
|
41
41
|
/* @__PURE__ */ new Set()
|
|
42
|
-
), E =
|
|
43
|
-
|
|
42
|
+
), E = W(), { t: o } = ae(), { addNotification: w } = X(), P = Number(n?.pageSize) || 5, [N, C] = l(1), [u, $] = l(P), [k, O] = l(void 0), v = _((e) => {
|
|
43
|
+
U(e), L(!0);
|
|
44
44
|
}, []), z = _(() => {
|
|
45
|
-
|
|
45
|
+
L(!1), U(null), A(/* @__PURE__ */ new Set());
|
|
46
46
|
}, []), F = _((e) => {
|
|
47
47
|
A((t) => new Set(t).add(e));
|
|
48
48
|
}, []), { data: i, isLoading: H, isError: S, error: b } = ne({
|
|
@@ -54,7 +54,7 @@ const Te = [
|
|
|
54
54
|
u
|
|
55
55
|
],
|
|
56
56
|
enabled: !!E,
|
|
57
|
-
queryFn: () =>
|
|
57
|
+
queryFn: () => J(
|
|
58
58
|
E,
|
|
59
59
|
f,
|
|
60
60
|
u,
|
|
@@ -83,8 +83,8 @@ const Te = [
|
|
|
83
83
|
method: "HEAD",
|
|
84
84
|
signal: e.signal
|
|
85
85
|
})).ok || a.add(m);
|
|
86
|
-
} catch (
|
|
87
|
-
|
|
86
|
+
} catch (M) {
|
|
87
|
+
M instanceof Error && M.name !== "AbortError" && a.add(m);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
e.signal.aborted || A(a);
|
|
@@ -98,7 +98,7 @@ const Te = [
|
|
|
98
98
|
), D = p(
|
|
99
99
|
() => n?.fields ?? Te,
|
|
100
100
|
[n?.fields]
|
|
101
|
-
),
|
|
101
|
+
), Q = p(() => [...i?.documents ?? []].sort((t, a) => !t.uploadedOn && !a.uploadedOn ? 0 : t.uploadedOn ? a.uploadedOn ? new Date(a.uploadedOn).getTime() - new Date(t.uploadedOn).getTime() : -1 : 1), [i]), j = p(() => he(D, o), [D, o]), K = p(
|
|
102
102
|
() => D.map((e) => ({
|
|
103
103
|
key: e,
|
|
104
104
|
sortable: e !== "attachments"
|
|
@@ -107,7 +107,7 @@ const Te = [
|
|
|
107
107
|
), h = p(
|
|
108
108
|
() => s ? B(s) : [],
|
|
109
109
|
[s]
|
|
110
|
-
),
|
|
110
|
+
), G = _(
|
|
111
111
|
(e, t) => {
|
|
112
112
|
switch (t) {
|
|
113
113
|
case "documentIdentifier":
|
|
@@ -142,14 +142,14 @@ const Te = [
|
|
|
142
142
|
/* @__PURE__ */ r("div", { "data-testid": "documents-table", children: /* @__PURE__ */ r(
|
|
143
143
|
ee,
|
|
144
144
|
{
|
|
145
|
-
headers:
|
|
145
|
+
headers: j,
|
|
146
146
|
ariaLabel: o("DOCUMENTS_TABLE_HEADING"),
|
|
147
|
-
rows:
|
|
147
|
+
rows: Q,
|
|
148
148
|
loading: H,
|
|
149
149
|
errorStateMessage: S ? b?.message : null,
|
|
150
|
-
sortable:
|
|
150
|
+
sortable: K,
|
|
151
151
|
emptyStateMessage: o("DOCUMENTS_NO_RECORDS"),
|
|
152
|
-
renderCell:
|
|
152
|
+
renderCell: G,
|
|
153
153
|
className: c.documentsTableBody,
|
|
154
154
|
dataTestId: "documents-table",
|
|
155
155
|
pageSize: u,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as i, jsxs as
|
|
2
|
-
import { u as be,
|
|
1
|
+
import { jsx as i, jsxs as $, Fragment as ge } from "react/jsx-runtime";
|
|
2
|
+
import { u as be, d as Oe, e as Ne, y as Ee, g as Te, p as ve, h as Fe, J as Ie, D as Ae, f as _e, i as De, Y as G, Q as Re, C as K, B as Q, V as Me, b as z, r as Le, j as Be, c as Ce, O as Se, k as Ue } from "./index-CxgzK6B5.js";
|
|
3
3
|
import { useQueryClient as ke, useQuery as E } from "@tanstack/react-query";
|
|
4
4
|
import { useState as Y, useMemo as d, useCallback as c } from "react";
|
|
5
5
|
import { useTranslation as we } from "react-i18next";
|
|
@@ -7,8 +7,8 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
|
|
|
7
7
|
formsTableBody: He,
|
|
8
8
|
modalHeading: Ve,
|
|
9
9
|
customAccordianItem: qe
|
|
10
|
-
}, Pe = "startConsultation",
|
|
11
|
-
episodeOfCareUuids:
|
|
10
|
+
}, Pe = "startConsultation", Qe = ({
|
|
11
|
+
episodeOfCareUuids: R,
|
|
12
12
|
encounterUuids: m,
|
|
13
13
|
config: J,
|
|
14
14
|
disableActions: W = !1,
|
|
@@ -18,10 +18,10 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
|
|
|
18
18
|
numberOfVisits: X,
|
|
19
19
|
hideThumbnail: Z = !1,
|
|
20
20
|
forms: b
|
|
21
|
-
} = J ?? {}, ee =
|
|
21
|
+
} = J ?? {}, ee = Oe(
|
|
22
22
|
Ue.EDIT_OBSERVATIONS
|
|
23
|
-
), { userPrivileges:
|
|
24
|
-
|
|
23
|
+
), { userPrivileges: O } = Ne(), v = ee && !W && !!y, B = Ee(
|
|
24
|
+
R,
|
|
25
25
|
m
|
|
26
26
|
), re = ke(), {
|
|
27
27
|
data: C = [],
|
|
@@ -30,7 +30,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
|
|
|
30
30
|
error: te,
|
|
31
31
|
refetch: oe
|
|
32
32
|
} = E({
|
|
33
|
-
queryKey: ["forms", u,
|
|
33
|
+
queryKey: ["forms", u, R],
|
|
34
34
|
queryFn: () => Te(u, void 0, X),
|
|
35
35
|
enabled: !!u && !B
|
|
36
36
|
}), k = d(() => {
|
|
@@ -40,26 +40,26 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
|
|
|
40
40
|
)), Array.isArray(b) && b.length > 0 && (e = e.filter(
|
|
41
41
|
(r) => b.some((o) => o.toLowerCase() === r.formName.toLowerCase())
|
|
42
42
|
)), e;
|
|
43
|
-
}, [C, m, b]), { data:
|
|
43
|
+
}, [C, m, b]), { data: N = [] } = E({
|
|
44
44
|
queryKey: ["observationForms"],
|
|
45
45
|
queryFn: () => ve()
|
|
46
46
|
}), w = c(
|
|
47
47
|
(e) => {
|
|
48
|
-
const r =
|
|
48
|
+
const r = N.find((t) => t.name === e);
|
|
49
49
|
if (!r?.privileges || r.privileges.length === 0) return !0;
|
|
50
|
-
if (!
|
|
51
|
-
const o = new Set(
|
|
50
|
+
if (!O || O.length === 0) return !1;
|
|
51
|
+
const o = new Set(O.map((t) => t.name));
|
|
52
52
|
return r.privileges.some(
|
|
53
53
|
(t) => o.has(t.privilegeName) && t.editable
|
|
54
54
|
);
|
|
55
55
|
},
|
|
56
|
-
[
|
|
56
|
+
[N, O]
|
|
57
57
|
), f = c(
|
|
58
58
|
(e) => !y || e.encounterUuid !== y ? !1 : w(e.formName),
|
|
59
59
|
[y, w]
|
|
60
60
|
), H = c(
|
|
61
|
-
(e) =>
|
|
62
|
-
[
|
|
61
|
+
(e) => N.find((o) => o.name === e)?.uuid,
|
|
62
|
+
[N]
|
|
63
63
|
), F = d(() => {
|
|
64
64
|
if (a)
|
|
65
65
|
return H(a.formName);
|
|
@@ -88,7 +88,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
|
|
|
88
88
|
},
|
|
89
89
|
[u]
|
|
90
90
|
);
|
|
91
|
-
const de = d(() => !A?.entry || !a?.formName ? [] : A.entry.filter((r) => r.resource?.resourceType === "Observation").map((r) => r.resource).filter((r) => _e(r) ?
|
|
91
|
+
const de = d(() => !A?.entry || !a?.formName ? [] : A.entry.filter((r) => r.resource?.resourceType === "Observation").map((r) => r.resource).filter((r) => _e(r) ? De(r)?.toLowerCase() === a.formName.toLowerCase() : !0), [A, a?.formName]), le = d(() => {
|
|
92
92
|
if (!l?.schema) return;
|
|
93
93
|
const e = [], r = (o) => {
|
|
94
94
|
(o ?? []).forEach((t) => {
|
|
@@ -126,9 +126,9 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
|
|
|
126
126
|
), Object.keys(e).length > 0 ? e : void 0;
|
|
127
127
|
}, [l]), ue = d(() => {
|
|
128
128
|
if (I)
|
|
129
|
-
return
|
|
129
|
+
return G(I).message;
|
|
130
130
|
if (_)
|
|
131
|
-
return
|
|
131
|
+
return G(_).message;
|
|
132
132
|
}, [I, _]), h = d(
|
|
133
133
|
() => [
|
|
134
134
|
{ key: "recordedOn", header: n("RECORDED_ON") },
|
|
@@ -156,7 +156,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
|
|
|
156
156
|
return o[s].push({
|
|
157
157
|
id: t.encounterUuid,
|
|
158
158
|
formName: t.formName,
|
|
159
|
-
recordedOn:
|
|
159
|
+
recordedOn: Re(t.encounterDateTime, n, !0).formattedResult,
|
|
160
160
|
recordedBy: p ?? "--",
|
|
161
161
|
encounterDateTime: t.encounterDateTime,
|
|
162
162
|
encounterUuid: t.encounterUuid
|
|
@@ -176,7 +176,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
|
|
|
176
176
|
L(e), M(!0);
|
|
177
177
|
}, []), j = c(() => {
|
|
178
178
|
M(!1), L(null);
|
|
179
|
-
}, []),
|
|
179
|
+
}, []), D = c((e) => {
|
|
180
180
|
globalThis.dispatchEvent(
|
|
181
181
|
new CustomEvent(Pe, {
|
|
182
182
|
detail: {
|
|
@@ -188,7 +188,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
|
|
|
188
188
|
}
|
|
189
189
|
})
|
|
190
190
|
);
|
|
191
|
-
}, []),
|
|
191
|
+
}, []), x = c(
|
|
192
192
|
(e, r) => {
|
|
193
193
|
switch (r) {
|
|
194
194
|
case "recordedOn":
|
|
@@ -197,25 +197,25 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
|
|
|
197
197
|
return e.recordedBy;
|
|
198
198
|
case "actions":
|
|
199
199
|
return f(e) ? /* @__PURE__ */ i(
|
|
200
|
-
|
|
200
|
+
K,
|
|
201
201
|
{
|
|
202
202
|
label: n("EDIT_OBSERVATION_FORM"),
|
|
203
203
|
kind: "ghost",
|
|
204
204
|
size: "sm",
|
|
205
205
|
testId: `edit-form-${e.encounterUuid}`,
|
|
206
|
-
onClick: () =>
|
|
207
|
-
children: /* @__PURE__ */ i(
|
|
206
|
+
onClick: () => D(e),
|
|
207
|
+
children: /* @__PURE__ */ i(Q, {})
|
|
208
208
|
}
|
|
209
209
|
) : null;
|
|
210
210
|
default:
|
|
211
211
|
return null;
|
|
212
212
|
}
|
|
213
213
|
},
|
|
214
|
-
[P,
|
|
214
|
+
[P, D, f, n]
|
|
215
215
|
);
|
|
216
|
-
return /* @__PURE__ */
|
|
216
|
+
return /* @__PURE__ */ $(ge, { children: [
|
|
217
217
|
/* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: S || U || q.length === 0 || B ? /* @__PURE__ */ i(
|
|
218
|
-
|
|
218
|
+
z,
|
|
219
219
|
{
|
|
220
220
|
headers: he,
|
|
221
221
|
ariaLabel: n("FORMS_HEADING"),
|
|
@@ -223,7 +223,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
|
|
|
223
223
|
loading: S,
|
|
224
224
|
errorStateMessage: U ? te?.message : void 0,
|
|
225
225
|
emptyStateMessage: n("FORMS_UNAVAILABLE"),
|
|
226
|
-
renderCell:
|
|
226
|
+
renderCell: x,
|
|
227
227
|
className: T.formsTableBody,
|
|
228
228
|
dataTestId: "forms-table"
|
|
229
229
|
}
|
|
@@ -237,7 +237,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
|
|
|
237
237
|
testId: `accordian-title-${o}`,
|
|
238
238
|
open: r === 0,
|
|
239
239
|
children: /* @__PURE__ */ i(
|
|
240
|
-
|
|
240
|
+
z,
|
|
241
241
|
{
|
|
242
242
|
headers: s,
|
|
243
243
|
ariaLabel: n("FORMS_HEADING"),
|
|
@@ -246,7 +246,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
|
|
|
246
246
|
errorStateMessage: "",
|
|
247
247
|
sortable: pe,
|
|
248
248
|
emptyStateMessage: n("FORMS_UNAVAILABLE"),
|
|
249
|
-
renderCell:
|
|
249
|
+
renderCell: x,
|
|
250
250
|
className: T.formsTableBody,
|
|
251
251
|
dataTestId: `forms-table-${o}`
|
|
252
252
|
}
|
|
@@ -262,19 +262,19 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
|
|
|
262
262
|
portalId: "main-display-area",
|
|
263
263
|
open: g,
|
|
264
264
|
onRequestClose: j,
|
|
265
|
-
modalHeading: /* @__PURE__ */
|
|
265
|
+
modalHeading: /* @__PURE__ */ $("div", { className: T.modalHeading, children: [
|
|
266
266
|
/* @__PURE__ */ i("span", { children: a.formName }),
|
|
267
267
|
v && f(a) && /* @__PURE__ */ i(
|
|
268
|
-
|
|
268
|
+
K,
|
|
269
269
|
{
|
|
270
270
|
label: n("EDIT_OBSERVATION_FORM"),
|
|
271
271
|
kind: "ghost",
|
|
272
272
|
size: "sm",
|
|
273
273
|
testId: `edit-form-modal-${a.encounterUuid}`,
|
|
274
274
|
onClick: () => {
|
|
275
|
-
j(),
|
|
275
|
+
j(), D(a);
|
|
276
276
|
},
|
|
277
|
-
children: /* @__PURE__ */ i(
|
|
277
|
+
children: /* @__PURE__ */ i(Q, {})
|
|
278
278
|
}
|
|
279
279
|
)
|
|
280
280
|
] }),
|
|
@@ -302,5 +302,5 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
|
|
|
302
302
|
] });
|
|
303
303
|
};
|
|
304
304
|
export {
|
|
305
|
-
|
|
305
|
+
Qe as default
|
|
306
306
|
};
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { jsx as i, jsxs as S } from "react/jsx-runtime";
|
|
2
|
+
import { l as k, m as F, t as z, G as H, Q as P, n as j, T as x, R as J, S as Y, u as W, a as X, A as Z, y as ee, K as se, o as te, D as re, q as ae, s as oe, v as ne, w as ie, x as ce, b as le } from "./index-CxgzK6B5.js";
|
|
3
|
+
import { useQueries as de, useQuery as ue } from "@tanstack/react-query";
|
|
4
|
+
import { useRef as pe, useEffect as C, useMemo as I } from "react";
|
|
5
|
+
import { useTranslation as w } from "react-i18next";
|
|
6
|
+
const be = "Observations-module_observations__RKSyo", me = "Observations-module_title__TJL3z", ve = "Observations-module_wrapper__muk2L", ye = "Observations-module_secondary__14nuS", y = {
|
|
7
|
+
observations: be,
|
|
8
|
+
title: me,
|
|
9
|
+
wrapper: ve,
|
|
10
|
+
secondary: ye
|
|
11
|
+
}, U = (t, l, n, c, u, r) => {
|
|
12
|
+
const a = z(t, l, u), e = a.value, p = H(e);
|
|
13
|
+
let o = e;
|
|
14
|
+
p === "Image" && (o = /* @__PURE__ */ i(
|
|
15
|
+
x,
|
|
16
|
+
{
|
|
17
|
+
imageSrc: e,
|
|
18
|
+
alt: e,
|
|
19
|
+
id: `${e}-img`,
|
|
20
|
+
hideThumbnail: r
|
|
21
|
+
}
|
|
22
|
+
)), p === "Video" && (o = /* @__PURE__ */ i(
|
|
23
|
+
J,
|
|
24
|
+
{
|
|
25
|
+
id: `${e}-video`,
|
|
26
|
+
videoSrc: e,
|
|
27
|
+
hideThumbnail: r
|
|
28
|
+
}
|
|
29
|
+
)), p === "PDF" && (o = /* @__PURE__ */ i(Y, { id: `${e}-pdf`, src: e }));
|
|
30
|
+
const b = /* @__PURE__ */ S("div", { className: y.wrapper, children: [
|
|
31
|
+
/* @__PURE__ */ i("span", { children: a.header.display }),
|
|
32
|
+
a.header.referenceRange && /* @__PURE__ */ i("span", { className: y.secondary, children: a.header.referenceRange })
|
|
33
|
+
] }), d = u("OBSERVATIONS_RECORDED_BY", {
|
|
34
|
+
provider: a.provider
|
|
35
|
+
}), m = t.effectiveDateTime ? P(t.effectiveDateTime, u, !0).formattedResult : void 0, _ = /* @__PURE__ */ S("div", { className: y.wrapper, children: [
|
|
36
|
+
/* @__PURE__ */ i("span", { children: d }),
|
|
37
|
+
m && /* @__PURE__ */ i("span", { className: y.secondary, children: m })
|
|
38
|
+
] }), v = t.display, T = t.observationValue?.isAbnormal ? "abnormal-obs" : "obs", O = c ? `${c}-${T}-${v}-${n}-${l}` : `${T}-${v}-${n}-${l}`;
|
|
39
|
+
return /* @__PURE__ */ i(
|
|
40
|
+
j,
|
|
41
|
+
{
|
|
42
|
+
header: b,
|
|
43
|
+
value: o,
|
|
44
|
+
info: _,
|
|
45
|
+
id: O,
|
|
46
|
+
testId: O,
|
|
47
|
+
ariaLabel: O
|
|
48
|
+
},
|
|
49
|
+
`obs-${t.id}`
|
|
50
|
+
);
|
|
51
|
+
}, fe = (t, l, n, c, u, r, a) => /* @__PURE__ */ i(
|
|
52
|
+
F,
|
|
53
|
+
{
|
|
54
|
+
title: t.display,
|
|
55
|
+
id: `grouped-obs-${t.display}-${c}`,
|
|
56
|
+
open: n,
|
|
57
|
+
children: t.members?.map(
|
|
58
|
+
(e, p) => U(
|
|
59
|
+
e,
|
|
60
|
+
p,
|
|
61
|
+
u,
|
|
62
|
+
r,
|
|
63
|
+
l,
|
|
64
|
+
a
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
},
|
|
68
|
+
`grouped-obs-${t.id}`
|
|
69
|
+
), Oe = ({
|
|
70
|
+
groupedData: t,
|
|
71
|
+
title: l = "",
|
|
72
|
+
hideThumbnail: n
|
|
73
|
+
}) => {
|
|
74
|
+
const { t: c } = w(), u = (r, a, e) => {
|
|
75
|
+
const p = k(r.encounterDetails, c);
|
|
76
|
+
return /* @__PURE__ */ S(
|
|
77
|
+
F,
|
|
78
|
+
{
|
|
79
|
+
title: p,
|
|
80
|
+
id: `encounter-${r.encounterId}`,
|
|
81
|
+
open: a,
|
|
82
|
+
children: [
|
|
83
|
+
r.observations.map(
|
|
84
|
+
(o, b) => U(
|
|
85
|
+
o,
|
|
86
|
+
b,
|
|
87
|
+
e,
|
|
88
|
+
l,
|
|
89
|
+
c,
|
|
90
|
+
n
|
|
91
|
+
)
|
|
92
|
+
),
|
|
93
|
+
r.groupedObservations.map(
|
|
94
|
+
(o, b) => fe(
|
|
95
|
+
o,
|
|
96
|
+
c,
|
|
97
|
+
a,
|
|
98
|
+
b,
|
|
99
|
+
e,
|
|
100
|
+
l,
|
|
101
|
+
n
|
|
102
|
+
)
|
|
103
|
+
)
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
`encounter-${r.encounterId}`
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
return /* @__PURE__ */ i(
|
|
110
|
+
"div",
|
|
111
|
+
{
|
|
112
|
+
id: "obs-by-encounter",
|
|
113
|
+
"data-testid": "obs-by-encounter-test-id",
|
|
114
|
+
"aria-label": "obs-by-encounter-aria-label",
|
|
115
|
+
children: t.map(
|
|
116
|
+
(r, a) => u(r, a === 0, a)
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
}, Ee = (t) => ["conceptUuid", t], he = (t, l, n, c) => [
|
|
121
|
+
"observations",
|
|
122
|
+
t,
|
|
123
|
+
...l,
|
|
124
|
+
n,
|
|
125
|
+
c
|
|
126
|
+
], Se = ({
|
|
127
|
+
config: t,
|
|
128
|
+
episodeOfCareUuids: l,
|
|
129
|
+
encounterUuids: n
|
|
130
|
+
}) => {
|
|
131
|
+
const c = t, {
|
|
132
|
+
conceptNames: u = [],
|
|
133
|
+
conceptUuid: r = [],
|
|
134
|
+
hideThumbnail: a = !1,
|
|
135
|
+
scope: e = "all"
|
|
136
|
+
} = c, p = pe(/* @__PURE__ */ new Set()), o = W(), { addNotification: b } = X(), { t: d } = w(), m = de({
|
|
137
|
+
queries: u.map((s) => ({
|
|
138
|
+
queryKey: Ee(s),
|
|
139
|
+
queryFn: () => Z(s),
|
|
140
|
+
enabled: !!s
|
|
141
|
+
}))
|
|
142
|
+
});
|
|
143
|
+
C(() => {
|
|
144
|
+
const s = m.some((D) => D.isError), R = p.current.size > 0;
|
|
145
|
+
s && !R ? (b({
|
|
146
|
+
title: d("ERROR_DEFAULT_TITLE"),
|
|
147
|
+
message: d("ERROR_FETCHING_OBSERVATIONS"),
|
|
148
|
+
type: "error"
|
|
149
|
+
}), p.current.add(0)) : !s && R && p.current.clear();
|
|
150
|
+
}, [m, b, d]);
|
|
151
|
+
const _ = I(() => m.map((s) => s.data?.uuid).filter((s) => !!s), [m]), v = I(() => [.../* @__PURE__ */ new Set([..._, ...r])], [_, r]), f = I(() => u.length === 0 ? !0 : m.every((s) => !s.isLoading), [m, u.length]), T = e === "latest" || e === "latest-encounter", O = ee(
|
|
152
|
+
l,
|
|
153
|
+
n
|
|
154
|
+
), {
|
|
155
|
+
data: E,
|
|
156
|
+
isLoading: V,
|
|
157
|
+
isError: N,
|
|
158
|
+
refetch: $
|
|
159
|
+
} = ue({
|
|
160
|
+
queryKey: he(
|
|
161
|
+
o,
|
|
162
|
+
v,
|
|
163
|
+
n,
|
|
164
|
+
e
|
|
165
|
+
),
|
|
166
|
+
queryFn: () => T ? se(
|
|
167
|
+
o,
|
|
168
|
+
v,
|
|
169
|
+
n
|
|
170
|
+
) : te(
|
|
171
|
+
o,
|
|
172
|
+
v,
|
|
173
|
+
n
|
|
174
|
+
),
|
|
175
|
+
enabled: !!o && v.length > 0 && f && !O
|
|
176
|
+
});
|
|
177
|
+
re(
|
|
178
|
+
(s) => {
|
|
179
|
+
s.patientUUID === o && s.updatedConcepts.size > 0 && [...s.updatedConcepts.keys()].some(
|
|
180
|
+
(D) => v.includes(D)
|
|
181
|
+
) && $();
|
|
182
|
+
},
|
|
183
|
+
[o, $]
|
|
184
|
+
), C(() => {
|
|
185
|
+
N && b({
|
|
186
|
+
title: d("ERROR_DEFAULT_TITLE"),
|
|
187
|
+
message: d("ERROR_FETCHING_OBSERVATIONS"),
|
|
188
|
+
type: "error"
|
|
189
|
+
});
|
|
190
|
+
}, [N]);
|
|
191
|
+
const A = I(() => {
|
|
192
|
+
if (!E) return [];
|
|
193
|
+
let s = ae(E);
|
|
194
|
+
e === "latest-encounter" && (s = oe(s));
|
|
195
|
+
const R = ne(s);
|
|
196
|
+
return ie(R);
|
|
197
|
+
}, [E, e]), K = [
|
|
198
|
+
{ key: "name", header: "name" },
|
|
199
|
+
{ key: "value", header: "value" },
|
|
200
|
+
{ key: "form", header: "form" }
|
|
201
|
+
], L = V || !f, B = N && f, Q = (!E || E.entry?.length === 0 || v.length === 0) && f, G = B ? d("ERROR_FETCHING_OBSERVATIONS") : null, M = Q ? d("NO_OBSERVATIONS_FOUND") : void 0, q = A.length > 0 && !L && !B, g = c.titleTranslationKey, h = g ? d(g) : "";
|
|
202
|
+
return /* @__PURE__ */ S(
|
|
203
|
+
"div",
|
|
204
|
+
{
|
|
205
|
+
id: "observations",
|
|
206
|
+
"data-testid": g ? `observations-${h}` : "observations",
|
|
207
|
+
"aria-label": "observations-aria-label",
|
|
208
|
+
className: y.observations,
|
|
209
|
+
children: [
|
|
210
|
+
/* @__PURE__ */ i(
|
|
211
|
+
ce,
|
|
212
|
+
{
|
|
213
|
+
id: "observations-title",
|
|
214
|
+
testId: g ? `observations-title-${h}` : "observations-title",
|
|
215
|
+
title: h,
|
|
216
|
+
className: y.title,
|
|
217
|
+
children: /* @__PURE__ */ i("p", { children: h })
|
|
218
|
+
}
|
|
219
|
+
),
|
|
220
|
+
q ? /* @__PURE__ */ i(
|
|
221
|
+
Oe,
|
|
222
|
+
{
|
|
223
|
+
groupedData: A,
|
|
224
|
+
title: h,
|
|
225
|
+
hideThumbnail: a
|
|
226
|
+
}
|
|
227
|
+
) : /* @__PURE__ */ i(
|
|
228
|
+
le,
|
|
229
|
+
{
|
|
230
|
+
headers: K,
|
|
231
|
+
rows: [],
|
|
232
|
+
ariaLabel: d("OBSERVATIONS"),
|
|
233
|
+
loading: L,
|
|
234
|
+
errorStateMessage: G,
|
|
235
|
+
emptyStateMessage: M ?? d("NO_OBSERVATIONS_AVAILABLE"),
|
|
236
|
+
dataTestId: "observations-table"
|
|
237
|
+
}
|
|
238
|
+
)
|
|
239
|
+
]
|
|
240
|
+
}
|
|
241
|
+
);
|
|
242
|
+
};
|
|
243
|
+
export {
|
|
244
|
+
Ee as conceptUuidQueryKeys,
|
|
245
|
+
Se as default,
|
|
246
|
+
he as observationsQueryKeys
|
|
247
|
+
};
|