@bahmni/widgets 0.0.1-dev.242 → 0.0.1-dev.246

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 s, jsxs as _, Fragment as Q } from "react/jsx-runtime";
2
- import { u as W, a as X, l as J, f as Z, k as x, m as ee, y as te } from "./index-CA2IZdZE.js";
2
+ import { u as W, a as X, y as J, f as Z, M as x, m as ee, b as te } from "./index-B8Sjdo3W.js";
3
3
  import { useQuery as ne } from "@tanstack/react-query";
4
4
  import { useState as l, useCallback as f, useEffect as N, useMemo as p } from "react";
5
5
  import { useTranslation as ae } from "react-i18next";
@@ -35,14 +35,14 @@ const _e = [
35
35
  "uploadedBy",
36
36
  "action"
37
37
  ], fe = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, R = (n) => n.attachments.length > 0 ? n.attachments : n.documentUrl ? [{ url: n.documentUrl, contentType: n.contentType }] : [], Ne = ({ config: n, encounterUuids: E }) => {
38
- const [d, M] = l(!1), [r, U] = l(
38
+ const [d, L] = l(!1), [r, U] = l(
39
39
  null
40
- ), [k, A] = l(
40
+ ), [P, A] = l(
41
41
  /* @__PURE__ */ new Set()
42
- ), T = W(), { t: o } = ae(), { addNotification: w } = X(), P = Number(n?.pageSize) || 5, [D, O] = l(1), [m, F] = l(P), [$, C] = l(void 0), b = f((e) => {
43
- U(e), M(!0);
42
+ ), T = W(), { t: o } = ae(), { addNotification: w } = X(), F = Number(n?.pageSize) || 5, [D, O] = l(1), [m, $] = l(F), [k, C] = l(void 0), b = f((e) => {
43
+ U(e), L(!0);
44
44
  }, []), V = f(() => {
45
- M(!1), U(null), A(/* @__PURE__ */ new Set());
45
+ L(!1), U(null), A(/* @__PURE__ */ new Set());
46
46
  }, []), B = f((e) => {
47
47
  A((t) => new Set(t).add(e));
48
48
  }, []), { data: u, isLoading: z, isError: y, error: S } = ne({
@@ -83,8 +83,8 @@ const _e = [
83
83
  method: "HEAD",
84
84
  signal: e.signal
85
85
  })).ok || a.add(i);
86
- } catch (L) {
87
- L instanceof Error && L.name !== "AbortError" && a.add(i);
86
+ } catch (M) {
87
+ M instanceof Error && M.name !== "AbortError" && a.add(i);
88
88
  }
89
89
  }
90
90
  e.signal.aborted || A(a);
@@ -92,7 +92,7 @@ const _e = [
92
92
  }, [d, r]);
93
93
  const H = f(
94
94
  (e, t) => {
95
- t !== m ? (F(t), O(1), C(void 0)) : O(e);
95
+ t !== m ? ($(t), O(1), C(void 0)) : O(e);
96
96
  },
97
97
  [m]
98
98
  ), g = p(
@@ -153,7 +153,7 @@ const _e = [
153
153
  className: c.documentsTableBody,
154
154
  dataTestId: "documents-table",
155
155
  pageSize: m,
156
- totalItems: $,
156
+ totalItems: k,
157
157
  page: D,
158
158
  onPageChange: H
159
159
  }
@@ -170,7 +170,7 @@ const _e = [
170
170
  size: "lg",
171
171
  testId: "document-view-modal",
172
172
  children: /* @__PURE__ */ s("div", { className: c.documentViewerContainer, children: h.map((e, t) => {
173
- const a = j(e.url), I = e.contentType?.toLowerCase().includes("pdf"), i = (e.contentType?.toLowerCase().includes("image") ?? !1) || fe.test(e.url ?? ""), v = k.has(t);
173
+ const a = j(e.url), I = e.contentType?.toLowerCase().includes("pdf"), i = (e.contentType?.toLowerCase().includes("image") ?? !1) || fe.test(e.url ?? ""), v = P.has(t);
174
174
  return a === "#" || v ? /* @__PURE__ */ _(
175
175
  "div",
176
176
  {
@@ -1,54 +1,54 @@
1
- import { jsx as n, jsxs as X, Fragment as Z } from "react/jsx-runtime";
2
- import { r as ee, u as re, F as te, Y as oe, G as ae, K as se, q as ne, c as de, O as C, k as ie, f as me, m as U, e as ce, t as le, y as ue, b as fe } from "./index-CA2IZdZE.js";
1
+ import { jsx as n, jsxs as W, Fragment as X } from "react/jsx-runtime";
2
+ import { o as ee, u as re, H as te, t as oe, Z as ae, e as se, V as ne, c as de, O as C, M as ie, f as me, m as U, d as ce, g as le, b as ue, h as fe } from "./index-B8Sjdo3W.js";
3
3
  import { useQueryClient as ye, useQuery as f } from "@tanstack/react-query";
4
- import { useState as k, useMemo as d, useCallback as y } from "react";
4
+ import { useState as x, useMemo as d, useCallback as y } from "react";
5
5
  import { useTranslation as pe } from "react-i18next";
6
- const be = "_formsTableBody_81hra_1", Fe = "_customAccordianItem_81hra_6", E = {
6
+ const be = "_formsTableBody_81hra_1", ge = "_customAccordianItem_81hra_6", N = {
7
7
  formsTableBody: be,
8
- customAccordianItem: Fe
9
- }, ge = (m) => m ? m.extension?.find(
8
+ customAccordianItem: ge
9
+ }, he = (m) => m ? m.extension?.find(
10
10
  (p) => p.url === ee
11
- )?.valueString : void 0, Ie = ({
11
+ )?.valueString : void 0, De = ({
12
12
  episodeOfCareUuids: m,
13
13
  encounterUuids: i,
14
14
  config: p
15
15
  }) => {
16
- const { t: s } = pe(), c = re(), [l, D] = k(!1), [t, I] = k(null), { numberOfVisits: w, hideThumbnail: x = !1 } = p ?? {}, v = te(
16
+ const { t: s } = pe(), c = re(), [l, M] = x(!1), [t, D] = x(null), { numberOfVisits: k, hideThumbnail: H = !1 } = p ?? {}, I = te(
17
17
  m,
18
18
  i
19
- ), K = ye(), {
19
+ ), P = ye(), {
20
20
  data: b = [],
21
- isLoading: M,
21
+ isLoading: v,
22
22
  isError: A,
23
- error: P,
24
- refetch: H
23
+ error: V,
24
+ refetch: K
25
25
  } = f({
26
26
  queryKey: ["forms", c, m],
27
- queryFn: () => oe(c, void 0, w),
28
- enabled: !!c && !v
27
+ queryFn: () => oe(c, void 0, k),
28
+ enabled: !!c && !I
29
29
  }), B = d(() => !i || i.length === 0 ? b : b.filter(
30
30
  (e) => i.includes(e.encounterUuid)
31
- ), [b, i]), { data: R = [] } = f({
31
+ ), [b, i]), { data: _ = [] } = f({
32
32
  queryKey: ["observationForms"],
33
33
  queryFn: () => ae()
34
- }), T = y(
35
- (e) => R.find((r) => r.name === e)?.uuid,
36
- [R]
37
- ), F = d(() => {
34
+ }), R = y(
35
+ (e) => _.find((r) => r.name === e)?.uuid,
36
+ [_]
37
+ ), g = d(() => {
38
38
  if (t)
39
- return T(t.formName);
40
- }, [t, T]), {
39
+ return R(t.formName);
40
+ }, [t, R]), {
41
41
  isLoading: j,
42
- isError: G,
43
- error: g
42
+ isError: $,
43
+ error: h
44
44
  } = f({
45
- queryKey: ["formMetadata", F],
46
- queryFn: () => se(F),
47
- enabled: !!F && l
45
+ queryKey: ["formMetadata", g],
46
+ queryFn: () => se(g),
47
+ enabled: !!g && l
48
48
  }), {
49
- data: h,
50
- isLoading: V,
51
- isError: $,
49
+ data: E,
50
+ isLoading: w,
51
+ isError: Q,
52
52
  error: O
53
53
  } = f({
54
54
  queryKey: ["formsEncounterFHIR", t?.encounterUuid],
@@ -57,41 +57,41 @@ const be = "_formsTableBody_81hra_1", Fe = "_customAccordianItem_81hra_6", E = {
57
57
  });
58
58
  de(
59
59
  (e) => {
60
- e.patientUUID === c && e.updatedConcepts.size > 0 && (H(), K.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
60
+ e.patientUUID === c && e.updatedConcepts.size > 0 && (K(), P.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
61
61
  },
62
62
  [c]
63
63
  );
64
- const Q = d(() => !h?.entry || !t?.formName ? [] : h.entry.filter((a) => a.resource?.resourceType === "Observation").map((a) => a.resource).filter((a) => {
65
- const r = ge(a);
64
+ const z = d(() => !E?.entry || !t?.formName ? [] : E.entry.filter((a) => a.resource?.resourceType === "Observation").map((a) => a.resource).filter((a) => {
65
+ const r = he(a);
66
66
  return !r || r.includes(t.formName);
67
- }), [h, t?.formName]), Y = d(() => {
68
- if (g)
69
- return C(g).message;
67
+ }), [E, t?.formName]), G = d(() => {
68
+ if (h)
69
+ return C(h).message;
70
70
  if (O)
71
71
  return C(O).message;
72
- }, [g, O]), L = d(
72
+ }, [h, O]), T = d(
73
73
  () => [
74
74
  { key: "recordedOn", header: s("RECORDED_ON") },
75
75
  { key: "recordedBy", header: s("RECORDED_BY") }
76
76
  ],
77
77
  [s]
78
- ), z = d(
78
+ ), Z = d(
79
79
  () => [
80
80
  { key: "recordedOn", sortable: !0 },
81
81
  { key: "recordedBy", sortable: !0 }
82
82
  ],
83
83
  []
84
- ), _ = d(() => {
84
+ ), L = d(() => {
85
85
  const e = B.reduce(
86
86
  (r, o) => {
87
87
  const u = o.formName;
88
88
  r[u] ??= [];
89
- const N = o.providers.map((W) => W.providerName).filter(Boolean).join(", ");
89
+ const F = o.providers.map((J) => J.providerName).filter(Boolean).join(", ");
90
90
  return r[u].push({
91
91
  id: o.encounterUuid,
92
92
  formName: o.formName,
93
93
  recordedOn: ie(o.encounterDateTime, s, !0).formattedResult,
94
- recordedBy: N ?? "--",
94
+ recordedBy: F ?? "--",
95
95
  encounterDateTime: o.encounterDateTime,
96
96
  encounterUuid: o.encounterUuid
97
97
  }), r;
@@ -102,62 +102,62 @@ const be = "_formsTableBody_81hra_1", Fe = "_customAccordianItem_81hra_6", E = {
102
102
  ([r, o]) => ({
103
103
  formName: r,
104
104
  records: o.sort(
105
- (u, N) => N.encounterDateTime - u.encounterDateTime
105
+ (u, F) => F.encounterDateTime - u.encounterDateTime
106
106
  )
107
107
  })
108
108
  ).sort((r, o) => r.formName.localeCompare(o.formName));
109
- }, [B, s]), q = y((e) => {
110
- I(e), D(!0);
111
- }, []), J = y(() => {
112
- D(!1), I(null);
113
- }, []), S = y(
109
+ }, [B, s]), S = y((e) => {
110
+ D(e), M(!0);
111
+ }, []), Y = y(() => {
112
+ M(!1), D(null);
113
+ }, []), q = y(
114
114
  (e, a) => {
115
115
  switch (a) {
116
116
  case "recordedOn":
117
- return /* @__PURE__ */ n(me, { onClick: () => q(e), children: e.recordedOn });
117
+ return /* @__PURE__ */ n(me, { onClick: () => S(e), children: e.recordedOn });
118
118
  case "recordedBy":
119
119
  return e.recordedBy;
120
120
  default:
121
121
  return null;
122
122
  }
123
123
  },
124
- [q]
124
+ [S]
125
125
  );
126
- return /* @__PURE__ */ X(Z, { children: [
127
- /* @__PURE__ */ n("div", { "data-testid": "forms-table", children: M || A || _.length === 0 || v ? /* @__PURE__ */ n(
126
+ return /* @__PURE__ */ W(X, { children: [
127
+ /* @__PURE__ */ n("div", { "data-testid": "forms-table", children: v || A || L.length === 0 || I ? /* @__PURE__ */ n(
128
128
  U,
129
129
  {
130
- headers: L,
130
+ headers: T,
131
131
  ariaLabel: s("FORMS_HEADING"),
132
132
  rows: [],
133
- loading: M,
134
- errorStateMessage: A ? P?.message : void 0,
133
+ loading: v,
134
+ errorStateMessage: A ? V?.message : void 0,
135
135
  emptyStateMessage: s("FORMS_UNAVAILABLE"),
136
- renderCell: S,
137
- className: E.formsTableBody,
136
+ renderCell: q,
137
+ className: N.formsTableBody,
138
138
  dataTestId: "forms-table"
139
139
  }
140
- ) : /* @__PURE__ */ n(ce, { align: "start", children: _.map((e, a) => {
140
+ ) : /* @__PURE__ */ n(ce, { align: "start", children: L.map((e, a) => {
141
141
  const { formName: r, records: o } = e;
142
142
  return /* @__PURE__ */ n(
143
143
  le,
144
144
  {
145
145
  title: r,
146
- className: E.customAccordianItem,
146
+ className: N.customAccordianItem,
147
147
  testId: `accordian-title-${r}`,
148
148
  open: a === 0,
149
149
  children: /* @__PURE__ */ n(
150
150
  U,
151
151
  {
152
- headers: L,
152
+ headers: T,
153
153
  ariaLabel: s("FORMS_HEADING"),
154
154
  rows: o,
155
155
  loading: !1,
156
156
  errorStateMessage: "",
157
- sortable: z,
157
+ sortable: Z,
158
158
  emptyStateMessage: s("FORMS_UNAVAILABLE"),
159
- renderCell: S,
160
- className: E.formsTableBody,
159
+ renderCell: q,
160
+ className: N.formsTableBody,
161
161
  dataTestId: `forms-table-${r}`
162
162
  }
163
163
  )
@@ -171,7 +171,7 @@ const be = "_formsTableBody_81hra_1", Fe = "_customAccordianItem_81hra_6", E = {
171
171
  id: "modalIdForActionAreaLayout",
172
172
  portalId: "main-display-area",
173
173
  open: l,
174
- onRequestClose: J,
174
+ onRequestClose: Y,
175
175
  modalHeading: t.formName,
176
176
  modalLabel: `${t.recordedOn} | ${t.recordedBy}`,
177
177
  passiveModal: !0,
@@ -180,13 +180,13 @@ const be = "_formsTableBody_81hra_1", Fe = "_customAccordianItem_81hra_6", E = {
180
180
  children: /* @__PURE__ */ n(
181
181
  fe,
182
182
  {
183
- observations: Q,
184
- isLoading: j || V,
185
- isError: G || $,
186
- errorMessage: Y,
183
+ observations: z,
184
+ isLoading: j || w,
185
+ isError: $ || Q,
186
+ errorMessage: G,
187
187
  emptyStateMessage: s("NO_FORM_DATA_AVAILABLE"),
188
188
  testIdPrefix: t.formName,
189
- hideThumbnail: x
189
+ hideThumbnail: H
190
190
  }
191
191
  )
192
192
  }
@@ -194,5 +194,5 @@ const be = "_formsTableBody_81hra_1", Fe = "_customAccordianItem_81hra_6", E = {
194
194
  ] });
195
195
  };
196
196
  export {
197
- Ie as default
197
+ De as default
198
198
  };
@@ -1,13 +1,13 @@
1
1
  import { jsx as l, jsxs as S } from "react/jsx-runtime";
2
- import { d as k, C as D, g as q, j as w, i as K, x as Q, h as G, z as j, u as P, a as z, n as H, o as x, c as Y, p as J, s as W, v as X, $ as Z, m as ee } from "./index-CA2IZdZE.js";
2
+ import { i as M, C as D, j as V, B as K, k as Q, x as w, l as G, z as P, u as j, a as z, W as H, q as W, c as Y, n as x, p as J, s as X, $ as Z, m as ee } from "./index-B8Sjdo3W.js";
3
3
  import { useQueries as te, useQuery as se } from "@tanstack/react-query";
4
- import { useRef as oe, useEffect as C, useMemo as g } from "react";
4
+ import { useRef as oe, useEffect as C, useMemo as O } from "react";
5
5
  import { useTranslation as U } from "react-i18next";
6
6
  const B = (t, i, c, d, u, r) => {
7
- const s = q(t, i, u), o = s.value, a = w(o);
7
+ const s = V(t, i, u), o = s.value, a = K(o);
8
8
  let n = o;
9
9
  a === "Image" && (n = /* @__PURE__ */ l(
10
- Q,
10
+ w,
11
11
  {
12
12
  imageSrc: o,
13
13
  alt: o,
@@ -21,12 +21,12 @@ const B = (t, i, c, d, u, r) => {
21
21
  videoSrc: o,
22
22
  hideThumbnail: r
23
23
  }
24
- )), a === "PDF" && (n = /* @__PURE__ */ l(j, { id: `${o}-pdf`, src: o }));
24
+ )), a === "PDF" && (n = /* @__PURE__ */ l(P, { id: `${o}-pdf`, src: o }));
25
25
  const b = u("OBSERVATIONS_RECORDED_BY", {
26
26
  provider: s.provider
27
27
  }), p = t.display, m = t.observationValue?.isAbnormal ? "abnormal-obs" : "obs", y = d ? `${d}-${m}-${p}-${c}-${i}` : `${m}-${p}-${c}-${i}`;
28
28
  return /* @__PURE__ */ l(
29
- K,
29
+ Q,
30
30
  {
31
31
  header: s.header,
32
32
  value: n,
@@ -61,7 +61,7 @@ const B = (t, i, c, d, u, r) => {
61
61
  hideThumbnail: c
62
62
  }) => {
63
63
  const { t: d } = U(), u = (r, s, o) => {
64
- const a = k(r.encounterDetails, d);
64
+ const a = M(r.encounterDetails, d);
65
65
  return /* @__PURE__ */ S(
66
66
  D,
67
67
  {
@@ -114,7 +114,7 @@ const B = (t, i, c, d, u, r) => {
114
114
  conceptNames: c = [],
115
115
  conceptUuid: d = [],
116
116
  hideThumbnail: u = !1
117
- } = i, r = oe(/* @__PURE__ */ new Set()), s = P(), { addNotification: o } = z(), { t: a } = U(), n = te({
117
+ } = i, r = oe(/* @__PURE__ */ new Set()), s = j(), { addNotification: o } = z(), { t: a } = U(), n = te({
118
118
  queries: c.map((e) => ({
119
119
  queryKey: ce(e),
120
120
  queryFn: () => H(e),
@@ -133,14 +133,14 @@ const B = (t, i, c, d, 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, ...d])], [b, d]), f = g(() => c.length === 0 ? !0 : n.every((e) => !e.isLoading), [n, c.length]), {
136
+ const b = O(() => n.map((e) => e.data?.uuid).filter((e) => !!e), [n]), p = O(() => [.../* @__PURE__ */ new Set([...b, ...d])], [b, d]), f = O(() => c.length === 0 ? !0 : n.every((e) => !e.isLoading), [n, c.length]), {
137
137
  data: m,
138
138
  isLoading: y,
139
- isError: O,
139
+ isError: g,
140
140
  refetch: T
141
141
  } = se({
142
142
  queryKey: de(s, p),
143
- queryFn: () => x(s, p),
143
+ queryFn: () => W(s, p),
144
144
  enabled: !!s && p.length > 0 && f
145
145
  });
146
146
  Y(
@@ -151,21 +151,21 @@ const B = (t, i, c, d, u, r) => {
151
151
  },
152
152
  [s, T]
153
153
  ), C(() => {
154
- O && o({
154
+ g && o({
155
155
  title: a("ERROR_DEFAULT_TITLE"),
156
156
  message: a("ERROR_FETCHING_OBSERVATIONS"),
157
157
  type: "error"
158
158
  });
159
- }, [O]);
160
- const $ = g(() => {
159
+ }, [g]);
160
+ const $ = O(() => {
161
161
  if (!m) return [];
162
- const e = J(m), v = W(e);
162
+ const e = x(m), v = J(e);
163
163
  return X(v);
164
164
  }, [m]), A = [
165
165
  { key: "name", header: "name" },
166
166
  { key: "value", header: "value" },
167
167
  { key: "form", header: "form" }
168
- ], I = y || !f, _ = O && 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, V = $.length > 0 && !I && !_, h = i.titleTranslationKey, E = h ? a(h) : "";
168
+ ], _ = y || !f, I = g && f, F = (!m || m.entry?.length === 0 || p.length === 0) && f, L = I ? a("ERROR_FETCHING_OBSERVATIONS") : null, q = F ? a("NO_OBSERVATIONS_FOUND") : void 0, k = $.length > 0 && !_ && !I, h = i.titleTranslationKey, E = h ? a(h) : "";
169
169
  return /* @__PURE__ */ S(
170
170
  "div",
171
171
  {
@@ -184,7 +184,7 @@ const B = (t, i, c, d, u, r) => {
184
184
  children: /* @__PURE__ */ l("p", { children: E })
185
185
  }
186
186
  ),
187
- V ? /* @__PURE__ */ l(
187
+ k ? /* @__PURE__ */ l(
188
188
  ae,
189
189
  {
190
190
  groupedData: $,
@@ -197,9 +197,9 @@ const B = (t, i, c, d, u, r) => {
197
197
  headers: A,
198
198
  rows: [],
199
199
  ariaLabel: a("OBSERVATIONS"),
200
- loading: I,
200
+ loading: _,
201
201
  errorStateMessage: L,
202
- emptyStateMessage: M,
202
+ emptyStateMessage: q,
203
203
  dataTestId: "observations-table"
204
204
  }
205
205
  )