@bahmni/home-app 0.0.1-dev.408 → 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.
@@ -1,5 +1,5 @@
1
1
  import { jsx as r, jsxs as p, Fragment as Y } from "react/jsx-runtime";
2
- import { v as x, u as G, z as W, t as J, q as X, w as Z, Y as ee, p as te } from "./index-BLBZZpTy.js";
2
+ import { v as x, u as G, z as W, n as J, q as X, w as Z, Y as ee, p as te } from "./index-EBKKwOv_.js";
3
3
  import { useQuery as ae } from "@tanstack/react-query";
4
4
  import { useState as l, useCallback as h, useEffect as I, useMemo as _ } from "react";
5
5
  const ne = "DocumentsTable-module_documentsTableBody__6iR3w", oe = "DocumentsTable-module_viewAttachmentsLink__aQ1on", re = "DocumentsTable-module_documentViewerContainer__F5m8D", de = "DocumentsTable-module_attachmentItem__17KA7", se = "DocumentsTable-module_attachmentCounter__WFiI3", me = "DocumentsTable-module_attachmentError__RI4U2", ce = "DocumentsTable-module_documentIframe__ptq5I", le = "DocumentsTable-module_documentImage__KQVgS", d = {
@@ -1,45 +1,45 @@
1
- import { jsx as i, jsxs as P, Fragment as ye } from "react/jsx-runtime";
2
- import { u as ge, v as be, e as Oe, a as Ne, b as Te, c as Ie, f as Ae, Q as Ee, d as ve, m as _e, g as Fe, o as Se, S as Q, w as Be, A as $, V as x, q as Me, Y as G, P as Re, F as Ce, p as Le, h as Ue, i as De } from "./index-BLBZZpTy.js";
3
- import { useQueryClient as ke, useQuery as N } from "@tanstack/react-query";
1
+ import { jsx as i, jsxs as x, Fragment as ye } from "react/jsx-runtime";
2
+ import { u as ge, v as be, e as Oe, a as Te, b as Ne, r as Ie, m as Ae, t as Ee, c as ve, d as _e, f as Fe, g as Se, S as K, w as Be, A as z, V as G, q as Me, Y as Q, P as Ce, F as Le, p as Ue, h as De, y as Re } from "./index-EBKKwOv_.js";
3
+ import { useQueryClient as ke, useQuery as T } from "@tanstack/react-query";
4
4
  import { useState as Y, useMemo as d, useCallback as c } from "react";
5
- const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_modalHeading__wnTmA", Ve = "FormsTable-module_customAccordianItem__isszs", T = {
5
+ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_modalHeading__wnTmA", Ve = "FormsTable-module_customAccordianItem__isszs", N = {
6
6
  formsTableBody: qe,
7
7
  modalHeading: we,
8
8
  customAccordianItem: Ve
9
- }, He = "startConsultation", Qe = ({
9
+ }, He = "startConsultation", Ke = ({
10
10
  episodeOfCareUuids: B,
11
11
  encounterUuids: m,
12
12
  config: X,
13
13
  disableActions: Z = !1,
14
14
  activeEncounterUuid: p = null
15
15
  }) => {
16
- const { t: n } = ge(), u = be(), [y, M] = Y(!1), [s, R] = Y(null), {
16
+ const { t: n } = ge(), u = be(), [y, M] = Y(!1), [s, C] = Y(null), {
17
17
  numberOfVisits: J,
18
18
  hideThumbnail: W = !1,
19
19
  forms: g
20
20
  } = X ?? {}, ee = Oe(
21
- De.EDIT_OBSERVATIONS
22
- ), { userPrivileges: b } = Ne(), I = ee && !Z && !!p, C = Te(
21
+ Re.EDIT_OBSERVATIONS
22
+ ), { userPrivileges: b } = Te(), I = ee && !Z && !!p, L = Ne(
23
23
  B,
24
24
  m
25
25
  ), re = ke(), {
26
- data: L = [],
27
- isLoading: U,
28
- isError: D,
26
+ data: U = [],
27
+ isLoading: D,
28
+ isError: R,
29
29
  error: oe,
30
30
  refetch: ae
31
- } = N({
31
+ } = T({
32
32
  queryKey: ["forms", u, B],
33
33
  queryFn: () => Ie(u, void 0, J),
34
- enabled: !!u && !C
34
+ enabled: !!u && !L
35
35
  }), k = d(() => {
36
- let e = L;
36
+ let e = U;
37
37
  return m && m.length > 0 && (e = e.filter(
38
38
  (r) => m.includes(r.encounterUuid)
39
39
  )), Array.isArray(g) && g.length > 0 && (e = e.filter(
40
40
  (r) => g.some((o) => o.toLowerCase() === r.formName.toLowerCase())
41
41
  )), e;
42
- }, [L, m, g]), { data: O = [] } = N({
42
+ }, [U, m, g]), { data: O = [] } = T({
43
43
  queryKey: ["observationForms"],
44
44
  queryFn: () => Ae()
45
45
  }), q = c(
@@ -67,7 +67,7 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
67
67
  isLoading: te,
68
68
  isError: se,
69
69
  error: E
70
- } = N({
70
+ } = T({
71
71
  queryKey: ["formMetadata", A],
72
72
  queryFn: () => Ee(A),
73
73
  enabled: !!A && y
@@ -76,7 +76,7 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
76
76
  isLoading: ne,
77
77
  isError: ie,
78
78
  error: _
79
- } = N({
79
+ } = T({
80
80
  queryKey: ["formsEncounterFHIR", s?.encounterUuid],
81
81
  queryFn: () => ve(s.encounterUuid),
82
82
  enabled: !!s?.encounterUuid && y
@@ -125,9 +125,9 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
125
125
  ), Object.keys(e).length > 0 ? e : void 0;
126
126
  }, [l]), ue = d(() => {
127
127
  if (E)
128
- return Q(E).message;
128
+ return K(E).message;
129
129
  if (_)
130
- return Q(_).message;
130
+ return K(_).message;
131
131
  }, [E, _]), h = d(
132
132
  () => [
133
133
  { key: "recordedOn", header: n("RECORDED_ON") },
@@ -172,9 +172,9 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
172
172
  })
173
173
  ).sort((r, o) => r.formName.localeCompare(o.formName));
174
174
  }, [k, n]), j = c((e) => {
175
- R(e), M(!0);
176
- }, []), z = c(() => {
177
- M(!1), R(null);
175
+ C(e), M(!0);
176
+ }, []), P = c(() => {
177
+ M(!1), C(null);
178
178
  }, []), F = c((e) => {
179
179
  globalThis.dispatchEvent(
180
180
  new CustomEvent(He, {
@@ -187,7 +187,7 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
187
187
  }
188
188
  })
189
189
  );
190
- }, []), K = c(
190
+ }, []), $ = c(
191
191
  (e, r) => {
192
192
  switch (r) {
193
193
  case "recordedOn":
@@ -196,14 +196,14 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
196
196
  return e.recordedBy;
197
197
  case "actions":
198
198
  return f(e) ? /* @__PURE__ */ i(
199
- $,
199
+ z,
200
200
  {
201
201
  label: n("EDIT_OBSERVATION_FORM"),
202
202
  kind: "ghost",
203
203
  size: "sm",
204
204
  testId: `edit-form-${e.encounterUuid}`,
205
205
  onClick: () => F(e),
206
- children: /* @__PURE__ */ i(x, {})
206
+ children: /* @__PURE__ */ i(G, {})
207
207
  }
208
208
  ) : null;
209
209
  default:
@@ -212,31 +212,31 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
212
212
  },
213
213
  [j, F, f, n]
214
214
  );
215
- return /* @__PURE__ */ P(ye, { children: [
216
- /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: U || D || H.length === 0 || C ? /* @__PURE__ */ i(
217
- G,
215
+ return /* @__PURE__ */ x(ye, { children: [
216
+ /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: D || R || H.length === 0 || L ? /* @__PURE__ */ i(
217
+ Q,
218
218
  {
219
219
  headers: he,
220
220
  ariaLabel: n("FORMS_HEADING"),
221
221
  rows: [],
222
- loading: U,
223
- errorStateMessage: D ? oe?.message : void 0,
222
+ loading: D,
223
+ errorStateMessage: R ? oe?.message : void 0,
224
224
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
225
- renderCell: K,
226
- className: T.formsTableBody,
225
+ renderCell: $,
226
+ className: N.formsTableBody,
227
227
  dataTestId: "forms-table"
228
228
  }
229
- ) : /* @__PURE__ */ i(Re, { align: "start", children: H.map((e, r) => {
229
+ ) : /* @__PURE__ */ i(Ce, { align: "start", children: H.map((e, r) => {
230
230
  const { formName: o, records: t } = e, a = fe(t);
231
231
  return /* @__PURE__ */ i(
232
- Ce,
232
+ Le,
233
233
  {
234
234
  title: o,
235
- className: T.customAccordianItem,
235
+ className: N.customAccordianItem,
236
236
  testId: `accordian-title-${o}`,
237
237
  open: r === 0,
238
238
  children: /* @__PURE__ */ i(
239
- G,
239
+ Q,
240
240
  {
241
241
  headers: a,
242
242
  ariaLabel: n("FORMS_HEADING"),
@@ -245,8 +245,8 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
245
245
  errorStateMessage: "",
246
246
  sortable: pe,
247
247
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
248
- renderCell: K,
249
- className: T.formsTableBody,
248
+ renderCell: $,
249
+ className: N.formsTableBody,
250
250
  dataTestId: `forms-table-${o}`
251
251
  }
252
252
  )
@@ -255,25 +255,25 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
255
255
  );
256
256
  }) }) }),
257
257
  y && s && /* @__PURE__ */ i(
258
- Le,
258
+ Ue,
259
259
  {
260
260
  id: "modalIdForActionAreaLayout",
261
261
  portalId: "main-display-area",
262
262
  open: y,
263
- onRequestClose: z,
264
- modalHeading: /* @__PURE__ */ P("div", { className: T.modalHeading, children: [
263
+ onRequestClose: P,
264
+ modalHeading: /* @__PURE__ */ x("div", { className: N.modalHeading, children: [
265
265
  /* @__PURE__ */ i("span", { children: s.formName }),
266
266
  I && f(s) && /* @__PURE__ */ i(
267
- $,
267
+ z,
268
268
  {
269
269
  label: n("EDIT_OBSERVATION_FORM"),
270
270
  kind: "ghost",
271
271
  size: "sm",
272
272
  testId: `edit-form-modal-${s.encounterUuid}`,
273
273
  onClick: () => {
274
- z(), F(s);
274
+ P(), F(s);
275
275
  },
276
- children: /* @__PURE__ */ i(x, {})
276
+ children: /* @__PURE__ */ i(G, {})
277
277
  }
278
278
  )
279
279
  ] }),
@@ -282,7 +282,7 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
282
282
  size: "md",
283
283
  testId: "form-details-modal",
284
284
  children: /* @__PURE__ */ i(
285
- Ue,
285
+ De,
286
286
  {
287
287
  observations: de,
288
288
  isLoading: te || ne,
@@ -301,5 +301,5 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
301
301
  ] });
302
302
  };
303
303
  export {
304
- Qe as default
304
+ Ke as default
305
305
  };
@@ -1,5 +1,5 @@
1
- import { c, T as l, P as m, a as u, D as v, Q as i } from "./YPM2AS64-DJb3J_xq.js";
2
- import { T as d, U as f, Z as e } from "./index-BLBZZpTy.js";
1
+ import { c, T as l, P as m, a as u, D as v, Q as i } from "./YPM2AS64-CR6AklHE.js";
2
+ import { _ as d, $ as f, a0 as e } from "./index-EBKKwOv_.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-DJb3J_xq.js";
2
- import { T as v, U as C, Z as e } from "./index-BLBZZpTy.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-CR6AklHE.js";
2
+ import { _ as v, $ as C, a0 as e } from "./index-EBKKwOv_.js";
3
3
  var h = (t) => {
4
4
  const [r, o] = s({
5
5
  prefix: "TanstackQueryDevtools"
@@ -0,0 +1,246 @@
1
+ import { jsxs as I, jsx as n } from "react/jsx-runtime";
2
+ import { v as M, z, u as B, X as G, b as j, i as H, Q as Y, d as X, j as J, k as P, l as W, o as Z, s as ee, Y as ae, x as se, L as U, B as re, C as te, w as ie, D as oe, M as ne, E as de, G as le } from "./index-EBKKwOv_.js";
3
+ import { useQueries as ue, useQuery as ce } from "@tanstack/react-query";
4
+ import { useRef as pe, useEffect as D, useMemo as g } from "react";
5
+ const me = "Observations-module_observations__RKSyo", be = "Observations-module_title__TJL3z", ve = "Observations-module_wrapper__muk2L", he = "Observations-module_secondary__14nuS", O = {
6
+ observations: me,
7
+ title: be,
8
+ wrapper: ve,
9
+ secondary: he
10
+ }, V = (s, l, o, d, c, r) => {
11
+ const t = re(s, l, c), e = t.value, p = te(e);
12
+ let i = e;
13
+ p === "Image" && (i = /* @__PURE__ */ n(
14
+ ne,
15
+ {
16
+ imageSrc: e,
17
+ alt: e,
18
+ id: `${e}-img`,
19
+ hideThumbnail: r
20
+ }
21
+ )), p === "Video" && (i = /* @__PURE__ */ n(
22
+ de,
23
+ {
24
+ id: `${e}-video`,
25
+ videoSrc: e,
26
+ hideThumbnail: r
27
+ }
28
+ )), p === "PDF" && (i = /* @__PURE__ */ n(le, { id: `${e}-pdf`, src: e }));
29
+ const m = /* @__PURE__ */ I("div", { className: O.wrapper, children: [
30
+ /* @__PURE__ */ n("span", { children: t.header.display }),
31
+ t.header.referenceRange && /* @__PURE__ */ n("span", { className: O.secondary, children: t.header.referenceRange })
32
+ ] }), u = c("OBSERVATIONS_RECORDED_BY", {
33
+ provider: t.provider
34
+ }), b = s.effectiveDateTime ? ie(s.effectiveDateTime, c, !0).formattedResult : void 0, T = /* @__PURE__ */ I("div", { className: O.wrapper, children: [
35
+ /* @__PURE__ */ n("span", { children: u }),
36
+ b && /* @__PURE__ */ n("span", { className: O.secondary, children: b })
37
+ ] }), v = s.display, h = s.observationValue?.isAbnormal ? "abnormal-obs" : "obs", R = d ? `${d}-${h}-${v}-${o}-${l}` : `${h}-${v}-${o}-${l}`;
38
+ return /* @__PURE__ */ n(
39
+ oe,
40
+ {
41
+ header: m,
42
+ value: i,
43
+ info: T,
44
+ id: R,
45
+ testId: R,
46
+ ariaLabel: R
47
+ },
48
+ `obs-${s.id}`
49
+ );
50
+ }, ye = (s, l, o, d, c, r, t) => /* @__PURE__ */ n(
51
+ U,
52
+ {
53
+ title: s.display,
54
+ id: `grouped-obs-${s.display}-${d}`,
55
+ open: o,
56
+ children: s.members?.map(
57
+ (e, p) => V(
58
+ e,
59
+ p,
60
+ c,
61
+ r,
62
+ l,
63
+ t
64
+ )
65
+ )
66
+ },
67
+ `grouped-obs-${s.id}`
68
+ ), Oe = ({
69
+ groupedData: s,
70
+ title: l = "",
71
+ hideThumbnail: o
72
+ }) => {
73
+ const { t: d } = B(), c = (r, t, e) => {
74
+ const p = se(r.encounterDetails, d);
75
+ return /* @__PURE__ */ I(
76
+ U,
77
+ {
78
+ title: p,
79
+ id: `encounter-${r.encounterId}`,
80
+ open: t,
81
+ children: [
82
+ r.observations.map(
83
+ (i, m) => V(
84
+ i,
85
+ m,
86
+ e,
87
+ l,
88
+ d,
89
+ o
90
+ )
91
+ ),
92
+ r.groupedObservations.map(
93
+ (i, m) => ye(
94
+ i,
95
+ d,
96
+ t,
97
+ m,
98
+ e,
99
+ l,
100
+ o
101
+ )
102
+ )
103
+ ]
104
+ },
105
+ `encounter-${r.encounterId}`
106
+ );
107
+ };
108
+ return /* @__PURE__ */ n(
109
+ "div",
110
+ {
111
+ id: "obs-by-encounter",
112
+ "data-testid": "obs-by-encounter-test-id",
113
+ "aria-label": "obs-by-encounter-aria-label",
114
+ children: s.map(
115
+ (r, t) => c(r, t === 0, t)
116
+ )
117
+ }
118
+ );
119
+ }, Re = (s) => ["conceptUuid", s], _e = (s, l, o, d) => [
120
+ "observations",
121
+ s,
122
+ ...l,
123
+ o,
124
+ d
125
+ ], Ie = ({
126
+ config: s,
127
+ episodeOfCareUuids: l,
128
+ encounterUuids: o
129
+ }) => {
130
+ const d = s, {
131
+ conceptNames: c = [],
132
+ conceptUuid: r = [],
133
+ hideThumbnail: t = !1,
134
+ scope: e = "all"
135
+ } = d, p = pe(/* @__PURE__ */ new Set()), i = M(), { addNotification: m } = z(), { t: u } = B(), b = ue({
136
+ queries: c.map((a) => ({
137
+ queryKey: Re(a),
138
+ queryFn: () => G(a),
139
+ enabled: !!a
140
+ }))
141
+ });
142
+ D(() => {
143
+ const a = b.some((x) => x.isError), y = p.current.size > 0;
144
+ a && !y ? (m({
145
+ title: u("ERROR_DEFAULT_TITLE"),
146
+ message: u("ERROR_FETCHING_OBSERVATIONS"),
147
+ type: "error"
148
+ }), p.current.add(0)) : !a && y && p.current.clear();
149
+ }, [b, m, u]);
150
+ const T = g(() => b.map((a) => a.data?.uuid).filter((a) => !!a), [b]), v = g(() => [.../* @__PURE__ */ new Set([...T, ...r])], [T, r]), h = g(() => c.length === 0 ? !0 : b.every((a) => !a.isLoading), [b, c.length]), R = e === "latest" || e === "latest-encounter", w = j(
151
+ l,
152
+ o
153
+ ), {
154
+ data: _,
155
+ isLoading: F,
156
+ isError: S,
157
+ refetch: N
158
+ } = ce({
159
+ queryKey: _e(
160
+ i,
161
+ v,
162
+ o,
163
+ e
164
+ ),
165
+ queryFn: () => R ? H(
166
+ i,
167
+ v,
168
+ o
169
+ ) : Y(
170
+ i,
171
+ v,
172
+ o
173
+ ),
174
+ enabled: !!i && v.length > 0 && h && !w
175
+ });
176
+ X(
177
+ (a) => {
178
+ a.patientUUID === i && a.updatedConcepts.size > 0 && [...a.updatedConcepts.keys()].some(
179
+ (y) => v.includes(y)
180
+ ) && N();
181
+ },
182
+ [i, N]
183
+ ), D(() => {
184
+ S && m({
185
+ title: u("ERROR_DEFAULT_TITLE"),
186
+ message: u("ERROR_FETCHING_OBSERVATIONS"),
187
+ type: "error"
188
+ });
189
+ }, [S]);
190
+ const $ = g(() => {
191
+ if (!_) return [];
192
+ let a = J(_);
193
+ e === "latest-encounter" && (a = P(a));
194
+ const y = W(a);
195
+ return Z(y);
196
+ }, [_, e]), C = [
197
+ { key: "name", header: "name" },
198
+ { key: "value", header: "value" },
199
+ { key: "form", header: "form" }
200
+ ], L = F || !h, A = S && h, K = (!_ || _.entry?.length === 0 || v.length === 0) && h, Q = A ? u("ERROR_FETCHING_OBSERVATIONS") : null, k = K ? u("NO_OBSERVATIONS_FOUND") : void 0, q = $.length > 0 && !L && !A, E = d.titleTranslationKey, f = E ? u(E) : "";
201
+ return /* @__PURE__ */ I(
202
+ "div",
203
+ {
204
+ id: "observations",
205
+ "data-testid": E ? `observations-${f}` : "observations",
206
+ "aria-label": "observations-aria-label",
207
+ className: O.observations,
208
+ children: [
209
+ /* @__PURE__ */ n(
210
+ ee,
211
+ {
212
+ id: "observations-title",
213
+ testId: E ? `observations-title-${f}` : "observations-title",
214
+ title: f,
215
+ className: O.title,
216
+ children: /* @__PURE__ */ n("p", { children: f })
217
+ }
218
+ ),
219
+ q ? /* @__PURE__ */ n(
220
+ Oe,
221
+ {
222
+ groupedData: $,
223
+ title: f,
224
+ hideThumbnail: t
225
+ }
226
+ ) : /* @__PURE__ */ n(
227
+ ae,
228
+ {
229
+ headers: C,
230
+ rows: [],
231
+ ariaLabel: u("OBSERVATIONS"),
232
+ loading: L,
233
+ errorStateMessage: Q,
234
+ emptyStateMessage: k ?? u("NO_OBSERVATIONS_AVAILABLE"),
235
+ dataTestId: "observations-table"
236
+ }
237
+ )
238
+ ]
239
+ }
240
+ );
241
+ };
242
+ export {
243
+ Re as conceptUuidQueryKeys,
244
+ Ie as default,
245
+ _e as observationsQueryKeys
246
+ };