@bahmni/registration-app 0.0.1-dev.210 → 0.0.1-dev.214

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.
@@ -0,0 +1,213 @@
1
+ import { jsxs as S, jsx as u } from "react/jsx-runtime";
2
+ import { c as w, e as V, u as N, p as x, q as K, w as Q, s as j, v as G, r as H, y as M, x as z, t as P, I as q, z as Y, o as Z, A as J, i as W, j as X, m as ee } from "./index-D8JUClPX.js";
3
+ import { useQueries as te, useQuery as ae } from "@tanstack/react-query";
4
+ import { useRef as se, useEffect as $, useMemo as R } from "react";
5
+ const A = (t, n, d, l, b, r) => {
6
+ const a = Y(t, n, b), s = a.value, i = Z(s);
7
+ let o = s;
8
+ i === "Image" && (o = /* @__PURE__ */ u(
9
+ W,
10
+ {
11
+ imageSrc: s,
12
+ alt: s,
13
+ id: `${s}-img`,
14
+ hideThumbnail: r
15
+ }
16
+ )), i === "Video" && (o = /* @__PURE__ */ u(
17
+ X,
18
+ {
19
+ id: `${s}-video`,
20
+ videoSrc: s,
21
+ hideThumbnail: r
22
+ }
23
+ )), i === "PDF" && (o = /* @__PURE__ */ u(ee, { id: `${s}-pdf`, src: s }));
24
+ const p = b("OBSERVATIONS_RECORDED_BY", {
25
+ provider: a.provider
26
+ }), m = t.display, v = t.observationValue?.isAbnormal ? "abnormal-obs" : "obs", c = l ? `${l}-${v}-${m}-${d}-${n}` : `${v}-${m}-${d}-${n}`;
27
+ return /* @__PURE__ */ u(
28
+ J,
29
+ {
30
+ header: a.header,
31
+ value: o,
32
+ info: p,
33
+ id: c,
34
+ testId: c,
35
+ ariaLabel: c
36
+ },
37
+ `obs-${t.id}`
38
+ );
39
+ }, re = (t, n, d, l, b, r, a) => /* @__PURE__ */ u(
40
+ q,
41
+ {
42
+ title: t.display,
43
+ id: `grouped-obs-${t.display}-${l}`,
44
+ open: d,
45
+ children: t.members?.map(
46
+ (s, i) => A(
47
+ s,
48
+ i,
49
+ b,
50
+ r,
51
+ n,
52
+ a
53
+ )
54
+ )
55
+ },
56
+ `grouped-obs-${t.id}`
57
+ ), ie = ({
58
+ groupedData: t,
59
+ title: n = "",
60
+ hideThumbnail: d
61
+ }) => {
62
+ const { t: l } = N(), b = (r, a, s) => {
63
+ const i = P(r.encounterDetails, l);
64
+ return /* @__PURE__ */ S(
65
+ q,
66
+ {
67
+ title: i,
68
+ id: `encounter-${r.encounterId}`,
69
+ open: a,
70
+ children: [
71
+ r.observations.map(
72
+ (o, p) => A(
73
+ o,
74
+ p,
75
+ s,
76
+ n,
77
+ l,
78
+ d
79
+ )
80
+ ),
81
+ r.groupedObservations.map(
82
+ (o, p) => re(
83
+ o,
84
+ l,
85
+ a,
86
+ p,
87
+ s,
88
+ n,
89
+ d
90
+ )
91
+ )
92
+ ]
93
+ },
94
+ `encounter-${r.encounterId}`
95
+ );
96
+ };
97
+ return /* @__PURE__ */ u(
98
+ "div",
99
+ {
100
+ id: "obs-by-encounter",
101
+ "data-testid": "obs-by-encounter-test-id",
102
+ "aria-label": "obs-by-encounter-aria-label",
103
+ children: t.map(
104
+ (r, a) => b(r, a === 0, a)
105
+ )
106
+ }
107
+ );
108
+ }, oe = "_observations_kfbhq_1", ne = "_title_kfbhq_12", I = {
109
+ observations: oe,
110
+ title: ne
111
+ }, de = (t) => ["conceptUuid", t], le = (t, n) => ["observations", t, ...n], me = ({ config: t }) => {
112
+ const n = t, {
113
+ conceptNames: d = [],
114
+ conceptUuid: l = [],
115
+ hideThumbnail: b = !1
116
+ } = n, r = se(/* @__PURE__ */ new Set()), a = w(), { addNotification: s } = V(), { t: i } = N(), o = te({
117
+ queries: d.map((e) => ({
118
+ queryKey: de(e),
119
+ queryFn: () => x(e),
120
+ enabled: !!e
121
+ }))
122
+ });
123
+ $(() => {
124
+ o.forEach((e, h) => {
125
+ if (e.isError && !r.current.has(h)) {
126
+ const k = d[h];
127
+ s({
128
+ title: i("ERROR_DEFAULT_TITLE"),
129
+ message: i("ERROR_FETCHING_CONCEPT", { conceptName: k }),
130
+ type: "error"
131
+ }), r.current.add(h);
132
+ } else e.isError || r.current.delete(h);
133
+ });
134
+ }, [o, d]);
135
+ const p = R(() => o.map((e) => e.data?.uuid).filter((e) => !!e), [o]), m = R(() => [.../* @__PURE__ */ new Set([...p, ...l])], [p, l]), v = R(() => d.length === 0 ? !0 : o.every((e) => !e.isLoading), [o, d.length]), {
136
+ data: c,
137
+ isLoading: D,
138
+ isError: T,
139
+ refetch: f
140
+ } = ae({
141
+ queryKey: le(a, m),
142
+ queryFn: () => K(a, m),
143
+ enabled: !!a && m.length > 0 && v
144
+ });
145
+ Q(
146
+ (e) => {
147
+ e.patientUUID === a && e.updatedConcepts.size > 0 && [...e.updatedConcepts.keys()].some(
148
+ (h) => m.includes(h)
149
+ ) && f();
150
+ },
151
+ [a, f]
152
+ ), $(() => {
153
+ T && s({
154
+ title: i("ERROR_DEFAULT_TITLE"),
155
+ message: i("ERROR_FETCHING_OBSERVATIONS"),
156
+ type: "error"
157
+ });
158
+ }, [T]);
159
+ const g = R(() => {
160
+ if (!c) return [];
161
+ const e = j(c), h = G(e);
162
+ return H(h);
163
+ }, [c]), F = [
164
+ { key: "name", header: "name" },
165
+ { key: "value", header: "value" },
166
+ { key: "form", header: "form" }
167
+ ], O = D || !v, _ = T && v, L = (!c || c.entry?.length === 0 || m.length === 0) && v, B = _ ? i("ERROR_FETCHING_OBSERVATIONS") : null, C = L ? i("NO_OBSERVATIONS_FOUND") : void 0, U = g.length > 0 && !O && !_, E = n.titleTranslationKey, y = E ? i(E) : "";
168
+ return /* @__PURE__ */ S(
169
+ "div",
170
+ {
171
+ id: "observations",
172
+ "data-testid": E ? `observations-${y}` : "observations",
173
+ "aria-label": "observations-aria-label",
174
+ className: I.observations,
175
+ children: [
176
+ /* @__PURE__ */ u(
177
+ M,
178
+ {
179
+ id: "observations-title",
180
+ testId: E ? `observations-title-${y}` : "observations-title",
181
+ title: y,
182
+ className: I.title,
183
+ children: /* @__PURE__ */ u("p", { children: y })
184
+ }
185
+ ),
186
+ U ? /* @__PURE__ */ u(
187
+ ie,
188
+ {
189
+ groupedData: g,
190
+ title: y,
191
+ hideThumbnail: b
192
+ }
193
+ ) : /* @__PURE__ */ u(
194
+ z,
195
+ {
196
+ headers: F,
197
+ rows: [],
198
+ ariaLabel: i("OBSERVATIONS"),
199
+ loading: O,
200
+ errorStateMessage: B,
201
+ emptyStateMessage: C,
202
+ dataTestId: "observations-table"
203
+ }
204
+ )
205
+ ]
206
+ }
207
+ );
208
+ };
209
+ export {
210
+ de as conceptUuidQueryKeys,
211
+ me as default,
212
+ le as observationsQueryKeys
213
+ };