@bahmni/widgets 0.0.1-dev.376 → 0.0.1-dev.378

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, T as J, P as Z, k as x, q as ee, F as te } from "./index-D6eQA2wz.js";
2
+ import { u as W, a as X, T as J, b as Z, k as x, c as ee, F as te } from "./index-DO4VzF3-.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,15 +37,15 @@ const Te = [
37
37
  ], _e = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, B = (n) => n.attachments.length > 0 ? n.attachments : n.documentUrl ? [{ url: n.documentUrl, contentType: n.contentType }] : [], Ie = ({ config: n, encounterUuids: f }) => {
38
38
  const [d, L] = l(!1), [s, U] = l(
39
39
  null
40
- ), [P, A] = l(
40
+ ), [k, A] = l(
41
41
  /* @__PURE__ */ new Set()
42
- ), E = W(), { t: o } = ae(), { addNotification: w } = X(), k = Number(n?.pageSize) || 5, [N, C] = l(1), [u, V] = l(k), [$, O] = l(void 0), v = _((e) => {
42
+ ), E = W(), { t: o } = ae(), { addNotification: w } = X(), P = Number(n?.pageSize) || 5, [N, C] = l(1), [u, V] = l(P), [$, O] = l(void 0), v = _((e) => {
43
43
  U(e), L(!0);
44
- }, []), H = _(() => {
44
+ }, []), z = _(() => {
45
45
  L(!1), U(null), A(/* @__PURE__ */ new Set());
46
46
  }, []), F = _((e) => {
47
47
  A((t) => new Set(t).add(e));
48
- }, []), { data: i, isLoading: q, isError: S, error: y } = ne({
48
+ }, []), { data: i, isLoading: H, isError: S, error: b } = ne({
49
49
  queryKey: [
50
50
  "documents",
51
51
  E,
@@ -68,18 +68,18 @@ const Te = [
68
68
  }, [E]), I(() => {
69
69
  S && w({
70
70
  title: o("ERROR_DEFAULT_TITLE"),
71
- message: y?.message ?? "",
71
+ message: b?.message ?? "",
72
72
  type: "error"
73
73
  });
74
- }, [S, y, w, o]), I(() => {
74
+ }, [S, b, w, o]), I(() => {
75
75
  const e = new AbortController();
76
76
  return (async () => {
77
77
  if (!d || !s) return;
78
78
  const a = /* @__PURE__ */ new Set(), g = B(s);
79
79
  for (let m = 0; m < g.length; m++) {
80
- const b = R(g[m].url);
80
+ const y = R(g[m].url);
81
81
  try {
82
- (await fetch(b, {
82
+ (await fetch(y, {
83
83
  method: "HEAD",
84
84
  signal: e.signal
85
85
  })).ok || a.add(m);
@@ -90,7 +90,7 @@ const Te = [
90
90
  e.signal.aborted || A(a);
91
91
  })(), () => e.abort();
92
92
  }, [d, s]);
93
- const z = _(
93
+ const q = _(
94
94
  (e, t) => {
95
95
  t !== u ? (V(t), C(1), O(void 0)) : C(e);
96
96
  },
@@ -145,8 +145,8 @@ const Te = [
145
145
  headers: K,
146
146
  ariaLabel: o("DOCUMENTS_TABLE_HEADING"),
147
147
  rows: j,
148
- loading: q,
149
- errorStateMessage: S ? y?.message : null,
148
+ loading: H,
149
+ errorStateMessage: S ? b?.message : null,
150
150
  sortable: G,
151
151
  emptyStateMessage: o("DOCUMENTS_NO_RECORDS"),
152
152
  renderCell: Q,
@@ -155,7 +155,7 @@ const Te = [
155
155
  pageSize: u,
156
156
  totalItems: $,
157
157
  page: N,
158
- onPageChange: z
158
+ onPageChange: q
159
159
  }
160
160
  ) }),
161
161
  d && s && /* @__PURE__ */ r(
@@ -164,14 +164,14 @@ const Te = [
164
164
  id: "modalIdForActionAreaLayout",
165
165
  portalId: "main-display-area",
166
166
  open: d,
167
- onRequestClose: H,
167
+ onRequestClose: z,
168
168
  modalHeading: s.documentIdentifier,
169
169
  passiveModal: !0,
170
170
  size: "lg",
171
171
  testId: "document-view-modal",
172
172
  children: /* @__PURE__ */ r("div", { className: c.documentViewerContainer, children: h.map((e, t) => {
173
- const a = R(e.url), g = e.contentType?.toLowerCase().includes("pdf"), m = (e.contentType?.toLowerCase().includes("image") ?? !1) || _e.test(e.url ?? ""), b = P.has(t);
174
- return a === "#" || b ? /* @__PURE__ */ T(
173
+ const a = R(e.url), g = e.contentType?.toLowerCase().includes("pdf"), m = (e.contentType?.toLowerCase().includes("image") ?? !1) || _e.test(e.url ?? ""), y = k.has(t);
174
+ return a === "#" || y ? /* @__PURE__ */ T(
175
175
  "div",
176
176
  {
177
177
  className: c.attachmentError,
@@ -1,5 +1,5 @@
1
- import { jsx as i, jsxs as x, Fragment as ge } from "react/jsx-runtime";
2
- import { u as be, b as Oe, c as Ne, r as Ee, e as Te, Q as Fe, X as ve, L as Ie, m as _e, d as Ae, f as Re, Y as z, k as De, i as G, $ as K, P as Me, q as Q, g as Le, R as Se, F as Be, O as Ce, C as ke } from "./index-D6eQA2wz.js";
1
+ import { jsx as i, jsxs as $, Fragment as ge } from "react/jsx-runtime";
2
+ import { u as be, d as Oe, e as Ne, r as Ee, f as Te, Q as Fe, X as ve, L as Ie, m as _e, g as Ae, h as Re, Y as G, k as De, H as K, Z as Q, b as Le, c as z, n as Me, i as Se, F as Be, O as Ce, C as ke } from "./index-DO4VzF3-.js";
3
3
  import { useQueryClient as Ue, useQuery as E } from "@tanstack/react-query";
4
4
  import { useState as Y, useMemo as d, useCallback as c } from "react";
5
5
  import { useTranslation as we } from "react-i18next";
@@ -7,20 +7,20 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
7
7
  formsTableBody: He,
8
8
  modalHeading: qe,
9
9
  customAccordianItem: Pe
10
- }, Ve = "startConsultation", Ke = ({
10
+ }, Ve = "startConsultation", Qe = ({
11
11
  episodeOfCareUuids: D,
12
12
  encounterUuids: m,
13
13
  config: X,
14
- disableActions: W = !1,
14
+ disableActions: Z = !1,
15
15
  activeEncounterUuid: y = null
16
16
  }) => {
17
- const { t: n } = we(), u = be(), [g, M] = Y(!1), [a, L] = Y(null), {
18
- numberOfVisits: J,
19
- hideThumbnail: Z = !1,
17
+ const { t: n } = we(), u = be(), [g, L] = Y(!1), [a, M] = Y(null), {
18
+ numberOfVisits: W,
19
+ hideThumbnail: J = !1,
20
20
  forms: b
21
21
  } = X ?? {}, ee = Oe(
22
22
  ke.EDIT_OBSERVATIONS
23
- ), { userPrivileges: O } = Ne(), F = ee && !W && !!y, S = Ee(
23
+ ), { userPrivileges: O } = Ne(), F = ee && !Z && !!y, S = Ee(
24
24
  D,
25
25
  m
26
26
  ), re = Ue(), {
@@ -31,7 +31,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
31
31
  refetch: oe
32
32
  } = E({
33
33
  queryKey: ["forms", u, D],
34
- queryFn: () => Te(u, void 0, J),
34
+ queryFn: () => Te(u, void 0, W),
35
35
  enabled: !!u && !S
36
36
  }), U = d(() => {
37
37
  let e = B;
@@ -126,9 +126,9 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
126
126
  ), Object.keys(e).length > 0 ? e : void 0;
127
127
  }, [l]), ue = d(() => {
128
128
  if (I)
129
- return z(I).message;
129
+ return G(I).message;
130
130
  if (A)
131
- return z(A).message;
131
+ return G(A).message;
132
132
  }, [I, A]), h = d(
133
133
  () => [
134
134
  { key: "recordedOn", header: n("RECORDED_ON") },
@@ -173,9 +173,9 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
173
173
  })
174
174
  ).sort((o, t) => o.formName.localeCompare(t.formName));
175
175
  }, [U, n]), V = c((e) => {
176
- L(e), M(!0);
177
- }, []), $ = c(() => {
178
- M(!1), L(null);
176
+ M(e), L(!0);
177
+ }, []), j = c(() => {
178
+ L(!1), M(null);
179
179
  }, []), R = c((e) => {
180
180
  globalThis.dispatchEvent(
181
181
  new CustomEvent(Ve, {
@@ -188,23 +188,23 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
188
188
  }
189
189
  })
190
190
  );
191
- }, []), j = c(
191
+ }, []), x = c(
192
192
  (e, r) => {
193
193
  switch (r) {
194
194
  case "recordedOn":
195
- return /* @__PURE__ */ i(Me, { onClick: () => V(e), children: e.recordedOn });
195
+ return /* @__PURE__ */ i(Le, { onClick: () => V(e), children: e.recordedOn });
196
196
  case "recordedBy":
197
197
  return e.recordedBy;
198
198
  case "actions":
199
199
  return f(e) ? /* @__PURE__ */ i(
200
- G,
200
+ K,
201
201
  {
202
202
  label: n("EDIT_OBSERVATION_FORM"),
203
203
  kind: "ghost",
204
204
  size: "sm",
205
205
  testId: `edit-form-${e.encounterUuid}`,
206
206
  onClick: () => R(e),
207
- children: /* @__PURE__ */ i(K, {})
207
+ children: /* @__PURE__ */ i(Q, {})
208
208
  }
209
209
  ) : null;
210
210
  default:
@@ -213,9 +213,9 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
213
213
  },
214
214
  [V, R, f, n]
215
215
  );
216
- return /* @__PURE__ */ x(ge, { children: [
216
+ return /* @__PURE__ */ $(ge, { children: [
217
217
  /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: C || k || P.length === 0 || S ? /* @__PURE__ */ i(
218
- Q,
218
+ z,
219
219
  {
220
220
  headers: he,
221
221
  ariaLabel: n("FORMS_HEADING"),
@@ -223,11 +223,11 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
223
223
  loading: C,
224
224
  errorStateMessage: k ? te?.message : void 0,
225
225
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
226
- renderCell: j,
226
+ renderCell: x,
227
227
  className: T.formsTableBody,
228
228
  dataTestId: "forms-table"
229
229
  }
230
- ) : /* @__PURE__ */ i(Le, { align: "start", children: P.map((e, r) => {
230
+ ) : /* @__PURE__ */ i(Me, { align: "start", children: P.map((e, r) => {
231
231
  const { formName: o, records: t } = e, s = fe(t);
232
232
  return /* @__PURE__ */ i(
233
233
  Se,
@@ -237,7 +237,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
237
237
  testId: `accordian-title-${o}`,
238
238
  open: r === 0,
239
239
  children: /* @__PURE__ */ i(
240
- Q,
240
+ z,
241
241
  {
242
242
  headers: s,
243
243
  ariaLabel: n("FORMS_HEADING"),
@@ -246,7 +246,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
246
246
  errorStateMessage: "",
247
247
  sortable: pe,
248
248
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
249
- renderCell: j,
249
+ renderCell: x,
250
250
  className: T.formsTableBody,
251
251
  dataTestId: `forms-table-${o}`
252
252
  }
@@ -261,20 +261,20 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
261
261
  id: "modalIdForActionAreaLayout",
262
262
  portalId: "main-display-area",
263
263
  open: g,
264
- onRequestClose: $,
265
- modalHeading: /* @__PURE__ */ x("div", { className: T.modalHeading, children: [
264
+ onRequestClose: j,
265
+ modalHeading: /* @__PURE__ */ $("div", { className: T.modalHeading, children: [
266
266
  /* @__PURE__ */ i("span", { children: a.formName }),
267
267
  F && f(a) && /* @__PURE__ */ i(
268
- G,
268
+ K,
269
269
  {
270
270
  label: n("EDIT_OBSERVATION_FORM"),
271
271
  kind: "ghost",
272
272
  size: "sm",
273
273
  testId: `edit-form-modal-${a.encounterUuid}`,
274
274
  onClick: () => {
275
- $(), R(a);
275
+ j(), R(a);
276
276
  },
277
- children: /* @__PURE__ */ i(K, {})
277
+ children: /* @__PURE__ */ i(Q, {})
278
278
  }
279
279
  )
280
280
  ] }),
@@ -291,7 +291,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
291
291
  errorMessage: ue,
292
292
  emptyStateMessage: n("NO_FORM_DATA_AVAILABLE"),
293
293
  testIdPrefix: a.formName,
294
- hideThumbnail: Z,
294
+ hideThumbnail: J,
295
295
  controlOrder: le,
296
296
  sectionMap: ce,
297
297
  conceptDatatypeMap: me
@@ -302,5 +302,5 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
302
302
  ] });
303
303
  };
304
304
  export {
305
- Ke as default
305
+ Qe as default
306
306
  };
@@ -1,10 +1,10 @@
1
- import { jsx as d, jsxs as S } from "react/jsx-runtime";
2
- import { h as K, j as N, t as V, D as q, W as Q, l as k, n as G, o as H, u as P, a as j, w as z, p as W, m as J, s as Y, v as X, x as Z, y as x, q as ee } from "./index-D6eQA2wz.js";
1
+ import { jsx as d, jsxs as N } from "react/jsx-runtime";
2
+ import { j as M, _ as C, t as V, D as Q, p as q, z as k, l as z, y as G, u as P, a as j, w as H, o as J, m as Y, q as W, s as X, v as Z, R as x, c as ee } from "./index-DO4VzF3-.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 D, useMemo as R } from "react";
5
5
  import { useTranslation as U } from "react-i18next";
6
6
  const B = (t, i, c, l, u, r) => {
7
- const s = V(t, i, u), o = s.value, a = q(o);
7
+ const s = V(t, i, u), o = s.value, a = Q(o);
8
8
  let n = o;
9
9
  a === "Image" && (n = /* @__PURE__ */ d(
10
10
  k,
@@ -15,30 +15,30 @@ const B = (t, i, c, l, u, r) => {
15
15
  hideThumbnail: r
16
16
  }
17
17
  )), a === "Video" && (n = /* @__PURE__ */ d(
18
- G,
18
+ z,
19
19
  {
20
20
  id: `${o}-video`,
21
21
  videoSrc: o,
22
22
  hideThumbnail: r
23
23
  }
24
- )), a === "PDF" && (n = /* @__PURE__ */ d(H, { 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 = l ? `${l}-${p}-${m}-${c}-${i}` : `${p}-${m}-${c}-${i}`;
27
+ }), m = t.display, p = t.observationValue?.isAbnormal ? "abnormal-obs" : "obs", f = l ? `${l}-${p}-${m}-${c}-${i}` : `${p}-${m}-${c}-${i}`;
28
28
  return /* @__PURE__ */ d(
29
- Q,
29
+ q,
30
30
  {
31
31
  header: s.header,
32
32
  value: n,
33
33
  info: b,
34
- id: y,
35
- testId: y,
36
- ariaLabel: y
34
+ id: f,
35
+ testId: f,
36
+ ariaLabel: f
37
37
  },
38
38
  `obs-${t.id}`
39
39
  );
40
40
  }, re = (t, i, c, l, u, r, s) => /* @__PURE__ */ d(
41
- N,
41
+ C,
42
42
  {
43
43
  title: t.display,
44
44
  id: `grouped-obs-${t.display}-${l}`,
@@ -61,9 +61,9 @@ const B = (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 = K(r.encounterDetails, l);
65
- return /* @__PURE__ */ S(
66
- N,
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}`,
@@ -106,7 +106,7 @@ const B = (t, i, c, l, u, r) => {
106
106
  )
107
107
  }
108
108
  );
109
- }, ne = "Observations-module_observations__RKSyo", ie = "Observations-module_title__TJL3z", D = {
109
+ }, ne = "Observations-module_observations__RKSyo", ie = "Observations-module_title__TJL3z", S = {
110
110
  observations: ne,
111
111
  title: ie
112
112
  }, ce = (t) => ["conceptUuid", t], le = (t, i) => ["observations", t, ...i], ve = ({ config: t }) => {
@@ -117,62 +117,62 @@ const B = (t, i, c, l, u, r) => {
117
117
  } = i, r = oe(/* @__PURE__ */ new Set()), s = P(), { addNotification: o } = j(), { t: a } = U(), n = te({
118
118
  queries: c.map((e) => ({
119
119
  queryKey: ce(e),
120
- queryFn: () => z(e),
120
+ queryFn: () => H(e),
121
121
  enabled: !!e
122
122
  }))
123
123
  });
124
- C(() => {
124
+ D(() => {
125
125
  n.forEach((e, v) => {
126
126
  if (e.isError && !r.current.has(v)) {
127
- const R = c[v];
127
+ const h = c[v];
128
128
  o({
129
129
  title: a("ERROR_DEFAULT_TITLE"),
130
- message: a("ERROR_FETCHING_CONCEPT", { conceptName: R }),
130
+ message: a("ERROR_FETCHING_CONCEPT", { conceptName: h }),
131
131
  type: "error"
132
132
  }), r.current.add(v);
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]), m = g(() => [.../* @__PURE__ */ new Set([...b, ...l])], [b, l]), f = g(() => c.length === 0 ? !0 : n.every((e) => !e.isLoading), [n, c.length]), {
136
+ const b = R(() => n.map((e) => e.data?.uuid).filter((e) => !!e), [n]), m = R(() => [.../* @__PURE__ */ new Set([...b, ...l])], [b, l]), y = R(() => c.length === 0 ? !0 : n.every((e) => !e.isLoading), [n, c.length]), {
137
137
  data: p,
138
- isLoading: y,
139
- isError: h,
138
+ isLoading: f,
139
+ isError: g,
140
140
  refetch: T
141
141
  } = se({
142
142
  queryKey: le(s, m),
143
- queryFn: () => W(s, m),
144
- enabled: !!s && m.length > 0 && f
143
+ queryFn: () => J(s, m),
144
+ enabled: !!s && m.length > 0 && y
145
145
  });
146
- J(
146
+ Y(
147
147
  (e) => {
148
148
  e.patientUUID === s && e.updatedConcepts.size > 0 && [...e.updatedConcepts.keys()].some(
149
- (R) => m.includes(R)
149
+ (h) => m.includes(h)
150
150
  ) && T();
151
151
  },
152
152
  [s, T]
153
- ), C(() => {
154
- h && o({
153
+ ), D(() => {
154
+ g && o({
155
155
  title: a("ERROR_DEFAULT_TITLE"),
156
156
  message: a("ERROR_FETCHING_OBSERVATIONS"),
157
157
  type: "error"
158
158
  });
159
- }, [h]);
160
- const _ = g(() => {
159
+ }, [g]);
160
+ const _ = R(() => {
161
161
  if (!p) return [];
162
- const e = Y(p), v = X(e);
162
+ const e = W(p), v = X(e);
163
163
  return Z(v);
164
- }, [p]), A = [
164
+ }, [p]), L = [
165
165
  { key: "name", header: "name" },
166
166
  { key: "value", header: "value" },
167
167
  { key: "form", header: "form" }
168
- ], I = y || !f, $ = h && f, F = (!p || p.entry?.length === 0 || m.length === 0) && f, L = $ ? a("ERROR_FETCHING_OBSERVATIONS") : null, M = F ? a("NO_OBSERVATIONS_FOUND") : void 0, w = _.length > 0 && !I && !$, O = i.titleTranslationKey, E = O ? a(O) : "";
169
- return /* @__PURE__ */ S(
168
+ ], I = f || !y, $ = g && y, A = (!p || p.entry?.length === 0 || m.length === 0) && y, F = $ ? a("ERROR_FETCHING_OBSERVATIONS") : null, w = 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",
173
173
  "data-testid": O ? `observations-${E}` : "observations",
174
174
  "aria-label": "observations-aria-label",
175
- className: D.observations,
175
+ className: S.observations,
176
176
  children: [
177
177
  /* @__PURE__ */ d(
178
178
  x,
@@ -180,11 +180,11 @@ const B = (t, i, c, l, u, r) => {
180
180
  id: "observations-title",
181
181
  testId: O ? `observations-title-${E}` : "observations-title",
182
182
  title: E,
183
- className: D.title,
183
+ className: S.title,
184
184
  children: /* @__PURE__ */ d("p", { children: E })
185
185
  }
186
186
  ),
187
- w ? /* @__PURE__ */ d(
187
+ K ? /* @__PURE__ */ d(
188
188
  ae,
189
189
  {
190
190
  groupedData: _,
@@ -194,12 +194,12 @@ const B = (t, i, c, l, u, r) => {
194
194
  ) : /* @__PURE__ */ d(
195
195
  ee,
196
196
  {
197
- headers: A,
197
+ headers: L,
198
198
  rows: [],
199
199
  ariaLabel: a("OBSERVATIONS"),
200
200
  loading: I,
201
- errorStateMessage: L,
202
- emptyStateMessage: M,
201
+ errorStateMessage: F,
202
+ emptyStateMessage: w,
203
203
  dataTestId: "observations-table"
204
204
  }
205
205
  )