@bahmni/clinical-app 0.0.1-dev.204 → 0.0.1-dev.206

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.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ay as i } from "./index-CERInyWn.js";
1
+ import { ay as i } from "./index-CnBX-u8j.js";
2
2
  export {
3
3
  i as ClinicalApp
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bahmni/clinical-app",
3
- "version": "0.0.1-dev.204",
3
+ "version": "0.0.1-dev.206",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -1,202 +0,0 @@
1
- import { jsx as o, jsxs as l, Fragment as k } from "react/jsx-runtime";
2
- import { l as V, u as x, Q as F, a as H, y as q, C as Q, x as P, T as G, s as Y } from "./index-CERInyWn.js";
3
- import { useState as I, useCallback as T, useEffect as U, useMemo as p } from "react";
4
- const z = "_documentsTableBody_1voj8_1", J = "_viewAttachmentsLink_1voj8_11", K = "_documentViewerContainer_1voj8_15", W = "_attachmentItem_1voj8_23", X = "_attachmentCounter_1voj8_27", Z = "_attachmentError_1voj8_36", ee = "_documentIframe_1voj8_44", te = "_documentImage_1voj8_50", d = {
5
- documentsTableBody: z,
6
- viewAttachmentsLink: J,
7
- documentViewerContainer: K,
8
- attachmentItem: W,
9
- attachmentCounter: X,
10
- attachmentError: Z,
11
- documentIframe: ee,
12
- documentImage: te
13
- }, ae = {
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 v(a) {
21
- return !a || a.includes(":") ? "#" : `/openmrs/auth?requested_document=/document_images/${a}`;
22
- }
23
- function ne(a, u) {
24
- return a.map((s) => ({
25
- key: s,
26
- header: u(ae[s])
27
- }));
28
- }
29
- const re = [
30
- "documentIdentifier",
31
- "documentType",
32
- "uploadedOn",
33
- "uploadedBy",
34
- "action"
35
- ], oe = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, w = (a) => a.attachments.length > 0 ? a.attachments : a.documentUrl ? [{ url: a.documentUrl, contentType: a.contentType }] : [], ie = ({ config: a, encounterUuids: u }) => {
36
- const [s, y] = I(!1), [r, O] = I(
37
- null
38
- ), [L, E] = I(
39
- /* @__PURE__ */ new Set()
40
- ), N = V(), { t: n } = x(), { addNotification: A } = F(), D = T((e) => {
41
- O(e), y(!0);
42
- }, []), M = T(() => {
43
- y(!1), O(null), E(/* @__PURE__ */ new Set());
44
- }, []), S = T((e) => {
45
- E((t) => new Set(t).add(e));
46
- }, []), { data: b, isLoading: j, isError: f, error: g } = H({
47
- queryKey: ["documents", N, u],
48
- enabled: !!N,
49
- queryFn: () => Y(N, u)
50
- });
51
- U(() => {
52
- f && A({
53
- title: n("ERROR_DEFAULT_TITLE"),
54
- message: g?.message ?? "",
55
- type: "error"
56
- });
57
- }, [f, g, A, n]), U(() => {
58
- const e = new AbortController();
59
- return (async () => {
60
- if (!s || !r) return;
61
- const t = /* @__PURE__ */ new Set(), c = w(r);
62
- for (let i = 0; i < c.length; i++) {
63
- const C = v(c[i].url);
64
- try {
65
- (await fetch(C, {
66
- method: "HEAD",
67
- signal: e.signal
68
- })).ok || t.add(i);
69
- } catch (h) {
70
- h instanceof Error && h.name !== "AbortError" && t.add(i);
71
- }
72
- }
73
- e.signal.aborted || E(t);
74
- })(), () => e.abort();
75
- }, [s, r]);
76
- const _ = p(
77
- () => a?.fields ?? re,
78
- [a?.fields]
79
- ), B = p(() => ne(_, n), [_, n]), R = p(
80
- () => _.map((e) => ({
81
- key: e,
82
- sortable: e !== "action"
83
- })),
84
- [_]
85
- ), m = p(
86
- () => r ? w(r) : [],
87
- [r]
88
- ), $ = 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 Q(
97
- e.uploadedOn,
98
- n,
99
- !0
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
- q,
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
- P,
122
- {
123
- headers: B,
124
- ariaLabel: n("DOCUMENTS_TABLE_HEADING"),
125
- rows: b ?? [],
126
- loading: j,
127
- errorStateMessage: f ? g?.message : null,
128
- sortable: R,
129
- emptyStateMessage: n("DOCUMENTS_NO_RECORDS"),
130
- renderCell: $,
131
- className: d.documentsTableBody,
132
- dataTestId: "documents-table"
133
- }
134
- ) }),
135
- s && r && /* @__PURE__ */ o(
136
- G,
137
- {
138
- id: "modalIdForActionAreaLayout",
139
- portalId: "main-display-area",
140
- open: s,
141
- onRequestClose: M,
142
- modalHeading: r.documentIdentifier,
143
- passiveModal: !0,
144
- size: "lg",
145
- testId: "document-view-modal",
146
- children: /* @__PURE__ */ o("div", { className: d.documentViewerContainer, children: m.map((e, t) => {
147
- const c = v(e.url), i = e.contentType?.toLowerCase().includes("pdf"), C = (e.contentType?.toLowerCase().includes("image") ?? !1) || oe.test(e.url ?? ""), h = L.has(t);
148
- return c === "#" || h ? /* @__PURE__ */ l(
149
- "div",
150
- {
151
- className: d.attachmentError,
152
- "data-testid": `attachment-error-${t}`,
153
- children: [
154
- m.length > 1 && /* @__PURE__ */ l("p", { className: d.attachmentCounter, children: [
155
- t + 1,
156
- "/",
157
- m.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
- m.length > 1 && /* @__PURE__ */ l("p", { className: d.attachmentCounter, children: [
170
- t + 1,
171
- "/",
172
- m.length
173
- ] }),
174
- C ? /* @__PURE__ */ o(
175
- "img",
176
- {
177
- src: c,
178
- alt: r.documentIdentifier,
179
- className: d.documentImage,
180
- onError: () => S(t)
181
- }
182
- ) : /* @__PURE__ */ o(
183
- "iframe",
184
- {
185
- src: i ? `${c}#toolbar=0` : c,
186
- className: d.documentIframe,
187
- title: r.documentIdentifier,
188
- onError: () => S(t)
189
- }
190
- )
191
- ]
192
- },
193
- `${r.id}-${e.url}`
194
- );
195
- }) })
196
- }
197
- )
198
- ] });
199
- };
200
- export {
201
- ie as default
202
- };