@bahmni/widgets 0.0.1-dev.180 → 0.0.1-dev.184

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,172 @@
1
+ import { jsx as d, jsxs as S } from "react/jsx-runtime";
2
+ import { m as K, n as C, t as Q, Q as w, o as M, e as V, f as k, r as G, u as P, a as H, q as j, R as z, K as Y, g as J, p as W, s as X, v as Z, _ as x } from "./index--PbXuF2w.js";
3
+ import { useQueries as ee, useQuery as te } from "@tanstack/react-query";
4
+ import { useRef as se, useEffect as $, useMemo as E } from "react";
5
+ import { useTranslation as D } from "react-i18next";
6
+ const U = (t, c, i, l, a) => {
7
+ const s = Q(t, c), o = s.value, r = w(o);
8
+ let n = o;
9
+ r === "Image" && (n = /* @__PURE__ */ d(V, { imageSrc: o, alt: o, id: `${o}-img` })), r === "Video" && (n = /* @__PURE__ */ d(k, { id: `${o}-video`, videoSrc: o })), r === "PDF" && (n = /* @__PURE__ */ d(G, { id: `${o}-pdf`, src: o }));
10
+ const u = a("OBSERVATIONS_RECORDED_BY", {
11
+ provider: s.provider
12
+ }), b = t.display, p = t.observationValue?.isAbnormal ? "abnormal-obs" : "obs", f = l ? `${l}-${p}-${b}-${i}-${c}` : `${p}-${b}-${i}-${c}`;
13
+ return /* @__PURE__ */ d(
14
+ M,
15
+ {
16
+ header: s.header,
17
+ value: n,
18
+ info: u,
19
+ id: f,
20
+ testId: f,
21
+ ariaLabel: f
22
+ },
23
+ `obs-${t.id}`
24
+ );
25
+ }, oe = (t, c, i, l, a, s) => /* @__PURE__ */ d(
26
+ C,
27
+ {
28
+ title: t.display,
29
+ id: `grouped-obs-${t.display}-${l}`,
30
+ open: i,
31
+ children: t.members?.map(
32
+ (o, r) => U(o, r, a, s, c)
33
+ )
34
+ },
35
+ `grouped-obs-${t.id}`
36
+ ), re = ({
37
+ groupedData: t,
38
+ title: c = ""
39
+ }) => {
40
+ const { t: i } = D(), l = (a, s, o) => {
41
+ const r = K(a.encounterDetails, i);
42
+ return /* @__PURE__ */ S(
43
+ C,
44
+ {
45
+ title: r,
46
+ id: `encounter-${a.encounterId}`,
47
+ open: s,
48
+ children: [
49
+ a.observations.map(
50
+ (n, u) => U(n, u, o, c, i)
51
+ ),
52
+ a.groupedObservations.map(
53
+ (n, u) => oe(
54
+ n,
55
+ i,
56
+ s,
57
+ u,
58
+ o,
59
+ c
60
+ )
61
+ )
62
+ ]
63
+ },
64
+ `encounter-${a.encounterId}`
65
+ );
66
+ };
67
+ return /* @__PURE__ */ d(
68
+ "div",
69
+ {
70
+ id: "obs-by-encounter",
71
+ "data-testid": "obs-by-encounter-test-id",
72
+ "aria-label": "obs-by-encounter-aria-label",
73
+ children: t.map(
74
+ (a, s) => l(a, s === 0, s)
75
+ )
76
+ }
77
+ );
78
+ }, ae = "_observations_kfbhq_1", ne = "_title_kfbhq_12", N = {
79
+ observations: ae,
80
+ title: ne
81
+ }, ie = (t) => ["conceptUuid", t], ce = (t, c) => ["observations", t, ...c], me = ({ config: t }) => {
82
+ const c = t, { conceptNames: i = [], conceptUuid: l = [] } = c, a = se(/* @__PURE__ */ new Set()), s = P(), { addNotification: o } = H(), { t: r } = D(), n = ee({
83
+ queries: i.map((e) => ({
84
+ queryKey: ie(e),
85
+ queryFn: () => j(e),
86
+ enabled: !!e
87
+ }))
88
+ });
89
+ $(() => {
90
+ n.forEach((e, m) => {
91
+ if (e.isError && !a.current.has(m)) {
92
+ const g = i[m];
93
+ o({
94
+ title: r("ERROR_DEFAULT_TITLE"),
95
+ message: r("ERROR_FETCHING_CONCEPT", { conceptName: g }),
96
+ type: "error"
97
+ }), a.current.add(m);
98
+ } else e.isError || a.current.delete(m);
99
+ });
100
+ }, [n, i]);
101
+ const u = E(() => n.map((e) => e.data?.uuid).filter((e) => !!e), [n]), b = E(() => [.../* @__PURE__ */ new Set([...u, ...l])], [u, l]), v = E(() => i.length === 0 ? !0 : n.every((e) => !e.isLoading), [n, i.length]), {
102
+ data: p,
103
+ isLoading: f,
104
+ isError: O,
105
+ refetch: R
106
+ } = te({
107
+ queryKey: ce(s, b),
108
+ queryFn: () => z(s, b),
109
+ enabled: !!s && b.length > 0 && v
110
+ });
111
+ Y(
112
+ (e) => {
113
+ e.patientUUID === s && e.updatedConcepts.size > 0 && [...e.updatedConcepts.keys()].some(
114
+ (g) => b.includes(g)
115
+ ) && R();
116
+ },
117
+ [s, R]
118
+ ), $(() => {
119
+ O && o({
120
+ title: r("ERROR_DEFAULT_TITLE"),
121
+ message: r("ERROR_FETCHING_OBSERVATIONS"),
122
+ type: "error"
123
+ });
124
+ }, [O]);
125
+ const T = E(() => {
126
+ if (!p) return [];
127
+ const e = J(p), m = W(e);
128
+ return X(m);
129
+ }, [p]), B = [
130
+ { key: "name", header: "name" },
131
+ { key: "value", header: "value" },
132
+ { key: "form", header: "form" }
133
+ ], _ = f || !v, I = O && v, A = (!p || p.entry?.length === 0 || b.length === 0) && v, F = I ? r("ERROR_FETCHING_OBSERVATIONS") : null, L = A ? r("NO_OBSERVATIONS_FOUND") : void 0, q = T.length > 0 && !_ && !I, h = c.titleTranslationKey, y = h ? r(h) : "";
134
+ return /* @__PURE__ */ S(
135
+ "div",
136
+ {
137
+ id: "observations",
138
+ "data-testid": h ? `observations-${y}` : "observations",
139
+ "aria-label": "observations-aria-label",
140
+ className: N.observations,
141
+ children: [
142
+ /* @__PURE__ */ d(
143
+ Z,
144
+ {
145
+ id: "observations-title",
146
+ testId: h ? `observations-title-${y}` : "observations-title",
147
+ title: y,
148
+ className: N.title,
149
+ children: /* @__PURE__ */ d("p", { children: y })
150
+ }
151
+ ),
152
+ q ? /* @__PURE__ */ d(re, { groupedData: T, title: y }) : /* @__PURE__ */ d(
153
+ x,
154
+ {
155
+ headers: B,
156
+ rows: [],
157
+ ariaLabel: r("OBSERVATIONS"),
158
+ loading: _,
159
+ errorStateMessage: F,
160
+ emptyStateMessage: L,
161
+ dataTestId: "observations-table"
162
+ }
163
+ )
164
+ ]
165
+ }
166
+ );
167
+ };
168
+ export {
169
+ ie as conceptUuidQueryKeys,
170
+ me as default,
171
+ ce as observationsQueryKeys
172
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"ObservationItem.d.ts","sourceRoot":"","sources":["../../src/forms/ObservationItem.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,UAAU,oBAAoB;IAC5B,WAAW,EAAE,oBAAoB,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAgKD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAmF1D,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"ObservationItem.d.ts","sourceRoot":"","sources":["../../src/forms/ObservationItem.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,UAAU,oBAAoB;IAC5B,WAAW,EAAE,oBAAoB,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAoKD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAmF1D,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -2,8 +2,9 @@ import { default as React } from 'react';
2
2
  import { WidgetProps } from '../registry/model';
3
3
  export declare const genericServiceRequestQueryKeys: (categoryUuid: string, patientUUID: string, encounterUuids?: string[]) => readonly ["genericServiceRequest", string, string, string[] | undefined];
4
4
  /**
5
- * Component to display patient service requests grouped by date in accordion format
6
- * Each accordion item contains a SortableDataTable with service requests for that date
5
+ * Component to display patient service requests in a flat sorted table.
6
+ * Items are sorted by orderedDate descending (newest first), with priority
7
+ * (stat before routine) as a tiebreaker for items with the same orderedDate.
7
8
  */
8
9
  declare const GenericServiceRequestTable: React.FC<WidgetProps>;
9
10
  export default GenericServiceRequestTable;
@@ -1 +1 @@
1
- {"version":3,"file":"GenericServiceRequestTable.d.ts","sourceRoot":"","sources":["../../src/genericServiceRequest/GenericServiceRequestTable.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAI/D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAahD,eAAO,MAAM,8BAA8B,GACzC,cAAc,MAAM,EACpB,aAAa,MAAM,EACnB,iBAAiB,MAAM,EAAE,6EAEoD,CAAC;AAehF;;;GAGG;AACH,QAAA,MAAM,0BAA0B,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAkOrD,CAAC;AAEF,eAAe,0BAA0B,CAAC"}
1
+ {"version":3,"file":"GenericServiceRequestTable.d.ts","sourceRoot":"","sources":["../../src/genericServiceRequest/GenericServiceRequestTable.tsx"],"names":[],"mappings":"AAUA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAI/D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAahD,eAAO,MAAM,8BAA8B,GACzC,cAAc,MAAM,EACpB,aAAa,MAAM,EACnB,iBAAiB,MAAM,EAAE,6EAEoD,CAAC;AAehF;;;;GAIG;AACH,QAAA,MAAM,0BAA0B,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA+KrD,CAAC;AAEF,eAAe,0BAA0B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/genericServiceRequest/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAe,cAAc,EAAE,MAAM,SAAS,CAAC;AAEnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAEnD;;;;GAIG;AACH,eAAO,MAAM,cAAc,UAAsB,CAAC;AAElD;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GAAI,UAAU,MAAM,KAAG,MAE5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,GACxC,UAAU,uBAAuB,EAAE,KAClC,uBAAuB,EAOzB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,sCAAsC,GACjD,UAAU,uBAAuB,EAAE,KAClC,uBAAuB,EAMzB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,GAC7B,uBAAuB,EAAE,CA6B3B"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/genericServiceRequest/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAe,cAAc,EAAE,MAAM,SAAS,CAAC;AAEnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAEnD;;;;GAIG;AACH,eAAO,MAAM,cAAc,UAAsB,CAAC;AAElD;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GAAI,UAAU,MAAM,KAAG,MAE5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,GACxC,UAAU,uBAAuB,EAAE,KAClC,uBAAuB,EAUzB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,sCAAsC,GACjD,UAAU,uBAAuB,EAAE,KAClC,uBAAuB,EAMzB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,GAC7B,uBAAuB,EAAE,CA6B3B"}