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

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 N, u as W, p as X, _ as Z, b as ee, E as re, h as oe, i as te, R as ae, x as $, a as ne, d as se, A as de, y as ce, e as x, s as me } from "./index-BaqvPC9o.js";
3
+ import { useQuery as g } from "@tanstack/react-query";
4
+ import { useState as U, useMemo as b, useCallback as h } 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", he = "_rowContainer_1pd36_43", Ne = "_groupLabel_1pd36_48", ye = "_rowLabel_1pd36_58", Me = "_rowValue_1pd36_67", Le = "_groupMembers_1pd36_75", Ae = "_memberRow_1pd36_81", Re = "_memberLabel_1pd36_86", Oe = "_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: he,
15
+ groupLabel: Ne,
16
+ rowLabel: ye,
17
+ rowValue: Me,
18
+ groupMembers: Le,
19
+ memberRow: Ae,
20
+ memberLabel: Re,
21
+ memberValue: Oe,
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
+ }, k = ({
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
+ k,
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: N(
66
+ r.memberLabel,
67
+ p ? r.abnormalValue : ""
68
+ ),
69
+ children: [
70
+ o,
71
+ i
72
+ ]
73
+ }
74
+ ),
75
+ /* @__PURE__ */ _(
76
+ "p",
77
+ {
78
+ className: N(
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: N(
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
+ k,
121
+ {
122
+ member: p,
123
+ depth: 0
124
+ },
125
+ `${p.concept.uuid}`
126
+ )) }) : /* @__PURE__ */ _(
127
+ "p",
128
+ {
129
+ className: N(
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, R] = U(null), H = d?.numberOfVisits, O = X(
156
+ e,
157
+ s
158
+ ), {
159
+ data: y = [],
160
+ isLoading: D,
161
+ isError: w,
162
+ error: P
163
+ } = g({
164
+ queryKey: ["forms", l, e],
165
+ queryFn: () => Z(l, void 0, H),
166
+ enabled: !!l && !O
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 = h(
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 = h((n) => {
234
+ R(n), p(!0);
235
+ }, []), Q = h(() => {
236
+ p(!1), R(null);
237
+ }, []), G = h(
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 || O ? /* @__PURE__ */ t(
252
+ $,
253
+ {
254
+ headers: I,
255
+ ariaLabel: o("FORMS_HEADING"),
256
+ rows: [],
257
+ loading: D,
258
+ errorStateMessage: w ? P?.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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;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,MAAM,WAAW,mBAAmB;IAClC,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,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,mBAAmB,EAAE,CAAC;CAChC"}
@@ -71346,15 +71346,8 @@ const _4 = (t, e) => t?.length === 0 ? !1 : e?.length === 0, uWe = async () => {
71346
71346
  translations: i
71347
71347
  };
71348
71348
  }, eJe = async (t, e, r) => {
71349
- let n;
71350
- try {
71351
- const a = sWe(t, r, n), i = await cr(a);
71352
- return Array.isArray(i) ? i : [];
71353
- } catch (a) {
71354
- throw new Error(
71355
- `Failed to fetch form data for patient ${t}: ${a instanceof Error ? a.message : "Unknown error"}`
71356
- );
71357
- }
71349
+ const n = sWe(t, r), a = await cr(n);
71350
+ return Array.isArray(a) ? a : [];
71358
71351
  }, mWe = Wr + "/bahmnicore/diseaseSummaryData?", wWe = async (t, e, r, n) => {
71359
71352
  const a = new URLSearchParams({
71360
71353
  groupBy: n,
@@ -75313,7 +75306,7 @@ const NGe = [
75313
75306
  },
75314
75307
  {
75315
75308
  type: "forms",
75316
- component: w1(() => import("./FormsTable-COl06FGn.js"))
75309
+ component: w1(() => import("./FormsTable-TnUjpfur.js"))
75317
75310
  }
75318
75311
  ];
75319
75312
  class Xr {
@@ -75366,6 +75359,7 @@ const iJe = (t) => {
75366
75359
  };
75367
75360
  export {
75368
75361
  l4 as A,
75362
+ hJe as B,
75369
75363
  dKe as C,
75370
75364
  vKe as D,
75371
75365
  QGe as E,
@@ -75381,27 +75375,28 @@ export {
75381
75375
  eJe as _,
75382
75376
  Ai as a,
75383
75377
  XGe as b,
75384
- tr as c,
75378
+ Nle as c,
75385
75379
  _i as d,
75386
- LWe as e,
75387
- Oce as f,
75388
- yYe as g,
75380
+ tr as e,
75381
+ LWe as f,
75382
+ Oce as g,
75389
75383
  JGe as h,
75390
75384
  Cr as i,
75391
- bGe as j,
75392
- hn as k,
75393
- rJe as l,
75394
- oJe as m,
75395
- aJe as n,
75396
- sJe as o,
75397
- lJe as p,
75398
- cJe as q,
75385
+ yYe as j,
75386
+ bGe as k,
75387
+ hn as l,
75388
+ rJe as m,
75389
+ oJe as n,
75390
+ aJe as o,
75391
+ _4 as p,
75392
+ sJe as q,
75399
75393
  iJe as r,
75400
75394
  GGe as s,
75401
- dJe as t,
75395
+ lJe as t,
75402
75396
  C1 as u,
75403
- uJe as v,
75404
- hJe as w,
75397
+ cJe as v,
75398
+ dJe as w,
75405
75399
  Qr as x,
75406
- Eke as y
75400
+ Eke as y,
75401
+ uJe as z
75407
75402
  };