@bahmni/widgets 0.0.1-dev.190 → 0.0.1-dev.192
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-DBGR411T.js +204 -0
- package/dist/FormsTable-BP08e4n9.js +423 -0
- package/dist/Observations-SiLS1rRQ.js +172 -0
- package/dist/appContext/AppContextProvider.d.ts +7 -0
- package/dist/appContext/AppContextProvider.d.ts.map +1 -0
- package/dist/appContext/index.d.ts +2 -0
- package/dist/appContext/index.d.ts.map +1 -0
- package/dist/appointments/AppointmentsTable.d.ts.map +1 -1
- package/dist/diagnoses/DiagnosesTable.d.ts.map +1 -1
- package/dist/documents/DocumentsTable.d.ts.map +1 -1
- package/dist/documents/utils.d.ts.map +1 -1
- package/dist/forms/FormsTable.d.ts.map +1 -1
- package/dist/forms/ObservationItem.d.ts.map +1 -1
- package/dist/genericServiceRequest/GenericServiceRequestTable.d.ts.map +1 -1
- package/dist/{index-p-FSqamS.js → index-B0cIttpN.js} +19411 -20645
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -22
- package/dist/labinvestigation/utils.d.ts.map +1 -1
- package/dist/medications/MedicationsTable.d.ts.map +1 -1
- package/dist/observations/utils.d.ts +2 -2
- package/dist/observations/utils.d.ts.map +1 -1
- package/dist/patientDetails/PatientDetails.d.ts.map +1 -1
- package/dist/patientPrograms/PatientProgramsTable.d.ts.map +1 -1
- package/dist/programDetails/ProgramDetails.d.ts.map +1 -1
- package/dist/radiologyInvestigation/RadiologyInvestigationTable.d.ts.map +1 -1
- package/dist/radiologyInvestigationReport/RadiologyInvestigationReport.d.ts.map +1 -1
- package/dist/searchPatient/strategies/AppointmentSearchStrategy.d.ts.map +1 -1
- package/dist/searchPatient/strategies/AttributeSearchStrategy.d.ts.map +1 -1
- package/dist/searchPatient/strategies/NameOrIdSearchStrategy.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/DocumentsTable-DvVXzGC-.js +0 -5431
- package/dist/FormsTable-DQOHUr73.js +0 -426
- package/dist/Observations-CLvr4ZXL.js +0 -172
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { jsx as o, jsxs as l, Fragment as V } from "react/jsx-runtime";
|
|
2
|
+
import { u as $, a as H, o as P, F as z, x as Y, c as j, y as G } from "./index-B0cIttpN.js";
|
|
3
|
+
import { useQuery as K } from "@tanstack/react-query";
|
|
4
|
+
import { useState as C, useCallback as E, useEffect as S, useMemo as f } from "react";
|
|
5
|
+
import { useTranslation as Q } from "react-i18next";
|
|
6
|
+
const W = "_documentsTableBody_6qsah_1", J = "_viewAttachmentsLink_6qsah_11", X = "_documentViewerContainer_6qsah_15", Z = "_attachmentItem_6qsah_23", x = "_attachmentCounter_6qsah_27", ee = "_attachmentError_6qsah_36", te = "_documentIframe_6qsah_44", ne = "_documentImage_6qsah_50", c = {
|
|
7
|
+
documentsTableBody: W,
|
|
8
|
+
viewAttachmentsLink: J,
|
|
9
|
+
documentViewerContainer: X,
|
|
10
|
+
attachmentItem: Z,
|
|
11
|
+
attachmentCounter: x,
|
|
12
|
+
attachmentError: ee,
|
|
13
|
+
documentIframe: te,
|
|
14
|
+
documentImage: ne
|
|
15
|
+
}, ae = {
|
|
16
|
+
documentIdentifier: "DOCUMENTS_DOCUMENT_IDENTIFIER",
|
|
17
|
+
documentType: "DOCUMENTS_TYPE",
|
|
18
|
+
uploadedOn: "DOCUMENTS_UPLOADED_ON",
|
|
19
|
+
uploadedBy: "DOCUMENTS_UPLOADED_BY",
|
|
20
|
+
action: "DOCUMENTS_ACTION"
|
|
21
|
+
};
|
|
22
|
+
function U(t) {
|
|
23
|
+
return !t || t.includes(":") ? "#" : `/openmrs/auth?requested_document=/document_images/${t}`;
|
|
24
|
+
}
|
|
25
|
+
function se(t, u) {
|
|
26
|
+
return t.map((d) => ({
|
|
27
|
+
key: d,
|
|
28
|
+
header: u(ae[d])
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
const re = [
|
|
32
|
+
"documentIdentifier",
|
|
33
|
+
"documentType",
|
|
34
|
+
"uploadedOn",
|
|
35
|
+
"uploadedBy",
|
|
36
|
+
"action"
|
|
37
|
+
], w = (t) => t.attachments.length > 0 ? t.attachments : t.documentUrl ? [{ url: t.documentUrl, contentType: t.contentType }] : [], le = ({ config: t, encounterUuids: u }) => {
|
|
38
|
+
const [d, O] = C(!1), [a, y] = C(
|
|
39
|
+
null
|
|
40
|
+
), [b, T] = C(
|
|
41
|
+
/* @__PURE__ */ new Set()
|
|
42
|
+
), p = $(), { t: n } = Q(), { addNotification: g } = H(), L = E((e) => {
|
|
43
|
+
y(e), O(!0);
|
|
44
|
+
}, []), v = E(() => {
|
|
45
|
+
O(!1), y(null), T(/* @__PURE__ */ new Set());
|
|
46
|
+
}, []), M = E((e) => {
|
|
47
|
+
T((s) => new Set(s).add(e));
|
|
48
|
+
}, []), { data: B, isLoading: q, isError: I, error: A } = K({
|
|
49
|
+
queryKey: ["documents", p, u],
|
|
50
|
+
enabled: !!p,
|
|
51
|
+
queryFn: () => P(p, u)
|
|
52
|
+
});
|
|
53
|
+
S(() => {
|
|
54
|
+
I && g({
|
|
55
|
+
title: n("ERROR_DEFAULT_TITLE"),
|
|
56
|
+
message: A?.message ?? "",
|
|
57
|
+
type: "error"
|
|
58
|
+
});
|
|
59
|
+
}, [I, A, g, n]), S(() => {
|
|
60
|
+
const e = new AbortController();
|
|
61
|
+
return (async () => {
|
|
62
|
+
if (!d || !a) return;
|
|
63
|
+
const r = /* @__PURE__ */ new Set(), _ = w(a);
|
|
64
|
+
for (let m = 0; m < _.length; m++) {
|
|
65
|
+
const N = U(_[m].url);
|
|
66
|
+
try {
|
|
67
|
+
(await fetch(N, {
|
|
68
|
+
method: "HEAD",
|
|
69
|
+
signal: e.signal
|
|
70
|
+
})).ok || r.add(m);
|
|
71
|
+
} catch (D) {
|
|
72
|
+
D instanceof Error && D.name !== "AbortError" && r.add(m);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
e.signal.aborted || T(r);
|
|
76
|
+
})(), () => e.abort();
|
|
77
|
+
}, [d, a]);
|
|
78
|
+
const h = f(
|
|
79
|
+
() => t?.fields ?? re,
|
|
80
|
+
[t?.fields]
|
|
81
|
+
), F = f(() => se(h, n), [h, n]), R = f(
|
|
82
|
+
() => h.map((e) => ({
|
|
83
|
+
key: e,
|
|
84
|
+
sortable: e !== "action"
|
|
85
|
+
})),
|
|
86
|
+
[h]
|
|
87
|
+
), i = f(
|
|
88
|
+
() => a ? w(a) : [],
|
|
89
|
+
[a]
|
|
90
|
+
), k = E(
|
|
91
|
+
(e, s) => {
|
|
92
|
+
switch (s) {
|
|
93
|
+
case "documentIdentifier":
|
|
94
|
+
return /* @__PURE__ */ o("span", { children: e.documentIdentifier });
|
|
95
|
+
case "documentType":
|
|
96
|
+
return e.documentType ?? n("DOCUMENTS_NOT_AVAILABLE");
|
|
97
|
+
case "uploadedOn":
|
|
98
|
+
return Y(
|
|
99
|
+
e.uploadedOn,
|
|
100
|
+
n,
|
|
101
|
+
!0
|
|
102
|
+
).formattedResult || n("DOCUMENTS_NOT_AVAILABLE");
|
|
103
|
+
case "uploadedBy":
|
|
104
|
+
return e.uploadedBy ?? n("DOCUMENTS_NOT_AVAILABLE");
|
|
105
|
+
case "action":
|
|
106
|
+
return e.attachments.length > 0 || !!e.documentUrl ? /* @__PURE__ */ o(
|
|
107
|
+
z,
|
|
108
|
+
{
|
|
109
|
+
onClick: () => L(e),
|
|
110
|
+
className: c.viewAttachmentsLink,
|
|
111
|
+
"data-testid": `view-attachments-${e.id}`,
|
|
112
|
+
children: n("DOCUMENTS_VIEW_ATTACHMENTS")
|
|
113
|
+
}
|
|
114
|
+
) : "--";
|
|
115
|
+
default:
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
[L, n]
|
|
120
|
+
);
|
|
121
|
+
return /* @__PURE__ */ l(V, { children: [
|
|
122
|
+
/* @__PURE__ */ o("div", { "data-testid": "documents-table", children: /* @__PURE__ */ o(
|
|
123
|
+
j,
|
|
124
|
+
{
|
|
125
|
+
headers: F,
|
|
126
|
+
ariaLabel: n("DOCUMENTS_TABLE_HEADING"),
|
|
127
|
+
rows: B ?? [],
|
|
128
|
+
loading: q,
|
|
129
|
+
errorStateMessage: I ? A?.message : null,
|
|
130
|
+
sortable: R,
|
|
131
|
+
emptyStateMessage: n("DOCUMENTS_NO_RECORDS"),
|
|
132
|
+
renderCell: k,
|
|
133
|
+
className: c.documentsTableBody,
|
|
134
|
+
dataTestId: "documents-table"
|
|
135
|
+
}
|
|
136
|
+
) }),
|
|
137
|
+
d && a && /* @__PURE__ */ o(
|
|
138
|
+
G,
|
|
139
|
+
{
|
|
140
|
+
id: "modalIdForActionAreaLayout",
|
|
141
|
+
portalId: "main-display-area",
|
|
142
|
+
open: d,
|
|
143
|
+
onRequestClose: v,
|
|
144
|
+
modalHeading: a.documentIdentifier,
|
|
145
|
+
passiveModal: !0,
|
|
146
|
+
size: "lg",
|
|
147
|
+
testId: "document-view-modal",
|
|
148
|
+
children: /* @__PURE__ */ o("div", { className: c.documentViewerContainer, children: i.map((e, s) => {
|
|
149
|
+
const r = U(e.url), _ = e.contentType?.toLowerCase().includes("pdf"), m = e.contentType?.toLowerCase().includes("image"), N = b.has(s);
|
|
150
|
+
return r === "#" || N ? /* @__PURE__ */ l(
|
|
151
|
+
"div",
|
|
152
|
+
{
|
|
153
|
+
className: c.attachmentError,
|
|
154
|
+
"data-testid": `attachment-error-${s}`,
|
|
155
|
+
children: [
|
|
156
|
+
i.length > 1 && /* @__PURE__ */ l("p", { className: c.attachmentCounter, children: [
|
|
157
|
+
s + 1,
|
|
158
|
+
"/",
|
|
159
|
+
i.length
|
|
160
|
+
] }),
|
|
161
|
+
/* @__PURE__ */ o("p", { children: n("DOCUMENTS_ERROR_LOADING_ATTACHMENT") })
|
|
162
|
+
]
|
|
163
|
+
},
|
|
164
|
+
`${a.id}-${e.url}`
|
|
165
|
+
) : /* @__PURE__ */ l(
|
|
166
|
+
"div",
|
|
167
|
+
{
|
|
168
|
+
className: c.attachmentItem,
|
|
169
|
+
"data-testid": `attachment-item-${s}`,
|
|
170
|
+
children: [
|
|
171
|
+
i.length > 1 && /* @__PURE__ */ l("p", { className: c.attachmentCounter, children: [
|
|
172
|
+
s + 1,
|
|
173
|
+
"/",
|
|
174
|
+
i.length
|
|
175
|
+
] }),
|
|
176
|
+
m ? /* @__PURE__ */ o(
|
|
177
|
+
"img",
|
|
178
|
+
{
|
|
179
|
+
src: r,
|
|
180
|
+
alt: a.documentIdentifier,
|
|
181
|
+
className: c.documentImage,
|
|
182
|
+
onError: () => M(s)
|
|
183
|
+
}
|
|
184
|
+
) : /* @__PURE__ */ o(
|
|
185
|
+
"iframe",
|
|
186
|
+
{
|
|
187
|
+
src: _ ? `${r}#toolbar=0` : r,
|
|
188
|
+
className: c.documentIframe,
|
|
189
|
+
title: a.documentIdentifier,
|
|
190
|
+
onError: () => M(s)
|
|
191
|
+
}
|
|
192
|
+
)
|
|
193
|
+
]
|
|
194
|
+
},
|
|
195
|
+
`${a.id}-${e.url}`
|
|
196
|
+
);
|
|
197
|
+
}) })
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
] });
|
|
201
|
+
};
|
|
202
|
+
export {
|
|
203
|
+
le as default
|
|
204
|
+
};
|
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import { jsxs as b, jsx as o, Fragment as K } from "react/jsx-runtime";
|
|
2
|
+
import { f as j, b as R, J as ae, r as oe, d as se, e as ne, g as de, n as ie, u as le, U as ce, z as me, H as ue, B as pe, h as be, s as fe, x as _e, F as ye, c as H, i as he, W as $e, y as ge, D as Ne, R as P } from "./index-B0cIttpN.js";
|
|
3
|
+
import { useQueryClient as ve, useQuery as O } from "@tanstack/react-query";
|
|
4
|
+
import { useState as k, useMemo as g, useCallback as L } from "react";
|
|
5
|
+
import { useTranslation as V } from "react-i18next";
|
|
6
|
+
const Fe = "_formsTableBody_1pd36_1", Oe = "_customAccordianItem_1pd36_6", Le = "_formContent_1pd36_18", Re = "_formDetailsContainer_1pd36_25", Me = "_observation_1pd36_30", Ce = "_groupContainer_1pd36_39", De = "_rowContainer_1pd36_43", Te = "_groupLabel_1pd36_48", Ve = "_rowLabel_1pd36_58", we = "_rowValue_1pd36_67", Be = "_groupMembers_1pd36_75", Ie = "_memberRow_1pd36_81", Ee = "_memberLabel_1pd36_86", Ae = "_memberValue_1pd36_94", Ge = "_abnormalValue_1pd36_102", xe = "_commentSection_1pd36_110", Se = "_commentText_1pd36_116", Ue = "_nestedGroup_1pd36_125", qe = "_nestedGroupLabel_1pd36_132", He = "_nestedGroupMembers_1pd36_141", s = {
|
|
7
|
+
formsTableBody: Fe,
|
|
8
|
+
customAccordianItem: Oe,
|
|
9
|
+
formContent: Le,
|
|
10
|
+
formDetailsContainer: Re,
|
|
11
|
+
observation: Me,
|
|
12
|
+
groupContainer: Ce,
|
|
13
|
+
rowContainer: De,
|
|
14
|
+
groupLabel: Te,
|
|
15
|
+
rowLabel: Ve,
|
|
16
|
+
rowValue: we,
|
|
17
|
+
groupMembers: Be,
|
|
18
|
+
memberRow: Ie,
|
|
19
|
+
memberLabel: Ee,
|
|
20
|
+
memberValue: Ae,
|
|
21
|
+
abnormalValue: Ge,
|
|
22
|
+
commentSection: xe,
|
|
23
|
+
commentText: Se,
|
|
24
|
+
nestedGroup: Ue,
|
|
25
|
+
nestedGroupLabel: qe,
|
|
26
|
+
nestedGroupMembers: He
|
|
27
|
+
}, z = (e) => {
|
|
28
|
+
const r = ae(e);
|
|
29
|
+
return r === "Image" ? /* @__PURE__ */ o(
|
|
30
|
+
oe,
|
|
31
|
+
{
|
|
32
|
+
imageSrc: e,
|
|
33
|
+
alt: e,
|
|
34
|
+
id: `${e}-img`
|
|
35
|
+
}
|
|
36
|
+
) : r === "Video" ? /* @__PURE__ */ o(se, { id: `${e}-video`, videoSrc: e }) : r === "PDF" ? /* @__PURE__ */ o(ne, { id: `${e}-pdf`, src: e }) : e;
|
|
37
|
+
}, Q = (e) => {
|
|
38
|
+
const r = e.observationValue?.referenceRange?.low?.value, a = e.observationValue?.referenceRange?.high?.value, n = r != null, d = a != null;
|
|
39
|
+
let i = "";
|
|
40
|
+
n && d ? i = ` (${r} - ${a})` : n ? i = ` (>${r})` : d && (i = ` (<${a})`);
|
|
41
|
+
const u = e.observationValue?.isAbnormal === !0;
|
|
42
|
+
return { rangeString: i, isAbnormal: u };
|
|
43
|
+
}, W = ({
|
|
44
|
+
member: e,
|
|
45
|
+
depth: r = 0,
|
|
46
|
+
memberIndex: a = 0,
|
|
47
|
+
formName: n = "",
|
|
48
|
+
comment: d
|
|
49
|
+
}) => {
|
|
50
|
+
const { t: i } = V(), u = e.members && e.members.length > 0, t = e.display, c = n ? `${n}-` : "";
|
|
51
|
+
if (u)
|
|
52
|
+
return /* @__PURE__ */ b(
|
|
53
|
+
"div",
|
|
54
|
+
{
|
|
55
|
+
className: s.nestedGroup,
|
|
56
|
+
"data-testid": `${c}obs-nested-group-${t}-${a}`,
|
|
57
|
+
children: [
|
|
58
|
+
/* @__PURE__ */ o(
|
|
59
|
+
"div",
|
|
60
|
+
{
|
|
61
|
+
className: s.nestedGroupLabel,
|
|
62
|
+
"data-testid": `${c}obs-nested-group-label-${t}-${a}`,
|
|
63
|
+
style: { paddingLeft: `${r * 16}px` },
|
|
64
|
+
children: t
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
/* @__PURE__ */ o(
|
|
68
|
+
"div",
|
|
69
|
+
{
|
|
70
|
+
className: s.nestedGroupMembers,
|
|
71
|
+
"data-testid": `${c}obs-nested-group-members-${t}-${a}`,
|
|
72
|
+
children: e.members?.map((N, v) => /* @__PURE__ */ o(
|
|
73
|
+
W,
|
|
74
|
+
{
|
|
75
|
+
member: N,
|
|
76
|
+
depth: r + 1,
|
|
77
|
+
memberIndex: v,
|
|
78
|
+
formName: n
|
|
79
|
+
},
|
|
80
|
+
`${N.id}`
|
|
81
|
+
))
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
const { rangeString: $, isAbnormal: f } = Q(e), _ = j(e, i), y = _ ? z(_) : null;
|
|
88
|
+
return /* @__PURE__ */ b(K, { children: [
|
|
89
|
+
/* @__PURE__ */ b(
|
|
90
|
+
"div",
|
|
91
|
+
{
|
|
92
|
+
className: s.memberRow,
|
|
93
|
+
"data-testid": `${c}obs-member-row-${t}-${a}`,
|
|
94
|
+
style: { paddingLeft: `${r * 16}px` },
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ b(
|
|
97
|
+
"p",
|
|
98
|
+
{
|
|
99
|
+
className: R(
|
|
100
|
+
s.memberLabel,
|
|
101
|
+
f ? s.abnormalValue : ""
|
|
102
|
+
),
|
|
103
|
+
"data-testid": `${c}obs-member-label-${t}-${a}`,
|
|
104
|
+
children: [
|
|
105
|
+
t,
|
|
106
|
+
$
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
),
|
|
110
|
+
/* @__PURE__ */ o(
|
|
111
|
+
"div",
|
|
112
|
+
{
|
|
113
|
+
className: R(
|
|
114
|
+
s.memberValue,
|
|
115
|
+
f ? s.abnormalValue : ""
|
|
116
|
+
),
|
|
117
|
+
"data-testid": `${c}obs-member-value-${t}-${a}`,
|
|
118
|
+
children: y
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
),
|
|
124
|
+
d && /* @__PURE__ */ o(
|
|
125
|
+
"div",
|
|
126
|
+
{
|
|
127
|
+
className: s.commentSection,
|
|
128
|
+
"data-testid": `${c}obs-member-comment-${t}-${a}`,
|
|
129
|
+
style: { paddingLeft: `${r * 16}px` },
|
|
130
|
+
children: /* @__PURE__ */ b("span", { className: s.commentText, children: [
|
|
131
|
+
d,
|
|
132
|
+
e.encounter?.provider && ` - by ${e.encounter.provider}`
|
|
133
|
+
] })
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
] });
|
|
137
|
+
}, Pe = ({
|
|
138
|
+
observation: e,
|
|
139
|
+
index: r,
|
|
140
|
+
formName: a = "",
|
|
141
|
+
comment: n
|
|
142
|
+
}) => {
|
|
143
|
+
const { t: d } = V(), i = e.members && e.members.length > 0, { rangeString: u, isAbnormal: t } = Q(e), c = a ? `${a}-` : "", $ = j(e, d), f = $ ? z($) : null;
|
|
144
|
+
return /* @__PURE__ */ b(
|
|
145
|
+
"div",
|
|
146
|
+
{
|
|
147
|
+
className: s.observation,
|
|
148
|
+
"data-testid": `${c}observation-item-${e.display}-${r}`,
|
|
149
|
+
children: [
|
|
150
|
+
/* @__PURE__ */ b(
|
|
151
|
+
"div",
|
|
152
|
+
{
|
|
153
|
+
className: i ? s.groupContainer : s.rowContainer,
|
|
154
|
+
"data-testid": `${c}observation-container-${e.display}-${r}`,
|
|
155
|
+
children: [
|
|
156
|
+
/* @__PURE__ */ b(
|
|
157
|
+
"p",
|
|
158
|
+
{
|
|
159
|
+
className: R(
|
|
160
|
+
i ? s.groupLabel : s.rowLabel,
|
|
161
|
+
!i && t ? s.abnormalValue : ""
|
|
162
|
+
),
|
|
163
|
+
"data-testid": `${c}observation-label-${e.display}-${r}`,
|
|
164
|
+
children: [
|
|
165
|
+
e.display,
|
|
166
|
+
!i && u && /* @__PURE__ */ o("span", { className: s.rangeInfo, children: u })
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
),
|
|
170
|
+
i ? /* @__PURE__ */ o(
|
|
171
|
+
"div",
|
|
172
|
+
{
|
|
173
|
+
className: s.groupMembers,
|
|
174
|
+
"data-testid": `${c}observation-group-members-${e.display}-${r}`,
|
|
175
|
+
children: e.members?.map((_, y) => /* @__PURE__ */ o(
|
|
176
|
+
W,
|
|
177
|
+
{
|
|
178
|
+
member: _,
|
|
179
|
+
depth: 0,
|
|
180
|
+
memberIndex: y,
|
|
181
|
+
formName: a
|
|
182
|
+
},
|
|
183
|
+
`${_.id}`
|
|
184
|
+
))
|
|
185
|
+
}
|
|
186
|
+
) : /* @__PURE__ */ o(
|
|
187
|
+
"div",
|
|
188
|
+
{
|
|
189
|
+
className: R(
|
|
190
|
+
s.rowValue,
|
|
191
|
+
t ? s.abnormalValue : ""
|
|
192
|
+
),
|
|
193
|
+
"data-testid": `${c}observation-value-${e.display}-${r}`,
|
|
194
|
+
children: f
|
|
195
|
+
}
|
|
196
|
+
)
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
),
|
|
200
|
+
n && /* @__PURE__ */ o(
|
|
201
|
+
"div",
|
|
202
|
+
{
|
|
203
|
+
className: s.commentSection,
|
|
204
|
+
"data-testid": `${c}observation-comment-${e.display}-${r}`,
|
|
205
|
+
children: /* @__PURE__ */ b("span", { className: s.commentText, children: [
|
|
206
|
+
n,
|
|
207
|
+
e.encounter?.provider && ` - by ${e.encounter.provider}`
|
|
208
|
+
] })
|
|
209
|
+
}
|
|
210
|
+
)
|
|
211
|
+
]
|
|
212
|
+
},
|
|
213
|
+
`${e.id}-${r}`
|
|
214
|
+
);
|
|
215
|
+
}, ke = (e) => e ? e.extension?.find(
|
|
216
|
+
(a) => a.url === ie
|
|
217
|
+
)?.valueString : void 0, Ke = (e) => {
|
|
218
|
+
if (e)
|
|
219
|
+
return e.note?.[0]?.text;
|
|
220
|
+
}, je = (e, r) => e.entry?.find((a) => a.resource?.id === r)?.resource, T = (e, r) => {
|
|
221
|
+
const a = je(e, r);
|
|
222
|
+
return a ? {
|
|
223
|
+
formFieldPath: ke(a),
|
|
224
|
+
comment: Ke(a)
|
|
225
|
+
} : {};
|
|
226
|
+
}, ze = (e, r) => {
|
|
227
|
+
if (!e?.entry || !r)
|
|
228
|
+
return [];
|
|
229
|
+
const a = de(e);
|
|
230
|
+
return [
|
|
231
|
+
...a.observations.map((d) => {
|
|
232
|
+
const { formFieldPath: i, comment: u } = T(
|
|
233
|
+
e,
|
|
234
|
+
d.id
|
|
235
|
+
);
|
|
236
|
+
return { obs: d, formFieldPath: i, comment: u };
|
|
237
|
+
}),
|
|
238
|
+
...a.groupedObservations.flatMap((d) => {
|
|
239
|
+
const { formFieldPath: i } = T(e, d.id);
|
|
240
|
+
return (d.members ?? []).map((u) => {
|
|
241
|
+
const { comment: t } = T(e, u.id);
|
|
242
|
+
return { obs: u, formFieldPath: i, comment: t };
|
|
243
|
+
});
|
|
244
|
+
})
|
|
245
|
+
].filter(
|
|
246
|
+
({ formFieldPath: d }) => !d || d.includes(r)
|
|
247
|
+
);
|
|
248
|
+
}, Ze = ({
|
|
249
|
+
episodeOfCareUuids: e,
|
|
250
|
+
encounterUuids: r,
|
|
251
|
+
config: a
|
|
252
|
+
}) => {
|
|
253
|
+
const { t: n } = V(), d = le(), [i, u] = k(!1), [t, c] = k(null), $ = a?.numberOfVisits, f = ce(
|
|
254
|
+
e,
|
|
255
|
+
r
|
|
256
|
+
), _ = ve(), {
|
|
257
|
+
data: y = [],
|
|
258
|
+
isLoading: N,
|
|
259
|
+
isError: v,
|
|
260
|
+
error: J,
|
|
261
|
+
refetch: Y
|
|
262
|
+
} = O({
|
|
263
|
+
queryKey: ["forms", d, e],
|
|
264
|
+
queryFn: () => me(d, void 0, $),
|
|
265
|
+
enabled: !!d && !f
|
|
266
|
+
}), w = g(() => !r || r.length === 0 ? y : y.filter(
|
|
267
|
+
(l) => r.includes(l.encounterUuid)
|
|
268
|
+
), [y, r]), { data: B = [] } = O({
|
|
269
|
+
queryKey: ["observationForms"],
|
|
270
|
+
queryFn: () => ue()
|
|
271
|
+
}), I = L(
|
|
272
|
+
(l) => B.find((m) => m.name === l)?.uuid,
|
|
273
|
+
[B]
|
|
274
|
+
), M = g(() => {
|
|
275
|
+
if (t)
|
|
276
|
+
return I(t.formName);
|
|
277
|
+
}, [t, I]), { isLoading: X, error: E } = O({
|
|
278
|
+
queryKey: ["formMetadata", M],
|
|
279
|
+
queryFn: () => pe(M),
|
|
280
|
+
enabled: !!M && i
|
|
281
|
+
}), {
|
|
282
|
+
data: C,
|
|
283
|
+
isLoading: Z,
|
|
284
|
+
error: A
|
|
285
|
+
} = O({
|
|
286
|
+
queryKey: ["formsEncounterFHIR", t?.encounterUuid],
|
|
287
|
+
queryFn: () => be(t.encounterUuid),
|
|
288
|
+
enabled: !!t?.encounterUuid && i
|
|
289
|
+
});
|
|
290
|
+
fe(
|
|
291
|
+
(l) => {
|
|
292
|
+
l.patientUUID === d && l.updatedConcepts.size > 0 && (Y(), _.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
|
|
293
|
+
},
|
|
294
|
+
[d]
|
|
295
|
+
);
|
|
296
|
+
const G = g(() => !C || !t?.formName ? [] : ze(
|
|
297
|
+
C,
|
|
298
|
+
t.formName
|
|
299
|
+
), [C, t?.formName]), x = g(
|
|
300
|
+
() => [
|
|
301
|
+
{ key: "recordedOn", header: n("FORM_RECORDED_ON") },
|
|
302
|
+
{ key: "recordedBy", header: n("FORM_RECORDED_BY") }
|
|
303
|
+
],
|
|
304
|
+
[n]
|
|
305
|
+
), ee = g(
|
|
306
|
+
() => [
|
|
307
|
+
{ key: "recordedOn", sortable: !0 },
|
|
308
|
+
{ key: "recordedBy", sortable: !0 }
|
|
309
|
+
],
|
|
310
|
+
[]
|
|
311
|
+
), S = g(() => {
|
|
312
|
+
const l = w.reduce(
|
|
313
|
+
(m, p) => {
|
|
314
|
+
const F = p.formName;
|
|
315
|
+
m[F] ??= [];
|
|
316
|
+
const D = p.providers.map((te) => te.providerName).filter(Boolean).join(", ");
|
|
317
|
+
return m[F].push({
|
|
318
|
+
id: p.encounterUuid,
|
|
319
|
+
formName: p.formName,
|
|
320
|
+
recordedOn: _e(p.encounterDateTime, n, !0).formattedResult,
|
|
321
|
+
recordedBy: D ?? "--",
|
|
322
|
+
encounterDateTime: p.encounterDateTime,
|
|
323
|
+
encounterUuid: p.encounterUuid
|
|
324
|
+
}), m;
|
|
325
|
+
},
|
|
326
|
+
{}
|
|
327
|
+
);
|
|
328
|
+
return Object.entries(l).map(
|
|
329
|
+
([m, p]) => ({
|
|
330
|
+
formName: m,
|
|
331
|
+
records: p.sort(
|
|
332
|
+
(F, D) => D.encounterDateTime - F.encounterDateTime
|
|
333
|
+
)
|
|
334
|
+
})
|
|
335
|
+
).sort((m, p) => m.formName.localeCompare(p.formName));
|
|
336
|
+
}, [w, n]), U = L((l) => {
|
|
337
|
+
c(l), u(!0);
|
|
338
|
+
}, []), re = L(() => {
|
|
339
|
+
u(!1), c(null);
|
|
340
|
+
}, []), q = L(
|
|
341
|
+
(l, h) => {
|
|
342
|
+
switch (h) {
|
|
343
|
+
case "recordedOn":
|
|
344
|
+
return /* @__PURE__ */ o(ye, { onClick: () => U(l), children: l.recordedOn });
|
|
345
|
+
case "recordedBy":
|
|
346
|
+
return l.recordedBy;
|
|
347
|
+
default:
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
[U]
|
|
352
|
+
);
|
|
353
|
+
return /* @__PURE__ */ b(K, { children: [
|
|
354
|
+
/* @__PURE__ */ o("div", { "data-testid": "forms-table", children: N || v || S.length === 0 || f ? /* @__PURE__ */ o(
|
|
355
|
+
H,
|
|
356
|
+
{
|
|
357
|
+
headers: x,
|
|
358
|
+
ariaLabel: n("FORMS_HEADING"),
|
|
359
|
+
rows: [],
|
|
360
|
+
loading: N,
|
|
361
|
+
errorStateMessage: v ? J?.message : void 0,
|
|
362
|
+
emptyStateMessage: n("FORMS_UNAVAILABLE"),
|
|
363
|
+
renderCell: q,
|
|
364
|
+
className: s.formsTableBody,
|
|
365
|
+
dataTestId: "forms-table"
|
|
366
|
+
}
|
|
367
|
+
) : /* @__PURE__ */ o(he, { align: "start", children: S.map((l, h) => {
|
|
368
|
+
const { formName: m, records: p } = l;
|
|
369
|
+
return /* @__PURE__ */ o(
|
|
370
|
+
$e,
|
|
371
|
+
{
|
|
372
|
+
title: m,
|
|
373
|
+
className: s.customAccordianItem,
|
|
374
|
+
testId: `accordian-title-${m}`,
|
|
375
|
+
open: h === 0,
|
|
376
|
+
children: /* @__PURE__ */ o(
|
|
377
|
+
H,
|
|
378
|
+
{
|
|
379
|
+
headers: x,
|
|
380
|
+
ariaLabel: n("FORMS_HEADING"),
|
|
381
|
+
rows: p,
|
|
382
|
+
loading: !1,
|
|
383
|
+
errorStateMessage: "",
|
|
384
|
+
sortable: ee,
|
|
385
|
+
emptyStateMessage: n("FORMS_UNAVAILABLE"),
|
|
386
|
+
renderCell: q,
|
|
387
|
+
className: s.formsTableBody,
|
|
388
|
+
dataTestId: `forms-table-${m}`
|
|
389
|
+
}
|
|
390
|
+
)
|
|
391
|
+
},
|
|
392
|
+
m
|
|
393
|
+
);
|
|
394
|
+
}) }) }),
|
|
395
|
+
i && t && /* @__PURE__ */ o(
|
|
396
|
+
ge,
|
|
397
|
+
{
|
|
398
|
+
id: "modalIdForActionAreaLayout",
|
|
399
|
+
portalId: "main-display-area",
|
|
400
|
+
open: i,
|
|
401
|
+
onRequestClose: re,
|
|
402
|
+
modalHeading: t.formName,
|
|
403
|
+
modalLabel: `${t.recordedOn} | ${t.recordedBy}`,
|
|
404
|
+
passiveModal: !0,
|
|
405
|
+
size: "md",
|
|
406
|
+
testId: "form-details-modal",
|
|
407
|
+
children: /* @__PURE__ */ o("div", { className: s.formContent, children: X || Z ? /* @__PURE__ */ o(Ne, { width: "100%", lineCount: 3 }) : E ? /* @__PURE__ */ o("div", { children: P(E).message ?? n("ERROR_FETCHING_FORM_METADATA") }) : A ? /* @__PURE__ */ o("div", { children: P(A).message ?? n("ERROR_FETCHING_FORM_DATA") }) : G.length > 0 ? /* @__PURE__ */ o("div", { className: s.formDetailsContainer, children: G.map(({ obs: l, comment: h }, m) => /* @__PURE__ */ o(
|
|
408
|
+
Pe,
|
|
409
|
+
{
|
|
410
|
+
observation: l,
|
|
411
|
+
index: m,
|
|
412
|
+
formName: t.formName,
|
|
413
|
+
comment: h
|
|
414
|
+
},
|
|
415
|
+
`${l.id}`
|
|
416
|
+
)) }) : /* @__PURE__ */ o("div", { children: n("NO_FORM_DATA_AVAILABLE") }) })
|
|
417
|
+
}
|
|
418
|
+
)
|
|
419
|
+
] });
|
|
420
|
+
};
|
|
421
|
+
export {
|
|
422
|
+
Ze as default
|
|
423
|
+
};
|