@bahmni/widgets 0.0.1-dev.295 → 0.0.1-dev.297

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, v as J, t as Z, O as x, i as ee, I as te } from "./index-PNPsmLqq.js";
2
+ import { u as W, a as X, R as J, t as Z, A as x, i as ee, I as te } from "./index-CRtgEAeB.js";
3
3
  import { useQuery as ne } from "@tanstack/react-query";
4
4
  import { useState as l, useCallback as _, useEffect as g, 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
- ), f = W(), { t: o } = ae(), { addNotification: U } = X(), V = Number(n?.pageSize) || 5, [N, O] = l(1), [u, $] = l(V), [k, C] = l(void 0), v = _((e) => {
42
+ ), f = W(), { t: o } = ae(), { addNotification: U } = X(), V = Number(n?.pageSize) || 5, [N, C] = l(1), [u, $] = l(V), [k, O] = l(void 0), v = _((e) => {
43
43
  L(e), w(!0);
44
44
  }, []), z = _(() => {
45
45
  w(!1), L(null), A(/* @__PURE__ */ new Set());
@@ -62,9 +62,9 @@ const Te = [
62
62
  )
63
63
  });
64
64
  g(() => {
65
- i && C(i.total);
65
+ i && O(i.total);
66
66
  }, [i]), g(() => {
67
- O(1), C(void 0);
67
+ C(1), O(void 0);
68
68
  }, [f]), g(() => {
69
69
  S && U({
70
70
  title: o("ERROR_DEFAULT_TITLE"),
@@ -92,7 +92,7 @@ const Te = [
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(
@@ -1,35 +1,35 @@
1
1
  import { jsx as n, jsxs as Z, Fragment as ee } from "react/jsx-runtime";
2
- import { J as re, u as te, j as oe, r as ae, e as se, b as ne, U as de, g as ie, M as q, O as me, t as le, i as x, X as ce, Q as ue, I as fe, c as ye } from "./index-PNPsmLqq.js";
2
+ import { Q as re, u as te, V as oe, n as ae, b as se, r as ne, q as de, y as ie, M as U, A as me, t as le, i as x, X as ce, c as ue, I as fe, O as ye } from "./index-CRtgEAeB.js";
3
3
  import { useQueryClient as be, useQuery as y } from "@tanstack/react-query";
4
4
  import { useState as k, useMemo as d, useCallback as b } from "react";
5
5
  import { useTranslation as pe } from "react-i18next";
6
- const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_customAccordianItem__isszs", E = {
6
+ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_customAccordianItem__isszs", O = {
7
7
  formsTableBody: ge,
8
8
  customAccordianItem: Fe
9
9
  }, he = (m) => m ? m.extension?.find(
10
10
  (p) => p.url === re
11
- )?.valueString : void 0, Ae = ({
11
+ )?.valueString : void 0, Me = ({
12
12
  episodeOfCareUuids: m,
13
13
  encounterUuids: i,
14
14
  config: p
15
15
  }) => {
16
- const { t: s } = pe(), l = te(), [c, I] = k(!1), [o, M] = k(null), {
17
- numberOfVisits: j,
18
- hideThumbnail: w = !1,
16
+ const { t: s } = pe(), l = te(), [c, A] = k(!1), [o, I] = k(null), {
17
+ numberOfVisits: w,
18
+ hideThumbnail: P = !1,
19
19
  forms: u
20
- } = p ?? {}, A = oe(
20
+ } = p ?? {}, M = oe(
21
21
  m,
22
22
  i
23
- ), P = be(), {
23
+ ), Q = be(), {
24
24
  data: D = [],
25
25
  isLoading: v,
26
26
  isError: B,
27
- error: H,
28
- refetch: K
27
+ error: V,
28
+ refetch: H
29
29
  } = y({
30
30
  queryKey: ["forms", l, m],
31
- queryFn: () => ae(l, void 0, j),
32
- enabled: !!l && !A
31
+ queryFn: () => ae(l, void 0, w),
32
+ enabled: !!l && !M
33
33
  }), T = d(() => {
34
34
  let e = D;
35
35
  return i && i.length > 0 && (e = e.filter(
@@ -47,8 +47,8 @@ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
47
47
  if (o)
48
48
  return L(o.formName);
49
49
  }, [o, L]), {
50
- isLoading: Q,
51
- isError: V,
50
+ isLoading: K,
51
+ isError: j,
52
52
  error: F
53
53
  } = y({
54
54
  queryKey: ["formMetadata", g],
@@ -66,41 +66,41 @@ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
66
66
  });
67
67
  ie(
68
68
  (e) => {
69
- e.patientUUID === l && e.updatedConcepts.size > 0 && (K(), P.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
69
+ e.patientUUID === l && e.updatedConcepts.size > 0 && (H(), Q.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
70
70
  },
71
71
  [l]
72
72
  );
73
73
  const G = d(() => !h?.entry || !o?.formName ? [] : h.entry.filter((t) => t.resource?.resourceType === "Observation").map((t) => t.resource).filter((t) => {
74
74
  const r = he(t);
75
75
  return !r || r.includes(o.formName);
76
- }), [h, o?.formName]), J = d(() => {
76
+ }), [h, o?.formName]), X = d(() => {
77
77
  if (F)
78
- return q(F).message;
78
+ return U(F).message;
79
79
  if (N)
80
- return q(N).message;
80
+ return U(N).message;
81
81
  }, [F, N]), R = d(
82
82
  () => [
83
83
  { key: "recordedOn", header: s("RECORDED_ON") },
84
84
  { key: "recordedBy", header: s("RECORDED_BY") }
85
85
  ],
86
86
  [s]
87
- ), X = d(
87
+ ), Y = d(
88
88
  () => [
89
89
  { key: "recordedOn", sortable: !0 },
90
90
  { key: "recordedBy", sortable: !0 }
91
91
  ],
92
92
  []
93
- ), C = d(() => {
93
+ ), q = d(() => {
94
94
  const e = T.reduce(
95
95
  (r, a) => {
96
96
  const f = a.formName;
97
97
  r[f] ??= [];
98
- const O = a.providers.map((W) => W.providerName).filter(Boolean).join(", ");
98
+ const E = a.providers.map((W) => W.providerName).filter(Boolean).join(", ");
99
99
  return r[f].push({
100
100
  id: a.encounterUuid,
101
101
  formName: a.formName,
102
102
  recordedOn: me(a.encounterDateTime, s, !0).formattedResult,
103
- recordedBy: O ?? "--",
103
+ recordedBy: E ?? "--",
104
104
  encounterDateTime: a.encounterDateTime,
105
105
  encounterUuid: a.encounterUuid
106
106
  }), r;
@@ -111,48 +111,48 @@ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
111
111
  ([r, a]) => ({
112
112
  formName: r,
113
113
  records: a.sort(
114
- (f, O) => O.encounterDateTime - f.encounterDateTime
114
+ (f, E) => E.encounterDateTime - f.encounterDateTime
115
115
  )
116
116
  })
117
117
  ).sort((r, a) => r.formName.localeCompare(a.formName));
118
- }, [T, s]), S = b((e) => {
119
- M(e), I(!0);
120
- }, []), Y = b(() => {
121
- I(!1), M(null);
122
- }, []), U = b(
118
+ }, [T, s]), C = b((e) => {
119
+ I(e), A(!0);
120
+ }, []), J = b(() => {
121
+ A(!1), I(null);
122
+ }, []), S = b(
123
123
  (e, t) => {
124
124
  switch (t) {
125
125
  case "recordedOn":
126
- return /* @__PURE__ */ n(le, { onClick: () => S(e), children: e.recordedOn });
126
+ return /* @__PURE__ */ n(le, { onClick: () => C(e), children: e.recordedOn });
127
127
  case "recordedBy":
128
128
  return e.recordedBy;
129
129
  default:
130
130
  return null;
131
131
  }
132
132
  },
133
- [S]
133
+ [C]
134
134
  );
135
135
  return /* @__PURE__ */ Z(ee, { children: [
136
- /* @__PURE__ */ n("div", { id: "forms-table", "data-testid": "forms-table", children: v || B || C.length === 0 || A ? /* @__PURE__ */ n(
136
+ /* @__PURE__ */ n("div", { id: "forms-table", "data-testid": "forms-table", children: v || B || q.length === 0 || M ? /* @__PURE__ */ n(
137
137
  x,
138
138
  {
139
139
  headers: R,
140
140
  ariaLabel: s("FORMS_HEADING"),
141
141
  rows: [],
142
142
  loading: v,
143
- errorStateMessage: B ? H?.message : void 0,
143
+ errorStateMessage: B ? V?.message : void 0,
144
144
  emptyStateMessage: s("FORMS_UNAVAILABLE"),
145
- renderCell: U,
146
- className: E.formsTableBody,
145
+ renderCell: S,
146
+ className: O.formsTableBody,
147
147
  dataTestId: "forms-table"
148
148
  }
149
- ) : /* @__PURE__ */ n(ce, { align: "start", children: C.map((e, t) => {
149
+ ) : /* @__PURE__ */ n(ce, { align: "start", children: q.map((e, t) => {
150
150
  const { formName: r, records: a } = e;
151
151
  return /* @__PURE__ */ n(
152
152
  ue,
153
153
  {
154
154
  title: r,
155
- className: E.customAccordianItem,
155
+ className: O.customAccordianItem,
156
156
  testId: `accordian-title-${r}`,
157
157
  open: t === 0,
158
158
  children: /* @__PURE__ */ n(
@@ -163,10 +163,10 @@ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
163
163
  rows: a,
164
164
  loading: !1,
165
165
  errorStateMessage: "",
166
- sortable: X,
166
+ sortable: Y,
167
167
  emptyStateMessage: s("FORMS_UNAVAILABLE"),
168
- renderCell: U,
169
- className: E.formsTableBody,
168
+ renderCell: S,
169
+ className: O.formsTableBody,
170
170
  dataTestId: `forms-table-${r}`
171
171
  }
172
172
  )
@@ -180,7 +180,7 @@ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
180
180
  id: "modalIdForActionAreaLayout",
181
181
  portalId: "main-display-area",
182
182
  open: c,
183
- onRequestClose: Y,
183
+ onRequestClose: J,
184
184
  modalHeading: o.formName,
185
185
  modalLabel: `${o.recordedOn} | ${o.recordedBy}`,
186
186
  passiveModal: !0,
@@ -190,12 +190,12 @@ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
190
190
  ye,
191
191
  {
192
192
  observations: G,
193
- isLoading: Q || $,
194
- isError: V || z,
195
- errorMessage: J,
193
+ isLoading: K || $,
194
+ isError: j || z,
195
+ errorMessage: X,
196
196
  emptyStateMessage: s("NO_FORM_DATA_AVAILABLE"),
197
197
  testIdPrefix: o.formName,
198
- hideThumbnail: w
198
+ hideThumbnail: P
199
199
  }
200
200
  )
201
201
  }
@@ -203,5 +203,5 @@ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
203
203
  ] });
204
204
  };
205
205
  export {
206
- Ae as default
206
+ Me as default
207
207
  };
@@ -1,7 +1,7 @@
1
1
  import { jsx as d, jsxs as N } from "react/jsx-runtime";
2
- import { f as M, d as C, h as V, k as Q, o as k, l as q, w as H, m as G, u as P, a as j, n as z, D as J, g as Y, p as W, q as X, s as Z, H as x, i as ee } from "./index-PNPsmLqq.js";
2
+ import { f as M, d as D, e as V, g as Q, o as k, h as q, w as H, m as G, u as P, a as j, j as z, C as J, y as Y, k as W, l as X, s as Z, H as x, i as ee } from "./index-CRtgEAeB.js";
3
3
  import { useQueries as te, useQuery as se } from "@tanstack/react-query";
4
- import { useRef as oe, useEffect as D, useMemo as g } from "react";
4
+ import { useRef as oe, useEffect as C, useMemo as h } from "react";
5
5
  import { useTranslation as U } from "react-i18next";
6
6
  const w = (t, i, c, l, u, r) => {
7
7
  const s = V(t, i, u), o = s.value, a = Q(o);
@@ -38,7 +38,7 @@ const w = (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}`,
@@ -63,7 +63,7 @@ const w = (t, i, c, l, u, r) => {
63
63
  const { t: l } = U(), u = (r, s, o) => {
64
64
  const a = M(r.encounterDetails, l);
65
65
  return /* @__PURE__ */ N(
66
- C,
66
+ D,
67
67
  {
68
68
  title: a,
69
69
  id: `encounter-${r.encounterId}`,
@@ -121,7 +121,7 @@ const w = (t, i, c, l, u, r) => {
121
121
  enabled: !!e
122
122
  }))
123
123
  });
124
- D(() => {
124
+ C(() => {
125
125
  n.forEach((e, v) => {
126
126
  if (e.isError && !r.current.has(v)) {
127
127
  const R = c[v];
@@ -133,10 +133,10 @@ const w = (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]), {
136
+ const b = h(() => n.map((e) => e.data?.uuid).filter((e) => !!e), [n]), m = h(() => [.../* @__PURE__ */ new Set([...b, ...l])], [b, l]), f = h(() => c.length === 0 ? !0 : n.every((e) => !e.isLoading), [n, c.length]), {
137
137
  data: p,
138
138
  isLoading: y,
139
- isError: h,
139
+ isError: g,
140
140
  refetch: T
141
141
  } = se({
142
142
  queryKey: le(s, m),
@@ -150,22 +150,22 @@ const w = (t, i, c, l, u, r) => {
150
150
  ) && T();
151
151
  },
152
152
  [s, T]
153
- ), D(() => {
154
- h && o({
153
+ ), C(() => {
154
+ g && o({
155
155
  title: a("ERROR_DEFAULT_TITLE"),
156
156
  message: a("ERROR_FETCHING_OBSERVATIONS"),
157
157
  type: "error"
158
158
  });
159
- }, [h]);
160
- const _ = g(() => {
159
+ }, [g]);
160
+ const _ = h(() => {
161
161
  if (!p) return [];
162
162
  const e = W(p), v = X(e);
163
163
  return Z(v);
164
- }, [p]), B = [
164
+ }, [p]), A = [
165
165
  { key: "name", header: "name" },
166
166
  { key: "value", header: "value" },
167
167
  { key: "form", header: "form" }
168
- ], I = y || !f, $ = h && f, A = (!p || p.entry?.length === 0 || m.length === 0) && f, F = $ ? a("ERROR_FETCHING_OBSERVATIONS") : null, L = A ? a("NO_OBSERVATIONS_FOUND") : void 0, K = _.length > 0 && !I && !$, O = i.titleTranslationKey, E = O ? a(O) : "";
168
+ ], I = y || !f, $ = g && f, B = (!p || p.entry?.length === 0 || m.length === 0) && f, F = $ ? a("ERROR_FETCHING_OBSERVATIONS") : null, L = B ? a("NO_OBSERVATIONS_FOUND") : void 0, K = _.length > 0 && !I && !$, O = i.titleTranslationKey, E = O ? a(O) : "";
169
169
  return /* @__PURE__ */ N(
170
170
  "div",
171
171
  {
@@ -194,7 +194,7 @@ const w = (t, i, c, l, u, r) => {
194
194
  ) : /* @__PURE__ */ d(
195
195
  ee,
196
196
  {
197
- headers: B,
197
+ headers: A,
198
198
  rows: [],
199
199
  ariaLabel: a("OBSERVATIONS"),
200
200
  loading: I,