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