@bahmni/widgets 0.0.1-dev.228 → 0.0.1-dev.230

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
- import { jsx as s, jsxs as _, Fragment as K } from "react/jsx-runtime";
2
- import { u as Q, a as X, W as J, r as Z, b as x, c as ee, y as te } from "./index-CvrYKnfA.js";
1
+ import { jsx as s, jsxs as _, Fragment as Q } from "react/jsx-runtime";
2
+ import { u as W, a as X, e as J, r as Z, T as x, b as ee, y as te } from "./index-Da68VNiu.js";
3
3
  import { useQuery as ne } from "@tanstack/react-query";
4
4
  import { useState as l, useCallback as p, useEffect as N, useMemo as f } from "react";
5
5
  import { useTranslation as ae } from "react-i18next";
@@ -22,10 +22,10 @@ const oe = "_documentsTableBody_1voj8_1", re = "_viewAttachmentsLink_1voj8_11",
22
22
  function j(n) {
23
23
  return !n || n.includes(":") ? "#" : `/openmrs/auth?requested_document=/document_images/${n}`;
24
24
  }
25
- function he(n, E) {
25
+ function he(n, T) {
26
26
  return n.map((d) => ({
27
27
  key: d,
28
- header: E(ue[d])
28
+ header: T(ue[d])
29
29
  }));
30
30
  }
31
31
  const _e = [
@@ -34,12 +34,12 @@ 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
+ ], 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: T }) => {
38
38
  const [d, M] = l(!1), [r, U] = l(
39
39
  null
40
40
  ), [P, A] = l(
41
41
  /* @__PURE__ */ new Set()
42
- ), T = Q(), { t: o } = ae(), { addNotification: w } = X(), F = Number(n?.pageSize) || 5, [D, O] = l(1), [m, $] = l(F), [k, C] = l(void 0), b = p((e) => {
42
+ ), E = W(), { t: o } = ae(), { addNotification: w } = X(), F = Number(n?.pageSize) || 5, [D, O] = l(1), [m, $] = l(F), [k, C] = l(void 0), b = p((e) => {
43
43
  U(e), M(!0);
44
44
  }, []), V = p(() => {
45
45
  M(!1), U(null), A(/* @__PURE__ */ new Set());
@@ -48,15 +48,15 @@ const _e = [
48
48
  }, []), { data: u, isLoading: z, isError: y, error: S } = ne({
49
49
  queryKey: [
50
50
  "documents",
51
- T,
52
51
  E,
52
+ T,
53
53
  D,
54
54
  m
55
55
  ],
56
- enabled: !!T,
56
+ enabled: !!E,
57
57
  queryFn: () => J(
58
- T,
59
58
  E,
59
+ T,
60
60
  m,
61
61
  D
62
62
  )
@@ -65,7 +65,7 @@ const _e = [
65
65
  u && C(u.total);
66
66
  }, [u]), N(() => {
67
67
  O(1), C(void 0);
68
- }, [T]), N(() => {
68
+ }, [E]), N(() => {
69
69
  y && w({
70
70
  title: o("ERROR_DEFAULT_TITLE"),
71
71
  message: S?.message ?? "",
@@ -98,7 +98,7 @@ const _e = [
98
98
  ), g = f(
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]), W = f(
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(
102
102
  () => g.map((e) => ({
103
103
  key: e,
104
104
  sortable: e !== "action"
@@ -107,7 +107,7 @@ const _e = [
107
107
  ), h = f(
108
108
  () => r ? R(r) : [],
109
109
  [r]
110
- ), Y = p(
110
+ ), K = p(
111
111
  (e, t) => {
112
112
  switch (t) {
113
113
  case "documentIdentifier":
@@ -138,7 +138,7 @@ const _e = [
138
138
  },
139
139
  [b, o]
140
140
  );
141
- return /* @__PURE__ */ _(K, { children: [
141
+ return /* @__PURE__ */ _(Q, { children: [
142
142
  /* @__PURE__ */ s("div", { "data-testid": "documents-table", children: /* @__PURE__ */ s(
143
143
  ee,
144
144
  {
@@ -147,9 +147,9 @@ const _e = [
147
147
  rows: q,
148
148
  loading: z,
149
149
  errorStateMessage: y ? S?.message : null,
150
- sortable: W,
150
+ sortable: Y,
151
151
  emptyStateMessage: o("DOCUMENTS_NO_RECORDS"),
152
- renderCell: Y,
152
+ renderCell: K,
153
153
  className: c.documentsTableBody,
154
154
  dataTestId: "documents-table",
155
155
  pageSize: m,
@@ -1,55 +1,55 @@
1
1
  import { jsx as n, jsxs as X, Fragment as Z } from "react/jsx-runtime";
2
- import { V as ee, u as re, $ as te, D as oe, I as ae, C as se, R as ne, K as de, d as q, b as ie, r as me, c as U, Q as ce, e as le, y as ue, O as fe } from "./index-CvrYKnfA.js";
2
+ import { K as ee, u as re, P as te, q as oe, x as ae, U as se, N as ne, Q as de, O as S, T as ie, r as me, b as C, c as ce, d as le, y as ue, f as fe } from "./index-Da68VNiu.js";
3
3
  import { useQueryClient as ye, useQuery as f } from "@tanstack/react-query";
4
4
  import { useState as x, useMemo as d, useCallback as y } from "react";
5
5
  import { useTranslation as pe } from "react-i18next";
6
- const be = "_formsTableBody_81hra_1", ge = "_customAccordianItem_81hra_6", v = {
6
+ const be = "_formsTableBody_81hra_1", Ne = "_customAccordianItem_81hra_6", E = {
7
7
  formsTableBody: be,
8
- customAccordianItem: ge
9
- }, he = (m) => m ? m.extension?.find(
8
+ customAccordianItem: Ne
9
+ }, ge = (m) => m ? m.extension?.find(
10
10
  (p) => p.url === ee
11
- )?.valueString : void 0, De = ({
11
+ )?.valueString : void 0, Ie = ({
12
12
  episodeOfCareUuids: m,
13
13
  encounterUuids: i,
14
14
  config: p
15
15
  }) => {
16
- const { t: s } = pe(), c = re(), [l, E] = x(!1), [t, D] = x(null), { numberOfVisits: k, hideThumbnail: K = !1 } = p ?? {}, I = te(
16
+ const { t: s } = pe(), c = re(), [l, D] = x(!1), [t, I] = x(null), { numberOfVisits: w, hideThumbnail: P = !1 } = p ?? {}, M = te(
17
17
  m,
18
18
  i
19
- ), P = ye(), {
19
+ ), k = ye(), {
20
20
  data: b = [],
21
- isLoading: M,
22
- isError: R,
23
- error: V,
24
- refetch: $
21
+ isLoading: v,
22
+ isError: A,
23
+ error: K,
24
+ refetch: Q
25
25
  } = f({
26
26
  queryKey: ["forms", c, m],
27
- queryFn: () => oe(c, void 0, k),
28
- enabled: !!c && !I
29
- }), A = d(() => !i || i.length === 0 ? b : b.filter(
27
+ queryFn: () => oe(c, void 0, w),
28
+ enabled: !!c && !M
29
+ }), B = d(() => !i || i.length === 0 ? b : b.filter(
30
30
  (e) => i.includes(e.encounterUuid)
31
- ), [b, i]), { data: B = [] } = f({
31
+ ), [b, i]), { data: T = [] } = f({
32
32
  queryKey: ["observationForms"],
33
33
  queryFn: () => ae()
34
- }), T = y(
35
- (e) => B.find((r) => r.name === e)?.uuid,
36
- [B]
37
- ), g = d(() => {
34
+ }), R = y(
35
+ (e) => T.find((r) => r.name === e)?.uuid,
36
+ [T]
37
+ ), N = d(() => {
38
38
  if (t)
39
- return T(t.formName);
40
- }, [t, T]), {
39
+ return R(t.formName);
40
+ }, [t, R]), {
41
41
  isLoading: H,
42
- isError: Q,
43
- error: h
42
+ isError: j,
43
+ error: g
44
44
  } = f({
45
- queryKey: ["formMetadata", g],
46
- queryFn: () => se(g),
47
- enabled: !!g && l
45
+ queryKey: ["formMetadata", N],
46
+ queryFn: () => se(N),
47
+ enabled: !!N && l
48
48
  }), {
49
- data: F,
50
- isLoading: j,
51
- isError: w,
52
- error: N
49
+ data: h,
50
+ isLoading: V,
51
+ isError: $,
52
+ error: O
53
53
  } = f({
54
54
  queryKey: ["formsEncounterFHIR", t?.encounterUuid],
55
55
  queryFn: () => ne(t.encounterUuid),
@@ -57,19 +57,19 @@ const be = "_formsTableBody_81hra_1", ge = "_customAccordianItem_81hra_6", v = {
57
57
  });
58
58
  de(
59
59
  (e) => {
60
- e.patientUUID === c && e.updatedConcepts.size > 0 && ($(), P.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
60
+ e.patientUUID === c && e.updatedConcepts.size > 0 && (Q(), k.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
61
61
  },
62
62
  [c]
63
63
  );
64
- const z = d(() => !F?.entry || !t?.formName ? [] : F.entry.filter((a) => a.resource?.resourceType === "Observation").map((a) => a.resource).filter((a) => {
65
- const r = he(a);
64
+ const z = d(() => !h?.entry || !t?.formName ? [] : h.entry.filter((a) => a.resource?.resourceType === "Observation").map((a) => a.resource).filter((a) => {
65
+ const r = ge(a);
66
66
  return !r || r.includes(t.formName);
67
- }), [F, t?.formName]), G = d(() => {
68
- if (h)
69
- return q(h).message;
70
- if (N)
71
- return q(N).message;
72
- }, [h, N]), L = d(
67
+ }), [h, t?.formName]), G = d(() => {
68
+ if (g)
69
+ return S(g).message;
70
+ if (O)
71
+ return S(O).message;
72
+ }, [g, O]), L = d(
73
73
  () => [
74
74
  { key: "recordedOn", header: s("RECORDED_ON") },
75
75
  { key: "recordedBy", header: s("RECORDED_BY") }
@@ -82,16 +82,16 @@ const be = "_formsTableBody_81hra_1", ge = "_customAccordianItem_81hra_6", v = {
82
82
  ],
83
83
  []
84
84
  ), _ = d(() => {
85
- const e = A.reduce(
85
+ const e = B.reduce(
86
86
  (r, o) => {
87
87
  const u = o.formName;
88
88
  r[u] ??= [];
89
- const O = o.providers.map((W) => W.providerName).filter(Boolean).join(", ");
89
+ const F = o.providers.map((W) => W.providerName).filter(Boolean).join(", ");
90
90
  return r[u].push({
91
91
  id: o.encounterUuid,
92
92
  formName: o.formName,
93
93
  recordedOn: ie(o.encounterDateTime, s, !0).formattedResult,
94
- recordedBy: O ?? "--",
94
+ recordedBy: F ?? "--",
95
95
  encounterDateTime: o.encounterDateTime,
96
96
  encounterUuid: o.encounterUuid
97
97
  }), r;
@@ -102,39 +102,39 @@ const be = "_formsTableBody_81hra_1", ge = "_customAccordianItem_81hra_6", v = {
102
102
  ([r, o]) => ({
103
103
  formName: r,
104
104
  records: o.sort(
105
- (u, O) => O.encounterDateTime - u.encounterDateTime
105
+ (u, F) => F.encounterDateTime - u.encounterDateTime
106
106
  )
107
107
  })
108
108
  ).sort((r, o) => r.formName.localeCompare(o.formName));
109
- }, [A, s]), C = y((e) => {
110
- D(e), E(!0);
109
+ }, [B, s]), q = y((e) => {
110
+ I(e), D(!0);
111
111
  }, []), J = y(() => {
112
- E(!1), D(null);
113
- }, []), S = y(
112
+ D(!1), I(null);
113
+ }, []), U = y(
114
114
  (e, a) => {
115
115
  switch (a) {
116
116
  case "recordedOn":
117
- return /* @__PURE__ */ n(me, { onClick: () => C(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:
121
121
  return null;
122
122
  }
123
123
  },
124
- [C]
124
+ [q]
125
125
  );
126
126
  return /* @__PURE__ */ X(Z, { children: [
127
- /* @__PURE__ */ n("div", { "data-testid": "forms-table", children: M || R || _.length === 0 || I ? /* @__PURE__ */ n(
128
- U,
127
+ /* @__PURE__ */ n("div", { "data-testid": "forms-table", children: v || A || _.length === 0 || M ? /* @__PURE__ */ n(
128
+ C,
129
129
  {
130
130
  headers: L,
131
131
  ariaLabel: s("FORMS_HEADING"),
132
132
  rows: [],
133
- loading: M,
134
- errorStateMessage: R ? V?.message : void 0,
133
+ loading: v,
134
+ errorStateMessage: A ? K?.message : void 0,
135
135
  emptyStateMessage: s("FORMS_UNAVAILABLE"),
136
- renderCell: S,
137
- className: v.formsTableBody,
136
+ renderCell: U,
137
+ className: E.formsTableBody,
138
138
  dataTestId: "forms-table"
139
139
  }
140
140
  ) : /* @__PURE__ */ n(ce, { align: "start", children: _.map((e, a) => {
@@ -143,11 +143,11 @@ const be = "_formsTableBody_81hra_1", ge = "_customAccordianItem_81hra_6", v = {
143
143
  le,
144
144
  {
145
145
  title: r,
146
- className: v.customAccordianItem,
146
+ className: E.customAccordianItem,
147
147
  testId: `accordian-title-${r}`,
148
148
  open: a === 0,
149
149
  children: /* @__PURE__ */ n(
150
- U,
150
+ C,
151
151
  {
152
152
  headers: L,
153
153
  ariaLabel: s("FORMS_HEADING"),
@@ -156,8 +156,8 @@ const be = "_formsTableBody_81hra_1", ge = "_customAccordianItem_81hra_6", v = {
156
156
  errorStateMessage: "",
157
157
  sortable: Y,
158
158
  emptyStateMessage: s("FORMS_UNAVAILABLE"),
159
- renderCell: S,
160
- className: v.formsTableBody,
159
+ renderCell: U,
160
+ className: E.formsTableBody,
161
161
  dataTestId: `forms-table-${r}`
162
162
  }
163
163
  )
@@ -181,12 +181,12 @@ const be = "_formsTableBody_81hra_1", ge = "_customAccordianItem_81hra_6", v = {
181
181
  fe,
182
182
  {
183
183
  observations: z,
184
- isLoading: H || j,
185
- isError: Q || w,
184
+ isLoading: H || V,
185
+ isError: j || $,
186
186
  errorMessage: G,
187
187
  emptyStateMessage: s("NO_FORM_DATA_AVAILABLE"),
188
188
  testIdPrefix: t.formName,
189
- hideThumbnail: K
189
+ hideThumbnail: P
190
190
  }
191
191
  )
192
192
  }
@@ -194,5 +194,5 @@ const be = "_formsTableBody_81hra_1", ge = "_customAccordianItem_81hra_6", v = {
194
194
  ] });
195
195
  };
196
196
  export {
197
- De as default
197
+ Ie as default
198
198
  };
@@ -1,13 +1,13 @@
1
1
  import { jsx as d, jsxs as S } from "react/jsx-runtime";
2
- import { f as V, g as D, t as k, A as q, l as Q, M as w, h as G, E as P, u as j, a as H, i as z, j as Y, K as J, k as W, m as X, s as Z, n as x, c as ee } from "./index-CvrYKnfA.js";
2
+ import { g as Q, h as D, t as k, C as w, l as q, M as K, V as G, E as P, u as j, a as H, i as z, j as Y, Q as J, k as W, m as X, s as Z, n as x, b as ee } from "./index-Da68VNiu.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
- const A = (t, i, c, l, u, r) => {
7
- const s = k(t, i, u), o = s.value, a = q(o);
6
+ const B = (t, i, c, l, u, r) => {
7
+ const s = k(t, i, u), o = s.value, a = w(o);
8
8
  let n = o;
9
9
  a === "Image" && (n = /* @__PURE__ */ d(
10
- w,
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
  }), p = t.display, m = t.observationValue?.isAbnormal ? "abnormal-obs" : "obs", y = l ? `${l}-${m}-${p}-${c}-${i}` : `${m}-${p}-${c}-${i}`;
28
28
  return /* @__PURE__ */ d(
29
- Q,
29
+ q,
30
30
  {
31
31
  header: s.header,
32
32
  value: n,
@@ -44,7 +44,7 @@ const A = (t, i, c, l, u, r) => {
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) => B(
48
48
  o,
49
49
  a,
50
50
  u,
@@ -61,7 +61,7 @@ const A = (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 = V(r.encounterDetails, l);
64
+ const a = Q(r.encounterDetails, l);
65
65
  return /* @__PURE__ */ S(
66
66
  D,
67
67
  {
@@ -70,7 +70,7 @@ const A = (t, i, c, l, u, r) => {
70
70
  open: s,
71
71
  children: [
72
72
  r.observations.map(
73
- (n, b) => A(
73
+ (n, b) => B(
74
74
  n,
75
75
  b,
76
76
  o,
@@ -161,11 +161,11 @@ const A = (t, i, c, l, u, r) => {
161
161
  if (!m) return [];
162
162
  const e = W(m), v = X(e);
163
163
  return Z(v);
164
- }, [m]), B = [
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, F = (!m || m.entry?.length === 0 || p.length === 0) && f, L = $ ? a("ERROR_FETCHING_OBSERVATIONS") : null, M = F ? a("NO_OBSERVATIONS_FOUND") : void 0, K = I.length > 0 && !_ && !$, h = i.titleTranslationKey, E = h ? a(h) : "";
168
+ ], _ = 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 = I.length > 0 && !_ && !$, h = i.titleTranslationKey, E = h ? a(h) : "";
169
169
  return /* @__PURE__ */ S(
170
170
  "div",
171
171
  {
@@ -184,7 +184,7 @@ const A = (t, i, c, l, u, r) => {
184
184
  children: /* @__PURE__ */ d("p", { children: E })
185
185
  }
186
186
  ),
187
- K ? /* @__PURE__ */ d(
187
+ V ? /* @__PURE__ */ d(
188
188
  ae,
189
189
  {
190
190
  groupedData: I,
@@ -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: _,