@bahmni/widgets 0.0.1-dev.352 → 0.0.1-dev.354

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, y as J, B as Z, D as x, q as ee, F as te } from "./index-C1aiHQqT.js";
2
+ import { u as W, a as X, m as J, B as Z, N as x, q as ee, F as te } from "./index-BAUpWnui.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";
@@ -37,20 +37,20 @@ const Te = [
37
37
  ], _e = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, R = (n) => n.attachments.length > 0 ? n.attachments : n.documentUrl ? [{ url: n.documentUrl, contentType: n.contentType }] : [], Ie = ({ config: n, encounterUuids: f }) => {
38
38
  const [d, L] = l(!1), [s, U] = l(
39
39
  null
40
- ), [P, A] = l(
40
+ ), [P, N] = l(
41
41
  /* @__PURE__ */ new Set()
42
- ), E = W(), { t: o } = ae(), { addNotification: w } = X(), V = Number(n?.pageSize) || 5, [N, C] = l(1), [u, $] = l(V), [k, O] = l(void 0), v = _((e) => {
42
+ ), E = W(), { t: o } = ae(), { addNotification: w } = X(), V = Number(n?.pageSize) || 5, [A, C] = l(1), [u, $] = l(V), [k, O] = l(void 0), v = _((e) => {
43
43
  U(e), L(!0);
44
44
  }, []), H = _(() => {
45
- L(!1), U(null), A(/* @__PURE__ */ new Set());
45
+ L(!1), U(null), N(/* @__PURE__ */ new Set());
46
46
  }, []), B = _((e) => {
47
- A((t) => new Set(t).add(e));
47
+ N((t) => new Set(t).add(e));
48
48
  }, []), { data: i, isLoading: q, isError: S, error: y } = 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,7 +58,7 @@ const Te = [
58
58
  E,
59
59
  f,
60
60
  u,
61
- N
61
+ A
62
62
  )
63
63
  });
64
64
  I(() => {
@@ -87,7 +87,7 @@ const Te = [
87
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 z = _(
@@ -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: z
159
159
  }
160
160
  ) }),
@@ -1,27 +1,27 @@
1
- import { jsx as i, jsxs as x, Fragment as be } from "react/jsx-runtime";
2
- import { u as ye, b as pe, c as Oe, Q as Ne, W as Te, Y as Ee, G as Fe, $ as Ie, d as ve, e as _e, f as Ae, g as z, D as Re, l as j, h as K, B as De, q as Q, T as Me, R as Be, F as Ce, O as Le, C as Se } from "./index-C1aiHQqT.js";
1
+ import { jsx as i, jsxs as G, Fragment as be } from "react/jsx-runtime";
2
+ import { u as ye, b as Ne, c as pe, W as Oe, G as Te, d as Ee, z as Fe, A as Ie, i as ve, e as Ae, f as _e, Y as x, N as Re, l as j, $ as K, B as Me, q as Q, T as Be, R as De, F as Ce, O as Le, C as Se } from "./index-BAUpWnui.js";
3
3
  import { useQueryClient as Ue, useQuery as T } from "@tanstack/react-query";
4
- import { useState as Y, useMemo as d, useCallback as l } from "react";
4
+ import { useState as W, useMemo as d, useCallback as l } from "react";
5
5
  import { useTranslation as we } from "react-i18next";
6
6
  const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_modalHeading__wnTmA", qe = "FormsTable-module_customAccordianItem__isszs", E = {
7
7
  formsTableBody: He,
8
8
  modalHeading: ke,
9
9
  customAccordianItem: qe
10
10
  }, Pe = "startConsultation", je = ({
11
- episodeOfCareUuids: D,
11
+ episodeOfCareUuids: M,
12
12
  encounterUuids: m,
13
- config: W,
13
+ config: Y,
14
14
  disableActions: J = !1,
15
15
  activeEncounterUuid: b = null
16
16
  }) => {
17
- const { t: n } = we(), u = ye(), [y, M] = Y(!1), [a, B] = Y(null), {
17
+ const { t: n } = we(), u = ye(), [y, B] = W(!1), [a, D] = W(null), {
18
18
  numberOfVisits: X,
19
19
  hideThumbnail: Z = !1,
20
- forms: p
21
- } = W ?? {}, ee = pe(
20
+ forms: N
21
+ } = Y ?? {}, ee = Ne(
22
22
  Se.EDIT_OBSERVATIONS
23
- ), { userPrivileges: O } = Oe(), F = ee && !J && !!b, C = Ne(
24
- D,
23
+ ), { userPrivileges: p } = pe(), F = ee && !J && !!b, C = Oe(
24
+ M,
25
25
  m
26
26
  ), re = Ue(), {
27
27
  data: L = [],
@@ -30,36 +30,36 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
30
30
  error: te,
31
31
  refetch: oe
32
32
  } = T({
33
- queryKey: ["forms", u, D],
33
+ queryKey: ["forms", u, M],
34
34
  queryFn: () => Te(u, void 0, X),
35
35
  enabled: !!u && !C
36
36
  }), w = d(() => {
37
37
  let e = L;
38
38
  return m && m.length > 0 && (e = e.filter(
39
39
  (r) => m.includes(r.encounterUuid)
40
- )), Array.isArray(p) && p.length > 0 && (e = e.filter(
41
- (r) => p.some((o) => o.toLowerCase() === r.formName.toLowerCase())
40
+ )), Array.isArray(N) && N.length > 0 && (e = e.filter(
41
+ (r) => N.some((o) => o.toLowerCase() === r.formName.toLowerCase())
42
42
  )), e;
43
- }, [L, m, p]), { data: N = [] } = T({
43
+ }, [L, m, N]), { data: O = [] } = T({
44
44
  queryKey: ["observationForms"],
45
45
  queryFn: () => Ee()
46
46
  }), H = l(
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 (!p || p.length === 0) return !1;
51
+ const o = new Set(p.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, p]
57
57
  ), f = l(
58
58
  (e) => !b || e.encounterUuid !== b ? !1 : H(e.formName),
59
59
  [b, H]
60
60
  ), k = l(
61
- (e) => N.find((o) => o.name === e)?.uuid,
62
- [N]
61
+ (e) => O.find((o) => o.name === e)?.uuid,
62
+ [O]
63
63
  ), I = d(() => {
64
64
  if (a)
65
65
  return k(a.formName);
@@ -73,10 +73,10 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
73
73
  queryFn: () => Fe(I),
74
74
  enabled: !!I && y
75
75
  }), {
76
- data: _,
76
+ data: A,
77
77
  isLoading: ne,
78
78
  isError: ie,
79
- error: A
79
+ error: _
80
80
  } = T({
81
81
  queryKey: ["formsEncounterFHIR", a?.encounterUuid],
82
82
  queryFn: () => Ie(a.encounterUuid),
@@ -88,7 +88,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
88
88
  },
89
89
  [u]
90
90
  );
91
- const de = d(() => !_?.entry || !a?.formName ? [] : _.entry.filter((r) => r.resource?.resourceType === "Observation").map((r) => r.resource).filter((r) => _e(r) ? Ae(r)?.toLowerCase() === a.formName.toLowerCase() : !0), [_, a?.formName]), le = d(() => {
91
+ const de = d(() => !A?.entry || !a?.formName ? [] : A.entry.filter((r) => r.resource?.resourceType === "Observation").map((r) => r.resource).filter((r) => Ae(r) ? _e(r)?.toLowerCase() === a.formName.toLowerCase() : !0), [A, a?.formName]), le = d(() => {
92
92
  if (!c?.schema) return;
93
93
  const e = [], r = (o) => {
94
94
  (o ?? []).forEach((t) => {
@@ -115,10 +115,10 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
115
115
  ), Object.keys(e).length > 0 ? e : void 0;
116
116
  }, [c]), me = d(() => {
117
117
  if (v)
118
- return z(v).message;
119
- if (A)
120
- return z(A).message;
121
- }, [v, A]), h = d(
118
+ return x(v).message;
119
+ if (_)
120
+ return x(_).message;
121
+ }, [v, _]), h = d(
122
122
  () => [
123
123
  { key: "recordedOn", header: n("RECORDED_ON") },
124
124
  { key: "recordedBy", header: n("RECORDED_BY") }
@@ -162,9 +162,9 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
162
162
  })
163
163
  ).sort((o, t) => o.formName.localeCompare(t.formName));
164
164
  }, [w, n]), V = l((e) => {
165
- B(e), M(!0);
166
- }, []), $ = l(() => {
167
- M(!1), B(null);
165
+ D(e), B(!0);
166
+ }, []), z = l(() => {
167
+ B(!1), D(null);
168
168
  }, []), R = l((e) => {
169
169
  globalThis.dispatchEvent(
170
170
  new CustomEvent(Pe, {
@@ -177,11 +177,11 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
177
177
  }
178
178
  })
179
179
  );
180
- }, []), G = l(
180
+ }, []), $ = l(
181
181
  (e, r) => {
182
182
  switch (r) {
183
183
  case "recordedOn":
184
- return /* @__PURE__ */ i(De, { onClick: () => V(e), children: e.recordedOn });
184
+ return /* @__PURE__ */ i(Me, { onClick: () => V(e), children: e.recordedOn });
185
185
  case "recordedBy":
186
186
  return e.recordedBy;
187
187
  case "actions":
@@ -202,7 +202,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
202
202
  },
203
203
  [V, R, f, n]
204
204
  );
205
- return /* @__PURE__ */ x(be, { children: [
205
+ return /* @__PURE__ */ G(be, { children: [
206
206
  /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: S || U || P.length === 0 || C ? /* @__PURE__ */ i(
207
207
  Q,
208
208
  {
@@ -212,14 +212,14 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
212
212
  loading: S,
213
213
  errorStateMessage: U ? te?.message : void 0,
214
214
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
215
- renderCell: G,
215
+ renderCell: $,
216
216
  className: E.formsTableBody,
217
217
  dataTestId: "forms-table"
218
218
  }
219
- ) : /* @__PURE__ */ i(Me, { align: "start", children: P.map((e, r) => {
219
+ ) : /* @__PURE__ */ i(Be, { align: "start", children: P.map((e, r) => {
220
220
  const { formName: o, records: t } = e, s = ue(t);
221
221
  return /* @__PURE__ */ i(
222
- Be,
222
+ De,
223
223
  {
224
224
  title: o,
225
225
  className: E.customAccordianItem,
@@ -235,7 +235,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
235
235
  errorStateMessage: "",
236
236
  sortable: he,
237
237
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
238
- renderCell: G,
238
+ renderCell: $,
239
239
  className: E.formsTableBody,
240
240
  dataTestId: `forms-table-${o}`
241
241
  }
@@ -250,8 +250,8 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
250
250
  id: "modalIdForActionAreaLayout",
251
251
  portalId: "main-display-area",
252
252
  open: y,
253
- onRequestClose: $,
254
- modalHeading: /* @__PURE__ */ x("div", { className: E.modalHeading, children: [
253
+ onRequestClose: z,
254
+ modalHeading: /* @__PURE__ */ G("div", { className: E.modalHeading, children: [
255
255
  /* @__PURE__ */ i("span", { children: a.formName }),
256
256
  F && f(a) && /* @__PURE__ */ i(
257
257
  j,
@@ -261,7 +261,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
261
261
  size: "sm",
262
262
  testId: `edit-form-modal-${a.encounterUuid}`,
263
263
  onClick: () => {
264
- $(), R(a);
264
+ z(), R(a);
265
265
  },
266
266
  children: /* @__PURE__ */ i(K, {})
267
267
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx as d, jsxs as N } from "react/jsx-runtime";
2
- import { i as Q, j as D, t as V, k as q, m as w, n as k, o as H, p as G, u as P, a as j, r as z, A as J, d as W, s as Y, v as X, w as Z, x, q as ee } from "./index-C1aiHQqT.js";
2
+ import { g as K, Q as D, t as V, h as q, j as w, k, n as H, o as G, u as P, a as j, p as z, r as J, i as W, s as Y, v as X, w as Z, x, q as ee } from "./index-BAUpWnui.js";
3
3
  import { useQueries as te, useQuery as se } from "@tanstack/react-query";
4
4
  import { useRef as oe, useEffect as C, useMemo as g } from "react";
5
5
  import { useTranslation as U } from "react-i18next";
@@ -24,7 +24,7 @@ const A = (t, i, c, l, u, r) => {
24
24
  )), a === "PDF" && (n = /* @__PURE__ */ d(G, { id: `${o}-pdf`, src: o }));
25
25
  const b = u("OBSERVATIONS_RECORDED_BY", {
26
26
  provider: s.provider
27
- }), m = t.display, p = t.observationValue?.isAbnormal ? "abnormal-obs" : "obs", y = l ? `${l}-${p}-${m}-${c}-${i}` : `${p}-${m}-${c}-${i}`;
27
+ }), p = t.display, m = t.observationValue?.isAbnormal ? "abnormal-obs" : "obs", y = l ? `${l}-${m}-${p}-${c}-${i}` : `${m}-${p}-${c}-${i}`;
28
28
  return /* @__PURE__ */ d(
29
29
  w,
30
30
  {
@@ -61,7 +61,7 @@ const A = (t, i, c, l, u, r) => {
61
61
  hideThumbnail: c
62
62
  }) => {
63
63
  const { t: l } = U(), u = (r, s, o) => {
64
- const a = Q(r.encounterDetails, l);
64
+ const a = K(r.encounterDetails, l);
65
65
  return /* @__PURE__ */ N(
66
66
  D,
67
67
  {
@@ -133,20 +133,20 @@ const A = (t, i, c, l, u, r) => {
133
133
  } else e.isError || r.current.delete(v);
134
134
  });
135
135
  }, [n, c]);
136
- const b = g(() => n.map((e) => e.data?.uuid).filter((e) => !!e), [n]), m = g(() => [.../* @__PURE__ */ new Set([...b, ...l])], [b, l]), f = g(() => c.length === 0 ? !0 : n.every((e) => !e.isLoading), [n, c.length]), {
137
- data: p,
136
+ const b = g(() => n.map((e) => e.data?.uuid).filter((e) => !!e), [n]), p = g(() => [.../* @__PURE__ */ new Set([...b, ...l])], [b, l]), f = g(() => c.length === 0 ? !0 : n.every((e) => !e.isLoading), [n, c.length]), {
137
+ data: m,
138
138
  isLoading: y,
139
139
  isError: h,
140
140
  refetch: T
141
141
  } = se({
142
- queryKey: le(s, m),
143
- queryFn: () => J(s, m),
144
- enabled: !!s && m.length > 0 && f
142
+ queryKey: le(s, p),
143
+ queryFn: () => J(s, p),
144
+ enabled: !!s && p.length > 0 && f
145
145
  });
146
146
  W(
147
147
  (e) => {
148
148
  e.patientUUID === s && e.updatedConcepts.size > 0 && [...e.updatedConcepts.keys()].some(
149
- (R) => m.includes(R)
149
+ (R) => p.includes(R)
150
150
  ) && T();
151
151
  },
152
152
  [s, T]
@@ -158,14 +158,14 @@ const A = (t, i, c, l, u, r) => {
158
158
  });
159
159
  }, [h]);
160
160
  const _ = g(() => {
161
- if (!p) return [];
162
- const e = Y(p), v = X(e);
161
+ if (!m) return [];
162
+ const e = Y(m), v = X(e);
163
163
  return Z(v);
164
- }, [p]), B = [
164
+ }, [m]), B = [
165
165
  { key: "name", header: "name" },
166
166
  { key: "value", header: "value" },
167
167
  { key: "form", header: "form" }
168
- ], $ = y || !f, I = h && f, F = (!p || p.entry?.length === 0 || m.length === 0) && f, L = I ? a("ERROR_FETCHING_OBSERVATIONS") : null, M = F ? a("NO_OBSERVATIONS_FOUND") : void 0, K = _.length > 0 && !$ && !I, O = i.titleTranslationKey, E = O ? a(O) : "";
168
+ ], I = y || !f, $ = h && f, F = (!m || m.entry?.length === 0 || p.length === 0) && f, L = $ ? a("ERROR_FETCHING_OBSERVATIONS") : null, M = F ? a("NO_OBSERVATIONS_FOUND") : void 0, Q = _.length > 0 && !I && !$, O = i.titleTranslationKey, E = O ? a(O) : "";
169
169
  return /* @__PURE__ */ N(
170
170
  "div",
171
171
  {
@@ -184,7 +184,7 @@ const A = (t, i, c, l, u, r) => {
184
184
  children: /* @__PURE__ */ d("p", { children: E })
185
185
  }
186
186
  ),
187
- K ? /* @__PURE__ */ d(
187
+ Q ? /* @__PURE__ */ d(
188
188
  ae,
189
189
  {
190
190
  groupedData: _,
@@ -197,7 +197,7 @@ const A = (t, i, c, l, u, r) => {
197
197
  headers: B,
198
198
  rows: [],
199
199
  ariaLabel: a("OBSERVATIONS"),
200
- loading: $,
200
+ loading: I,
201
201
  errorStateMessage: L,
202
202
  emptyStateMessage: M,
203
203
  dataTestId: "observations-table"