@bahmni/widgets 0.0.1-dev.409 → 0.0.1-dev.410

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,5 +1,5 @@
1
1
  import { jsx as r, jsxs as T, Fragment as Y } from "react/jsx-runtime";
2
- import { u as W, a as X, F as J, V as Z, Q as x, b as ee, c as te } from "./index-CxgzK6B5.js";
2
+ import { u as W, a as X, F as J, V as Z, Q as x, b as ee, c as te } from "./index-B4RtTGnL.js";
3
3
  import { useQuery as ne } from "@tanstack/react-query";
4
4
  import { useState as l, useCallback as _, useEffect as I, useMemo as p } from "react";
5
5
  import { useTranslation as ae } from "react-i18next";
@@ -0,0 +1,273 @@
1
+ import { jsx as n, jsxs as j, Fragment as ge } from "react/jsx-runtime";
2
+ import { u as pe, d as Ne, e as Oe, y as Ee, g as Te, p as Fe, h as Ie, J as ve, D as Ae, f as _e, i as De, j as Re, Y as G, Q as Me, C as K, B as Q, V as Le, b as z, r as Be, k as Se, c as Ce, O as Ue, l as we } from "./index-B4RtTGnL.js";
3
+ import { useQueryClient as ke, useQuery as N } from "@tanstack/react-query";
4
+ import { useState as Y, useMemo as i, useCallback as d } from "react";
5
+ import { useTranslation as He } from "react-i18next";
6
+ const Ve = "FormsTable-module_formsTableBody__SvGha", qe = "FormsTable-module_modalHeading__wnTmA", Pe = "FormsTable-module_customAccordianItem__isszs", O = {
7
+ formsTableBody: Ve,
8
+ modalHeading: qe,
9
+ customAccordianItem: Pe
10
+ }, xe = "startConsultation", ze = ({
11
+ episodeOfCareUuids: D,
12
+ encounterUuids: m,
13
+ config: J,
14
+ disableActions: W = !1,
15
+ activeEncounterUuid: y = null
16
+ }) => {
17
+ const { t: s } = He(), c = pe(), [h, R] = Y(!1), [o, M] = Y(null), {
18
+ numberOfVisits: X,
19
+ hideThumbnail: Z = !1,
20
+ forms: b
21
+ } = J ?? {}, ee = Ne(
22
+ we.EDIT_OBSERVATIONS
23
+ ), { userPrivileges: g } = Oe(), E = ee && !W && !!y, L = Ee(
24
+ D,
25
+ m
26
+ ), re = ke(), {
27
+ data: B = [],
28
+ isLoading: S,
29
+ isError: C,
30
+ error: te,
31
+ refetch: ae
32
+ } = N({
33
+ queryKey: ["forms", c, D],
34
+ queryFn: () => Te(c, void 0, X),
35
+ enabled: !!c && !L
36
+ }), U = i(() => {
37
+ let e = B;
38
+ return m && m.length > 0 && (e = e.filter(
39
+ (r) => m.includes(r.encounterUuid)
40
+ )), Array.isArray(b) && b.length > 0 && (e = e.filter(
41
+ (r) => b.some((t) => t.toLowerCase() === r.formName.toLowerCase())
42
+ )), e;
43
+ }, [B, m, b]), { data: p = [] } = N({
44
+ queryKey: ["observationForms"],
45
+ queryFn: () => Fe()
46
+ }), w = d(
47
+ (e) => {
48
+ const r = p.find((a) => a.name === e);
49
+ if (!r?.privileges || r.privileges.length === 0) return !0;
50
+ if (!g || g.length === 0) return !1;
51
+ const t = new Set(g.map((a) => a.name));
52
+ return r.privileges.some(
53
+ (a) => t.has(a.privilegeName) && a.editable
54
+ );
55
+ },
56
+ [p, g]
57
+ ), u = d(
58
+ (e) => !y || e.encounterUuid !== y ? !1 : w(e.formName),
59
+ [y, w]
60
+ ), k = d(
61
+ (e) => p.find((t) => t.name === e)?.uuid,
62
+ [p]
63
+ ), T = i(() => {
64
+ if (o)
65
+ return k(o.formName);
66
+ }, [o, k]), {
67
+ data: H,
68
+ isLoading: oe,
69
+ isError: se,
70
+ error: F
71
+ } = N({
72
+ queryKey: ["formMetadata", T],
73
+ queryFn: () => Ie(T),
74
+ enabled: !!T && h
75
+ }), {
76
+ data: I,
77
+ isLoading: ne,
78
+ isError: ie,
79
+ error: v
80
+ } = N({
81
+ queryKey: ["formsEncounterFHIR", o?.encounterUuid],
82
+ queryFn: () => ve(o.encounterUuid),
83
+ enabled: !!o?.encounterUuid && h
84
+ });
85
+ Ae(
86
+ (e) => {
87
+ e.patientUUID === c && (ae(), re.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
88
+ },
89
+ [c]
90
+ );
91
+ const de = i(() => !I?.entry || !o?.formName ? [] : I.entry.filter((r) => r.resource?.resourceType === "Observation").map((r) => r.resource).filter((r) => _e(r) ? De(r)?.toLowerCase() === o.formName.toLowerCase() : !0), [I, o?.formName]), { controlOrder: le, sectionMap: me, conceptDatatypeMap: ce } = i(
92
+ () => Re(H?.schema),
93
+ [H]
94
+ ), ue = i(() => {
95
+ if (F)
96
+ return G(F).message;
97
+ if (v)
98
+ return G(v).message;
99
+ }, [F, v]), f = i(
100
+ () => [
101
+ { key: "recordedOn", header: s("RECORDED_ON") },
102
+ { key: "recordedBy", header: s("RECORDED_BY") }
103
+ ],
104
+ [s]
105
+ ), V = i(
106
+ () => [...f, { key: "actions", header: s("ACTIONS") }],
107
+ [f, s]
108
+ ), fe = d(
109
+ (e) => E && e.some((t) => u(t)) ? V : f,
110
+ [E, u, V, f]
111
+ ), ye = f, he = i(
112
+ () => [
113
+ { key: "recordedOn", sortable: !0 },
114
+ { key: "recordedBy", sortable: !0 }
115
+ ],
116
+ []
117
+ ), q = i(() => {
118
+ const e = U.reduce(
119
+ (t, a) => {
120
+ const l = a.formName;
121
+ t[l] ??= [];
122
+ const _ = a.providers.map((be) => be.providerName).filter(Boolean).join(", ");
123
+ return t[l].push({
124
+ id: a.encounterUuid,
125
+ formName: a.formName,
126
+ recordedOn: Me(a.encounterDateTime, s, !0).formattedResult,
127
+ recordedBy: _ ?? "--",
128
+ encounterDateTime: a.encounterDateTime,
129
+ encounterUuid: a.encounterUuid
130
+ }), t;
131
+ },
132
+ {}
133
+ );
134
+ return Object.entries(e).map(
135
+ ([t, a]) => ({
136
+ formName: t,
137
+ records: a.sort(
138
+ (l, _) => _.encounterDateTime - l.encounterDateTime
139
+ )
140
+ })
141
+ ).sort((t, a) => t.formName.localeCompare(a.formName));
142
+ }, [U, s]), P = d((e) => {
143
+ M(e), R(!0);
144
+ }, []), x = d(() => {
145
+ R(!1), M(null);
146
+ }, []), A = d((e) => {
147
+ globalThis.dispatchEvent(
148
+ new CustomEvent(xe, {
149
+ detail: {
150
+ editOnly: "observationForms",
151
+ editTitle: "EDIT_OBSERVATION_FORM_TITLE",
152
+ sourceEncounterUuid: e.encounterUuid,
153
+ formName: e.formName,
154
+ directFormMode: !0
155
+ }
156
+ })
157
+ );
158
+ }, []), $ = d(
159
+ (e, r) => {
160
+ switch (r) {
161
+ case "recordedOn":
162
+ return /* @__PURE__ */ n(Le, { onClick: () => P(e), children: e.recordedOn });
163
+ case "recordedBy":
164
+ return e.recordedBy;
165
+ case "actions":
166
+ return u(e) ? /* @__PURE__ */ n(
167
+ K,
168
+ {
169
+ label: s("EDIT_OBSERVATION_FORM"),
170
+ kind: "ghost",
171
+ size: "sm",
172
+ testId: `edit-form-${e.encounterUuid}`,
173
+ onClick: () => A(e),
174
+ children: /* @__PURE__ */ n(Q, {})
175
+ }
176
+ ) : null;
177
+ default:
178
+ return null;
179
+ }
180
+ },
181
+ [P, A, u, s]
182
+ );
183
+ return /* @__PURE__ */ j(ge, { children: [
184
+ /* @__PURE__ */ n("div", { id: "forms-table", "data-testid": "forms-table", children: S || C || q.length === 0 || L ? /* @__PURE__ */ n(
185
+ z,
186
+ {
187
+ headers: ye,
188
+ ariaLabel: s("FORMS_HEADING"),
189
+ rows: [],
190
+ loading: S,
191
+ errorStateMessage: C ? te?.message : void 0,
192
+ emptyStateMessage: s("FORMS_UNAVAILABLE"),
193
+ renderCell: $,
194
+ className: O.formsTableBody,
195
+ dataTestId: "forms-table"
196
+ }
197
+ ) : /* @__PURE__ */ n(Be, { align: "start", children: q.map((e, r) => {
198
+ const { formName: t, records: a } = e, l = fe(a);
199
+ return /* @__PURE__ */ n(
200
+ Se,
201
+ {
202
+ title: t,
203
+ className: O.customAccordianItem,
204
+ testId: `accordian-title-${t}`,
205
+ open: r === 0,
206
+ children: /* @__PURE__ */ n(
207
+ z,
208
+ {
209
+ headers: l,
210
+ ariaLabel: s("FORMS_HEADING"),
211
+ rows: a,
212
+ loading: !1,
213
+ errorStateMessage: "",
214
+ sortable: he,
215
+ emptyStateMessage: s("FORMS_UNAVAILABLE"),
216
+ renderCell: $,
217
+ className: O.formsTableBody,
218
+ dataTestId: `forms-table-${t}`
219
+ }
220
+ )
221
+ },
222
+ t
223
+ );
224
+ }) }) }),
225
+ h && o && /* @__PURE__ */ n(
226
+ Ce,
227
+ {
228
+ id: "modalIdForActionAreaLayout",
229
+ portalId: "main-display-area",
230
+ open: h,
231
+ onRequestClose: x,
232
+ modalHeading: /* @__PURE__ */ j("div", { className: O.modalHeading, children: [
233
+ /* @__PURE__ */ n("span", { children: o.formName }),
234
+ E && u(o) && /* @__PURE__ */ n(
235
+ K,
236
+ {
237
+ label: s("EDIT_OBSERVATION_FORM"),
238
+ kind: "ghost",
239
+ size: "sm",
240
+ testId: `edit-form-modal-${o.encounterUuid}`,
241
+ onClick: () => {
242
+ x(), A(o);
243
+ },
244
+ children: /* @__PURE__ */ n(Q, {})
245
+ }
246
+ )
247
+ ] }),
248
+ modalLabel: `${o.recordedOn} | ${o.recordedBy}`,
249
+ passiveModal: !0,
250
+ size: "md",
251
+ testId: "form-details-modal",
252
+ children: /* @__PURE__ */ n(
253
+ Ue,
254
+ {
255
+ observations: de,
256
+ isLoading: oe || ne,
257
+ isError: se || ie,
258
+ errorMessage: ue,
259
+ emptyStateMessage: s("NO_FORM_DATA_AVAILABLE"),
260
+ testIdPrefix: o.formName,
261
+ hideThumbnail: Z,
262
+ controlOrder: le,
263
+ sectionMap: me,
264
+ conceptDatatypeMap: ce
265
+ }
266
+ )
267
+ }
268
+ )
269
+ ] });
270
+ };
271
+ export {
272
+ ze as default
273
+ };
@@ -1,5 +1,5 @@
1
1
  import { jsx as i, jsxs as S } from "react/jsx-runtime";
2
- import { l as k, m as F, t as z, G as H, Q as P, n as j, T as x, R as J, S as Y, u as W, a as X, A as Z, y as ee, K as se, o as te, D as re, q as ae, s as oe, v as ne, w as ie, x as ce, b as le } from "./index-CxgzK6B5.js";
2
+ import { m as k, n as F, t as z, G as H, Q as P, o as j, T as x, R as J, S as Y, u as W, a as X, A as Z, y as ee, K as se, q as te, D as re, s as ae, v as oe, w as ne, x as ie, z as ce, b as le } from "./index-B4RtTGnL.js";
3
3
  import { useQueries as de, useQuery as ue } from "@tanstack/react-query";
4
4
  import { useRef as pe, useEffect as C, useMemo as I } from "react";
5
5
  import { useTranslation as w } from "react-i18next";
@@ -1 +1 @@
1
- {"version":3,"file":"FormsTable.d.ts","sourceRoot":"","sources":["../../src/forms/FormsTable.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAI9D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAehD,uEAAuE;AACvE,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA8drC,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"FormsTable.d.ts","sourceRoot":"","sources":["../../src/forms/FormsTable.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAI9D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAgBhD,uEAAuE;AACvE,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAwZrC,CAAC;AAEF,eAAe,UAAU,CAAC"}