@bahmni/widgets 0.0.1-dev.118 → 0.0.1-dev.120
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/{FormsTable-DKfPe7sR.js → FormsTable-R9y4-AL4.js} +54 -54
- package/dist/Observations-DgVj51KZ.js +330 -0
- package/dist/{index-Ciduksrd.js → index-CQcHNtl1.js} +10472 -10249
- package/dist/index.css +1 -1
- package/dist/index.js +15 -15
- package/dist/labinvestigation/LabInvestigation.d.ts.map +1 -1
- package/dist/labinvestigation/LabInvestigationItem.d.ts +5 -2
- package/dist/labinvestigation/LabInvestigationItem.d.ts.map +1 -1
- package/dist/labinvestigation/models.d.ts +30 -0
- package/dist/labinvestigation/models.d.ts.map +1 -0
- package/dist/labinvestigation/utils.d.ts +38 -0
- package/dist/labinvestigation/utils.d.ts.map +1 -0
- package/dist/observations/__mocks__/observationTestData.d.ts +5 -0
- package/dist/observations/__mocks__/observationTestData.d.ts.map +1 -1
- package/dist/observations/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/Observations-CDcoFLGt.js +0 -306
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsxs as _, jsx as t, Fragment as
|
|
2
|
-
import { c as h, u as
|
|
1
|
+
import { jsxs as _, jsx as t, Fragment as Q } from "react/jsx-runtime";
|
|
2
|
+
import { c as h, u as Y, C as W, F as Z, q as ee, U as re, D as oe, J as te, l as ae, K as $, a as ne, m as se, p as ce, X as de, b as U, o as me } from "./index-CQcHNtl1.js";
|
|
3
3
|
import { useQuery as g } from "@tanstack/react-query";
|
|
4
4
|
import { useState as q, useMemo as b, useCallback as N } from "react";
|
|
5
|
-
import { createPortal as
|
|
5
|
+
import { createPortal as le } from "react-dom";
|
|
6
6
|
import { useTranslation as ie } from "react-i18next";
|
|
7
|
-
const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e = "_formContent_1pd36_18", be = "_formDetailsContainer_1pd36_25", fe = "_observation_1pd36_30", ge = "_groupContainer_1pd36_39", Ne = "_rowContainer_1pd36_43", he = "_groupLabel_1pd36_48", ye = "_rowLabel_1pd36_58", Me = "_rowValue_1pd36_67", Le = "_groupMembers_1pd36_75", Ae = "_memberRow_1pd36_81", Oe = "_memberLabel_1pd36_86",
|
|
7
|
+
const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e = "_formContent_1pd36_18", be = "_formDetailsContainer_1pd36_25", fe = "_observation_1pd36_30", ge = "_groupContainer_1pd36_39", Ne = "_rowContainer_1pd36_43", he = "_groupLabel_1pd36_48", ye = "_rowLabel_1pd36_58", Me = "_rowValue_1pd36_67", Le = "_groupMembers_1pd36_75", Ae = "_memberRow_1pd36_81", Oe = "_memberLabel_1pd36_86", De = "_memberValue_1pd36_94", Re = "_abnormalValue_1pd36_102", Ce = "_commentSection_1pd36_110", Fe = "_commentText_1pd36_116", Te = "_nestedGroup_1pd36_125", ve = "_nestedGroupLabel_1pd36_132", Ee = "_nestedGroupMembers_1pd36_141", r = {
|
|
8
8
|
formsTableBody: ue,
|
|
9
9
|
customAccordianItem: pe,
|
|
10
10
|
formContent: _e,
|
|
@@ -18,17 +18,17 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
|
|
|
18
18
|
groupMembers: Le,
|
|
19
19
|
memberRow: Ae,
|
|
20
20
|
memberLabel: Oe,
|
|
21
|
-
memberValue:
|
|
22
|
-
abnormalValue:
|
|
23
|
-
commentSection:
|
|
21
|
+
memberValue: De,
|
|
22
|
+
abnormalValue: Re,
|
|
23
|
+
commentSection: Ce,
|
|
24
24
|
commentText: Fe,
|
|
25
25
|
nestedGroup: Te,
|
|
26
26
|
nestedGroupLabel: ve,
|
|
27
27
|
nestedGroupMembers: Ee
|
|
28
28
|
}, we = "ABNORMAL", x = (e) => {
|
|
29
|
-
const s = e.concept?.units, c = e.concept?.lowNormal, o = e.concept?.hiNormal,
|
|
29
|
+
const s = e.concept?.units, c = e.concept?.lowNormal, o = e.concept?.hiNormal, l = c != null, i = o != null, p = l && i ? ` (${c} - ${o})` : l ? ` (>${c})` : i ? ` (<${o})` : "", a = e.interpretation && e.interpretation.toUpperCase() === we;
|
|
30
30
|
return { units: s, rangeString: p, isAbnormal: a };
|
|
31
|
-
},
|
|
31
|
+
}, k = ({
|
|
32
32
|
member: e,
|
|
33
33
|
depth: s = 0
|
|
34
34
|
}) => {
|
|
@@ -44,7 +44,7 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
|
|
|
44
44
|
}
|
|
45
45
|
),
|
|
46
46
|
/* @__PURE__ */ t("div", { className: r.nestedGroupMembers, children: e.groupMembers?.map((a) => /* @__PURE__ */ t(
|
|
47
|
-
|
|
47
|
+
k,
|
|
48
48
|
{
|
|
49
49
|
member: a,
|
|
50
50
|
depth: s + 1
|
|
@@ -52,7 +52,7 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
|
|
|
52
52
|
`${a.concept.uuid}`
|
|
53
53
|
)) })
|
|
54
54
|
] });
|
|
55
|
-
const { units:
|
|
55
|
+
const { units: l, rangeString: i, isAbnormal: p } = x(e);
|
|
56
56
|
return /* @__PURE__ */ _(
|
|
57
57
|
"div",
|
|
58
58
|
{
|
|
@@ -81,18 +81,18 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
|
|
|
81
81
|
),
|
|
82
82
|
children: [
|
|
83
83
|
e.valueAsString,
|
|
84
|
-
|
|
84
|
+
l && ` ${l}`
|
|
85
85
|
]
|
|
86
86
|
}
|
|
87
87
|
)
|
|
88
88
|
]
|
|
89
89
|
}
|
|
90
90
|
);
|
|
91
|
-
},
|
|
91
|
+
}, Be = ({
|
|
92
92
|
observation: e,
|
|
93
93
|
index: s
|
|
94
94
|
}) => {
|
|
95
|
-
const c = e.groupMembers && e.groupMembers.length > 0, { units: o, rangeString:
|
|
95
|
+
const c = e.groupMembers && e.groupMembers.length > 0, { units: o, rangeString: l, isAbnormal: i } = x(e);
|
|
96
96
|
return /* @__PURE__ */ _(
|
|
97
97
|
"div",
|
|
98
98
|
{
|
|
@@ -112,12 +112,12 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
|
|
|
112
112
|
),
|
|
113
113
|
children: [
|
|
114
114
|
e.conceptNameToDisplay,
|
|
115
|
-
!c &&
|
|
115
|
+
!c && l && /* @__PURE__ */ t("span", { className: r.rangeInfo, children: l })
|
|
116
116
|
]
|
|
117
117
|
}
|
|
118
118
|
),
|
|
119
119
|
c ? /* @__PURE__ */ t("div", { className: r.groupMembers, children: e.groupMembers?.map((p) => /* @__PURE__ */ t(
|
|
120
|
-
|
|
120
|
+
k,
|
|
121
121
|
{
|
|
122
122
|
member: p,
|
|
123
123
|
depth: 0
|
|
@@ -152,18 +152,18 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
|
|
|
152
152
|
encounterUuids: s,
|
|
153
153
|
config: c
|
|
154
154
|
}) => {
|
|
155
|
-
const { t: o } = ie(),
|
|
155
|
+
const { t: o } = ie(), l = Y(), [i, p] = q(!1), [a, O] = q(null), H = c?.numberOfVisits, D = W(
|
|
156
156
|
e,
|
|
157
157
|
s
|
|
158
158
|
), {
|
|
159
159
|
data: y = [],
|
|
160
|
-
isLoading:
|
|
161
|
-
isError:
|
|
162
|
-
error:
|
|
160
|
+
isLoading: R,
|
|
161
|
+
isError: C,
|
|
162
|
+
error: K
|
|
163
163
|
} = g({
|
|
164
|
-
queryKey: ["forms",
|
|
165
|
-
queryFn: () => Z(
|
|
166
|
-
enabled: !!
|
|
164
|
+
queryKey: ["forms", l, e],
|
|
165
|
+
queryFn: () => Z(l, void 0, H),
|
|
166
|
+
enabled: !!l && !D
|
|
167
167
|
}), F = b(() => !s || s.length === 0 ? y : y.filter(
|
|
168
168
|
(n) => s.includes(n.encounterUuid)
|
|
169
169
|
), [y, s]), { data: T = [] } = g({
|
|
@@ -176,8 +176,8 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
|
|
|
176
176
|
if (a)
|
|
177
177
|
return v(a.formName);
|
|
178
178
|
}, [a, v]), {
|
|
179
|
-
data:
|
|
180
|
-
isLoading:
|
|
179
|
+
data: Ie,
|
|
180
|
+
isLoading: P,
|
|
181
181
|
error: E
|
|
182
182
|
} = g({
|
|
183
183
|
queryKey: ["formMetadata", M],
|
|
@@ -185,21 +185,21 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
|
|
|
185
185
|
enabled: !!M && i
|
|
186
186
|
}), {
|
|
187
187
|
data: L,
|
|
188
|
-
isLoading:
|
|
188
|
+
isLoading: j,
|
|
189
189
|
error: w
|
|
190
190
|
} = g({
|
|
191
191
|
queryKey: ["formsEncounter", a?.encounterUuid],
|
|
192
192
|
queryFn: () => oe(a.encounterUuid, !0),
|
|
193
193
|
enabled: !!a?.encounterUuid && i
|
|
194
|
-
}),
|
|
194
|
+
}), B = b(() => !L?.observations || !a?.formName ? [] : L.observations.filter(
|
|
195
195
|
(u) => "formFieldPath" in u && typeof u.formFieldPath == "string" && u.formFieldPath.includes(a.formName)
|
|
196
|
-
), [L?.observations, a?.formName]),
|
|
196
|
+
), [L?.observations, a?.formName]), I = b(
|
|
197
197
|
() => [
|
|
198
198
|
{ key: "recordedOn", header: o("FORM_RECORDED_ON") },
|
|
199
199
|
{ key: "recordedBy", header: o("FORM_RECORDED_BY") }
|
|
200
200
|
],
|
|
201
201
|
[o]
|
|
202
|
-
),
|
|
202
|
+
), J = b(
|
|
203
203
|
() => [
|
|
204
204
|
{ key: "recordedOn", sortable: !0 },
|
|
205
205
|
{ key: "recordedBy", sortable: !0 }
|
|
@@ -207,32 +207,32 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
|
|
|
207
207
|
[]
|
|
208
208
|
), V = b(() => {
|
|
209
209
|
const n = F.reduce(
|
|
210
|
-
(d,
|
|
211
|
-
const f =
|
|
210
|
+
(d, m) => {
|
|
211
|
+
const f = m.formName;
|
|
212
212
|
d[f] ??= [];
|
|
213
|
-
const A =
|
|
213
|
+
const A = m.providers.map((z) => z.providerName).filter(Boolean).join(", ");
|
|
214
214
|
return d[f].push({
|
|
215
|
-
id:
|
|
216
|
-
formName:
|
|
217
|
-
recordedOn: te(
|
|
215
|
+
id: m.encounterUuid,
|
|
216
|
+
formName: m.formName,
|
|
217
|
+
recordedOn: te(m.encounterDateTime, o, me).formattedResult,
|
|
218
218
|
recordedBy: A ?? "--",
|
|
219
|
-
encounterDateTime:
|
|
220
|
-
encounterUuid:
|
|
219
|
+
encounterDateTime: m.encounterDateTime,
|
|
220
|
+
encounterUuid: m.encounterUuid
|
|
221
221
|
}), d;
|
|
222
222
|
},
|
|
223
223
|
{}
|
|
224
224
|
);
|
|
225
225
|
return Object.entries(n).map(
|
|
226
|
-
([d,
|
|
226
|
+
([d, m]) => ({
|
|
227
227
|
formName: d,
|
|
228
|
-
records:
|
|
228
|
+
records: m.sort(
|
|
229
229
|
(f, A) => A.encounterDateTime - f.encounterDateTime
|
|
230
230
|
)
|
|
231
231
|
})
|
|
232
|
-
).sort((d,
|
|
232
|
+
).sort((d, m) => d.formName.localeCompare(m.formName));
|
|
233
233
|
}, [F, o]), S = N((n) => {
|
|
234
234
|
O(n), p(!0);
|
|
235
|
-
}, []),
|
|
235
|
+
}, []), X = N(() => {
|
|
236
236
|
p(!1), O(null);
|
|
237
237
|
}, []), G = N(
|
|
238
238
|
(n, u) => {
|
|
@@ -247,22 +247,22 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
|
|
|
247
247
|
},
|
|
248
248
|
[S]
|
|
249
249
|
);
|
|
250
|
-
return /* @__PURE__ */ _(
|
|
251
|
-
/* @__PURE__ */ t("div", { "data-testid": "forms-table", children:
|
|
250
|
+
return /* @__PURE__ */ _(Q, { children: [
|
|
251
|
+
/* @__PURE__ */ t("div", { "data-testid": "forms-table", children: R || C || V.length === 0 || D ? /* @__PURE__ */ t(
|
|
252
252
|
$,
|
|
253
253
|
{
|
|
254
|
-
headers:
|
|
254
|
+
headers: I,
|
|
255
255
|
ariaLabel: o("FORMS_HEADING"),
|
|
256
256
|
rows: [],
|
|
257
|
-
loading:
|
|
258
|
-
errorStateMessage:
|
|
257
|
+
loading: R,
|
|
258
|
+
errorStateMessage: C ? K?.message : void 0,
|
|
259
259
|
emptyStateMessage: o("FORMS_UNAVAILABLE"),
|
|
260
260
|
renderCell: G,
|
|
261
261
|
className: r.formsTableBody,
|
|
262
262
|
"data-testid": "sortable-data-table"
|
|
263
263
|
}
|
|
264
264
|
) : /* @__PURE__ */ t(ne, { align: "start", children: V.map((n, u) => {
|
|
265
|
-
const { formName: d, records:
|
|
265
|
+
const { formName: d, records: m } = n;
|
|
266
266
|
return /* @__PURE__ */ t(
|
|
267
267
|
se,
|
|
268
268
|
{
|
|
@@ -273,12 +273,12 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
|
|
|
273
273
|
children: /* @__PURE__ */ t(
|
|
274
274
|
$,
|
|
275
275
|
{
|
|
276
|
-
headers:
|
|
276
|
+
headers: I,
|
|
277
277
|
ariaLabel: o("FORMS_HEADING"),
|
|
278
|
-
rows:
|
|
278
|
+
rows: m,
|
|
279
279
|
loading: !1,
|
|
280
280
|
errorStateMessage: "",
|
|
281
|
-
sortable:
|
|
281
|
+
sortable: J,
|
|
282
282
|
emptyStateMessage: o("FORMS_UNAVAILABLE"),
|
|
283
283
|
renderCell: G,
|
|
284
284
|
className: r.formsTableBody,
|
|
@@ -289,20 +289,20 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
|
|
|
289
289
|
d
|
|
290
290
|
);
|
|
291
291
|
}) }) }),
|
|
292
|
-
i && a &&
|
|
292
|
+
i && a && le(
|
|
293
293
|
/* @__PURE__ */ t(
|
|
294
294
|
ce,
|
|
295
295
|
{
|
|
296
296
|
id: "formDetailsModal",
|
|
297
297
|
open: i,
|
|
298
|
-
onRequestClose:
|
|
298
|
+
onRequestClose: X,
|
|
299
299
|
modalHeading: a.formName,
|
|
300
300
|
modalLabel: `${a.recordedOn} | ${a.recordedBy}`,
|
|
301
301
|
passiveModal: !0,
|
|
302
302
|
size: "md",
|
|
303
303
|
testId: "form-details-modal",
|
|
304
|
-
children: /* @__PURE__ */ t("div", { className: r.formContent, children:
|
|
305
|
-
|
|
304
|
+
children: /* @__PURE__ */ t("div", { className: r.formContent, children: P || j ? /* @__PURE__ */ t(de, { width: "100%", lineCount: 3 }) : E ? /* @__PURE__ */ t("div", { children: U(E).message ?? o("ERROR_FETCHING_FORM_METADATA") }) : w ? /* @__PURE__ */ t("div", { children: U(w).message ?? o("ERROR_FETCHING_FORM_DATA") }) : B.length > 0 ? /* @__PURE__ */ t("div", { className: r.formDetailsContainer, children: B.map((n, u) => /* @__PURE__ */ t(
|
|
305
|
+
Be,
|
|
306
306
|
{
|
|
307
307
|
observation: n,
|
|
308
308
|
index: u
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { jsx as d, jsxs as T } from "react/jsx-runtime";
|
|
2
|
+
import { Y as B, H as $, d as U, L as F, e as x, V as K, u as q, f as H, g as Q, A as k, S as G, K as P } from "./index-CQcHNtl1.js";
|
|
3
|
+
import { useQueries as Y, useQuery as j } from "@tanstack/react-query";
|
|
4
|
+
import { useRef as z, useEffect as R, useMemo as m } from "react";
|
|
5
|
+
import { useTranslation as _ } from "react-i18next";
|
|
6
|
+
const J = "normal", W = "http://terminology.hl7.org/CodeSystem/referencerange-meaning", X = "A", Z = "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", ee = (e, n) => e?.date ? B(e.date, n).formattedResult : n("DATE_ERROR_PARSE"), te = (e) => {
|
|
7
|
+
if (!e.observationValue?.value)
|
|
8
|
+
return "";
|
|
9
|
+
const { value: n, unit: t } = e.observationValue;
|
|
10
|
+
return t ? `${n} ${t}` : String(n);
|
|
11
|
+
}, ne = (e) => {
|
|
12
|
+
const n = e.display;
|
|
13
|
+
if (!e.observationValue)
|
|
14
|
+
return String(n);
|
|
15
|
+
const { unit: t, referenceRange: r } = e.observationValue;
|
|
16
|
+
if (!r)
|
|
17
|
+
return String(n);
|
|
18
|
+
const { low: o, high: i } = r;
|
|
19
|
+
if (o && i) {
|
|
20
|
+
const s = o.unit ? `${o.value} ${o.unit}` : t ? `${o.value} ${t}` : String(o.value), a = i.unit ? `${i.value} ${i.unit}` : t ? `${i.value} ${t}` : String(i.value);
|
|
21
|
+
return `${n} (${s} - ${a})`;
|
|
22
|
+
}
|
|
23
|
+
if (o) {
|
|
24
|
+
const s = o.unit ? `${o.value} ${o.unit}` : t ? `${o.value} ${t}` : String(o.value);
|
|
25
|
+
return `${n} (>${s})`;
|
|
26
|
+
}
|
|
27
|
+
if (i) {
|
|
28
|
+
const s = i.unit ? `${i.value} ${i.unit}` : t ? `${i.value} ${t}` : String(i.value);
|
|
29
|
+
return `${n} (<${s})`;
|
|
30
|
+
}
|
|
31
|
+
return n;
|
|
32
|
+
}, re = (e, n) => ({
|
|
33
|
+
index: n,
|
|
34
|
+
header: ne(e),
|
|
35
|
+
value: te(e),
|
|
36
|
+
provider: e.encounter?.provider
|
|
37
|
+
}), h = (e) => (typeof e == "string" ? e : e?.reference)?.split("/")?.pop();
|
|
38
|
+
function oe(e) {
|
|
39
|
+
return !e.interpretation || e.interpretation.length === 0 ? !1 : e.interpretation.some(
|
|
40
|
+
(n) => n.coding?.some(
|
|
41
|
+
(t) => t.system === Z && t.code === X
|
|
42
|
+
)
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
function ie(e) {
|
|
46
|
+
const {
|
|
47
|
+
valueQuantity: n,
|
|
48
|
+
valueCodeableConcept: t,
|
|
49
|
+
valueString: r,
|
|
50
|
+
valueBoolean: o,
|
|
51
|
+
valueInteger: i,
|
|
52
|
+
referenceRange: s
|
|
53
|
+
} = e, a = oe(e);
|
|
54
|
+
if (n) {
|
|
55
|
+
const u = {
|
|
56
|
+
value: n.value ?? "",
|
|
57
|
+
unit: n.unit,
|
|
58
|
+
type: "quantity",
|
|
59
|
+
isAbnormal: a
|
|
60
|
+
};
|
|
61
|
+
if (s && s.length > 0) {
|
|
62
|
+
const l = s.find(
|
|
63
|
+
(p) => p.type?.coding?.some(
|
|
64
|
+
(v) => v.system === W && v.code === J
|
|
65
|
+
)
|
|
66
|
+
);
|
|
67
|
+
l && (l.low || l.high) && (u.referenceRange = {
|
|
68
|
+
low: l.low ? {
|
|
69
|
+
value: l.low.value,
|
|
70
|
+
unit: l.low.unit
|
|
71
|
+
} : void 0,
|
|
72
|
+
high: l.high ? {
|
|
73
|
+
value: l.high.value,
|
|
74
|
+
unit: l.high.unit
|
|
75
|
+
} : void 0
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return u;
|
|
79
|
+
}
|
|
80
|
+
if (t)
|
|
81
|
+
return {
|
|
82
|
+
value: t.text ?? t.coding[0].display,
|
|
83
|
+
type: "codeable",
|
|
84
|
+
isAbnormal: a
|
|
85
|
+
};
|
|
86
|
+
if (r)
|
|
87
|
+
return {
|
|
88
|
+
value: r,
|
|
89
|
+
type: "string",
|
|
90
|
+
isAbnormal: a
|
|
91
|
+
};
|
|
92
|
+
if (o !== void 0)
|
|
93
|
+
return {
|
|
94
|
+
value: o,
|
|
95
|
+
type: "boolean",
|
|
96
|
+
isAbnormal: a
|
|
97
|
+
};
|
|
98
|
+
if (i !== void 0)
|
|
99
|
+
return {
|
|
100
|
+
value: i,
|
|
101
|
+
type: "integer",
|
|
102
|
+
isAbnormal: a
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function se(e, n) {
|
|
106
|
+
const t = n.get(e);
|
|
107
|
+
if (t)
|
|
108
|
+
return {
|
|
109
|
+
id: t.id ?? e,
|
|
110
|
+
type: t.type?.[0]?.coding?.[0]?.display ?? "Unknown",
|
|
111
|
+
date: t.period?.start ?? "",
|
|
112
|
+
provider: t.participant?.[0]?.individual?.display,
|
|
113
|
+
location: t.location?.[0]?.location?.display
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function I(e, n, t) {
|
|
117
|
+
const r = h(e.encounter), o = (e.hasMember ?? []).map((i) => h(i)).map((i) => i ? t.get(i) : void 0).filter((i) => !!i).map(
|
|
118
|
+
(i) => I(i, n, t)
|
|
119
|
+
);
|
|
120
|
+
return {
|
|
121
|
+
id: e.id,
|
|
122
|
+
display: e.code?.text ?? e.code?.coding?.[0]?.display ?? "",
|
|
123
|
+
observationValue: ie(e),
|
|
124
|
+
effectiveDateTime: e.effectiveDateTime,
|
|
125
|
+
issued: e.issued,
|
|
126
|
+
encounter: r ? se(r, n) : void 0,
|
|
127
|
+
members: o.length > 0 ? o : void 0
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function ae(e) {
|
|
131
|
+
const n = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
|
|
132
|
+
e.entry?.forEach(({ resource: s }) => {
|
|
133
|
+
s?.id && (s.resourceType === "Encounter" ? n.set(s.id, s) : s.resourceType === "Observation" && (t.set(s.id, s), s.hasMember?.forEach((a) => {
|
|
134
|
+
const u = h(a);
|
|
135
|
+
u && r.add(u);
|
|
136
|
+
})));
|
|
137
|
+
});
|
|
138
|
+
const o = [], i = [];
|
|
139
|
+
return t.forEach((s, a) => {
|
|
140
|
+
if (r.has(a)) return;
|
|
141
|
+
const u = I(
|
|
142
|
+
s,
|
|
143
|
+
n,
|
|
144
|
+
t
|
|
145
|
+
);
|
|
146
|
+
u.members?.length ? i.push({ ...u, children: u.members }) : o.push(u);
|
|
147
|
+
}), { observations: o, groupedObservations: i };
|
|
148
|
+
}
|
|
149
|
+
function ue(e) {
|
|
150
|
+
const n = /* @__PURE__ */ new Map();
|
|
151
|
+
return e.observations.forEach((t) => {
|
|
152
|
+
if (!t.encounter?.id) return;
|
|
153
|
+
const r = t.encounter.id;
|
|
154
|
+
n.has(r) || n.set(r, {
|
|
155
|
+
observations: [],
|
|
156
|
+
groupedObservations: []
|
|
157
|
+
}), n.get(r).observations.push(t);
|
|
158
|
+
}), e.groupedObservations.forEach((t) => {
|
|
159
|
+
if (!t.encounter?.id) return;
|
|
160
|
+
const r = t.encounter.id;
|
|
161
|
+
n.has(r) || n.set(r, {
|
|
162
|
+
observations: [],
|
|
163
|
+
groupedObservations: []
|
|
164
|
+
}), n.get(r).groupedObservations.push(t);
|
|
165
|
+
}), Array.from(n.entries()).map(([t, r]) => {
|
|
166
|
+
const o = r.observations[0]?.encounter ?? r.groupedObservations[0]?.encounter;
|
|
167
|
+
return {
|
|
168
|
+
encounterId: t,
|
|
169
|
+
encounterDetails: o,
|
|
170
|
+
observations: r.observations,
|
|
171
|
+
groupedObservations: r.groupedObservations
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function ce(e) {
|
|
176
|
+
return [...e].sort((n, t) => {
|
|
177
|
+
const r = n.encounterDetails?.date, o = t.encounterDetails?.date;
|
|
178
|
+
return !r && !o ? 0 : r ? o ? new Date(o).getTime() - new Date(r).getTime() : -1 : 1;
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
const N = (e, n, t) => {
|
|
182
|
+
const r = re(e, n), o = r.value, i = U(o);
|
|
183
|
+
let s = o;
|
|
184
|
+
i === "Image" && (s = /* @__PURE__ */ d(x, { imageSrc: o, alt: o, id: `${o}-img` })), i === "Video" && (s = /* @__PURE__ */ d(K, { id: `${o}-video`, videoSrc: o }));
|
|
185
|
+
const a = t("OBSERVATIONS_RECORDED_BY", {
|
|
186
|
+
provider: r.provider
|
|
187
|
+
}), u = e.observationValue?.isAbnormal ? `abnormal-obs-${e.id}` : `obs-${e.id}`;
|
|
188
|
+
return /* @__PURE__ */ d(
|
|
189
|
+
F,
|
|
190
|
+
{
|
|
191
|
+
header: r.header,
|
|
192
|
+
value: s,
|
|
193
|
+
info: a,
|
|
194
|
+
id: u,
|
|
195
|
+
testId: `${u}-test-id`,
|
|
196
|
+
ariaLabel: `${u}-aria-label`
|
|
197
|
+
},
|
|
198
|
+
`obs-${e.id}`
|
|
199
|
+
);
|
|
200
|
+
}, le = (e, n, t) => /* @__PURE__ */ d(
|
|
201
|
+
$,
|
|
202
|
+
{
|
|
203
|
+
title: e.display,
|
|
204
|
+
id: `grouped-obs-${e.id}`,
|
|
205
|
+
open: t,
|
|
206
|
+
children: e.children.map(
|
|
207
|
+
(r, o) => N(r, o, n)
|
|
208
|
+
)
|
|
209
|
+
},
|
|
210
|
+
`grouped-obs-${e.id}`
|
|
211
|
+
), de = ({
|
|
212
|
+
groupedData: e
|
|
213
|
+
}) => {
|
|
214
|
+
const { t: n } = _(), t = (r, o) => {
|
|
215
|
+
const i = ee(r.encounterDetails, n);
|
|
216
|
+
return /* @__PURE__ */ T(
|
|
217
|
+
$,
|
|
218
|
+
{
|
|
219
|
+
title: i,
|
|
220
|
+
id: `encounter-${r.encounterId}`,
|
|
221
|
+
open: o,
|
|
222
|
+
children: [
|
|
223
|
+
r.observations.map(
|
|
224
|
+
(s, a) => N(s, a, n)
|
|
225
|
+
),
|
|
226
|
+
r.groupedObservations.map(
|
|
227
|
+
(s) => le(s, n, o)
|
|
228
|
+
)
|
|
229
|
+
]
|
|
230
|
+
},
|
|
231
|
+
`encounter-${r.encounterId}`
|
|
232
|
+
);
|
|
233
|
+
};
|
|
234
|
+
return /* @__PURE__ */ d(
|
|
235
|
+
"div",
|
|
236
|
+
{
|
|
237
|
+
id: "obs-by-encounter",
|
|
238
|
+
"data-testid": "obs-by-encounter-test-id",
|
|
239
|
+
"aria-label": "obs-by-encounter-aria-label",
|
|
240
|
+
children: e.map(
|
|
241
|
+
(r, o) => t(r, o === 0)
|
|
242
|
+
)
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
}, ve = "_observations_kfbhq_1", pe = "_title_kfbhq_12", S = {
|
|
246
|
+
observations: ve,
|
|
247
|
+
title: pe
|
|
248
|
+
}, fe = (e) => ["conceptUuid", e], ge = (e, n) => ["observations", e, ...n], Oe = ({ config: e }) => {
|
|
249
|
+
const n = e, { conceptNames: t = [], conceptUuid: r = [] } = n, o = z(/* @__PURE__ */ new Set()), i = q(), { addNotification: s } = H(), { t: a } = _(), u = Y({
|
|
250
|
+
queries: t.map((c) => ({
|
|
251
|
+
queryKey: fe(c),
|
|
252
|
+
queryFn: () => Q(c),
|
|
253
|
+
enabled: !!c
|
|
254
|
+
}))
|
|
255
|
+
});
|
|
256
|
+
R(() => {
|
|
257
|
+
u.forEach((c, f) => {
|
|
258
|
+
if (c.isError && !o.current.has(f)) {
|
|
259
|
+
const M = t[f];
|
|
260
|
+
s({
|
|
261
|
+
title: a("ERROR_DEFAULT_TITLE"),
|
|
262
|
+
message: a("ERROR_FETCHING_CONCEPT", { conceptName: M }),
|
|
263
|
+
type: "error"
|
|
264
|
+
}), o.current.add(f);
|
|
265
|
+
} else c.isError || o.current.delete(f);
|
|
266
|
+
});
|
|
267
|
+
}, [u, t]);
|
|
268
|
+
const l = m(() => u.map((c) => c.data?.uuid).filter((c) => !!c), [u]), p = m(() => [.../* @__PURE__ */ new Set([...l, ...r])], [l, r]), v = m(() => t.length === 0 ? !0 : u.every((c) => !c.isLoading), [u, t.length]), {
|
|
269
|
+
data: g,
|
|
270
|
+
isLoading: A,
|
|
271
|
+
isError: b
|
|
272
|
+
} = j({
|
|
273
|
+
queryKey: ge(i, p),
|
|
274
|
+
queryFn: () => k(i, p),
|
|
275
|
+
enabled: !!i && p.length > 0 && v
|
|
276
|
+
});
|
|
277
|
+
R(() => {
|
|
278
|
+
b && s({
|
|
279
|
+
title: a("ERROR_DEFAULT_TITLE"),
|
|
280
|
+
message: a("ERROR_FETCHING_OBSERVATIONS"),
|
|
281
|
+
type: "error"
|
|
282
|
+
});
|
|
283
|
+
}, [b]);
|
|
284
|
+
const y = m(() => {
|
|
285
|
+
if (!g) return [];
|
|
286
|
+
const c = ae(g), f = ue(c);
|
|
287
|
+
return ce(f);
|
|
288
|
+
}, [g]), D = [
|
|
289
|
+
{ key: "name", header: "name" },
|
|
290
|
+
{ key: "value", header: "value" },
|
|
291
|
+
{ key: "form", header: "form" }
|
|
292
|
+
], E = A || !v, O = b && v, w = (!g || g.entry?.length === 0 || p.length === 0) && v, C = O ? a("ERROR_FETCHING_OBSERVATIONS") : null, V = w ? a("NO_OBSERVATIONS_FOUND") : void 0, L = y.length > 0 && !E && !O;
|
|
293
|
+
return /* @__PURE__ */ T(
|
|
294
|
+
"div",
|
|
295
|
+
{
|
|
296
|
+
id: "observations",
|
|
297
|
+
"data-testid": "observations-test-id",
|
|
298
|
+
"aria-label": "observations-aria-label",
|
|
299
|
+
className: S.observations,
|
|
300
|
+
children: [
|
|
301
|
+
/* @__PURE__ */ d(
|
|
302
|
+
G,
|
|
303
|
+
{
|
|
304
|
+
id: "observations-title",
|
|
305
|
+
testId: "observations-title-test-id",
|
|
306
|
+
title: a(n.titleTranslationKey),
|
|
307
|
+
className: S.title,
|
|
308
|
+
children: /* @__PURE__ */ d("p", { children: a(n.titleTranslationKey) })
|
|
309
|
+
}
|
|
310
|
+
),
|
|
311
|
+
L ? /* @__PURE__ */ d(de, { groupedData: y }) : /* @__PURE__ */ d(
|
|
312
|
+
P,
|
|
313
|
+
{
|
|
314
|
+
headers: D,
|
|
315
|
+
rows: [],
|
|
316
|
+
ariaLabel: a("OBSERVATIONS"),
|
|
317
|
+
loading: E,
|
|
318
|
+
errorStateMessage: C,
|
|
319
|
+
emptyStateMessage: V
|
|
320
|
+
}
|
|
321
|
+
)
|
|
322
|
+
]
|
|
323
|
+
}
|
|
324
|
+
);
|
|
325
|
+
};
|
|
326
|
+
export {
|
|
327
|
+
fe as conceptUuidQueryKeys,
|
|
328
|
+
Oe as default,
|
|
329
|
+
ge as observationsQueryKeys
|
|
330
|
+
};
|