@bahmni/registration-app 0.0.1-dev.348 → 0.0.1-dev.349

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