@bahmni/widgets 0.0.1-dev.299 → 0.0.1-dev.302

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,5 +1,5 @@
1
1
  import { jsx as r, jsxs as T, Fragment as Y } from "react/jsx-runtime";
2
- import { u as W, a as X, T as J, t as Z, A as x, i as ee, I as te } from "./index-BxDZltVB.js";
2
+ import { u as W, a as X, T as J, t as Z, A as x, i as ee, I as te } from "./index-DFn3IxWh.js";
3
3
  import { useQuery as ne } from "@tanstack/react-query";
4
4
  import { useState as l, useCallback as _, useEffect as g, useMemo as p } from "react";
5
5
  import { useTranslation as ae } from "react-i18next";
@@ -0,0 +1,235 @@
1
+ import { jsx as i, jsxs as te, Fragment as oe } from "react/jsx-runtime";
2
+ import { Q as se, u as ae, V as ne, n as de, b as ie, r as ce, q as le, y as me, M as k, A as ue, t as fe, i as x, X as ye, c as be, I as pe, O as he } from "./index-DFn3IxWh.js";
3
+ import { useQueryClient as ge, useQuery as p } from "@tanstack/react-query";
4
+ import { useState as w, useMemo as d, useCallback as h } from "react";
5
+ import { useTranslation as Fe } from "react-i18next";
6
+ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_customAccordianItem__isszs", v = {
7
+ formsTableBody: Ne,
8
+ customAccordianItem: Oe
9
+ }, Ee = (m) => m ? m.extension?.find(
10
+ (g) => g.url === se
11
+ )?.valueString : void 0, Be = ({
12
+ episodeOfCareUuids: m,
13
+ encounterUuids: c,
14
+ config: g
15
+ }) => {
16
+ const { t: n } = Fe(), u = ae(), [y, I] = w(!1), [a, M] = w(null), {
17
+ numberOfVisits: P,
18
+ hideThumbnail: Q = !1,
19
+ forms: b
20
+ } = g ?? {}, A = ne(
21
+ m,
22
+ c
23
+ ), V = ge(), {
24
+ data: D = [],
25
+ isLoading: B,
26
+ isError: T,
27
+ error: j,
28
+ refetch: H
29
+ } = p({
30
+ queryKey: ["forms", u, m],
31
+ queryFn: () => de(u, void 0, P),
32
+ enabled: !!u && !A
33
+ }), _ = d(() => {
34
+ let e = D;
35
+ return c && c.length > 0 && (e = e.filter(
36
+ (t) => c.includes(t.encounterUuid)
37
+ )), Array.isArray(b) && b.length > 0 && (e = e.filter(
38
+ (t) => b.some((r) => r.toLowerCase() === t.formName.toLowerCase())
39
+ )), e;
40
+ }, [D, c, b]), { data: L = [] } = p({
41
+ queryKey: ["observationForms"],
42
+ queryFn: () => ie()
43
+ }), R = h(
44
+ (e) => L.find((r) => r.name === e)?.uuid,
45
+ [L]
46
+ ), F = d(() => {
47
+ if (a)
48
+ return R(a.formName);
49
+ }, [a, R]), {
50
+ data: l,
51
+ isLoading: K,
52
+ isError: $,
53
+ error: N
54
+ } = p({
55
+ queryKey: ["formMetadata", F],
56
+ queryFn: () => ce(F),
57
+ enabled: !!F && y
58
+ }), {
59
+ data: O,
60
+ isLoading: z,
61
+ isError: G,
62
+ error: E
63
+ } = p({
64
+ queryKey: ["formsEncounterFHIR", a?.encounterUuid],
65
+ queryFn: () => le(a.encounterUuid),
66
+ enabled: !!a?.encounterUuid && y
67
+ });
68
+ me(
69
+ (e) => {
70
+ e.patientUUID === u && e.updatedConcepts.size > 0 && (H(), V.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
71
+ },
72
+ [u]
73
+ );
74
+ const X = d(() => !O?.entry || !a?.formName ? [] : O.entry.filter((t) => t.resource?.resourceType === "Observation").map((t) => t.resource).filter((t) => {
75
+ const r = Ee(t);
76
+ return !r || r.includes(a.formName);
77
+ }), [O, a?.formName]), Y = d(() => {
78
+ if (!l?.schema) return;
79
+ const e = [], t = (r) => {
80
+ (r ?? []).forEach((o) => {
81
+ const s = o;
82
+ s.id != null && e.push(String(s.id)), s.controls && t(s.controls);
83
+ });
84
+ };
85
+ return t(
86
+ l.schema.controls ?? []
87
+ ), e.length > 0 ? e : void 0;
88
+ }, [l]), J = d(() => {
89
+ if (!l?.schema) return;
90
+ const e = {}, t = (r, o) => {
91
+ for (const s of r)
92
+ if (s.type === "section") {
93
+ const f = s.label?.value ?? "Section";
94
+ t(s.controls ?? [], f);
95
+ } else
96
+ s.id != null && o && (e[String(s.id)] = o), s.controls && t(s.controls, o);
97
+ };
98
+ return t(
99
+ l.schema.controls ?? [],
100
+ null
101
+ ), Object.keys(e).length > 0 ? e : void 0;
102
+ }, [l]), W = d(() => {
103
+ if (N)
104
+ return k(N).message;
105
+ if (E)
106
+ return k(E).message;
107
+ }, [N, E]), C = d(
108
+ () => [
109
+ { key: "recordedOn", header: n("RECORDED_ON") },
110
+ { key: "recordedBy", header: n("RECORDED_BY") }
111
+ ],
112
+ [n]
113
+ ), Z = d(
114
+ () => [
115
+ { key: "recordedOn", sortable: !0 },
116
+ { key: "recordedBy", sortable: !0 }
117
+ ],
118
+ []
119
+ ), S = d(() => {
120
+ const e = _.reduce(
121
+ (r, o) => {
122
+ const s = o.formName;
123
+ r[s] ??= [];
124
+ const f = o.providers.map((re) => re.providerName).filter(Boolean).join(", ");
125
+ return r[s].push({
126
+ id: o.encounterUuid,
127
+ formName: o.formName,
128
+ recordedOn: ue(o.encounterDateTime, n, !0).formattedResult,
129
+ recordedBy: f ?? "--",
130
+ encounterDateTime: o.encounterDateTime,
131
+ encounterUuid: o.encounterUuid
132
+ }), r;
133
+ },
134
+ {}
135
+ );
136
+ return Object.entries(e).map(
137
+ ([r, o]) => ({
138
+ formName: r,
139
+ records: o.sort(
140
+ (s, f) => f.encounterDateTime - s.encounterDateTime
141
+ )
142
+ })
143
+ ).sort((r, o) => r.formName.localeCompare(o.formName));
144
+ }, [_, n]), q = h((e) => {
145
+ M(e), I(!0);
146
+ }, []), ee = h(() => {
147
+ I(!1), M(null);
148
+ }, []), U = h(
149
+ (e, t) => {
150
+ switch (t) {
151
+ case "recordedOn":
152
+ return /* @__PURE__ */ i(fe, { onClick: () => q(e), children: e.recordedOn });
153
+ case "recordedBy":
154
+ return e.recordedBy;
155
+ default:
156
+ return null;
157
+ }
158
+ },
159
+ [q]
160
+ );
161
+ return /* @__PURE__ */ te(oe, { children: [
162
+ /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: B || T || S.length === 0 || A ? /* @__PURE__ */ i(
163
+ x,
164
+ {
165
+ headers: C,
166
+ ariaLabel: n("FORMS_HEADING"),
167
+ rows: [],
168
+ loading: B,
169
+ errorStateMessage: T ? j?.message : void 0,
170
+ emptyStateMessage: n("FORMS_UNAVAILABLE"),
171
+ renderCell: U,
172
+ className: v.formsTableBody,
173
+ dataTestId: "forms-table"
174
+ }
175
+ ) : /* @__PURE__ */ i(ye, { align: "start", children: S.map((e, t) => {
176
+ const { formName: r, records: o } = e;
177
+ return /* @__PURE__ */ i(
178
+ be,
179
+ {
180
+ title: r,
181
+ className: v.customAccordianItem,
182
+ testId: `accordian-title-${r}`,
183
+ open: t === 0,
184
+ children: /* @__PURE__ */ i(
185
+ x,
186
+ {
187
+ headers: C,
188
+ ariaLabel: n("FORMS_HEADING"),
189
+ rows: o,
190
+ loading: !1,
191
+ errorStateMessage: "",
192
+ sortable: Z,
193
+ emptyStateMessage: n("FORMS_UNAVAILABLE"),
194
+ renderCell: U,
195
+ className: v.formsTableBody,
196
+ dataTestId: `forms-table-${r}`
197
+ }
198
+ )
199
+ },
200
+ r
201
+ );
202
+ }) }) }),
203
+ y && a && /* @__PURE__ */ i(
204
+ pe,
205
+ {
206
+ id: "modalIdForActionAreaLayout",
207
+ portalId: "main-display-area",
208
+ open: y,
209
+ onRequestClose: ee,
210
+ modalHeading: a.formName,
211
+ modalLabel: `${a.recordedOn} | ${a.recordedBy}`,
212
+ passiveModal: !0,
213
+ size: "md",
214
+ testId: "form-details-modal",
215
+ children: /* @__PURE__ */ i(
216
+ he,
217
+ {
218
+ observations: X,
219
+ isLoading: K || z,
220
+ isError: $ || G,
221
+ errorMessage: W,
222
+ emptyStateMessage: n("NO_FORM_DATA_AVAILABLE"),
223
+ testIdPrefix: a.formName,
224
+ hideThumbnail: Q,
225
+ controlOrder: Y,
226
+ sectionMap: J
227
+ }
228
+ )
229
+ }
230
+ )
231
+ ] });
232
+ };
233
+ export {
234
+ Be as default
235
+ };
@@ -1,5 +1,5 @@
1
1
  import { jsx as d, jsxs as N } from "react/jsx-runtime";
2
- import { f as M, d as D, e as V, g as Q, o as k, h as q, w as H, m as G, u as P, a as j, j as z, C as J, y as Y, k as W, l as X, s as Z, H as x, i as ee } from "./index-BxDZltVB.js";
2
+ import { f as M, d as D, e as V, g as Q, o as k, h as q, w as H, m as G, u as P, a as j, j as z, C as J, y as Y, k as W, l as X, s as Z, H as x, i as ee } from "./index-DFn3IxWh.js";
3
3
  import { useQueries as te, useQuery as se } from "@tanstack/react-query";
4
4
  import { useRef as oe, useEffect as C, useMemo as h } from "react";
5
5
  import { useTranslation as U } from "react-i18next";
@@ -0,0 +1,21 @@
1
+ import { default as React } from 'react';
2
+ import { ConditionViewModel } from './models';
3
+ interface ConditionsTabContentProps {
4
+ patientUUID: string;
5
+ configPageSize: number;
6
+ clinicalStatus: 'active' | 'inactive';
7
+ emptyStateMessageKey: string;
8
+ headers: Array<{
9
+ key: string;
10
+ header: string;
11
+ }>;
12
+ renderCell: (condition: ConditionViewModel, cellId: string) => React.ReactNode;
13
+ /**
14
+ * If true, the tab's query is enabled immediately on mount.
15
+ * If false (default for lazy tabs), query is deferred until `enabled` flips to true externally.
16
+ */
17
+ enabled?: boolean;
18
+ }
19
+ declare const ConditionsTabContent: React.FC<ConditionsTabContentProps>;
20
+ export default ConditionsTabContent;
21
+ //# sourceMappingURL=ConditionsTabContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConditionsTabContent.d.ts","sourceRoot":"","sources":["../../src/conditions/ConditionsTabContent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAI9C,UAAU,yBAAyB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,QAAQ,GAAG,UAAU,CAAC;IACtC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,OAAO,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChD,UAAU,EAAE,CACV,SAAS,EAAE,kBAAkB,EAC7B,MAAM,EAAE,MAAM,KACX,KAAK,CAAC,SAAS,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,QAAA,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAmF7D,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionsTable.d.ts","sourceRoot":"","sources":["../../src/conditions/ConditionsTable.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAIzE,OAAO,EAAsB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAOpE,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA4N1C,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"ConditionsTable.d.ts","sourceRoot":"","sources":["../../src/conditions/ConditionsTable.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAI9D,OAAO,EAAsB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAOpE,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA4N1C,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"FormsTable.d.ts","sourceRoot":"","sources":["../../src/forms/FormsTable.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAG9D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAWhD;;;GAGG;AACH,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAwSrC,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"FormsTable.d.ts","sourceRoot":"","sources":["../../src/forms/FormsTable.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAG9D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAWhD;;;GAGG;AACH,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA+VrC,CAAC;AAEF,eAAe,UAAU,CAAC"}