@bahmni/widgets 0.0.1-dev.293 → 0.0.1-dev.294

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, t as Z, T as x, i as ee, I as te } from "./index-C0VMuD23.js";
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-C0w9hjlA.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, C] = l(1), [u, $] = l(V), [k, O] = l(void 0), v = _((e) => {
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) => {
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 && O(i.total);
65
+ i && C(i.total);
66
66
  }, [i]), g(() => {
67
- C(1), O(void 0);
67
+ O(1), C(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), C(1), O(void 0)) : C(e);
95
+ t !== u ? ($(t), O(1), C(void 0)) : O(e);
96
96
  },
97
97
  [u]
98
98
  ), D = p(
@@ -1,9 +1,9 @@
1
1
  import { jsx as n, jsxs as Z, Fragment as ee } from "react/jsx-runtime";
2
- import { G as re, u as te, k as oe, Q as ae, W as se, J as ne, x as de, d as ie, M as U, T as me, t as le, i as x, X as ce, b as ue, I as fe, O as ye } from "./index-C0VMuD23.js";
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-C0w9hjlA.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", O = {
6
+ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_customAccordianItem__isszs", E = {
7
7
  formsTableBody: ge,
8
8
  customAccordianItem: Fe
9
9
  }, he = (m) => m ? m.extension?.find(
@@ -14,41 +14,41 @@ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
14
14
  config: p
15
15
  }) => {
16
16
  const { t: s } = pe(), l = te(), [c, I] = k(!1), [o, M] = k(null), {
17
- numberOfVisits: w,
18
- hideThumbnail: P = !1,
17
+ numberOfVisits: j,
18
+ hideThumbnail: w = !1,
19
19
  forms: u
20
20
  } = p ?? {}, A = oe(
21
21
  m,
22
22
  i
23
- ), Q = be(), {
23
+ ), P = be(), {
24
24
  data: D = [],
25
- isLoading: T,
26
- isError: v,
27
- error: G,
28
- refetch: H
25
+ isLoading: v,
26
+ isError: B,
27
+ error: H,
28
+ refetch: K
29
29
  } = y({
30
30
  queryKey: ["forms", l, m],
31
- queryFn: () => ae(l, void 0, w),
31
+ queryFn: () => ae(l, void 0, j),
32
32
  enabled: !!l && !A
33
- }), B = d(() => {
33
+ }), T = d(() => {
34
34
  let e = D;
35
35
  return i && i.length > 0 && (e = e.filter(
36
36
  (t) => i.includes(t.encounterUuid)
37
37
  )), Array.isArray(u) && u.length > 0 && (e = e.filter(
38
38
  (t) => u.some((r) => r.toLowerCase() === t.formName.toLowerCase())
39
39
  )), e;
40
- }, [D, i, u]), { data: L = [] } = y({
40
+ }, [D, i, u]), { data: _ = [] } = y({
41
41
  queryKey: ["observationForms"],
42
42
  queryFn: () => se()
43
- }), R = b(
44
- (e) => L.find((r) => r.name === e)?.uuid,
45
- [L]
43
+ }), L = b(
44
+ (e) => _.find((r) => r.name === e)?.uuid,
45
+ [_]
46
46
  ), g = d(() => {
47
47
  if (o)
48
- return R(o.formName);
49
- }, [o, R]), {
50
- isLoading: K,
51
- isError: j,
48
+ return L(o.formName);
49
+ }, [o, L]), {
50
+ isLoading: Q,
51
+ isError: V,
52
52
  error: F
53
53
  } = y({
54
54
  queryKey: ["formMetadata", g],
@@ -56,8 +56,8 @@ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
56
56
  enabled: !!g && c
57
57
  }), {
58
58
  data: h,
59
- isLoading: V,
60
- isError: $,
59
+ isLoading: $,
60
+ isError: z,
61
61
  error: N
62
62
  } = y({
63
63
  queryKey: ["formsEncounterFHIR", o?.encounterUuid],
@@ -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 && (H(), Q.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
69
+ e.patientUUID === l && e.updatedConcepts.size > 0 && (K(), P.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
70
70
  },
71
71
  [l]
72
72
  );
73
- const z = d(() => !h?.entry || !o?.formName ? [] : h.entry.filter((t) => t.resource?.resourceType === "Observation").map((t) => t.resource).filter((t) => {
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
76
  }), [h, o?.formName]), J = d(() => {
77
77
  if (F)
78
- return U(F).message;
78
+ return q(F).message;
79
79
  if (N)
80
- return U(N).message;
81
- }, [F, N]), _ = d(
80
+ return q(N).message;
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
- ), W = d(
87
+ ), X = d(
88
88
  () => [
89
89
  { key: "recordedOn", sortable: !0 },
90
90
  { key: "recordedBy", sortable: !0 }
91
91
  ],
92
92
  []
93
93
  ), C = d(() => {
94
- const e = B.reduce(
94
+ const e = T.reduce(
95
95
  (r, a) => {
96
96
  const f = a.formName;
97
97
  r[f] ??= [];
98
- const E = a.providers.map((Y) => Y.providerName).filter(Boolean).join(", ");
98
+ const O = 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: E ?? "--",
103
+ recordedBy: O ?? "--",
104
104
  encounterDateTime: a.encounterDateTime,
105
105
  encounterUuid: a.encounterUuid
106
106
  }), r;
@@ -111,15 +111,15 @@ 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, E) => E.encounterDateTime - f.encounterDateTime
114
+ (f, O) => O.encounterDateTime - f.encounterDateTime
115
115
  )
116
116
  })
117
117
  ).sort((r, a) => r.formName.localeCompare(a.formName));
118
- }, [B, s]), S = b((e) => {
118
+ }, [T, s]), S = b((e) => {
119
119
  M(e), I(!0);
120
- }, []), X = b(() => {
120
+ }, []), Y = b(() => {
121
121
  I(!1), M(null);
122
- }, []), q = b(
122
+ }, []), U = b(
123
123
  (e, t) => {
124
124
  switch (t) {
125
125
  case "recordedOn":
@@ -133,17 +133,17 @@ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
133
133
  [S]
134
134
  );
135
135
  return /* @__PURE__ */ Z(ee, { children: [
136
- /* @__PURE__ */ n("div", { id: "forms-table", "data-testid": "forms-table", children: T || v || C.length === 0 || A ? /* @__PURE__ */ n(
136
+ /* @__PURE__ */ n("div", { id: "forms-table", "data-testid": "forms-table", children: v || B || C.length === 0 || A ? /* @__PURE__ */ n(
137
137
  x,
138
138
  {
139
- headers: _,
139
+ headers: R,
140
140
  ariaLabel: s("FORMS_HEADING"),
141
141
  rows: [],
142
- loading: T,
143
- errorStateMessage: v ? G?.message : void 0,
142
+ loading: v,
143
+ errorStateMessage: B ? H?.message : void 0,
144
144
  emptyStateMessage: s("FORMS_UNAVAILABLE"),
145
- renderCell: q,
146
- className: O.formsTableBody,
145
+ renderCell: U,
146
+ className: E.formsTableBody,
147
147
  dataTestId: "forms-table"
148
148
  }
149
149
  ) : /* @__PURE__ */ n(ce, { align: "start", children: C.map((e, t) => {
@@ -152,21 +152,21 @@ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
152
152
  ue,
153
153
  {
154
154
  title: r,
155
- className: O.customAccordianItem,
155
+ className: E.customAccordianItem,
156
156
  testId: `accordian-title-${r}`,
157
157
  open: t === 0,
158
158
  children: /* @__PURE__ */ n(
159
159
  x,
160
160
  {
161
- headers: _,
161
+ headers: R,
162
162
  ariaLabel: s("FORMS_HEADING"),
163
163
  rows: a,
164
164
  loading: !1,
165
165
  errorStateMessage: "",
166
- sortable: W,
166
+ sortable: X,
167
167
  emptyStateMessage: s("FORMS_UNAVAILABLE"),
168
- renderCell: q,
169
- className: O.formsTableBody,
168
+ renderCell: U,
169
+ className: E.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: X,
183
+ onRequestClose: Y,
184
184
  modalHeading: o.formName,
185
185
  modalLabel: `${o.recordedOn} | ${o.recordedBy}`,
186
186
  passiveModal: !0,
@@ -189,13 +189,13 @@ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
189
189
  children: /* @__PURE__ */ n(
190
190
  ye,
191
191
  {
192
- observations: z,
193
- isLoading: K || V,
194
- isError: j || $,
192
+ observations: G,
193
+ isLoading: Q || $,
194
+ isError: V || z,
195
195
  errorMessage: J,
196
196
  emptyStateMessage: s("NO_FORM_DATA_AVAILABLE"),
197
197
  testIdPrefix: o.formName,
198
- hideThumbnail: P
198
+ hideThumbnail: w
199
199
  }
200
200
  )
201
201
  }
@@ -1,32 +1,32 @@
1
- import { jsx as l, jsxs as C } from "react/jsx-runtime";
2
- import { f as K, c as D, e as V, g as Q, o as H, h as k, w as q, m as G, u as P, a as j, j as z, N as J, d as Y, l as W, n as X, s as Z, H as x, i as ee } from "./index-C0VMuD23.js";
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-C0w9hjlA.js";
3
3
  import { useQueries as te, useQuery as se } from "@tanstack/react-query";
4
- import { useRef as oe, useEffect as N, useMemo as h } from "react";
4
+ import { useRef as oe, useEffect as D, useMemo as g } from "react";
5
5
  import { useTranslation as U } from "react-i18next";
6
- const w = (t, i, c, d, u, r) => {
6
+ const w = (t, i, c, l, u, r) => {
7
7
  const s = V(t, i, u), o = s.value, a = Q(o);
8
8
  let n = o;
9
- a === "Image" && (n = /* @__PURE__ */ l(
10
- k,
9
+ a === "Image" && (n = /* @__PURE__ */ d(
10
+ q,
11
11
  {
12
12
  imageSrc: o,
13
13
  alt: o,
14
14
  id: `${o}-img`,
15
15
  hideThumbnail: r
16
16
  }
17
- )), a === "Video" && (n = /* @__PURE__ */ l(
18
- q,
17
+ )), a === "Video" && (n = /* @__PURE__ */ d(
18
+ H,
19
19
  {
20
20
  id: `${o}-video`,
21
21
  videoSrc: o,
22
22
  hideThumbnail: r
23
23
  }
24
- )), a === "PDF" && (n = /* @__PURE__ */ l(G, { id: `${o}-pdf`, src: o }));
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 = d ? `${d}-${p}-${m}-${c}-${i}` : `${p}-${m}-${c}-${i}`;
28
- return /* @__PURE__ */ l(
29
- H,
27
+ }), m = t.display, p = t.observationValue?.isAbnormal ? "abnormal-obs" : "obs", y = l ? `${l}-${p}-${m}-${c}-${i}` : `${p}-${m}-${c}-${i}`;
28
+ return /* @__PURE__ */ d(
29
+ k,
30
30
  {
31
31
  header: s.header,
32
32
  value: n,
@@ -37,11 +37,11 @@ const w = (t, i, c, d, u, r) => {
37
37
  },
38
38
  `obs-${t.id}`
39
39
  );
40
- }, re = (t, i, c, d, u, r, s) => /* @__PURE__ */ l(
41
- D,
40
+ }, re = (t, i, c, l, u, r, s) => /* @__PURE__ */ d(
41
+ C,
42
42
  {
43
43
  title: t.display,
44
- id: `grouped-obs-${t.display}-${d}`,
44
+ id: `grouped-obs-${t.display}-${l}`,
45
45
  open: c,
46
46
  children: t.members?.map(
47
47
  (o, a) => w(
@@ -60,10 +60,10 @@ const w = (t, i, c, d, u, r) => {
60
60
  title: i = "",
61
61
  hideThumbnail: c
62
62
  }) => {
63
- const { t: d } = U(), u = (r, s, o) => {
64
- const a = K(r.encounterDetails, d);
65
- return /* @__PURE__ */ C(
66
- D,
63
+ const { t: l } = U(), u = (r, s, o) => {
64
+ const a = M(r.encounterDetails, l);
65
+ return /* @__PURE__ */ N(
66
+ C,
67
67
  {
68
68
  title: a,
69
69
  id: `encounter-${r.encounterId}`,
@@ -75,14 +75,14 @@ const w = (t, i, c, d, u, r) => {
75
75
  b,
76
76
  o,
77
77
  i,
78
- d,
78
+ l,
79
79
  c
80
80
  )
81
81
  ),
82
82
  r.groupedObservations.map(
83
83
  (n, b) => re(
84
84
  n,
85
- d,
85
+ l,
86
86
  s,
87
87
  b,
88
88
  o,
@@ -95,7 +95,7 @@ const w = (t, i, c, d, u, r) => {
95
95
  `encounter-${r.encounterId}`
96
96
  );
97
97
  };
98
- return /* @__PURE__ */ l(
98
+ return /* @__PURE__ */ d(
99
99
  "div",
100
100
  {
101
101
  id: "obs-by-encounter",
@@ -109,10 +109,10 @@ const w = (t, i, c, d, u, r) => {
109
109
  }, ne = "Observations-module_observations__RKSyo", ie = "Observations-module_title__TJL3z", S = {
110
110
  observations: ne,
111
111
  title: ie
112
- }, ce = (t) => ["conceptUuid", t], de = (t, i) => ["observations", t, ...i], ve = ({ config: t }) => {
112
+ }, ce = (t) => ["conceptUuid", t], le = (t, i) => ["observations", t, ...i], ve = ({ config: t }) => {
113
113
  const i = t, {
114
114
  conceptNames: c = [],
115
- conceptUuid: d = [],
115
+ conceptUuid: l = [],
116
116
  hideThumbnail: u = !1
117
117
  } = i, r = oe(/* @__PURE__ */ new Set()), s = P(), { addNotification: o } = j(), { t: a } = U(), n = te({
118
118
  queries: c.map((e) => ({
@@ -121,7 +121,7 @@ const w = (t, i, c, d, u, r) => {
121
121
  enabled: !!e
122
122
  }))
123
123
  });
124
- N(() => {
124
+ D(() => {
125
125
  n.forEach((e, v) => {
126
126
  if (e.isError && !r.current.has(v)) {
127
127
  const R = c[v];
@@ -133,13 +133,13 @@ const w = (t, i, c, d, u, r) => {
133
133
  } else e.isError || r.current.delete(v);
134
134
  });
135
135
  }, [n, c]);
136
- const b = h(() => n.map((e) => e.data?.uuid).filter((e) => !!e), [n]), m = h(() => [.../* @__PURE__ */ new Set([...b, ...d])], [b, d]), f = h(() => c.length === 0 ? !0 : n.every((e) => !e.isLoading), [n, c.length]), {
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
137
  data: p,
138
138
  isLoading: y,
139
- isError: g,
139
+ isError: h,
140
140
  refetch: T
141
141
  } = se({
142
- queryKey: de(s, m),
142
+ queryKey: le(s, m),
143
143
  queryFn: () => J(s, m),
144
144
  enabled: !!s && m.length > 0 && f
145
145
  });
@@ -150,14 +150,14 @@ const w = (t, i, c, d, u, r) => {
150
150
  ) && T();
151
151
  },
152
152
  [s, T]
153
- ), N(() => {
154
- g && o({
153
+ ), D(() => {
154
+ h && o({
155
155
  title: a("ERROR_DEFAULT_TITLE"),
156
156
  message: a("ERROR_FETCHING_OBSERVATIONS"),
157
157
  type: "error"
158
158
  });
159
- }, [g]);
160
- const _ = h(() => {
159
+ }, [h]);
160
+ const _ = g(() => {
161
161
  if (!p) return [];
162
162
  const e = W(p), v = X(e);
163
163
  return Z(v);
@@ -165,8 +165,8 @@ const w = (t, i, c, d, u, r) => {
165
165
  { key: "name", header: "name" },
166
166
  { key: "value", header: "value" },
167
167
  { key: "form", header: "form" }
168
- ], I = y || !f, $ = g && 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, M = _.length > 0 && !I && !$, O = i.titleTranslationKey, E = O ? a(O) : "";
169
- return /* @__PURE__ */ C(
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) : "";
169
+ return /* @__PURE__ */ N(
170
170
  "div",
171
171
  {
172
172
  id: "observations",
@@ -174,24 +174,24 @@ const w = (t, i, c, d, u, r) => {
174
174
  "aria-label": "observations-aria-label",
175
175
  className: S.observations,
176
176
  children: [
177
- /* @__PURE__ */ l(
177
+ /* @__PURE__ */ d(
178
178
  x,
179
179
  {
180
180
  id: "observations-title",
181
181
  testId: O ? `observations-title-${E}` : "observations-title",
182
182
  title: E,
183
183
  className: S.title,
184
- children: /* @__PURE__ */ l("p", { children: E })
184
+ children: /* @__PURE__ */ d("p", { children: E })
185
185
  }
186
186
  ),
187
- M ? /* @__PURE__ */ l(
187
+ K ? /* @__PURE__ */ d(
188
188
  ae,
189
189
  {
190
190
  groupedData: _,
191
191
  title: E,
192
192
  hideThumbnail: u
193
193
  }
194
- ) : /* @__PURE__ */ l(
194
+ ) : /* @__PURE__ */ d(
195
195
  ee,
196
196
  {
197
197
  headers: B,
@@ -210,5 +210,5 @@ const w = (t, i, c, d, u, r) => {
210
210
  export {
211
211
  ce as conceptUuidQueryKeys,
212
212
  ve as default,
213
- de as observationsQueryKeys
213
+ le as observationsQueryKeys
214
214
  };