@bahmni/clinical-app 0.0.1-dev.150 → 0.0.1-dev.151

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { aH as i } from "./index-Hbs3D7h0.js";
1
+ import { at as i } from "./index-D9U_fT9q.js";
2
2
  export {
3
3
  i as ClinicalApp
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bahmni/clinical-app",
3
- "version": "0.0.1-dev.150",
3
+ "version": "0.0.1-dev.151",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -1,361 +0,0 @@
1
- import { jsxs as A, jsx as m } from "react/jsx-runtime";
2
- import { S as U, n as w, r as P, Q as q, e as V, f as K, h as j, j as z, k as G, l as X, m as J, s as _, o as C, p as W, t as Y, H as Z, v as ee, u as k, P as se, a as te, K as re, X as ie, x as ne, y as oe, A as ae, z as ue, B, J as le, D as ce, O as he, E as de, M as be, I as pe } from "./index-Hbs3D7h0.js";
3
- import * as E from "react";
4
- import { useRef as fe, useEffect as I, useMemo as T } from "react";
5
- function $(e, s) {
6
- const t = new Set(s);
7
- return e.filter((i) => !t.has(i));
8
- }
9
- function ye(e, s, t) {
10
- const i = e.slice(0);
11
- return i[s] = t, i;
12
- }
13
- var me = class extends U {
14
- #r;
15
- #e;
16
- #i;
17
- #n;
18
- #s;
19
- #t;
20
- #o;
21
- #a;
22
- #u = [];
23
- constructor(e, s, t) {
24
- super(), this.#r = e, this.#n = t, this.#i = [], this.#s = [], this.#e = [], this.setQueries(s);
25
- }
26
- onSubscribe() {
27
- this.listeners.size === 1 && this.#s.forEach((e) => {
28
- e.subscribe((s) => {
29
- this.#d(e, s);
30
- });
31
- });
32
- }
33
- onUnsubscribe() {
34
- this.listeners.size || this.destroy();
35
- }
36
- destroy() {
37
- this.listeners = /* @__PURE__ */ new Set(), this.#s.forEach((e) => {
38
- e.destroy();
39
- });
40
- }
41
- setQueries(e, s) {
42
- if (this.#i = e, this.#n = s, process.env.NODE_ENV !== "production") {
43
- const t = e.map(
44
- (i) => this.#r.defaultQueryOptions(i).queryHash
45
- );
46
- new Set(t).size !== t.length && console.warn(
47
- "[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior."
48
- );
49
- }
50
- w.batch(() => {
51
- const t = this.#s, i = this.#h(this.#i);
52
- this.#u = i, i.forEach(
53
- (n) => n.observer.setOptions(n.defaultedQueryOptions)
54
- );
55
- const r = i.map((n) => n.observer), o = r.map(
56
- (n) => n.getCurrentResult()
57
- ), a = r.some(
58
- (n, u) => n !== t[u]
59
- );
60
- t.length === r.length && !a || (this.#s = r, this.#e = o, this.hasListeners() && ($(t, r).forEach((n) => {
61
- n.destroy();
62
- }), $(r, t).forEach((n) => {
63
- n.subscribe((u) => {
64
- this.#d(n, u);
65
- });
66
- }), this.#b()));
67
- });
68
- }
69
- getCurrentResult() {
70
- return this.#e;
71
- }
72
- getQueries() {
73
- return this.#s.map((e) => e.getCurrentQuery());
74
- }
75
- getObservers() {
76
- return this.#s;
77
- }
78
- getOptimisticResult(e, s) {
79
- const t = this.#h(e), i = t.map(
80
- (r) => r.observer.getOptimisticResult(r.defaultedQueryOptions)
81
- );
82
- return [
83
- i,
84
- (r) => this.#c(r ?? i, s),
85
- () => this.#l(i, t)
86
- ];
87
- }
88
- #l(e, s) {
89
- return s.map((t, i) => {
90
- const r = e[i];
91
- return t.defaultedQueryOptions.notifyOnChangeProps ? r : t.observer.trackResult(r, (o) => {
92
- s.forEach((a) => {
93
- a.observer.trackProp(o);
94
- });
95
- });
96
- });
97
- }
98
- #c(e, s) {
99
- return s ? ((!this.#t || this.#e !== this.#a || s !== this.#o) && (this.#o = s, this.#a = this.#e, this.#t = P(
100
- this.#t,
101
- s(e)
102
- )), this.#t) : e;
103
- }
104
- #h(e) {
105
- const s = new Map(
106
- this.#s.map((i) => [i.options.queryHash, i])
107
- ), t = [];
108
- return e.forEach((i) => {
109
- const r = this.#r.defaultQueryOptions(i), o = s.get(r.queryHash);
110
- o ? t.push({
111
- defaultedQueryOptions: r,
112
- observer: o
113
- }) : t.push({
114
- defaultedQueryOptions: r,
115
- observer: new q(this.#r, r)
116
- });
117
- }), t;
118
- }
119
- #d(e, s) {
120
- const t = this.#s.indexOf(e);
121
- t !== -1 && (this.#e = ye(this.#e, t, s), this.#b());
122
- }
123
- #b() {
124
- if (this.hasListeners()) {
125
- const e = this.#t, s = this.#l(this.#e, this.#u), t = this.#c(s, this.#n?.combine);
126
- e !== t && w.batch(() => {
127
- this.listeners.forEach((i) => {
128
- i(this.#e);
129
- });
130
- });
131
- }
132
- }
133
- };
134
- function ve({
135
- queries: e,
136
- ...s
137
- }, t) {
138
- const i = V(t), r = K(), o = j(), a = E.useMemo(
139
- () => e.map((l) => {
140
- const f = i.defaultQueryOptions(
141
- l
142
- );
143
- return f._optimisticResults = r ? "isRestoring" : "optimistic", f;
144
- }),
145
- [e, i, r]
146
- );
147
- a.forEach((l) => {
148
- z(l), G(l, o);
149
- }), X(o);
150
- const [n] = E.useState(
151
- () => new me(
152
- i,
153
- a,
154
- s
155
- )
156
- ), [u, d, y] = n.getOptimisticResult(
157
- a,
158
- s.combine
159
- ), b = !r && s.subscribed !== !1;
160
- E.useSyncExternalStore(
161
- E.useCallback(
162
- (l) => b ? n.subscribe(w.batchCalls(l)) : J,
163
- [n, b]
164
- ),
165
- () => n.getCurrentResult(),
166
- () => n.getCurrentResult()
167
- ), E.useEffect(() => {
168
- n.setQueries(
169
- a,
170
- s
171
- );
172
- }, [a, s, n]);
173
- const S = u.some(
174
- (l, f) => _(a[f], l)
175
- ) ? u.flatMap((l, f) => {
176
- const h = a[f];
177
- if (h) {
178
- const R = new q(i, h);
179
- if (_(h, l))
180
- return C(h, R, o);
181
- W(l, r) && C(h, R, o);
182
- }
183
- return [];
184
- }) : [];
185
- if (S.length > 0)
186
- throw Promise.all(S);
187
- const v = u.find(
188
- (l, f) => {
189
- const h = a[f];
190
- return h && Y({
191
- result: l,
192
- errorResetBoundary: o,
193
- throwOnError: h.throwOnError,
194
- query: i.getQueryCache().get(h.queryHash),
195
- suspense: h.suspense
196
- });
197
- }
198
- );
199
- if (v?.error)
200
- throw v.error;
201
- return d(y());
202
- }
203
- const D = (e, s, t, i, r) => {
204
- const o = le(e, s), a = o.value, n = ce(a);
205
- let u = a;
206
- n === "Image" && (u = /* @__PURE__ */ m(de, { imageSrc: a, alt: a, id: `${a}-img` })), n === "Video" && (u = /* @__PURE__ */ m(be, { id: `${a}-video`, videoSrc: a }));
207
- const d = r("OBSERVATIONS_RECORDED_BY", {
208
- provider: o.provider
209
- }), y = e.display, b = e.observationValue?.isAbnormal ? "abnormal-obs" : "obs", p = i ? `${i}-${b}-${y}-${t}-${s}` : `${b}-${y}-${t}-${s}`;
210
- return /* @__PURE__ */ m(
211
- he,
212
- {
213
- header: o.header,
214
- value: u,
215
- info: d,
216
- id: p,
217
- testId: p,
218
- ariaLabel: p
219
- },
220
- `obs-${e.id}`
221
- );
222
- }, Oe = (e, s, t, i, r, o) => /* @__PURE__ */ m(
223
- B,
224
- {
225
- title: e.display,
226
- id: `grouped-obs-${e.display}-${i}`,
227
- open: t,
228
- children: e.members?.map(
229
- (a, n) => D(a, n, r, o, s)
230
- )
231
- },
232
- `grouped-obs-${e.id}`
233
- ), Re = ({
234
- groupedData: e,
235
- title: s = ""
236
- }) => {
237
- const { t } = k(), i = (r, o, a) => {
238
- const n = ue(r.encounterDetails, t);
239
- return /* @__PURE__ */ A(
240
- B,
241
- {
242
- title: n,
243
- id: `encounter-${r.encounterId}`,
244
- open: o,
245
- children: [
246
- r.observations.map(
247
- (u, d) => D(u, d, a, s, t)
248
- ),
249
- r.groupedObservations.map(
250
- (u, d) => Oe(
251
- u,
252
- t,
253
- o,
254
- d,
255
- a,
256
- s
257
- )
258
- )
259
- ]
260
- },
261
- `encounter-${r.encounterId}`
262
- );
263
- };
264
- return /* @__PURE__ */ m(
265
- "div",
266
- {
267
- id: "obs-by-encounter",
268
- "data-testid": "obs-by-encounter-test-id",
269
- "aria-label": "obs-by-encounter-aria-label",
270
- children: e.map(
271
- (r, o) => i(r, o === 0, o)
272
- )
273
- }
274
- );
275
- }, ge = "_observations_kfbhq_1", Ee = "_title_kfbhq_12", N = {
276
- observations: ge,
277
- title: Ee
278
- }, Se = (e) => ["conceptUuid", e], Qe = (e, s) => ["observations", e, ...s], Ce = ({ config: e }) => {
279
- const s = e, { conceptNames: t = [], conceptUuid: i = [] } = s, r = fe(/* @__PURE__ */ new Set()), o = Z(), { addNotification: a } = ee(), { t: n } = k(), u = ve({
280
- queries: t.map((c) => ({
281
- queryKey: Se(c),
282
- queryFn: () => se(c),
283
- enabled: !!c
284
- }))
285
- });
286
- I(() => {
287
- u.forEach((c, O) => {
288
- if (c.isError && !r.current.has(O)) {
289
- const F = t[O];
290
- a({
291
- title: n("ERROR_DEFAULT_TITLE"),
292
- message: n("ERROR_FETCHING_CONCEPT", { conceptName: F }),
293
- type: "error"
294
- }), r.current.add(O);
295
- } else c.isError || r.current.delete(O);
296
- });
297
- }, [u, t]);
298
- const d = T(() => u.map((c) => c.data?.uuid).filter((c) => !!c), [u]), y = T(() => [.../* @__PURE__ */ new Set([...d, ...i])], [d, i]), b = T(() => t.length === 0 ? !0 : u.every((c) => !c.isLoading), [u, t.length]), {
299
- data: p,
300
- isLoading: S,
301
- isError: v
302
- } = te({
303
- queryKey: Qe(o, y),
304
- queryFn: () => pe(o, y),
305
- enabled: !!o && y.length > 0 && b
306
- });
307
- I(() => {
308
- v && a({
309
- title: n("ERROR_DEFAULT_TITLE"),
310
- message: n("ERROR_FETCHING_OBSERVATIONS"),
311
- type: "error"
312
- });
313
- }, [v]);
314
- const l = T(() => {
315
- if (!p) return [];
316
- const c = re(p), O = ie(c);
317
- return ne(O);
318
- }, [p]), f = [
319
- { key: "name", header: "name" },
320
- { key: "value", header: "value" },
321
- { key: "form", header: "form" }
322
- ], h = S || !b, R = v && b, L = (!p || p.entry?.length === 0 || y.length === 0) && b, M = R ? n("ERROR_FETCHING_OBSERVATIONS") : null, H = L ? n("NO_OBSERVATIONS_FOUND") : void 0, x = l.length > 0 && !h && !R, Q = s.titleTranslationKey, g = Q ? n(Q) : "";
323
- return /* @__PURE__ */ A(
324
- "div",
325
- {
326
- id: "observations",
327
- "data-testid": Q ? `observations-${g}` : "observations",
328
- "aria-label": "observations-aria-label",
329
- className: N.observations,
330
- children: [
331
- /* @__PURE__ */ m(
332
- oe,
333
- {
334
- id: "observations-title",
335
- testId: Q ? `observations-title-${g}` : "observations-title",
336
- title: g,
337
- className: N.title,
338
- children: /* @__PURE__ */ m("p", { children: g })
339
- }
340
- ),
341
- x ? /* @__PURE__ */ m(Re, { groupedData: l, title: g }) : /* @__PURE__ */ m(
342
- ae,
343
- {
344
- headers: f,
345
- rows: [],
346
- ariaLabel: n("OBSERVATIONS"),
347
- loading: h,
348
- errorStateMessage: M,
349
- emptyStateMessage: H,
350
- dataTestId: "observations-table"
351
- }
352
- )
353
- ]
354
- }
355
- );
356
- };
357
- export {
358
- Se as conceptUuidQueryKeys,
359
- Ce as default,
360
- Qe as observationsQueryKeys
361
- };