@bahmni/widgets 0.0.1-dev.241 → 0.0.1-dev.242

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 s, jsxs as _, Fragment as Q } from "react/jsx-runtime";
2
- import { u as W, a as X, l as J, o as Z, k as x, b as ee, y as te } from "./index-BOsdedao.js";
2
+ import { u as W, a as X, l as J, f as Z, k as x, m as ee, y as te } from "./index-CA2IZdZE.js";
3
3
  import { useQuery as ne } from "@tanstack/react-query";
4
- import { useState as l, useCallback as p, useEffect as N, useMemo as f } from "react";
4
+ import { useState as l, useCallback as f, useEffect as N, useMemo as p } from "react";
5
5
  import { useTranslation as ae } from "react-i18next";
6
6
  const oe = "_documentsTableBody_1voj8_1", re = "_viewAttachmentsLink_1voj8_11", se = "_documentViewerContainer_1voj8_15", ce = "_attachmentItem_1voj8_23", de = "_attachmentCounter_1voj8_27", ie = "_attachmentError_1voj8_36", le = "_documentIframe_1voj8_44", me = "_documentImage_1voj8_50", c = {
7
7
  documentsTableBody: oe,
@@ -34,16 +34,16 @@ const _e = [
34
34
  "uploadedOn",
35
35
  "uploadedBy",
36
36
  "action"
37
- ], pe = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, R = (n) => n.attachments.length > 0 ? n.attachments : n.documentUrl ? [{ url: n.documentUrl, contentType: n.contentType }] : [], Ne = ({ config: n, encounterUuids: E }) => {
37
+ ], fe = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, R = (n) => n.attachments.length > 0 ? n.attachments : n.documentUrl ? [{ url: n.documentUrl, contentType: n.contentType }] : [], Ne = ({ config: n, encounterUuids: E }) => {
38
38
  const [d, M] = l(!1), [r, U] = l(
39
39
  null
40
40
  ), [k, A] = l(
41
41
  /* @__PURE__ */ new Set()
42
- ), T = W(), { t: o } = ae(), { addNotification: w } = X(), P = Number(n?.pageSize) || 5, [D, O] = l(1), [m, F] = l(P), [$, C] = l(void 0), b = p((e) => {
42
+ ), T = W(), { t: o } = ae(), { addNotification: w } = X(), P = Number(n?.pageSize) || 5, [D, O] = l(1), [m, F] = l(P), [$, C] = l(void 0), b = f((e) => {
43
43
  U(e), M(!0);
44
- }, []), V = p(() => {
44
+ }, []), V = f(() => {
45
45
  M(!1), U(null), A(/* @__PURE__ */ new Set());
46
- }, []), B = p((e) => {
46
+ }, []), B = f((e) => {
47
47
  A((t) => new Set(t).add(e));
48
48
  }, []), { data: u, isLoading: z, isError: y, error: S } = ne({
49
49
  queryKey: [
@@ -90,24 +90,24 @@ const _e = [
90
90
  e.signal.aborted || A(a);
91
91
  })(), () => e.abort();
92
92
  }, [d, r]);
93
- const H = p(
93
+ const H = f(
94
94
  (e, t) => {
95
95
  t !== m ? (F(t), O(1), C(void 0)) : O(e);
96
96
  },
97
97
  [m]
98
- ), g = f(
98
+ ), g = p(
99
99
  () => n?.fields ?? _e,
100
100
  [n?.fields]
101
- ), q = f(() => [...u?.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), [u]), G = f(() => he(g, o), [g, o]), Y = f(
101
+ ), q = p(() => [...u?.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), [u]), G = p(() => he(g, o), [g, o]), Y = p(
102
102
  () => g.map((e) => ({
103
103
  key: e,
104
104
  sortable: e !== "action"
105
105
  })),
106
106
  [g]
107
- ), h = f(
107
+ ), h = p(
108
108
  () => r ? R(r) : [],
109
109
  [r]
110
- ), K = p(
110
+ ), K = f(
111
111
  (e, t) => {
112
112
  switch (t) {
113
113
  case "documentIdentifier":
@@ -170,7 +170,7 @@ const _e = [
170
170
  size: "lg",
171
171
  testId: "document-view-modal",
172
172
  children: /* @__PURE__ */ s("div", { className: c.documentViewerContainer, children: h.map((e, t) => {
173
- const a = j(e.url), I = e.contentType?.toLowerCase().includes("pdf"), i = (e.contentType?.toLowerCase().includes("image") ?? !1) || pe.test(e.url ?? ""), v = k.has(t);
173
+ const a = j(e.url), I = e.contentType?.toLowerCase().includes("pdf"), i = (e.contentType?.toLowerCase().includes("image") ?? !1) || fe.test(e.url ?? ""), v = k.has(t);
174
174
  return a === "#" || v ? /* @__PURE__ */ _(
175
175
  "div",
176
176
  {
@@ -1,20 +1,20 @@
1
1
  import { jsx as n, jsxs as X, Fragment as Z } from "react/jsx-runtime";
2
- import { r as ee, u as re, F as te, Y as oe, G as ae, K as se, q as ne, c as de, O as C, k as ie, o as ce, b as U, Q as me, e as le, y as ue, d as fe } from "./index-BOsdedao.js";
2
+ import { r as ee, u as re, F as te, Y as oe, G as ae, K as se, q as ne, c as de, O as C, k as ie, f as me, m as U, e as ce, t as le, y as ue, b as fe } from "./index-CA2IZdZE.js";
3
3
  import { useQueryClient as ye, useQuery as f } from "@tanstack/react-query";
4
4
  import { useState as k, useMemo as d, useCallback as y } from "react";
5
5
  import { useTranslation as pe } from "react-i18next";
6
6
  const be = "_formsTableBody_81hra_1", Fe = "_customAccordianItem_81hra_6", E = {
7
7
  formsTableBody: be,
8
8
  customAccordianItem: Fe
9
- }, ge = (c) => c ? c.extension?.find(
9
+ }, ge = (m) => m ? m.extension?.find(
10
10
  (p) => p.url === ee
11
11
  )?.valueString : void 0, Ie = ({
12
- episodeOfCareUuids: c,
12
+ episodeOfCareUuids: m,
13
13
  encounterUuids: i,
14
14
  config: p
15
15
  }) => {
16
- const { t: s } = pe(), m = re(), [l, D] = k(!1), [t, I] = k(null), { numberOfVisits: w, hideThumbnail: x = !1 } = p ?? {}, v = te(
17
- c,
16
+ const { t: s } = pe(), c = re(), [l, D] = k(!1), [t, I] = k(null), { numberOfVisits: w, hideThumbnail: x = !1 } = p ?? {}, v = te(
17
+ m,
18
18
  i
19
19
  ), K = ye(), {
20
20
  data: b = [],
@@ -23,9 +23,9 @@ const be = "_formsTableBody_81hra_1", Fe = "_customAccordianItem_81hra_6", E = {
23
23
  error: P,
24
24
  refetch: H
25
25
  } = f({
26
- queryKey: ["forms", m, c],
27
- queryFn: () => oe(m, void 0, w),
28
- enabled: !!m && !v
26
+ queryKey: ["forms", c, m],
27
+ queryFn: () => oe(c, void 0, w),
28
+ enabled: !!c && !v
29
29
  }), B = d(() => !i || i.length === 0 ? b : b.filter(
30
30
  (e) => i.includes(e.encounterUuid)
31
31
  ), [b, i]), { data: R = [] } = f({
@@ -38,8 +38,8 @@ const be = "_formsTableBody_81hra_1", Fe = "_customAccordianItem_81hra_6", E = {
38
38
  if (t)
39
39
  return T(t.formName);
40
40
  }, [t, T]), {
41
- isLoading: Q,
42
- isError: j,
41
+ isLoading: j,
42
+ isError: G,
43
43
  error: g
44
44
  } = f({
45
45
  queryKey: ["formMetadata", F],
@@ -47,8 +47,8 @@ const be = "_formsTableBody_81hra_1", Fe = "_customAccordianItem_81hra_6", E = {
47
47
  enabled: !!F && l
48
48
  }), {
49
49
  data: h,
50
- isLoading: G,
51
- isError: V,
50
+ isLoading: V,
51
+ isError: $,
52
52
  error: O
53
53
  } = f({
54
54
  queryKey: ["formsEncounterFHIR", t?.encounterUuid],
@@ -57,11 +57,11 @@ const be = "_formsTableBody_81hra_1", Fe = "_customAccordianItem_81hra_6", E = {
57
57
  });
58
58
  de(
59
59
  (e) => {
60
- e.patientUUID === m && e.updatedConcepts.size > 0 && (H(), K.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
60
+ e.patientUUID === c && e.updatedConcepts.size > 0 && (H(), K.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
61
61
  },
62
- [m]
62
+ [c]
63
63
  );
64
- const $ = d(() => !h?.entry || !t?.formName ? [] : h.entry.filter((a) => a.resource?.resourceType === "Observation").map((a) => a.resource).filter((a) => {
64
+ const Q = d(() => !h?.entry || !t?.formName ? [] : h.entry.filter((a) => a.resource?.resourceType === "Observation").map((a) => a.resource).filter((a) => {
65
65
  const r = ge(a);
66
66
  return !r || r.includes(t.formName);
67
67
  }), [h, t?.formName]), Y = d(() => {
@@ -114,7 +114,7 @@ const be = "_formsTableBody_81hra_1", Fe = "_customAccordianItem_81hra_6", E = {
114
114
  (e, a) => {
115
115
  switch (a) {
116
116
  case "recordedOn":
117
- return /* @__PURE__ */ n(ce, { onClick: () => q(e), children: e.recordedOn });
117
+ return /* @__PURE__ */ n(me, { onClick: () => q(e), children: e.recordedOn });
118
118
  case "recordedBy":
119
119
  return e.recordedBy;
120
120
  default:
@@ -137,7 +137,7 @@ const be = "_formsTableBody_81hra_1", Fe = "_customAccordianItem_81hra_6", E = {
137
137
  className: E.formsTableBody,
138
138
  dataTestId: "forms-table"
139
139
  }
140
- ) : /* @__PURE__ */ n(me, { align: "start", children: _.map((e, a) => {
140
+ ) : /* @__PURE__ */ n(ce, { align: "start", children: _.map((e, a) => {
141
141
  const { formName: r, records: o } = e;
142
142
  return /* @__PURE__ */ n(
143
143
  le,
@@ -180,9 +180,9 @@ const be = "_formsTableBody_81hra_1", Fe = "_customAccordianItem_81hra_6", E = {
180
180
  children: /* @__PURE__ */ n(
181
181
  fe,
182
182
  {
183
- observations: $,
184
- isLoading: Q || G,
185
- isError: j || V,
183
+ observations: Q,
184
+ isLoading: j || V,
185
+ isError: G || $,
186
186
  errorMessage: Y,
187
187
  emptyStateMessage: s("NO_FORM_DATA_AVAILABLE"),
188
188
  testIdPrefix: t.formName,
@@ -1,7 +1,7 @@
1
- import { jsx as l, jsxs as C } from "react/jsx-runtime";
2
- import { f as k, E as D, t as q, j as w, g as K, V as Q, L as G, H, u as j, a as P, h as z, x as Y, c as x, i as J, m as W, s as X, N as Z, b as ee } from "./index-BOsdedao.js";
1
+ import { jsx as l, jsxs as S } from "react/jsx-runtime";
2
+ import { d as k, C as D, g as q, j as w, i as K, x as Q, h as G, z as j, u as P, a as z, n as H, o as x, c as Y, p as J, s as W, v as X, $ as Z, m as ee } from "./index-CA2IZdZE.js";
3
3
  import { useQueries as te, useQuery as se } from "@tanstack/react-query";
4
- import { useRef as oe, useEffect as N, useMemo as g } from "react";
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, d, u, r) => {
7
7
  const s = q(t, i, u), o = s.value, a = w(o);
@@ -21,7 +21,7 @@ const B = (t, i, c, d, u, r) => {
21
21
  videoSrc: o,
22
22
  hideThumbnail: r
23
23
  }
24
- )), a === "PDF" && (n = /* @__PURE__ */ l(H, { id: `${o}-pdf`, src: o }));
24
+ )), a === "PDF" && (n = /* @__PURE__ */ l(j, { id: `${o}-pdf`, src: o }));
25
25
  const b = u("OBSERVATIONS_RECORDED_BY", {
26
26
  provider: s.provider
27
27
  }), p = t.display, m = t.observationValue?.isAbnormal ? "abnormal-obs" : "obs", y = d ? `${d}-${m}-${p}-${c}-${i}` : `${m}-${p}-${c}-${i}`;
@@ -62,7 +62,7 @@ const B = (t, i, c, d, u, r) => {
62
62
  }) => {
63
63
  const { t: d } = U(), u = (r, s, o) => {
64
64
  const a = k(r.encounterDetails, d);
65
- return /* @__PURE__ */ C(
65
+ return /* @__PURE__ */ S(
66
66
  D,
67
67
  {
68
68
  title: a,
@@ -106,7 +106,7 @@ const B = (t, i, c, d, u, r) => {
106
106
  )
107
107
  }
108
108
  );
109
- }, ne = "_observations_kfbhq_1", ie = "_title_kfbhq_12", S = {
109
+ }, ne = "_observations_kfbhq_1", ie = "_title_kfbhq_12", N = {
110
110
  observations: ne,
111
111
  title: ie
112
112
  }, ce = (t) => ["conceptUuid", t], de = (t, i) => ["observations", t, ...i], ve = ({ config: t }) => {
@@ -114,14 +114,14 @@ const B = (t, i, c, d, u, r) => {
114
114
  conceptNames: c = [],
115
115
  conceptUuid: d = [],
116
116
  hideThumbnail: u = !1
117
- } = i, r = oe(/* @__PURE__ */ new Set()), s = j(), { addNotification: o } = P(), { t: a } = U(), n = te({
117
+ } = i, r = oe(/* @__PURE__ */ new Set()), s = P(), { addNotification: o } = z(), { 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
- N(() => {
124
+ C(() => {
125
125
  n.forEach((e, v) => {
126
126
  if (e.isError && !r.current.has(v)) {
127
127
  const R = c[v];
@@ -140,39 +140,39 @@ const B = (t, i, c, d, u, r) => {
140
140
  refetch: T
141
141
  } = se({
142
142
  queryKey: de(s, p),
143
- queryFn: () => Y(s, p),
143
+ queryFn: () => x(s, p),
144
144
  enabled: !!s && p.length > 0 && f
145
145
  });
146
- x(
146
+ Y(
147
147
  (e) => {
148
148
  e.patientUUID === s && e.updatedConcepts.size > 0 && [...e.updatedConcepts.keys()].some(
149
149
  (R) => p.includes(R)
150
150
  ) && T();
151
151
  },
152
152
  [s, T]
153
- ), N(() => {
153
+ ), C(() => {
154
154
  O && o({
155
155
  title: a("ERROR_DEFAULT_TITLE"),
156
156
  message: a("ERROR_FETCHING_OBSERVATIONS"),
157
157
  type: "error"
158
158
  });
159
159
  }, [O]);
160
- const I = g(() => {
160
+ const $ = g(() => {
161
161
  if (!m) return [];
162
162
  const e = J(m), v = W(e);
163
163
  return X(v);
164
- }, [m]), L = [
164
+ }, [m]), A = [
165
165
  { key: "name", header: "name" },
166
166
  { key: "value", header: "value" },
167
167
  { key: "form", header: "form" }
168
- ], _ = y || !f, $ = O && f, A = (!m || m.entry?.length === 0 || p.length === 0) && f, F = $ ? a("ERROR_FETCHING_OBSERVATIONS") : null, V = A ? a("NO_OBSERVATIONS_FOUND") : void 0, M = I.length > 0 && !_ && !$, h = i.titleTranslationKey, E = h ? a(h) : "";
169
- return /* @__PURE__ */ C(
168
+ ], I = y || !f, _ = O && 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, V = $.length > 0 && !I && !_, h = i.titleTranslationKey, E = h ? a(h) : "";
169
+ return /* @__PURE__ */ S(
170
170
  "div",
171
171
  {
172
172
  id: "observations",
173
173
  "data-testid": h ? `observations-${E}` : "observations",
174
174
  "aria-label": "observations-aria-label",
175
- className: S.observations,
175
+ className: N.observations,
176
176
  children: [
177
177
  /* @__PURE__ */ l(
178
178
  Z,
@@ -180,26 +180,26 @@ const B = (t, i, c, d, u, r) => {
180
180
  id: "observations-title",
181
181
  testId: h ? `observations-title-${E}` : "observations-title",
182
182
  title: E,
183
- className: S.title,
183
+ className: N.title,
184
184
  children: /* @__PURE__ */ l("p", { children: E })
185
185
  }
186
186
  ),
187
- M ? /* @__PURE__ */ l(
187
+ V ? /* @__PURE__ */ l(
188
188
  ae,
189
189
  {
190
- groupedData: I,
190
+ groupedData: $,
191
191
  title: E,
192
192
  hideThumbnail: u
193
193
  }
194
194
  ) : /* @__PURE__ */ l(
195
195
  ee,
196
196
  {
197
- headers: L,
197
+ headers: A,
198
198
  rows: [],
199
199
  ariaLabel: a("OBSERVATIONS"),
200
- loading: _,
201
- errorStateMessage: F,
202
- emptyStateMessage: V,
200
+ loading: I,
201
+ errorStateMessage: L,
202
+ emptyStateMessage: M,
203
203
  dataTestId: "observations-table"
204
204
  }
205
205
  )