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