@bahmni/widgets 0.0.1-dev.405 → 0.0.1-dev.408

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
- import { jsx as r, jsxs as T, Fragment as Q } from "react/jsx-runtime";
2
- import { u as W, a as X, L as J, V as Z, Y as x, b as ee, F as te } from "./index-DSanaOUz.js";
1
+ import { jsx as r, jsxs as T, Fragment as Y } from "react/jsx-runtime";
2
+ import { u as J, a as W, U as X, V as Z, J as x, b as ee, F as te } from "./index-pfbCZxrx.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,14 +35,14 @@ 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, U] = l(
38
+ const [d, M] = l(!1), [s, L] = l(
39
39
  null
40
40
  ), [V, A] = l(
41
41
  /* @__PURE__ */ new Set()
42
- ), E = W(), { t: o } = ae(), { addNotification: w } = X(), P = Number(n?.pageSize) || 5, [N, C] = l(1), [u, $] = l(P), [k, O] = l(void 0), v = _((e) => {
43
- U(e), M(!0);
42
+ ), E = J(), { t: o } = ae(), { addNotification: w } = W(), P = Number(n?.pageSize) || 5, [N, C] = l(1), [u, $] = l(P), [k, O] = l(void 0), v = _((e) => {
43
+ L(e), M(!0);
44
44
  }, []), z = _(() => {
45
- M(!1), U(null), A(/* @__PURE__ */ new Set());
45
+ M(!1), L(null), A(/* @__PURE__ */ new Set());
46
46
  }, []), F = _((e) => {
47
47
  A((t) => new Set(t).add(e));
48
48
  }, []), { data: i, isLoading: H, isError: S, error: b } = ne({
@@ -54,7 +54,7 @@ const Te = [
54
54
  u
55
55
  ],
56
56
  enabled: !!E,
57
- queryFn: () => J(
57
+ queryFn: () => X(
58
58
  E,
59
59
  f,
60
60
  u,
@@ -83,8 +83,8 @@ const Te = [
83
83
  method: "HEAD",
84
84
  signal: e.signal
85
85
  })).ok || a.add(m);
86
- } catch (L) {
87
- L instanceof Error && L.name !== "AbortError" && a.add(m);
86
+ } catch (U) {
87
+ U instanceof Error && U.name !== "AbortError" && a.add(m);
88
88
  }
89
89
  }
90
90
  e.signal.aborted || A(a);
@@ -98,7 +98,7 @@ const Te = [
98
98
  ), D = p(
99
99
  () => n?.fields ?? Te,
100
100
  [n?.fields]
101
- ), Y = p(() => [...i?.documents ?? []].sort((t, a) => !t.uploadedOn && !a.uploadedOn ? 0 : t.uploadedOn ? a.uploadedOn ? new Date(a.uploadedOn).getTime() - new Date(t.uploadedOn).getTime() : -1 : 1), [i]), j = p(() => he(D, o), [D, o]), K = p(
101
+ ), j = p(() => [...i?.documents ?? []].sort((t, a) => !t.uploadedOn && !a.uploadedOn ? 0 : t.uploadedOn ? a.uploadedOn ? new Date(a.uploadedOn).getTime() - new Date(t.uploadedOn).getTime() : -1 : 1), [i]), K = p(() => he(D, o), [D, o]), G = p(
102
102
  () => D.map((e) => ({
103
103
  key: e,
104
104
  sortable: e !== "attachments"
@@ -107,7 +107,7 @@ const Te = [
107
107
  ), h = p(
108
108
  () => s ? B(s) : [],
109
109
  [s]
110
- ), G = _(
110
+ ), Q = _(
111
111
  (e, t) => {
112
112
  switch (t) {
113
113
  case "documentIdentifier":
@@ -138,18 +138,18 @@ const Te = [
138
138
  },
139
139
  [v, o]
140
140
  );
141
- return /* @__PURE__ */ T(Q, { children: [
141
+ return /* @__PURE__ */ T(Y, { children: [
142
142
  /* @__PURE__ */ r("div", { "data-testid": "documents-table", children: /* @__PURE__ */ r(
143
143
  ee,
144
144
  {
145
- headers: j,
145
+ headers: K,
146
146
  ariaLabel: o("DOCUMENTS_TABLE_HEADING"),
147
- rows: Y,
147
+ rows: j,
148
148
  loading: H,
149
149
  errorStateMessage: S ? b?.message : null,
150
- sortable: K,
150
+ sortable: G,
151
151
  emptyStateMessage: o("DOCUMENTS_NO_RECORDS"),
152
- renderCell: G,
152
+ renderCell: Q,
153
153
  className: c.documentsTableBody,
154
154
  dataTestId: "documents-table",
155
155
  pageSize: u,
@@ -1,7 +1,7 @@
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, f as Ee, l as Te, i as ve, e as Fe, B as Ie, O as Ae, g as _e, h as Re, j as G, Y as De, C as K, k as z, V as Me, b as Y, r as Be, m as Le, F as Ce, n as Se, o as Ue } from "./index-DSanaOUz.js";
1
+ import { jsx as i, jsxs as x, Fragment as ge } from "react/jsx-runtime";
2
+ import { u as be, c as Ne, d as Oe, g as Ee, h as Te, e as ve, f as Fe, K as Ie, N as Ae, i as _e, j as Re, Y as $, J as De, C as G, B as z, V as Me, b as Q, r as Le, k as Be, F as Ce, O as Se, l as Ue } from "./index-pfbCZxrx.js";
3
3
  import { useQueryClient as ke, useQuery as E } from "@tanstack/react-query";
4
- import { useState as Q, useMemo as d, useCallback as c } from "react";
4
+ import { useState as Y, useMemo as d, useCallback as c } from "react";
5
5
  import { useTranslation as we } from "react-i18next";
6
6
  const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_modalHeading__wnTmA", qe = "FormsTable-module_customAccordianItem__isszs", T = {
7
7
  formsTableBody: He,
@@ -10,17 +10,17 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
10
10
  }, Pe = "startConsultation", ze = ({
11
11
  episodeOfCareUuids: D,
12
12
  encounterUuids: m,
13
- config: W,
14
- disableActions: J = !1,
13
+ config: J,
14
+ disableActions: W = !1,
15
15
  activeEncounterUuid: y = null
16
16
  }) => {
17
- const { t: n } = we(), u = be(), [g, M] = Q(!1), [a, B] = Q(null), {
17
+ const { t: n } = we(), u = be(), [g, M] = Y(!1), [a, L] = Y(null), {
18
18
  numberOfVisits: X,
19
19
  hideThumbnail: Z = !1,
20
20
  forms: b
21
- } = W ?? {}, ee = Oe(
21
+ } = J ?? {}, ee = Ne(
22
22
  Ue.EDIT_OBSERVATIONS
23
- ), { userPrivileges: O } = Ne(), v = ee && !J && !!y, L = Ee(
23
+ ), { userPrivileges: N } = Oe(), v = ee && !W && !!y, B = Ee(
24
24
  D,
25
25
  m
26
26
  ), re = ke(), {
@@ -32,7 +32,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
32
32
  } = E({
33
33
  queryKey: ["forms", u, D],
34
34
  queryFn: () => Te(u, void 0, X),
35
- enabled: !!u && !L
35
+ enabled: !!u && !B
36
36
  }), k = d(() => {
37
37
  let e = C;
38
38
  return m && m.length > 0 && (e = e.filter(
@@ -40,26 +40,26 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
40
40
  )), Array.isArray(b) && b.length > 0 && (e = e.filter(
41
41
  (r) => b.some((o) => o.toLowerCase() === r.formName.toLowerCase())
42
42
  )), e;
43
- }, [C, m, b]), { data: N = [] } = E({
43
+ }, [C, m, b]), { data: O = [] } = E({
44
44
  queryKey: ["observationForms"],
45
45
  queryFn: () => ve()
46
46
  }), w = c(
47
47
  (e) => {
48
- const r = N.find((t) => t.name === e);
48
+ const r = O.find((t) => t.name === e);
49
49
  if (!r?.privileges || r.privileges.length === 0) return !0;
50
- if (!O || O.length === 0) return !1;
51
- const o = new Set(O.map((t) => t.name));
50
+ if (!N || N.length === 0) return !1;
51
+ const o = new Set(N.map((t) => t.name));
52
52
  return r.privileges.some(
53
53
  (t) => o.has(t.privilegeName) && t.editable
54
54
  );
55
55
  },
56
- [N, O]
56
+ [O, N]
57
57
  ), f = c(
58
58
  (e) => !y || e.encounterUuid !== y ? !1 : w(e.formName),
59
59
  [y, w]
60
60
  ), H = c(
61
- (e) => N.find((o) => o.name === e)?.uuid,
62
- [N]
61
+ (e) => O.find((o) => o.name === e)?.uuid,
62
+ [O]
63
63
  ), F = d(() => {
64
64
  if (a)
65
65
  return H(a.formName);
@@ -126,9 +126,9 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
126
126
  ), Object.keys(e).length > 0 ? e : void 0;
127
127
  }, [l]), ue = d(() => {
128
128
  if (I)
129
- return G(I).message;
129
+ return $(I).message;
130
130
  if (_)
131
- return G(_).message;
131
+ return $(_).message;
132
132
  }, [I, _]), h = d(
133
133
  () => [
134
134
  { key: "recordedOn", header: n("RECORDED_ON") },
@@ -173,9 +173,9 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
173
173
  })
174
174
  ).sort((o, t) => o.formName.localeCompare(t.formName));
175
175
  }, [k, n]), P = c((e) => {
176
- B(e), M(!0);
176
+ L(e), M(!0);
177
177
  }, []), j = c(() => {
178
- M(!1), B(null);
178
+ M(!1), L(null);
179
179
  }, []), R = c((e) => {
180
180
  globalThis.dispatchEvent(
181
181
  new CustomEvent(Pe, {
@@ -188,7 +188,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
188
188
  }
189
189
  })
190
190
  );
191
- }, []), x = c(
191
+ }, []), K = c(
192
192
  (e, r) => {
193
193
  switch (r) {
194
194
  case "recordedOn":
@@ -197,7 +197,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
197
197
  return e.recordedBy;
198
198
  case "actions":
199
199
  return f(e) ? /* @__PURE__ */ i(
200
- K,
200
+ G,
201
201
  {
202
202
  label: n("EDIT_OBSERVATION_FORM"),
203
203
  kind: "ghost",
@@ -213,9 +213,9 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
213
213
  },
214
214
  [P, R, f, n]
215
215
  );
216
- return /* @__PURE__ */ $(ge, { children: [
217
- /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: S || U || q.length === 0 || L ? /* @__PURE__ */ i(
218
- Y,
216
+ return /* @__PURE__ */ x(ge, { children: [
217
+ /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: S || U || q.length === 0 || B ? /* @__PURE__ */ i(
218
+ Q,
219
219
  {
220
220
  headers: he,
221
221
  ariaLabel: n("FORMS_HEADING"),
@@ -223,21 +223,21 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
223
223
  loading: S,
224
224
  errorStateMessage: U ? te?.message : void 0,
225
225
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
226
- renderCell: x,
226
+ renderCell: K,
227
227
  className: T.formsTableBody,
228
228
  dataTestId: "forms-table"
229
229
  }
230
- ) : /* @__PURE__ */ i(Be, { align: "start", children: q.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
- Le,
233
+ Be,
234
234
  {
235
235
  title: o,
236
236
  className: T.customAccordianItem,
237
237
  testId: `accordian-title-${o}`,
238
238
  open: r === 0,
239
239
  children: /* @__PURE__ */ i(
240
- Y,
240
+ Q,
241
241
  {
242
242
  headers: s,
243
243
  ariaLabel: n("FORMS_HEADING"),
@@ -246,7 +246,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
246
246
  errorStateMessage: "",
247
247
  sortable: pe,
248
248
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
249
- renderCell: x,
249
+ renderCell: K,
250
250
  className: T.formsTableBody,
251
251
  dataTestId: `forms-table-${o}`
252
252
  }
@@ -262,10 +262,10 @@ const He = "FormsTable-module_formsTableBody__SvGha", Ve = "FormsTable-module_mo
262
262
  portalId: "main-display-area",
263
263
  open: g,
264
264
  onRequestClose: j,
265
- modalHeading: /* @__PURE__ */ $("div", { className: T.modalHeading, children: [
265
+ modalHeading: /* @__PURE__ */ x("div", { className: T.modalHeading, children: [
266
266
  /* @__PURE__ */ i("span", { children: a.formName }),
267
267
  v && f(a) && /* @__PURE__ */ i(
268
- K,
268
+ G,
269
269
  {
270
270
  label: n("EDIT_OBSERVATION_FORM"),
271
271
  kind: "ghost",
@@ -1,7 +1,7 @@
1
1
  import { jsx as d, jsxs as D } from "react/jsx-runtime";
2
- import { p as M, D as A, t as w, q as Q, s as q, T as k, R as G, S as P, u as z, a as H, v as j, w as J, O as Y, x as W, y as X, z as Z, A as x, b as ee } from "./index-DSanaOUz.js";
2
+ import { m as M, D as A, t as w, n as Q, o as q, T as k, R as G, S as P, u as H, a as Y, A as j, p as z, N as J, q as W, s as X, v as Z, w as x, b as ee } from "./index-pfbCZxrx.js";
3
3
  import { useQueries as te, useQuery as se } from "@tanstack/react-query";
4
- import { useRef as oe, useEffect as $, useMemo as R } from "react";
4
+ import { useRef as oe, useEffect as N, useMemo as R } from "react";
5
5
  import { useTranslation as C } from "react-i18next";
6
6
  const U = (t, i, c, l, u, a) => {
7
7
  const s = w(t, i, u), o = s.value, r = Q(o);
@@ -24,16 +24,16 @@ const U = (t, i, c, l, u, a) => {
24
24
  )), r === "PDF" && (n = /* @__PURE__ */ d(P, { id: `${o}-pdf`, src: o }));
25
25
  const b = u("OBSERVATIONS_RECORDED_BY", {
26
26
  provider: s.provider
27
- }), p = t.display, m = t.observationValue?.isAbnormal ? "abnormal-obs" : "obs", f = l ? `${l}-${m}-${p}-${c}-${i}` : `${m}-${p}-${c}-${i}`;
27
+ }), m = t.display, p = t.observationValue?.isAbnormal ? "abnormal-obs" : "obs", y = l ? `${l}-${p}-${m}-${c}-${i}` : `${p}-${m}-${c}-${i}`;
28
28
  return /* @__PURE__ */ d(
29
29
  q,
30
30
  {
31
31
  header: s.header,
32
32
  value: n,
33
33
  info: b,
34
- id: f,
35
- testId: f,
36
- ariaLabel: f
34
+ id: y,
35
+ testId: y,
36
+ ariaLabel: y
37
37
  },
38
38
  `obs-${t.id}`
39
39
  );
@@ -106,7 +106,7 @@ const U = (t, i, c, l, u, a) => {
106
106
  )
107
107
  }
108
108
  );
109
- }, ne = "Observations-module_observations__RKSyo", ie = "Observations-module_title__TJL3z", N = {
109
+ }, ne = "Observations-module_observations__RKSyo", ie = "Observations-module_title__TJL3z", $ = {
110
110
  observations: ne,
111
111
  title: ie
112
112
  }, ce = (t) => ["conceptUuid", t], le = (t, i) => ["observations", t, ...i], ve = ({ config: t }) => {
@@ -114,14 +114,14 @@ const U = (t, i, c, l, u, a) => {
114
114
  conceptNames: c = [],
115
115
  conceptUuid: l = [],
116
116
  hideThumbnail: u = !1
117
- } = i, a = oe(/* @__PURE__ */ new Set()), s = z(), { addNotification: o } = H(), { t: r } = C(), n = te({
117
+ } = i, a = oe(/* @__PURE__ */ new Set()), s = H(), { addNotification: o } = Y(), { t: r } = C(), n = te({
118
118
  queries: c.map((e) => ({
119
119
  queryKey: ce(e),
120
120
  queryFn: () => j(e),
121
121
  enabled: !!e
122
122
  }))
123
123
  });
124
- $(() => {
124
+ N(() => {
125
125
  n.forEach((e, v) => {
126
126
  if (e.isError && !a.current.has(v)) {
127
127
  const T = c[v];
@@ -133,24 +133,24 @@ const U = (t, i, c, l, u, a) => {
133
133
  } else e.isError || a.current.delete(v);
134
134
  });
135
135
  }, [n, c]);
136
- const b = R(() => n.map((e) => e.data?.uuid).filter((e) => !!e), [n]), p = R(() => [.../* @__PURE__ */ new Set([...b, ...l])], [b, l]), y = R(() => c.length === 0 ? !0 : n.every((e) => !e.isLoading), [n, c.length]), {
137
- data: m,
138
- isLoading: f,
136
+ const b = R(() => n.map((e) => e.data?.uuid).filter((e) => !!e), [n]), m = R(() => [.../* @__PURE__ */ new Set([...b, ...l])], [b, l]), f = R(() => c.length === 0 ? !0 : n.every((e) => !e.isLoading), [n, c.length]), {
137
+ data: p,
138
+ isLoading: y,
139
139
  isError: h,
140
140
  refetch: g
141
141
  } = se({
142
- queryKey: le(s, p),
143
- queryFn: () => J(s, p),
144
- enabled: !!s && p.length > 0 && y
142
+ queryKey: le(s, m),
143
+ queryFn: () => z(s, m),
144
+ enabled: !!s && m.length > 0 && f
145
145
  });
146
- Y(
146
+ J(
147
147
  (e) => {
148
148
  e.patientUUID === s && e.updatedConcepts.size > 0 && [...e.updatedConcepts.keys()].some(
149
- (T) => p.includes(T)
149
+ (T) => m.includes(T)
150
150
  ) && g();
151
151
  },
152
152
  [s, g]
153
- ), $(() => {
153
+ ), N(() => {
154
154
  h && o({
155
155
  title: r("ERROR_DEFAULT_TITLE"),
156
156
  message: r("ERROR_FETCHING_OBSERVATIONS"),
@@ -158,21 +158,21 @@ const U = (t, i, c, l, u, a) => {
158
158
  });
159
159
  }, [h]);
160
160
  const _ = R(() => {
161
- if (!m) return [];
162
- const e = W(m), v = X(e);
161
+ if (!p) return [];
162
+ const e = W(p), v = X(e);
163
163
  return Z(v);
164
- }, [m]), B = [
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, S = h && y, L = (!m || m.entry?.length === 0 || p.length === 0) && y, V = S ? r("ERROR_FETCHING_OBSERVATIONS") : null, F = L ? r("NO_OBSERVATIONS_FOUND") : void 0, K = _.length > 0 && !I && !S, O = i.titleTranslationKey, E = O ? r(O) : "";
168
+ ], I = y || !f, S = h && f, L = (!p || p.entry?.length === 0 || m.length === 0) && f, F = S ? r("ERROR_FETCHING_OBSERVATIONS") : null, V = L ? r("NO_OBSERVATIONS_FOUND") : void 0, K = _.length > 0 && !I && !S, O = i.titleTranslationKey, E = O ? r(O) : "";
169
169
  return /* @__PURE__ */ D(
170
170
  "div",
171
171
  {
172
172
  id: "observations",
173
173
  "data-testid": O ? `observations-${E}` : "observations",
174
174
  "aria-label": "observations-aria-label",
175
- className: N.observations,
175
+ className: $.observations,
176
176
  children: [
177
177
  /* @__PURE__ */ d(
178
178
  x,
@@ -180,7 +180,7 @@ const U = (t, i, c, l, u, a) => {
180
180
  id: "observations-title",
181
181
  testId: O ? `observations-title-${E}` : "observations-title",
182
182
  title: E,
183
- className: N.title,
183
+ className: $.title,
184
184
  children: /* @__PURE__ */ d("p", { children: E })
185
185
  }
186
186
  ),
@@ -198,8 +198,8 @@ const U = (t, i, c, l, u, a) => {
198
198
  rows: [],
199
199
  ariaLabel: r("OBSERVATIONS"),
200
200
  loading: I,
201
- errorStateMessage: V,
202
- emptyStateMessage: F ?? r("NO_OBSERVATIONS_AVAILABLE"),
201
+ errorStateMessage: F,
202
+ emptyStateMessage: V ?? r("NO_OBSERVATIONS_AVAILABLE"),
203
203
  dataTestId: "observations-table"
204
204
  }
205
205
  )