@bahmni/registration-app 0.0.1-dev.191 → 0.0.1-dev.193

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