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