@bahmni/clinical-app 0.0.1-dev.189 → 0.0.1-dev.191

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.
@@ -0,0 +1,202 @@
1
+ import { jsx as o, jsxs as l, Fragment as k } from "react/jsx-runtime";
2
+ import { p as V, u as F, o as H, a as x, $ as P, b as j, A as G, c as Y, m as z, g as J } from "./index-DdWTjZmQ.js";
3
+ import { useState as C, useCallback as T, useEffect as S, useMemo as E } from "react";
4
+ const K = "_documentsTableBody_6qsah_1", Q = "_viewAttachmentsLink_6qsah_11", W = "_documentViewerContainer_6qsah_15", X = "_attachmentItem_6qsah_23", Z = "_attachmentCounter_6qsah_27", ee = "_attachmentError_6qsah_36", te = "_documentIframe_6qsah_44", ae = "_documentImage_6qsah_50", d = {
5
+ documentsTableBody: K,
6
+ viewAttachmentsLink: Q,
7
+ documentViewerContainer: W,
8
+ attachmentItem: X,
9
+ attachmentCounter: Z,
10
+ attachmentError: ee,
11
+ documentIframe: te,
12
+ documentImage: ae
13
+ }, ne = {
14
+ documentIdentifier: "DOCUMENTS_DOCUMENT_IDENTIFIER",
15
+ documentType: "DOCUMENTS_TYPE",
16
+ uploadedOn: "DOCUMENTS_UPLOADED_ON",
17
+ uploadedBy: "DOCUMENTS_UPLOADED_BY",
18
+ action: "DOCUMENTS_ACTION"
19
+ };
20
+ function U(a) {
21
+ return !a || a.includes(":") ? "#" : `/openmrs/auth?requested_document=/document_images/${a}`;
22
+ }
23
+ function re(a, u) {
24
+ return a.map((s) => ({
25
+ key: s,
26
+ header: u(ne[s])
27
+ }));
28
+ }
29
+ const oe = [
30
+ "documentIdentifier",
31
+ "documentType",
32
+ "uploadedOn",
33
+ "uploadedBy",
34
+ "action"
35
+ ], M = (a) => a.attachments.length > 0 ? a.attachments : a.documentUrl ? [{ url: a.documentUrl, contentType: a.contentType }] : [], me = ({ config: a, encounterUuids: u }) => {
36
+ const [s, g] = C(!1), [r, O] = C(
37
+ null
38
+ ), [w, p] = C(
39
+ /* @__PURE__ */ new Set()
40
+ ), N = V(), { t: n } = F(), { addNotification: y } = H(), D = T((e) => {
41
+ O(e), g(!0);
42
+ }, []), b = T(() => {
43
+ g(!1), O(null), p(/* @__PURE__ */ new Set());
44
+ }, []), L = T((e) => {
45
+ p((t) => new Set(t).add(e));
46
+ }, []), { data: q, isLoading: B, isError: f, error: I } = x({
47
+ queryKey: ["documents", N, u],
48
+ enabled: !!N,
49
+ queryFn: () => J(N, u)
50
+ });
51
+ S(() => {
52
+ f && y({
53
+ title: n("ERROR_DEFAULT_TITLE"),
54
+ message: I?.message ?? "",
55
+ type: "error"
56
+ });
57
+ }, [f, I, y, n]), S(() => {
58
+ const e = new AbortController();
59
+ return (async () => {
60
+ if (!s || !r) return;
61
+ const t = /* @__PURE__ */ new Set(), c = M(r);
62
+ for (let m = 0; m < c.length; m++) {
63
+ const A = U(c[m].url);
64
+ try {
65
+ (await fetch(A, {
66
+ method: "HEAD",
67
+ signal: e.signal
68
+ })).ok || t.add(m);
69
+ } catch (_) {
70
+ _ instanceof Error && _.name !== "AbortError" && t.add(m);
71
+ }
72
+ }
73
+ e.signal.aborted || p(t);
74
+ })(), () => e.abort();
75
+ }, [s, r]);
76
+ const h = E(
77
+ () => a?.fields ?? oe,
78
+ [a?.fields]
79
+ ), R = E(() => re(h, n), [h, n]), $ = E(
80
+ () => h.map((e) => ({
81
+ key: e,
82
+ sortable: e !== "action"
83
+ })),
84
+ [h]
85
+ ), i = E(
86
+ () => r ? M(r) : [],
87
+ [r]
88
+ ), v = T(
89
+ (e, t) => {
90
+ switch (t) {
91
+ case "documentIdentifier":
92
+ return /* @__PURE__ */ o("span", { children: e.documentIdentifier });
93
+ case "documentType":
94
+ return e.documentType ?? n("DOCUMENTS_NOT_AVAILABLE");
95
+ case "uploadedOn":
96
+ return j(
97
+ e.uploadedOn,
98
+ n,
99
+ z
100
+ ).formattedResult || n("DOCUMENTS_NOT_AVAILABLE");
101
+ case "uploadedBy":
102
+ return e.uploadedBy ?? n("DOCUMENTS_NOT_AVAILABLE");
103
+ case "action":
104
+ return e.attachments.length > 0 || e.documentUrl ? /* @__PURE__ */ o(
105
+ P,
106
+ {
107
+ onClick: () => D(e),
108
+ className: d.viewAttachmentsLink,
109
+ "data-testid": `view-attachments-${e.id}`,
110
+ children: n("DOCUMENTS_VIEW_ATTACHMENTS")
111
+ }
112
+ ) : "--";
113
+ default:
114
+ return null;
115
+ }
116
+ },
117
+ [D, n]
118
+ );
119
+ return /* @__PURE__ */ l(k, { children: [
120
+ /* @__PURE__ */ o("div", { "data-testid": "documents-table", children: /* @__PURE__ */ o(
121
+ G,
122
+ {
123
+ headers: R,
124
+ ariaLabel: n("DOCUMENTS_TABLE_HEADING"),
125
+ rows: q ?? [],
126
+ loading: B,
127
+ errorStateMessage: f ? I?.message : null,
128
+ sortable: $,
129
+ emptyStateMessage: n("DOCUMENTS_NO_RECORDS"),
130
+ renderCell: v,
131
+ className: d.documentsTableBody,
132
+ dataTestId: "documents-table"
133
+ }
134
+ ) }),
135
+ s && r && /* @__PURE__ */ o(
136
+ Y,
137
+ {
138
+ id: "modalIdForActionAreaLayout",
139
+ portalId: "main-display-area",
140
+ open: s,
141
+ onRequestClose: b,
142
+ modalHeading: r.documentIdentifier,
143
+ passiveModal: !0,
144
+ size: "lg",
145
+ testId: "document-view-modal",
146
+ children: /* @__PURE__ */ o("div", { className: d.documentViewerContainer, children: i.map((e, t) => {
147
+ const c = U(e.url), m = e.contentType?.toLowerCase().includes("pdf"), A = e.contentType?.toLowerCase().includes("image"), _ = w.has(t);
148
+ return c === "#" || _ ? /* @__PURE__ */ l(
149
+ "div",
150
+ {
151
+ className: d.attachmentError,
152
+ "data-testid": `attachment-error-${t}`,
153
+ children: [
154
+ i.length > 1 && /* @__PURE__ */ l("p", { className: d.attachmentCounter, children: [
155
+ t + 1,
156
+ "/",
157
+ i.length
158
+ ] }),
159
+ /* @__PURE__ */ o("p", { children: n("DOCUMENTS_ERROR_LOADING_ATTACHMENT") })
160
+ ]
161
+ },
162
+ `${r.id}-${e.url}`
163
+ ) : /* @__PURE__ */ l(
164
+ "div",
165
+ {
166
+ className: d.attachmentItem,
167
+ "data-testid": `attachment-item-${t}`,
168
+ children: [
169
+ i.length > 1 && /* @__PURE__ */ l("p", { className: d.attachmentCounter, children: [
170
+ t + 1,
171
+ "/",
172
+ i.length
173
+ ] }),
174
+ A ? /* @__PURE__ */ o(
175
+ "img",
176
+ {
177
+ src: c,
178
+ alt: r.documentIdentifier,
179
+ className: d.documentImage,
180
+ onError: () => L(t)
181
+ }
182
+ ) : /* @__PURE__ */ o(
183
+ "iframe",
184
+ {
185
+ src: m ? `${c}#toolbar=0` : c,
186
+ className: d.documentIframe,
187
+ title: r.documentIdentifier,
188
+ onError: () => L(t)
189
+ }
190
+ )
191
+ ]
192
+ },
193
+ `${r.id}-${e.url}`
194
+ );
195
+ }) })
196
+ }
197
+ )
198
+ ] });
199
+ };
200
+ export {
201
+ me as default
202
+ };
@@ -1,7 +1,7 @@
1
1
  import { jsx as s, jsxs as p, Fragment as k } from "react/jsx-runtime";
2
- import { u as ee, p as re, y as ae, c as te, a as A, d as oe, b as ne, e as se, A as q, Y as de, G as me, $ as ie, P as le, Z as U, h as ce, m as ue, T as R, f as be, F as pe, q as fe, W as _e, i as $e, w as he, j as ve, k as ge, l as ye } from "./index-hzibnTqr.js";
2
+ import { u as ee, p as re, y as ae, d as te, a as A, e as oe, b as ne, $ as se, A as q, Y as de, G as me, c as ie, P as le, Z as U, h as ce, m as ue, T as R, f as be, F as pe, q as fe, W as _e, i as $e, w as he, j as ve, k as ge, l as ye } from "./index-DdWTjZmQ.js";
3
3
  import { useState as P, useMemo as g, useCallback as F } from "react";
4
- const Ne = "_formsTableBody_1pd36_1", Ae = "_customAccordianItem_1pd36_6", Fe = "_formContent_1pd36_18", Re = "_formDetailsContainer_1pd36_25", Le = "_observation_1pd36_30", Ce = "_groupContainer_1pd36_39", Oe = "_rowContainer_1pd36_43", Ie = "_groupLabel_1pd36_48", Te = "_rowLabel_1pd36_58", Me = "_rowValue_1pd36_67", Ve = "_groupMembers_1pd36_75", Se = "_memberRow_1pd36_81", we = "_memberLabel_1pd36_86", De = "_memberValue_1pd36_94", xe = "_abnormalValue_1pd36_102", Ee = "_commentSection_1pd36_110", Be = "_commentText_1pd36_116", Ge = "_nestedGroup_1pd36_125", qe = "_nestedGroupLabel_1pd36_132", Ue = "_nestedGroupMembers_1pd36_141", o = {
4
+ const Ne = "_formsTableBody_1pd36_1", Ae = "_customAccordianItem_1pd36_6", Fe = "_formContent_1pd36_18", Re = "_formDetailsContainer_1pd36_25", Le = "_observation_1pd36_30", Ce = "_groupContainer_1pd36_39", Oe = "_rowContainer_1pd36_43", Ie = "_groupLabel_1pd36_48", Te = "_rowLabel_1pd36_58", Me = "_rowValue_1pd36_67", Ve = "_groupMembers_1pd36_75", Se = "_memberRow_1pd36_81", we = "_memberLabel_1pd36_86", De = "_memberValue_1pd36_94", Ee = "_abnormalValue_1pd36_102", xe = "_commentSection_1pd36_110", Be = "_commentText_1pd36_116", Ge = "_nestedGroup_1pd36_125", qe = "_nestedGroupLabel_1pd36_132", Ue = "_nestedGroupMembers_1pd36_141", o = {
5
5
  formsTableBody: Ne,
6
6
  customAccordianItem: Ae,
7
7
  formContent: Fe,
@@ -16,8 +16,8 @@ const Ne = "_formsTableBody_1pd36_1", Ae = "_customAccordianItem_1pd36_6", Fe =
16
16
  memberRow: Se,
17
17
  memberLabel: we,
18
18
  memberValue: De,
19
- abnormalValue: xe,
20
- commentSection: Ee,
19
+ abnormalValue: Ee,
20
+ commentSection: xe,
21
21
  commentText: Be,
22
22
  nestedGroup: Ge,
23
23
  nestedGroupLabel: qe,
@@ -297,7 +297,7 @@ const Ne = "_formsTableBody_1pd36_1", Ae = "_customAccordianItem_1pd36_6", Fe =
297
297
  const D = g(() => !C || !t?.formName ? [] : Ke(
298
298
  C,
299
299
  t.formName
300
- ), [C, t?.formName]), x = g(
300
+ ), [C, t?.formName]), E = g(
301
301
  () => [
302
302
  { key: "recordedOn", header: a("FORM_RECORDED_ON") },
303
303
  { key: "recordedBy", header: a("FORM_RECORDED_BY") }
@@ -309,7 +309,7 @@ const Ne = "_formsTableBody_1pd36_1", Ae = "_customAccordianItem_1pd36_6", Fe =
309
309
  { key: "recordedBy", sortable: !0 }
310
310
  ],
311
311
  []
312
- ), E = g(() => {
312
+ ), x = g(() => {
313
313
  const i = T.reduce(
314
314
  (u, l) => {
315
315
  const v = l.formName;
@@ -352,10 +352,10 @@ const Ne = "_formsTableBody_1pd36_1", Ae = "_customAccordianItem_1pd36_6", Fe =
352
352
  [B]
353
353
  );
354
354
  return /* @__PURE__ */ p(k, { children: [
355
- /* @__PURE__ */ s("div", { "data-testid": "forms-table", children: y || N || E.length === 0 || f ? /* @__PURE__ */ s(
355
+ /* @__PURE__ */ s("div", { "data-testid": "forms-table", children: y || N || x.length === 0 || f ? /* @__PURE__ */ s(
356
356
  q,
357
357
  {
358
- headers: x,
358
+ headers: E,
359
359
  ariaLabel: a("FORMS_HEADING"),
360
360
  rows: [],
361
361
  loading: y,
@@ -365,7 +365,7 @@ const Ne = "_formsTableBody_1pd36_1", Ae = "_customAccordianItem_1pd36_6", Fe =
365
365
  className: o.formsTableBody,
366
366
  dataTestId: "forms-table"
367
367
  }
368
- ) : /* @__PURE__ */ s(de, { align: "start", children: E.map((i, u) => {
368
+ ) : /* @__PURE__ */ s(de, { align: "start", children: x.map((i, u) => {
369
369
  const { formName: l, records: v } = i;
370
370
  return /* @__PURE__ */ s(
371
371
  me,
@@ -377,7 +377,7 @@ const Ne = "_formsTableBody_1pd36_1", Ae = "_customAccordianItem_1pd36_6", Fe =
377
377
  children: /* @__PURE__ */ s(
378
378
  q,
379
379
  {
380
- headers: x,
380
+ headers: E,
381
381
  ariaLabel: a("FORMS_HEADING"),
382
382
  rows: v,
383
383
  loading: !1,
@@ -1,5 +1,5 @@
1
- import { c, T as l, P as m, a as u, D as v, Q as i } from "./YPM2AS64-DXoAiWaQ.js";
2
- import { B as d, C as f, D as e } from "./index-hzibnTqr.js";
1
+ import { c, T as l, P as m, a as u, D as v, Q as i } from "./YPM2AS64-Dhjpvwx6.js";
2
+ import { B as d, C as f, D as e } from "./index-DdWTjZmQ.js";
3
3
  var p = (a) => {
4
4
  const [r, t] = c({
5
5
  prefix: "TanstackQueryDevtools"
@@ -1,5 +1,5 @@
1
- import { c as s, T as c, P as u, a as i, b as m, C as P, Q as d } from "./YPM2AS64-DXoAiWaQ.js";
2
- import { B as C, C as v, D as e } from "./index-hzibnTqr.js";
1
+ import { c as s, T as c, P as u, a as i, b as m, C as P, Q as d } from "./YPM2AS64-Dhjpvwx6.js";
2
+ import { B as C, C as v, D as e } from "./index-DdWTjZmQ.js";
3
3
  var h = (t) => {
4
4
  const [r, o] = s({
5
5
  prefix: "TanstackQueryDevtools"
@@ -1,5 +1,5 @@
1
1
  import { jsxs as I, jsx as l } from "react/jsx-runtime";
2
- import { p as B, o as k, u as N, n as H, r as K, a as w, d as x, h as Q, H as j, s as G, L as M, A as z, t as P, v as S, V as W, f as Y, x as J, F as X, q as Z, W as ee, z as te } from "./index-hzibnTqr.js";
2
+ import { p as k, o as B, u as N, n as H, r as K, a as x, e as Q, h as j, H as w, s as G, L as M, A as z, t as P, v as S, V as W, f as Y, x as J, F as X, q as Z, W as ee, z as te } from "./index-DdWTjZmQ.js";
3
3
  import { useRef as ae, useEffect as $, useMemo as E } from "react";
4
4
  const F = (t, d, n, u, o) => {
5
5
  const a = W(t, d), s = a.value, r = Y(s);
@@ -77,7 +77,7 @@ const F = (t, d, n, u, o) => {
77
77
  observations: oe,
78
78
  title: ie
79
79
  }, ne = (t) => ["conceptUuid", t], de = (t, d) => ["observations", t, ...d], be = ({ config: t }) => {
80
- const d = t, { conceptNames: n = [], conceptUuid: u = [] } = d, o = ae(/* @__PURE__ */ new Set()), a = B(), { addNotification: s } = k(), { t: r } = N(), i = H({
80
+ const d = t, { conceptNames: n = [], conceptUuid: u = [] } = d, o = ae(/* @__PURE__ */ new Set()), a = k(), { addNotification: s } = B(), { t: r } = N(), i = H({
81
81
  queries: n.map((e) => ({
82
82
  queryKey: ne(e),
83
83
  queryFn: () => K(e),
@@ -101,12 +101,12 @@ const F = (t, d, n, u, o) => {
101
101
  isLoading: A,
102
102
  isError: R,
103
103
  refetch: f
104
- } = w({
104
+ } = x({
105
105
  queryKey: de(a, p),
106
106
  queryFn: () => te(a, p),
107
107
  enabled: !!a && p.length > 0 && v
108
108
  });
109
- x(
109
+ Q(
110
110
  (e) => {
111
111
  e.patientUUID === a && e.updatedConcepts.size > 0 && [...e.updatedConcepts.keys()].some(
112
112
  (m) => p.includes(m)
@@ -122,7 +122,7 @@ const F = (t, d, n, u, o) => {
122
122
  }, [R]);
123
123
  const g = E(() => {
124
124
  if (!c) return [];
125
- const e = Q(c), m = j(e);
125
+ const e = j(c), m = w(e);
126
126
  return G(m);
127
127
  }, [c]), L = [
128
128
  { key: "name", header: "name" },
@@ -1,4 +1,4 @@
1
- import { E as we, I as z, J as xt, M as B, C as q, D as y, N as Ro, O as ye, S as R, Q as _, R as k, U as N, X as A, _ as bs, a0 as ir, a1 as $e, a2 as U, a3 as Hn, a4 as Vn, a5 as dt, a6 as D, a7 as xs, a8 as cn, a9 as Be, aa as ws, ab as qt, ac as zt, ad as $s, ae as Cs, af as $n, ag as Ss, ah as Nr, ai as Bt, aj as zo, ak as ks, al as Es, am as j, an as Ur, ao as Ms, ap as Ds, aq as sr, ar as As, as as Ts, at as zn, au as Fs, av as Is, aw as Z, ax as Ps, ay as Os } from "./index-hzibnTqr.js";
1
+ import { E as we, I as z, J as xt, K as B, C as q, D as y, M as Ro, N as ye, S as R, O as _, Q as k, R as N, U as A, X as bs, _ as ir, a0 as $e, a1 as U, a2 as Hn, a3 as Vn, a4 as dt, a5 as D, a6 as xs, a7 as cn, a8 as Be, a9 as ws, aa as qt, ab as zt, ac as $s, ad as Cs, ae as $n, af as Ss, ag as Nr, ah as Bt, ai as zo, aj as ks, ak as Es, al as j, am as Ur, an as Ms, ao as Ds, ap as sr, aq as As, ar as Ts, as as zn, at as Fs, au as Is, av as Z, aw as Ps, ax as Os } from "./index-DdWTjZmQ.js";
2
2
  var Ls = (e) => e != null, qs = (e) => e.filter(Ls);
3
3
  function _s(e) {
4
4
  return (...t) => {