@bahmni/widgets 0.0.1-dev.285 → 0.0.1-dev.288

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, O as x, i as ee, I as te } from "./index-BZtaBEPW.js";
2
+ import { u as W, a as X, E as J, t as Z, O as x, i as ee, I as te } from "./index-Bb-lHWAD.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";
@@ -1,7 +1,7 @@
1
- import { jsx as n, jsxs as Z, Fragment as ee } from "react/jsx-runtime";
2
- import { K as re, u as te, x as oe, Q as ae, W as se, J as ne, L as de, d as ie, M as U, O as me, t as le, i as x, X as ce, b as ue, I as fe, c as ye } from "./index-BZtaBEPW.js";
1
+ import { jsx as n, jsxs as W, Fragment as ee } from "react/jsx-runtime";
2
+ import { K as re, u as te, M as oe, Z as ae, Q as se, X as ne, k as de, p as ie, b as U, O as me, t as le, i as k, c as ce, d as ue, I as fe, e as ye } from "./index-Bb-lHWAD.js";
3
3
  import { useQueryClient as be, useQuery as y } from "@tanstack/react-query";
4
- import { useState as k, useMemo as d, useCallback as b } from "react";
4
+ import { useState as x, useMemo as d, useCallback as b } from "react";
5
5
  import { useTranslation as pe } from "react-i18next";
6
6
  const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_customAccordianItem__isszs", E = {
7
7
  formsTableBody: ge,
@@ -13,7 +13,7 @@ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
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), {
16
+ const { t: s } = pe(), l = te(), [c, I] = x(!1), [o, M] = x(null), {
17
17
  numberOfVisits: K,
18
18
  hideThumbnail: w = !1,
19
19
  forms: u
@@ -23,26 +23,26 @@ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
23
23
  ), P = be(), {
24
24
  data: D = [],
25
25
  isLoading: v,
26
- isError: L,
26
+ isError: B,
27
27
  error: Q,
28
28
  refetch: H
29
29
  } = y({
30
30
  queryKey: ["forms", l, m],
31
31
  queryFn: () => ae(l, void 0, K),
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: T = [] } = y({
40
+ }, [D, i, u]), { data: L = [] } = y({
41
41
  queryKey: ["observationForms"],
42
42
  queryFn: () => se()
43
43
  }), R = b(
44
- (e) => T.find((r) => r.name === e)?.uuid,
45
- [T]
44
+ (e) => L.find((r) => r.name === e)?.uuid,
45
+ [L]
46
46
  ), g = d(() => {
47
47
  if (o)
48
48
  return R(o.formName);
@@ -73,7 +73,7 @@ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
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
78
  return U(F).message;
79
79
  if (N)
@@ -84,18 +84,18 @@ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
84
84
  { key: "recordedBy", header: s("RECORDED_BY") }
85
85
  ],
86
86
  [s]
87
- ), W = d(
87
+ ), Z = 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 O = a.providers.map((Y) => Y.providerName).filter(Boolean).join(", ");
98
+ const O = a.providers.map((J) => J.providerName).filter(Boolean).join(", ");
99
99
  return r[f].push({
100
100
  id: a.encounterUuid,
101
101
  formName: a.formName,
@@ -115,9 +115,9 @@ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
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
122
  }, []), q = b(
123
123
  (e, t) => {
@@ -132,15 +132,15 @@ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
132
132
  },
133
133
  [S]
134
134
  );
135
- return /* @__PURE__ */ Z(ee, { children: [
136
- /* @__PURE__ */ n("div", { id: "forms-table", "data-testid": "forms-table", children: v || L || C.length === 0 || A ? /* @__PURE__ */ n(
137
- x,
135
+ return /* @__PURE__ */ W(ee, { children: [
136
+ /* @__PURE__ */ n("div", { id: "forms-table", "data-testid": "forms-table", children: v || B || C.length === 0 || A ? /* @__PURE__ */ n(
137
+ k,
138
138
  {
139
139
  headers: _,
140
140
  ariaLabel: s("FORMS_HEADING"),
141
141
  rows: [],
142
142
  loading: v,
143
- errorStateMessage: L ? Q?.message : void 0,
143
+ errorStateMessage: B ? Q?.message : void 0,
144
144
  emptyStateMessage: s("FORMS_UNAVAILABLE"),
145
145
  renderCell: q,
146
146
  className: E.formsTableBody,
@@ -156,14 +156,14 @@ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
156
156
  testId: `accordian-title-${r}`,
157
157
  open: t === 0,
158
158
  children: /* @__PURE__ */ n(
159
- x,
159
+ k,
160
160
  {
161
161
  headers: _,
162
162
  ariaLabel: s("FORMS_HEADING"),
163
163
  rows: a,
164
164
  loading: !1,
165
165
  errorStateMessage: "",
166
- sortable: W,
166
+ sortable: Z,
167
167
  emptyStateMessage: s("FORMS_UNAVAILABLE"),
168
168
  renderCell: q,
169
169
  className: E.formsTableBody,
@@ -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,
@@ -192,7 +192,7 @@ const ge = "FormsTable-module_formsTableBody__SvGha", Fe = "FormsTable-module_cu
192
192
  observations: G,
193
193
  isLoading: j || $,
194
194
  isError: V || z,
195
- errorMessage: J,
195
+ errorMessage: X,
196
196
  emptyStateMessage: s("NO_FORM_DATA_AVAILABLE"),
197
197
  testIdPrefix: o.formName,
198
198
  hideThumbnail: w
@@ -1,32 +1,32 @@
1
- import { jsx as l, jsxs as U } from "react/jsx-runtime";
2
- import { f as M, e as C, g as V, h as Q, o as k, j as H, w as q, m as G, u as P, a as j, U as z, N as J, d as Y, k as W, l as X, s as Z, H as x, i as ee } from "./index-BZtaBEPW.js";
1
+ import { jsx as d, jsxs as U } from "react/jsx-runtime";
2
+ import { f as M, g as C, h as V, j as P, o as Q, l as q, w as H, m as k, u as G, a as j, U as z, P as J, p as Y, n as W, q as X, s as Z, H as x, i as ee } from "./index-Bb-lHWAD.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 S, useMemo as h } from "react";
5
5
  import { useTranslation as D } from "react-i18next";
6
- const w = (t, i, c, d, u, r) => {
7
- const s = V(t, i, u), o = s.value, a = Q(o);
6
+ const w = (t, i, c, l, u, r) => {
7
+ const s = V(t, i, u), o = s.value, a = P(o);
8
8
  let n = o;
9
- a === "Image" && (n = /* @__PURE__ */ l(
10
- H,
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(k, { 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
- k,
27
+ }), p = t.display, m = t.observationValue?.isAbnormal ? "abnormal-obs" : "obs", y = l ? `${l}-${m}-${p}-${c}-${i}` : `${m}-${p}-${c}-${i}`;
28
+ return /* @__PURE__ */ d(
29
+ Q,
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(
40
+ }, re = (t, i, c, l, u, r, s) => /* @__PURE__ */ d(
41
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,8 +60,8 @@ const w = (t, i, c, d, u, r) => {
60
60
  title: i = "",
61
61
  hideThumbnail: c
62
62
  }) => {
63
- const { t: d } = D(), u = (r, s, o) => {
64
- const a = M(r.encounterDetails, d);
63
+ const { t: l } = D(), u = (r, s, o) => {
64
+ const a = M(r.encounterDetails, l);
65
65
  return /* @__PURE__ */ U(
66
66
  C,
67
67
  {
@@ -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",
@@ -106,22 +106,22 @@ const w = (t, i, c, d, 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", N = {
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
- } = i, r = oe(/* @__PURE__ */ new Set()), s = P(), { addNotification: o } = j(), { t: a } = D(), n = te({
117
+ } = i, r = oe(/* @__PURE__ */ new Set()), s = G(), { addNotification: o } = j(), { t: a } = D(), n = te({
118
118
  queries: c.map((e) => ({
119
119
  queryKey: ce(e),
120
120
  queryFn: () => z(e),
121
121
  enabled: !!e
122
122
  }))
123
123
  });
124
- N(() => {
124
+ S(() => {
125
125
  n.forEach((e, v) => {
126
126
  if (e.isError && !r.current.has(v)) {
127
127
  const R = c[v];
@@ -133,24 +133,24 @@ 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]), {
137
- data: p,
136
+ const b = h(() => n.map((e) => e.data?.uuid).filter((e) => !!e), [n]), p = h(() => [.../* @__PURE__ */ new Set([...b, ...l])], [b, l]), f = h(() => c.length === 0 ? !0 : n.every((e) => !e.isLoading), [n, c.length]), {
137
+ data: m,
138
138
  isLoading: y,
139
139
  isError: g,
140
140
  refetch: T
141
141
  } = se({
142
- queryKey: de(s, m),
143
- queryFn: () => J(s, m),
144
- enabled: !!s && m.length > 0 && f
142
+ queryKey: le(s, p),
143
+ queryFn: () => J(s, p),
144
+ enabled: !!s && p.length > 0 && f
145
145
  });
146
146
  Y(
147
147
  (e) => {
148
148
  e.patientUUID === s && e.updatedConcepts.size > 0 && [...e.updatedConcepts.keys()].some(
149
- (R) => m.includes(R)
149
+ (R) => p.includes(R)
150
150
  ) && T();
151
151
  },
152
152
  [s, T]
153
- ), N(() => {
153
+ ), S(() => {
154
154
  g && o({
155
155
  title: a("ERROR_DEFAULT_TITLE"),
156
156
  message: a("ERROR_FETCHING_OBSERVATIONS"),
@@ -158,40 +158,40 @@ const w = (t, i, c, d, u, r) => {
158
158
  });
159
159
  }, [g]);
160
160
  const _ = h(() => {
161
- if (!p) return [];
162
- const e = W(p), v = X(e);
161
+ if (!m) return [];
162
+ const e = W(m), v = X(e);
163
163
  return Z(v);
164
- }, [p]), B = [
164
+ }, [m]), B = [
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, K = _.length > 0 && !I && !$, O = i.titleTranslationKey, E = O ? a(O) : "";
168
+ ], I = y || !f, $ = g && f, A = (!m || m.entry?.length === 0 || p.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
169
  return /* @__PURE__ */ U(
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: N.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
- className: S.title,
184
- children: /* @__PURE__ */ l("p", { children: E })
183
+ className: N.title,
184
+ children: /* @__PURE__ */ d("p", { children: E })
185
185
  }
186
186
  ),
187
- K ? /* @__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
  };