@bahmni/widgets 0.0.1-dev.370 → 0.0.1-dev.373

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,7 +1,7 @@
1
1
  import { jsx as r, jsxs as T, Fragment as Y } from "react/jsx-runtime";
2
- import { u as W, a as X, m as J, B as Z, I as x, q as ee, F as te } from "./index-Cv9sFAZU.js";
2
+ import { u as W, a as X, b as J, P as Z, x, q as ee, F as te } from "./index-DQzzZ7W6.js";
3
3
  import { useQuery as ne } from "@tanstack/react-query";
4
- import { useState as l, useCallback as _, useEffect as g, useMemo as p } from "react";
4
+ import { useState as l, useCallback as _, useEffect as I, useMemo as p } from "react";
5
5
  import { useTranslation as ae } from "react-i18next";
6
6
  const oe = "DocumentsTable-module_documentsTableBody__6iR3w", se = "DocumentsTable-module_viewAttachmentsLink__aQ1on", re = "DocumentsTable-module_documentViewerContainer__F5m8D", ce = "DocumentsTable-module_attachmentItem__17KA7", de = "DocumentsTable-module_attachmentCounter__WFiI3", me = "DocumentsTable-module_attachmentError__RI4U2", le = "DocumentsTable-module_documentIframe__ptq5I", ue = "DocumentsTable-module_documentImage__KQVgS", c = {
7
7
  documentsTableBody: oe,
@@ -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) {
@@ -34,7 +34,7 @@ const Te = [
34
34
  "attachments",
35
35
  "uploadedOn",
36
36
  "uploadedBy"
37
- ], _e = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, R = (n) => n.attachments.length > 0 ? n.attachments : n.documentUrl ? [{ url: n.documentUrl, contentType: n.contentType }] : [], ge = ({ config: n, encounterUuids: f }) => {
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
40
  ), [P, A] = l(
@@ -43,9 +43,9 @@ const Te = [
43
43
  U(e), L(!0);
44
44
  }, []), H = _(() => {
45
45
  L(!1), U(null), A(/* @__PURE__ */ new Set());
46
- }, []), B = _((e) => {
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: q, isError: S, error: b } = ne({
49
49
  queryKey: [
50
50
  "documents",
51
51
  E,
@@ -61,25 +61,25 @@ const Te = [
61
61
  N
62
62
  )
63
63
  });
64
- g(() => {
64
+ I(() => {
65
65
  i && O(i.total);
66
- }, [i]), g(() => {
66
+ }, [i]), I(() => {
67
67
  C(1), O(void 0);
68
- }, [E]), g(() => {
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]), g(() => {
74
+ }, [S, b, w, o]), I(() => {
75
75
  const e = new AbortController();
76
76
  return (async () => {
77
77
  if (!d || !s) return;
78
- const a = /* @__PURE__ */ new Set(), I = R(s);
79
- for (let m = 0; m < I.length; m++) {
80
- const b = F(I[m].url);
78
+ const a = /* @__PURE__ */ new Set(), g = B(s);
79
+ for (let m = 0; m < g.length; m++) {
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);
@@ -105,7 +105,7 @@ const Te = [
105
105
  })),
106
106
  [D]
107
107
  ), h = p(
108
- () => s ? R(s) : [],
108
+ () => s ? B(s) : [],
109
109
  [s]
110
110
  ), Q = _(
111
111
  (e, t) => {
@@ -146,7 +146,7 @@ const Te = [
146
146
  ariaLabel: o("DOCUMENTS_TABLE_HEADING"),
147
147
  rows: j,
148
148
  loading: q,
149
- errorStateMessage: S ? y?.message : null,
149
+ errorStateMessage: S ? b?.message : null,
150
150
  sortable: G,
151
151
  emptyStateMessage: o("DOCUMENTS_NO_RECORDS"),
152
152
  renderCell: Q,
@@ -170,8 +170,8 @@ 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), I = 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 = P.has(t);
174
+ return a === "#" || y ? /* @__PURE__ */ T(
175
175
  "div",
176
176
  {
177
177
  className: c.attachmentError,
@@ -203,15 +203,15 @@ const Te = [
203
203
  src: a,
204
204
  alt: s.documentIdentifier,
205
205
  className: c.documentImage,
206
- onError: () => B(t)
206
+ onError: () => F(t)
207
207
  }
208
208
  ) : /* @__PURE__ */ r(
209
209
  "iframe",
210
210
  {
211
- src: I ? `${a}#toolbar=0` : a,
211
+ src: g ? `${a}#toolbar=0` : a,
212
212
  className: c.documentIframe,
213
213
  title: s.documentIdentifier,
214
- onError: () => B(t)
214
+ onError: () => F(t)
215
215
  }
216
216
  )
217
217
  ]
@@ -224,5 +224,5 @@ const Te = [
224
224
  ] });
225
225
  };
226
226
  export {
227
- ge as default
227
+ Ie as default
228
228
  };
@@ -1,46 +1,46 @@
1
- import { jsx as i, jsxs as G, Fragment as be } from "react/jsx-runtime";
2
- import { u as ye, b as pe, c as Oe, J as Ne, G as Te, d as Ee, z as Fe, P as Ie, i as ve, e as _e, f as Ae, Y as x, I as Re, l as j, $ as K, B as Me, q as Q, T as Be, R as De, F as Ce, O as Le, C as Se } from "./index-Cv9sFAZU.js";
1
+ import { jsx as i, jsxs as z, Fragment as ye } from "react/jsx-runtime";
2
+ import { u as be, c as pe, d as Oe, t as Ne, X as Te, W as Ee, J as Fe, C as Ie, f as ve, e as _e, g as Ae, Y as j, x as Re, i as G, $ as K, P as Me, q as Q, T as De, R as Ce, F as Le, O as Se, h as Be } from "./index-DQzzZ7W6.js";
3
3
  import { useQueryClient as Ue, useQuery as T } from "@tanstack/react-query";
4
- import { useState as Y, useMemo as d, useCallback as l } from "react";
4
+ import { useState as W, useMemo as d, useCallback as l } from "react";
5
5
  import { useTranslation as we } from "react-i18next";
6
6
  const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_modalHeading__wnTmA", qe = "FormsTable-module_customAccordianItem__isszs", E = {
7
7
  formsTableBody: He,
8
8
  modalHeading: ke,
9
9
  customAccordianItem: qe
10
- }, Pe = "startConsultation", je = ({
10
+ }, Pe = "startConsultation", Ge = ({
11
11
  episodeOfCareUuids: M,
12
12
  encounterUuids: m,
13
- config: J,
14
- disableActions: W = !1,
15
- activeEncounterUuid: b = null
13
+ config: Y,
14
+ disableActions: J = !1,
15
+ activeEncounterUuid: y = null
16
16
  }) => {
17
- const { t: n } = we(), u = ye(), [y, B] = Y(!1), [a, D] = Y(null), {
17
+ const { t: n } = we(), u = be(), [b, D] = W(!1), [a, C] = W(null), {
18
18
  numberOfVisits: X,
19
19
  hideThumbnail: Z = !1,
20
20
  forms: p
21
- } = J ?? {}, ee = pe(
22
- Se.EDIT_OBSERVATIONS
23
- ), { userPrivileges: O } = Oe(), F = ee && !W && !!b, C = Ne(
21
+ } = Y ?? {}, ee = pe(
22
+ Be.EDIT_OBSERVATIONS
23
+ ), { userPrivileges: O } = Oe(), F = ee && !J && !!y, L = Ne(
24
24
  M,
25
25
  m
26
26
  ), re = Ue(), {
27
- data: L = [],
28
- isLoading: S,
27
+ data: S = [],
28
+ isLoading: B,
29
29
  isError: U,
30
30
  error: te,
31
31
  refetch: oe
32
32
  } = T({
33
33
  queryKey: ["forms", u, M],
34
34
  queryFn: () => Te(u, void 0, X),
35
- enabled: !!u && !C
35
+ enabled: !!u && !L
36
36
  }), w = d(() => {
37
- let e = L;
37
+ let e = S;
38
38
  return m && m.length > 0 && (e = e.filter(
39
39
  (r) => m.includes(r.encounterUuid)
40
40
  )), Array.isArray(p) && p.length > 0 && (e = e.filter(
41
41
  (r) => p.some((o) => o.toLowerCase() === r.formName.toLowerCase())
42
42
  )), e;
43
- }, [L, m, p]), { data: N = [] } = T({
43
+ }, [S, m, p]), { data: N = [] } = T({
44
44
  queryKey: ["observationForms"],
45
45
  queryFn: () => Ee()
46
46
  }), H = l(
@@ -55,8 +55,8 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
55
55
  },
56
56
  [N, O]
57
57
  ), f = l(
58
- (e) => !b || e.encounterUuid !== b ? !1 : H(e.formName),
59
- [b, H]
58
+ (e) => !y || e.encounterUuid !== y ? !1 : H(e.formName),
59
+ [y, H]
60
60
  ), k = l(
61
61
  (e) => N.find((o) => o.name === e)?.uuid,
62
62
  [N]
@@ -71,7 +71,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
71
71
  } = T({
72
72
  queryKey: ["formMetadata", I],
73
73
  queryFn: () => Fe(I),
74
- enabled: !!I && y
74
+ enabled: !!I && b
75
75
  }), {
76
76
  data: _,
77
77
  isLoading: ne,
@@ -80,7 +80,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
80
80
  } = T({
81
81
  queryKey: ["formsEncounterFHIR", a?.encounterUuid],
82
82
  queryFn: () => Ie(a.encounterUuid),
83
- enabled: !!a?.encounterUuid && y
83
+ enabled: !!a?.encounterUuid && b
84
84
  });
85
85
  ve(
86
86
  (e) => {
@@ -115,9 +115,9 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
115
115
  ), Object.keys(e).length > 0 ? e : void 0;
116
116
  }, [c]), me = d(() => {
117
117
  if (v)
118
- return x(v).message;
118
+ return j(v).message;
119
119
  if (A)
120
- return x(A).message;
120
+ return j(A).message;
121
121
  }, [v, A]), h = d(
122
122
  () => [
123
123
  { key: "recordedOn", header: n("RECORDED_ON") },
@@ -162,9 +162,9 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
162
162
  })
163
163
  ).sort((o, t) => o.formName.localeCompare(t.formName));
164
164
  }, [w, n]), V = l((e) => {
165
- D(e), B(!0);
166
- }, []), z = l(() => {
167
- B(!1), D(null);
165
+ C(e), D(!0);
166
+ }, []), x = l(() => {
167
+ D(!1), C(null);
168
168
  }, []), R = l((e) => {
169
169
  globalThis.dispatchEvent(
170
170
  new CustomEvent(Pe, {
@@ -186,7 +186,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
186
186
  return e.recordedBy;
187
187
  case "actions":
188
188
  return f(e) ? /* @__PURE__ */ i(
189
- j,
189
+ G,
190
190
  {
191
191
  label: n("EDIT_OBSERVATION_FORM"),
192
192
  kind: "ghost",
@@ -202,24 +202,24 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
202
202
  },
203
203
  [V, R, f, n]
204
204
  );
205
- return /* @__PURE__ */ G(be, { children: [
206
- /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: S || U || P.length === 0 || C ? /* @__PURE__ */ i(
205
+ return /* @__PURE__ */ z(ye, { children: [
206
+ /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: B || U || P.length === 0 || L ? /* @__PURE__ */ i(
207
207
  Q,
208
208
  {
209
209
  headers: fe,
210
210
  ariaLabel: n("FORMS_HEADING"),
211
211
  rows: [],
212
- loading: S,
212
+ loading: B,
213
213
  errorStateMessage: U ? te?.message : void 0,
214
214
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
215
215
  renderCell: $,
216
216
  className: E.formsTableBody,
217
217
  dataTestId: "forms-table"
218
218
  }
219
- ) : /* @__PURE__ */ i(Be, { align: "start", children: P.map((e, r) => {
219
+ ) : /* @__PURE__ */ i(De, { align: "start", children: P.map((e, r) => {
220
220
  const { formName: o, records: t } = e, s = ue(t);
221
221
  return /* @__PURE__ */ i(
222
- De,
222
+ Ce,
223
223
  {
224
224
  title: o,
225
225
  className: E.customAccordianItem,
@@ -244,24 +244,24 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
244
244
  o
245
245
  );
246
246
  }) }) }),
247
- y && a && /* @__PURE__ */ i(
248
- Ce,
247
+ b && a && /* @__PURE__ */ i(
248
+ Le,
249
249
  {
250
250
  id: "modalIdForActionAreaLayout",
251
251
  portalId: "main-display-area",
252
- open: y,
253
- onRequestClose: z,
254
- modalHeading: /* @__PURE__ */ G("div", { className: E.modalHeading, children: [
252
+ open: b,
253
+ onRequestClose: x,
254
+ modalHeading: /* @__PURE__ */ z("div", { className: E.modalHeading, children: [
255
255
  /* @__PURE__ */ i("span", { children: a.formName }),
256
256
  F && f(a) && /* @__PURE__ */ i(
257
- j,
257
+ G,
258
258
  {
259
259
  label: n("EDIT_OBSERVATION_FORM"),
260
260
  kind: "ghost",
261
261
  size: "sm",
262
262
  testId: `edit-form-modal-${a.encounterUuid}`,
263
263
  onClick: () => {
264
- z(), R(a);
264
+ x(), R(a);
265
265
  },
266
266
  children: /* @__PURE__ */ i(K, {})
267
267
  }
@@ -272,7 +272,7 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
272
272
  size: "md",
273
273
  testId: "form-details-modal",
274
274
  children: /* @__PURE__ */ i(
275
- Le,
275
+ Se,
276
276
  {
277
277
  observations: de,
278
278
  isLoading: se || ne,
@@ -290,5 +290,5 @@ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
290
290
  ] });
291
291
  };
292
292
  export {
293
- je as default
293
+ Ge as default
294
294
  };
@@ -1,10 +1,10 @@
1
1
  import { jsx as d, jsxs as N } from "react/jsx-runtime";
2
- import { g as K, Q as D, t as V, h as q, W as w, j as k, n as H, k as P, u as G, a as j, o as z, p as W, i as J, r as Y, s as X, v as Z, w as x, q as ee } from "./index-Cv9sFAZU.js";
2
+ import { j as V, k as D, l as q, I as w, m as Q, n as k, r as G, o as H, u as P, a as j, E as z, p as J, f as W, s as Y, v as X, w as Z, y as x, q as ee } from "./index-DQzzZ7W6.js";
3
3
  import { useQueries as te, useQuery as se } from "@tanstack/react-query";
4
4
  import { useRef as oe, useEffect as C, useMemo as g } 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 = q(t, i, u), o = s.value, a = w(o);
8
8
  let n = o;
9
9
  a === "Image" && (n = /* @__PURE__ */ d(
10
10
  k,
@@ -15,18 +15,18 @@ const B = (t, i, c, l, u, r) => {
15
15
  hideThumbnail: r
16
16
  }
17
17
  )), a === "Video" && (n = /* @__PURE__ */ d(
18
- H,
18
+ G,
19
19
  {
20
20
  id: `${o}-video`,
21
21
  videoSrc: o,
22
22
  hideThumbnail: r
23
23
  }
24
- )), a === "PDF" && (n = /* @__PURE__ */ d(P, { id: `${o}-pdf`, src: o }));
24
+ )), a === "PDF" && (n = /* @__PURE__ */ d(H, { id: `${o}-pdf`, src: o }));
25
25
  const b = u("OBSERVATIONS_RECORDED_BY", {
26
26
  provider: s.provider
27
- }), p = t.display, m = t.observationValue?.isAbnormal ? "abnormal-obs" : "obs", y = l ? `${l}-${m}-${p}-${c}-${i}` : `${m}-${p}-${c}-${i}`;
27
+ }), m = t.display, p = t.observationValue?.isAbnormal ? "abnormal-obs" : "obs", y = l ? `${l}-${p}-${m}-${c}-${i}` : `${p}-${m}-${c}-${i}`;
28
28
  return /* @__PURE__ */ d(
29
- w,
29
+ Q,
30
30
  {
31
31
  header: s.header,
32
32
  value: n,
@@ -61,7 +61,7 @@ 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);
64
+ const a = V(r.encounterDetails, l);
65
65
  return /* @__PURE__ */ N(
66
66
  D,
67
67
  {
@@ -114,7 +114,7 @@ const B = (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 = G(), { addNotification: o } = j(), { t: a } = U(), n = te({
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
120
  queryFn: () => z(e),
@@ -133,20 +133,20 @@ const B = (t, i, c, l, u, r) => {
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]), p = g(() => [.../* @__PURE__ */ new Set([...b, ...l])], [b, l]), f = g(() => c.length === 0 ? !0 : n.every((e) => !e.isLoading), [n, c.length]), {
137
- data: m,
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
+ data: p,
138
138
  isLoading: y,
139
139
  isError: h,
140
140
  refetch: T
141
141
  } = se({
142
- queryKey: le(s, p),
143
- queryFn: () => W(s, p),
144
- enabled: !!s && p.length > 0 && f
142
+ queryKey: le(s, m),
143
+ queryFn: () => J(s, m),
144
+ enabled: !!s && m.length > 0 && f
145
145
  });
146
- J(
146
+ W(
147
147
  (e) => {
148
148
  e.patientUUID === s && e.updatedConcepts.size > 0 && [...e.updatedConcepts.keys()].some(
149
- (R) => p.includes(R)
149
+ (R) => m.includes(R)
150
150
  ) && T();
151
151
  },
152
152
  [s, T]
@@ -157,15 +157,15 @@ const B = (t, i, c, l, u, r) => {
157
157
  type: "error"
158
158
  });
159
159
  }, [h]);
160
- const _ = g(() => {
161
- if (!m) return [];
162
- const e = Y(m), v = X(e);
160
+ const I = g(() => {
161
+ if (!p) return [];
162
+ const e = Y(p), v = X(e);
163
163
  return Z(v);
164
- }, [m]), A = [
164
+ }, [p]), A = [
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 = (!m || m.entry?.length === 0 || p.length === 0) && f, L = $ ? a("ERROR_FETCHING_OBSERVATIONS") : null, M = F ? a("NO_OBSERVATIONS_FOUND") : void 0, Q = _.length > 0 && !I && !$, O = i.titleTranslationKey, E = O ? a(O) : "";
168
+ ], _ = 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, K = I.length > 0 && !_ && !$, O = i.titleTranslationKey, E = O ? a(O) : "";
169
169
  return /* @__PURE__ */ N(
170
170
  "div",
171
171
  {
@@ -184,10 +184,10 @@ const B = (t, i, c, l, u, r) => {
184
184
  children: /* @__PURE__ */ d("p", { children: E })
185
185
  }
186
186
  ),
187
- Q ? /* @__PURE__ */ d(
187
+ K ? /* @__PURE__ */ d(
188
188
  ae,
189
189
  {
190
- groupedData: _,
190
+ groupedData: I,
191
191
  title: E,
192
192
  hideThumbnail: u
193
193
  }
@@ -197,7 +197,7 @@ const B = (t, i, c, l, u, r) => {
197
197
  headers: A,
198
198
  rows: [],
199
199
  ariaLabel: a("OBSERVATIONS"),
200
- loading: I,
200
+ loading: _,
201
201
  errorStateMessage: L,
202
202
  emptyStateMessage: M,
203
203
  dataTestId: "observations-table"