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