@bahmni/reports-app 0.0.1-dev.445 → 0.0.1-dev.447

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,7 +1,7 @@
1
- import { jsx as d, jsxs as h, Fragment as x } from "react/jsx-runtime";
2
- import { d as G, u as J, z as W, i as Y, J as X, h as Z, $ as ee, a as te } from "./index-BJ2mligI.js";
1
+ import { jsx as d, jsxs as h, Fragment as Y } from "react/jsx-runtime";
2
+ import { d as x, u as G, z as J, J as W, Y as X, h as Z, I as ee, a as te } from "./index-CRUk3_DP.js";
3
3
  import { useQuery as ae } from "@tanstack/react-query";
4
- import { useState as l, useCallback as _, useEffect as I, useMemo as p } from "react";
4
+ import { useState as l, useCallback as _, useEffect as D, useMemo as p } from "react";
5
5
  const ne = "DocumentsTable-module_documentsTableBody__6iR3w", oe = "DocumentsTable-module_viewAttachmentsLink__aQ1on", de = "DocumentsTable-module_documentViewerContainer__F5m8D", re = "DocumentsTable-module_attachmentItem__17KA7", se = "DocumentsTable-module_attachmentCounter__WFiI3", me = "DocumentsTable-module_attachmentError__RI4U2", ce = "DocumentsTable-module_documentIframe__ptq5I", le = "DocumentsTable-module_documentImage__KQVgS", r = {
6
6
  documentsTableBody: ne,
7
7
  viewAttachmentsLink: oe,
@@ -33,12 +33,12 @@ const Te = [
33
33
  "attachments",
34
34
  "uploadedOn",
35
35
  "uploadedBy"
36
- ], he = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, B = (a) => a.attachments.length > 0 ? a.attachments : a.documentUrl ? [{ url: a.documentUrl, contentType: a.contentType }] : [], Ne = ({ config: a, encounterUuids: E }) => {
36
+ ], he = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, B = (a) => a.attachments.length > 0 ? a.attachments : a.documentUrl ? [{ url: a.documentUrl, contentType: a.contentType }] : [], Ie = ({ config: a, encounterUuids: E }) => {
37
37
  const [s, w] = l(!1), [o, U] = l(
38
38
  null
39
39
  ), [$, O] = l(
40
40
  /* @__PURE__ */ new Set()
41
- ), g = G(), { t: n } = J(), { addNotification: L } = W(), k = Number(a?.pageSize) || 5, [f, C] = l(1), [u, V] = l(k), [F, A] = l(void 0), M = _((e) => {
41
+ ), g = x(), { t: n } = G(), { addNotification: L } = J(), k = Number(a?.pageSize) || 5, [f, C] = l(1), [u, V] = l(k), [F, A] = l(void 0), M = _((e) => {
42
42
  U(e), w(!0);
43
43
  }, []), H = _(() => {
44
44
  w(!1), U(null), O(/* @__PURE__ */ new Set());
@@ -53,24 +53,24 @@ const Te = [
53
53
  u
54
54
  ],
55
55
  enabled: !!g,
56
- queryFn: () => Y(
56
+ queryFn: () => W(
57
57
  g,
58
58
  E,
59
59
  u,
60
60
  f
61
61
  )
62
62
  });
63
- I(() => {
63
+ D(() => {
64
64
  i && A(i.total);
65
- }, [i]), I(() => {
65
+ }, [i]), D(() => {
66
66
  C(1), A(void 0);
67
- }, [g]), I(() => {
67
+ }, [g]), D(() => {
68
68
  y && L({
69
69
  title: n("ERROR_DEFAULT_TITLE"),
70
70
  message: b?.message ?? "",
71
71
  type: "error"
72
72
  });
73
- }, [y, b, L, n]), I(() => {
73
+ }, [y, b, L, n]), D(() => {
74
74
  const e = new AbortController();
75
75
  return (async () => {
76
76
  if (!s || !o) return;
@@ -82,8 +82,8 @@ const Te = [
82
82
  method: "HEAD",
83
83
  signal: e.signal
84
84
  })).ok || t.add(c);
85
- } catch (D) {
86
- D instanceof Error && D.name !== "AbortError" && t.add(c);
85
+ } catch (N) {
86
+ N instanceof Error && N.name !== "AbortError" && t.add(c);
87
87
  }
88
88
  }
89
89
  e.signal.aborted || O(t);
@@ -94,15 +94,15 @@ const Te = [
94
94
  t !== u ? (V(t), C(1), A(void 0)) : C(e);
95
95
  },
96
96
  [u]
97
- ), N = p(
97
+ ), I = p(
98
98
  () => a?.fields ?? Te,
99
99
  [a?.fields]
100
- ), j = p(() => [...i?.documents ?? []].sort((e, t) => !e.uploadedOn && !t.uploadedOn ? 0 : e.uploadedOn ? t.uploadedOn ? new Date(t.uploadedOn).getTime() - new Date(e.uploadedOn).getTime() : -1 : 1), [i]), P = p(() => ie(N, n), [N, n]), K = p(
101
- () => N.map((e) => ({
100
+ ), j = p(() => [...i?.documents ?? []].sort((e, t) => !e.uploadedOn && !t.uploadedOn ? 0 : e.uploadedOn ? t.uploadedOn ? new Date(t.uploadedOn).getTime() - new Date(e.uploadedOn).getTime() : -1 : 1), [i]), P = p(() => ie(I, n), [I, n]), K = p(
101
+ () => I.map((e) => ({
102
102
  key: e,
103
103
  sortable: e !== "attachments"
104
104
  })),
105
- [N]
105
+ [I]
106
106
  ), T = p(
107
107
  () => o ? B(o) : [],
108
108
  [o]
@@ -137,7 +137,7 @@ const Te = [
137
137
  },
138
138
  [M, n]
139
139
  );
140
- return /* @__PURE__ */ h(x, { children: [
140
+ return /* @__PURE__ */ h(Y, { children: [
141
141
  /* @__PURE__ */ d("div", { "data-testid": "documents-table", children: /* @__PURE__ */ d(
142
142
  ee,
143
143
  {
@@ -169,8 +169,8 @@ const Te = [
169
169
  size: "lg",
170
170
  testId: "document-view-modal",
171
171
  children: /* @__PURE__ */ d("div", { className: r.documentViewerContainer, children: T.map((e, t) => {
172
- const m = R(e.url), c = e.contentType?.toLowerCase().includes("pdf"), S = (e.contentType?.toLowerCase().includes("image") ?? !1) || he.test(e.url ?? ""), D = $.has(t);
173
- return m === "#" || D ? /* @__PURE__ */ h(
172
+ const m = R(e.url), c = e.contentType?.toLowerCase().includes("pdf"), S = (e.contentType?.toLowerCase().includes("image") ?? !1) || he.test(e.url ?? ""), N = $.has(t);
173
+ return m === "#" || N ? /* @__PURE__ */ h(
174
174
  "div",
175
175
  {
176
176
  className: r.attachmentError,
@@ -223,5 +223,5 @@ const Te = [
223
223
  ] });
224
224
  };
225
225
  export {
226
- Ne as default
226
+ Ie as default
227
227
  };
@@ -1,102 +1,102 @@
1
1
  import { jsx as n, jsxs as q, Fragment as ne } from "react/jsx-runtime";
2
- import { u as ie, d as de, x as le, k as me, H as ue, b as ce, y as fe, e as ye, w as Te, S as he, D as Ne, R as ge, h as pe, L as V, T as $, J as Oe, $ as x, W as be, q as Ie, a as Ee, c as _e, M as Ae } from "./index-BJ2mligI.js";
3
- import { useQueryClient as Le, useQuery as E } from "@tanstack/react-query";
4
- import { useState as K, useMemo as i, useCallback as d } from "react";
5
- const Re = "FormsTable-module_formsTableBody__SvGha", Ce = "FormsTable-module_modalHeading__wnTmA", ve = "FormsTable-module_customAccordianItem__isszs", N = {
6
- formsTableBody: Re,
7
- modalHeading: Ce,
8
- customAccordianItem: ve
9
- }, Be = "startConsultation", Ue = ({
10
- episodeOfCareUuids: _,
2
+ import { u as ie, d as de, y as le, k as me, H as ue, b as ce, m as fe, c as ye, w as he, e as Ne, f as ge, R as Te, h as pe, g as V, i as z, Y as Ie, I as K, U as Oe, W as be, a as Ae, A as Ee, j as _e } from "./index-CRUk3_DP.js";
3
+ import { useQueryClient as Re, useQuery as A } from "@tanstack/react-query";
4
+ import { useState as Y, useMemo as i, useCallback as d } from "react";
5
+ const Ce = "FormsTable-module_formsTableBody__SvGha", ve = "FormsTable-module_modalHeading__wnTmA", Le = "FormsTable-module_customAccordianItem__isszs", g = {
6
+ formsTableBody: Ce,
7
+ modalHeading: ve,
8
+ customAccordianItem: Le
9
+ }, Ue = "startConsultation", Me = ({
10
+ episodeOfCareUuids: E,
11
11
  encounterUuids: l,
12
- config: j,
13
- disableActions: z = !1,
12
+ config: $,
13
+ disableActions: j = !1,
14
14
  activeEncounterUuid: y = null
15
15
  }) => {
16
- const { t: o } = ie(), m = de(), [g, A] = K(!1), [t, L] = K(null), {
17
- numberOfVisits: Q,
18
- hideThumbnail: G = !1,
19
- forms: T
20
- } = j ?? {}, J = le(
21
- Ae.EDIT_OBSERVATIONS
22
- ), { userPrivileges: h } = me(), p = J && !z && !!y, R = ue(
23
- _,
16
+ const { t: o } = ie(), m = de(), [T, _] = Y(!1), [t, R] = Y(null), {
17
+ numberOfVisits: x,
18
+ hideThumbnail: Q = !1,
19
+ forms: h
20
+ } = $ ?? {}, G = le(
21
+ _e.EDIT_OBSERVATIONS
22
+ ), { userPrivileges: N } = me(), p = G && !j && !!y, C = ue(
23
+ E,
24
24
  l
25
- ), P = Le(), {
26
- data: C = [],
27
- isLoading: v,
28
- isError: B,
25
+ ), P = Re(), {
26
+ data: v = [],
27
+ isLoading: L,
28
+ isError: U,
29
29
  error: W,
30
- refetch: Y
31
- } = E({
32
- queryKey: ["forms", m, _],
33
- queryFn: () => ce(m, void 0, Q),
34
- enabled: !!m && !R
35
- }), D = i(() => {
36
- let e = C;
30
+ refetch: J
31
+ } = A({
32
+ queryKey: ["forms", m, E],
33
+ queryFn: () => ce(m, void 0, x),
34
+ enabled: !!m && !C
35
+ }), B = i(() => {
36
+ let e = v;
37
37
  return l && l.length > 0 && (e = e.filter(
38
38
  (r) => l.includes(r.encounterUuid)
39
- )), Array.isArray(T) && T.length > 0 && (e = e.filter(
40
- (r) => T.some((a) => a.toLowerCase() === r.formName.toLowerCase())
39
+ )), Array.isArray(h) && h.length > 0 && (e = e.filter(
40
+ (r) => h.some((a) => a.toLowerCase() === r.formName.toLowerCase())
41
41
  )), e;
42
- }, [C, l, T]), { data: F = [] } = E({
42
+ }, [v, l, h]), { data: F = [] } = A({
43
43
  queryKey: ["observationForms"],
44
44
  queryFn: () => fe()
45
- }), S = d(
45
+ }), D = d(
46
46
  (e) => {
47
47
  const r = F.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 (!N || N.length === 0) return !1;
52
+ const a = new Set(N.map((s) => s.name));
53
53
  return r.privileges.some(
54
54
  (s) => a.has(s.privilegeName) && s.editable
55
55
  );
56
56
  },
57
- [F, h]
57
+ [F, N]
58
58
  ), u = d(
59
- (e) => !y || e.encounterUuid !== y ? !1 : S(e.formName),
60
- [y, S]
59
+ (e) => !y || e.encounterUuid !== y ? !1 : D(e.formName),
60
+ [y, D]
61
61
  ), {
62
- data: O,
62
+ data: I,
63
63
  isLoading: X,
64
64
  isError: Z,
65
- error: b
66
- } = E({
65
+ error: O
66
+ } = A({
67
67
  queryKey: ["formsEncounterFHIR", t?.encounterUuid],
68
68
  queryFn: () => ye(t.encounterUuid),
69
- enabled: !!t?.encounterUuid && g
69
+ enabled: !!t?.encounterUuid && T
70
70
  });
71
- Te(
71
+ he(
72
72
  (e) => {
73
- e.patientUUID === m && (Y(), P.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
73
+ e.patientUUID === m && (J(), 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) ? Ne(e)?.toLowerCase() === t.formName.toLowerCase() : !0), [O, t?.formName]), re = i(() => {
78
- if (b)
79
- return ge(b).message;
80
- }, [b]), c = i(
77
+ const ee = i(() => !I?.entry || !t?.formName ? [] : I.entry.filter((e) => e.resource?.resourceType === "Observation").map((e) => e.resource).filter((e) => Ne(e) ? ge(e)?.toLowerCase() === t.formName.toLowerCase() : !0), [I, t?.formName]), re = i(() => {
78
+ if (O)
79
+ return Te(O).message;
80
+ }, [O]), c = i(
81
81
  () => [
82
82
  { key: "recordedOn", header: o("RECORDED_ON") },
83
83
  { key: "recordedBy", header: o("RECORDED_BY") }
84
84
  ],
85
85
  [o]
86
- ), M = i(
86
+ ), S = i(
87
87
  () => [...c, { key: "actions", header: o("ACTIONS") }],
88
88
  [c, o]
89
89
  ), ae = d(
90
- (e) => p && e.some((r) => u(r)) ? M : c,
91
- [p, u, M, c]
90
+ (e) => p && e.some((r) => u(r)) ? S : c,
91
+ [p, u, S, c]
92
92
  ), oe = c, te = i(
93
93
  () => [
94
94
  { key: "recordedOn", sortable: !0 },
95
95
  { key: "recordedBy", sortable: !0 }
96
96
  ],
97
97
  []
98
- ), U = i(() => {
99
- const e = D.reduce(
98
+ ), M = i(() => {
99
+ const e = B.reduce(
100
100
  (r, a) => {
101
101
  const s = a.formName;
102
102
  r[s] ??= [];
@@ -120,13 +120,13 @@ const Re = "FormsTable-module_formsTableBody__SvGha", Ce = "FormsTable-module_mo
120
120
  )
121
121
  })
122
122
  ).sort((r, a) => r.formName.localeCompare(a.formName));
123
- }, [D, o]), k = d((e) => {
124
- L(e), A(!0);
123
+ }, [B, o]), k = d((e) => {
124
+ R(e), _(!0);
125
125
  }, []), w = d(() => {
126
- A(!1), L(null);
127
- }, []), I = d((e) => {
126
+ _(!1), R(null);
127
+ }, []), b = d((e) => {
128
128
  globalThis.dispatchEvent(
129
- new CustomEvent(Be, {
129
+ new CustomEvent(Ue, {
130
130
  detail: {
131
131
  editOnly: "observationForms",
132
132
  editTitle: "EDIT_OBSERVATION_FORM_TITLE",
@@ -140,7 +140,7 @@ const Re = "FormsTable-module_formsTableBody__SvGha", Ce = "FormsTable-module_mo
140
140
  (e, r) => {
141
141
  switch (r) {
142
142
  case "recordedOn":
143
- return /* @__PURE__ */ n(Oe, { onClick: () => k(e), children: e.recordedOn });
143
+ return /* @__PURE__ */ n(Ie, { onClick: () => k(e), children: e.recordedOn });
144
144
  case "recordedBy":
145
145
  return e.recordedBy;
146
146
  case "actions":
@@ -151,41 +151,41 @@ const Re = "FormsTable-module_formsTableBody__SvGha", Ce = "FormsTable-module_mo
151
151
  kind: "ghost",
152
152
  size: "sm",
153
153
  testId: `edit-form-${e.encounterUuid}`,
154
- onClick: () => I(e),
155
- children: /* @__PURE__ */ n($, {})
154
+ onClick: () => b(e),
155
+ children: /* @__PURE__ */ n(z, {})
156
156
  }
157
157
  ) : null;
158
158
  default:
159
159
  return null;
160
160
  }
161
161
  },
162
- [k, I, u, o]
162
+ [k, b, u, o]
163
163
  );
164
164
  return /* @__PURE__ */ q(ne, { children: [
165
- /* @__PURE__ */ n("div", { id: "forms-table", "data-testid": "forms-table", children: v || B || U.length === 0 || R ? /* @__PURE__ */ n(
166
- x,
165
+ /* @__PURE__ */ n("div", { id: "forms-table", "data-testid": "forms-table", children: L || U || M.length === 0 || C ? /* @__PURE__ */ n(
166
+ K,
167
167
  {
168
168
  headers: oe,
169
169
  ariaLabel: o("FORMS_HEADING"),
170
170
  rows: [],
171
- loading: v,
172
- errorStateMessage: B ? W?.message : void 0,
171
+ loading: L,
172
+ errorStateMessage: U ? W?.message : void 0,
173
173
  emptyStateMessage: o("FORMS_UNAVAILABLE"),
174
174
  renderCell: H,
175
- className: N.formsTableBody,
175
+ className: g.formsTableBody,
176
176
  dataTestId: "forms-table"
177
177
  }
178
- ) : /* @__PURE__ */ n(be, { align: "start", children: U.map((e, r) => {
178
+ ) : /* @__PURE__ */ n(Oe, { align: "start", children: M.map((e, r) => {
179
179
  const { formName: a, records: s } = e, f = ae(s);
180
180
  return /* @__PURE__ */ n(
181
- Ie,
181
+ be,
182
182
  {
183
183
  title: a,
184
- className: N.customAccordianItem,
184
+ className: g.customAccordianItem,
185
185
  testId: `accordian-title-${a}`,
186
186
  open: r === 0,
187
187
  children: /* @__PURE__ */ n(
188
- x,
188
+ K,
189
189
  {
190
190
  headers: f,
191
191
  ariaLabel: o("FORMS_HEADING"),
@@ -195,7 +195,7 @@ const Re = "FormsTable-module_formsTableBody__SvGha", Ce = "FormsTable-module_mo
195
195
  sortable: te,
196
196
  emptyStateMessage: o("FORMS_UNAVAILABLE"),
197
197
  renderCell: H,
198
- className: N.formsTableBody,
198
+ className: g.formsTableBody,
199
199
  dataTestId: `forms-table-${a}`
200
200
  }
201
201
  )
@@ -203,14 +203,14 @@ const Re = "FormsTable-module_formsTableBody__SvGha", Ce = "FormsTable-module_mo
203
203
  a
204
204
  );
205
205
  }) }) }),
206
- g && t && /* @__PURE__ */ n(
207
- Ee,
206
+ T && t && /* @__PURE__ */ n(
207
+ Ae,
208
208
  {
209
209
  id: "modalIdForActionAreaLayout",
210
210
  portalId: "main-display-area",
211
- open: g,
211
+ open: T,
212
212
  onRequestClose: w,
213
- modalHeading: /* @__PURE__ */ q("div", { className: N.modalHeading, children: [
213
+ modalHeading: /* @__PURE__ */ q("div", { className: g.modalHeading, children: [
214
214
  /* @__PURE__ */ n("span", { children: t.formName }),
215
215
  p && u(t) && /* @__PURE__ */ n(
216
216
  V,
@@ -220,9 +220,9 @@ const Re = "FormsTable-module_formsTableBody__SvGha", Ce = "FormsTable-module_mo
220
220
  size: "sm",
221
221
  testId: `edit-form-modal-${t.encounterUuid}`,
222
222
  onClick: () => {
223
- w(), I(t);
223
+ w(), b(t);
224
224
  },
225
- children: /* @__PURE__ */ n($, {})
225
+ children: /* @__PURE__ */ n(z, {})
226
226
  }
227
227
  )
228
228
  ] }),
@@ -231,7 +231,7 @@ const Re = "FormsTable-module_formsTableBody__SvGha", Ce = "FormsTable-module_mo
231
231
  size: "md",
232
232
  testId: "form-details-modal",
233
233
  children: /* @__PURE__ */ n(
234
- _e,
234
+ Ee,
235
235
  {
236
236
  observations: ee,
237
237
  isLoading: X,
@@ -239,7 +239,7 @@ const Re = "FormsTable-module_formsTableBody__SvGha", Ce = "FormsTable-module_mo
239
239
  errorMessage: re,
240
240
  emptyStateMessage: o("NO_FORM_DATA_AVAILABLE"),
241
241
  testIdPrefix: t.formName,
242
- hideThumbnail: G,
242
+ hideThumbnail: Q,
243
243
  formName: t.formName
244
244
  }
245
245
  )
@@ -248,5 +248,5 @@ const Re = "FormsTable-module_formsTableBody__SvGha", Ce = "FormsTable-module_mo
248
248
  ] });
249
249
  };
250
250
  export {
251
- Ue as default
251
+ Me as default
252
252
  };
@@ -1,5 +1,5 @@
1
- import { c, T as l, P as m, a as i, D as u, Q as v } from "./YPM2AS64-C3mxeOxI.js";
2
- import { ag as d, ah as f, ai as e } from "./index-BJ2mligI.js";
1
+ import { c, T as l, P as m, a as i, D as u, Q as v } from "./YPM2AS64-BwqZqUlj.js";
2
+ import { ag as d, ah as f, ai as e } from "./index-CRUk3_DP.js";
3
3
  var h = (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 i, a as u, b as m, C as P, Q as d } from "./YPM2AS64-C3mxeOxI.js";
2
- import { ag as h, ah as v, ai as e } from "./index-BJ2mligI.js";
1
+ import { c as s, T as c, P as i, a as u, b as m, C as P, Q as d } from "./YPM2AS64-BwqZqUlj.js";
2
+ import { ag as h, ah as v, ai as e } from "./index-CRUk3_DP.js";
3
3
  var C = (t) => {
4
4
  const [r, o] = s({
5
5
  prefix: "TanstackQueryDevtools"