@bahmni/widgets 0.0.1-dev.344 → 0.0.1-dev.346

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,16 +1,16 @@
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, I as Z, s as x, q as ee, F as te } from "./index-DYEFLsy1.js";
2
+ import { u as W, a as X, l as J, B as Z, R as x, q as ee, F as te } from "./index-D-OVBhy0.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 m, useCallback as _, useEffect as I, useMemo as p } from "react";
5
5
  import { useTranslation as ae } from "react-i18next";
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 = {
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", le = "DocumentsTable-module_attachmentError__RI4U2", me = "DocumentsTable-module_documentIframe__ptq5I", ue = "DocumentsTable-module_documentImage__KQVgS", c = {
7
7
  documentsTableBody: oe,
8
8
  viewAttachmentsLink: se,
9
9
  documentViewerContainer: re,
10
10
  attachmentItem: ce,
11
11
  attachmentCounter: de,
12
- attachmentError: me,
13
- documentIframe: le,
12
+ attachmentError: le,
13
+ documentIframe: me,
14
14
  documentImage: ue
15
15
  }, ie = {
16
16
  documentIdentifier: "DOCUMENTS_DOCUMENT_IDENTIFIER",
@@ -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 R(n) {
22
+ function B(n) {
23
23
  return !n || n.includes(":") ? "#" : `/openmrs/auth?requested_document=/document_images/${n}`;
24
24
  }
25
25
  function he(n, f) {
@@ -34,16 +34,16 @@ const Te = [
34
34
  "attachments",
35
35
  "uploadedOn",
36
36
  "uploadedBy"
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 }] : [], ge = ({ config: n, encounterUuids: f }) => {
38
- const [d, L] = l(!1), [s, U] = l(
37
+ ], _e = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, F = (n) => n.attachments.length > 0 ? n.attachments : n.documentUrl ? [{ url: n.documentUrl, contentType: n.contentType }] : [], Ie = ({ config: n, encounterUuids: f }) => {
38
+ const [d, L] = m(!1), [s, U] = m(
39
39
  null
40
- ), [P, A] = l(
40
+ ), [P, A] = m(
41
41
  /* @__PURE__ */ new Set()
42
- ), E = W(), { t: o } = ae(), { addNotification: w } = X(), H = Number(n?.pageSize) || 5, [N, C] = l(1), [u, V] = l(H), [$, O] = l(void 0), v = _((e) => {
42
+ ), E = W(), { t: o } = ae(), { addNotification: w } = X(), V = Number(n?.pageSize) || 5, [N, C] = m(1), [u, $] = m(V), [k, O] = m(void 0), v = _((e) => {
43
43
  U(e), L(!0);
44
- }, []), k = _(() => {
44
+ }, []), H = _(() => {
45
45
  L(!1), U(null), A(/* @__PURE__ */ new Set());
46
- }, []), F = _((e) => {
46
+ }, []), R = _((e) => {
47
47
  A((t) => new Set(t).add(e));
48
48
  }, []), { data: i, isLoading: q, isError: S, error: y } = ne({
49
49
  queryKey: [
@@ -61,30 +61,30 @@ 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
71
  message: y?.message ?? "",
72
72
  type: "error"
73
73
  });
74
- }, [S, y, w, o]), g(() => {
74
+ }, [S, y, 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 = B(s);
79
- for (let m = 0; m < I.length; m++) {
80
- const b = R(I[m].url);
78
+ const a = /* @__PURE__ */ new Set(), g = F(s);
79
+ for (let l = 0; l < g.length; l++) {
80
+ const b = B(g[l].url);
81
81
  try {
82
82
  (await fetch(b, {
83
83
  method: "HEAD",
84
84
  signal: e.signal
85
- })).ok || a.add(m);
85
+ })).ok || a.add(l);
86
86
  } catch (M) {
87
- M instanceof Error && M.name !== "AbortError" && a.add(m);
87
+ M instanceof Error && M.name !== "AbortError" && a.add(l);
88
88
  }
89
89
  }
90
90
  e.signal.aborted || A(a);
@@ -92,7 +92,7 @@ const Te = [
92
92
  }, [d, s]);
93
93
  const z = _(
94
94
  (e, t) => {
95
- t !== u ? (V(t), C(1), O(void 0)) : C(e);
95
+ t !== u ? ($(t), C(1), O(void 0)) : C(e);
96
96
  },
97
97
  [u]
98
98
  ), D = p(
@@ -105,7 +105,7 @@ const Te = [
105
105
  })),
106
106
  [D]
107
107
  ), h = p(
108
- () => s ? B(s) : [],
108
+ () => s ? F(s) : [],
109
109
  [s]
110
110
  ), Q = _(
111
111
  (e, t) => {
@@ -153,7 +153,7 @@ const Te = [
153
153
  className: c.documentsTableBody,
154
154
  dataTestId: "documents-table",
155
155
  pageSize: u,
156
- totalItems: $,
156
+ totalItems: k,
157
157
  page: N,
158
158
  onPageChange: z
159
159
  }
@@ -164,13 +164,13 @@ const Te = [
164
164
  id: "modalIdForActionAreaLayout",
165
165
  portalId: "main-display-area",
166
166
  open: d,
167
- onRequestClose: k,
167
+ onRequestClose: H,
168
168
  modalHeading: s.documentIdentifier,
169
169
  passiveModal: !0,
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 = R(e.url), I = e.contentType?.toLowerCase().includes("pdf"), m = (e.contentType?.toLowerCase().includes("image") ?? !1) || _e.test(e.url ?? ""), b = P.has(t);
173
+ const a = B(e.url), g = e.contentType?.toLowerCase().includes("pdf"), l = (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
  {
@@ -197,21 +197,21 @@ const Te = [
197
197
  "/",
198
198
  h.length
199
199
  ] }),
200
- m ? /* @__PURE__ */ r(
200
+ l ? /* @__PURE__ */ r(
201
201
  "img",
202
202
  {
203
203
  src: a,
204
204
  alt: s.documentIdentifier,
205
205
  className: c.documentImage,
206
- onError: () => F(t)
206
+ onError: () => R(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: () => F(t)
214
+ onError: () => R(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,50 +1,50 @@
1
1
  import { jsx as i, jsxs as oe, Fragment as te } from "react/jsx-runtime";
2
- import { u as se, b as ae, _ as ne, E as de, c as ie, n as ce, x as le, e as me, d as U, s as ue, I as fe, q as k, T as ye, R as be, F as pe, O as ge } from "./index-DYEFLsy1.js";
2
+ import { u as se, A as ae, V as ne, b as de, j as ie, S as ce, r as le, e as me, c as U, R as ue, B as fe, q as k, T as ye, d as be, F as pe, O as ge } from "./index-D-OVBhy0.js";
3
3
  import { useQueryClient as he, useQuery as b } from "@tanstack/react-query";
4
- import { useState as x, useMemo as d, useCallback as p } from "react";
4
+ import { useState as j, useMemo as d, useCallback as p } from "react";
5
5
  import { useTranslation as Fe } from "react-i18next";
6
6
  const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_customAccordianItem__isszs", O = {
7
7
  formsTableBody: Ne,
8
8
  customAccordianItem: Oe
9
- }, Ae = ({
10
- episodeOfCareUuids: E,
9
+ }, Ie = ({
10
+ episodeOfCareUuids: v,
11
11
  encounterUuids: l,
12
12
  config: H
13
13
  }) => {
14
- const { t: n } = Fe(), m = se(), [f, v] = x(!1), [a, I] = x(null), {
15
- numberOfVisits: j,
14
+ const { t: n } = Fe(), m = se(), [f, A] = j(!1), [a, E] = j(null), {
15
+ numberOfVisits: V,
16
16
  hideThumbnail: w = !1,
17
17
  forms: y
18
18
  } = H ?? {}, M = ae(
19
- E,
19
+ v,
20
20
  l
21
- ), K = he(), {
22
- data: _ = [],
23
- isLoading: A,
21
+ ), x = he(), {
22
+ data: B = [],
23
+ isLoading: I,
24
24
  isError: D,
25
- error: P,
26
- refetch: V
25
+ error: K,
26
+ refetch: P
27
27
  } = b({
28
- queryKey: ["forms", m, E],
29
- queryFn: () => ne(m, void 0, j),
28
+ queryKey: ["forms", m, v],
29
+ queryFn: () => ne(m, void 0, V),
30
30
  enabled: !!m && !M
31
31
  }), T = d(() => {
32
- let e = _;
32
+ let e = B;
33
33
  return l && l.length > 0 && (e = e.filter(
34
34
  (o) => l.includes(o.encounterUuid)
35
35
  )), Array.isArray(y) && y.length > 0 && (e = e.filter(
36
36
  (o) => y.some((r) => r.toLowerCase() === o.formName.toLowerCase())
37
37
  )), e;
38
- }, [_, l, y]), { data: B = [] } = b({
38
+ }, [B, l, y]), { data: R = [] } = b({
39
39
  queryKey: ["observationForms"],
40
40
  queryFn: () => de()
41
- }), R = p(
42
- (e) => B.find((r) => r.name === e)?.uuid,
43
- [B]
41
+ }), _ = p(
42
+ (e) => R.find((r) => r.name === e)?.uuid,
43
+ [R]
44
44
  ), g = d(() => {
45
45
  if (a)
46
- return R(a.formName);
47
- }, [a, R]), {
46
+ return _(a.formName);
47
+ }, [a, _]), {
48
48
  data: c,
49
49
  isLoading: $,
50
50
  isError: z,
@@ -65,7 +65,7 @@ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_cu
65
65
  });
66
66
  le(
67
67
  (e) => {
68
- e.patientUUID === m && e.updatedConcepts.size > 0 && (V(), K.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
68
+ e.patientUUID === m && e.updatedConcepts.size > 0 && (P(), x.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
69
69
  },
70
70
  [m]
71
71
  );
@@ -114,7 +114,7 @@ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_cu
114
114
  { key: "recordedBy", sortable: !0 }
115
115
  ],
116
116
  []
117
- ), q = d(() => {
117
+ ), S = d(() => {
118
118
  const e = T.reduce(
119
119
  (r, t) => {
120
120
  const s = t.formName;
@@ -140,10 +140,10 @@ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_cu
140
140
  })
141
141
  ).sort((r, t) => r.formName.localeCompare(t.formName));
142
142
  }, [T, n]), C = p((e) => {
143
- I(e), v(!0);
143
+ E(e), A(!0);
144
144
  }, []), ee = p(() => {
145
- v(!1), I(null);
146
- }, []), S = p(
145
+ A(!1), E(null);
146
+ }, []), q = p(
147
147
  (e, o) => {
148
148
  switch (o) {
149
149
  case "recordedOn":
@@ -157,20 +157,20 @@ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_cu
157
157
  [C]
158
158
  );
159
159
  return /* @__PURE__ */ oe(te, { children: [
160
- /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: A || D || q.length === 0 || M ? /* @__PURE__ */ i(
160
+ /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: I || D || S.length === 0 || M ? /* @__PURE__ */ i(
161
161
  k,
162
162
  {
163
163
  headers: L,
164
164
  ariaLabel: n("FORMS_HEADING"),
165
165
  rows: [],
166
- loading: A,
167
- errorStateMessage: D ? P?.message : void 0,
166
+ loading: I,
167
+ errorStateMessage: D ? K?.message : void 0,
168
168
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
169
- renderCell: S,
169
+ renderCell: q,
170
170
  className: O.formsTableBody,
171
171
  dataTestId: "forms-table"
172
172
  }
173
- ) : /* @__PURE__ */ i(ye, { align: "start", children: q.map((e, o) => {
173
+ ) : /* @__PURE__ */ i(ye, { align: "start", children: S.map((e, o) => {
174
174
  const { formName: r, records: t } = e;
175
175
  return /* @__PURE__ */ i(
176
176
  be,
@@ -189,7 +189,7 @@ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_cu
189
189
  errorStateMessage: "",
190
190
  sortable: Z,
191
191
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
192
- renderCell: S,
192
+ renderCell: q,
193
193
  className: O.formsTableBody,
194
194
  dataTestId: `forms-table-${r}`
195
195
  }
@@ -229,5 +229,5 @@ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_cu
229
229
  ] });
230
230
  };
231
231
  export {
232
- Ae as default
232
+ Ie as default
233
233
  };
@@ -1,13 +1,13 @@
1
1
  import { jsx as d, jsxs as N } from "react/jsx-runtime";
2
- import { f as H, X as D, t as K, r as V, W as q, Q as k, g as w, h as G, u as P, a as j, i as W, j as z, x as X, k as J, l as Y, m as x, o as Z, q as ee } from "./index-DYEFLsy1.js";
2
+ import { f as K, Q as D, t as V, g as q, W as k, h as w, n as H, i as G, u as P, a as j, k as z, m as W, r as J, o as Y, p as X, s as Z, v as x, q as ee } from "./index-D-OVBhy0.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
- k,
10
+ w,
11
11
  {
12
12
  imageSrc: o,
13
13
  alt: o,
@@ -15,7 +15,7 @@ const B = (t, i, c, l, u, r) => {
15
15
  hideThumbnail: r
16
16
  }
17
17
  )), a === "Video" && (n = /* @__PURE__ */ d(
18
- w,
18
+ H,
19
19
  {
20
20
  id: `${o}-video`,
21
21
  videoSrc: o,
@@ -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
+ k,
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 = H(r.encounterDetails, l);
64
+ const a = K(r.encounterDetails, l);
65
65
  return /* @__PURE__ */ N(
66
66
  D,
67
67
  {
@@ -117,7 +117,7 @@ const B = (t, i, c, l, u, r) => {
117
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
- queryFn: () => W(e),
120
+ queryFn: () => z(e),
121
121
  enabled: !!e
122
122
  }))
123
123
  });
@@ -140,10 +140,10 @@ const B = (t, i, c, l, u, r) => {
140
140
  refetch: T
141
141
  } = se({
142
142
  queryKey: le(s, m),
143
- queryFn: () => z(s, m),
143
+ queryFn: () => W(s, m),
144
144
  enabled: !!s && m.length > 0 && f
145
145
  });
146
- X(
146
+ J(
147
147
  (e) => {
148
148
  e.patientUUID === s && e.updatedConcepts.size > 0 && [...e.updatedConcepts.keys()].some(
149
149
  (R) => m.includes(R)
@@ -159,8 +159,8 @@ const B = (t, i, c, l, u, r) => {
159
159
  }, [h]);
160
160
  const _ = g(() => {
161
161
  if (!p) return [];
162
- const e = J(p), v = Y(e);
163
- return x(v);
162
+ const e = Y(p), v = X(e);
163
+ return Z(v);
164
164
  }, [p]), A = [
165
165
  { key: "name", header: "name" },
166
166
  { key: "value", header: "value" },
@@ -175,7 +175,7 @@ const B = (t, i, c, l, u, r) => {
175
175
  className: S.observations,
176
176
  children: [
177
177
  /* @__PURE__ */ d(
178
- Z,
178
+ x,
179
179
  {
180
180
  id: "observations-title",
181
181
  testId: O ? `observations-title-${E}` : "observations-title",
@@ -1 +1 @@
1
- {"version":3,"file":"DocumentUpload.d.ts","sourceRoot":"","sources":["../../src/documentUpload/DocumentUpload.tsx"],"names":[],"mappings":"AAaA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAMhD,OAAO,EAAE,mBAAmB,EAAmB,MAAM,UAAU,CAAC;AAIhE,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAoOxD,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"DocumentUpload.d.ts","sourceRoot":"","sources":["../../src/documentUpload/DocumentUpload.tsx"],"names":[],"mappings":"AAaA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAMhD,OAAO,EAAE,mBAAmB,EAAmB,MAAM,UAAU,CAAC;AAIhE,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA4OxD,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -5,6 +5,7 @@ export interface DocumentUploadProps {
5
5
  encounterTypeName: string;
6
6
  saveTarget: DocumentSaveTarget;
7
7
  documentTypes?: DocumentType[];
8
+ defaultOption?: string | null;
8
9
  onSaved?: () => void;
9
10
  }
10
11
  export interface PendingDocument {
@@ -1 +1 @@
1
- {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/documentUpload/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGzE,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAGD,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB"}
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/documentUpload/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGzE,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAGD,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB"}