@bahmni/widgets 0.0.1-dev.375 → 0.0.1-dev.376

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, _ as J, P as Z, x, q as ee, F as te } from "./index-BuzazPX_.js";
2
+ import { u as W, a as X, T as J, P as Z, k as x, q as ee, F as te } from "./index-D6eQA2wz.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";
@@ -39,7 +39,7 @@ const Te = [
39
39
  null
40
40
  ), [P, A] = 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(), k = Number(n?.pageSize) || 5, [N, C] = l(1), [u, V] = l(k), [$, O] = l(void 0), v = _((e) => {
43
43
  U(e), L(!0);
44
44
  }, []), H = _(() => {
45
45
  L(!1), U(null), A(/* @__PURE__ */ new Set());
@@ -92,7 +92,7 @@ const Te = [
92
92
  }, [d, s]);
93
93
  const z = _(
94
94
  (e, t) => {
95
- t !== u ? ($(t), C(1), O(void 0)) : C(e);
95
+ t !== u ? (V(t), C(1), O(void 0)) : C(e);
96
96
  },
97
97
  [u]
98
98
  ), D = p(
@@ -153,7 +153,7 @@ const Te = [
153
153
  className: c.documentsTableBody,
154
154
  dataTestId: "documents-table",
155
155
  pageSize: u,
156
- totalItems: k,
156
+ totalItems: $,
157
157
  page: N,
158
158
  onPageChange: z
159
159
  }
@@ -1,49 +1,49 @@
1
- import { jsx as i, jsxs as j, Fragment as ge } from "react/jsx-runtime";
2
- import { u as be, b as Oe, c as Ne, t as Ee, X as Te, W as Fe, J as Ie, C as ve, p as _e, e as Ae, d as Re, Y as z, x as De, i as G, $ as K, P as Me, q as Q, T as Ce, R as Le, F as Se, O as Be, f as Ue } from "./index-BuzazPX_.js";
3
- import { useQueryClient as we, useQuery as E } from "@tanstack/react-query";
4
- import { useState as W, useMemo as d, useCallback as c } from "react";
5
- import { useTranslation as He } from "react-i18next";
6
- const ke = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_modalHeading__wnTmA", Pe = "FormsTable-module_customAccordianItem__isszs", T = {
7
- formsTableBody: ke,
1
+ import { jsx as i, jsxs as x, Fragment as ge } from "react/jsx-runtime";
2
+ import { u as be, b as Oe, c as Ne, r as Ee, e as Te, Q as Fe, X as ve, L as Ie, m as _e, d as Ae, f as Re, Y as z, k as De, i as G, $ as K, P as Me, q as Q, g as Le, R as Se, F as Be, O as Ce, C as ke } from "./index-D6eQA2wz.js";
3
+ import { useQueryClient as Ue, useQuery as E } from "@tanstack/react-query";
4
+ import { useState as Y, useMemo as d, useCallback as c } from "react";
5
+ import { useTranslation as we } from "react-i18next";
6
+ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_modalHeading__wnTmA", Pe = "FormsTable-module_customAccordianItem__isszs", T = {
7
+ formsTableBody: He,
8
8
  modalHeading: qe,
9
9
  customAccordianItem: Pe
10
10
  }, Ve = "startConsultation", Ke = ({
11
11
  episodeOfCareUuids: D,
12
12
  encounterUuids: m,
13
- config: Y,
14
- disableActions: J = !1,
13
+ config: X,
14
+ disableActions: W = !1,
15
15
  activeEncounterUuid: y = null
16
16
  }) => {
17
- const { t: n } = He(), u = be(), [g, M] = W(!1), [a, C] = W(null), {
18
- numberOfVisits: X,
17
+ const { t: n } = we(), u = be(), [g, M] = Y(!1), [a, L] = Y(null), {
18
+ numberOfVisits: J,
19
19
  hideThumbnail: Z = !1,
20
20
  forms: b
21
- } = Y ?? {}, ee = Oe(
22
- Ue.EDIT_OBSERVATIONS
23
- ), { userPrivileges: O } = Ne(), F = ee && !J && !!y, L = Ee(
21
+ } = X ?? {}, ee = Oe(
22
+ ke.EDIT_OBSERVATIONS
23
+ ), { userPrivileges: O } = Ne(), F = ee && !W && !!y, S = Ee(
24
24
  D,
25
25
  m
26
- ), re = we(), {
27
- data: S = [],
28
- isLoading: B,
29
- isError: U,
26
+ ), re = Ue(), {
27
+ data: B = [],
28
+ isLoading: C,
29
+ isError: k,
30
30
  error: te,
31
31
  refetch: oe
32
32
  } = E({
33
33
  queryKey: ["forms", u, D],
34
- queryFn: () => Te(u, void 0, X),
35
- enabled: !!u && !L
36
- }), w = d(() => {
37
- let e = S;
34
+ queryFn: () => Te(u, void 0, J),
35
+ enabled: !!u && !S
36
+ }), U = d(() => {
37
+ let e = B;
38
38
  return m && m.length > 0 && (e = e.filter(
39
39
  (r) => m.includes(r.encounterUuid)
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
- }, [S, m, b]), { data: N = [] } = E({
43
+ }, [B, m, b]), { data: N = [] } = E({
44
44
  queryKey: ["observationForms"],
45
45
  queryFn: () => Fe()
46
- }), H = c(
46
+ }), w = c(
47
47
  (e) => {
48
48
  const r = N.find((t) => t.name === e);
49
49
  if (!r?.privileges || r.privileges.length === 0) return !0;
@@ -55,23 +55,23 @@ const ke = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
55
55
  },
56
56
  [N, O]
57
57
  ), f = c(
58
- (e) => !y || e.encounterUuid !== y ? !1 : H(e.formName),
59
- [y, H]
60
- ), k = c(
58
+ (e) => !y || e.encounterUuid !== y ? !1 : w(e.formName),
59
+ [y, w]
60
+ ), H = c(
61
61
  (e) => N.find((o) => o.name === e)?.uuid,
62
62
  [N]
63
- ), I = d(() => {
63
+ ), v = d(() => {
64
64
  if (a)
65
- return k(a.formName);
66
- }, [a, k]), {
65
+ return H(a.formName);
66
+ }, [a, H]), {
67
67
  data: l,
68
68
  isLoading: se,
69
69
  isError: ae,
70
- error: v
70
+ error: I
71
71
  } = E({
72
- queryKey: ["formMetadata", I],
73
- queryFn: () => Ie(I),
74
- enabled: !!I && g
72
+ queryKey: ["formMetadata", v],
73
+ queryFn: () => ve(v),
74
+ enabled: !!v && g
75
75
  }), {
76
76
  data: _,
77
77
  isLoading: ne,
@@ -79,7 +79,7 @@ const ke = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
79
79
  error: A
80
80
  } = E({
81
81
  queryKey: ["formsEncounterFHIR", a?.encounterUuid],
82
- queryFn: () => ve(a.encounterUuid),
82
+ queryFn: () => Ie(a.encounterUuid),
83
83
  enabled: !!a?.encounterUuid && g
84
84
  });
85
85
  _e(
@@ -104,8 +104,8 @@ const ke = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
104
104
  const e = {}, r = (o, t) => {
105
105
  for (const s of o)
106
106
  if (s.type === "section") {
107
- const h = s.label?.value ?? "Section";
108
- r(s.controls ?? [], h);
107
+ const p = s.label?.value ?? "Section";
108
+ r(s.controls ?? [], p);
109
109
  } else
110
110
  s.id != null && t && (e[String(s.id)] = t), s.controls && r(s.controls, t);
111
111
  };
@@ -125,39 +125,39 @@ const ke = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
125
125
  l.schema.controls ?? []
126
126
  ), Object.keys(e).length > 0 ? e : void 0;
127
127
  }, [l]), ue = d(() => {
128
- if (v)
129
- return z(v).message;
128
+ if (I)
129
+ return z(I).message;
130
130
  if (A)
131
131
  return z(A).message;
132
- }, [v, A]), p = d(
132
+ }, [I, A]), h = d(
133
133
  () => [
134
134
  { key: "recordedOn", header: n("RECORDED_ON") },
135
135
  { key: "recordedBy", header: n("RECORDED_BY") }
136
136
  ],
137
137
  [n]
138
138
  ), q = d(
139
- () => [...p, { key: "actions", header: n("ACTIONS") }],
140
- [p, n]
139
+ () => [...h, { key: "actions", header: n("ACTIONS") }],
140
+ [h, n]
141
141
  ), fe = c(
142
- (e) => F && e.some((o) => f(o)) ? q : p,
143
- [F, f, q, p]
144
- ), pe = p, he = d(
142
+ (e) => F && e.some((o) => f(o)) ? q : h,
143
+ [F, f, q, h]
144
+ ), he = h, pe = d(
145
145
  () => [
146
146
  { key: "recordedOn", sortable: !0 },
147
147
  { key: "recordedBy", sortable: !0 }
148
148
  ],
149
149
  []
150
150
  ), P = d(() => {
151
- const e = w.reduce(
151
+ const e = U.reduce(
152
152
  (o, t) => {
153
153
  const s = t.formName;
154
154
  o[s] ??= [];
155
- const h = t.providers.map((ye) => ye.providerName).filter(Boolean).join(", ");
155
+ const p = t.providers.map((ye) => ye.providerName).filter(Boolean).join(", ");
156
156
  return o[s].push({
157
157
  id: t.encounterUuid,
158
158
  formName: t.formName,
159
159
  recordedOn: De(t.encounterDateTime, n, !0).formattedResult,
160
- recordedBy: h ?? "--",
160
+ recordedBy: p ?? "--",
161
161
  encounterDateTime: t.encounterDateTime,
162
162
  encounterUuid: t.encounterUuid
163
163
  }), o;
@@ -168,14 +168,14 @@ const ke = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
168
168
  ([o, t]) => ({
169
169
  formName: o,
170
170
  records: t.sort(
171
- (s, h) => h.encounterDateTime - s.encounterDateTime
171
+ (s, p) => p.encounterDateTime - s.encounterDateTime
172
172
  )
173
173
  })
174
174
  ).sort((o, t) => o.formName.localeCompare(t.formName));
175
- }, [w, n]), V = c((e) => {
176
- C(e), M(!0);
177
- }, []), x = c(() => {
178
- M(!1), C(null);
175
+ }, [U, n]), V = c((e) => {
176
+ L(e), M(!0);
177
+ }, []), $ = c(() => {
178
+ M(!1), L(null);
179
179
  }, []), R = c((e) => {
180
180
  globalThis.dispatchEvent(
181
181
  new CustomEvent(Ve, {
@@ -188,7 +188,7 @@ const ke = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
188
188
  }
189
189
  })
190
190
  );
191
- }, []), $ = c(
191
+ }, []), j = c(
192
192
  (e, r) => {
193
193
  switch (r) {
194
194
  case "recordedOn":
@@ -213,24 +213,24 @@ const ke = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
213
213
  },
214
214
  [V, R, f, n]
215
215
  );
216
- return /* @__PURE__ */ j(ge, { children: [
217
- /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: B || U || P.length === 0 || L ? /* @__PURE__ */ i(
216
+ return /* @__PURE__ */ x(ge, { children: [
217
+ /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: C || k || P.length === 0 || S ? /* @__PURE__ */ i(
218
218
  Q,
219
219
  {
220
- headers: pe,
220
+ headers: he,
221
221
  ariaLabel: n("FORMS_HEADING"),
222
222
  rows: [],
223
- loading: B,
224
- errorStateMessage: U ? te?.message : void 0,
223
+ loading: C,
224
+ errorStateMessage: k ? te?.message : void 0,
225
225
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
226
- renderCell: $,
226
+ renderCell: j,
227
227
  className: T.formsTableBody,
228
228
  dataTestId: "forms-table"
229
229
  }
230
- ) : /* @__PURE__ */ i(Ce, { align: "start", children: P.map((e, r) => {
230
+ ) : /* @__PURE__ */ i(Le, { align: "start", children: P.map((e, r) => {
231
231
  const { formName: o, records: t } = e, s = fe(t);
232
232
  return /* @__PURE__ */ i(
233
- Le,
233
+ Se,
234
234
  {
235
235
  title: o,
236
236
  className: T.customAccordianItem,
@@ -244,9 +244,9 @@ const ke = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
244
244
  rows: t,
245
245
  loading: !1,
246
246
  errorStateMessage: "",
247
- sortable: he,
247
+ sortable: pe,
248
248
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
249
- renderCell: $,
249
+ renderCell: j,
250
250
  className: T.formsTableBody,
251
251
  dataTestId: `forms-table-${o}`
252
252
  }
@@ -256,13 +256,13 @@ const ke = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
256
256
  );
257
257
  }) }) }),
258
258
  g && a && /* @__PURE__ */ i(
259
- Se,
259
+ Be,
260
260
  {
261
261
  id: "modalIdForActionAreaLayout",
262
262
  portalId: "main-display-area",
263
263
  open: g,
264
- onRequestClose: x,
265
- modalHeading: /* @__PURE__ */ j("div", { className: T.modalHeading, children: [
264
+ onRequestClose: $,
265
+ modalHeading: /* @__PURE__ */ x("div", { className: T.modalHeading, children: [
266
266
  /* @__PURE__ */ i("span", { children: a.formName }),
267
267
  F && f(a) && /* @__PURE__ */ i(
268
268
  G,
@@ -272,7 +272,7 @@ const ke = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
272
272
  size: "sm",
273
273
  testId: `edit-form-modal-${a.encounterUuid}`,
274
274
  onClick: () => {
275
- x(), R(a);
275
+ $(), R(a);
276
276
  },
277
277
  children: /* @__PURE__ */ i(K, {})
278
278
  }
@@ -283,7 +283,7 @@ const ke = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
283
283
  size: "md",
284
284
  testId: "form-details-modal",
285
285
  children: /* @__PURE__ */ i(
286
- Be,
286
+ Ce,
287
287
  {
288
288
  observations: de,
289
289
  isLoading: se || ne,
@@ -1,5 +1,5 @@
1
- import { jsx as d, jsxs as N } from "react/jsx-runtime";
2
- import { g as K, h as D, j as V, I as q, k as Q, l as k, r as G, n as H, u as P, a as j, w as z, m as J, p as W, o as Y, s as X, v as Z, y as x, q as ee } from "./index-BuzazPX_.js";
1
+ import { jsx as d, jsxs as S } from "react/jsx-runtime";
2
+ import { h as K, j as N, t as V, D as q, W as Q, l as k, n as G, o as H, u as P, a as j, w as z, p as W, m as J, s as Y, v as X, x as Z, y as x, q as ee } from "./index-D6eQA2wz.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 B = (t, i, c, l, u, r) => {
24
24
  )), a === "PDF" && (n = /* @__PURE__ */ d(H, { 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", y = 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
  {
@@ -38,7 +38,7 @@ const B = (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
- D,
41
+ N,
42
42
  {
43
43
  title: t.display,
44
44
  id: `grouped-obs-${t.display}-${l}`,
@@ -62,8 +62,8 @@ const B = (t, i, c, l, u, r) => {
62
62
  }) => {
63
63
  const { t: l } = U(), u = (r, s, o) => {
64
64
  const a = K(r.encounterDetails, l);
65
- return /* @__PURE__ */ N(
66
- D,
65
+ return /* @__PURE__ */ S(
66
+ N,
67
67
  {
68
68
  title: a,
69
69
  id: `encounter-${r.encounterId}`,
@@ -106,7 +106,7 @@ const B = (t, i, c, l, u, r) => {
106
106
  )
107
107
  }
108
108
  );
109
- }, ne = "Observations-module_observations__RKSyo", ie = "Observations-module_title__TJL3z", S = {
109
+ }, ne = "Observations-module_observations__RKSyo", ie = "Observations-module_title__TJL3z", D = {
110
110
  observations: ne,
111
111
  title: ie
112
112
  }, ce = (t) => ["conceptUuid", t], le = (t, i) => ["observations", t, ...i], ve = ({ config: t }) => {
@@ -133,20 +133,20 @@ const B = (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]), 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,
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,
138
138
  isLoading: y,
139
139
  isError: h,
140
140
  refetch: T
141
141
  } = se({
142
- queryKey: le(s, p),
143
- queryFn: () => J(s, p),
144
- enabled: !!s && p.length > 0 && f
142
+ queryKey: le(s, m),
143
+ queryFn: () => W(s, m),
144
+ enabled: !!s && m.length > 0 && f
145
145
  });
146
- W(
146
+ J(
147
147
  (e) => {
148
148
  e.patientUUID === s && e.updatedConcepts.size > 0 && [...e.updatedConcepts.keys()].some(
149
- (R) => p.includes(R)
149
+ (R) => m.includes(R)
150
150
  ) && T();
151
151
  },
152
152
  [s, T]
@@ -157,22 +157,22 @@ const B = (t, i, c, l, u, r) => {
157
157
  type: "error"
158
158
  });
159
159
  }, [h]);
160
- const I = g(() => {
161
- if (!m) return [];
162
- const e = Y(m), v = X(e);
160
+ const _ = g(() => {
161
+ if (!p) return [];
162
+ const e = Y(p), v = X(e);
163
163
  return Z(v);
164
- }, [m]), A = [
164
+ }, [p]), A = [
165
165
  { key: "name", header: "name" },
166
166
  { key: "value", header: "value" },
167
167
  { key: "form", header: "form" }
168
- ], _ = 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, w = I.length > 0 && !_ && !$, O = i.titleTranslationKey, E = O ? a(O) : "";
169
- return /* @__PURE__ */ N(
168
+ ], I = y || !f, $ = h && f, F = (!p || p.entry?.length === 0 || m.length === 0) && f, L = $ ? a("ERROR_FETCHING_OBSERVATIONS") : null, M = F ? a("NO_OBSERVATIONS_FOUND") : void 0, w = _.length > 0 && !I && !$, O = i.titleTranslationKey, E = O ? a(O) : "";
169
+ return /* @__PURE__ */ S(
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: S.observations,
175
+ className: D.observations,
176
176
  children: [
177
177
  /* @__PURE__ */ d(
178
178
  x,
@@ -180,14 +180,14 @@ const B = (t, i, c, l, u, r) => {
180
180
  id: "observations-title",
181
181
  testId: O ? `observations-title-${E}` : "observations-title",
182
182
  title: E,
183
- className: S.title,
183
+ className: D.title,
184
184
  children: /* @__PURE__ */ d("p", { children: E })
185
185
  }
186
186
  ),
187
187
  w ? /* @__PURE__ */ d(
188
188
  ae,
189
189
  {
190
- groupedData: I,
190
+ groupedData: _,
191
191
  title: E,
192
192
  hideThumbnail: u
193
193
  }
@@ -197,7 +197,7 @@ const B = (t, i, c, l, u, r) => {
197
197
  headers: A,
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"