@bahmni/widgets 0.0.1-dev.349 → 0.0.1-dev.350

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, h as J, B as Z, A as x, q as ee, F as te } from "./index-BAz36sQ7.js";
2
+ import { u as W, a as X, g as J, B as Z, P as x, q as ee, F as te } from "./index-C1f36q-O.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";
@@ -75,9 +75,9 @@ const Te = [
75
75
  const e = new AbortController();
76
76
  return (async () => {
77
77
  if (!d || !s) return;
78
- const a = /* @__PURE__ */ new Set(), g = R(s);
79
- for (let m = 0; m < g.length; m++) {
80
- const b = F(g[m].url);
78
+ const a = /* @__PURE__ */ new Set(), D = R(s);
79
+ for (let m = 0; m < D.length; m++) {
80
+ const b = F(D[m].url);
81
81
  try {
82
82
  (await fetch(b, {
83
83
  method: "HEAD",
@@ -95,15 +95,15 @@ const Te = [
95
95
  t !== u ? ($(t), C(1), O(void 0)) : C(e);
96
96
  },
97
97
  [u]
98
- ), D = p(
98
+ ), g = p(
99
99
  () => n?.fields ?? Te,
100
100
  [n?.fields]
101
- ), j = 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(
102
- () => D.map((e) => ({
101
+ ), j = 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(g, o), [g, o]), G = p(
102
+ () => g.map((e) => ({
103
103
  key: e,
104
104
  sortable: e !== "attachments"
105
105
  })),
106
- [D]
106
+ [g]
107
107
  ), h = p(
108
108
  () => s ? R(s) : [],
109
109
  [s]
@@ -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 ?? ""), b = P.has(t);
173
+ const a = F(e.url), D = e.contentType?.toLowerCase().includes("pdf"), m = (e.contentType?.toLowerCase().includes("image") ?? !1) || _e.test(e.url ?? ""), b = P.has(t);
174
174
  return a === "#" || b ? /* @__PURE__ */ T(
175
175
  "div",
176
176
  {
@@ -208,7 +208,7 @@ const Te = [
208
208
  ) : /* @__PURE__ */ r(
209
209
  "iframe",
210
210
  {
211
- src: g ? `${a}#toolbar=0` : a,
211
+ src: D ? `${a}#toolbar=0` : a,
212
212
  className: c.documentIframe,
213
213
  title: s.documentIdentifier,
214
214
  onError: () => B(t)
@@ -1,65 +1,65 @@
1
- import { jsx as i, jsxs as x, Fragment as be } from "react/jsx-runtime";
2
- import { u as ye, b as Ne, c as pe, N as Oe, Y as Te, H as Ee, d as Fe, e as Ie, f as ve, g as Ae, i as _e, j as z, A as Re, l as G, $ as K, B as Be, q as Q, T as Me, R as De, F as Ce, O as Le, C as Se } from "./index-BAz36sQ7.js";
3
- import { useQueryClient as He, useQuery as T } from "@tanstack/react-query";
1
+ import { jsx as i, jsxs as K, Fragment as ye } from "react/jsx-runtime";
2
+ import { u as be, b as pe, c as Oe, D as Ne, K as Te, z as Ee, Y as Fe, v as Ie, d as ve, e as _e, f as Ae, h as x, P as Re, l as j, $ as G, B as De, q as Q, T as Me, R as Be, F as Ce, O as Le, C as Se } from "./index-C1f36q-O.js";
3
+ import { useQueryClient as Ue, useQuery as T } from "@tanstack/react-query";
4
4
  import { useState as Y, useMemo as d, useCallback as l } from "react";
5
- import { useTranslation as Ue } from "react-i18next";
6
- const we = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_modalHeading__wnTmA", qe = "FormsTable-module_customAccordianItem__isszs", E = {
7
- formsTableBody: we,
5
+ import { useTranslation as we } from "react-i18next";
6
+ const He = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_modalHeading__wnTmA", qe = "FormsTable-module_customAccordianItem__isszs", E = {
7
+ formsTableBody: He,
8
8
  modalHeading: ke,
9
9
  customAccordianItem: qe
10
- }, Pe = "startConsultation", Ge = ({
11
- episodeOfCareUuids: B,
10
+ }, Pe = "startConsultation", je = ({
11
+ episodeOfCareUuids: D,
12
12
  encounterUuids: m,
13
13
  config: W,
14
14
  disableActions: J = !1,
15
- activeEncounterUuid: b = null
15
+ activeEncounterUuid: y = null
16
16
  }) => {
17
- const { t: n } = Ue(), u = ye(), [y, M] = Y(!1), [a, D] = Y(null), {
17
+ const { t: n } = we(), u = be(), [b, M] = Y(!1), [a, B] = Y(null), {
18
18
  numberOfVisits: X,
19
19
  hideThumbnail: Z = !1,
20
- forms: N
21
- } = W ?? {}, ee = Ne(
20
+ forms: p
21
+ } = W ?? {}, ee = pe(
22
22
  Se.EDIT_OBSERVATIONS
23
- ), { userPrivileges: p } = pe(), F = ee && !J && !!b, C = Oe(
24
- B,
23
+ ), { userPrivileges: O } = Oe(), F = ee && !J && !!y, C = Ne(
24
+ D,
25
25
  m
26
- ), re = He(), {
26
+ ), re = Ue(), {
27
27
  data: L = [],
28
28
  isLoading: S,
29
- isError: H,
29
+ isError: U,
30
30
  error: te,
31
31
  refetch: oe
32
32
  } = T({
33
- queryKey: ["forms", u, B],
33
+ queryKey: ["forms", u, D],
34
34
  queryFn: () => Te(u, void 0, X),
35
35
  enabled: !!u && !C
36
- }), U = d(() => {
36
+ }), w = d(() => {
37
37
  let e = L;
38
38
  return m && m.length > 0 && (e = e.filter(
39
39
  (r) => m.includes(r.encounterUuid)
40
- )), Array.isArray(N) && N.length > 0 && (e = e.filter(
41
- (r) => N.some((o) => o.toLowerCase() === r.formName.toLowerCase())
40
+ )), Array.isArray(p) && p.length > 0 && (e = e.filter(
41
+ (r) => p.some((o) => o.toLowerCase() === r.formName.toLowerCase())
42
42
  )), e;
43
- }, [L, m, N]), { data: O = [] } = T({
43
+ }, [L, m, p]), { data: N = [] } = T({
44
44
  queryKey: ["observationForms"],
45
45
  queryFn: () => Ee()
46
- }), w = l(
46
+ }), H = l(
47
47
  (e) => {
48
- const r = O.find((t) => t.name === e);
48
+ const r = N.find((t) => t.name === e);
49
49
  if (!r?.privileges || r.privileges.length === 0) return !0;
50
- if (!p || p.length === 0) return !1;
51
- const o = new Set(p.map((t) => t.name));
50
+ if (!O || O.length === 0) return !1;
51
+ const o = new Set(O.map((t) => t.name));
52
52
  return r.privileges.some(
53
53
  (t) => o.has(t.privilegeName) && t.editable
54
54
  );
55
55
  },
56
- [O, p]
56
+ [N, O]
57
57
  ), f = l(
58
- (e) => !b || e.encounterUuid !== b ? !1 : w(e.formName),
59
- [b, w]
58
+ (e) => !y || e.encounterUuid !== y ? !1 : H(e.formName),
59
+ [y, H]
60
60
  ), k = l(
61
- (e) => O.find((o) => o.name === e)?.uuid,
62
- [O]
61
+ (e) => N.find((o) => o.name === e)?.uuid,
62
+ [N]
63
63
  ), I = d(() => {
64
64
  if (a)
65
65
  return k(a.formName);
@@ -71,16 +71,16 @@ const we = "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
- data: A,
76
+ data: _,
77
77
  isLoading: ne,
78
78
  isError: ie,
79
- error: _
79
+ error: A
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) => {
@@ -88,7 +88,7 @@ const we = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
88
88
  },
89
89
  [u]
90
90
  );
91
- const de = d(() => !A?.entry || !a?.formName ? [] : A.entry.filter((r) => r.resource?.resourceType === "Observation").map((r) => r.resource).filter((r) => Ae(r) ? _e(r)?.toLowerCase() === a.formName.toLowerCase() : !0), [A, a?.formName]), le = d(() => {
91
+ const de = d(() => !_?.entry || !a?.formName ? [] : _.entry.filter((r) => r.resource?.resourceType === "Observation").map((r) => r.resource).filter((r) => _e(r) ? Ae(r)?.toLowerCase() === a.formName.toLowerCase() : !0), [_, a?.formName]), le = d(() => {
92
92
  if (!c?.schema) return;
93
93
  const e = [], r = (o) => {
94
94
  (o ?? []).forEach((t) => {
@@ -104,8 +104,8 @@ const we = "FormsTable-module_formsTableBody__SvGha", ke = "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 h = s.label?.value ?? "Section";
108
- r(s.controls ?? [], h);
107
+ const g = s.label?.value ?? "Section";
108
+ r(s.controls ?? [], g);
109
109
  } else
110
110
  s.id != null && t && (e[String(s.id)] = t), s.controls && r(s.controls, t);
111
111
  };
@@ -115,38 +115,38 @@ const we = "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 z(v).message;
119
- if (_)
120
- return z(_).message;
121
- }, [v, _]), g = d(
118
+ return x(v).message;
119
+ if (A)
120
+ return x(A).message;
121
+ }, [v, A]), h = d(
122
122
  () => [
123
123
  { key: "recordedOn", header: n("RECORDED_ON") },
124
124
  { key: "recordedBy", header: n("RECORDED_BY") }
125
125
  ],
126
126
  [n]
127
127
  ), q = d(
128
- () => [...g, { key: "actions", header: n("ACTIONS") }],
129
- [g, n]
128
+ () => [...h, { key: "actions", header: n("ACTIONS") }],
129
+ [h, n]
130
130
  ), ue = l(
131
- (e) => F && e.some((o) => f(o)) ? q : g,
132
- [F, f, q, g]
133
- ), fe = g, ge = d(
131
+ (e) => F && e.some((o) => f(o)) ? q : h,
132
+ [F, f, q, h]
133
+ ), fe = h, he = d(
134
134
  () => [
135
135
  { key: "recordedOn", sortable: !0 },
136
136
  { key: "recordedBy", sortable: !0 }
137
137
  ],
138
138
  []
139
139
  ), P = d(() => {
140
- const e = U.reduce(
140
+ const e = w.reduce(
141
141
  (o, t) => {
142
142
  const s = t.formName;
143
143
  o[s] ??= [];
144
- const h = t.providers.map((he) => he.providerName).filter(Boolean).join(", ");
144
+ const g = t.providers.map((ge) => ge.providerName).filter(Boolean).join(", ");
145
145
  return o[s].push({
146
146
  id: t.encounterUuid,
147
147
  formName: t.formName,
148
148
  recordedOn: Re(t.encounterDateTime, n, !0).formattedResult,
149
- recordedBy: h ?? "--",
149
+ recordedBy: g ?? "--",
150
150
  encounterDateTime: t.encounterDateTime,
151
151
  encounterUuid: t.encounterUuid
152
152
  }), o;
@@ -157,14 +157,14 @@ const we = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
157
157
  ([o, t]) => ({
158
158
  formName: o,
159
159
  records: t.sort(
160
- (s, h) => h.encounterDateTime - s.encounterDateTime
160
+ (s, g) => g.encounterDateTime - s.encounterDateTime
161
161
  )
162
162
  })
163
163
  ).sort((o, t) => o.formName.localeCompare(t.formName));
164
- }, [U, n]), V = l((e) => {
165
- D(e), M(!0);
166
- }, []), $ = l(() => {
167
- M(!1), D(null);
164
+ }, [w, n]), V = l((e) => {
165
+ B(e), M(!0);
166
+ }, []), z = l(() => {
167
+ M(!1), B(null);
168
168
  }, []), R = l((e) => {
169
169
  globalThis.dispatchEvent(
170
170
  new CustomEvent(Pe, {
@@ -177,23 +177,23 @@ const we = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
177
177
  }
178
178
  })
179
179
  );
180
- }, []), j = l(
180
+ }, []), $ = l(
181
181
  (e, r) => {
182
182
  switch (r) {
183
183
  case "recordedOn":
184
- return /* @__PURE__ */ i(Be, { onClick: () => V(e), children: e.recordedOn });
184
+ return /* @__PURE__ */ i(De, { onClick: () => V(e), children: e.recordedOn });
185
185
  case "recordedBy":
186
186
  return e.recordedBy;
187
187
  case "actions":
188
188
  return f(e) ? /* @__PURE__ */ i(
189
- G,
189
+ j,
190
190
  {
191
191
  label: n("EDIT_OBSERVATION_FORM"),
192
192
  kind: "ghost",
193
193
  size: "sm",
194
194
  testId: `edit-form-${e.encounterUuid}`,
195
195
  onClick: () => R(e),
196
- children: /* @__PURE__ */ i(K, {})
196
+ children: /* @__PURE__ */ i(G, {})
197
197
  }
198
198
  ) : null;
199
199
  default:
@@ -202,24 +202,24 @@ const we = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
202
202
  },
203
203
  [V, R, f, n]
204
204
  );
205
- return /* @__PURE__ */ x(be, { children: [
206
- /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: S || H || P.length === 0 || C ? /* @__PURE__ */ i(
205
+ return /* @__PURE__ */ K(ye, { children: [
206
+ /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: S || U || P.length === 0 || C ? /* @__PURE__ */ i(
207
207
  Q,
208
208
  {
209
209
  headers: fe,
210
210
  ariaLabel: n("FORMS_HEADING"),
211
211
  rows: [],
212
212
  loading: S,
213
- errorStateMessage: H ? te?.message : void 0,
213
+ errorStateMessage: U ? te?.message : void 0,
214
214
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
215
- renderCell: j,
215
+ renderCell: $,
216
216
  className: E.formsTableBody,
217
217
  dataTestId: "forms-table"
218
218
  }
219
219
  ) : /* @__PURE__ */ i(Me, { 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
+ Be,
223
223
  {
224
224
  title: o,
225
225
  className: E.customAccordianItem,
@@ -233,9 +233,9 @@ const we = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
233
233
  rows: t,
234
234
  loading: !1,
235
235
  errorStateMessage: "",
236
- sortable: ge,
236
+ sortable: he,
237
237
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
238
- renderCell: j,
238
+ renderCell: $,
239
239
  className: E.formsTableBody,
240
240
  dataTestId: `forms-table-${o}`
241
241
  }
@@ -244,26 +244,26 @@ const we = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
244
244
  o
245
245
  );
246
246
  }) }) }),
247
- y && a && /* @__PURE__ */ i(
247
+ b && a && /* @__PURE__ */ i(
248
248
  Ce,
249
249
  {
250
250
  id: "modalIdForActionAreaLayout",
251
251
  portalId: "main-display-area",
252
- open: y,
253
- onRequestClose: $,
254
- modalHeading: /* @__PURE__ */ x("div", { className: E.modalHeading, children: [
252
+ open: b,
253
+ onRequestClose: z,
254
+ modalHeading: /* @__PURE__ */ K("div", { className: E.modalHeading, children: [
255
255
  /* @__PURE__ */ i("span", { children: a.formName }),
256
256
  F && f(a) && /* @__PURE__ */ i(
257
- G,
257
+ j,
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
- $(), R(a);
264
+ z(), R(a);
265
265
  },
266
- children: /* @__PURE__ */ i(K, {})
266
+ children: /* @__PURE__ */ i(G, {})
267
267
  }
268
268
  )
269
269
  ] }),
@@ -290,5 +290,5 @@ const we = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_mo
290
290
  ] });
291
291
  };
292
292
  export {
293
- Ge as default
293
+ je as default
294
294
  };
@@ -1,10 +1,10 @@
1
1
  import { jsx as d, jsxs as N } from "react/jsx-runtime";
2
- import { k as w, Q as D, t as K, m as V, W as q, n as k, o as H, p as G, u as P, a as j, r as z, w as W, f as J, s as Y, v as X, x as Z, y as x, q as ee } from "./index-BAz36sQ7.js";
2
+ import { i as K, Q as D, t as V, j as q, W as w, k, n as H, m as G, u as P, a as j, o as z, p as W, d as J, r as Y, s as X, w as Z, x, q as ee } from "./index-C1f36q-O.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 = K(t, i, u), o = s.value, a = V(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,
@@ -26,7 +26,7 @@ const B = (t, i, c, l, u, r) => {
26
26
  provider: s.provider
27
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
- q,
29
+ w,
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 = w(r.encounterDetails, l);
64
+ const a = K(r.encounterDetails, l);
65
65
  return /* @__PURE__ */ N(
66
66
  D,
67
67
  {