@bahmni/widgets 0.0.1-dev.315 → 0.0.1-dev.316

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 Y } from "react/jsx-runtime";
2
- import { u as W, a as Z, R as X, Z as J, N as x, j as ee, P as te } from "./index-CuwGq3LN.js";
1
+ import { jsx as r, jsxs as T, Fragment as Q } from "react/jsx-runtime";
2
+ import { u as W, a as Z, A as X, Z as J, Y as x, j as ee, P as te } from "./index-C4zXayYk.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, P = (n) => n.attachments.length > 0 ? n.attachments : n.documentUrl ? [{ url: n.documentUrl, contentType: n.contentType }] : [], Ie = ({ config: n, encounterUuids: E }) => {
38
38
  const [d, L] = l(!1), [s, U] = l(
39
39
  null
40
- ), [F, N] = l(
40
+ ), [F, A] = l(
41
41
  /* @__PURE__ */ new Set()
42
- ), f = W(), { t: o } = ae(), { addNotification: w } = Z(), V = Number(n?.pageSize) || 5, [A, C] = l(1), [u, $] = l(V), [k, O] = l(void 0), v = _((e) => {
42
+ ), f = W(), { t: o } = ae(), { addNotification: w } = Z(), V = Number(n?.pageSize) || 5, [N, 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), N(/* @__PURE__ */ new Set());
45
+ L(!1), U(null), A(/* @__PURE__ */ new Set());
46
46
  }, []), R = _((e) => {
47
- N((t) => new Set(t).add(e));
47
+ A((t) => new Set(t).add(e));
48
48
  }, []), { data: i, isLoading: z, isError: S, error: y } = ne({
49
49
  queryKey: [
50
50
  "documents",
51
51
  f,
52
52
  E,
53
- A,
53
+ N,
54
54
  u
55
55
  ],
56
56
  enabled: !!f,
@@ -58,7 +58,7 @@ const Te = [
58
58
  f,
59
59
  E,
60
60
  u,
61
- A
61
+ N
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 || N(a);
90
+ e.signal.aborted || A(a);
91
91
  })(), () => e.abort();
92
92
  }, [d, s]);
93
93
  const j = _(
@@ -98,7 +98,7 @@ const Te = [
98
98
  ), D = p(
99
99
  () => n?.fields ?? Te,
100
100
  [n?.fields]
101
- ), q = 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(
101
+ ), q = 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]), Y = p(() => he(D, o), [D, o]), K = 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 ? P(s) : [],
109
109
  [s]
110
- ), Q = _(
110
+ ), G = _(
111
111
  (e, t) => {
112
112
  switch (t) {
113
113
  case "documentIdentifier":
@@ -138,23 +138,23 @@ const Te = [
138
138
  },
139
139
  [v, o]
140
140
  );
141
- return /* @__PURE__ */ T(Y, { children: [
141
+ return /* @__PURE__ */ T(Q, { children: [
142
142
  /* @__PURE__ */ r("div", { "data-testid": "documents-table", children: /* @__PURE__ */ r(
143
143
  ee,
144
144
  {
145
- headers: K,
145
+ headers: Y,
146
146
  ariaLabel: o("DOCUMENTS_TABLE_HEADING"),
147
147
  rows: q,
148
148
  loading: z,
149
149
  errorStateMessage: S ? y?.message : null,
150
- sortable: G,
150
+ sortable: K,
151
151
  emptyStateMessage: o("DOCUMENTS_NO_RECORDS"),
152
- renderCell: Q,
152
+ renderCell: G,
153
153
  className: c.documentsTableBody,
154
154
  dataTestId: "documents-table",
155
155
  pageSize: u,
156
156
  totalItems: k,
157
- page: A,
157
+ page: N,
158
158
  onPageChange: j
159
159
  }
160
160
  ) }),
@@ -1,65 +1,65 @@
1
1
  import { jsx as i, jsxs as oe, Fragment as te } from "react/jsx-runtime";
2
- import { b as se, u as ae, B as ne, o as de, n as ie, s as ce, c as le, E as me, q as j, N as ue, Z as fe, j as k, T as ye, d as be, P as pe, O as he } from "./index-CuwGq3LN.js";
2
+ import { b as se, u as ae, c as ne, i as de, o as ie, d as ce, H as le, _ as me, q as k, Y as ue, Z as fe, j as x, T as ye, R as be, P as pe, O as he } from "./index-C4zXayYk.js";
3
3
  import { useQueryClient as ge, useQuery as p } from "@tanstack/react-query";
4
- import { useState as x, useMemo as d, useCallback as h } from "react";
5
- import { useTranslation as Ne } from "react-i18next";
6
- const Ee = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_customAccordianItem__isszs", v = {
7
- formsTableBody: Ee,
8
- customAccordianItem: Fe
9
- }, Oe = (m) => m ? m.extension?.find(
4
+ import { useState as H, useMemo as d, useCallback as h } from "react";
5
+ import { useTranslation as Fe } from "react-i18next";
6
+ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_customAccordianItem__isszs", v = {
7
+ formsTableBody: Ne,
8
+ customAccordianItem: Oe
9
+ }, Ee = (m) => m ? m.extension?.find(
10
10
  (g) => g.url === se
11
- )?.valueString : void 0, De = ({
11
+ )?.valueString : void 0, Te = ({
12
12
  episodeOfCareUuids: m,
13
13
  encounterUuids: c,
14
14
  config: g
15
15
  }) => {
16
- const { t: n } = Ne(), u = ae(), [y, M] = x(!1), [a, I] = x(null), {
16
+ const { t: n } = Fe(), u = ae(), [y, M] = H(!1), [a, A] = H(null), {
17
17
  numberOfVisits: P,
18
- hideThumbnail: H = !1,
18
+ hideThumbnail: j = !1,
19
19
  forms: b
20
- } = g ?? {}, A = ne(
20
+ } = g ?? {}, I = ne(
21
21
  m,
22
22
  c
23
23
  ), w = ge(), {
24
- data: B = [],
25
- isLoading: D,
26
- isError: T,
24
+ data: D = [],
25
+ isLoading: T,
26
+ isError: _,
27
27
  error: K,
28
28
  refetch: V
29
29
  } = p({
30
30
  queryKey: ["forms", u, m],
31
31
  queryFn: () => de(u, void 0, P),
32
- enabled: !!u && !A
33
- }), _ = d(() => {
34
- let e = B;
32
+ enabled: !!u && !I
33
+ }), B = d(() => {
34
+ let e = D;
35
35
  return c && c.length > 0 && (e = e.filter(
36
36
  (o) => c.includes(o.encounterUuid)
37
37
  )), Array.isArray(b) && b.length > 0 && (e = e.filter(
38
38
  (o) => b.some((r) => r.toLowerCase() === o.formName.toLowerCase())
39
39
  )), e;
40
- }, [B, c, b]), { data: L = [] } = p({
40
+ }, [D, c, b]), { data: R = [] } = p({
41
41
  queryKey: ["observationForms"],
42
42
  queryFn: () => ie()
43
- }), R = h(
44
- (e) => L.find((r) => r.name === e)?.uuid,
45
- [L]
46
- ), N = d(() => {
43
+ }), L = h(
44
+ (e) => R.find((r) => r.name === e)?.uuid,
45
+ [R]
46
+ ), F = d(() => {
47
47
  if (a)
48
- return R(a.formName);
49
- }, [a, R]), {
48
+ return L(a.formName);
49
+ }, [a, L]), {
50
50
  data: l,
51
- isLoading: $,
52
- isError: z,
53
- error: E
51
+ isLoading: Y,
52
+ isError: $,
53
+ error: N
54
54
  } = p({
55
- queryKey: ["formMetadata", N],
56
- queryFn: () => ce(N),
57
- enabled: !!N && y
55
+ queryKey: ["formMetadata", F],
56
+ queryFn: () => ce(F),
57
+ enabled: !!F && y
58
58
  }), {
59
- data: F,
60
- isLoading: G,
61
- isError: Q,
62
- error: O
59
+ data: O,
60
+ isLoading: z,
61
+ isError: G,
62
+ error: E
63
63
  } = p({
64
64
  queryKey: ["formsEncounterFHIR", a?.encounterUuid],
65
65
  queryFn: () => le(a.encounterUuid),
@@ -71,10 +71,10 @@ const Ee = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
71
71
  },
72
72
  [u]
73
73
  );
74
- const Z = d(() => !F?.entry || !a?.formName ? [] : F.entry.filter((o) => o.resource?.resourceType === "Observation").map((o) => o.resource).filter((o) => {
75
- const r = Oe(o);
74
+ const Q = d(() => !O?.entry || !a?.formName ? [] : O.entry.filter((o) => o.resource?.resourceType === "Observation").map((o) => o.resource).filter((o) => {
75
+ const r = Ee(o);
76
76
  return !r || r.includes(a.formName);
77
- }), [F, a?.formName]), Y = d(() => {
77
+ }), [O, a?.formName]), Z = d(() => {
78
78
  if (!l?.schema) return;
79
79
  const e = [], o = (r) => {
80
80
  (r ?? []).forEach((t) => {
@@ -100,11 +100,11 @@ const Ee = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
100
100
  null
101
101
  ), Object.keys(e).length > 0 ? e : void 0;
102
102
  }, [l]), W = d(() => {
103
+ if (N)
104
+ return k(N).message;
103
105
  if (E)
104
- return j(E).message;
105
- if (O)
106
- return j(O).message;
107
- }, [E, O]), C = d(
106
+ return k(E).message;
107
+ }, [N, E]), C = d(
108
108
  () => [
109
109
  { key: "recordedOn", header: n("RECORDED_ON") },
110
110
  { key: "recordedBy", header: n("RECORDED_BY") }
@@ -117,7 +117,7 @@ const Ee = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
117
117
  ],
118
118
  []
119
119
  ), S = d(() => {
120
- const e = _.reduce(
120
+ const e = B.reduce(
121
121
  (r, t) => {
122
122
  const s = t.formName;
123
123
  r[s] ??= [];
@@ -141,10 +141,10 @@ const Ee = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
141
141
  )
142
142
  })
143
143
  ).sort((r, t) => r.formName.localeCompare(t.formName));
144
- }, [_, n]), q = h((e) => {
145
- I(e), M(!0);
144
+ }, [B, n]), q = h((e) => {
145
+ A(e), M(!0);
146
146
  }, []), ee = h(() => {
147
- M(!1), I(null);
147
+ M(!1), A(null);
148
148
  }, []), U = h(
149
149
  (e, o) => {
150
150
  switch (o) {
@@ -159,14 +159,14 @@ const Ee = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
159
159
  [q]
160
160
  );
161
161
  return /* @__PURE__ */ oe(te, { children: [
162
- /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: D || T || S.length === 0 || A ? /* @__PURE__ */ i(
163
- k,
162
+ /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: T || _ || S.length === 0 || I ? /* @__PURE__ */ i(
163
+ x,
164
164
  {
165
165
  headers: C,
166
166
  ariaLabel: n("FORMS_HEADING"),
167
167
  rows: [],
168
- loading: D,
169
- errorStateMessage: T ? K?.message : void 0,
168
+ loading: T,
169
+ errorStateMessage: _ ? K?.message : void 0,
170
170
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
171
171
  renderCell: U,
172
172
  className: v.formsTableBody,
@@ -182,7 +182,7 @@ const Ee = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
182
182
  testId: `accordian-title-${r}`,
183
183
  open: o === 0,
184
184
  children: /* @__PURE__ */ i(
185
- k,
185
+ x,
186
186
  {
187
187
  headers: C,
188
188
  ariaLabel: n("FORMS_HEADING"),
@@ -215,14 +215,14 @@ const Ee = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
215
215
  children: /* @__PURE__ */ i(
216
216
  he,
217
217
  {
218
- observations: Z,
219
- isLoading: $ || G,
220
- isError: z || Q,
218
+ observations: Q,
219
+ isLoading: Y || z,
220
+ isError: $ || G,
221
221
  errorMessage: W,
222
222
  emptyStateMessage: n("NO_FORM_DATA_AVAILABLE"),
223
223
  testIdPrefix: a.formName,
224
- hideThumbnail: H,
225
- controlOrder: Y,
224
+ hideThumbnail: j,
225
+ controlOrder: Z,
226
226
  sectionMap: J
227
227
  }
228
228
  )
@@ -231,5 +231,5 @@ const Ee = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
231
231
  ] });
232
232
  };
233
233
  export {
234
- De as default
234
+ Te as default
235
235
  };
@@ -1,13 +1,13 @@
1
1
  import { jsx as d, jsxs as N } from "react/jsx-runtime";
2
- import { f as H, J as D, t as K, $ as V, F as w, X as j, e as k, Q as q, u as G, a as P, g as J, x as z, E as X, h as Y, i as x, k as W, l as Z, j as ee } from "./index-CuwGq3LN.js";
2
+ import { f as H, J as D, t as K, B as V, F as w, X as k, e as j, Q as q, u as G, a as P, s as J, M as z, _ as X, g as Y, h as W, k as Z, l as x, j as ee } from "./index-C4zXayYk.js";
3
3
  import { useQueries as te, useQuery as se } from "@tanstack/react-query";
4
4
  import { useRef as oe, useEffect as S, useMemo as g } from "react";
5
5
  import { useTranslation as U } from "react-i18next";
6
- const F = (t, i, c, l, u, r) => {
6
+ const B = (t, i, c, l, u, r) => {
7
7
  const s = K(t, i, u), o = s.value, a = V(o);
8
8
  let n = o;
9
9
  a === "Image" && (n = /* @__PURE__ */ d(
10
- j,
10
+ k,
11
11
  {
12
12
  imageSrc: o,
13
13
  alt: o,
@@ -15,7 +15,7 @@ const F = (t, i, c, l, u, r) => {
15
15
  hideThumbnail: r
16
16
  }
17
17
  )), a === "Video" && (n = /* @__PURE__ */ d(
18
- k,
18
+ j,
19
19
  {
20
20
  id: `${o}-video`,
21
21
  videoSrc: o,
@@ -24,16 +24,16 @@ const F = (t, i, c, l, u, r) => {
24
24
  )), a === "PDF" && (n = /* @__PURE__ */ d(q, { 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", E = l ? `${l}-${m}-${p}-${c}-${i}` : `${m}-${p}-${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
  {
31
31
  header: s.header,
32
32
  value: n,
33
33
  info: b,
34
- id: E,
35
- testId: E,
36
- ariaLabel: E
34
+ id: y,
35
+ testId: y,
36
+ ariaLabel: y
37
37
  },
38
38
  `obs-${t.id}`
39
39
  );
@@ -44,7 +44,7 @@ const F = (t, i, c, l, u, r) => {
44
44
  id: `grouped-obs-${t.display}-${l}`,
45
45
  open: c,
46
46
  children: t.members?.map(
47
- (o, a) => F(
47
+ (o, a) => B(
48
48
  o,
49
49
  a,
50
50
  u,
@@ -70,7 +70,7 @@ const F = (t, i, c, l, u, r) => {
70
70
  open: s,
71
71
  children: [
72
72
  r.observations.map(
73
- (n, b) => F(
73
+ (n, b) => B(
74
74
  n,
75
75
  b,
76
76
  o,
@@ -135,7 +135,7 @@ const F = (t, i, c, l, u, r) => {
135
135
  }, [n, c]);
136
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
137
  data: m,
138
- isLoading: E,
138
+ isLoading: y,
139
139
  isError: h,
140
140
  refetch: T
141
141
  } = se({
@@ -157,47 +157,47 @@ const F = (t, i, c, l, u, r) => {
157
157
  type: "error"
158
158
  });
159
159
  }, [h]);
160
- const $ = g(() => {
160
+ const _ = g(() => {
161
161
  if (!m) return [];
162
- const e = Y(m), v = x(e);
163
- return W(v);
164
- }, [m]), B = [
162
+ const e = Y(m), v = W(e);
163
+ return Z(v);
164
+ }, [m]), F = [
165
165
  { key: "name", header: "name" },
166
166
  { key: "value", header: "value" },
167
167
  { key: "form", header: "form" }
168
- ], _ = E || !f, I = h && f, A = (!m || m.entry?.length === 0 || p.length === 0) && f, L = I ? a("ERROR_FETCHING_OBSERVATIONS") : null, M = A ? a("NO_OBSERVATIONS_FOUND") : void 0, Q = $.length > 0 && !_ && !I, O = i.titleTranslationKey, y = O ? a(O) : "";
168
+ ], I = y || !f, $ = h && f, A = (!m || m.entry?.length === 0 || p.length === 0) && f, L = $ ? a("ERROR_FETCHING_OBSERVATIONS") : null, M = A ? 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
  {
172
172
  id: "observations",
173
- "data-testid": O ? `observations-${y}` : "observations",
173
+ "data-testid": O ? `observations-${E}` : "observations",
174
174
  "aria-label": "observations-aria-label",
175
175
  className: C.observations,
176
176
  children: [
177
177
  /* @__PURE__ */ d(
178
- Z,
178
+ x,
179
179
  {
180
180
  id: "observations-title",
181
- testId: O ? `observations-title-${y}` : "observations-title",
182
- title: y,
181
+ testId: O ? `observations-title-${E}` : "observations-title",
182
+ title: E,
183
183
  className: C.title,
184
- children: /* @__PURE__ */ d("p", { children: y })
184
+ children: /* @__PURE__ */ d("p", { children: E })
185
185
  }
186
186
  ),
187
187
  Q ? /* @__PURE__ */ d(
188
188
  ae,
189
189
  {
190
- groupedData: $,
191
- title: y,
190
+ groupedData: _,
191
+ title: E,
192
192
  hideThumbnail: u
193
193
  }
194
194
  ) : /* @__PURE__ */ d(
195
195
  ee,
196
196
  {
197
- headers: B,
197
+ headers: F,
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"