@bahmni/widgets 0.0.1-dev.384 → 0.0.1-dev.386

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, R as J, m as Z, M as x, b as ee, F as te } from "./index-DgSe-s_z.js";
2
+ import { u as W, a as X, O as J, m as Z, U as x, b as ee, F as te } from "./index-C4Ies-5q.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";
@@ -19,7 +19,7 @@ const oe = "DocumentsTable-module_documentsTableBody__6iR3w", se = "DocumentsTab
19
19
  uploadedBy: "DOCUMENTS_UPLOADED_BY",
20
20
  attachments: "DOCUMENTS_ATTACHMENTS"
21
21
  };
22
- function F(n) {
22
+ function R(n) {
23
23
  return !n || n.includes(":") ? "#" : `/openmrs/auth?requested_document=/document_images/${n}`;
24
24
  }
25
25
  function he(n, f) {
@@ -35,15 +35,15 @@ const Te = [
35
35
  "uploadedOn",
36
36
  "uploadedBy"
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
- const [d, L] = l(!1), [s, U] = l(
38
+ const [d, M] = l(!1), [s, L] = l(
39
39
  null
40
40
  ), [P, A] = l(
41
41
  /* @__PURE__ */ new Set()
42
- ), E = W(), { t: o } = ae(), { addNotification: w } = X(), V = Number(n?.pageSize) || 5, [N, C] = l(1), [u, $] = l(V), [k, O] = l(void 0), v = _((e) => {
43
- U(e), L(!0);
42
+ ), E = W(), { t: o } = ae(), { addNotification: w } = X(), V = Number(n?.pageSize) || 5, [N, O] = l(1), [u, $] = l(V), [k, C] = l(void 0), v = _((e) => {
43
+ L(e), M(!0);
44
44
  }, []), z = _(() => {
45
- L(!1), U(null), A(/* @__PURE__ */ new Set());
46
- }, []), R = _((e) => {
45
+ M(!1), L(null), A(/* @__PURE__ */ new Set());
46
+ }, []), F = _((e) => {
47
47
  A((t) => new Set(t).add(e));
48
48
  }, []), { data: i, isLoading: H, isError: S, error: b } = ne({
49
49
  queryKey: [
@@ -62,9 +62,9 @@ const Te = [
62
62
  )
63
63
  });
64
64
  I(() => {
65
- i && O(i.total);
65
+ i && C(i.total);
66
66
  }, [i]), I(() => {
67
- C(1), O(void 0);
67
+ O(1), C(void 0);
68
68
  }, [E]), I(() => {
69
69
  S && w({
70
70
  title: o("ERROR_DEFAULT_TITLE"),
@@ -77,14 +77,14 @@ const Te = [
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 y = F(g[m].url);
80
+ const y = R(g[m].url);
81
81
  try {
82
82
  (await fetch(y, {
83
83
  method: "HEAD",
84
84
  signal: e.signal
85
85
  })).ok || a.add(m);
86
- } catch (M) {
87
- M instanceof Error && M.name !== "AbortError" && a.add(m);
86
+ } catch (U) {
87
+ U instanceof Error && U.name !== "AbortError" && a.add(m);
88
88
  }
89
89
  }
90
90
  e.signal.aborted || A(a);
@@ -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(
@@ -170,7 +170,7 @@ const Te = [
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 = F(e.url), g = e.contentType?.toLowerCase().includes("pdf"), m = (e.contentType?.toLowerCase().includes("image") ?? !1) || _e.test(e.url ?? ""), y = P.has(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 = P.has(t);
174
174
  return a === "#" || y ? /* @__PURE__ */ T(
175
175
  "div",
176
176
  {
@@ -203,7 +203,7 @@ const Te = [
203
203
  src: a,
204
204
  alt: s.documentIdentifier,
205
205
  className: c.documentImage,
206
- onError: () => R(t)
206
+ onError: () => F(t)
207
207
  }
208
208
  ) : /* @__PURE__ */ r(
209
209
  "iframe",
@@ -211,7 +211,7 @@ const Te = [
211
211
  src: g ? `${a}#toolbar=0` : a,
212
212
  className: c.documentIframe,
213
213
  title: s.documentIdentifier,
214
- onError: () => R(t)
214
+ onError: () => F(t)
215
215
  }
216
216
  )
217
217
  ]
@@ -1,5 +1,5 @@
1
1
  import { jsx as i, jsxs as $, Fragment as be } from "react/jsx-runtime";
2
- import { u as ge, c as Oe, d as Ne, n as Ee, t as Te, X as Fe, Z as ve, x as Ie, y as Ae, e as _e, f as Re, Y as G, M as Me, C as K, B as z, m as De, b as Q, r as Le, g as Be, F as Ce, O as Se, h as Ue } from "./index-DgSe-s_z.js";
2
+ import { u as ge, c as Ne, d as Oe, s as Ee, r as Te, Z as ve, e as Fe, k as Ie, w as Ae, f as _e, g as Re, Y as G, U as De, C as K, B as z, m as Me, b as Q, h as Le, i as Be, F as Ce, j as Se, l as Ue } from "./index-C4Ies-5q.js";
3
3
  import { useQueryClient as we, 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 ke } from "react-i18next";
@@ -8,20 +8,20 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
8
8
  modalHeading: qe,
9
9
  customAccordianItem: Pe
10
10
  }, Ve = "startConsultation", ze = ({
11
- episodeOfCareUuids: M,
11
+ episodeOfCareUuids: D,
12
12
  encounterUuids: m,
13
- config: X,
14
- disableActions: Z = !1,
15
- activeEncounterUuid: p = null
13
+ config: Z,
14
+ disableActions: W = !1,
15
+ activeEncounterUuid: y = null
16
16
  }) => {
17
- const { t: n } = ke(), u = ge(), [b, D] = Y(!1), [a, L] = Y(null), {
18
- numberOfVisits: W,
19
- hideThumbnail: J = !1,
17
+ const { t: n } = ke(), u = ge(), [b, M] = Y(!1), [a, L] = Y(null), {
18
+ numberOfVisits: J,
19
+ hideThumbnail: X = !1,
20
20
  forms: g
21
- } = X ?? {}, ee = Oe(
21
+ } = Z ?? {}, ee = Ne(
22
22
  Ue.EDIT_OBSERVATIONS
23
- ), { userPrivileges: O } = Ne(), F = ee && !Z && !!p, B = Ee(
24
- M,
23
+ ), { userPrivileges: N } = Oe(), v = ee && !W && !!y, B = Ee(
24
+ D,
25
25
  m
26
26
  ), re = we(), {
27
27
  data: C = [],
@@ -30,8 +30,8 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
30
30
  error: te,
31
31
  refetch: oe
32
32
  } = E({
33
- queryKey: ["forms", u, M],
34
- queryFn: () => Te(u, void 0, W),
33
+ queryKey: ["forms", u, D],
34
+ queryFn: () => Te(u, void 0, J),
35
35
  enabled: !!u && !B
36
36
  }), w = d(() => {
37
37
  let e = C;
@@ -40,27 +40,27 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
40
40
  )), Array.isArray(g) && g.length > 0 && (e = e.filter(
41
41
  (r) => g.some((o) => o.toLowerCase() === r.formName.toLowerCase())
42
42
  )), e;
43
- }, [C, m, g]), { data: N = [] } = E({
43
+ }, [C, m, g]), { data: O = [] } = E({
44
44
  queryKey: ["observationForms"],
45
- queryFn: () => Fe()
45
+ queryFn: () => ve()
46
46
  }), k = c(
47
47
  (e) => {
48
- const r = N.find((t) => t.name === e);
48
+ const r = O.find((t) => t.name === e);
49
49
  if (!r?.privileges || r.privileges.length === 0) return !0;
50
- if (!O || O.length === 0) return !1;
51
- const o = new Set(O.map((t) => t.name));
50
+ if (!N || N.length === 0) return !1;
51
+ const o = new Set(N.map((t) => t.name));
52
52
  return r.privileges.some(
53
53
  (t) => o.has(t.privilegeName) && t.editable
54
54
  );
55
55
  },
56
- [N, O]
56
+ [O, N]
57
57
  ), f = c(
58
- (e) => !p || e.encounterUuid !== p ? !1 : k(e.formName),
59
- [p, k]
58
+ (e) => !y || e.encounterUuid !== y ? !1 : k(e.formName),
59
+ [y, k]
60
60
  ), H = c(
61
- (e) => N.find((o) => o.name === e)?.uuid,
62
- [N]
63
- ), v = d(() => {
61
+ (e) => O.find((o) => o.name === e)?.uuid,
62
+ [O]
63
+ ), F = d(() => {
64
64
  if (a)
65
65
  return H(a.formName);
66
66
  }, [a, H]), {
@@ -69,9 +69,9 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
69
69
  isError: ae,
70
70
  error: I
71
71
  } = E({
72
- queryKey: ["formMetadata", v],
73
- queryFn: () => ve(v),
74
- enabled: !!v && b
72
+ queryKey: ["formMetadata", F],
73
+ queryFn: () => Fe(F),
74
+ enabled: !!F && b
75
75
  }), {
76
76
  data: A,
77
77
  isLoading: ne,
@@ -104,8 +104,8 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
104
104
  const e = {}, r = (o, t) => {
105
105
  for (const s of o)
106
106
  if (s.type === "section") {
107
- const y = s.label?.value ?? "Section";
108
- r(s.controls ?? [], y);
107
+ const p = s.label?.value ?? "Section";
108
+ r(s.controls ?? [], p);
109
109
  } else
110
110
  s.id != null && t && (e[String(s.id)] = t), s.controls && r(s.controls, t);
111
111
  };
@@ -139,9 +139,9 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
139
139
  () => [...h, { key: "actions", header: n("ACTIONS") }],
140
140
  [h, n]
141
141
  ), fe = c(
142
- (e) => F && e.some((o) => f(o)) ? q : h,
143
- [F, f, q, h]
144
- ), he = h, ye = d(
142
+ (e) => v && e.some((o) => f(o)) ? q : h,
143
+ [v, f, q, h]
144
+ ), he = h, pe = d(
145
145
  () => [
146
146
  { key: "recordedOn", sortable: !0 },
147
147
  { key: "recordedBy", sortable: !0 }
@@ -152,12 +152,12 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
152
152
  (o, t) => {
153
153
  const s = t.formName;
154
154
  o[s] ??= [];
155
- const y = t.providers.map((pe) => pe.providerName).filter(Boolean).join(", ");
155
+ const p = t.providers.map((ye) => ye.providerName).filter(Boolean).join(", ");
156
156
  return o[s].push({
157
157
  id: t.encounterUuid,
158
158
  formName: t.formName,
159
- recordedOn: Me(t.encounterDateTime, n, !0).formattedResult,
160
- recordedBy: y ?? "--",
159
+ recordedOn: De(t.encounterDateTime, n, !0).formattedResult,
160
+ recordedBy: p ?? "--",
161
161
  encounterDateTime: t.encounterDateTime,
162
162
  encounterUuid: t.encounterUuid
163
163
  }), o;
@@ -168,14 +168,14 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
168
168
  ([o, t]) => ({
169
169
  formName: o,
170
170
  records: t.sort(
171
- (s, y) => y.encounterDateTime - s.encounterDateTime
171
+ (s, p) => p.encounterDateTime - s.encounterDateTime
172
172
  )
173
173
  })
174
174
  ).sort((o, t) => o.formName.localeCompare(t.formName));
175
175
  }, [w, n]), V = c((e) => {
176
- L(e), D(!0);
177
- }, []), x = c(() => {
178
- D(!1), L(null);
176
+ L(e), M(!0);
177
+ }, []), j = c(() => {
178
+ M(!1), L(null);
179
179
  }, []), R = c((e) => {
180
180
  globalThis.dispatchEvent(
181
181
  new CustomEvent(Ve, {
@@ -188,11 +188,11 @@ 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(De, { onClick: () => V(e), children: e.recordedOn });
195
+ return /* @__PURE__ */ i(Me, { onClick: () => V(e), children: e.recordedOn });
196
196
  case "recordedBy":
197
197
  return e.recordedBy;
198
198
  case "actions":
@@ -223,7 +223,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
223
223
  loading: S,
224
224
  errorStateMessage: U ? 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
  }
@@ -244,9 +244,9 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
244
244
  rows: t,
245
245
  loading: !1,
246
246
  errorStateMessage: "",
247
- sortable: ye,
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,10 +261,10 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
261
261
  id: "modalIdForActionAreaLayout",
262
262
  portalId: "main-display-area",
263
263
  open: b,
264
- onRequestClose: x,
264
+ onRequestClose: j,
265
265
  modalHeading: /* @__PURE__ */ $("div", { className: T.modalHeading, children: [
266
266
  /* @__PURE__ */ i("span", { children: a.formName }),
267
- F && f(a) && /* @__PURE__ */ i(
267
+ v && f(a) && /* @__PURE__ */ i(
268
268
  K,
269
269
  {
270
270
  label: n("EDIT_OBSERVATION_FORM"),
@@ -272,7 +272,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_mo
272
272
  size: "sm",
273
273
  testId: `edit-form-modal-${a.encounterUuid}`,
274
274
  onClick: () => {
275
- x(), R(a);
275
+ j(), R(a);
276
276
  },
277
277
  children: /* @__PURE__ */ i(z, {})
278
278
  }
@@ -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: J,
294
+ hideThumbnail: X,
295
295
  controlOrder: le,
296
296
  sectionMap: ce,
297
297
  conceptDatatypeMap: me
@@ -1,13 +1,13 @@
1
- import { jsx as d, jsxs as S } from "react/jsx-runtime";
2
- import { i as M, z as D, j as V, k as Q, l as k, o as q, N as z, p as G, u as P, a as j, w as H, q as J, y as Y, s as W, v as X, A as Z, D as x, b as ee } from "./index-DgSe-s_z.js";
1
+ import { jsx as d, jsxs as D } from "react/jsx-runtime";
2
+ import { n as M, z as C, t as V, L as Q, o as q, y as k, N as z, p as G, u as P, a as H, E as j, q as J, w as Y, v as W, x as X, A as Z, D as x, b as ee } from "./index-C4Ies-5q.js";
3
3
  import { useQueries as te, useQuery as se } from "@tanstack/react-query";
4
4
  import { useRef as oe, useEffect as N, useMemo as h } from "react";
5
- import { useTranslation as U } from "react-i18next";
6
- const A = (t, i, c, l, u, r) => {
5
+ import { useTranslation as L } from "react-i18next";
6
+ const U = (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
9
  a === "Image" && (n = /* @__PURE__ */ d(
10
- q,
10
+ k,
11
11
  {
12
12
  imageSrc: o,
13
13
  alt: o,
@@ -26,7 +26,7 @@ const A = (t, i, c, l, u, r) => {
26
26
  provider: s.provider
27
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
- k,
29
+ q,
30
30
  {
31
31
  header: s.header,
32
32
  value: n,
@@ -38,13 +38,13 @@ const A = (t, i, c, l, u, r) => {
38
38
  `obs-${t.id}`
39
39
  );
40
40
  }, re = (t, i, c, l, u, r, s) => /* @__PURE__ */ d(
41
- D,
41
+ C,
42
42
  {
43
43
  title: t.display,
44
44
  id: `grouped-obs-${t.display}-${l}`,
45
45
  open: c,
46
46
  children: t.members?.map(
47
- (o, a) => A(
47
+ (o, a) => U(
48
48
  o,
49
49
  a,
50
50
  u,
@@ -60,17 +60,17 @@ const A = (t, i, c, l, u, r) => {
60
60
  title: i = "",
61
61
  hideThumbnail: c
62
62
  }) => {
63
- const { t: l } = U(), u = (r, s, o) => {
63
+ const { t: l } = L(), u = (r, s, o) => {
64
64
  const a = M(r.encounterDetails, l);
65
- return /* @__PURE__ */ S(
66
- D,
65
+ return /* @__PURE__ */ D(
66
+ C,
67
67
  {
68
68
  title: a,
69
69
  id: `encounter-${r.encounterId}`,
70
70
  open: s,
71
71
  children: [
72
72
  r.observations.map(
73
- (n, b) => A(
73
+ (n, b) => U(
74
74
  n,
75
75
  b,
76
76
  o,
@@ -106,7 +106,7 @@ const A = (t, i, c, l, u, r) => {
106
106
  )
107
107
  }
108
108
  );
109
- }, ne = "Observations-module_observations__RKSyo", ie = "Observations-module_title__TJL3z", C = {
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 }) => {
@@ -114,10 +114,10 @@ const A = (t, i, c, l, u, r) => {
114
114
  conceptNames: c = [],
115
115
  conceptUuid: l = [],
116
116
  hideThumbnail: u = !1
117
- } = i, r = oe(/* @__PURE__ */ new Set()), s = P(), { addNotification: o } = j(), { t: a } = U(), n = te({
117
+ } = i, r = oe(/* @__PURE__ */ new Set()), s = P(), { addNotification: o } = H(), { t: a } = L(), n = te({
118
118
  queries: c.map((e) => ({
119
119
  queryKey: ce(e),
120
- queryFn: () => H(e),
120
+ queryFn: () => j(e),
121
121
  enabled: !!e
122
122
  }))
123
123
  });
@@ -161,18 +161,18 @@ const A = (t, i, c, l, u, r) => {
161
161
  if (!p) return [];
162
162
  const e = W(p), v = X(e);
163
163
  return Z(v);
164
- }, [p]), B = [
164
+ }, [p]), A = [
165
165
  { key: "name", header: "name" },
166
166
  { key: "value", header: "value" },
167
167
  { key: "form", header: "form" }
168
- ], I = f || !y, $ = g && y, L = (!p || p.entry?.length === 0 || m.length === 0) && y, F = $ ? a("ERROR_FETCHING_OBSERVATIONS") : null, w = L ? a("NO_OBSERVATIONS_FOUND") : void 0, K = _.length > 0 && !I && !$, O = i.titleTranslationKey, E = O ? a(O) : "";
169
- return /* @__PURE__ */ S(
168
+ ], I = f || !y, $ = g && y, B = (!p || p.entry?.length === 0 || m.length === 0) && y, F = $ ? a("ERROR_FETCHING_OBSERVATIONS") : null, w = B ? a("NO_OBSERVATIONS_FOUND") : void 0, K = _.length > 0 && !I && !$, O = i.titleTranslationKey, E = O ? a(O) : "";
169
+ return /* @__PURE__ */ D(
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: C.observations,
175
+ className: S.observations,
176
176
  children: [
177
177
  /* @__PURE__ */ d(
178
178
  x,
@@ -180,7 +180,7 @@ const A = (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: C.title,
183
+ className: S.title,
184
184
  children: /* @__PURE__ */ d("p", { children: E })
185
185
  }
186
186
  ),
@@ -194,7 +194,7 @@ const A = (t, i, c, l, u, r) => {
194
194
  ) : /* @__PURE__ */ d(
195
195
  ee,
196
196
  {
197
- headers: B,
197
+ headers: A,
198
198
  rows: [],
199
199
  ariaLabel: a("OBSERVATIONS"),
200
200
  loading: I,