@bahmni/reports-app 0.0.1-dev.461 → 0.0.1-dev.462

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,83 +1,83 @@
1
- import { jsx as n, jsxs as q, Fragment as ne } from "react/jsx-runtime";
2
- import { a as ie, u as de, i as le, Z as me, V as ue, f as ce, g as fe, j as ye, w as Ne, $ as he, A as ge, R as Te, h as Ie, U as H, k as K, K as Oe, I as $, W as pe, l as be, e as Ae, m as Ee, y as _e } from "./index-CGSYweTe.js";
3
- import { useQueryClient as Re, useQuery as A } from "@tanstack/react-query";
1
+ import { jsx as n, jsxs as H, Fragment as ne } from "react/jsx-runtime";
2
+ import { a as ie, u as de, s as le, Z as me, f as ue, W as ce, y as fe, v as ye, w as Ne, k as ge, g as pe, i as he, h as be, N as Ae, q as K, C as V, K as Ie, I as $, j as Oe, l as Te, b as _e, A as Ce, m as Ee } from "./index-By5r-Flz.js";
3
+ import { useQueryClient as ve, useQuery as T } from "@tanstack/react-query";
4
4
  import { useState as j, useMemo as i, useCallback as d } from "react";
5
- const ve = "FormsTable-module_formsTableBody__SvGha", Ce = "FormsTable-module_modalHeading__wnTmA", Ue = "FormsTable-module_customAccordianItem__isszs", g = {
6
- formsTableBody: ve,
7
- modalHeading: Ce,
8
- customAccordianItem: Ue
9
- }, Le = "startConsultation", Me = ({
10
- episodeOfCareUuids: E,
5
+ const Le = "FormsTable-module_formsTableBody__SvGha", Be = "FormsTable-module_modalHeading__wnTmA", Fe = "FormsTable-module_customAccordianItem__isszs", p = {
6
+ formsTableBody: Le,
7
+ modalHeading: Be,
8
+ customAccordianItem: Fe
9
+ }, Me = ({
10
+ episodeOfCareUuids: _,
11
11
  encounterUuids: l,
12
- config: z,
13
- disableActions: x = !1,
12
+ config: x,
13
+ disableActions: z = !1,
14
14
  activeEncounterUuid: y = null
15
15
  }) => {
16
- const { t: o } = ie(), m = de(), [T, _] = j(!1), [t, R] = j(null), {
16
+ const { t: o } = ie(), m = de(), [h, C] = j(!1), [t, E] = j(null), {
17
17
  numberOfVisits: G,
18
- hideThumbnail: Z = !1,
18
+ hideThumbnail: Q = !1,
19
19
  forms: N
20
- } = z ?? {}, Q = le(
21
- _e.EDIT_OBSERVATIONS
22
- ), { userPrivileges: h } = me(), I = Q && !x && !!y, v = ue(
23
- E,
20
+ } = x ?? {}, Z = le(
21
+ Ee.EDIT_OBSERVATIONS
22
+ ), { userPrivileges: g } = me(), b = Z && !z && !!y, v = ue(
23
+ _,
24
24
  l
25
- ), W = Re(), {
26
- data: C = [],
27
- isLoading: U,
28
- isError: L,
29
- error: P,
30
- refetch: X
31
- } = A({
32
- queryKey: ["forms", m, E],
25
+ ), P = ve(), {
26
+ data: L = [],
27
+ isLoading: B,
28
+ isError: F,
29
+ error: W,
30
+ refetch: Y
31
+ } = T({
32
+ queryKey: ["forms", m, _],
33
33
  queryFn: () => ce(m, void 0, G),
34
34
  enabled: !!m && !v
35
- }), F = i(() => {
36
- let e = C;
35
+ }), R = i(() => {
36
+ let e = L;
37
37
  return l && l.length > 0 && (e = e.filter(
38
38
  (r) => l.includes(r.encounterUuid)
39
39
  )), Array.isArray(N) && N.length > 0 && (e = e.filter(
40
40
  (r) => N.some((a) => a.toLowerCase() === r.formName.toLowerCase())
41
41
  )), e;
42
- }, [C, l, N]), { data: B = [] } = A({
42
+ }, [L, l, N]), { data: U = [] } = T({
43
43
  queryKey: ["observationForms"],
44
44
  queryFn: () => fe()
45
45
  }), D = d(
46
46
  (e) => {
47
- const r = B.find(
47
+ const r = U.find(
48
48
  (s) => s.name.toLowerCase() === e.toLowerCase()
49
49
  );
50
50
  if (!r?.privileges || r.privileges.length === 0) return !0;
51
- if (!h || h.length === 0) return !1;
52
- const a = new Set(h.map((s) => s.name));
51
+ if (!g || g.length === 0) return !1;
52
+ const a = new Set(g.map((s) => s.name));
53
53
  return r.privileges.some(
54
54
  (s) => a.has(s.privilegeName) && s.editable
55
55
  );
56
56
  },
57
- [B, h]
57
+ [U, g]
58
58
  ), u = d(
59
59
  (e) => !y || e.encounterUuid !== y ? !1 : D(e.formName),
60
60
  [y, D]
61
61
  ), {
62
- data: O,
63
- isLoading: Y,
64
- isError: J,
65
- error: p
66
- } = A({
62
+ data: A,
63
+ isLoading: J,
64
+ isError: X,
65
+ error: I
66
+ } = T({
67
67
  queryKey: ["formsEncounterFHIR", t?.encounterUuid],
68
68
  queryFn: () => ye(t.encounterUuid),
69
- enabled: !!t?.encounterUuid && T
69
+ enabled: !!t?.encounterUuid && h
70
70
  });
71
71
  Ne(
72
72
  (e) => {
73
- e.patientUUID === m && (X(), W.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
73
+ e.patientUUID === m && (Y(), P.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
74
74
  },
75
75
  [m]
76
76
  );
77
- const ee = i(() => !O?.entry || !t?.formName ? [] : O.entry.filter((e) => e.resource?.resourceType === "Observation").map((e) => e.resource).filter((e) => he(e) ? ge(e)?.toLowerCase() === t.formName.toLowerCase() : !0), [O, t?.formName]), re = i(() => {
78
- if (p)
79
- return Te(p).message;
80
- }, [p]), c = i(
77
+ const ee = i(() => !A?.entry || !t?.formName ? [] : A.entry.filter((e) => e.resource?.resourceType === "Observation").map((e) => e.resource).filter((e) => ge(e) ? pe(e)?.toLowerCase() === t.formName.toLowerCase() : !0), [A, t?.formName]), re = i(() => {
78
+ if (I)
79
+ return he(I).message;
80
+ }, [I]), c = i(
81
81
  () => [
82
82
  { key: "recordedOn", header: o("RECORDED_ON") },
83
83
  { key: "recordedBy", header: o("RECORDED_BY") }
@@ -87,8 +87,8 @@ const ve = "FormsTable-module_formsTableBody__SvGha", Ce = "FormsTable-module_mo
87
87
  () => [...c, { key: "actions", header: o("ACTIONS") }],
88
88
  [c, o]
89
89
  ), ae = d(
90
- (e) => I && e.some((r) => u(r)) ? S : c,
91
- [I, u, S, c]
90
+ (e) => b && e.some((r) => u(r)) ? S : c,
91
+ [b, u, S, c]
92
92
  ), oe = c, te = i(
93
93
  () => [
94
94
  { key: "recordedOn", sortable: !0 },
@@ -96,7 +96,7 @@ const ve = "FormsTable-module_formsTableBody__SvGha", Ce = "FormsTable-module_mo
96
96
  ],
97
97
  []
98
98
  ), M = i(() => {
99
- const e = F.reduce(
99
+ const e = R.reduce(
100
100
  (r, a) => {
101
101
  const s = a.formName;
102
102
  r[s] ??= [];
@@ -104,7 +104,7 @@ const ve = "FormsTable-module_formsTableBody__SvGha", Ce = "FormsTable-module_mo
104
104
  return r[s].push({
105
105
  id: a.encounterUuid,
106
106
  formName: a.formName,
107
- recordedOn: Ie(a.encounterDateTime, o, !0).formattedResult,
107
+ recordedOn: be(a.encounterDateTime, o, !0).formattedResult,
108
108
  recordedBy: f ?? "--",
109
109
  encounterDateTime: a.encounterDateTime,
110
110
  encounterUuid: a.encounterUuid
@@ -120,68 +120,65 @@ const ve = "FormsTable-module_formsTableBody__SvGha", Ce = "FormsTable-module_mo
120
120
  )
121
121
  })
122
122
  ).sort((r, a) => r.formName.localeCompare(a.formName));
123
- }, [F, o]), w = d((e) => {
124
- R(e), _(!0);
125
- }, []), k = d(() => {
126
- _(!1), R(null);
127
- }, []), b = d((e) => {
128
- globalThis.dispatchEvent(
129
- new CustomEvent(Le, {
130
- detail: {
131
- editOnly: "observationForms",
132
- editTitle: "EDIT_OBSERVATION_FORM_TITLE",
133
- sourceEncounterUuid: e.encounterUuid,
134
- formName: e.formName,
135
- directFormMode: !0
136
- }
137
- })
138
- );
139
- }, []), V = d(
123
+ }, [R, o]), k = d((e) => {
124
+ E(e), C(!0);
125
+ }, []), w = d(() => {
126
+ C(!1), E(null);
127
+ }, []), O = d((e) => {
128
+ Ae({
129
+ context: {
130
+ encounter: { resourceType: "Encounter", id: e.encounterUuid },
131
+ formName: e.formName,
132
+ directFormMode: !0
133
+ },
134
+ action: { type: "update", resourceType: "Observation" }
135
+ });
136
+ }, []), q = d(
140
137
  (e, r) => {
141
138
  switch (r) {
142
139
  case "recordedOn":
143
- return /* @__PURE__ */ n(Oe, { onClick: () => w(e), children: e.recordedOn });
140
+ return /* @__PURE__ */ n(Ie, { onClick: () => k(e), children: e.recordedOn });
144
141
  case "recordedBy":
145
142
  return e.recordedBy;
146
143
  case "actions":
147
144
  return u(e) ? /* @__PURE__ */ n(
148
- H,
145
+ K,
149
146
  {
150
147
  label: o("EDIT_OBSERVATION_FORM"),
151
148
  kind: "ghost",
152
149
  size: "sm",
153
150
  testId: `edit-form-${e.encounterUuid}`,
154
- onClick: () => b(e),
155
- children: /* @__PURE__ */ n(K, {})
151
+ onClick: () => O(e),
152
+ children: /* @__PURE__ */ n(V, {})
156
153
  }
157
154
  ) : null;
158
155
  default:
159
156
  return null;
160
157
  }
161
158
  },
162
- [w, b, u, o]
159
+ [k, O, u, o]
163
160
  );
164
- return /* @__PURE__ */ q(ne, { children: [
165
- /* @__PURE__ */ n("div", { id: "forms-table", "data-testid": "forms-table", children: U || L || M.length === 0 || v ? /* @__PURE__ */ n(
161
+ return /* @__PURE__ */ H(ne, { children: [
162
+ /* @__PURE__ */ n("div", { id: "forms-table", "data-testid": "forms-table", children: B || F || M.length === 0 || v ? /* @__PURE__ */ n(
166
163
  $,
167
164
  {
168
165
  headers: oe,
169
166
  ariaLabel: o("FORMS_HEADING"),
170
167
  rows: [],
171
- loading: U,
172
- errorStateMessage: L ? P?.message : void 0,
168
+ loading: B,
169
+ errorStateMessage: F ? W?.message : void 0,
173
170
  emptyStateMessage: o("FORMS_UNAVAILABLE"),
174
- renderCell: V,
175
- className: g.formsTableBody,
171
+ renderCell: q,
172
+ className: p.formsTableBody,
176
173
  dataTestId: "forms-table"
177
174
  }
178
- ) : /* @__PURE__ */ n(pe, { align: "start", children: M.map((e, r) => {
175
+ ) : /* @__PURE__ */ n(Oe, { align: "start", children: M.map((e, r) => {
179
176
  const { formName: a, records: s } = e, f = ae(s);
180
177
  return /* @__PURE__ */ n(
181
- be,
178
+ Te,
182
179
  {
183
180
  title: a,
184
- className: g.customAccordianItem,
181
+ className: p.customAccordianItem,
185
182
  testId: `accordian-title-${a}`,
186
183
  open: r === 0,
187
184
  children: /* @__PURE__ */ n(
@@ -194,8 +191,8 @@ const ve = "FormsTable-module_formsTableBody__SvGha", Ce = "FormsTable-module_mo
194
191
  errorStateMessage: "",
195
192
  sortable: te,
196
193
  emptyStateMessage: o("FORMS_UNAVAILABLE"),
197
- renderCell: V,
198
- className: g.formsTableBody,
194
+ renderCell: q,
195
+ className: p.formsTableBody,
199
196
  dataTestId: `forms-table-${a}`
200
197
  }
201
198
  )
@@ -203,26 +200,26 @@ const ve = "FormsTable-module_formsTableBody__SvGha", Ce = "FormsTable-module_mo
203
200
  a
204
201
  );
205
202
  }) }) }),
206
- T && t && /* @__PURE__ */ n(
207
- Ae,
203
+ h && t && /* @__PURE__ */ n(
204
+ _e,
208
205
  {
209
206
  id: "modalIdForActionAreaLayout",
210
207
  portalId: "main-display-area",
211
- open: T,
212
- onRequestClose: k,
213
- modalHeading: /* @__PURE__ */ q("div", { className: g.modalHeading, children: [
208
+ open: h,
209
+ onRequestClose: w,
210
+ modalHeading: /* @__PURE__ */ H("div", { className: p.modalHeading, children: [
214
211
  /* @__PURE__ */ n("span", { children: t.formName }),
215
- I && u(t) && /* @__PURE__ */ n(
216
- H,
212
+ b && u(t) && /* @__PURE__ */ n(
213
+ K,
217
214
  {
218
215
  label: o("EDIT_OBSERVATION_FORM"),
219
216
  kind: "ghost",
220
217
  size: "sm",
221
218
  testId: `edit-form-modal-${t.encounterUuid}`,
222
219
  onClick: () => {
223
- k(), b(t);
220
+ w(), O(t);
224
221
  },
225
- children: /* @__PURE__ */ n(K, {})
222
+ children: /* @__PURE__ */ n(V, {})
226
223
  }
227
224
  )
228
225
  ] }),
@@ -231,15 +228,15 @@ const ve = "FormsTable-module_formsTableBody__SvGha", Ce = "FormsTable-module_mo
231
228
  size: "md",
232
229
  testId: "form-details-modal",
233
230
  children: /* @__PURE__ */ n(
234
- Ee,
231
+ Ce,
235
232
  {
236
233
  observations: ee,
237
- isLoading: Y,
238
- isError: J,
234
+ isLoading: J,
235
+ isError: X,
239
236
  errorMessage: re,
240
237
  emptyStateMessage: o("NO_FORM_DATA_AVAILABLE"),
241
238
  testIdPrefix: t.formName,
242
- hideThumbnail: Z,
239
+ hideThumbnail: Q,
243
240
  formName: t.formName
244
241
  }
245
242
  )
@@ -1,5 +1,5 @@
1
- import { c, T as l, P as m, a as u, D as v, Q as i } from "./YPM2AS64-BxqTs3Oh.js";
2
- import { at as d, au as f, av as e } from "./index-CGSYweTe.js";
1
+ import { c, T as l, P as m, a as u, D as v, Q as i } from "./YPM2AS64-DUGB6Q1i.js";
2
+ import { au as d, av as f, aw as e } from "./index-By5r-Flz.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-BxqTs3Oh.js";
2
- import { at as v, au as C, av as e } from "./index-CGSYweTe.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-DUGB6Q1i.js";
2
+ import { au as v, av as C, aw as e } from "./index-By5r-Flz.js";
3
3
  var h = (t) => {
4
4
  const [r, o] = s({
5
5
  prefix: "TanstackQueryDevtools"
@@ -1,5 +1,5 @@
1
1
  import { jsxs as S, jsx as n } from "react/jsx-runtime";
2
- import { u as z, z as Q, a as V, n as M, V as G, o as H, Y, w as j, p as J, q as P, r as W, s as X, d as ee, I as ae, t as se, v as B, x as te, B as re, h as ie, C as oe, D as ne, E as de, F as le } from "./index-CGSYweTe.js";
2
+ import { u as z, z as M, a as U, n as Q, f as H, o as G, U as j, w as P, r as J, x as Y, B as W, D as X, p as ee, I as ae, E as se, F as V, H as te, M as re, h as ie, P as oe, S as ne, T as de, V as le } from "./index-By5r-Flz.js";
3
3
  import { useQueries as ue, useQuery as ce } from "@tanstack/react-query";
4
4
  import { useRef as pe, useEffect as L, useMemo as g } from "react";
5
5
  const me = "Observations-module_observations__RKSyo", be = "Observations-module_title__TJL3z", he = "Observations-module_wrapper__muk2L", ve = "Observations-module_secondary__14nuS", O = {
@@ -7,7 +7,7 @@ const me = "Observations-module_observations__RKSyo", be = "Observations-module_
7
7
  title: be,
8
8
  wrapper: he,
9
9
  secondary: ve
10
- }, F = (s, l, o, d, c, t) => {
10
+ }, B = (s, l, o, d, c, t) => {
11
11
  const r = te(s, l, c), e = r.value, p = re(e);
12
12
  let i = e;
13
13
  p === "Image" && (i = /* @__PURE__ */ n(
@@ -48,13 +48,13 @@ const me = "Observations-module_observations__RKSyo", be = "Observations-module_
48
48
  `obs-${s.id}`
49
49
  );
50
50
  }, ye = (s, l, o, d, c, t, r) => /* @__PURE__ */ n(
51
- B,
51
+ V,
52
52
  {
53
53
  title: s.display,
54
54
  id: `grouped-obs-${s.display}-${d}`,
55
55
  open: o,
56
56
  children: s.members?.map(
57
- (e, p) => F(
57
+ (e, p) => B(
58
58
  e,
59
59
  p,
60
60
  c,
@@ -70,17 +70,17 @@ const me = "Observations-module_observations__RKSyo", be = "Observations-module_
70
70
  title: l = "",
71
71
  hideThumbnail: o
72
72
  }) => {
73
- const { t: d } = V(), c = (t, r, e) => {
73
+ const { t: d } = U(), c = (t, r, e) => {
74
74
  const p = se(t.encounterDetails, d);
75
75
  return /* @__PURE__ */ S(
76
- B,
76
+ V,
77
77
  {
78
78
  title: p,
79
79
  id: `encounter-${t.encounterId}`,
80
80
  open: r,
81
81
  children: [
82
82
  t.observations.map(
83
- (i, m) => F(
83
+ (i, m) => B(
84
84
  i,
85
85
  m,
86
86
  e,
@@ -132,10 +132,10 @@ const me = "Observations-module_observations__RKSyo", be = "Observations-module_
132
132
  conceptUuid: t = [],
133
133
  hideThumbnail: r = !1,
134
134
  scope: e = "all"
135
- } = d, p = pe(/* @__PURE__ */ new Set()), i = z(), { addNotification: m } = Q(), { t: u } = V(), b = ue({
135
+ } = d, p = pe(/* @__PURE__ */ new Set()), i = z(), { addNotification: m } = M(), { t: u } = U(), b = ue({
136
136
  queries: c.map((a) => ({
137
137
  queryKey: Re(a),
138
- queryFn: () => M(a),
138
+ queryFn: () => Q(a),
139
139
  enabled: !!a
140
140
  }))
141
141
  });
@@ -147,14 +147,14 @@ const me = "Observations-module_observations__RKSyo", be = "Observations-module_
147
147
  type: "error"
148
148
  }), p.current.add(0)) : !a && y && p.current.clear();
149
149
  }, [b, m, u]);
150
- const T = g(() => b.map((a) => a.data?.uuid).filter((a) => !!a), [b]), h = g(() => [.../* @__PURE__ */ new Set([...T, ...t])], [T, t]), v = g(() => c.length === 0 ? !0 : b.every((a) => !a.isLoading), [b, c.length]), R = e === "latest" || e === "latest-encounter", U = G(
150
+ const T = g(() => b.map((a) => a.data?.uuid).filter((a) => !!a), [b]), h = g(() => [.../* @__PURE__ */ new Set([...T, ...t])], [T, t]), v = g(() => c.length === 0 ? !0 : b.every((a) => !a.isLoading), [b, c.length]), R = e === "latest" || e === "latest-encounter", w = H(
151
151
  l,
152
152
  o
153
153
  ), {
154
154
  data: _,
155
- isLoading: k,
156
- isError: I,
157
- refetch: N
155
+ isLoading: F,
156
+ isError: N,
157
+ refetch: I
158
158
  } = ce({
159
159
  queryKey: _e(
160
160
  i,
@@ -162,42 +162,42 @@ const me = "Observations-module_observations__RKSyo", be = "Observations-module_
162
162
  o,
163
163
  e
164
164
  ),
165
- queryFn: () => R ? H(
165
+ queryFn: () => R ? G(
166
166
  i,
167
167
  h,
168
168
  o
169
- ) : Y(
169
+ ) : j(
170
170
  i,
171
171
  h,
172
172
  o
173
173
  ),
174
- enabled: !!i && h.length > 0 && v && !U
174
+ enabled: !!i && h.length > 0 && v && !w
175
175
  });
176
- j(
176
+ P(
177
177
  (a) => {
178
178
  a.patientUUID === i && a.updatedConcepts.size > 0 && [...a.updatedConcepts.keys()].some(
179
179
  (y) => h.includes(y)
180
- ) && N();
180
+ ) && I();
181
181
  },
182
- [i, N]
182
+ [i, I]
183
183
  ), L(() => {
184
- I && m({
184
+ N && m({
185
185
  title: u("ERROR_DEFAULT_TITLE"),
186
186
  message: u("ERROR_FETCHING_OBSERVATIONS"),
187
187
  type: "error"
188
188
  });
189
- }, [I]);
189
+ }, [N]);
190
190
  const $ = g(() => {
191
191
  if (!_) return [];
192
192
  let a = J(_);
193
- e === "latest-encounter" && (a = P(a));
193
+ e === "latest-encounter" && (a = Y(a));
194
194
  const y = W(a);
195
195
  return X(y);
196
- }, [_, e]), w = [
196
+ }, [_, e]), k = [
197
197
  { key: "name", header: "name" },
198
198
  { key: "value", header: "value" },
199
199
  { key: "form", header: "form" }
200
- ], A = k || !v, D = I && v, C = (!_ || _.entry?.length === 0 || h.length === 0) && v, q = D ? u("ERROR_FETCHING_OBSERVATIONS") : null, x = C ? u("NO_OBSERVATIONS_FOUND") : void 0, K = $.length > 0 && !A && !D, E = d.titleTranslationKey, f = E ? u(E) : "";
200
+ ], A = F || !v, D = N && v, q = (!_ || _.entry?.length === 0 || h.length === 0) && v, x = D ? u("ERROR_FETCHING_OBSERVATIONS") : null, C = q ? u("NO_OBSERVATIONS_FOUND") : void 0, K = $.length > 0 && !A && !D, E = d.titleTranslationKey, f = E ? u(E) : "";
201
201
  return /* @__PURE__ */ S(
202
202
  "div",
203
203
  {
@@ -226,12 +226,12 @@ const me = "Observations-module_observations__RKSyo", be = "Observations-module_
226
226
  ) : /* @__PURE__ */ n(
227
227
  ae,
228
228
  {
229
- headers: w,
229
+ headers: k,
230
230
  rows: [],
231
231
  ariaLabel: u("OBSERVATIONS"),
232
232
  loading: A,
233
- errorStateMessage: q,
234
- emptyStateMessage: x ?? u("NO_OBSERVATIONS_AVAILABLE"),
233
+ errorStateMessage: x,
234
+ emptyStateMessage: C ?? u("NO_OBSERVATIONS_AVAILABLE"),
235
235
  dataTestId: "observations-table"
236
236
  }
237
237
  )