@bahmni/widgets 0.0.1-dev.314 → 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, S as X, Z as J, $ as x, j as ee, P as te } from "./index-CvF-qMtP.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";
@@ -39,7 +39,7 @@ const Te = [
39
39
  null
40
40
  ), [F, A] = l(
41
41
  /* @__PURE__ */ new Set()
42
- ), f = W(), { t: o } = ae(), { addNotification: w } = Z(), $ = Number(n?.pageSize) || 5, [N, C] = l(1), [u, V] = l($), [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
45
  L(!1), U(null), A(/* @__PURE__ */ new Set());
@@ -92,13 +92,13 @@ const Te = [
92
92
  }, [d, s]);
93
93
  const j = _(
94
94
  (e, t) => {
95
- t !== u ? (V(t), C(1), O(void 0)) : C(e);
95
+ t !== u ? ($(t), C(1), O(void 0)) : C(e);
96
96
  },
97
97
  [u]
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,18 +138,18 @@ 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,
@@ -1,6 +1,6 @@
1
- import { jsx as i, jsxs as te, Fragment as oe } from "react/jsx-runtime";
2
- import { X as se, u as ae, H as ne, s as de, r as ie, n as ce, F as le, w as me, M as k, $ as ue, Z as fe, j as x, T as ye, R as pe, P as be, O as he } from "./index-CvF-qMtP.js";
3
- import { useQueryClient as ge, useQuery as b } from "@tanstack/react-query";
1
+ import { jsx as i, jsxs as oe, Fragment as te } from "react/jsx-runtime";
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
+ import { useQueryClient as ge, useQuery as p } from "@tanstack/react-query";
4
4
  import { useState as H, useMemo as d, useCallback as h } from "react";
5
5
  import { useTranslation as Fe } from "react-i18next";
6
6
  const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_customAccordianItem__isszs", v = {
@@ -13,93 +13,93 @@ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_cu
13
13
  encounterUuids: c,
14
14
  config: g
15
15
  }) => {
16
- const { t: n } = Fe(), u = ae(), [y, M] = H(!1), [a, I] = H(null), {
16
+ const { t: n } = Fe(), u = ae(), [y, M] = H(!1), [a, A] = H(null), {
17
17
  numberOfVisits: P,
18
18
  hideThumbnail: j = !1,
19
- forms: p
20
- } = g ?? {}, A = ne(
19
+ forms: b
20
+ } = g ?? {}, I = ne(
21
21
  m,
22
22
  c
23
23
  ), w = ge(), {
24
24
  data: D = [],
25
25
  isLoading: T,
26
- isError: B,
27
- error: $,
28
- refetch: K
29
- } = b({
26
+ isError: _,
27
+ error: K,
28
+ refetch: V
29
+ } = p({
30
30
  queryKey: ["forms", u, m],
31
31
  queryFn: () => de(u, void 0, P),
32
- enabled: !!u && !A
33
- }), R = d(() => {
32
+ enabled: !!u && !I
33
+ }), B = d(() => {
34
34
  let e = D;
35
35
  return c && c.length > 0 && (e = e.filter(
36
- (t) => c.includes(t.encounterUuid)
37
- )), Array.isArray(p) && p.length > 0 && (e = e.filter(
38
- (t) => p.some((r) => r.toLowerCase() === t.formName.toLowerCase())
36
+ (o) => c.includes(o.encounterUuid)
37
+ )), Array.isArray(b) && b.length > 0 && (e = e.filter(
38
+ (o) => b.some((r) => r.toLowerCase() === o.formName.toLowerCase())
39
39
  )), e;
40
- }, [D, c, p]), { data: _ = [] } = b({
40
+ }, [D, c, b]), { data: R = [] } = p({
41
41
  queryKey: ["observationForms"],
42
42
  queryFn: () => ie()
43
43
  }), L = h(
44
- (e) => _.find((r) => r.name === e)?.uuid,
45
- [_]
44
+ (e) => R.find((r) => r.name === e)?.uuid,
45
+ [R]
46
46
  ), F = d(() => {
47
47
  if (a)
48
48
  return L(a.formName);
49
49
  }, [a, L]), {
50
50
  data: l,
51
- isLoading: V,
52
- isError: z,
51
+ isLoading: Y,
52
+ isError: $,
53
53
  error: N
54
- } = b({
54
+ } = p({
55
55
  queryKey: ["formMetadata", F],
56
56
  queryFn: () => ce(F),
57
57
  enabled: !!F && y
58
58
  }), {
59
59
  data: O,
60
- isLoading: G,
61
- isError: Q,
60
+ isLoading: z,
61
+ isError: G,
62
62
  error: E
63
- } = b({
63
+ } = p({
64
64
  queryKey: ["formsEncounterFHIR", a?.encounterUuid],
65
65
  queryFn: () => le(a.encounterUuid),
66
66
  enabled: !!a?.encounterUuid && y
67
67
  });
68
68
  me(
69
69
  (e) => {
70
- e.patientUUID === u && e.updatedConcepts.size > 0 && (K(), w.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
70
+ e.patientUUID === u && e.updatedConcepts.size > 0 && (V(), w.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
71
71
  },
72
72
  [u]
73
73
  );
74
- const X = d(() => !O?.entry || !a?.formName ? [] : O.entry.filter((t) => t.resource?.resourceType === "Observation").map((t) => t.resource).filter((t) => {
75
- const r = Ee(t);
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
77
  }), [O, a?.formName]), Z = d(() => {
78
78
  if (!l?.schema) return;
79
- const e = [], t = (r) => {
80
- (r ?? []).forEach((o) => {
81
- const s = o;
82
- s.id != null && e.push(String(s.id)), s.controls && t(s.controls);
79
+ const e = [], o = (r) => {
80
+ (r ?? []).forEach((t) => {
81
+ const s = t;
82
+ s.id != null && e.push(String(s.id)), s.controls && o(s.controls);
83
83
  });
84
84
  };
85
- return t(
85
+ return o(
86
86
  l.schema.controls ?? []
87
87
  ), e.length > 0 ? e : void 0;
88
- }, [l]), Y = d(() => {
88
+ }, [l]), J = d(() => {
89
89
  if (!l?.schema) return;
90
- const e = {}, t = (r, o) => {
90
+ const e = {}, o = (r, t) => {
91
91
  for (const s of r)
92
92
  if (s.type === "section") {
93
93
  const f = s.label?.value ?? "Section";
94
- t(s.controls ?? [], f);
94
+ o(s.controls ?? [], f);
95
95
  } else
96
- s.id != null && o && (e[String(s.id)] = o), s.controls && t(s.controls, o);
96
+ s.id != null && t && (e[String(s.id)] = t), s.controls && o(s.controls, t);
97
97
  };
98
- return t(
98
+ return o(
99
99
  l.schema.controls ?? [],
100
100
  null
101
101
  ), Object.keys(e).length > 0 ? e : void 0;
102
- }, [l]), J = d(() => {
102
+ }, [l]), W = d(() => {
103
103
  if (N)
104
104
  return k(N).message;
105
105
  if (E)
@@ -110,44 +110,44 @@ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_cu
110
110
  { key: "recordedBy", header: n("RECORDED_BY") }
111
111
  ],
112
112
  [n]
113
- ), W = d(
113
+ ), X = d(
114
114
  () => [
115
115
  { key: "recordedOn", sortable: !0 },
116
116
  { key: "recordedBy", sortable: !0 }
117
117
  ],
118
118
  []
119
119
  ), S = d(() => {
120
- const e = R.reduce(
121
- (r, o) => {
122
- const s = o.formName;
120
+ const e = B.reduce(
121
+ (r, t) => {
122
+ const s = t.formName;
123
123
  r[s] ??= [];
124
- const f = o.providers.map((re) => re.providerName).filter(Boolean).join(", ");
124
+ const f = t.providers.map((re) => re.providerName).filter(Boolean).join(", ");
125
125
  return r[s].push({
126
- id: o.encounterUuid,
127
- formName: o.formName,
128
- recordedOn: ue(o.encounterDateTime, n, !0).formattedResult,
126
+ id: t.encounterUuid,
127
+ formName: t.formName,
128
+ recordedOn: ue(t.encounterDateTime, n, !0).formattedResult,
129
129
  recordedBy: f ?? "--",
130
- encounterDateTime: o.encounterDateTime,
131
- encounterUuid: o.encounterUuid
130
+ encounterDateTime: t.encounterDateTime,
131
+ encounterUuid: t.encounterUuid
132
132
  }), r;
133
133
  },
134
134
  {}
135
135
  );
136
136
  return Object.entries(e).map(
137
- ([r, o]) => ({
137
+ ([r, t]) => ({
138
138
  formName: r,
139
- records: o.sort(
139
+ records: t.sort(
140
140
  (s, f) => f.encounterDateTime - s.encounterDateTime
141
141
  )
142
142
  })
143
- ).sort((r, o) => r.formName.localeCompare(o.formName));
144
- }, [R, n]), q = h((e) => {
145
- I(e), M(!0);
143
+ ).sort((r, t) => r.formName.localeCompare(t.formName));
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
- (e, t) => {
150
- switch (t) {
149
+ (e, o) => {
150
+ switch (o) {
151
151
  case "recordedOn":
152
152
  return /* @__PURE__ */ i(fe, { onClick: () => q(e), children: e.recordedOn });
153
153
  case "recordedBy":
@@ -158,38 +158,38 @@ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_cu
158
158
  },
159
159
  [q]
160
160
  );
161
- return /* @__PURE__ */ te(oe, { children: [
162
- /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: T || B || S.length === 0 || A ? /* @__PURE__ */ i(
161
+ return /* @__PURE__ */ oe(te, { children: [
162
+ /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: T || _ || S.length === 0 || I ? /* @__PURE__ */ i(
163
163
  x,
164
164
  {
165
165
  headers: C,
166
166
  ariaLabel: n("FORMS_HEADING"),
167
167
  rows: [],
168
168
  loading: T,
169
- errorStateMessage: B ? $?.message : void 0,
169
+ errorStateMessage: _ ? K?.message : void 0,
170
170
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
171
171
  renderCell: U,
172
172
  className: v.formsTableBody,
173
173
  dataTestId: "forms-table"
174
174
  }
175
- ) : /* @__PURE__ */ i(ye, { align: "start", children: S.map((e, t) => {
176
- const { formName: r, records: o } = e;
175
+ ) : /* @__PURE__ */ i(ye, { align: "start", children: S.map((e, o) => {
176
+ const { formName: r, records: t } = e;
177
177
  return /* @__PURE__ */ i(
178
- pe,
178
+ be,
179
179
  {
180
180
  title: r,
181
181
  className: v.customAccordianItem,
182
182
  testId: `accordian-title-${r}`,
183
- open: t === 0,
183
+ open: o === 0,
184
184
  children: /* @__PURE__ */ i(
185
185
  x,
186
186
  {
187
187
  headers: C,
188
188
  ariaLabel: n("FORMS_HEADING"),
189
- rows: o,
189
+ rows: t,
190
190
  loading: !1,
191
191
  errorStateMessage: "",
192
- sortable: W,
192
+ sortable: X,
193
193
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
194
194
  renderCell: U,
195
195
  className: v.formsTableBody,
@@ -201,7 +201,7 @@ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_cu
201
201
  );
202
202
  }) }) }),
203
203
  y && a && /* @__PURE__ */ i(
204
- be,
204
+ pe,
205
205
  {
206
206
  id: "modalIdForActionAreaLayout",
207
207
  portalId: "main-display-area",
@@ -215,15 +215,15 @@ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_cu
215
215
  children: /* @__PURE__ */ i(
216
216
  he,
217
217
  {
218
- observations: X,
219
- isLoading: V || G,
220
- isError: z || Q,
221
- errorMessage: J,
218
+ observations: Q,
219
+ isLoading: Y || z,
220
+ isError: $ || G,
221
+ errorMessage: W,
222
222
  emptyStateMessage: n("NO_FORM_DATA_AVAILABLE"),
223
223
  testIdPrefix: a.formName,
224
224
  hideThumbnail: j,
225
225
  controlOrder: Z,
226
- sectionMap: Y
226
+ sectionMap: J
227
227
  }
228
228
  )
229
229
  }
@@ -1,10 +1,10 @@
1
1
  import { jsx as d, jsxs as N } from "react/jsx-runtime";
2
- import { f as Q, J as D, t as H, b as K, c as V, d as k, e as j, Q as q, u as G, a as P, g as J, L as z, w as X, h as Y, i as W, k as Z, o as x, j as ee } from "./index-CvF-qMtP.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) => {
7
- const s = H(t, i, u), o = s.value, a = K(o);
6
+ const B = (t, i, c, l, u, r) => {
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
10
  k,
@@ -26,7 +26,7 @@ const F = (t, i, c, l, u, r) => {
26
26
  provider: s.provider
27
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
- V,
29
+ w,
30
30
  {
31
31
  header: s.header,
32
32
  value: n,
@@ -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,
@@ -61,7 +61,7 @@ const F = (t, i, c, l, u, r) => {
61
61
  hideThumbnail: c
62
62
  }) => {
63
63
  const { t: l } = U(), u = (r, s, o) => {
64
- const a = Q(r.encounterDetails, l);
64
+ const a = H(r.encounterDetails, l);
65
65
  return /* @__PURE__ */ N(
66
66
  D,
67
67
  {
@@ -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,
@@ -161,11 +161,11 @@ const F = (t, i, c, l, u, r) => {
161
161
  if (!m) return [];
162
162
  const e = Y(m), v = W(e);
163
163
  return Z(v);
164
- }, [m]), L = [
164
+ }, [m]), F = [
165
165
  { key: "name", header: "name" },
166
166
  { key: "value", header: "value" },
167
167
  { key: "form", header: "form" }
168
- ], $ = y || !f, I = h && f, B = (!m || m.entry?.length === 0 || p.length === 0) && f, A = I ? a("ERROR_FETCHING_OBSERVATIONS") : null, w = B ? a("NO_OBSERVATIONS_FOUND") : void 0, M = _.length > 0 && !$ && !I, O = i.titleTranslationKey, E = 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
  {
@@ -184,7 +184,7 @@ const F = (t, i, c, l, u, r) => {
184
184
  children: /* @__PURE__ */ d("p", { children: E })
185
185
  }
186
186
  ),
187
- M ? /* @__PURE__ */ d(
187
+ Q ? /* @__PURE__ */ d(
188
188
  ae,
189
189
  {
190
190
  groupedData: _,
@@ -194,12 +194,12 @@ const F = (t, i, c, l, u, r) => {
194
194
  ) : /* @__PURE__ */ d(
195
195
  ee,
196
196
  {
197
- headers: L,
197
+ headers: F,
198
198
  rows: [],
199
199
  ariaLabel: a("OBSERVATIONS"),
200
- loading: $,
201
- errorStateMessage: A,
202
- emptyStateMessage: w,
200
+ loading: I,
201
+ errorStateMessage: L,
202
+ emptyStateMessage: M,
203
203
  dataTestId: "observations-table"
204
204
  }
205
205
  )