@bahmni/widgets 0.0.1-dev.388 → 0.0.1-dev.390

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 T, Fragment as Y } from "react/jsx-runtime";
2
- import { u as W, a as X, O as J, m as Z, U as x, b as ee, F as te } from "./index-BLFDusgt.js";
2
+ import { u as W, a as X, N as J, m as Z, V as x, b as ee, F as te } from "./index-D5lvSY7S.js";
3
3
  import { useQuery as ne } from "@tanstack/react-query";
4
4
  import { useState as l, useCallback as _, useEffect as I, useMemo as p } from "react";
5
5
  import { useTranslation as ae } from "react-i18next";
@@ -35,22 +35,22 @@ const Te = [
35
35
  "uploadedOn",
36
36
  "uploadedBy"
37
37
  ], _e = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, B = (n) => n.attachments.length > 0 ? n.attachments : n.documentUrl ? [{ url: n.documentUrl, contentType: n.contentType }] : [], Ie = ({ config: n, encounterUuids: f }) => {
38
- const [d, M] = l(!1), [s, L] = l(
38
+ const [d, L] = l(!1), [s, U] = l(
39
39
  null
40
- ), [P, A] = l(
40
+ ), [V, N] = l(
41
41
  /* @__PURE__ */ new Set()
42
- ), E = W(), { t: o } = ae(), { addNotification: w } = X(), V = Number(n?.pageSize) || 5, [N, O] = l(1), [u, $] = l(V), [k, C] = l(void 0), v = _((e) => {
43
- L(e), M(!0);
42
+ ), E = W(), { t: o } = ae(), { addNotification: w } = X(), P = Number(n?.pageSize) || 5, [A, C] = l(1), [u, $] = l(P), [k, O] = l(void 0), v = _((e) => {
43
+ U(e), L(!0);
44
44
  }, []), z = _(() => {
45
- M(!1), L(null), A(/* @__PURE__ */ new Set());
45
+ L(!1), U(null), N(/* @__PURE__ */ new Set());
46
46
  }, []), F = _((e) => {
47
- A((t) => new Set(t).add(e));
47
+ N((t) => new Set(t).add(e));
48
48
  }, []), { data: i, isLoading: H, isError: S, error: b } = ne({
49
49
  queryKey: [
50
50
  "documents",
51
51
  E,
52
52
  f,
53
- N,
53
+ A,
54
54
  u
55
55
  ],
56
56
  enabled: !!E,
@@ -58,13 +58,13 @@ const Te = [
58
58
  E,
59
59
  f,
60
60
  u,
61
- N
61
+ A
62
62
  )
63
63
  });
64
64
  I(() => {
65
- i && C(i.total);
65
+ i && O(i.total);
66
66
  }, [i]), I(() => {
67
- O(1), C(void 0);
67
+ C(1), O(void 0);
68
68
  }, [E]), I(() => {
69
69
  S && w({
70
70
  title: o("ERROR_DEFAULT_TITLE"),
@@ -83,16 +83,16 @@ const Te = [
83
83
  method: "HEAD",
84
84
  signal: e.signal
85
85
  })).ok || a.add(m);
86
- } catch (U) {
87
- U instanceof Error && U.name !== "AbortError" && a.add(m);
86
+ } catch (M) {
87
+ M instanceof Error && M.name !== "AbortError" && a.add(m);
88
88
  }
89
89
  }
90
- e.signal.aborted || A(a);
90
+ e.signal.aborted || N(a);
91
91
  })(), () => e.abort();
92
92
  }, [d, s]);
93
93
  const q = _(
94
94
  (e, t) => {
95
- t !== u ? ($(t), O(1), C(void 0)) : O(e);
95
+ t !== u ? ($(t), C(1), O(void 0)) : C(e);
96
96
  },
97
97
  [u]
98
98
  ), D = p(
@@ -154,7 +154,7 @@ const Te = [
154
154
  dataTestId: "documents-table",
155
155
  pageSize: u,
156
156
  totalItems: k,
157
- page: N,
157
+ page: A,
158
158
  onPageChange: q
159
159
  }
160
160
  ) }),
@@ -170,7 +170,7 @@ const Te = [
170
170
  size: "lg",
171
171
  testId: "document-view-modal",
172
172
  children: /* @__PURE__ */ r("div", { className: c.documentViewerContainer, children: h.map((e, t) => {
173
- const a = R(e.url), g = e.contentType?.toLowerCase().includes("pdf"), m = (e.contentType?.toLowerCase().includes("image") ?? !1) || _e.test(e.url ?? ""), y = P.has(t);
173
+ const a = R(e.url), g = e.contentType?.toLowerCase().includes("pdf"), m = (e.contentType?.toLowerCase().includes("image") ?? !1) || _e.test(e.url ?? ""), y = V.has(t);
174
174
  return a === "#" || y ? /* @__PURE__ */ T(
175
175
  "div",
176
176
  {
@@ -1,29 +1,29 @@
1
- import { jsx as i, jsxs as $, Fragment as be } from "react/jsx-runtime";
2
- import { u as ge, c as Ne, d as Oe, s as Ee, r as Te, Z as ve, e as Fe, k as Ie, w as Ae, f as _e, g as Re, Y as G, U as De, C as K, B as z, m as Me, b as Q, h as Le, i as Be, F as Ce, j as Se, l as Ue } from "./index-BLFDusgt.js";
3
- import { useQueryClient as we, useQuery as E } from "@tanstack/react-query";
1
+ import { jsx as i, jsxs as $, Fragment as ge } from "react/jsx-runtime";
2
+ import { u as be, c as Oe, d as Ne, e as Ee, f as ve, n as Te, s as Fe, g as Ie, v as Ae, h as _e, i as Re, Y as G, V as De, C as K, B as z, m as Me, b as Q, r as Le, j as Be, F as Ce, O as Se, k as Ue } from "./index-D5lvSY7S.js";
3
+ import { useQueryClient as ke, useQuery as E } from "@tanstack/react-query";
4
4
  import { useState as Y, useMemo as d, useCallback as c } from "react";
5
- import { useTranslation as ke } from "react-i18next";
6
- const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_modalHeading__wnTmA", Pe = "FormsTable-module_customAccordianItem__isszs", T = {
5
+ import { useTranslation as we } from "react-i18next";
6
+ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_modalHeading__wnTmA", qe = "FormsTable-module_customAccordianItem__isszs", v = {
7
7
  formsTableBody: He,
8
- modalHeading: qe,
9
- customAccordianItem: Pe
10
- }, Ve = "startConsultation", ze = ({
8
+ modalHeading: Ve,
9
+ customAccordianItem: qe
10
+ }, Pe = "startConsultation", ze = ({
11
11
  episodeOfCareUuids: D,
12
12
  encounterUuids: m,
13
- config: Z,
14
- disableActions: W = !1,
13
+ config: W,
14
+ disableActions: J = !1,
15
15
  activeEncounterUuid: y = null
16
16
  }) => {
17
- const { t: n } = ke(), u = ge(), [b, M] = Y(!1), [a, L] = Y(null), {
18
- numberOfVisits: J,
19
- hideThumbnail: X = !1,
20
- forms: g
21
- } = Z ?? {}, ee = Ne(
17
+ const { t: n } = we(), u = be(), [g, M] = Y(!1), [a, L] = Y(null), {
18
+ numberOfVisits: X,
19
+ hideThumbnail: Z = !1,
20
+ forms: b
21
+ } = W ?? {}, ee = Oe(
22
22
  Ue.EDIT_OBSERVATIONS
23
- ), { userPrivileges: N } = Oe(), v = ee && !W && !!y, B = Ee(
23
+ ), { userPrivileges: O } = Ne(), T = ee && !J && !!y, B = Ee(
24
24
  D,
25
25
  m
26
- ), re = we(), {
26
+ ), re = ke(), {
27
27
  data: C = [],
28
28
  isLoading: S,
29
29
  isError: U,
@@ -31,35 +31,35 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
31
31
  refetch: oe
32
32
  } = E({
33
33
  queryKey: ["forms", u, D],
34
- queryFn: () => Te(u, void 0, J),
34
+ queryFn: () => ve(u, void 0, X),
35
35
  enabled: !!u && !B
36
- }), w = d(() => {
36
+ }), k = d(() => {
37
37
  let e = C;
38
38
  return m && m.length > 0 && (e = e.filter(
39
39
  (r) => m.includes(r.encounterUuid)
40
- )), Array.isArray(g) && g.length > 0 && (e = e.filter(
41
- (r) => g.some((o) => o.toLowerCase() === r.formName.toLowerCase())
40
+ )), Array.isArray(b) && b.length > 0 && (e = e.filter(
41
+ (r) => b.some((o) => o.toLowerCase() === r.formName.toLowerCase())
42
42
  )), e;
43
- }, [C, m, g]), { data: O = [] } = E({
43
+ }, [C, m, b]), { data: N = [] } = E({
44
44
  queryKey: ["observationForms"],
45
- queryFn: () => ve()
46
- }), k = c(
45
+ queryFn: () => Te()
46
+ }), w = c(
47
47
  (e) => {
48
- const r = O.find((t) => t.name === e);
48
+ const r = N.find((t) => t.name === e);
49
49
  if (!r?.privileges || r.privileges.length === 0) return !0;
50
- if (!N || N.length === 0) return !1;
51
- const o = new Set(N.map((t) => t.name));
50
+ if (!O || O.length === 0) return !1;
51
+ const o = new Set(O.map((t) => t.name));
52
52
  return r.privileges.some(
53
53
  (t) => o.has(t.privilegeName) && t.editable
54
54
  );
55
55
  },
56
- [O, N]
56
+ [N, O]
57
57
  ), f = c(
58
- (e) => !y || e.encounterUuid !== y ? !1 : k(e.formName),
59
- [y, k]
58
+ (e) => !y || e.encounterUuid !== y ? !1 : w(e.formName),
59
+ [y, w]
60
60
  ), H = c(
61
- (e) => O.find((o) => o.name === e)?.uuid,
62
- [O]
61
+ (e) => N.find((o) => o.name === e)?.uuid,
62
+ [N]
63
63
  ), F = d(() => {
64
64
  if (a)
65
65
  return H(a.formName);
@@ -71,7 +71,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
71
71
  } = E({
72
72
  queryKey: ["formMetadata", F],
73
73
  queryFn: () => Fe(F),
74
- enabled: !!F && b
74
+ enabled: !!F && g
75
75
  }), {
76
76
  data: A,
77
77
  isLoading: ne,
@@ -80,7 +80,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
80
80
  } = E({
81
81
  queryKey: ["formsEncounterFHIR", a?.encounterUuid],
82
82
  queryFn: () => Ie(a.encounterUuid),
83
- enabled: !!a?.encounterUuid && b
83
+ enabled: !!a?.encounterUuid && g
84
84
  });
85
85
  Ae(
86
86
  (e) => {
@@ -135,20 +135,20 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
135
135
  { key: "recordedBy", header: n("RECORDED_BY") }
136
136
  ],
137
137
  [n]
138
- ), q = d(
138
+ ), V = d(
139
139
  () => [...h, { key: "actions", header: n("ACTIONS") }],
140
140
  [h, n]
141
141
  ), fe = c(
142
- (e) => v && e.some((o) => f(o)) ? q : h,
143
- [v, f, q, h]
142
+ (e) => T && e.some((o) => f(o)) ? V : h,
143
+ [T, f, V, h]
144
144
  ), he = h, pe = d(
145
145
  () => [
146
146
  { key: "recordedOn", sortable: !0 },
147
147
  { key: "recordedBy", sortable: !0 }
148
148
  ],
149
149
  []
150
- ), P = d(() => {
151
- const e = w.reduce(
150
+ ), q = d(() => {
151
+ const e = k.reduce(
152
152
  (o, t) => {
153
153
  const s = t.formName;
154
154
  o[s] ??= [];
@@ -172,13 +172,13 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
172
172
  )
173
173
  })
174
174
  ).sort((o, t) => o.formName.localeCompare(t.formName));
175
- }, [w, n]), V = c((e) => {
175
+ }, [k, n]), P = c((e) => {
176
176
  L(e), M(!0);
177
177
  }, []), j = c(() => {
178
178
  M(!1), L(null);
179
179
  }, []), R = c((e) => {
180
180
  globalThis.dispatchEvent(
181
- new CustomEvent(Ve, {
181
+ new CustomEvent(Pe, {
182
182
  detail: {
183
183
  editOnly: "observationForms",
184
184
  editTitle: "EDIT_OBSERVATION_FORM_TITLE",
@@ -192,7 +192,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
192
192
  (e, r) => {
193
193
  switch (r) {
194
194
  case "recordedOn":
195
- return /* @__PURE__ */ i(Me, { onClick: () => V(e), children: e.recordedOn });
195
+ return /* @__PURE__ */ i(Me, { onClick: () => P(e), children: e.recordedOn });
196
196
  case "recordedBy":
197
197
  return e.recordedBy;
198
198
  case "actions":
@@ -211,10 +211,10 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
211
211
  return null;
212
212
  }
213
213
  },
214
- [V, R, f, n]
214
+ [P, R, f, n]
215
215
  );
216
- return /* @__PURE__ */ $(be, { children: [
217
- /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: S || U || P.length === 0 || B ? /* @__PURE__ */ i(
216
+ return /* @__PURE__ */ $(ge, { children: [
217
+ /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: S || U || q.length === 0 || B ? /* @__PURE__ */ i(
218
218
  Q,
219
219
  {
220
220
  headers: he,
@@ -224,16 +224,16 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
224
224
  errorStateMessage: U ? te?.message : void 0,
225
225
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
226
226
  renderCell: x,
227
- className: T.formsTableBody,
227
+ className: v.formsTableBody,
228
228
  dataTestId: "forms-table"
229
229
  }
230
- ) : /* @__PURE__ */ i(Le, { align: "start", children: P.map((e, r) => {
230
+ ) : /* @__PURE__ */ i(Le, { align: "start", children: q.map((e, r) => {
231
231
  const { formName: o, records: t } = e, s = fe(t);
232
232
  return /* @__PURE__ */ i(
233
233
  Be,
234
234
  {
235
235
  title: o,
236
- className: T.customAccordianItem,
236
+ className: v.customAccordianItem,
237
237
  testId: `accordian-title-${o}`,
238
238
  open: r === 0,
239
239
  children: /* @__PURE__ */ i(
@@ -247,7 +247,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
247
247
  sortable: pe,
248
248
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
249
249
  renderCell: x,
250
- className: T.formsTableBody,
250
+ className: v.formsTableBody,
251
251
  dataTestId: `forms-table-${o}`
252
252
  }
253
253
  )
@@ -255,16 +255,16 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
255
255
  o
256
256
  );
257
257
  }) }) }),
258
- b && a && /* @__PURE__ */ i(
258
+ g && a && /* @__PURE__ */ i(
259
259
  Ce,
260
260
  {
261
261
  id: "modalIdForActionAreaLayout",
262
262
  portalId: "main-display-area",
263
- open: b,
263
+ open: g,
264
264
  onRequestClose: j,
265
- modalHeading: /* @__PURE__ */ $("div", { className: T.modalHeading, children: [
265
+ modalHeading: /* @__PURE__ */ $("div", { className: v.modalHeading, children: [
266
266
  /* @__PURE__ */ i("span", { children: a.formName }),
267
- v && f(a) && /* @__PURE__ */ i(
267
+ T && f(a) && /* @__PURE__ */ i(
268
268
  K,
269
269
  {
270
270
  label: n("EDIT_OBSERVATION_FORM"),
@@ -291,7 +291,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
291
291
  errorMessage: ue,
292
292
  emptyStateMessage: n("NO_FORM_DATA_AVAILABLE"),
293
293
  testIdPrefix: a.formName,
294
- hideThumbnail: X,
294
+ hideThumbnail: Z,
295
295
  controlOrder: le,
296
296
  sectionMap: ce,
297
297
  conceptDatatypeMap: me
@@ -1,10 +1,10 @@
1
- import { jsx as d, jsxs as D } from "react/jsx-runtime";
2
- import { n as M, z as C, t as V, L as Q, o as q, y as k, N as z, p as G, u as P, a as H, E as j, q as J, w as Y, v as W, x as X, A as Z, D as x, b as ee } from "./index-BLFDusgt.js";
1
+ import { jsx as d, jsxs as U } from "react/jsx-runtime";
2
+ import { l as V, z as D, t as w, U as Q, o as q, y as k, p as z, q as G, u as P, a as H, _ as j, w as J, v as Y, x as W, A as X, D as Z, E as x, b as ee } from "./index-D5lvSY7S.js";
3
3
  import { useQueries as te, useQuery as se } from "@tanstack/react-query";
4
4
  import { useRef as oe, useEffect as N, useMemo as h } from "react";
5
- import { useTranslation as L } from "react-i18next";
6
- const U = (t, i, c, l, u, r) => {
7
- const s = V(t, i, u), o = s.value, a = Q(o);
5
+ import { useTranslation as C } from "react-i18next";
6
+ const A = (t, i, c, l, u, r) => {
7
+ const s = w(t, i, u), o = s.value, a = Q(o);
8
8
  let n = o;
9
9
  a === "Image" && (n = /* @__PURE__ */ d(
10
10
  k,
@@ -38,13 +38,13 @@ const U = (t, i, c, l, u, r) => {
38
38
  `obs-${t.id}`
39
39
  );
40
40
  }, re = (t, i, c, l, u, r, s) => /* @__PURE__ */ d(
41
- C,
41
+ D,
42
42
  {
43
43
  title: t.display,
44
44
  id: `grouped-obs-${t.display}-${l}`,
45
45
  open: c,
46
46
  children: t.members?.map(
47
- (o, a) => U(
47
+ (o, a) => A(
48
48
  o,
49
49
  a,
50
50
  u,
@@ -60,17 +60,17 @@ const U = (t, i, c, l, u, r) => {
60
60
  title: i = "",
61
61
  hideThumbnail: c
62
62
  }) => {
63
- const { t: l } = L(), u = (r, s, o) => {
64
- const a = M(r.encounterDetails, l);
65
- return /* @__PURE__ */ D(
66
- C,
63
+ const { t: l } = C(), u = (r, s, o) => {
64
+ const a = V(r.encounterDetails, l);
65
+ return /* @__PURE__ */ U(
66
+ D,
67
67
  {
68
68
  title: a,
69
69
  id: `encounter-${r.encounterId}`,
70
70
  open: s,
71
71
  children: [
72
72
  r.observations.map(
73
- (n, b) => U(
73
+ (n, b) => A(
74
74
  n,
75
75
  b,
76
76
  o,
@@ -114,7 +114,7 @@ const U = (t, i, c, l, u, r) => {
114
114
  conceptNames: c = [],
115
115
  conceptUuid: l = [],
116
116
  hideThumbnail: u = !1
117
- } = i, r = oe(/* @__PURE__ */ new Set()), s = P(), { addNotification: o } = H(), { t: a } = L(), n = te({
117
+ } = i, r = oe(/* @__PURE__ */ new Set()), s = P(), { addNotification: o } = H(), { t: a } = C(), n = te({
118
118
  queries: c.map((e) => ({
119
119
  queryKey: ce(e),
120
120
  queryFn: () => j(e),
@@ -161,12 +161,12 @@ const U = (t, i, c, l, u, r) => {
161
161
  if (!p) return [];
162
162
  const e = W(p), v = X(e);
163
163
  return Z(v);
164
- }, [p]), A = [
164
+ }, [p]), B = [
165
165
  { key: "name", header: "name" },
166
166
  { key: "value", header: "value" },
167
167
  { key: "form", header: "form" }
168
- ], I = f || !y, $ = g && y, B = (!p || p.entry?.length === 0 || m.length === 0) && y, F = $ ? a("ERROR_FETCHING_OBSERVATIONS") : null, w = B ? a("NO_OBSERVATIONS_FOUND") : void 0, K = _.length > 0 && !I && !$, O = i.titleTranslationKey, E = O ? a(O) : "";
169
- return /* @__PURE__ */ D(
168
+ ], I = f || !y, $ = g && y, L = (!p || p.entry?.length === 0 || m.length === 0) && y, F = $ ? a("ERROR_FETCHING_OBSERVATIONS") : null, K = L ? a("NO_OBSERVATIONS_FOUND") : void 0, M = _.length > 0 && !I && !$, O = i.titleTranslationKey, E = O ? a(O) : "";
169
+ return /* @__PURE__ */ U(
170
170
  "div",
171
171
  {
172
172
  id: "observations",
@@ -184,7 +184,7 @@ const U = (t, i, c, l, u, r) => {
184
184
  children: /* @__PURE__ */ d("p", { children: E })
185
185
  }
186
186
  ),
187
- K ? /* @__PURE__ */ d(
187
+ M ? /* @__PURE__ */ d(
188
188
  ae,
189
189
  {
190
190
  groupedData: _,
@@ -194,12 +194,12 @@ const U = (t, i, c, l, u, r) => {
194
194
  ) : /* @__PURE__ */ d(
195
195
  ee,
196
196
  {
197
- headers: A,
197
+ headers: B,
198
198
  rows: [],
199
199
  ariaLabel: a("OBSERVATIONS"),
200
200
  loading: I,
201
201
  errorStateMessage: F,
202
- emptyStateMessage: w,
202
+ emptyStateMessage: K,
203
203
  dataTestId: "observations-table"
204
204
  }
205
205
  )