@bahmni/home-app 0.0.1-dev.465 → 0.0.1-dev.469

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