@bahmni/clinical-app 0.0.1-dev.101 → 0.0.1-dev.103

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,259 @@
1
+ import { jsx as e, jsxs as _, Fragment as K } from "react/jsx-runtime";
2
+ import { u as Q, C as J, a as p, b as X, V as z, Q as S, A as Y, _ as W, l as Z, E as ee, t as I, G as re, e as ae, X as oe, c as ne, J as te } from "./index-Bcg37FwC.js";
3
+ import { useState as U, useMemo as u, useCallback as f } from "react";
4
+ import { createPortal as se } from "react-dom";
5
+ const de = "_formsTableBody_ua0cn_1", me = "_customAccordianItem_ua0cn_6", ie = "_formContent_ua0cn_18", ce = "_formDetailsContainer_ua0cn_25", le = "_observation_ua0cn_30", ue = "_groupContainer_ua0cn_39", _e = "_rowContainer_ua0cn_43", be = "_groupLabel_ua0cn_48", pe = "_rowLabel_ua0cn_58", fe = "_rowValue_ua0cn_67", he = "_groupMembers_ua0cn_75", Ne = "_memberRow_ua0cn_81", ge = "_memberLabel_ua0cn_86", ye = "_memberValue_ua0cn_94", ve = "_commentSection_ua0cn_102", Me = "_commentText_ua0cn_108", Ce = "_nestedGroup_ua0cn_117", Le = "_nestedGroupLabel_ua0cn_124", Ae = "_nestedGroupMembers_ua0cn_133", o = {
6
+ formsTableBody: de,
7
+ customAccordianItem: me,
8
+ formContent: ie,
9
+ formDetailsContainer: ce,
10
+ observation: le,
11
+ groupContainer: ue,
12
+ rowContainer: _e,
13
+ groupLabel: be,
14
+ rowLabel: pe,
15
+ rowValue: fe,
16
+ groupMembers: he,
17
+ memberRow: Ne,
18
+ memberLabel: ge,
19
+ memberValue: ye,
20
+ commentSection: ve,
21
+ commentText: Me,
22
+ nestedGroup: Ce,
23
+ nestedGroupLabel: Le,
24
+ nestedGroupMembers: Ae
25
+ }, V = ({
26
+ member: r,
27
+ depth: m = 0
28
+ }) => {
29
+ const i = r.groupMembers && r.groupMembers.length > 0, n = r.conceptNameToDisplay ?? r.concept?.shortName ?? r.concept?.name;
30
+ return i ? /* @__PURE__ */ _("div", { className: o.nestedGroup, children: [
31
+ /* @__PURE__ */ e(
32
+ "div",
33
+ {
34
+ className: o.nestedGroupLabel,
35
+ style: { paddingLeft: `${m * 16}px` },
36
+ children: n
37
+ }
38
+ ),
39
+ /* @__PURE__ */ e("div", { className: o.nestedGroupMembers, children: r.groupMembers?.map((c, b) => /* @__PURE__ */ e(
40
+ V,
41
+ {
42
+ member: c,
43
+ depth: m + 1
44
+ },
45
+ `${c.concept.uuid}`
46
+ )) })
47
+ ] }) : /* @__PURE__ */ _(
48
+ "div",
49
+ {
50
+ className: o.memberRow,
51
+ style: { paddingLeft: `${m * 16}px` },
52
+ children: [
53
+ /* @__PURE__ */ e("p", { className: o.memberLabel, children: n }),
54
+ /* @__PURE__ */ e("p", { className: o.memberValue, children: r.valueAsString })
55
+ ]
56
+ }
57
+ );
58
+ }, Oe = ({
59
+ observation: r,
60
+ index: m
61
+ }) => {
62
+ const i = r.groupMembers && r.groupMembers.length > 0;
63
+ return /* @__PURE__ */ _(
64
+ "div",
65
+ {
66
+ className: o.observation,
67
+ children: [
68
+ /* @__PURE__ */ _(
69
+ "div",
70
+ {
71
+ className: i ? o.groupContainer : o.rowContainer,
72
+ children: [
73
+ /* @__PURE__ */ e("p", { className: i ? o.groupLabel : o.rowLabel, children: r.conceptNameToDisplay }),
74
+ i ? /* @__PURE__ */ e("div", { className: o.groupMembers, children: r.groupMembers?.map((n, c) => /* @__PURE__ */ e(
75
+ V,
76
+ {
77
+ member: n,
78
+ depth: 0
79
+ },
80
+ `${n.concept.uuid}`
81
+ )) }) : /* @__PURE__ */ e("p", { className: o.rowValue, children: r.valueAsString })
82
+ ]
83
+ }
84
+ ),
85
+ r.comment && /* @__PURE__ */ e("div", { className: o.commentSection, children: /* @__PURE__ */ _("span", { className: o.commentText, children: [
86
+ r.comment,
87
+ r.providers?.[0]?.name && ` - by ${r.providers[0].name}`
88
+ ] }) })
89
+ ]
90
+ },
91
+ `${r.concept.uuid}-${m}`
92
+ );
93
+ }, Ge = ({
94
+ episodeOfCareUuids: r,
95
+ encounterUuids: m,
96
+ config: i
97
+ }) => {
98
+ const { t: n } = Q(), c = J(), [b, v] = U(!1), [d, M] = U(null), $ = i?.numberOfVisits, {
99
+ data: h = [],
100
+ isLoading: C,
101
+ isError: L,
102
+ error: q
103
+ } = p({
104
+ queryKey: ["forms", c, r],
105
+ queryFn: () => ae(c, void 0, $),
106
+ enabled: !!c
107
+ }), A = u(() => !m || m.length === 0 ? h : h.filter(
108
+ (a) => m.includes(a.encounterUuid)
109
+ ), [h, m]), { data: O = [] } = p({
110
+ queryKey: ["observationForms"],
111
+ queryFn: oe
112
+ }), R = f(
113
+ (a) => O.find((t) => t.name === a)?.uuid,
114
+ [O]
115
+ ), N = u(() => {
116
+ if (d)
117
+ return R(d.formName);
118
+ }, [d, R]), {
119
+ data: Re,
120
+ isLoading: x,
121
+ error: T
122
+ } = p({
123
+ queryKey: ["formMetadata", N],
124
+ queryFn: () => ne(N),
125
+ enabled: !!N && b
126
+ }), {
127
+ data: g,
128
+ isLoading: k,
129
+ error: D
130
+ } = p({
131
+ queryKey: ["formsEncounter", d?.encounterUuid],
132
+ queryFn: () => te(d.encounterUuid, !0),
133
+ enabled: !!d?.encounterUuid && b
134
+ }), F = u(() => !g?.observations || !d?.formName ? [] : g.observations.filter(
135
+ (a) => "formFieldPath" in a && typeof a.formFieldPath == "string" && a.formFieldPath.includes(d.formName)
136
+ ), [g?.observations, d?.formName]), E = u(
137
+ () => [
138
+ { key: "recordedOn", header: n("FORM_RECORDED_ON") },
139
+ { key: "recordedBy", header: n("FORM_RECORDED_BY") }
140
+ ],
141
+ [n]
142
+ ), H = u(
143
+ () => [
144
+ { key: "recordedOn", sortable: !0 },
145
+ { key: "recordedBy", sortable: !0 }
146
+ ],
147
+ []
148
+ ), G = u(() => {
149
+ const a = A.reduce(
150
+ (t, s) => {
151
+ const l = s.formName;
152
+ t[l] ??= [];
153
+ const y = s.providers.map((P) => P.providerName).filter(Boolean).join(", ");
154
+ return t[l].push({
155
+ id: s.encounterUuid,
156
+ formName: s.formName,
157
+ recordedOn: X(s.encounterDateTime, n, re).formattedResult,
158
+ recordedBy: y ?? "--",
159
+ encounterDateTime: s.encounterDateTime,
160
+ encounterUuid: s.encounterUuid
161
+ }), t;
162
+ },
163
+ {}
164
+ );
165
+ return Object.entries(a).map(
166
+ ([t, s]) => ({
167
+ formName: t,
168
+ records: s.sort(
169
+ (l, y) => y.encounterDateTime - l.encounterDateTime
170
+ )
171
+ })
172
+ ).sort((t, s) => t.formName.localeCompare(s.formName));
173
+ }, [A, n]), w = f((a) => {
174
+ M(a), v(!0);
175
+ }, []), j = f(() => {
176
+ v(!1), M(null);
177
+ }, []), B = f(
178
+ (a, t) => {
179
+ switch (t) {
180
+ case "recordedOn":
181
+ return /* @__PURE__ */ e(z, { onClick: () => w(a), children: a.recordedOn });
182
+ case "recordedBy":
183
+ return a.recordedBy;
184
+ default:
185
+ return null;
186
+ }
187
+ },
188
+ [w]
189
+ );
190
+ return /* @__PURE__ */ _(K, { children: [
191
+ /* @__PURE__ */ e("div", { "data-testid": "forms-table", children: C || L || G.length === 0 ? /* @__PURE__ */ e(
192
+ S,
193
+ {
194
+ headers: E,
195
+ ariaLabel: n("FORMS_HEADING"),
196
+ rows: [],
197
+ loading: C,
198
+ errorStateMessage: L ? q?.message : void 0,
199
+ emptyStateMessage: n("FORMS_UNAVAILABLE"),
200
+ renderCell: B,
201
+ className: o.formsTableBody,
202
+ "data-testid": "sortable-data-table"
203
+ }
204
+ ) : /* @__PURE__ */ e(Y, { align: "start", children: G.map((a, t) => {
205
+ const { formName: s, records: l } = a;
206
+ return /* @__PURE__ */ e(
207
+ W,
208
+ {
209
+ title: s,
210
+ className: o.customAccordianItem,
211
+ testId: "accordian-table-title",
212
+ open: t === 0,
213
+ children: /* @__PURE__ */ e(
214
+ S,
215
+ {
216
+ headers: E,
217
+ ariaLabel: n("FORMS_HEADING"),
218
+ rows: l,
219
+ loading: !1,
220
+ errorStateMessage: "",
221
+ sortable: H,
222
+ emptyStateMessage: n("FORMS_UNAVAILABLE"),
223
+ renderCell: B,
224
+ className: o.formsTableBody,
225
+ "data-testid": "sortable-data-table"
226
+ }
227
+ )
228
+ },
229
+ s
230
+ );
231
+ }) }) }),
232
+ b && d && se(
233
+ /* @__PURE__ */ e(
234
+ Z,
235
+ {
236
+ open: b,
237
+ onRequestClose: j,
238
+ modalHeading: d.formName,
239
+ modalLabel: `${d.recordedOn} | ${d.recordedBy}`,
240
+ passiveModal: !0,
241
+ size: "md",
242
+ testId: "form-details-modal",
243
+ children: /* @__PURE__ */ e("div", { className: o.formContent, children: x || k ? /* @__PURE__ */ e(ee, { width: "100%", lineCount: 3 }) : T ? /* @__PURE__ */ e("div", { children: I(T).message ?? n("ERROR_FETCHING_FORM_METADATA") }) : D ? /* @__PURE__ */ e("div", { children: I(D).message ?? n("ERROR_FETCHING_FORM_DATA") }) : F.length > 0 ? /* @__PURE__ */ e("div", { className: o.formDetailsContainer, children: F.map((a, t) => /* @__PURE__ */ e(
244
+ Oe,
245
+ {
246
+ observation: a,
247
+ index: t
248
+ },
249
+ `${a.concept.uuid}`
250
+ )) }) : /* @__PURE__ */ e("div", { children: n("NO_FORM_DATA_AVAILABLE") }) })
251
+ }
252
+ ),
253
+ document.getElementById("actionAreaLayout") ?? document.body
254
+ )
255
+ ] });
256
+ };
257
+ export {
258
+ Ge as default
259
+ };
@@ -1,5 +1,5 @@
1
- import { c, T as l, P as m, a as u, D as v, Q as i } from "./YPM2AS64-DmFd1py5.js";
2
- import { g as d, c as f, a as e } from "./index-D0T3DBL7.js";
1
+ import { c, T as l, P as m, a as u, D as v, Q as i } from "./YPM2AS64-Bs9kvYd3.js";
2
+ import { g as d, d as f, f as e } from "./index-Bcg37FwC.js";
3
3
  var p = (a) => {
4
4
  const [r, t] = c({
5
5
  prefix: "TanstackQueryDevtools"
@@ -1,13 +1,13 @@
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-DmFd1py5.js";
2
- import { g as v, c as C, a as e } from "./index-D0T3DBL7.js";
3
- var h = (t) => {
1
+ import { c as s, T as c, P as u, a as i, b as m, C as d, Q as P } from "./YPM2AS64-Bs9kvYd3.js";
2
+ import { g as v, d as C, f as e } from "./index-Bcg37FwC.js";
3
+ var f = (t) => {
4
4
  const [r, o] = s({
5
5
  prefix: "TanstackQueryDevtools"
6
6
  }), a = v(), l = C(() => {
7
7
  const n = r.theme_preference || c;
8
8
  return n !== "system" ? n : a();
9
9
  });
10
- return e(d.Provider, {
10
+ return e(P.Provider, {
11
11
  value: t,
12
12
  get children() {
13
13
  return e(u, {
@@ -20,7 +20,7 @@ var h = (t) => {
20
20
  get children() {
21
21
  return e(m, {
22
22
  get children() {
23
- return e(P, {
23
+ return e(d, {
24
24
  localStore: r,
25
25
  setLocalStore: o,
26
26
  get onClose() {
@@ -36,7 +36,7 @@ var h = (t) => {
36
36
  });
37
37
  }
38
38
  });
39
- }, p = h;
39
+ }, p = f;
40
40
  export {
41
41
  p as default
42
42
  };
@@ -1,4 +1,4 @@
1
- import { b as we, d as z, o as xt, e as B, c as q, a as y, P as Ro, m as ye, S as R, t as _, i as k, f as N, h as A, j as bs, k as ir, u as $e, l as U, s as Hn, n as Vn, p as dt, q as D, r as xs, v as cn, w as Be, x as ws, y as qt, z as zt, A as $s, B as Cs, C as $n, F as Ss, D as Nr, E as Bt, $ as zo, G as ks, H as Es, I as j, J as Ur, K as Ms, L as Ds, M as sr, N as As, O as Ts, Q as zn, R as Fs, T as Is, U as Z, V as Ps, W as Ls } from "./index-D0T3DBL7.js";
1
+ import { h as we, i as z, o as xt, j as B, d as q, f as y, P as Ro, m as ye, S as R, k as _, n as k, p as N, q as A, r as bs, s as ir, v as $e, w as U, x as Hn, y as Vn, z as dt, B as D, D as xs, F as cn, H as Be, I as ws, K as qt, L as zt, M as $s, N as Cs, O as $n, R as Ss, T as Nr, U as Bt, $ as zo, W as ks, Y as Es, Z as j, a0 as Ur, a1 as Ms, a2 as Ds, a3 as sr, a4 as As, a5 as Ts, a6 as zn, a7 as Fs, a8 as Is, a9 as Z, aa as Ps, ab as Ls } from "./index-Bcg37FwC.js";
2
2
  var Os = (e) => e != null, qs = (e) => e.filter(Os);
3
3
  function _s(e) {
4
4
  return (...t) => {