@bahmni/widgets 0.0.1-dev.269 → 0.0.1-dev.270

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 s, jsxs as _, Fragment as Q } from "react/jsx-runtime";
2
- import { u as W, a as X, p as J, f as Z, T as x, m as ee, y as te } from "./index-BaQzqsoc.js";
2
+ import { u as W, a as X, p as J, f as Z, T as x, m as ee, y as te } from "./index-xrLM2RJL.js";
3
3
  import { useQuery as ne } from "@tanstack/react-query";
4
4
  import { useState as l, useCallback as p, useEffect as N, useMemo as f } from "react";
5
5
  import { useTranslation as ae } from "react-i18next";
@@ -0,0 +1,207 @@
1
+ import { jsx as n, jsxs as Z, Fragment as ee } from "react/jsx-runtime";
2
+ import { z as re, u as te, D as oe, K as ae, Y as se, G as ne, I as de, c as ie, M as U, T as me, f as ce, m as x, e as le, t as ue, y as fe, O as ye } from "./index-xrLM2RJL.js";
3
+ import { useQueryClient as be, useQuery as y } from "@tanstack/react-query";
4
+ import { useState as k, useMemo as d, useCallback as b } from "react";
5
+ import { useTranslation as pe } from "react-i18next";
6
+ const ge = "_formsTableBody_ourq9_5", Ne = "_customAccordianItem_ourq9_10", O = {
7
+ formsTableBody: ge,
8
+ customAccordianItem: Ne
9
+ }, he = (m) => m ? m.extension?.find(
10
+ (p) => p.url === re
11
+ )?.valueString : void 0, Me = ({
12
+ episodeOfCareUuids: m,
13
+ encounterUuids: i,
14
+ config: p
15
+ }) => {
16
+ const { t: s } = pe(), c = te(), [l, D] = k(!1), [o, I] = k(null), {
17
+ numberOfVisits: K,
18
+ hideThumbnail: P = !1,
19
+ forms: u
20
+ } = p ?? {}, M = oe(
21
+ m,
22
+ i
23
+ ), w = be(), {
24
+ data: A = [],
25
+ isLoading: v,
26
+ isError: B,
27
+ error: H,
28
+ refetch: j
29
+ } = y({
30
+ queryKey: ["forms", c, m],
31
+ queryFn: () => ae(c, void 0, K),
32
+ enabled: !!c && !M
33
+ }), T = d(() => {
34
+ let e = A;
35
+ return i && i.length > 0 && (e = e.filter(
36
+ (t) => i.includes(t.encounterUuid)
37
+ )), Array.isArray(u) && u.length > 0 && (e = e.filter(
38
+ (t) => u.some((r) => r.toLowerCase() === t.formName.toLowerCase())
39
+ )), e;
40
+ }, [A, i, u]), { data: L = [] } = y({
41
+ queryKey: ["observationForms"],
42
+ queryFn: () => se()
43
+ }), R = b(
44
+ (e) => L.find((r) => r.name === e)?.uuid,
45
+ [L]
46
+ ), g = d(() => {
47
+ if (o)
48
+ return R(o.formName);
49
+ }, [o, R]), {
50
+ isLoading: z,
51
+ isError: G,
52
+ error: N
53
+ } = y({
54
+ queryKey: ["formMetadata", g],
55
+ queryFn: () => ne(g),
56
+ enabled: !!g && l
57
+ }), {
58
+ data: h,
59
+ isLoading: V,
60
+ isError: $,
61
+ error: E
62
+ } = y({
63
+ queryKey: ["formsEncounterFHIR", o?.encounterUuid],
64
+ queryFn: () => de(o.encounterUuid),
65
+ enabled: !!o?.encounterUuid && l
66
+ });
67
+ ie(
68
+ (e) => {
69
+ e.patientUUID === c && e.updatedConcepts.size > 0 && (j(), w.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
70
+ },
71
+ [c]
72
+ );
73
+ const Q = d(() => !h?.entry || !o?.formName ? [] : h.entry.filter((t) => t.resource?.resourceType === "Observation").map((t) => t.resource).filter((t) => {
74
+ const r = he(t);
75
+ return !r || r.includes(o.formName);
76
+ }), [h, o?.formName]), Y = d(() => {
77
+ if (N)
78
+ return U(N).message;
79
+ if (E)
80
+ return U(E).message;
81
+ }, [N, E]), _ = d(
82
+ () => [
83
+ { key: "recordedOn", header: s("RECORDED_ON") },
84
+ { key: "recordedBy", header: s("RECORDED_BY") }
85
+ ],
86
+ [s]
87
+ ), J = d(
88
+ () => [
89
+ { key: "recordedOn", sortable: !0 },
90
+ { key: "recordedBy", sortable: !0 }
91
+ ],
92
+ []
93
+ ), q = d(() => {
94
+ const e = T.reduce(
95
+ (r, a) => {
96
+ const f = a.formName;
97
+ r[f] ??= [];
98
+ const F = a.providers.map((X) => X.providerName).filter(Boolean).join(", ");
99
+ return r[f].push({
100
+ id: a.encounterUuid,
101
+ formName: a.formName,
102
+ recordedOn: me(a.encounterDateTime, s, !0).formattedResult,
103
+ recordedBy: F ?? "--",
104
+ encounterDateTime: a.encounterDateTime,
105
+ encounterUuid: a.encounterUuid
106
+ }), r;
107
+ },
108
+ {}
109
+ );
110
+ return Object.entries(e).map(
111
+ ([r, a]) => ({
112
+ formName: r,
113
+ records: a.sort(
114
+ (f, F) => F.encounterDateTime - f.encounterDateTime
115
+ )
116
+ })
117
+ ).sort((r, a) => r.formName.localeCompare(a.formName));
118
+ }, [T, s]), C = b((e) => {
119
+ I(e), D(!0);
120
+ }, []), W = b(() => {
121
+ D(!1), I(null);
122
+ }, []), S = b(
123
+ (e, t) => {
124
+ switch (t) {
125
+ case "recordedOn":
126
+ return /* @__PURE__ */ n(ce, { onClick: () => C(e), children: e.recordedOn });
127
+ case "recordedBy":
128
+ return e.recordedBy;
129
+ default:
130
+ return null;
131
+ }
132
+ },
133
+ [C]
134
+ );
135
+ return /* @__PURE__ */ Z(ee, { children: [
136
+ /* @__PURE__ */ n("div", { id: "forms-table", "data-testid": "forms-table", children: v || B || q.length === 0 || M ? /* @__PURE__ */ n(
137
+ x,
138
+ {
139
+ headers: _,
140
+ ariaLabel: s("FORMS_HEADING"),
141
+ rows: [],
142
+ loading: v,
143
+ errorStateMessage: B ? H?.message : void 0,
144
+ emptyStateMessage: s("FORMS_UNAVAILABLE"),
145
+ renderCell: S,
146
+ className: O.formsTableBody,
147
+ dataTestId: "forms-table"
148
+ }
149
+ ) : /* @__PURE__ */ n(le, { align: "start", children: q.map((e, t) => {
150
+ const { formName: r, records: a } = e;
151
+ return /* @__PURE__ */ n(
152
+ ue,
153
+ {
154
+ title: r,
155
+ className: O.customAccordianItem,
156
+ testId: `accordian-title-${r}`,
157
+ open: t === 0,
158
+ children: /* @__PURE__ */ n(
159
+ x,
160
+ {
161
+ headers: _,
162
+ ariaLabel: s("FORMS_HEADING"),
163
+ rows: a,
164
+ loading: !1,
165
+ errorStateMessage: "",
166
+ sortable: J,
167
+ emptyStateMessage: s("FORMS_UNAVAILABLE"),
168
+ renderCell: S,
169
+ className: O.formsTableBody,
170
+ dataTestId: `forms-table-${r}`
171
+ }
172
+ )
173
+ },
174
+ r
175
+ );
176
+ }) }) }),
177
+ l && o && /* @__PURE__ */ n(
178
+ fe,
179
+ {
180
+ id: "modalIdForActionAreaLayout",
181
+ portalId: "main-display-area",
182
+ open: l,
183
+ onRequestClose: W,
184
+ modalHeading: o.formName,
185
+ modalLabel: `${o.recordedOn} | ${o.recordedBy}`,
186
+ passiveModal: !0,
187
+ size: "md",
188
+ testId: "form-details-modal",
189
+ children: /* @__PURE__ */ n(
190
+ ye,
191
+ {
192
+ observations: Q,
193
+ isLoading: z || V,
194
+ isError: G || $,
195
+ errorMessage: Y,
196
+ emptyStateMessage: s("NO_FORM_DATA_AVAILABLE"),
197
+ testIdPrefix: o.formName,
198
+ hideThumbnail: P
199
+ }
200
+ )
201
+ }
202
+ )
203
+ ] });
204
+ };
205
+ export {
206
+ Me as default
207
+ };
@@ -1,5 +1,5 @@
1
1
  import { jsx as l, jsxs as S } from "react/jsx-runtime";
2
- import { b as V, C as D, d as k, g as K, i as Q, x as q, h as G, j as P, u as j, a as H, k as x, l as z, c as Y, n as J, o as W, s as X, $ as Z, m as ee } from "./index-BaQzqsoc.js";
2
+ import { b as V, C as D, d as k, g as K, i as Q, x as q, h as G, j as P, u as j, a as H, k as x, l as z, c as Y, n as J, o as W, s as X, $ as Z, m as ee } from "./index-xrLM2RJL.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";
@@ -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;AAUhD;;;GAGG;AACH,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA+RrC,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,CAwSrC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -87539,7 +87539,7 @@ const wpt = [
87539
87539
  },
87540
87540
  {
87541
87541
  type: "patientDocuments",
87542
- component: Br(() => import("./DocumentsTable-CWc_01xl.js"))
87542
+ component: Br(() => import("./DocumentsTable-vCJICNVK.js"))
87543
87543
  },
87544
87544
  {
87545
87545
  type: "flowSheet",
@@ -87547,7 +87547,7 @@ const wpt = [
87547
87547
  },
87548
87548
  {
87549
87549
  type: "forms",
87550
- component: Br(() => import("./FormsTable-BmPCw62a.js"))
87550
+ component: Br(() => import("./FormsTable-iiGXH-hu.js"))
87551
87551
  },
87552
87552
  {
87553
87553
  type: "labOrders",
@@ -87555,7 +87555,7 @@ const wpt = [
87555
87555
  },
87556
87556
  {
87557
87557
  type: "observations",
87558
- component: Br(() => import("./Observations-0noP4PJi.js"))
87558
+ component: Br(() => import("./Observations-BuYik4Q1.js"))
87559
87559
  },
87560
87560
  {
87561
87561
  type: "ordersControl",
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a3 as s, a1 as t, A as o, a0 as r, r as n, _ as g, v as l, q as c, w as P, F as d, J as v, L as b, ad as A, af as C, ag as T, B as f, Q as m, U as p, O as u, P as I, H as L, N as R, E as S, R as W, S as N, Z as U, V as y, a5 as D, a4 as x, ab as H, aa as O, a7 as h, a8 as E, a9 as V, a6 as _, ac as q, a2 as w, X as F, ae as G, a as M, u as k, W as z } from "./index-BaQzqsoc.js";
1
+ import { a3 as s, a1 as t, A as o, a0 as r, r as n, _ as g, v as l, q as c, w as P, F as d, J as v, L as b, ad as A, af as C, ag as T, B as f, Q as m, U as p, O as u, P as I, H as L, N as R, E as S, R as W, S as N, Z as U, V as y, a5 as D, a4 as x, ab as H, aa as O, a7 as h, a8 as E, a9 as V, a6 as _, ac as q, a2 as w, X as F, ae as G, a as M, u as k, W as z } from "./index-xrLM2RJL.js";
2
2
  import "react";
3
3
  export {
4
4
  s as ActivePractitionerContext,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bahmni/widgets",
3
- "version": "0.0.1-dev.269",
3
+ "version": "0.0.1-dev.270",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -1,198 +0,0 @@
1
- import { jsx as n, jsxs as X, Fragment as Z } from "react/jsx-runtime";
2
- import { z as ee, u as re, D as te, K as oe, Y as ae, G as se, I as ne, c as de, M as C, T as ie, f as me, m as U, e as ce, t as le, y as ue, O as fe } from "./index-BaQzqsoc.js";
3
- import { useQueryClient as ye, useQuery as f } from "@tanstack/react-query";
4
- import { useState as x, useMemo as d, useCallback as y } from "react";
5
- import { useTranslation as be } from "react-i18next";
6
- const pe = "_formsTableBody_ourq9_5", ge = "_customAccordianItem_ourq9_10", h = {
7
- formsTableBody: pe,
8
- customAccordianItem: ge
9
- }, Ee = (m) => m ? m.extension?.find(
10
- (b) => b.url === ee
11
- )?.valueString : void 0, Ie = ({
12
- episodeOfCareUuids: m,
13
- encounterUuids: i,
14
- config: b
15
- }) => {
16
- const { t: s } = be(), c = re(), [l, D] = x(!1), [t, I] = x(null), { numberOfVisits: k, hideThumbnail: K = !1 } = b ?? {}, M = te(
17
- m,
18
- i
19
- ), P = ye(), {
20
- data: p = [],
21
- isLoading: v,
22
- isError: A,
23
- error: H,
24
- refetch: j
25
- } = f({
26
- queryKey: ["forms", c, m],
27
- queryFn: () => oe(c, void 0, k),
28
- enabled: !!c && !M
29
- }), B = d(() => !i || i.length === 0 ? p : p.filter(
30
- (e) => i.includes(e.encounterUuid)
31
- ), [p, i]), { data: T = [] } = f({
32
- queryKey: ["observationForms"],
33
- queryFn: () => ae()
34
- }), R = y(
35
- (e) => T.find((r) => r.name === e)?.uuid,
36
- [T]
37
- ), g = d(() => {
38
- if (t)
39
- return R(t.formName);
40
- }, [t, R]), {
41
- isLoading: z,
42
- isError: G,
43
- error: E
44
- } = f({
45
- queryKey: ["formMetadata", g],
46
- queryFn: () => se(g),
47
- enabled: !!g && l
48
- }), {
49
- data: F,
50
- isLoading: V,
51
- isError: $,
52
- error: N
53
- } = f({
54
- queryKey: ["formsEncounterFHIR", t?.encounterUuid],
55
- queryFn: () => ne(t.encounterUuid),
56
- enabled: !!t?.encounterUuid && l
57
- });
58
- de(
59
- (e) => {
60
- e.patientUUID === c && e.updatedConcepts.size > 0 && (j(), P.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
61
- },
62
- [c]
63
- );
64
- const w = d(() => !F?.entry || !t?.formName ? [] : F.entry.filter((a) => a.resource?.resourceType === "Observation").map((a) => a.resource).filter((a) => {
65
- const r = Ee(a);
66
- return !r || r.includes(t.formName);
67
- }), [F, t?.formName]), Q = d(() => {
68
- if (E)
69
- return C(E).message;
70
- if (N)
71
- return C(N).message;
72
- }, [E, N]), L = d(
73
- () => [
74
- { key: "recordedOn", header: s("RECORDED_ON") },
75
- { key: "recordedBy", header: s("RECORDED_BY") }
76
- ],
77
- [s]
78
- ), Y = d(
79
- () => [
80
- { key: "recordedOn", sortable: !0 },
81
- { key: "recordedBy", sortable: !0 }
82
- ],
83
- []
84
- ), _ = d(() => {
85
- const e = B.reduce(
86
- (r, o) => {
87
- const u = o.formName;
88
- r[u] ??= [];
89
- const O = o.providers.map((W) => W.providerName).filter(Boolean).join(", ");
90
- return r[u].push({
91
- id: o.encounterUuid,
92
- formName: o.formName,
93
- recordedOn: ie(o.encounterDateTime, s, !0).formattedResult,
94
- recordedBy: O ?? "--",
95
- encounterDateTime: o.encounterDateTime,
96
- encounterUuid: o.encounterUuid
97
- }), r;
98
- },
99
- {}
100
- );
101
- return Object.entries(e).map(
102
- ([r, o]) => ({
103
- formName: r,
104
- records: o.sort(
105
- (u, O) => O.encounterDateTime - u.encounterDateTime
106
- )
107
- })
108
- ).sort((r, o) => r.formName.localeCompare(o.formName));
109
- }, [B, s]), q = y((e) => {
110
- I(e), D(!0);
111
- }, []), J = y(() => {
112
- D(!1), I(null);
113
- }, []), S = y(
114
- (e, a) => {
115
- switch (a) {
116
- case "recordedOn":
117
- return /* @__PURE__ */ n(me, { onClick: () => q(e), children: e.recordedOn });
118
- case "recordedBy":
119
- return e.recordedBy;
120
- default:
121
- return null;
122
- }
123
- },
124
- [q]
125
- );
126
- return /* @__PURE__ */ X(Z, { children: [
127
- /* @__PURE__ */ n("div", { id: "forms-table", "data-testid": "forms-table", children: v || A || _.length === 0 || M ? /* @__PURE__ */ n(
128
- U,
129
- {
130
- headers: L,
131
- ariaLabel: s("FORMS_HEADING"),
132
- rows: [],
133
- loading: v,
134
- errorStateMessage: A ? H?.message : void 0,
135
- emptyStateMessage: s("FORMS_UNAVAILABLE"),
136
- renderCell: S,
137
- className: h.formsTableBody,
138
- dataTestId: "forms-table"
139
- }
140
- ) : /* @__PURE__ */ n(ce, { align: "start", children: _.map((e, a) => {
141
- const { formName: r, records: o } = e;
142
- return /* @__PURE__ */ n(
143
- le,
144
- {
145
- title: r,
146
- className: h.customAccordianItem,
147
- testId: `accordian-title-${r}`,
148
- open: a === 0,
149
- children: /* @__PURE__ */ n(
150
- U,
151
- {
152
- headers: L,
153
- ariaLabel: s("FORMS_HEADING"),
154
- rows: o,
155
- loading: !1,
156
- errorStateMessage: "",
157
- sortable: Y,
158
- emptyStateMessage: s("FORMS_UNAVAILABLE"),
159
- renderCell: S,
160
- className: h.formsTableBody,
161
- dataTestId: `forms-table-${r}`
162
- }
163
- )
164
- },
165
- r
166
- );
167
- }) }) }),
168
- l && t && /* @__PURE__ */ n(
169
- ue,
170
- {
171
- id: "modalIdForActionAreaLayout",
172
- portalId: "main-display-area",
173
- open: l,
174
- onRequestClose: J,
175
- modalHeading: t.formName,
176
- modalLabel: `${t.recordedOn} | ${t.recordedBy}`,
177
- passiveModal: !0,
178
- size: "md",
179
- testId: "form-details-modal",
180
- children: /* @__PURE__ */ n(
181
- fe,
182
- {
183
- observations: w,
184
- isLoading: z || V,
185
- isError: G || $,
186
- errorMessage: Q,
187
- emptyStateMessage: s("NO_FORM_DATA_AVAILABLE"),
188
- testIdPrefix: t.formName,
189
- hideThumbnail: K
190
- }
191
- )
192
- }
193
- )
194
- ] });
195
- };
196
- export {
197
- Ie as default
198
- };