@bahmni/clinical-app 0.0.1-dev.310 → 0.0.1-dev.311

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