@bahmni/registration-app 0.0.1-dev.306 → 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,234 +0,0 @@
1
- import { jsx as i, jsxs as re, Fragment as oe } from "react/jsx-runtime";
2
- import { u as te, h as ae, y as se, K as ne, W as de, q as ie, U as le, e as me, _ as q, a as ue, m as ce, c as H, T as fe, O as ye, o as he, J as be, F as pe } from "./index-NnRVGwAc.js";
3
- import { useQueryClient as ge, useQuery as h } from "@tanstack/react-query";
4
- import { useState as K, useMemo as d, useCallback as b } from "react";
5
- const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_customAccordianItem__isszs", T = {
6
- formsTableBody: Ne,
7
- customAccordianItem: Oe
8
- }, Ae = (u) => u ? u.extension?.find(
9
- (l) => l.url === pe
10
- )?.valueString : void 0, _e = ({
11
- episodeOfCareUuids: u,
12
- encounterUuids: l,
13
- config: k
14
- }) => {
15
- const { t: n } = te(), c = ae(), [f, F] = K(!1), [a, I] = K(null), {
16
- numberOfVisits: j,
17
- hideThumbnail: w = !1,
18
- forms: y
19
- } = k ?? {}, E = se(
20
- u,
21
- l
22
- ), x = ge(), {
23
- data: _ = [],
24
- isLoading: v,
25
- isError: B,
26
- error: V,
27
- refetch: $
28
- } = h({
29
- queryKey: ["forms", c, u],
30
- queryFn: () => ne(c, void 0, j),
31
- enabled: !!c && !E
32
- }), L = d(() => {
33
- let e = _;
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((o) => o.toLowerCase() === r.formName.toLowerCase())
38
- )), e;
39
- }, [_, l, y]), { data: M = [] } = h({
40
- queryKey: ["observationForms"],
41
- queryFn: () => de()
42
- }), S = b(
43
- (e) => M.find((r) => r.name === e)?.uuid,
44
- [M]
45
- ), p = d(() => {
46
- if (a)
47
- return S(a.formName);
48
- }, [a, S]), {
49
- data: m,
50
- isLoading: z,
51
- isError: G,
52
- error: g
53
- } = h({
54
- queryKey: ["formMetadata", p],
55
- queryFn: () => ie(p),
56
- enabled: !!p && f
57
- }), {
58
- data: N,
59
- isLoading: Q,
60
- isError: J,
61
- error: O
62
- } = h({
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 && ($(), x.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
70
- },
71
- [c]
72
- );
73
- const W = d(() => !N?.entry || !a?.formName ? [] : N.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
- }), [N, a?.formName]), P = d(() => {
77
- if (!m?.schema) return;
78
- const e = [], r = (o) => {
79
- (o ?? []).forEach((s) => {
80
- const t = s;
81
- t.id != null && e.push(String(t.id)), t.controls && r(t.controls);
82
- });
83
- };
84
- return r(
85
- m.schema.controls ?? []
86
- ), e.length > 0 ? e : void 0;
87
- }, [m]), Y = d(() => {
88
- if (!m?.schema) return;
89
- const e = {}, r = (o, s) => {
90
- for (const t of o)
91
- if (t.type === "section") {
92
- const A = t.label?.value ?? "Section";
93
- r(t.controls ?? [], A);
94
- } else
95
- t.id != null && s && (e[String(t.id)] = s), t.controls && r(t.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 (g)
103
- return q(g).message;
104
- if (O)
105
- return q(O).message;
106
- }, [g, O]), U = 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, o) => {
121
- const s = o.formName;
122
- r[s] ??= [];
123
- const t = o.providers.map((A) => A.providerName).filter(Boolean).join(", ");
124
- return r[s].push({
125
- id: o.encounterUuid,
126
- formName: o.formName,
127
- recordedOn: ue(o.encounterDateTime, n, !0).formattedResult,
128
- recordedBy: t ?? "--",
129
- encounterDateTime: o.encounterDateTime,
130
- encounterUuid: o.encounterUuid
131
- }), r;
132
- },
133
- {}
134
- );
135
- return Object.entries(e).map(
136
- ([r, o]) => ({
137
- formName: r,
138
- records: o.sort(
139
- (s, t) => t.encounterDateTime - s.encounterDateTime
140
- )
141
- })
142
- ).sort((r, o) => r.formName.localeCompare(o.formName));
143
- }, [L, n]), D = b((e) => {
144
- I(e), F(!0);
145
- }, []), ee = b(() => {
146
- F(!1), I(null);
147
- }, []), R = b(
148
- (e, r) => {
149
- switch (r) {
150
- case "recordedOn":
151
- return /* @__PURE__ */ i(ce, { onClick: () => D(e), children: e.recordedOn });
152
- case "recordedBy":
153
- return e.recordedBy;
154
- default:
155
- return null;
156
- }
157
- },
158
- [D]
159
- );
160
- return /* @__PURE__ */ re(oe, { children: [
161
- /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: v || B || C.length === 0 || E ? /* @__PURE__ */ i(
162
- H,
163
- {
164
- headers: U,
165
- ariaLabel: n("FORMS_HEADING"),
166
- rows: [],
167
- loading: v,
168
- errorStateMessage: B ? V?.message : void 0,
169
- emptyStateMessage: n("FORMS_UNAVAILABLE"),
170
- renderCell: R,
171
- className: T.formsTableBody,
172
- dataTestId: "forms-table"
173
- }
174
- ) : /* @__PURE__ */ i(fe, { align: "start", children: C.map((e, r) => {
175
- const { formName: o, records: s } = e;
176
- return /* @__PURE__ */ i(
177
- ye,
178
- {
179
- title: o,
180
- className: T.customAccordianItem,
181
- testId: `accordian-title-${o}`,
182
- open: r === 0,
183
- children: /* @__PURE__ */ i(
184
- H,
185
- {
186
- headers: U,
187
- ariaLabel: n("FORMS_HEADING"),
188
- rows: s,
189
- loading: !1,
190
- errorStateMessage: "",
191
- sortable: Z,
192
- emptyStateMessage: n("FORMS_UNAVAILABLE"),
193
- renderCell: R,
194
- className: T.formsTableBody,
195
- dataTestId: `forms-table-${o}`
196
- }
197
- )
198
- },
199
- o
200
- );
201
- }) }) }),
202
- f && a && /* @__PURE__ */ i(
203
- he,
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
- be,
216
- {
217
- observations: W,
218
- isLoading: z || Q,
219
- isError: G || J,
220
- errorMessage: X,
221
- emptyStateMessage: n("NO_FORM_DATA_AVAILABLE"),
222
- testIdPrefix: a.formName,
223
- hideThumbnail: w,
224
- controlOrder: P,
225
- sectionMap: Y
226
- }
227
- )
228
- }
229
- )
230
- ] });
231
- };
232
- export {
233
- _e as default
234
- };