@bahmni/widgets 0.0.1-dev.107 → 0.0.1-dev.109

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,320 @@
1
+ import { jsxs as _, jsx as t, Fragment as J } from "react/jsx-runtime";
2
+ import { c as h, u as W, E as X, O as Z, P as ee, A as re, b as oe, i as te, R as ae, x as $, h as ne, d as se, a as de, y as ce, e as x, s as me } from "./index-Z7N8pibh.js";
3
+ import { useQuery as g } from "@tanstack/react-query";
4
+ import { useState as U, useMemo as b, useCallback as N } from "react";
5
+ import { createPortal as le } from "react-dom";
6
+ import { useTranslation as ie } from "react-i18next";
7
+ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e = "_formContent_1pd36_18", be = "_formDetailsContainer_1pd36_25", fe = "_observation_1pd36_30", ge = "_groupContainer_1pd36_39", Ne = "_rowContainer_1pd36_43", he = "_groupLabel_1pd36_48", ye = "_rowLabel_1pd36_58", Me = "_rowValue_1pd36_67", Le = "_groupMembers_1pd36_75", Ae = "_memberRow_1pd36_81", Oe = "_memberLabel_1pd36_86", Re = "_memberValue_1pd36_94", De = "_abnormalValue_1pd36_102", we = "_commentSection_1pd36_110", Ce = "_commentText_1pd36_116", Fe = "_nestedGroup_1pd36_125", Te = "_nestedGroupLabel_1pd36_132", Ee = "_nestedGroupMembers_1pd36_141", r = {
8
+ formsTableBody: ue,
9
+ customAccordianItem: pe,
10
+ formContent: _e,
11
+ formDetailsContainer: be,
12
+ observation: fe,
13
+ groupContainer: ge,
14
+ rowContainer: Ne,
15
+ groupLabel: he,
16
+ rowLabel: ye,
17
+ rowValue: Me,
18
+ groupMembers: Le,
19
+ memberRow: Ae,
20
+ memberLabel: Oe,
21
+ memberValue: Re,
22
+ abnormalValue: De,
23
+ commentSection: we,
24
+ commentText: Ce,
25
+ nestedGroup: Fe,
26
+ nestedGroupLabel: Te,
27
+ nestedGroupMembers: Ee
28
+ }, ve = "ABNORMAL", q = (e) => {
29
+ const s = e.concept?.units, d = e.concept?.lowNormal, o = e.concept?.hiNormal, l = d != null, i = o != null, p = l && i ? ` (${d} - ${o})` : l ? ` (>${d})` : i ? ` (<${o})` : "", a = e.interpretation && e.interpretation.toUpperCase() === ve;
30
+ return { units: s, rangeString: p, isAbnormal: a };
31
+ }, P = ({
32
+ member: e,
33
+ depth: s = 0
34
+ }) => {
35
+ const d = e.groupMembers && e.groupMembers.length > 0, o = e.conceptNameToDisplay ?? e.concept?.shortName ?? e.concept?.name;
36
+ if (d)
37
+ return /* @__PURE__ */ _("div", { className: r.nestedGroup, children: [
38
+ /* @__PURE__ */ t(
39
+ "div",
40
+ {
41
+ className: r.nestedGroupLabel,
42
+ style: { paddingLeft: `${s * 16}px` },
43
+ children: o
44
+ }
45
+ ),
46
+ /* @__PURE__ */ t("div", { className: r.nestedGroupMembers, children: e.groupMembers?.map((a) => /* @__PURE__ */ t(
47
+ P,
48
+ {
49
+ member: a,
50
+ depth: s + 1
51
+ },
52
+ `${a.concept.uuid}`
53
+ )) })
54
+ ] });
55
+ const { units: l, rangeString: i, isAbnormal: p } = q(e);
56
+ return /* @__PURE__ */ _(
57
+ "div",
58
+ {
59
+ className: r.memberRow,
60
+ style: { paddingLeft: `${s * 16}px` },
61
+ children: [
62
+ /* @__PURE__ */ _(
63
+ "p",
64
+ {
65
+ className: h(
66
+ r.memberLabel,
67
+ p ? r.abnormalValue : ""
68
+ ),
69
+ children: [
70
+ o,
71
+ i
72
+ ]
73
+ }
74
+ ),
75
+ /* @__PURE__ */ _(
76
+ "p",
77
+ {
78
+ className: h(
79
+ r.memberValue,
80
+ p ? r.abnormalValue : ""
81
+ ),
82
+ children: [
83
+ e.valueAsString,
84
+ l && ` ${l}`
85
+ ]
86
+ }
87
+ )
88
+ ]
89
+ }
90
+ );
91
+ }, Be = ({
92
+ observation: e,
93
+ index: s
94
+ }) => {
95
+ const d = e.groupMembers && e.groupMembers.length > 0, { units: o, rangeString: l, isAbnormal: i } = q(e);
96
+ return /* @__PURE__ */ _(
97
+ "div",
98
+ {
99
+ className: r.observation,
100
+ children: [
101
+ /* @__PURE__ */ _(
102
+ "div",
103
+ {
104
+ className: d ? r.groupContainer : r.rowContainer,
105
+ children: [
106
+ /* @__PURE__ */ _(
107
+ "p",
108
+ {
109
+ className: h(
110
+ d ? r.groupLabel : r.rowLabel,
111
+ !d && i ? r.abnormalValue : ""
112
+ ),
113
+ children: [
114
+ e.conceptNameToDisplay,
115
+ !d && l && /* @__PURE__ */ t("span", { className: r.rangeInfo, children: l })
116
+ ]
117
+ }
118
+ ),
119
+ d ? /* @__PURE__ */ t("div", { className: r.groupMembers, children: e.groupMembers?.map((p) => /* @__PURE__ */ t(
120
+ P,
121
+ {
122
+ member: p,
123
+ depth: 0
124
+ },
125
+ `${p.concept.uuid}`
126
+ )) }) : /* @__PURE__ */ _(
127
+ "p",
128
+ {
129
+ className: h(
130
+ r.rowValue,
131
+ i ? r.abnormalValue : ""
132
+ ),
133
+ children: [
134
+ e.valueAsString,
135
+ o && ` ${o}`
136
+ ]
137
+ }
138
+ )
139
+ ]
140
+ }
141
+ ),
142
+ e.comment && /* @__PURE__ */ t("div", { className: r.commentSection, children: /* @__PURE__ */ _("span", { className: r.commentText, children: [
143
+ e.comment,
144
+ e.providers?.[0]?.name && ` - by ${e.providers[0].name}`
145
+ ] }) })
146
+ ]
147
+ },
148
+ `${e.concept.uuid}-${s}`
149
+ );
150
+ }, qe = ({
151
+ episodeOfCareUuids: e,
152
+ encounterUuids: s,
153
+ config: d
154
+ }) => {
155
+ const { t: o } = ie(), l = W(), [i, p] = U(!1), [a, O] = U(null), k = d?.numberOfVisits, R = X(
156
+ e,
157
+ s
158
+ ), {
159
+ data: y = [],
160
+ isLoading: D,
161
+ isError: w,
162
+ error: H
163
+ } = g({
164
+ queryKey: ["forms", l, e],
165
+ queryFn: () => Z(l, void 0, k),
166
+ enabled: !!l && !R
167
+ }), C = b(() => !s || s.length === 0 ? y : y.filter(
168
+ (n) => s.includes(n.encounterUuid)
169
+ ), [y, s]), { data: F = [] } = g({
170
+ queryKey: ["observationForms"],
171
+ queryFn: ee
172
+ }), T = N(
173
+ (n) => F.find((c) => c.name === n)?.uuid,
174
+ [F]
175
+ ), M = b(() => {
176
+ if (a)
177
+ return T(a.formName);
178
+ }, [a, T]), {
179
+ data: Ie,
180
+ isLoading: j,
181
+ error: E
182
+ } = g({
183
+ queryKey: ["formMetadata", M],
184
+ queryFn: () => re(M),
185
+ enabled: !!M && i
186
+ }), {
187
+ data: L,
188
+ isLoading: K,
189
+ error: v
190
+ } = g({
191
+ queryKey: ["formsEncounter", a?.encounterUuid],
192
+ queryFn: () => oe(a.encounterUuid, !0),
193
+ enabled: !!a?.encounterUuid && i
194
+ }), B = b(() => !L?.observations || !a?.formName ? [] : L.observations.filter(
195
+ (u) => "formFieldPath" in u && typeof u.formFieldPath == "string" && u.formFieldPath.includes(a.formName)
196
+ ), [L?.observations, a?.formName]), I = b(
197
+ () => [
198
+ { key: "recordedOn", header: o("FORM_RECORDED_ON") },
199
+ { key: "recordedBy", header: o("FORM_RECORDED_BY") }
200
+ ],
201
+ [o]
202
+ ), z = b(
203
+ () => [
204
+ { key: "recordedOn", sortable: !0 },
205
+ { key: "recordedBy", sortable: !0 }
206
+ ],
207
+ []
208
+ ), V = b(() => {
209
+ const n = C.reduce(
210
+ (c, m) => {
211
+ const f = m.formName;
212
+ c[f] ??= [];
213
+ const A = m.providers.map((Y) => Y.providerName).filter(Boolean).join(", ");
214
+ return c[f].push({
215
+ id: m.encounterUuid,
216
+ formName: m.formName,
217
+ recordedOn: te(m.encounterDateTime, o, me).formattedResult,
218
+ recordedBy: A ?? "--",
219
+ encounterDateTime: m.encounterDateTime,
220
+ encounterUuid: m.encounterUuid
221
+ }), c;
222
+ },
223
+ {}
224
+ );
225
+ return Object.entries(n).map(
226
+ ([c, m]) => ({
227
+ formName: c,
228
+ records: m.sort(
229
+ (f, A) => A.encounterDateTime - f.encounterDateTime
230
+ )
231
+ })
232
+ ).sort((c, m) => c.formName.localeCompare(m.formName));
233
+ }, [C, o]), S = N((n) => {
234
+ O(n), p(!0);
235
+ }, []), Q = N(() => {
236
+ p(!1), O(null);
237
+ }, []), G = N(
238
+ (n, u) => {
239
+ switch (u) {
240
+ case "recordedOn":
241
+ return /* @__PURE__ */ t(ae, { onClick: () => S(n), children: n.recordedOn });
242
+ case "recordedBy":
243
+ return n.recordedBy;
244
+ default:
245
+ return null;
246
+ }
247
+ },
248
+ [S]
249
+ );
250
+ return /* @__PURE__ */ _(J, { children: [
251
+ /* @__PURE__ */ t("div", { "data-testid": "forms-table", children: D || w || V.length === 0 || R ? /* @__PURE__ */ t(
252
+ $,
253
+ {
254
+ headers: I,
255
+ ariaLabel: o("FORMS_HEADING"),
256
+ rows: [],
257
+ loading: D,
258
+ errorStateMessage: w ? H?.message : void 0,
259
+ emptyStateMessage: o("FORMS_UNAVAILABLE"),
260
+ renderCell: G,
261
+ className: r.formsTableBody,
262
+ "data-testid": "sortable-data-table"
263
+ }
264
+ ) : /* @__PURE__ */ t(ne, { align: "start", children: V.map((n, u) => {
265
+ const { formName: c, records: m } = n;
266
+ return /* @__PURE__ */ t(
267
+ se,
268
+ {
269
+ title: c,
270
+ className: r.customAccordianItem,
271
+ testId: `accordian-title-${c}`,
272
+ open: u === 0,
273
+ children: /* @__PURE__ */ t(
274
+ $,
275
+ {
276
+ headers: I,
277
+ ariaLabel: o("FORMS_HEADING"),
278
+ rows: m,
279
+ loading: !1,
280
+ errorStateMessage: "",
281
+ sortable: z,
282
+ emptyStateMessage: o("FORMS_UNAVAILABLE"),
283
+ renderCell: G,
284
+ className: r.formsTableBody,
285
+ "data-testid": "forms-data-table"
286
+ }
287
+ )
288
+ },
289
+ c
290
+ );
291
+ }) }) }),
292
+ i && a && le(
293
+ /* @__PURE__ */ t(
294
+ de,
295
+ {
296
+ id: "formDetailsModal",
297
+ open: i,
298
+ onRequestClose: Q,
299
+ modalHeading: a.formName,
300
+ modalLabel: `${a.recordedOn} | ${a.recordedBy}`,
301
+ passiveModal: !0,
302
+ size: "md",
303
+ testId: "form-details-modal",
304
+ children: /* @__PURE__ */ t("div", { className: r.formContent, children: j || K ? /* @__PURE__ */ t(ce, { width: "100%", lineCount: 3 }) : E ? /* @__PURE__ */ t("div", { children: x(E).message ?? o("ERROR_FETCHING_FORM_METADATA") }) : v ? /* @__PURE__ */ t("div", { children: x(v).message ?? o("ERROR_FETCHING_FORM_DATA") }) : B.length > 0 ? /* @__PURE__ */ t("div", { className: r.formDetailsContainer, children: B.map((n, u) => /* @__PURE__ */ t(
305
+ Be,
306
+ {
307
+ observation: n,
308
+ index: u
309
+ },
310
+ `${n.concept.uuid}`
311
+ )) }) : /* @__PURE__ */ t("div", { children: o("NO_FORM_DATA_AVAILABLE") }) })
312
+ }
313
+ ),
314
+ document.getElementById("actionAreaLayout") ?? document.body
315
+ )
316
+ ] });
317
+ };
318
+ export {
319
+ qe as default
320
+ };
@@ -1 +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"}
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;AAShD;;;GAGG;AACH,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAsRrC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1 +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"}
1
+ {"version":3,"file":"ObservationItem.d.ts","sourceRoot":"","sources":["../../src/forms/ObservationItem.tsx"],"names":[],"mappings":"AACA,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;AAuGD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAgE1D,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -19,7 +19,7 @@ export interface ObservationData {
19
19
  }>;
20
20
  interpretation?: string;
21
21
  }
22
- interface FormRecordViewModel {
22
+ export interface FormRecordViewModel {
23
23
  id: string;
24
24
  formName: string;
25
25
  recordedOn: string;
@@ -27,9 +27,8 @@ interface FormRecordViewModel {
27
27
  encounterDateTime: number;
28
28
  encounterUuid: string;
29
29
  }
30
- interface GroupedFormRecords {
30
+ export interface GroupedFormRecords {
31
31
  formName: string;
32
32
  records: FormRecordViewModel[];
33
33
  }
34
- export type { FormRecordViewModel, GroupedFormRecords };
35
34
  //# sourceMappingURL=models.d.ts.map
@@ -1 +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,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