@bahmni/widgets 0.0.1-dev.100 → 0.0.1-dev.102

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.
@@ -0,0 +1,261 @@
1
+ import { jsxs as p, jsx as e, Fragment as z } from "react/jsx-runtime";
2
+ import { u as Q, E as Y, w as J, b as W, f as X, i as Z, S as ee, V as I, a as re, c as oe, A as ae, z as te, d as V, s as ne } from "./index-DQRZqaXZ.js";
3
+ import { useQuery as f } from "@tanstack/react-query";
4
+ import { useState as x, useMemo as u, useCallback as g } from "react";
5
+ import { createPortal as se } from "react-dom";
6
+ import { useTranslation as ce } from "react-i18next";
7
+ const de = "_formsTableBody_ua0cn_1", me = "_customAccordianItem_ua0cn_6", ie = "_formContent_ua0cn_18", le = "_formDetailsContainer_ua0cn_25", ue = "_observation_ua0cn_30", pe = "_groupContainer_ua0cn_39", _e = "_rowContainer_ua0cn_43", be = "_groupLabel_ua0cn_48", fe = "_rowLabel_ua0cn_58", ge = "_rowValue_ua0cn_67", he = "_groupMembers_ua0cn_75", Ne = "_memberRow_ua0cn_81", ye = "_memberLabel_ua0cn_86", Me = "_memberValue_ua0cn_94", Le = "_commentSection_ua0cn_102", Oe = "_commentText_ua0cn_108", ve = "_nestedGroup_ua0cn_117", Ce = "_nestedGroupLabel_ua0cn_124", De = "_nestedGroupMembers_ua0cn_133", o = {
8
+ formsTableBody: de,
9
+ customAccordianItem: me,
10
+ formContent: ie,
11
+ formDetailsContainer: le,
12
+ observation: ue,
13
+ groupContainer: pe,
14
+ rowContainer: _e,
15
+ groupLabel: be,
16
+ rowLabel: fe,
17
+ rowValue: ge,
18
+ groupMembers: he,
19
+ memberRow: Ne,
20
+ memberLabel: ye,
21
+ memberValue: Me,
22
+ commentSection: Le,
23
+ commentText: Oe,
24
+ nestedGroup: ve,
25
+ nestedGroupLabel: Ce,
26
+ nestedGroupMembers: De
27
+ }, U = ({
28
+ member: r,
29
+ depth: m = 0
30
+ }) => {
31
+ const i = r.groupMembers && r.groupMembers.length > 0, a = r.conceptNameToDisplay ?? r.concept?.shortName ?? r.concept?.name;
32
+ return i ? /* @__PURE__ */ p("div", { className: o.nestedGroup, children: [
33
+ /* @__PURE__ */ e(
34
+ "div",
35
+ {
36
+ className: o.nestedGroupLabel,
37
+ style: { paddingLeft: `${m * 16}px` },
38
+ children: a
39
+ }
40
+ ),
41
+ /* @__PURE__ */ e("div", { className: o.nestedGroupMembers, children: r.groupMembers?.map((l, _) => /* @__PURE__ */ e(
42
+ U,
43
+ {
44
+ member: l,
45
+ depth: m + 1
46
+ },
47
+ `${l.concept.uuid}`
48
+ )) })
49
+ ] }) : /* @__PURE__ */ p(
50
+ "div",
51
+ {
52
+ className: o.memberRow,
53
+ style: { paddingLeft: `${m * 16}px` },
54
+ children: [
55
+ /* @__PURE__ */ e("p", { className: o.memberLabel, children: a }),
56
+ /* @__PURE__ */ e("p", { className: o.memberValue, children: r.valueAsString })
57
+ ]
58
+ }
59
+ );
60
+ }, Re = ({
61
+ observation: r,
62
+ index: m
63
+ }) => {
64
+ const i = r.groupMembers && r.groupMembers.length > 0;
65
+ return /* @__PURE__ */ p(
66
+ "div",
67
+ {
68
+ className: o.observation,
69
+ children: [
70
+ /* @__PURE__ */ p(
71
+ "div",
72
+ {
73
+ className: i ? o.groupContainer : o.rowContainer,
74
+ children: [
75
+ /* @__PURE__ */ e("p", { className: i ? o.groupLabel : o.rowLabel, children: r.conceptNameToDisplay }),
76
+ i ? /* @__PURE__ */ e("div", { className: o.groupMembers, children: r.groupMembers?.map((a, l) => /* @__PURE__ */ e(
77
+ U,
78
+ {
79
+ member: a,
80
+ depth: 0
81
+ },
82
+ `${a.concept.uuid}`
83
+ )) }) : /* @__PURE__ */ e("p", { className: o.rowValue, children: r.valueAsString })
84
+ ]
85
+ }
86
+ ),
87
+ r.comment && /* @__PURE__ */ e("div", { className: o.commentSection, children: /* @__PURE__ */ p("span", { className: o.commentText, children: [
88
+ r.comment,
89
+ r.providers?.[0]?.name && ` - by ${r.providers[0].name}`
90
+ ] }) })
91
+ ]
92
+ },
93
+ `${r.concept.uuid}-${m}`
94
+ );
95
+ }, Se = ({
96
+ episodeOfCareUuids: r,
97
+ encounterUuids: m,
98
+ config: i
99
+ }) => {
100
+ const { t: a } = ce(), l = Q(), [_, L] = x(!1), [n, O] = x(null), $ = i?.numberOfVisits, {
101
+ data: h = [],
102
+ isLoading: v,
103
+ isError: C,
104
+ error: q
105
+ } = f({
106
+ queryKey: ["forms", l, r],
107
+ queryFn: () => Y(l, void 0, $),
108
+ enabled: !!l
109
+ }), D = u(() => !m || m.length === 0 ? h : h.filter(
110
+ (t) => m.includes(t.encounterUuid)
111
+ ), [h, m]), { data: R = [] } = f({
112
+ queryKey: ["observationForms"],
113
+ queryFn: J
114
+ }), A = g(
115
+ (t) => R.find((c) => c.name === t)?.uuid,
116
+ [R]
117
+ ), N = u(() => {
118
+ if (n)
119
+ return A(n.formName);
120
+ }, [n, A]), {
121
+ data: Ae,
122
+ isLoading: k,
123
+ error: w
124
+ } = f({
125
+ queryKey: ["formMetadata", N],
126
+ queryFn: () => W(N),
127
+ enabled: !!N && _
128
+ }), {
129
+ data: y,
130
+ isLoading: H,
131
+ error: F
132
+ } = f({
133
+ queryKey: ["formsEncounter", n?.encounterUuid],
134
+ queryFn: () => X(n.encounterUuid, !0),
135
+ enabled: !!n?.encounterUuid && _
136
+ }), T = u(() => !y?.observations || !n?.formName ? [] : y.observations.filter(
137
+ (d) => "formFieldPath" in d && typeof d.formFieldPath == "string" && d.formFieldPath.includes(n.formName)
138
+ ), [y?.observations, n?.formName]), E = u(
139
+ () => [
140
+ { key: "recordedOn", header: a("FORM_RECORDED_ON") },
141
+ { key: "recordedBy", header: a("FORM_RECORDED_BY") }
142
+ ],
143
+ [a]
144
+ ), P = u(
145
+ () => [
146
+ { key: "recordedOn", sortable: !0 },
147
+ { key: "recordedBy", sortable: !0 }
148
+ ],
149
+ []
150
+ ), B = u(() => {
151
+ const t = D.reduce(
152
+ (c, s) => {
153
+ const b = s.formName;
154
+ c[b] ??= [];
155
+ const M = s.providers.map((K) => K.providerName).filter(Boolean).join(", ");
156
+ return c[b].push({
157
+ id: s.encounterUuid,
158
+ formName: s.formName,
159
+ recordedOn: Z(s.encounterDateTime, a, ne).formattedResult,
160
+ recordedBy: M ?? "--",
161
+ encounterDateTime: s.encounterDateTime,
162
+ encounterUuid: s.encounterUuid
163
+ }), c;
164
+ },
165
+ {}
166
+ );
167
+ return Object.entries(t).map(
168
+ ([c, s]) => ({
169
+ formName: c,
170
+ records: s.sort(
171
+ (b, M) => M.encounterDateTime - b.encounterDateTime
172
+ )
173
+ })
174
+ ).sort((c, s) => c.formName.localeCompare(s.formName));
175
+ }, [D, a]), G = g((t) => {
176
+ O(t), L(!0);
177
+ }, []), j = g(() => {
178
+ L(!1), O(null);
179
+ }, []), S = g(
180
+ (t, d) => {
181
+ switch (d) {
182
+ case "recordedOn":
183
+ return /* @__PURE__ */ e(ee, { onClick: () => G(t), children: t.recordedOn });
184
+ case "recordedBy":
185
+ return t.recordedBy;
186
+ default:
187
+ return null;
188
+ }
189
+ },
190
+ [G]
191
+ );
192
+ return /* @__PURE__ */ p(z, { children: [
193
+ /* @__PURE__ */ e("div", { "data-testid": "forms-table", children: v || C || B.length === 0 ? /* @__PURE__ */ e(
194
+ I,
195
+ {
196
+ headers: E,
197
+ ariaLabel: a("FORMS_HEADING"),
198
+ rows: [],
199
+ loading: v,
200
+ errorStateMessage: C ? q?.message : void 0,
201
+ emptyStateMessage: a("FORMS_UNAVAILABLE"),
202
+ renderCell: S,
203
+ className: o.formsTableBody,
204
+ "data-testid": "sortable-data-table"
205
+ }
206
+ ) : /* @__PURE__ */ e(re, { align: "start", children: B.map((t, d) => {
207
+ const { formName: c, records: s } = t;
208
+ return /* @__PURE__ */ e(
209
+ oe,
210
+ {
211
+ title: c,
212
+ className: o.customAccordianItem,
213
+ testId: "accordian-table-title",
214
+ open: d === 0,
215
+ children: /* @__PURE__ */ e(
216
+ I,
217
+ {
218
+ headers: E,
219
+ ariaLabel: a("FORMS_HEADING"),
220
+ rows: s,
221
+ loading: !1,
222
+ errorStateMessage: "",
223
+ sortable: P,
224
+ emptyStateMessage: a("FORMS_UNAVAILABLE"),
225
+ renderCell: S,
226
+ className: o.formsTableBody,
227
+ "data-testid": "sortable-data-table"
228
+ }
229
+ )
230
+ },
231
+ c
232
+ );
233
+ }) }) }),
234
+ _ && n && se(
235
+ /* @__PURE__ */ e(
236
+ ae,
237
+ {
238
+ open: _,
239
+ onRequestClose: j,
240
+ modalHeading: n.formName,
241
+ modalLabel: `${n.recordedOn} | ${n.recordedBy}`,
242
+ passiveModal: !0,
243
+ size: "md",
244
+ testId: "form-details-modal",
245
+ children: /* @__PURE__ */ e("div", { className: o.formContent, children: k || H ? /* @__PURE__ */ e(te, { width: "100%", lineCount: 3 }) : w ? /* @__PURE__ */ e("div", { children: V(w).message ?? a("ERROR_FETCHING_FORM_METADATA") }) : F ? /* @__PURE__ */ e("div", { children: V(F).message ?? a("ERROR_FETCHING_FORM_DATA") }) : T.length > 0 ? /* @__PURE__ */ e("div", { className: o.formDetailsContainer, children: T.map((t, d) => /* @__PURE__ */ e(
246
+ Re,
247
+ {
248
+ observation: t,
249
+ index: d
250
+ },
251
+ `${t.concept.uuid}`
252
+ )) }) : /* @__PURE__ */ e("div", { children: a("NO_FORM_DATA_AVAILABLE") }) })
253
+ }
254
+ ),
255
+ document.getElementById("actionAreaLayout") ?? document.body
256
+ )
257
+ ] });
258
+ };
259
+ export {
260
+ Se as default
261
+ };
@@ -0,0 +1,9 @@
1
+ import { default as React } from 'react';
2
+ import { WidgetProps } from '../registry/model';
3
+ /**
4
+ * Component to display patient forms grouped by form name in accordion format
5
+ * Each accordion item contains a SortableDataTable with form records for that form type
6
+ */
7
+ declare const FormsTable: React.FC<WidgetProps>;
8
+ export default FormsTable;
9
+ //# sourceMappingURL=FormsTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormsTable.d.ts","sourceRoot":"","sources":["../../src/forms/FormsTable.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAG9D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAShD;;;GAGG;AACH,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA6QrC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { default as React } from 'react';
2
+ import { ObservationData } from './models';
3
+ interface ObservationItemProps {
4
+ observation: ObservationData;
5
+ index: number;
6
+ }
7
+ export declare const ObservationItem: React.FC<ObservationItemProps>;
8
+ export default ObservationItem;
9
+ //# sourceMappingURL=ObservationItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObservationItem.d.ts","sourceRoot":"","sources":["../../src/forms/ObservationItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,UAAU,oBAAoB;IAC5B,WAAW,EAAE,eAAe,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf;AAyDD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA6C1D,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default } from './FormsTable';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/forms/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,35 @@
1
+ export interface ObservationData {
2
+ concept: {
3
+ name: string;
4
+ uuid: string;
5
+ shortName?: string;
6
+ units?: string;
7
+ hiNormal?: number;
8
+ lowNormal?: number;
9
+ };
10
+ value?: unknown;
11
+ valueAsString?: string;
12
+ conceptNameToDisplay?: string;
13
+ groupMembers?: ObservationData[];
14
+ formFieldPath?: string;
15
+ comment?: string;
16
+ providers?: Array<{
17
+ uuid: string;
18
+ name: string;
19
+ }>;
20
+ interpretation?: string;
21
+ }
22
+ interface FormRecordViewModel {
23
+ id: string;
24
+ formName: string;
25
+ recordedOn: string;
26
+ recordedBy: string;
27
+ encounterDateTime: number;
28
+ encounterUuid: string;
29
+ }
30
+ interface GroupedFormRecords {
31
+ formName: string;
32
+ records: FormRecordViewModel[];
33
+ }
34
+ export type { FormRecordViewModel, GroupedFormRecords };
35
+ //# sourceMappingURL=models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/forms/models.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,KAAK,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,mBAAmB;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,mBAAmB,EAAE,CAAC;CAChC;AACD,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,CAAC"}