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