@bahmni/home-app 0.0.1-dev.401 → 0.0.1-dev.405

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,213 +0,0 @@
1
- import { jsxs as S, jsx as u } from "react/jsx-runtime";
2
- import { g as q, C as k, u as N, $ as x, I as G, m as Q, f as j, h as w, J as H, i as J, K as M, j as z, l as C, r as P, s as Y, y as W, t as X, V as Z, x as ee } from "./index-DxLqK-Hp.js";
3
- import { useQueries as ae, useQuery as te } from "@tanstack/react-query";
4
- import { useRef as se, useEffect as $, useMemo as g } from "react";
5
- const D = (a, n, d, l, b, r) => {
6
- const t = P(a, n, b), s = t.value, i = Y(s);
7
- let o = s;
8
- i === "Image" && (o = /* @__PURE__ */ u(
9
- X,
10
- {
11
- imageSrc: s,
12
- alt: s,
13
- id: `${s}-img`,
14
- hideThumbnail: r
15
- }
16
- )), i === "Video" && (o = /* @__PURE__ */ u(
17
- Z,
18
- {
19
- id: `${s}-video`,
20
- videoSrc: s,
21
- hideThumbnail: r
22
- }
23
- )), i === "PDF" && (o = /* @__PURE__ */ u(ee, { id: `${s}-pdf`, src: s }));
24
- const m = b("OBSERVATIONS_RECORDED_BY", {
25
- provider: t.provider
26
- }), p = a.display, h = a.observationValue?.isAbnormal ? "abnormal-obs" : "obs", c = l ? `${l}-${h}-${p}-${d}-${n}` : `${h}-${p}-${d}-${n}`;
27
- return /* @__PURE__ */ u(
28
- W,
29
- {
30
- header: t.header,
31
- value: o,
32
- info: m,
33
- id: c,
34
- testId: c,
35
- ariaLabel: c
36
- },
37
- `obs-${a.id}`
38
- );
39
- }, re = (a, n, d, l, b, r, t) => /* @__PURE__ */ u(
40
- C,
41
- {
42
- title: a.display,
43
- id: `grouped-obs-${a.display}-${l}`,
44
- open: d,
45
- children: a.members?.map(
46
- (s, i) => D(
47
- s,
48
- i,
49
- b,
50
- r,
51
- n,
52
- t
53
- )
54
- )
55
- },
56
- `grouped-obs-${a.id}`
57
- ), ie = ({
58
- groupedData: a,
59
- title: n = "",
60
- hideThumbnail: d
61
- }) => {
62
- const { t: l } = N(), b = (r, t, s) => {
63
- const i = z(r.encounterDetails, l);
64
- return /* @__PURE__ */ S(
65
- C,
66
- {
67
- title: i,
68
- id: `encounter-${r.encounterId}`,
69
- open: t,
70
- children: [
71
- r.observations.map(
72
- (o, m) => D(
73
- o,
74
- m,
75
- s,
76
- n,
77
- l,
78
- d
79
- )
80
- ),
81
- r.groupedObservations.map(
82
- (o, m) => re(
83
- o,
84
- l,
85
- t,
86
- m,
87
- s,
88
- n,
89
- d
90
- )
91
- )
92
- ]
93
- },
94
- `encounter-${r.encounterId}`
95
- );
96
- };
97
- return /* @__PURE__ */ u(
98
- "div",
99
- {
100
- id: "obs-by-encounter",
101
- "data-testid": "obs-by-encounter-test-id",
102
- "aria-label": "obs-by-encounter-aria-label",
103
- children: a.map(
104
- (r, t) => b(r, t === 0, t)
105
- )
106
- }
107
- );
108
- }, oe = "Observations-module_observations__RKSyo", ne = "Observations-module_title__TJL3z", _ = {
109
- observations: oe,
110
- title: ne
111
- }, de = (a) => ["conceptUuid", a], le = (a, n) => ["observations", a, ...n], pe = ({ config: a }) => {
112
- const n = a, {
113
- conceptNames: d = [],
114
- conceptUuid: l = [],
115
- hideThumbnail: b = !1
116
- } = n, r = se(/* @__PURE__ */ new Set()), t = q(), { addNotification: s } = k(), { t: i } = N(), o = ae({
117
- queries: d.map((e) => ({
118
- queryKey: de(e),
119
- queryFn: () => x(e),
120
- enabled: !!e
121
- }))
122
- });
123
- $(() => {
124
- o.forEach((e, y) => {
125
- if (e.isError && !r.current.has(y)) {
126
- const B = d[y];
127
- s({
128
- title: i("ERROR_DEFAULT_TITLE"),
129
- message: i("ERROR_FETCHING_CONCEPT", { conceptName: B }),
130
- type: "error"
131
- }), r.current.add(y);
132
- } else e.isError || r.current.delete(y);
133
- });
134
- }, [o, d]);
135
- const m = g(() => o.map((e) => e.data?.uuid).filter((e) => !!e), [o]), p = g(() => [.../* @__PURE__ */ new Set([...m, ...l])], [m, l]), h = g(() => d.length === 0 ? !0 : o.every((e) => !e.isLoading), [o, d.length]), {
136
- data: c,
137
- isLoading: F,
138
- isError: R,
139
- refetch: T
140
- } = te({
141
- queryKey: le(t, p),
142
- queryFn: () => G(t, p),
143
- enabled: !!t && p.length > 0 && h
144
- });
145
- Q(
146
- (e) => {
147
- e.patientUUID === t && e.updatedConcepts.size > 0 && [...e.updatedConcepts.keys()].some(
148
- (y) => p.includes(y)
149
- ) && T();
150
- },
151
- [t, T]
152
- ), $(() => {
153
- R && s({
154
- title: i("ERROR_DEFAULT_TITLE"),
155
- message: i("ERROR_FETCHING_OBSERVATIONS"),
156
- type: "error"
157
- });
158
- }, [R]);
159
- const f = g(() => {
160
- if (!c) return [];
161
- const e = j(c), y = w(e);
162
- return H(y);
163
- }, [c]), K = [
164
- { key: "name", header: "name" },
165
- { key: "value", header: "value" },
166
- { key: "form", header: "form" }
167
- ], I = F || !h, O = R && h, L = (!c || c.entry?.length === 0 || p.length === 0) && h, V = O ? i("ERROR_FETCHING_OBSERVATIONS") : null, A = L ? i("NO_OBSERVATIONS_FOUND") : void 0, U = f.length > 0 && !I && !O, E = n.titleTranslationKey, v = E ? i(E) : "";
168
- return /* @__PURE__ */ S(
169
- "div",
170
- {
171
- id: "observations",
172
- "data-testid": E ? `observations-${v}` : "observations",
173
- "aria-label": "observations-aria-label",
174
- className: _.observations,
175
- children: [
176
- /* @__PURE__ */ u(
177
- J,
178
- {
179
- id: "observations-title",
180
- testId: E ? `observations-title-${v}` : "observations-title",
181
- title: v,
182
- className: _.title,
183
- children: /* @__PURE__ */ u("p", { children: v })
184
- }
185
- ),
186
- U ? /* @__PURE__ */ u(
187
- ie,
188
- {
189
- groupedData: f,
190
- title: v,
191
- hideThumbnail: b
192
- }
193
- ) : /* @__PURE__ */ u(
194
- M,
195
- {
196
- headers: K,
197
- rows: [],
198
- ariaLabel: i("OBSERVATIONS"),
199
- loading: I,
200
- errorStateMessage: V,
201
- emptyStateMessage: A,
202
- dataTestId: "observations-table"
203
- }
204
- )
205
- ]
206
- }
207
- );
208
- };
209
- export {
210
- de as conceptUuidQueryKeys,
211
- pe as default,
212
- le as observationsQueryKeys
213
- };
@@ -1,108 +0,0 @@
1
- import { jsxs as c, jsx as e, Fragment as p } from "react/jsx-runtime";
2
- import { u as m, z as b, A as y, D as H, H as N, a as P, L as v, M as E, O as f, Q as G, R as S, S as T, T as O } from "./index-DxLqK-Hp.js";
3
- import "react";
4
- import { useQuery as C } from "@tanstack/react-query";
5
- const L = "AppTile-module_tile__-CBFh", B = "AppTile-module_label__6vslD", A = "AppTile-module_bottom__lcJiG", d = {
6
- tile: L,
7
- label: B,
8
- bottom: A
9
- }, M = ({ id: r, label: n, icon: s, url: l }) => {
10
- const { t } = m(), i = t(n);
11
- return /* @__PURE__ */ c(
12
- b,
13
- {
14
- href: l,
15
- className: d.tile,
16
- "aria-label": i,
17
- testId: `app-tile-${r}`,
18
- children: [
19
- /* @__PURE__ */ e("h2", { className: d.label, "aria-hidden": "true", children: i }),
20
- /* @__PURE__ */ c("div", { className: d.bottom, children: [
21
- /* @__PURE__ */ e(y, { name: s, id: r, size: H.X2, "aria-hidden": "true" }),
22
- /* @__PURE__ */ e(N, { size: 20, "aria-hidden": "true" })
23
- ] })
24
- ]
25
- }
26
- );
27
- }, F = "HomePageGrid-module_container__Kxfim", k = "HomePageGrid-module_tileGrid__X6-Bm", x = "HomePageGrid-module_skeletonTile__U-1vu", D = "HomePageGrid-module_emptyState__xEwoK", K = "HomePageGrid-module_errorContainer__IKR3E", o = {
28
- container: F,
29
- tileGrid: k,
30
- skeletonTile: x,
31
- emptyState: D,
32
- errorContainer: K
33
- }, I = () => {
34
- const { t: r } = m(), {
35
- userPrivileges: n,
36
- isLoading: s,
37
- error: l
38
- } = P(), t = n?.map((a) => a.name) ?? null, {
39
- data: i = [],
40
- isLoading: _,
41
- isError: u,
42
- refetch: h
43
- } = C({
44
- queryKey: ["home-modules", t],
45
- queryFn: () => v("org.bahmni.home.dashboard", t),
46
- enabled: !s && l === null && t !== null
47
- });
48
- return s || _ || t === null && !l ? /* @__PURE__ */ e(
49
- "div",
50
- {
51
- className: o.container,
52
- role: "status",
53
- "aria-label": r("HOME_LOADING_MODULES"),
54
- "aria-busy": "true",
55
- children: /* @__PURE__ */ e("div", { className: o.tileGrid, children: Array.from(
56
- { length: E },
57
- (a, g) => `skeleton-${g}`
58
- ).map((a) => /* @__PURE__ */ e(f, { className: o.skeletonTile }, a)) })
59
- }
60
- ) : l || u ? /* @__PURE__ */ e(
61
- "div",
62
- {
63
- className: o.errorContainer,
64
- "data-testid": "home-error",
65
- role: "alert",
66
- children: /* @__PURE__ */ e(
67
- G,
68
- {
69
- kind: "error",
70
- lowContrast: !0,
71
- subtitle: r("HOME_ERROR_FETCH_CONFIG"),
72
- hideCloseButton: !1,
73
- onClose: () => void h()
74
- }
75
- )
76
- }
77
- ) : i.length === 0 ? /* @__PURE__ */ e("div", { className: o.emptyState, role: "status", children: r("HOME_NO_MODULES") }) : /* @__PURE__ */ e("div", { className: o.container, children: /* @__PURE__ */ e("div", { className: o.tileGrid, children: i.map((a) => /* @__PURE__ */ e(
78
- M,
79
- {
80
- id: a.id,
81
- label: a.translationKey ?? a.label,
82
- icon: a.icon,
83
- url: a.url
84
- },
85
- a.id
86
- )) }) });
87
- }, R = "HomePageHeader-module_locationSelector__foYmn", $ = {
88
- locationSelector: R
89
- }, z = () => /* @__PURE__ */ e(
90
- S,
91
- {
92
- ariaLabel: "Bahmni",
93
- brandPrefix: "Home",
94
- brandHref: "/",
95
- globalFeatures: [
96
- /* @__PURE__ */ e("div", { className: $.locationSelector, children: /* @__PURE__ */ e(O, {}) }, "location")
97
- ],
98
- userMenu: /* @__PURE__ */ e(T, {})
99
- }
100
- ), U = "HomePage-module_homePageBody__0qtrS", q = {
101
- homePageBody: U
102
- }, J = () => /* @__PURE__ */ c(p, { children: [
103
- /* @__PURE__ */ e(z, {}),
104
- /* @__PURE__ */ e("main", { className: q.homePageBody, children: /* @__PURE__ */ e(I, {}) })
105
- ] });
106
- export {
107
- J as HomePage
108
- };