@bahmni/clinical-app 0.0.1-dev.118 → 0.0.1-dev.119

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,5 +1,5 @@
1
1
  import { jsx as o, jsxs as p, Fragment as Y } from "react/jsx-runtime";
2
- import { u as J, O as W, K as X, a as f, _ as Z, T as ee, e as $, b as re, c as ae, D as oe, C as ne, w as I, q as te, L as N, S as se, d as de, R as me, f as ie } from "./index-d8oOVCXW.js";
2
+ import { u as J, O as W, K as X, a as f, _ as Z, T as ee, e as $, b as re, c as ae, D as oe, C as ne, w as I, q as te, L as N, S as se, d as de, R as me, f as ie } from "./index-aCQK8yvY.js";
3
3
  import { useState as x, useMemo as b, useCallback as g } from "react";
4
4
  import { createPortal as le } from "react-dom";
5
5
  const ce = "_formsTableBody_1pd36_1", ue = "_customAccordianItem_1pd36_6", pe = "_formContent_1pd36_18", _e = "_formDetailsContainer_1pd36_25", be = "_observation_1pd36_30", fe = "_groupContainer_1pd36_39", ge = "_rowContainer_1pd36_43", Ne = "_groupLabel_1pd36_48", he = "_rowLabel_1pd36_58", ye = "_rowValue_1pd36_67", ve = "_groupMembers_1pd36_75", Le = "_memberRow_1pd36_81", Me = "_memberLabel_1pd36_86", Ae = "_memberValue_1pd36_94", Oe = "_abnormalValue_1pd36_102", Ce = "_commentSection_1pd36_110", Re = "_commentText_1pd36_116", Te = "_nestedGroup_1pd36_125", De = "_nestedGroupLabel_1pd36_132", Fe = "_nestedGroupMembers_1pd36_141", r = {
@@ -1,5 +1,5 @@
1
- import { c, T as l, P as m, a as u, D as v, Q as i } from "./YPM2AS64-BApeGioG.js";
2
- import { H as d, I as f, J as e } from "./index-d8oOVCXW.js";
1
+ import { c, T as l, P as m, a as u, D as v, Q as i } from "./YPM2AS64-BwafKS9M.js";
2
+ import { H as d, I as f, J as e } from "./index-aCQK8yvY.js";
3
3
  var p = (a) => {
4
4
  const [r, t] = c({
5
5
  prefix: "TanstackQueryDevtools"
@@ -1,5 +1,5 @@
1
- import { c as s, T as c, P as u, a as i, b as m, C as P, Q as d } from "./YPM2AS64-BApeGioG.js";
2
- import { H as v, I as C, J as e } from "./index-d8oOVCXW.js";
1
+ import { c as s, T as c, P as u, a as i, b as m, C as P, Q as d } from "./YPM2AS64-BwafKS9M.js";
2
+ import { H as v, I as C, J as e } from "./index-aCQK8yvY.js";
3
3
  var h = (t) => {
4
4
  const [r, o] = s({
5
5
  prefix: "TanstackQueryDevtools"
@@ -0,0 +1,527 @@
1
+ import { jsxs as I, jsx as b } from "react/jsx-runtime";
2
+ import { g as F, n as w, r as H, Q as D, h as U, i as P, j as K, k as z, l as W, m as j, o as J, s as T, p as Q, t as X, v as Y, O as Z, x as ee, u as N, y as te, a as se, W as re, e as ne, z as ie, A as M, B as oe, V as ae, E as ue, F as le, G as ce } from "./index-aCQK8yvY.js";
3
+ import * as R from "react";
4
+ import { useRef as de, useEffect as C, useMemo as S } from "react";
5
+ function _(e, s) {
6
+ const t = new Set(s);
7
+ return e.filter((r) => !t.has(r));
8
+ }
9
+ function he(e, s, t) {
10
+ const r = e.slice(0);
11
+ return r[s] = t, r;
12
+ }
13
+ var pe = class extends F {
14
+ #r;
15
+ #e;
16
+ #n;
17
+ #i;
18
+ #t;
19
+ #s;
20
+ #o;
21
+ #a;
22
+ #u = [];
23
+ constructor(e, s, t) {
24
+ super(), this.#r = e, this.#i = t, this.#n = [], this.#t = [], this.#e = [], this.setQueries(s);
25
+ }
26
+ onSubscribe() {
27
+ this.listeners.size === 1 && this.#t.forEach((e) => {
28
+ e.subscribe((s) => {
29
+ this.#h(e, s);
30
+ });
31
+ });
32
+ }
33
+ onUnsubscribe() {
34
+ this.listeners.size || this.destroy();
35
+ }
36
+ destroy() {
37
+ this.listeners = /* @__PURE__ */ new Set(), this.#t.forEach((e) => {
38
+ e.destroy();
39
+ });
40
+ }
41
+ setQueries(e, s) {
42
+ if (this.#n = e, this.#i = s, process.env.NODE_ENV !== "production") {
43
+ const t = e.map(
44
+ (r) => this.#r.defaultQueryOptions(r).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.#t, r = this.#d(this.#n);
52
+ this.#u = r, r.forEach(
53
+ (o) => o.observer.setOptions(o.defaultedQueryOptions)
54
+ );
55
+ const n = r.map((o) => o.observer), i = n.map(
56
+ (o) => o.getCurrentResult()
57
+ ), a = n.some(
58
+ (o, u) => o !== t[u]
59
+ );
60
+ t.length === n.length && !a || (this.#t = n, this.#e = i, this.hasListeners() && (_(t, n).forEach((o) => {
61
+ o.destroy();
62
+ }), _(n, t).forEach((o) => {
63
+ o.subscribe((u) => {
64
+ this.#h(o, u);
65
+ });
66
+ }), this.#p()));
67
+ });
68
+ }
69
+ getCurrentResult() {
70
+ return this.#e;
71
+ }
72
+ getQueries() {
73
+ return this.#t.map((e) => e.getCurrentQuery());
74
+ }
75
+ getObservers() {
76
+ return this.#t;
77
+ }
78
+ getOptimisticResult(e, s) {
79
+ const t = this.#d(e), r = t.map(
80
+ (n) => n.observer.getOptimisticResult(n.defaultedQueryOptions)
81
+ );
82
+ return [
83
+ r,
84
+ (n) => this.#c(n ?? r, s),
85
+ () => this.#l(r, t)
86
+ ];
87
+ }
88
+ #l(e, s) {
89
+ return s.map((t, r) => {
90
+ const n = e[r];
91
+ return t.defaultedQueryOptions.notifyOnChangeProps ? n : t.observer.trackResult(n, (i) => {
92
+ s.forEach((a) => {
93
+ a.observer.trackProp(i);
94
+ });
95
+ });
96
+ });
97
+ }
98
+ #c(e, s) {
99
+ return s ? ((!this.#s || this.#e !== this.#a || s !== this.#o) && (this.#o = s, this.#a = this.#e, this.#s = H(
100
+ this.#s,
101
+ s(e)
102
+ )), this.#s) : e;
103
+ }
104
+ #d(e) {
105
+ const s = new Map(
106
+ this.#t.map((r) => [r.options.queryHash, r])
107
+ ), t = [];
108
+ return e.forEach((r) => {
109
+ const n = this.#r.defaultQueryOptions(r), i = s.get(n.queryHash);
110
+ i ? t.push({
111
+ defaultedQueryOptions: n,
112
+ observer: i
113
+ }) : t.push({
114
+ defaultedQueryOptions: n,
115
+ observer: new D(this.#r, n)
116
+ });
117
+ }), t;
118
+ }
119
+ #h(e, s) {
120
+ const t = this.#t.indexOf(e);
121
+ t !== -1 && (this.#e = he(this.#e, t, s), this.#p());
122
+ }
123
+ #p() {
124
+ if (this.hasListeners()) {
125
+ const e = this.#s, s = this.#l(this.#e, this.#u), t = this.#c(s, this.#i?.combine);
126
+ e !== t && w.batch(() => {
127
+ this.listeners.forEach((r) => {
128
+ r(this.#e);
129
+ });
130
+ });
131
+ }
132
+ }
133
+ };
134
+ function ve({
135
+ queries: e,
136
+ ...s
137
+ }, t) {
138
+ const r = U(t), n = P(), i = K(), a = R.useMemo(
139
+ () => e.map((l) => {
140
+ const v = r.defaultQueryOptions(
141
+ l
142
+ );
143
+ return v._optimisticResults = n ? "isRestoring" : "optimistic", v;
144
+ }),
145
+ [e, r, n]
146
+ );
147
+ a.forEach((l) => {
148
+ z(l), W(l, i);
149
+ }), j(i);
150
+ const [o] = R.useState(
151
+ () => new pe(
152
+ r,
153
+ a,
154
+ s
155
+ )
156
+ ), [u, c, f] = o.getOptimisticResult(
157
+ a,
158
+ s.combine
159
+ ), p = !n && s.subscribed !== !1;
160
+ R.useSyncExternalStore(
161
+ R.useCallback(
162
+ (l) => p ? o.subscribe(w.batchCalls(l)) : J,
163
+ [o, p]
164
+ ),
165
+ () => o.getCurrentResult(),
166
+ () => o.getCurrentResult()
167
+ ), R.useEffect(() => {
168
+ o.setQueries(
169
+ a,
170
+ s
171
+ );
172
+ }, [a, s, o]);
173
+ const E = u.some(
174
+ (l, v) => T(a[v], l)
175
+ ) ? u.flatMap((l, v) => {
176
+ const h = a[v];
177
+ if (h) {
178
+ const O = new D(r, h);
179
+ if (T(h, l))
180
+ return Q(h, O, i);
181
+ X(l, n) && Q(h, O, i);
182
+ }
183
+ return [];
184
+ }) : [];
185
+ if (E.length > 0)
186
+ throw Promise.all(E);
187
+ const m = u.find(
188
+ (l, v) => {
189
+ const h = a[v];
190
+ return h && Y({
191
+ result: l,
192
+ errorResetBoundary: i,
193
+ throwOnError: h.throwOnError,
194
+ query: r.getQueryCache().get(h.queryHash),
195
+ suspense: h.suspense
196
+ });
197
+ }
198
+ );
199
+ if (m?.error)
200
+ throw m.error;
201
+ return c(f());
202
+ }
203
+ const be = "normal", fe = "http://terminology.hl7.org/CodeSystem/referencerange-meaning", ge = "A", me = "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", ye = (e, s) => e?.date ? ie(e.date, s).formattedResult : s("DATE_ERROR_PARSE"), Oe = (e) => {
204
+ if (!e.observationValue?.value)
205
+ return "";
206
+ const { value: s, unit: t } = e.observationValue;
207
+ return t ? `${s} ${t}` : String(s);
208
+ }, Re = (e) => {
209
+ const s = e.display;
210
+ if (!e.observationValue)
211
+ return String(s);
212
+ const { unit: t, referenceRange: r } = e.observationValue;
213
+ if (!r)
214
+ return String(s);
215
+ const { low: n, high: i } = r;
216
+ if (n && i) {
217
+ const a = n.unit ? `${n.value} ${n.unit}` : t ? `${n.value} ${t}` : String(n.value), o = i.unit ? `${i.value} ${i.unit}` : t ? `${i.value} ${t}` : String(i.value);
218
+ return `${s} (${a} - ${o})`;
219
+ }
220
+ if (n) {
221
+ const a = n.unit ? `${n.value} ${n.unit}` : t ? `${n.value} ${t}` : String(n.value);
222
+ return `${s} (>${a})`;
223
+ }
224
+ if (i) {
225
+ const a = i.unit ? `${i.value} ${i.unit}` : t ? `${i.value} ${t}` : String(i.value);
226
+ return `${s} (<${a})`;
227
+ }
228
+ return s;
229
+ }, Ee = (e, s) => ({
230
+ index: s,
231
+ header: Re(e),
232
+ value: Oe(e),
233
+ provider: e.encounter?.provider
234
+ }), $ = (e) => (typeof e == "string" ? e : e?.reference)?.split("/")?.pop();
235
+ function Se(e) {
236
+ return !e.interpretation || e.interpretation.length === 0 ? !1 : e.interpretation.some(
237
+ (s) => s.coding?.some(
238
+ (t) => t.system === me && t.code === ge
239
+ )
240
+ );
241
+ }
242
+ function we(e) {
243
+ const {
244
+ valueQuantity: s,
245
+ valueCodeableConcept: t,
246
+ valueString: r,
247
+ valueBoolean: n,
248
+ valueInteger: i,
249
+ referenceRange: a
250
+ } = e, o = Se(e);
251
+ if (s) {
252
+ const u = {
253
+ value: s.value ?? "",
254
+ unit: s.unit,
255
+ type: "quantity",
256
+ isAbnormal: o
257
+ };
258
+ if (a && a.length > 0) {
259
+ const c = a.find(
260
+ (f) => f.type?.coding?.some(
261
+ (p) => p.system === fe && p.code === be
262
+ )
263
+ );
264
+ c && (c.low || c.high) && (u.referenceRange = {
265
+ low: c.low ? {
266
+ value: c.low.value,
267
+ unit: c.low.unit
268
+ } : void 0,
269
+ high: c.high ? {
270
+ value: c.high.value,
271
+ unit: c.high.unit
272
+ } : void 0
273
+ });
274
+ }
275
+ return u;
276
+ }
277
+ if (t)
278
+ return {
279
+ value: t.text ?? t.coding[0].display,
280
+ type: "codeable",
281
+ isAbnormal: o
282
+ };
283
+ if (r)
284
+ return {
285
+ value: r,
286
+ type: "string",
287
+ isAbnormal: o
288
+ };
289
+ if (n !== void 0)
290
+ return {
291
+ value: n,
292
+ type: "boolean",
293
+ isAbnormal: o
294
+ };
295
+ if (i !== void 0)
296
+ return {
297
+ value: i,
298
+ type: "integer",
299
+ isAbnormal: o
300
+ };
301
+ }
302
+ function $e(e, s) {
303
+ const t = s.get(e);
304
+ if (t)
305
+ return {
306
+ id: t.id ?? e,
307
+ type: t.type?.[0]?.coding?.[0]?.display ?? "Unknown",
308
+ date: t.period?.start ?? "",
309
+ provider: t.participant?.[0]?.individual?.display,
310
+ location: t.location?.[0]?.location?.display
311
+ };
312
+ }
313
+ function V(e, s, t) {
314
+ const r = $(e.encounter), n = (e.hasMember ?? []).map((i) => $(i)).map((i) => i ? t.get(i) : void 0).filter((i) => !!i).map(
315
+ (i) => V(i, s, t)
316
+ );
317
+ return {
318
+ id: e.id,
319
+ display: e.code?.text ?? e.code?.coding?.[0]?.display ?? "",
320
+ observationValue: we(e),
321
+ effectiveDateTime: e.effectiveDateTime,
322
+ issued: e.issued,
323
+ encounter: r ? $e(r, s) : void 0,
324
+ members: n.length > 0 ? n : void 0
325
+ };
326
+ }
327
+ function Te(e) {
328
+ const s = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
329
+ e.entry?.forEach(({ resource: a }) => {
330
+ a?.id && (a.resourceType === "Encounter" ? s.set(a.id, a) : a.resourceType === "Observation" && (t.set(a.id, a), a.hasMember?.forEach((o) => {
331
+ const u = $(o);
332
+ u && r.add(u);
333
+ })));
334
+ });
335
+ const n = [], i = [];
336
+ return t.forEach((a, o) => {
337
+ if (r.has(o)) return;
338
+ const u = V(
339
+ a,
340
+ s,
341
+ t
342
+ );
343
+ u.members?.length ? i.push({ ...u, children: u.members }) : n.push(u);
344
+ }), { observations: n, groupedObservations: i };
345
+ }
346
+ function Qe(e) {
347
+ const s = /* @__PURE__ */ new Map();
348
+ return e.observations.forEach((t) => {
349
+ if (!t.encounter?.id) return;
350
+ const r = t.encounter.id;
351
+ s.has(r) || s.set(r, {
352
+ observations: [],
353
+ groupedObservations: []
354
+ }), s.get(r).observations.push(t);
355
+ }), e.groupedObservations.forEach((t) => {
356
+ if (!t.encounter?.id) return;
357
+ const r = t.encounter.id;
358
+ s.has(r) || s.set(r, {
359
+ observations: [],
360
+ groupedObservations: []
361
+ }), s.get(r).groupedObservations.push(t);
362
+ }), Array.from(s.entries()).map(([t, r]) => {
363
+ const n = r.observations[0]?.encounter ?? r.groupedObservations[0]?.encounter;
364
+ return {
365
+ encounterId: t,
366
+ encounterDetails: n,
367
+ observations: r.observations,
368
+ groupedObservations: r.groupedObservations
369
+ };
370
+ });
371
+ }
372
+ function Ce(e) {
373
+ return [...e].sort((s, t) => {
374
+ const r = s.encounterDetails?.date, n = t.encounterDetails?.date;
375
+ return !r && !n ? 0 : r ? n ? new Date(n).getTime() - new Date(r).getTime() : -1 : 1;
376
+ });
377
+ }
378
+ const q = (e, s, t) => {
379
+ const r = Ee(e, s), n = r.value, i = oe(n);
380
+ let a = n;
381
+ i === "Image" && (a = /* @__PURE__ */ b(ue, { imageSrc: n, alt: n, id: `${n}-img` })), i === "Video" && (a = /* @__PURE__ */ b(le, { id: `${n}-video`, videoSrc: n }));
382
+ const o = t("OBSERVATIONS_RECORDED_BY", {
383
+ provider: r.provider
384
+ }), u = e.observationValue?.isAbnormal ? `abnormal-obs-${e.id}` : `obs-${e.id}`;
385
+ return /* @__PURE__ */ b(
386
+ ae,
387
+ {
388
+ header: r.header,
389
+ value: a,
390
+ info: o,
391
+ id: u,
392
+ testId: `${u}-test-id`,
393
+ ariaLabel: `${u}-aria-label`
394
+ },
395
+ `obs-${e.id}`
396
+ );
397
+ }, _e = (e, s, t) => /* @__PURE__ */ b(
398
+ M,
399
+ {
400
+ title: e.display,
401
+ id: `grouped-obs-${e.id}`,
402
+ open: t,
403
+ children: e.children.map(
404
+ (r, n) => q(r, n, s)
405
+ )
406
+ },
407
+ `grouped-obs-${e.id}`
408
+ ), Ae = ({
409
+ groupedData: e
410
+ }) => {
411
+ const { t: s } = N(), t = (r, n) => {
412
+ const i = ye(r.encounterDetails, s);
413
+ return /* @__PURE__ */ I(
414
+ M,
415
+ {
416
+ title: i,
417
+ id: `encounter-${r.encounterId}`,
418
+ open: n,
419
+ children: [
420
+ r.observations.map(
421
+ (a, o) => q(a, o, s)
422
+ ),
423
+ r.groupedObservations.map(
424
+ (a) => _e(a, s, n)
425
+ )
426
+ ]
427
+ },
428
+ `encounter-${r.encounterId}`
429
+ );
430
+ };
431
+ return /* @__PURE__ */ b(
432
+ "div",
433
+ {
434
+ id: "obs-by-encounter",
435
+ "data-testid": "obs-by-encounter-test-id",
436
+ "aria-label": "obs-by-encounter-aria-label",
437
+ children: e.map(
438
+ (r, n) => t(r, n === 0)
439
+ )
440
+ }
441
+ );
442
+ }, Ie = "_observations_kfbhq_1", De = "_title_kfbhq_12", A = {
443
+ observations: Ie,
444
+ title: De
445
+ }, Ne = (e) => ["conceptUuid", e], Me = (e, s) => ["observations", e, ...s], xe = ({ config: e }) => {
446
+ const s = e, { conceptNames: t = [], conceptUuid: r = [] } = s, n = de(/* @__PURE__ */ new Set()), i = Z(), { addNotification: a } = ee(), { t: o } = N(), u = ve({
447
+ queries: t.map((d) => ({
448
+ queryKey: Ne(d),
449
+ queryFn: () => te(d),
450
+ enabled: !!d
451
+ }))
452
+ });
453
+ C(() => {
454
+ u.forEach((d, y) => {
455
+ if (d.isError && !n.current.has(y)) {
456
+ const G = t[y];
457
+ a({
458
+ title: o("ERROR_DEFAULT_TITLE"),
459
+ message: o("ERROR_FETCHING_CONCEPT", { conceptName: G }),
460
+ type: "error"
461
+ }), n.current.add(y);
462
+ } else d.isError || n.current.delete(y);
463
+ });
464
+ }, [u, t]);
465
+ const c = S(() => u.map((d) => d.data?.uuid).filter((d) => !!d), [u]), f = S(() => [.../* @__PURE__ */ new Set([...c, ...r])], [c, r]), p = S(() => t.length === 0 ? !0 : u.every((d) => !d.isLoading), [u, t.length]), {
466
+ data: g,
467
+ isLoading: E,
468
+ isError: m
469
+ } = se({
470
+ queryKey: Me(i, f),
471
+ queryFn: () => ce(i, f),
472
+ enabled: !!i && f.length > 0 && p
473
+ });
474
+ C(() => {
475
+ m && a({
476
+ title: o("ERROR_DEFAULT_TITLE"),
477
+ message: o("ERROR_FETCHING_OBSERVATIONS"),
478
+ type: "error"
479
+ });
480
+ }, [m]);
481
+ const l = S(() => {
482
+ if (!g) return [];
483
+ const d = Te(g), y = Qe(d);
484
+ return Ce(y);
485
+ }, [g]), v = [
486
+ { key: "name", header: "name" },
487
+ { key: "value", header: "value" },
488
+ { key: "form", header: "form" }
489
+ ], h = E || !p, O = m && p, k = (!g || g.entry?.length === 0 || f.length === 0) && p, x = O ? o("ERROR_FETCHING_OBSERVATIONS") : null, B = k ? o("NO_OBSERVATIONS_FOUND") : void 0, L = l.length > 0 && !h && !O;
490
+ return /* @__PURE__ */ I(
491
+ "div",
492
+ {
493
+ id: "observations",
494
+ "data-testid": "observations-test-id",
495
+ "aria-label": "observations-aria-label",
496
+ className: A.observations,
497
+ children: [
498
+ /* @__PURE__ */ b(
499
+ re,
500
+ {
501
+ id: "observations-title",
502
+ testId: "observations-title-test-id",
503
+ title: o(s.titleTranslationKey),
504
+ className: A.title,
505
+ children: /* @__PURE__ */ b("p", { children: o(s.titleTranslationKey) })
506
+ }
507
+ ),
508
+ L ? /* @__PURE__ */ b(Ae, { groupedData: l }) : /* @__PURE__ */ b(
509
+ ne,
510
+ {
511
+ headers: v,
512
+ rows: [],
513
+ ariaLabel: o("OBSERVATIONS"),
514
+ loading: h,
515
+ errorStateMessage: x,
516
+ emptyStateMessage: B
517
+ }
518
+ )
519
+ ]
520
+ }
521
+ );
522
+ };
523
+ export {
524
+ Ne as conceptUuidQueryKeys,
525
+ xe as default,
526
+ Me as observationsQueryKeys
527
+ };
@@ -1,4 +1,4 @@
1
- import { M as we, N as z, P as xt, U as B, I as q, J as y, X as Ro, Y as ye, Z as R, $ as _, a0 as k, a1 as N, a2 as A, a3 as bs, a4 as ir, a5 as $e, a6 as U, a7 as Hn, a8 as Vn, a9 as dt, aa as D, ab as xs, ac as cn, ad as Be, ae as ws, af as qt, ag as zt, ah as $s, ai as Cs, aj as $n, ak as Ss, al as Nr, am as Bt, an as zo, ao as ks, ap as Es, aq as j, ar as Ur, as as Ms, at as Ds, au as sr, av as As, aw as Ts, ax as zn, ay as Fs, az as Is, aA as Z, aB as Ps, aC as Ls } from "./index-d8oOVCXW.js";
1
+ import { M as we, N as z, P as xt, U as B, I as q, J as y, X as Ro, Y as ye, Z as R, $ as _, a0 as k, a1 as N, a2 as A, a3 as bs, a4 as ir, a5 as $e, a6 as U, a7 as Hn, a8 as Vn, a9 as dt, aa as D, ab as xs, ac as cn, ad as Be, ae as ws, af as qt, ag as zt, ah as $s, ai as Cs, aj as $n, ak as Ss, al as Nr, am as Bt, an as zo, ao as ks, ap as Es, aq as j, ar as Ur, as as Ms, at as Ds, au as sr, av as As, aw as Ts, ax as zn, ay as Fs, az as Is, aA as Z, aB as Ps, aC as Ls } from "./index-aCQK8yvY.js";
2
2
  var Os = (e) => e != null, qs = (e) => e.filter(Os);
3
3
  function _s(e) {
4
4
  return (...t) => {
@@ -156425,11 +156425,11 @@ const BGe = () => {
156425
156425
  },
156426
156426
  {
156427
156427
  type: "forms",
156428
- component: lazy$1(() => import("./FormsTable-DGMnOsw7-BtXmuF_u.js"))
156428
+ component: lazy$1(() => import("./FormsTable-B3aV3wve-D9ogh7Uh.js"))
156429
156429
  },
156430
156430
  {
156431
156431
  type: "observations",
156432
- component: lazy$1(() => import("./Observations-nESYMiLR-DXxlcCTx.js"))
156432
+ component: lazy$1(() => import("./Observations-DejWaIb1-BK8LvbgH.js"))
156433
156433
  }
156434
156434
  ];
156435
156435
  class Qr {
@@ -158310,7 +158310,7 @@ var displayValue = (n, e = !1) => {
158310
158310
  const e = render(() => {
158311
158311
  const a = this, [r] = this.#o, [l] = this.#d, [f] = this.#f, [d] = this.#u, [h] = this.#p, [m] = this.#e;
158312
158312
  let A;
158313
- return this.#s ? A = this.#s : (A = lazy(() => import("./LNWAZHJI-DOwuU-iG.js")), this.#s = A), setupStyleSheet(this.#i, this.#l), createComponent(A, mergeProps({
158313
+ return this.#s ? A = this.#s : (A = lazy(() => import("./LNWAZHJI-R4bHJQFP.js")), this.#s = A), setupStyleSheet(this.#i, this.#l), createComponent(A, mergeProps({
158314
158314
  get queryFlavor() {
158315
158315
  return a.#n;
158316
158316
  },
@@ -158408,7 +158408,7 @@ var displayValue = (n, e = !1) => {
158408
158408
  const e = render(() => {
158409
158409
  const a = this, [r] = this.#o, [l] = this.#d, [f] = this.#f, [d] = this.#u, [h] = this.#p, [m] = this.#e, [A] = this.#s;
158410
158410
  let g;
158411
- return this.#c ? g = this.#c : (g = lazy(() => import("./MWZ6AO7Z-BxXGvUxd.js")), this.#c = g), setupStyleSheet(this.#i, this.#l), createComponent(g, mergeProps({
158411
+ return this.#c ? g = this.#c : (g = lazy(() => import("./MWZ6AO7Z-dYsrujMJ.js")), this.#c = g), setupStyleSheet(this.#i, this.#l), createComponent(g, mergeProps({
158412
158412
  get queryFlavor() {
158413
158413
  return a.#n;
158414
158414
  },
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { aD as i } from "./index-d8oOVCXW.js";
1
+ import { aD as i } from "./index-aCQK8yvY.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.118",
3
+ "version": "0.0.1-dev.119",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -1,503 +0,0 @@
1
- import { jsxs as D, jsx as p } from "react/jsx-runtime";
2
- import { g as F, n as w, r as U, Q as I, h as H, i as P, j as K, k as z, l as W, m as j, o as J, s as T, p as Q, t as X, v as Y, O as Z, x as ee, u as N, y as te, a as se, W as re, e as ne, z as ie, A as M, B as oe, V as ae, E as ue, F as ce, G as le } from "./index-d8oOVCXW.js";
3
- import * as R from "react";
4
- import { useRef as de, useEffect as C, useMemo as S } from "react";
5
- function _(e, t) {
6
- const s = new Set(t);
7
- return e.filter((r) => !s.has(r));
8
- }
9
- function he(e, t, s) {
10
- const r = e.slice(0);
11
- return r[t] = s, r;
12
- }
13
- var pe = class extends F {
14
- #r;
15
- #e;
16
- #n;
17
- #i;
18
- #t;
19
- #s;
20
- #o;
21
- #a;
22
- #u = [];
23
- constructor(e, t, s) {
24
- super(), this.#r = e, this.#i = s, this.#n = [], this.#t = [], this.#e = [], this.setQueries(t);
25
- }
26
- onSubscribe() {
27
- this.listeners.size === 1 && this.#t.forEach((e) => {
28
- e.subscribe((t) => {
29
- this.#h(e, t);
30
- });
31
- });
32
- }
33
- onUnsubscribe() {
34
- this.listeners.size || this.destroy();
35
- }
36
- destroy() {
37
- this.listeners = /* @__PURE__ */ new Set(), this.#t.forEach((e) => {
38
- e.destroy();
39
- });
40
- }
41
- setQueries(e, t) {
42
- if (this.#n = e, this.#i = t, process.env.NODE_ENV !== "production") {
43
- const s = e.map(
44
- (r) => this.#r.defaultQueryOptions(r).queryHash
45
- );
46
- new Set(s).size !== s.length && console.warn(
47
- "[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior."
48
- );
49
- }
50
- w.batch(() => {
51
- const s = this.#t, r = this.#d(this.#n);
52
- this.#u = r, r.forEach(
53
- (i) => i.observer.setOptions(i.defaultedQueryOptions)
54
- );
55
- const n = r.map((i) => i.observer), o = n.map(
56
- (i) => i.getCurrentResult()
57
- ), a = n.some(
58
- (i, u) => i !== s[u]
59
- );
60
- s.length === n.length && !a || (this.#t = n, this.#e = o, this.hasListeners() && (_(s, n).forEach((i) => {
61
- i.destroy();
62
- }), _(n, s).forEach((i) => {
63
- i.subscribe((u) => {
64
- this.#h(i, u);
65
- });
66
- }), this.#p()));
67
- });
68
- }
69
- getCurrentResult() {
70
- return this.#e;
71
- }
72
- getQueries() {
73
- return this.#t.map((e) => e.getCurrentQuery());
74
- }
75
- getObservers() {
76
- return this.#t;
77
- }
78
- getOptimisticResult(e, t) {
79
- const s = this.#d(e), r = s.map(
80
- (n) => n.observer.getOptimisticResult(n.defaultedQueryOptions)
81
- );
82
- return [
83
- r,
84
- (n) => this.#l(n ?? r, t),
85
- () => this.#c(r, s)
86
- ];
87
- }
88
- #c(e, t) {
89
- return t.map((s, r) => {
90
- const n = e[r];
91
- return s.defaultedQueryOptions.notifyOnChangeProps ? n : s.observer.trackResult(n, (o) => {
92
- t.forEach((a) => {
93
- a.observer.trackProp(o);
94
- });
95
- });
96
- });
97
- }
98
- #l(e, t) {
99
- return t ? ((!this.#s || this.#e !== this.#a || t !== this.#o) && (this.#o = t, this.#a = this.#e, this.#s = U(
100
- this.#s,
101
- t(e)
102
- )), this.#s) : e;
103
- }
104
- #d(e) {
105
- const t = new Map(
106
- this.#t.map((r) => [r.options.queryHash, r])
107
- ), s = [];
108
- return e.forEach((r) => {
109
- const n = this.#r.defaultQueryOptions(r), o = t.get(n.queryHash);
110
- o ? s.push({
111
- defaultedQueryOptions: n,
112
- observer: o
113
- }) : s.push({
114
- defaultedQueryOptions: n,
115
- observer: new I(this.#r, n)
116
- });
117
- }), s;
118
- }
119
- #h(e, t) {
120
- const s = this.#t.indexOf(e);
121
- s !== -1 && (this.#e = he(this.#e, s, t), this.#p());
122
- }
123
- #p() {
124
- if (this.hasListeners()) {
125
- const e = this.#s, t = this.#c(this.#e, this.#u), s = this.#l(t, this.#i?.combine);
126
- e !== s && w.batch(() => {
127
- this.listeners.forEach((r) => {
128
- r(this.#e);
129
- });
130
- });
131
- }
132
- }
133
- };
134
- function fe({
135
- queries: e,
136
- ...t
137
- }, s) {
138
- const r = H(s), n = P(), o = K(), a = R.useMemo(
139
- () => e.map((c) => {
140
- const h = r.defaultQueryOptions(
141
- c
142
- );
143
- return h._optimisticResults = n ? "isRestoring" : "optimistic", h;
144
- }),
145
- [e, r, n]
146
- );
147
- a.forEach((c) => {
148
- z(c), W(c, o);
149
- }), j(o);
150
- const [i] = R.useState(
151
- () => new pe(
152
- r,
153
- a,
154
- t
155
- )
156
- ), [u, f, v] = i.getOptimisticResult(
157
- a,
158
- t.combine
159
- ), b = !n && t.subscribed !== !1;
160
- R.useSyncExternalStore(
161
- R.useCallback(
162
- (c) => b ? i.subscribe(w.batchCalls(c)) : J,
163
- [i, b]
164
- ),
165
- () => i.getCurrentResult(),
166
- () => i.getCurrentResult()
167
- ), R.useEffect(() => {
168
- i.setQueries(
169
- a,
170
- t
171
- );
172
- }, [a, t, i]);
173
- const E = u.some(
174
- (c, h) => T(a[h], c)
175
- ) ? u.flatMap((c, h) => {
176
- const d = a[h];
177
- if (d) {
178
- const O = new I(r, d);
179
- if (T(d, c))
180
- return Q(d, O, o);
181
- X(c, n) && Q(d, O, o);
182
- }
183
- return [];
184
- }) : [];
185
- if (E.length > 0)
186
- throw Promise.all(E);
187
- const m = u.find(
188
- (c, h) => {
189
- const d = a[h];
190
- return d && Y({
191
- result: c,
192
- errorResetBoundary: o,
193
- throwOnError: d.throwOnError,
194
- query: r.getQueryCache().get(d.queryHash),
195
- suspense: d.suspense
196
- });
197
- }
198
- );
199
- if (m?.error)
200
- throw m.error;
201
- return f(v());
202
- }
203
- const be = "normal", ve = "http://terminology.hl7.org/CodeSystem/referencerange-meaning", ge = "A", me = "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", ye = (e, t) => e?.date ? ie(e.date, t).formattedResult : t("DATE_ERROR_PARSE"), Oe = (e) => {
204
- const { value: t, unit: s } = e.observationValue;
205
- return s ? `${t} ${s}` : String(t);
206
- }, Re = (e) => {
207
- const { unit: t, referenceRange: s } = e.observationValue, r = e.display;
208
- if (!s)
209
- return String(r);
210
- const { low: n, high: o } = s;
211
- if (n && o) {
212
- const a = n.unit ? `${n.value} ${n.unit}` : t ? `${n.value} ${t}` : String(n.value), i = o.unit ? `${o.value} ${o.unit}` : t ? `${o.value} ${t}` : String(o.value);
213
- return `${r} (${a} - ${i})`;
214
- }
215
- if (n) {
216
- const a = n.unit ? `${n.value} ${n.unit}` : t ? `${n.value} ${t}` : String(n.value);
217
- return `${r} (>${a})`;
218
- }
219
- if (o) {
220
- const a = o.unit ? `${o.value} ${o.unit}` : t ? `${o.value} ${t}` : String(o.value);
221
- return `${r} (<${a})`;
222
- }
223
- return r;
224
- }, Ee = (e, t) => ({
225
- index: t,
226
- header: Re(e),
227
- value: Oe(e),
228
- provider: e.encounter?.provider
229
- }), $ = (e) => (typeof e == "string" ? e : e?.reference)?.split("/")?.pop();
230
- function Se(e) {
231
- return !e.interpretation || e.interpretation.length === 0 ? !1 : e.interpretation.some(
232
- (t) => t.coding?.some(
233
- (s) => s.system === me && s.code === ge
234
- )
235
- );
236
- }
237
- function we(e) {
238
- const { valueQuantity: t, valueCodeableConcept: s, valueString: r, referenceRange: n } = e, o = Se(e);
239
- if (t) {
240
- const a = {
241
- value: t.value ?? "",
242
- unit: t.unit,
243
- type: "quantity",
244
- isAbnormal: o
245
- };
246
- if (n && n.length > 0) {
247
- const i = n.find(
248
- (u) => u.type?.coding?.some(
249
- (f) => f.system === ve && f.code === be
250
- )
251
- );
252
- i && (i.low || i.high) && (a.referenceRange = {
253
- low: i.low ? {
254
- value: i.low.value,
255
- unit: i.low.unit
256
- } : void 0,
257
- high: i.high ? {
258
- value: i.high.value,
259
- unit: i.high.unit
260
- } : void 0
261
- });
262
- }
263
- return a;
264
- }
265
- if (s)
266
- return {
267
- value: s.text ?? s.coding[0].display,
268
- type: "codeable",
269
- isAbnormal: o
270
- };
271
- if (r)
272
- return {
273
- value: r,
274
- type: "string",
275
- isAbnormal: o
276
- };
277
- }
278
- function $e(e, t) {
279
- const s = t.get(e);
280
- if (s)
281
- return {
282
- id: s.id ?? e,
283
- type: s.type?.[0]?.coding?.[0]?.display ?? "Unknown",
284
- date: s.period?.start ?? "",
285
- provider: s.participant?.[0]?.individual?.display,
286
- location: s.location?.[0]?.location?.display
287
- };
288
- }
289
- function q(e, t, s) {
290
- const r = $(e.encounter), n = (e.hasMember ?? []).map((o) => $(o)).map((o) => o ? s.get(o) : void 0).filter((o) => !!o).map(
291
- (o) => q(o, t, s)
292
- );
293
- return {
294
- id: e.id,
295
- display: e.code?.text ?? e.code?.coding?.[0]?.display ?? "",
296
- observationValue: we(e),
297
- effectiveDateTime: e.effectiveDateTime,
298
- issued: e.issued,
299
- encounter: r ? $e(r, t) : void 0,
300
- members: n.length > 0 ? n : void 0
301
- };
302
- }
303
- function Te(e) {
304
- const t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
305
- e.entry?.forEach(({ resource: a }) => {
306
- a?.id && (a.resourceType === "Encounter" ? t.set(a.id, a) : a.resourceType === "Observation" && (s.set(a.id, a), a.hasMember?.forEach((i) => {
307
- const u = $(i);
308
- u && r.add(u);
309
- })));
310
- });
311
- const n = [], o = [];
312
- return s.forEach((a, i) => {
313
- if (r.has(i)) return;
314
- const u = q(
315
- a,
316
- t,
317
- s
318
- );
319
- u.members?.length ? o.push({ ...u, children: u.members }) : n.push(u);
320
- }), { observations: n, groupedObservations: o };
321
- }
322
- function Qe(e) {
323
- const t = /* @__PURE__ */ new Map();
324
- return e.observations.forEach((s) => {
325
- if (!s.encounter?.id) return;
326
- const r = s.encounter.id;
327
- t.has(r) || t.set(r, {
328
- observations: [],
329
- groupedObservations: []
330
- }), t.get(r).observations.push(s);
331
- }), e.groupedObservations.forEach((s) => {
332
- if (!s.encounter?.id) return;
333
- const r = s.encounter.id;
334
- t.has(r) || t.set(r, {
335
- observations: [],
336
- groupedObservations: []
337
- }), t.get(r).groupedObservations.push(s);
338
- }), Array.from(t.entries()).map(([s, r]) => {
339
- const n = r.observations[0]?.encounter ?? r.groupedObservations[0]?.encounter;
340
- return {
341
- encounterId: s,
342
- encounterDetails: n,
343
- observations: r.observations,
344
- groupedObservations: r.groupedObservations
345
- };
346
- });
347
- }
348
- function Ce(e) {
349
- return [...e].sort((t, s) => {
350
- const r = t.encounterDetails?.date, n = s.encounterDetails?.date;
351
- return !r && !n ? 0 : r ? n ? new Date(n).getTime() - new Date(r).getTime() : -1 : 1;
352
- });
353
- }
354
- const k = (e, t, s) => {
355
- const r = Ee(e, t), n = r.value, o = oe(n);
356
- let a = n;
357
- o === "Image" && (a = /* @__PURE__ */ p(ue, { imageSrc: n, alt: n, id: `${n}-img` })), o === "Video" && (a = /* @__PURE__ */ p(ce, { id: `${n}-video`, videoSrc: n }));
358
- const i = s("OBSERVATIONS_RECORDED_BY", {
359
- provider: r.provider
360
- }), u = e.observationValue?.isAbnormal ? `abnormal-obs-${e.id}` : `obs-${e.id}`;
361
- return /* @__PURE__ */ p(
362
- ae,
363
- {
364
- header: r.header,
365
- value: a,
366
- info: i,
367
- id: u,
368
- testId: `${u}-test-id`,
369
- ariaLabel: `${u}-aria-label`
370
- },
371
- `obs-${e.id}`
372
- );
373
- }, _e = (e, t, s) => /* @__PURE__ */ p(
374
- M,
375
- {
376
- title: e.display,
377
- id: `grouped-obs-${e.id}`,
378
- open: s,
379
- children: e.children.map(
380
- (r, n) => k(r, n, t)
381
- )
382
- },
383
- `grouped-obs-${e.id}`
384
- ), Ae = ({
385
- groupedData: e
386
- }) => {
387
- const { t } = N(), s = (r, n) => {
388
- const o = ye(r.encounterDetails, t);
389
- return /* @__PURE__ */ D(
390
- M,
391
- {
392
- title: o,
393
- id: `encounter-${r.encounterId}`,
394
- open: n,
395
- children: [
396
- r.observations.map(
397
- (a, i) => k(a, i, t)
398
- ),
399
- r.groupedObservations.map(
400
- (a) => _e(a, t, n)
401
- )
402
- ]
403
- },
404
- `encounter-${r.encounterId}`
405
- );
406
- };
407
- return /* @__PURE__ */ p(
408
- "div",
409
- {
410
- id: "obs-by-encounter",
411
- "data-testid": "obs-by-encounter-test-id",
412
- "aria-label": "obs-by-encounter-aria-label",
413
- children: e.map(
414
- (r, n) => s(r, n === 0)
415
- )
416
- }
417
- );
418
- }, De = "_observations_kfbhq_1", Ie = "_title_kfbhq_12", A = {
419
- observations: De,
420
- title: Ie
421
- }, Ne = (e) => ["conceptUuid", e], Me = (e, t) => ["observations", e, ...t], Ve = ({ config: e }) => {
422
- const t = e, { conceptNames: s = [], conceptUuid: r = [] } = t, n = de(/* @__PURE__ */ new Set()), o = Z(), { addNotification: a } = ee(), { t: i } = N(), u = fe({
423
- queries: s.map((l) => ({
424
- queryKey: Ne(l),
425
- queryFn: () => te(l),
426
- enabled: !!l
427
- }))
428
- });
429
- C(() => {
430
- u.forEach((l, y) => {
431
- if (l.isError && !n.current.has(y)) {
432
- const G = s[y];
433
- a({
434
- title: i("ERROR_DEFAULT_TITLE"),
435
- message: i("ERROR_FETCHING_CONCEPT", { conceptName: G }),
436
- type: "error"
437
- }), n.current.add(y);
438
- } else l.isError || n.current.delete(y);
439
- });
440
- }, [u, s]);
441
- const f = S(() => u.map((l) => l.data?.uuid).filter((l) => !!l), [u]), v = S(() => [.../* @__PURE__ */ new Set([...f, ...r])], [f, r]), b = S(() => s.length === 0 ? !0 : u.every((l) => !l.isLoading), [u, s.length]), {
442
- data: g,
443
- isLoading: E,
444
- isError: m
445
- } = se({
446
- queryKey: Me(o, v),
447
- queryFn: () => le(o, v),
448
- enabled: !!o && v.length > 0 && b
449
- });
450
- C(() => {
451
- m && a({
452
- title: i("ERROR_DEFAULT_TITLE"),
453
- message: i("ERROR_FETCHING_OBSERVATIONS"),
454
- type: "error"
455
- });
456
- }, [m]);
457
- const c = S(() => {
458
- if (!g) return [];
459
- const l = Te(g), y = Qe(l);
460
- return Ce(y);
461
- }, [g]), h = [
462
- { key: "name", header: "name" },
463
- { key: "value", header: "value" },
464
- { key: "form", header: "form" }
465
- ], d = E || !b, O = m && b, x = (!g || g.entry?.length === 0 || v.length === 0) && b, V = O ? i("ERROR_FETCHING_OBSERVATIONS") : null, L = x ? i("NO_OBSERVATIONS_FOUND") : void 0, B = c.length > 0 && !d && !O;
466
- return /* @__PURE__ */ D(
467
- "div",
468
- {
469
- id: "observations",
470
- "data-testid": "observations-test-id",
471
- "aria-label": "observations-aria-label",
472
- className: A.observations,
473
- children: [
474
- /* @__PURE__ */ p(
475
- re,
476
- {
477
- id: "observations-title",
478
- testId: "observations-title-test-id",
479
- title: i(t.titleTranslationKey),
480
- className: A.title,
481
- children: /* @__PURE__ */ p("p", { children: i(t.titleTranslationKey) })
482
- }
483
- ),
484
- B ? /* @__PURE__ */ p(Ae, { groupedData: c }) : /* @__PURE__ */ p(
485
- ne,
486
- {
487
- headers: h,
488
- rows: [],
489
- ariaLabel: i("OBSERVATIONS"),
490
- loading: d,
491
- errorStateMessage: V,
492
- emptyStateMessage: L
493
- }
494
- )
495
- ]
496
- }
497
- );
498
- };
499
- export {
500
- Ne as conceptUuidQueryKeys,
501
- Ve as default,
502
- Me as observationsQueryKeys
503
- };