@bahmni/home-app 0.0.1-dev.268 → 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,112 +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, e as J, b as X, m as Z, c as ee, n as te } from "./index-Cb3jb-Bx.js";
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-DAATtEkD.js";
3
3
  import { useQuery as ae } from "@tanstack/react-query";
4
- import { useState as m, useCallback as p, useEffect as f, useMemo as T } from "react";
5
- 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 = {
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 = {
6
6
  documentsTableBody: ne,
7
7
  viewAttachmentsLink: oe,
8
8
  documentViewerContainer: re,
9
9
  attachmentItem: de,
10
10
  attachmentCounter: se,
11
11
  attachmentError: ce,
12
- documentIframe: ie,
13
- documentImage: me
14
- }, le = {
12
+ documentIframe: me,
13
+ documentImage: le
14
+ }, ue = {
15
15
  documentIdentifier: "DOCUMENTS_DOCUMENT_IDENTIFIER",
16
16
  documentType: "DOCUMENTS_TYPE",
17
17
  uploadedOn: "DOCUMENTS_UPLOADED_ON",
18
18
  uploadedBy: "DOCUMENTS_UPLOADED_BY",
19
19
  action: "DOCUMENTS_ACTION"
20
20
  };
21
- function j(a) {
21
+ function R(a) {
22
22
  return !a || a.includes(":") ? "#" : `/openmrs/auth?requested_document=/document_images/${a}`;
23
23
  }
24
- function ue(a, g) {
24
+ function ie(a, g) {
25
25
  return a.map((s) => ({
26
26
  key: s,
27
- header: g(le[s])
27
+ header: g(ue[s])
28
28
  }));
29
29
  }
30
- const _e = [
30
+ const Te = [
31
31
  "documentIdentifier",
32
32
  "documentType",
33
33
  "uploadedOn",
34
34
  "uploadedBy",
35
35
  "action"
36
- ], 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 }] : [], Ne = ({ config: a, encounterUuids: g }) => {
37
- 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(
38
38
  null
39
- ), [R, I] = m(
39
+ ), [$, D] = l(
40
40
  /* @__PURE__ */ new Set()
41
- ), 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) => {
42
- L(e), w(!0);
43
- }, []), F = p(() => {
44
- w(!1), L(null), I(/* @__PURE__ */ new Set());
45
- }, []), M = p((e) => {
46
- I((t) => new Set(t).add(e));
47
- }, []), { data: u, isLoading: H, isError: D, error: v } = ae({
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({
48
48
  queryKey: [
49
49
  "documents",
50
50
  E,
51
51
  g,
52
- C,
53
- l
52
+ f,
53
+ u
54
54
  ],
55
55
  enabled: !!E,
56
56
  queryFn: () => J(
57
57
  E,
58
58
  g,
59
- l,
60
- C
59
+ u,
60
+ f
61
61
  )
62
62
  });
63
- f(() => {
64
- u && y(u.total);
65
- }, [u]), f(() => {
66
- A(1), y(void 0);
67
- }, [E]), f(() => {
68
- D && U({
63
+ O(() => {
64
+ i && A(i.total);
65
+ }, [i]), O(() => {
66
+ C(1), A(void 0);
67
+ }, [E]), O(() => {
68
+ b && L({
69
69
  title: n("ERROR_DEFAULT_TITLE"),
70
- message: v?.message ?? "",
70
+ message: y?.message ?? "",
71
71
  type: "error"
72
72
  });
73
- }, [D, v, U, n]), f(() => {
73
+ }, [b, y, L, n]), O(() => {
74
74
  const e = new AbortController();
75
75
  return (async () => {
76
76
  if (!s || !o) return;
77
77
  const t = /* @__PURE__ */ new Set(), c = B(o);
78
- for (let i = 0; i < c.length; i++) {
79
- const S = j(c[i].url);
78
+ for (let m = 0; m < c.length; m++) {
79
+ const S = R(c[m].url);
80
80
  try {
81
81
  (await fetch(S, {
82
82
  method: "HEAD",
83
83
  signal: e.signal
84
- })).ok || t.add(i);
85
- } catch (O) {
86
- 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);
87
87
  }
88
88
  }
89
- e.signal.aborted || I(t);
89
+ e.signal.aborted || D(t);
90
90
  })(), () => e.abort();
91
91
  }, [s, o]);
92
- const q = p(
92
+ const j = h(
93
93
  (e, t) => {
94
- t !== l ? (k(t), A(1), y(void 0)) : A(e);
94
+ t !== u ? (V(t), C(1), A(void 0)) : C(e);
95
95
  },
96
- [l]
97
- ), N = T(
98
- () => a?.fields ?? _e,
96
+ [u]
97
+ ), I = _(
98
+ () => a?.fields ?? Te,
99
99
  [a?.fields]
100
- ), 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(
101
- () => 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) => ({
102
102
  key: e,
103
103
  sortable: e !== "action"
104
104
  })),
105
- [N]
106
- ), _ = T(
105
+ [I]
106
+ ), T = _(
107
107
  () => o ? B(o) : [],
108
108
  [o]
109
- ), G = p(
109
+ ), Q = h(
110
110
  (e, t) => {
111
111
  switch (t) {
112
112
  case "documentIdentifier":
@@ -125,7 +125,7 @@ const _e = [
125
125
  return e.attachments.length > 0 || e.documentUrl ? /* @__PURE__ */ r(
126
126
  X,
127
127
  {
128
- onClick: () => b(e),
128
+ onClick: () => M(e),
129
129
  className: d.viewAttachmentsLink,
130
130
  "data-testid": `view-attachments-${e.id}`,
131
131
  children: n("DOCUMENTS_VIEW_ATTACHMENTS")
@@ -135,9 +135,9 @@ const _e = [
135
135
  return null;
136
136
  }
137
137
  },
138
- [b, n]
138
+ [M, n]
139
139
  );
140
- return /* @__PURE__ */ h(Y, { children: [
140
+ return /* @__PURE__ */ p(x, { children: [
141
141
  /* @__PURE__ */ r("div", { "data-testid": "documents-table", children: /* @__PURE__ */ r(
142
142
  ee,
143
143
  {
@@ -145,16 +145,16 @@ const _e = [
145
145
  ariaLabel: n("DOCUMENTS_TABLE_HEADING"),
146
146
  rows: P,
147
147
  loading: H,
148
- errorStateMessage: D ? v?.message : null,
149
- sortable: x,
148
+ errorStateMessage: b ? y?.message : null,
149
+ sortable: K,
150
150
  emptyStateMessage: n("DOCUMENTS_NO_RECORDS"),
151
- renderCell: G,
151
+ renderCell: Q,
152
152
  className: d.documentsTableBody,
153
153
  dataTestId: "documents-table",
154
- pageSize: l,
155
- totalItems: V,
156
- page: C,
157
- onPageChange: q
154
+ pageSize: u,
155
+ totalItems: F,
156
+ page: f,
157
+ onPageChange: j
158
158
  }
159
159
  ) }),
160
160
  s && o && /* @__PURE__ */ r(
@@ -163,38 +163,38 @@ const _e = [
163
163
  id: "modalIdForActionAreaLayout",
164
164
  portalId: "main-display-area",
165
165
  open: s,
166
- onRequestClose: F,
166
+ onRequestClose: q,
167
167
  modalHeading: o.documentIdentifier,
168
168
  passiveModal: !0,
169
169
  size: "lg",
170
170
  testId: "document-view-modal",
171
- children: /* @__PURE__ */ r("div", { className: d.documentViewerContainer, children: _.map((e, t) => {
172
- 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);
173
- 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(
174
174
  "div",
175
175
  {
176
176
  className: d.attachmentError,
177
177
  "data-testid": `attachment-error-${t}`,
178
178
  children: [
179
- _.length > 1 && /* @__PURE__ */ h("p", { className: d.attachmentCounter, children: [
179
+ T.length > 1 && /* @__PURE__ */ p("p", { className: d.attachmentCounter, children: [
180
180
  t + 1,
181
181
  "/",
182
- _.length
182
+ T.length
183
183
  ] }),
184
184
  /* @__PURE__ */ r("p", { children: n("DOCUMENTS_ERROR_LOADING_ATTACHMENT") })
185
185
  ]
186
186
  },
187
187
  `${o.id}-${e.url}`
188
- ) : /* @__PURE__ */ h(
188
+ ) : /* @__PURE__ */ p(
189
189
  "div",
190
190
  {
191
191
  className: d.attachmentItem,
192
192
  "data-testid": `attachment-item-${t}`,
193
193
  children: [
194
- _.length > 1 && /* @__PURE__ */ h("p", { className: d.attachmentCounter, children: [
194
+ T.length > 1 && /* @__PURE__ */ p("p", { className: d.attachmentCounter, children: [
195
195
  t + 1,
196
196
  "/",
197
- _.length
197
+ T.length
198
198
  ] }),
199
199
  S ? /* @__PURE__ */ r(
200
200
  "img",
@@ -202,15 +202,15 @@ const _e = [
202
202
  src: c,
203
203
  alt: o.documentIdentifier,
204
204
  className: d.documentImage,
205
- onError: () => M(t)
205
+ onError: () => v(t)
206
206
  }
207
207
  ) : /* @__PURE__ */ r(
208
208
  "iframe",
209
209
  {
210
- src: i ? `${c}#toolbar=0` : c,
210
+ src: m ? `${c}#toolbar=0` : c,
211
211
  className: d.documentIframe,
212
212
  title: o.documentIdentifier,
213
- onError: () => M(t)
213
+ onError: () => v(t)
214
214
  }
215
215
  )
216
216
  ]
@@ -223,5 +223,5 @@ const _e = [
223
223
  ] });
224
224
  };
225
225
  export {
226
- Ne as default
226
+ Ie as default
227
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-DAATtEkD.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,5 +1,5 @@
1
- import { c, T as l, P as m, a as u, D as v, Q as i } from "./YPM2AS64-CE2Xp6XF.js";
2
- import { P as d, U as f, V as e } from "./index-Cb3jb-Bx.js";
1
+ import { c, T as l, P as m, a as u, D as v, Q as i } from "./YPM2AS64-B-ArbTgh.js";
2
+ import { U as d, V as f, W as e } from "./index-DAATtEkD.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-CE2Xp6XF.js";
2
- import { P as v, U as C, V as e } from "./index-Cb3jb-Bx.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-B-ArbTgh.js";
2
+ import { U as v, V as C, W as e } from "./index-DAATtEkD.js";
3
3
  var h = (t) => {
4
4
  const [r, o] = s({
5
5
  prefix: "TanstackQueryDevtools"