@bahmni/widgets 0.0.1-dev.465 → 0.0.1-dev.469

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,15 +1,15 @@
1
1
  import { jsx as i, jsxs as N } from "react/jsx-runtime";
2
- import { B as k, D as C, F as z, Z as H, e as P, G as j, H as x, K as J, I as Z, u as Y, a as W, J as X, U as ee, L as se, M as te, n as re, N as ae, P as oe, R as ne, T as ie, f as ce, z as le } from "./index-DDpIAfSc.js";
2
+ import { x as H, _ as U, y as z, Z as G, f as P, z as j, H as x, L as J, D as Z, u as Y, a as W, I as X, U as ee, J as se, K as te, s as re, M as ae, N as oe, P as ne, R as ie, S as ce, A as le } from "./index-CmbXgAAP.js";
3
3
  import { useQueries as de, useQuery as ue } from "@tanstack/react-query";
4
- import { useRef as pe, useEffect as U, useMemo as I } from "react";
4
+ import { useRef as pe, useEffect as C, useMemo as I } from "react";
5
5
  import { useTranslation as F } from "react-i18next";
6
- const be = "Observations-module_observations__RKSyo", me = "Observations-module_title__TJL3z", ve = "Observations-module_wrapper__muk2L", fe = "Observations-module_secondary__14nuS", f = {
7
- observations: be,
8
- title: me,
6
+ const me = "Observations-module_observations__RKSyo", be = "Observations-module_title__TJL3z", ve = "Observations-module_wrapper__muk2L", fe = "Observations-module_secondary__14nuS", f = {
7
+ observations: me,
8
+ title: be,
9
9
  wrapper: ve,
10
10
  secondary: fe
11
11
  }, w = (t, l, n, c, u, r) => {
12
- const a = z(t, l, u), e = a.value, p = H(e);
12
+ const a = z(t, l, u), e = a.value, p = G(e);
13
13
  let o = e;
14
14
  p === "Image" && (o = /* @__PURE__ */ i(
15
15
  x,
@@ -27,21 +27,21 @@ const be = "Observations-module_observations__RKSyo", me = "Observations-module_
27
27
  hideThumbnail: r
28
28
  }
29
29
  )), p === "PDF" && (o = /* @__PURE__ */ i(Z, { id: `${e}-pdf`, src: e }));
30
- const b = /* @__PURE__ */ N("div", { className: f.wrapper, children: [
30
+ const m = /* @__PURE__ */ N("div", { className: f.wrapper, children: [
31
31
  /* @__PURE__ */ i("span", { children: a.header.display }),
32
32
  a.header.referenceRange && /* @__PURE__ */ i("span", { className: f.secondary, children: a.header.referenceRange })
33
33
  ] }), d = u("OBSERVATIONS_RECORDED_BY", {
34
34
  provider: a.provider
35
- }), m = t.effectiveDateTime ? P(t.effectiveDateTime, u, !0).formattedResult : void 0, g = /* @__PURE__ */ N("div", { className: f.wrapper, children: [
35
+ }), b = t.effectiveDateTime ? P(t.effectiveDateTime, u, !0).formattedResult : void 0, _ = /* @__PURE__ */ N("div", { className: f.wrapper, children: [
36
36
  /* @__PURE__ */ i("span", { children: d }),
37
- m && /* @__PURE__ */ i("span", { className: f.secondary, children: m })
38
- ] }), v = t.display, _ = t.observationValue?.isAbnormal ? "abnormal-obs" : "obs", O = c ? `${c}-${_}-${v}-${n}-${l}` : `${_}-${v}-${n}-${l}`;
37
+ b && /* @__PURE__ */ i("span", { className: f.secondary, children: b })
38
+ ] }), v = t.display, g = t.observationValue?.isAbnormal ? "abnormal-obs" : "obs", O = c ? `${c}-${g}-${v}-${n}-${l}` : `${g}-${v}-${n}-${l}`;
39
39
  return /* @__PURE__ */ i(
40
40
  j,
41
41
  {
42
- header: b,
42
+ header: m,
43
43
  value: o,
44
- info: g,
44
+ info: _,
45
45
  id: O,
46
46
  testId: O,
47
47
  ariaLabel: O
@@ -49,7 +49,7 @@ const be = "Observations-module_observations__RKSyo", me = "Observations-module_
49
49
  `obs-${t.id}`
50
50
  );
51
51
  }, ye = (t, l, n, c, u, r, a) => /* @__PURE__ */ i(
52
- C,
52
+ U,
53
53
  {
54
54
  title: t.display,
55
55
  id: `grouped-obs-${t.display}-${c}`,
@@ -72,18 +72,18 @@ const be = "Observations-module_observations__RKSyo", me = "Observations-module_
72
72
  hideThumbnail: n
73
73
  }) => {
74
74
  const { t: c } = F(), u = (r, a, e) => {
75
- const p = k(r.encounterDetails, c);
75
+ const p = H(r.encounterDetails, c);
76
76
  return /* @__PURE__ */ N(
77
- C,
77
+ U,
78
78
  {
79
79
  title: p,
80
80
  id: `encounter-${r.encounterId}`,
81
81
  open: a,
82
82
  children: [
83
83
  r.observations.map(
84
- (o, b) => w(
84
+ (o, m) => w(
85
85
  o,
86
- b,
86
+ m,
87
87
  e,
88
88
  l,
89
89
  c,
@@ -91,11 +91,11 @@ const be = "Observations-module_observations__RKSyo", me = "Observations-module_
91
91
  )
92
92
  ),
93
93
  r.groupedObservations.map(
94
- (o, b) => ye(
94
+ (o, m) => ye(
95
95
  o,
96
96
  c,
97
97
  a,
98
- b,
98
+ m,
99
99
  e,
100
100
  l,
101
101
  n
@@ -133,29 +133,29 @@ const be = "Observations-module_observations__RKSyo", me = "Observations-module_
133
133
  conceptUuid: r = [],
134
134
  hideThumbnail: a = !1,
135
135
  scope: e = "all"
136
- } = c, p = pe(/* @__PURE__ */ new Set()), o = Y(), { addNotification: b } = W(), { t: d } = F(), m = de({
136
+ } = c, p = pe(/* @__PURE__ */ new Set()), o = Y(), { addNotification: m } = W(), { t: d } = F(), b = de({
137
137
  queries: u.map((s) => ({
138
138
  queryKey: Ee(s),
139
139
  queryFn: () => X(s),
140
140
  enabled: !!s
141
141
  }))
142
142
  });
143
- U(() => {
144
- const s = m.some(($) => $.isError), R = p.current.size > 0;
145
- s && !R ? (b({
143
+ C(() => {
144
+ const s = b.some(($) => $.isError), R = p.current.size > 0;
145
+ s && !R ? (m({
146
146
  title: d("ERROR_DEFAULT_TITLE"),
147
147
  message: d("ERROR_FETCHING_OBSERVATIONS"),
148
148
  type: "error"
149
149
  }), p.current.add(0)) : !s && R && p.current.clear();
150
- }, [m, b, d]);
151
- const g = I(() => m.map((s) => s.data?.uuid).filter((s) => !!s), [m]), v = I(() => [.../* @__PURE__ */ new Set([...g, ...r])], [g, r]), y = I(() => u.length === 0 ? !0 : m.every((s) => !s.isLoading), [m, u.length]), _ = e === "latest" || e === "latest-encounter", O = ee(
150
+ }, [b, m, d]);
151
+ const _ = I(() => b.map((s) => s.data?.uuid).filter((s) => !!s), [b]), v = I(() => [.../* @__PURE__ */ new Set([..._, ...r])], [_, r]), y = I(() => u.length === 0 ? !0 : b.every((s) => !s.isLoading), [b, u.length]), g = e === "latest" || e === "latest-encounter", O = ee(
152
152
  l,
153
153
  n
154
154
  ), {
155
155
  data: E,
156
156
  isLoading: V,
157
157
  isError: S,
158
- refetch: D
158
+ refetch: A
159
159
  } = ue({
160
160
  queryKey: he(
161
161
  o,
@@ -163,7 +163,7 @@ const be = "Observations-module_observations__RKSyo", me = "Observations-module_
163
163
  n,
164
164
  e
165
165
  ),
166
- queryFn: () => _ ? se(
166
+ queryFn: () => g ? se(
167
167
  o,
168
168
  v,
169
169
  n
@@ -178,17 +178,17 @@ const be = "Observations-module_observations__RKSyo", me = "Observations-module_
178
178
  (s) => {
179
179
  s.patientUUID === o && s.updatedConcepts.size > 0 && [...s.updatedConcepts.keys()].some(
180
180
  ($) => v.includes($)
181
- ) && D();
181
+ ) && A();
182
182
  },
183
- [o, D]
184
- ), U(() => {
185
- S && b({
183
+ [o, A]
184
+ ), C(() => {
185
+ S && m({
186
186
  title: d("ERROR_DEFAULT_TITLE"),
187
187
  message: d("ERROR_FETCHING_OBSERVATIONS"),
188
188
  type: "error"
189
189
  });
190
190
  }, [S]);
191
- const A = I(() => {
191
+ const D = I(() => {
192
192
  if (!E) return [];
193
193
  let s = ae(E);
194
194
  e === "latest-encounter" && (s = oe(s));
@@ -198,7 +198,7 @@ const be = "Observations-module_observations__RKSyo", me = "Observations-module_
198
198
  { key: "name", header: "name" },
199
199
  { key: "value", header: "value" },
200
200
  { key: "form", header: "form" }
201
- ], B = V || !y, L = S && y, M = (!E || E.entry?.length === 0 || v.length === 0) && y, q = L ? d("ERROR_FETCHING_OBSERVATIONS") : null, G = M ? d("NO_OBSERVATIONS_FOUND") : void 0, Q = A.length > 0 && !B && !L, T = c.titleTranslationKey, h = T ? d(T) : "";
201
+ ], L = V || !y, B = S && y, M = (!E || E.entry?.length === 0 || v.length === 0) && y, Q = B ? d("ERROR_FETCHING_OBSERVATIONS") : null, k = M ? d("NO_OBSERVATIONS_FOUND") : void 0, q = D.length > 0 && !L && !B, T = c.titleTranslationKey, h = T ? d(T) : "";
202
202
  return /* @__PURE__ */ N(
203
203
  "div",
204
204
  {
@@ -217,10 +217,10 @@ const be = "Observations-module_observations__RKSyo", me = "Observations-module_
217
217
  children: /* @__PURE__ */ i("p", { children: h })
218
218
  }
219
219
  ),
220
- Q ? /* @__PURE__ */ i(
220
+ q ? /* @__PURE__ */ i(
221
221
  Oe,
222
222
  {
223
- groupedData: A,
223
+ groupedData: D,
224
224
  title: h,
225
225
  hideThumbnail: a
226
226
  }
@@ -230,9 +230,9 @@ const be = "Observations-module_observations__RKSyo", me = "Observations-module_
230
230
  headers: K,
231
231
  rows: [],
232
232
  ariaLabel: d("OBSERVATIONS"),
233
- loading: B,
234
- errorStateMessage: q,
235
- emptyStateMessage: G ?? d("NO_OBSERVATIONS_AVAILABLE"),
233
+ loading: L,
234
+ errorStateMessage: Q,
235
+ emptyStateMessage: k ?? d("NO_OBSERVATIONS_AVAILABLE"),
236
236
  dataTestId: "observations-table"
237
237
  }
238
238
  )
@@ -0,0 +1,21 @@
1
+ export declare const SUPPORTED_CHART_TYPES: ReadonlySet<string>;
2
+ export declare const CHART_MAPPERS: {
3
+ readonly area: (meta: {
4
+ title: string;
5
+ group?: string;
6
+ }) => (ChartData: import('./model').ChartData) => import('./mappers').MappedChart;
7
+ readonly bar: (meta: {
8
+ title: string;
9
+ group?: string;
10
+ }) => (ChartData: import('./model').ChartData) => import('./mappers').MappedChart;
11
+ readonly scatter: (meta: {
12
+ title: string;
13
+ group?: string;
14
+ }) => (ChartData: import('./model').ChartData) => import('./mappers').MappedChart;
15
+ readonly line: (meta: {
16
+ title: string;
17
+ group?: string;
18
+ }) => (ChartData: import('./model').ChartData) => import('./mappers').MappedChart;
19
+ };
20
+ export declare const DEFAULT_CHART_HEIGHT = "clamp(244px, 50vh, 80vh)";
21
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/charts/constants.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,qBAAqB,EAAE,WAAW,CAAC,MAAM,CAKpD,CAAC;AAEH,eAAO,MAAM,aAAa;;;aAQoqE,CAAC;WAAkB,sCAAoB;;;aAAvC,CAAC;WAAkB,sCAAoB;;;aAAvC,CAAC;WAAkB,sCAAoB;;;aAAvC,CAAC;WAAkB,sCAAoB;CAH3tE,CAAC;AAEX,eAAO,MAAM,oBAAoB,6BAA6B,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { default as React } from 'react';
2
+ import { WidgetProps } from '../registry/model';
3
+ export type ChartWidgetPropTypes = WidgetProps;
4
+ declare const Chart: React.FC<ChartWidgetPropTypes>;
5
+ export default Chart;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/charts/index.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAQhD,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC;AAmE/C,QAAA,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAoFzC,CAAC;AAEF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { AreaChartOptions, BarChartOptions, ChartTabularData, LineChartOptions, ScatterChartOptions } from '@carbon/charts';
2
+ import { ChartData } from '../model';
3
+ type SupportedChartOptions = LineChartOptions | AreaChartOptions | BarChartOptions | ScatterChartOptions;
4
+ export interface MappedChart {
5
+ data: ChartTabularData;
6
+ options: SupportedChartOptions;
7
+ ariaLabel: string;
8
+ testId: string;
9
+ }
10
+ export declare const mapLineChart: (meta: {
11
+ title: string;
12
+ group?: string;
13
+ }) => (ChartData: ChartData) => MappedChart;
14
+ export declare const mapAreaChart: (meta: {
15
+ title: string;
16
+ group?: string;
17
+ }) => (ChartData: ChartData) => MappedChart;
18
+ export declare const mapBarChart: (meta: {
19
+ title: string;
20
+ group?: string;
21
+ }) => (ChartData: ChartData) => MappedChart;
22
+ export declare const mapScatterChart: (meta: {
23
+ title: string;
24
+ group?: string;
25
+ }) => (ChartData: ChartData) => MappedChart;
26
+ export type { ChartOptions } from '@carbon/charts';
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/charts/mappers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EAEzB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,KAAK,qBAAqB,GACtB,gBAAgB,GAChB,gBAAgB,GAChB,eAAe,GACf,mBAAmB,CAAC;AAExB,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,EAAE,qBAAqB,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AA8GD,eAAO,MAAM,YAAY,SAXhB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,MACvC,WAAW,SAAS,KAAG,WAUa,CAAC;AACxC,eAAO,MAAM,YAAY,SAZhB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,MACvC,WAAW,SAAS,KAAG,WAWa,CAAC;AACxC,eAAO,MAAM,WAAW,SAbf;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,MACvC,WAAW,SAAS,KAAG,WAYW,CAAC;AACtC,eAAO,MAAM,eAAe,SAdnB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,MACvC,WAAW,SAAS,KAAG,WAamB,CAAC;AAE9C,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Configuration for a `type: "charts"` dashboard control.
3
+ */
4
+ export interface ChartConfig {
5
+ /**
6
+ * FHIR search/read URL template. `{expr}` tokens are resolved at runtime
7
+ * against `{ patientUuid }` via `resolveNavigationURL`.
8
+ */
9
+ url: string;
10
+ /**
11
+ * Heading rendered above the chart. Falls back to the chart mode name
12
+ * (`"Line"`, `"Area"`, etc.) when omitted.
13
+ */
14
+ title: string;
15
+ /**
16
+ * Which chart to render. A fixed union; adding a new value is a code change
17
+ */
18
+ chartType: 'line' | 'area' | 'bar' | 'scatter';
19
+ /**
20
+ * A `jsonata` expression evaluated over the entire fetched FHIR `Bundle`,
21
+ * producing a `ChartData` shape.
22
+ */
23
+ expression: string;
24
+ /**
25
+ * Unit label for the plotted value, e.g. `"mmHg"`, `"%"`.
26
+ */
27
+ unit?: string;
28
+ /**
29
+ * Optional fixed `[min, max]` y scale.
30
+ */
31
+ yDomain?: [number, number] | null;
32
+ /**
33
+ * Optional alternate empty state message.
34
+ */
35
+ emptyMessage?: string;
36
+ /**
37
+ * Optional alternate error state message.
38
+ */
39
+ errorMessage?: string;
40
+ }
41
+ /** The `jsonata` `expression` is evaluated to produce this mode-agnostic shape. */
42
+ export interface ChartData {
43
+ points: Array<{
44
+ x: number | string;
45
+ y: number;
46
+ series?: string;
47
+ }>;
48
+ xType: 'date' | 'category';
49
+ xTitle?: string;
50
+ yTitle?: string;
51
+ unit?: string;
52
+ yDomain?: [number, number];
53
+ }
54
+ /** The closed set of chart modes the widget supports. */
55
+ export type ChartType = ChartConfig['chartType'];
56
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/charts/model.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC;IAC/C;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAClC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,mFAAmF;AACnF,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,KAAK,CAAC;QACZ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACnB,CAAC,EAAE,MAAM,CAAC;QACV,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IACH,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5B;AAED,yDAAyD;AACzD,MAAM,MAAM,SAAS,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { Bundle } from 'fhir/r4';
2
+ import { ChartConfig, ChartData } from './model';
3
+ /**
4
+ * Evaluates a JSONata expression against a bundle to produce normalized chart data.
5
+ *
6
+ * @param config - Chart configuration containing the JSONata query string.
7
+ * @param bundle - The source data payload to evaluate against.
8
+ * @param t - Active i18next translation function for error messages.
9
+ * @returns A promise resolving to the validated {@link ChartData} object.
10
+ *
11
+ * @throws {Error} If `config.expression` fails to compile or evaluate.
12
+ * @throws {Error} If the evaluation result is nullish or not an object.
13
+ * @throws {Error} If the evaluated result is missing an array-valued `points` property.
14
+ */
15
+ export declare const evaluateChartData: (config: ChartConfig, bundle: Bundle<unknown>, t: (content: string) => string) => Promise<ChartData>;
16
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/charts/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEjD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,WAAW,EACnB,QAAQ,MAAM,CAAC,OAAO,CAAC,EACvB,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,KAC7B,OAAO,CAAC,SAAS,CAqBnB,CAAC"}