@bahmni/widgets 0.0.1-dev.212 → 0.0.1-dev.215

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