@bahmni/clinical-app 0.0.1-dev.269 → 0.0.1-dev.271

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,111 +1,112 @@
1
- import { jsx as r, jsxs as h, Fragment as Y } from "react/jsx-runtime";
2
- import { u as K, a as Q, h as W, b as J, c as X, m as Z, d as ee, n as te, e as ae } from "./index-CVOSTJhz.js";
3
- import { useState as m, useCallback as p, useEffect as f, useMemo as T } from "react";
4
- const ne = "_documentsTableBody_1voj8_1", oe = "_viewAttachmentsLink_1voj8_11", re = "_documentViewerContainer_1voj8_15", de = "_attachmentItem_1voj8_23", se = "_attachmentCounter_1voj8_27", ce = "_attachmentError_1voj8_36", ie = "_documentIframe_1voj8_44", me = "_documentImage_1voj8_50", d = {
1
+ import { jsx as r, jsxs as p, Fragment as x } from "react/jsx-runtime";
2
+ import { u as G, a as W, h as Y, t as J, b as X, m as Z, c as ee, n as te } from "./index-D8R0WjHJ.js";
3
+ import { useQuery as ae } from "@tanstack/react-query";
4
+ import { useState as l, useCallback as h, useEffect as O, useMemo as _ } from "react";
5
+ const ne = "DocumentsTable-module_documentsTableBody__6iR3w", oe = "DocumentsTable-module_viewAttachmentsLink__aQ1on", re = "DocumentsTable-module_documentViewerContainer__F5m8D", de = "DocumentsTable-module_attachmentItem__17KA7", se = "DocumentsTable-module_attachmentCounter__WFiI3", ce = "DocumentsTable-module_attachmentError__RI4U2", me = "DocumentsTable-module_documentIframe__ptq5I", le = "DocumentsTable-module_documentImage__KQVgS", d = {
5
6
  documentsTableBody: ne,
6
7
  viewAttachmentsLink: oe,
7
8
  documentViewerContainer: re,
8
9
  attachmentItem: de,
9
10
  attachmentCounter: se,
10
11
  attachmentError: ce,
11
- documentIframe: ie,
12
- documentImage: me
13
- }, le = {
12
+ documentIframe: me,
13
+ documentImage: le
14
+ }, ue = {
14
15
  documentIdentifier: "DOCUMENTS_DOCUMENT_IDENTIFIER",
15
16
  documentType: "DOCUMENTS_TYPE",
16
17
  uploadedOn: "DOCUMENTS_UPLOADED_ON",
17
18
  uploadedBy: "DOCUMENTS_UPLOADED_BY",
18
19
  action: "DOCUMENTS_ACTION"
19
20
  };
20
- function j(a) {
21
+ function R(a) {
21
22
  return !a || a.includes(":") ? "#" : `/openmrs/auth?requested_document=/document_images/${a}`;
22
23
  }
23
- function ue(a, g) {
24
+ function ie(a, g) {
24
25
  return a.map((s) => ({
25
26
  key: s,
26
- header: g(le[s])
27
+ header: g(ue[s])
27
28
  }));
28
29
  }
29
- const _e = [
30
+ const Te = [
30
31
  "documentIdentifier",
31
32
  "documentType",
32
33
  "uploadedOn",
33
34
  "uploadedBy",
34
35
  "action"
35
- ], he = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, B = (a) => a.attachments.length > 0 ? a.attachments : a.documentUrl ? [{ url: a.documentUrl, contentType: a.contentType }] : [], Ee = ({ config: a, encounterUuids: g }) => {
36
- const [s, w] = m(!1), [o, L] = m(
36
+ ], pe = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, B = (a) => a.attachments.length > 0 ? a.attachments : a.documentUrl ? [{ url: a.documentUrl, contentType: a.contentType }] : [], Ie = ({ config: a, encounterUuids: g }) => {
37
+ const [s, w] = l(!1), [o, U] = l(
37
38
  null
38
- ), [R, I] = m(
39
+ ), [$, D] = l(
39
40
  /* @__PURE__ */ new Set()
40
- ), E = K(), { t: n } = Q(), { addNotification: U } = W(), $ = Number(a?.pageSize) || 5, [C, A] = m(1), [l, k] = m($), [V, y] = m(void 0), b = p((e) => {
41
- L(e), w(!0);
42
- }, []), F = p(() => {
43
- w(!1), L(null), I(/* @__PURE__ */ new Set());
44
- }, []), M = p((e) => {
45
- I((t) => new Set(t).add(e));
46
- }, []), { data: u, isLoading: H, isError: D, error: v } = J({
41
+ ), E = G(), { t: n } = W(), { addNotification: L } = Y(), k = Number(a?.pageSize) || 5, [f, C] = l(1), [u, V] = l(k), [F, A] = l(void 0), M = h((e) => {
42
+ U(e), w(!0);
43
+ }, []), q = h(() => {
44
+ w(!1), U(null), D(/* @__PURE__ */ new Set());
45
+ }, []), v = h((e) => {
46
+ D((t) => new Set(t).add(e));
47
+ }, []), { data: i, isLoading: H, isError: b, error: y } = ae({
47
48
  queryKey: [
48
49
  "documents",
49
50
  E,
50
51
  g,
51
- C,
52
- l
52
+ f,
53
+ u
53
54
  ],
54
55
  enabled: !!E,
55
- queryFn: () => ae(
56
+ queryFn: () => J(
56
57
  E,
57
58
  g,
58
- l,
59
- C
59
+ u,
60
+ f
60
61
  )
61
62
  });
62
- f(() => {
63
- u && y(u.total);
64
- }, [u]), f(() => {
65
- A(1), y(void 0);
66
- }, [E]), f(() => {
67
- D && U({
63
+ O(() => {
64
+ i && A(i.total);
65
+ }, [i]), O(() => {
66
+ C(1), A(void 0);
67
+ }, [E]), O(() => {
68
+ b && L({
68
69
  title: n("ERROR_DEFAULT_TITLE"),
69
- message: v?.message ?? "",
70
+ message: y?.message ?? "",
70
71
  type: "error"
71
72
  });
72
- }, [D, v, U, n]), f(() => {
73
+ }, [b, y, L, n]), O(() => {
73
74
  const e = new AbortController();
74
75
  return (async () => {
75
76
  if (!s || !o) return;
76
77
  const t = /* @__PURE__ */ new Set(), c = B(o);
77
- for (let i = 0; i < c.length; i++) {
78
- const S = j(c[i].url);
78
+ for (let m = 0; m < c.length; m++) {
79
+ const S = R(c[m].url);
79
80
  try {
80
81
  (await fetch(S, {
81
82
  method: "HEAD",
82
83
  signal: e.signal
83
- })).ok || t.add(i);
84
- } catch (O) {
85
- O instanceof Error && O.name !== "AbortError" && t.add(i);
84
+ })).ok || t.add(m);
85
+ } catch (N) {
86
+ N instanceof Error && N.name !== "AbortError" && t.add(m);
86
87
  }
87
88
  }
88
- e.signal.aborted || I(t);
89
+ e.signal.aborted || D(t);
89
90
  })(), () => e.abort();
90
91
  }, [s, o]);
91
- const q = p(
92
+ const j = h(
92
93
  (e, t) => {
93
- t !== l ? (k(t), A(1), y(void 0)) : A(e);
94
+ t !== u ? (V(t), C(1), A(void 0)) : C(e);
94
95
  },
95
- [l]
96
- ), N = T(
97
- () => a?.fields ?? _e,
96
+ [u]
97
+ ), I = _(
98
+ () => a?.fields ?? Te,
98
99
  [a?.fields]
99
- ), P = T(() => [...u?.documents ?? []].sort((e, t) => !e.uploadedOn && !t.uploadedOn ? 0 : e.uploadedOn ? t.uploadedOn ? new Date(t.uploadedOn).getTime() - new Date(e.uploadedOn).getTime() : -1 : 1), [u]), z = T(() => ue(N, n), [N, n]), x = T(
100
- () => N.map((e) => ({
100
+ ), P = _(() => [...i?.documents ?? []].sort((e, t) => !e.uploadedOn && !t.uploadedOn ? 0 : e.uploadedOn ? t.uploadedOn ? new Date(t.uploadedOn).getTime() - new Date(e.uploadedOn).getTime() : -1 : 1), [i]), z = _(() => ie(I, n), [I, n]), K = _(
101
+ () => I.map((e) => ({
101
102
  key: e,
102
103
  sortable: e !== "action"
103
104
  })),
104
- [N]
105
- ), _ = T(
105
+ [I]
106
+ ), T = _(
106
107
  () => o ? B(o) : [],
107
108
  [o]
108
- ), G = p(
109
+ ), Q = h(
109
110
  (e, t) => {
110
111
  switch (t) {
111
112
  case "documentIdentifier":
@@ -124,7 +125,7 @@ const _e = [
124
125
  return e.attachments.length > 0 || e.documentUrl ? /* @__PURE__ */ r(
125
126
  X,
126
127
  {
127
- onClick: () => b(e),
128
+ onClick: () => M(e),
128
129
  className: d.viewAttachmentsLink,
129
130
  "data-testid": `view-attachments-${e.id}`,
130
131
  children: n("DOCUMENTS_VIEW_ATTACHMENTS")
@@ -134,9 +135,9 @@ const _e = [
134
135
  return null;
135
136
  }
136
137
  },
137
- [b, n]
138
+ [M, n]
138
139
  );
139
- return /* @__PURE__ */ h(Y, { children: [
140
+ return /* @__PURE__ */ p(x, { children: [
140
141
  /* @__PURE__ */ r("div", { "data-testid": "documents-table", children: /* @__PURE__ */ r(
141
142
  ee,
142
143
  {
@@ -144,16 +145,16 @@ const _e = [
144
145
  ariaLabel: n("DOCUMENTS_TABLE_HEADING"),
145
146
  rows: P,
146
147
  loading: H,
147
- errorStateMessage: D ? v?.message : null,
148
- sortable: x,
148
+ errorStateMessage: b ? y?.message : null,
149
+ sortable: K,
149
150
  emptyStateMessage: n("DOCUMENTS_NO_RECORDS"),
150
- renderCell: G,
151
+ renderCell: Q,
151
152
  className: d.documentsTableBody,
152
153
  dataTestId: "documents-table",
153
- pageSize: l,
154
- totalItems: V,
155
- page: C,
156
- onPageChange: q
154
+ pageSize: u,
155
+ totalItems: F,
156
+ page: f,
157
+ onPageChange: j
157
158
  }
158
159
  ) }),
159
160
  s && o && /* @__PURE__ */ r(
@@ -162,38 +163,38 @@ const _e = [
162
163
  id: "modalIdForActionAreaLayout",
163
164
  portalId: "main-display-area",
164
165
  open: s,
165
- onRequestClose: F,
166
+ onRequestClose: q,
166
167
  modalHeading: o.documentIdentifier,
167
168
  passiveModal: !0,
168
169
  size: "lg",
169
170
  testId: "document-view-modal",
170
- children: /* @__PURE__ */ r("div", { className: d.documentViewerContainer, children: _.map((e, t) => {
171
- const c = j(e.url), i = e.contentType?.toLowerCase().includes("pdf"), S = (e.contentType?.toLowerCase().includes("image") ?? !1) || he.test(e.url ?? ""), O = R.has(t);
172
- return c === "#" || O ? /* @__PURE__ */ h(
171
+ children: /* @__PURE__ */ r("div", { className: d.documentViewerContainer, children: T.map((e, t) => {
172
+ const c = R(e.url), m = e.contentType?.toLowerCase().includes("pdf"), S = (e.contentType?.toLowerCase().includes("image") ?? !1) || pe.test(e.url ?? ""), N = $.has(t);
173
+ return c === "#" || N ? /* @__PURE__ */ p(
173
174
  "div",
174
175
  {
175
176
  className: d.attachmentError,
176
177
  "data-testid": `attachment-error-${t}`,
177
178
  children: [
178
- _.length > 1 && /* @__PURE__ */ h("p", { className: d.attachmentCounter, children: [
179
+ T.length > 1 && /* @__PURE__ */ p("p", { className: d.attachmentCounter, children: [
179
180
  t + 1,
180
181
  "/",
181
- _.length
182
+ T.length
182
183
  ] }),
183
184
  /* @__PURE__ */ r("p", { children: n("DOCUMENTS_ERROR_LOADING_ATTACHMENT") })
184
185
  ]
185
186
  },
186
187
  `${o.id}-${e.url}`
187
- ) : /* @__PURE__ */ h(
188
+ ) : /* @__PURE__ */ p(
188
189
  "div",
189
190
  {
190
191
  className: d.attachmentItem,
191
192
  "data-testid": `attachment-item-${t}`,
192
193
  children: [
193
- _.length > 1 && /* @__PURE__ */ h("p", { className: d.attachmentCounter, children: [
194
+ T.length > 1 && /* @__PURE__ */ p("p", { className: d.attachmentCounter, children: [
194
195
  t + 1,
195
196
  "/",
196
- _.length
197
+ T.length
197
198
  ] }),
198
199
  S ? /* @__PURE__ */ r(
199
200
  "img",
@@ -201,15 +202,15 @@ const _e = [
201
202
  src: c,
202
203
  alt: o.documentIdentifier,
203
204
  className: d.documentImage,
204
- onError: () => M(t)
205
+ onError: () => v(t)
205
206
  }
206
207
  ) : /* @__PURE__ */ r(
207
208
  "iframe",
208
209
  {
209
- src: i ? `${c}#toolbar=0` : c,
210
+ src: m ? `${c}#toolbar=0` : c,
210
211
  className: d.documentIframe,
211
212
  title: o.documentIdentifier,
212
- onError: () => M(t)
213
+ onError: () => v(t)
213
214
  }
214
215
  )
215
216
  ]
@@ -222,5 +223,5 @@ const _e = [
222
223
  ] });
223
224
  };
224
225
  export {
225
- Ee as default
226
+ Ie as default
226
227
  };
@@ -0,0 +1,206 @@
1
+ import { jsx as s, jsxs as W, Fragment as Z } from "react/jsx-runtime";
2
+ import { a as ee, u as re, w as ae, e as oe, Q as te, X as se, J as ne, d as de, R as S, m as ie, b as me, c as U, T as ue, C as le, n as ce, f as fe, Y as ye } from "./index-D8R0WjHJ.js";
3
+ import { useQueryClient as pe, useQuery as f } from "@tanstack/react-query";
4
+ import { useState as q, useMemo as d, useCallback as y } from "react";
5
+ const be = "FormsTable-module_formsTableBody__SvGha", ge = "FormsTable-module_customAccordianItem__isszs", A = {
6
+ formsTableBody: be,
7
+ customAccordianItem: ge
8
+ }, Ne = (m) => m ? m.extension?.find(
9
+ (n) => n.url === ye
10
+ )?.valueString : void 0, Ie = ({
11
+ episodeOfCareUuids: m,
12
+ encounterUuids: n,
13
+ config: w
14
+ }) => {
15
+ const { t } = ee(), u = re(), [l, T] = q(!1), [o, O] = q(null), {
16
+ numberOfVisits: k,
17
+ hideThumbnail: H = !1,
18
+ forms: c
19
+ } = w ?? {}, I = ae(
20
+ m,
21
+ n
22
+ ), K = pe(), {
23
+ data: F = [],
24
+ isLoading: L,
25
+ isError: B,
26
+ error: Q,
27
+ refetch: j
28
+ } = f({
29
+ queryKey: ["forms", u, m],
30
+ queryFn: () => oe(u, void 0, k),
31
+ enabled: !!u && !I
32
+ }), C = d(() => {
33
+ let e = F;
34
+ return n && n.length > 0 && (e = e.filter(
35
+ (r) => n.includes(r.encounterUuid)
36
+ )), Array.isArray(c) && c.length > 0 && (e = e.filter(
37
+ (r) => c.some((a) => a.toLowerCase() === r.formName.toLowerCase())
38
+ )), e;
39
+ }, [F, n, c]), { data: E = [] } = f({
40
+ queryKey: ["observationForms"],
41
+ queryFn: () => te()
42
+ }), M = y(
43
+ (e) => E.find((r) => r.name === e)?.uuid,
44
+ [E]
45
+ ), p = d(() => {
46
+ if (o)
47
+ return M(o.formName);
48
+ }, [o, M]), {
49
+ isLoading: x,
50
+ isError: V,
51
+ error: b
52
+ } = f({
53
+ queryKey: ["formMetadata", p],
54
+ queryFn: () => se(p),
55
+ enabled: !!p && l
56
+ }), {
57
+ data: g,
58
+ isLoading: $,
59
+ isError: z,
60
+ error: N
61
+ } = f({
62
+ queryKey: ["formsEncounterFHIR", o?.encounterUuid],
63
+ queryFn: () => ne(o.encounterUuid),
64
+ enabled: !!o?.encounterUuid && l
65
+ });
66
+ de(
67
+ (e) => {
68
+ e.patientUUID === u && e.updatedConcepts.size > 0 && (j(), K.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
69
+ },
70
+ [u]
71
+ );
72
+ const G = d(() => !g?.entry || !o?.formName ? [] : g.entry.filter((e) => e.resource?.resourceType === "Observation").map((e) => e.resource).filter((e) => {
73
+ const r = Ne(e);
74
+ return !r || r.includes(o.formName);
75
+ }), [g, o?.formName]), J = d(() => {
76
+ if (b)
77
+ return S(b).message;
78
+ if (N)
79
+ return S(N).message;
80
+ }, [b, N]), R = d(
81
+ () => [
82
+ { key: "recordedOn", header: t("RECORDED_ON") },
83
+ { key: "recordedBy", header: t("RECORDED_BY") }
84
+ ],
85
+ [t]
86
+ ), Y = d(
87
+ () => [
88
+ { key: "recordedOn", sortable: !0 },
89
+ { key: "recordedBy", sortable: !0 }
90
+ ],
91
+ []
92
+ ), _ = d(() => {
93
+ const e = C.reduce(
94
+ (r, a) => {
95
+ const i = a.formName;
96
+ r[i] ??= [];
97
+ const h = a.providers.map((P) => P.providerName).filter(Boolean).join(", ");
98
+ return r[i].push({
99
+ id: a.encounterUuid,
100
+ formName: a.formName,
101
+ recordedOn: ie(a.encounterDateTime, t, !0).formattedResult,
102
+ recordedBy: h ?? "--",
103
+ encounterDateTime: a.encounterDateTime,
104
+ encounterUuid: a.encounterUuid
105
+ }), r;
106
+ },
107
+ {}
108
+ );
109
+ return Object.entries(e).map(
110
+ ([r, a]) => ({
111
+ formName: r,
112
+ records: a.sort(
113
+ (i, h) => h.encounterDateTime - i.encounterDateTime
114
+ )
115
+ })
116
+ ).sort((r, a) => r.formName.localeCompare(a.formName));
117
+ }, [C, t]), v = y((e) => {
118
+ O(e), T(!0);
119
+ }, []), X = y(() => {
120
+ T(!1), O(null);
121
+ }, []), D = y(
122
+ (e, r) => {
123
+ switch (r) {
124
+ case "recordedOn":
125
+ return /* @__PURE__ */ s(me, { onClick: () => v(e), children: e.recordedOn });
126
+ case "recordedBy":
127
+ return e.recordedBy;
128
+ default:
129
+ return null;
130
+ }
131
+ },
132
+ [v]
133
+ );
134
+ return /* @__PURE__ */ W(Z, { children: [
135
+ /* @__PURE__ */ s("div", { id: "forms-table", "data-testid": "forms-table", children: L || B || _.length === 0 || I ? /* @__PURE__ */ s(
136
+ U,
137
+ {
138
+ headers: R,
139
+ ariaLabel: t("FORMS_HEADING"),
140
+ rows: [],
141
+ loading: L,
142
+ errorStateMessage: B ? Q?.message : void 0,
143
+ emptyStateMessage: t("FORMS_UNAVAILABLE"),
144
+ renderCell: D,
145
+ className: A.formsTableBody,
146
+ dataTestId: "forms-table"
147
+ }
148
+ ) : /* @__PURE__ */ s(ue, { align: "start", children: _.map((e, r) => {
149
+ const { formName: a, records: i } = e;
150
+ return /* @__PURE__ */ s(
151
+ le,
152
+ {
153
+ title: a,
154
+ className: A.customAccordianItem,
155
+ testId: `accordian-title-${a}`,
156
+ open: r === 0,
157
+ children: /* @__PURE__ */ s(
158
+ U,
159
+ {
160
+ headers: R,
161
+ ariaLabel: t("FORMS_HEADING"),
162
+ rows: i,
163
+ loading: !1,
164
+ errorStateMessage: "",
165
+ sortable: Y,
166
+ emptyStateMessage: t("FORMS_UNAVAILABLE"),
167
+ renderCell: D,
168
+ className: A.formsTableBody,
169
+ dataTestId: `forms-table-${a}`
170
+ }
171
+ )
172
+ },
173
+ a
174
+ );
175
+ }) }) }),
176
+ l && o && /* @__PURE__ */ s(
177
+ ce,
178
+ {
179
+ id: "modalIdForActionAreaLayout",
180
+ portalId: "main-display-area",
181
+ open: l,
182
+ onRequestClose: X,
183
+ modalHeading: o.formName,
184
+ modalLabel: `${o.recordedOn} | ${o.recordedBy}`,
185
+ passiveModal: !0,
186
+ size: "md",
187
+ testId: "form-details-modal",
188
+ children: /* @__PURE__ */ s(
189
+ fe,
190
+ {
191
+ observations: G,
192
+ isLoading: x || $,
193
+ isError: V || z,
194
+ errorMessage: J,
195
+ emptyStateMessage: t("NO_FORM_DATA_AVAILABLE"),
196
+ testIdPrefix: o.formName,
197
+ hideThumbnail: H
198
+ }
199
+ )
200
+ }
201
+ )
202
+ ] });
203
+ };
204
+ export {
205
+ Ie as default
206
+ };
@@ -1,9 +1,9 @@
1
- import { c, T as l, P as m, a as v, D as u, Q as i } from "./YPM2AS64-bWTEzVUO.js";
2
- import { r as d, t as f, v as e } from "./index-CVOSTJhz.js";
3
- var p = (a) => {
1
+ import { c, T as l, P as m, a as u, D as v, Q as i } from "./YPM2AS64-DXiOE6PS.js";
2
+ import { p, q as d, r as e } from "./index-D8R0WjHJ.js";
3
+ var f = (a) => {
4
4
  const [r, t] = c({
5
5
  prefix: "TanstackQueryDevtools"
6
- }), n = d(), s = f(() => {
6
+ }), n = p(), s = d(() => {
7
7
  const o = r.theme_preference || l;
8
8
  return o !== "system" ? o : n();
9
9
  });
@@ -14,10 +14,10 @@ var p = (a) => {
14
14
  localStore: r,
15
15
  setLocalStore: t,
16
16
  get children() {
17
- return e(v.Provider, {
17
+ return e(u.Provider, {
18
18
  value: s,
19
19
  get children() {
20
- return e(u, {
20
+ return e(v, {
21
21
  localStore: r,
22
22
  setLocalStore: t
23
23
  });
@@ -27,7 +27,7 @@ var p = (a) => {
27
27
  });
28
28
  }
29
29
  });
30
- }, C = p;
30
+ }, C = f;
31
31
  export {
32
32
  C as default
33
33
  };
@@ -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-bWTEzVUO.js";
2
- import { r as v, t as C, v as e } from "./index-CVOSTJhz.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-DXiOE6PS.js";
2
+ import { p as v, q as C, r as e } from "./index-D8R0WjHJ.js";
3
3
  var h = (t) => {
4
4
  const [r, o] = s({
5
5
  prefix: "TanstackQueryDevtools"
@@ -36,7 +36,7 @@ var h = (t) => {
36
36
  });
37
37
  }
38
38
  });
39
- }, p = h;
39
+ }, g = h;
40
40
  export {
41
- p as default
41
+ g as default
42
42
  };