@bahmni/widgets 0.0.1-dev.215 → 0.0.1-dev.216

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, C as J, c as Z, b as x, d as ee, y as te } from "./index-Cu7kAJjg.js";
2
+ import { u as W, a as X, k as J, c as Z, i as x, d as ee, y as te } from "./index-BrKymTP5.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";
@@ -37,9 +37,9 @@ const _e = [
37
37
  ], pe = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, R = (n) => n.attachments.length > 0 ? n.attachments : n.documentUrl ? [{ url: n.documentUrl, contentType: n.contentType }] : [], Ne = ({ config: n, encounterUuids: E }) => {
38
38
  const [d, M] = l(!1), [r, U] = l(
39
39
  null
40
- ), [P, A] = l(
40
+ ), [k, A] = l(
41
41
  /* @__PURE__ */ new Set()
42
- ), T = W(), { t: o } = ae(), { addNotification: w } = X(), F = Number(n?.pageSize) || 5, [C, D] = l(1), [m, $] = l(F), [k, O] = l(void 0), b = p((e) => {
42
+ ), T = W(), { t: o } = ae(), { addNotification: w } = X(), P = Number(n?.pageSize) || 5, [D, O] = l(1), [m, F] = l(P), [$, C] = l(void 0), b = p((e) => {
43
43
  U(e), M(!0);
44
44
  }, []), V = p(() => {
45
45
  M(!1), U(null), A(/* @__PURE__ */ new Set());
@@ -50,7 +50,7 @@ const _e = [
50
50
  "documents",
51
51
  T,
52
52
  E,
53
- C,
53
+ D,
54
54
  m
55
55
  ],
56
56
  enabled: !!T,
@@ -58,13 +58,13 @@ const _e = [
58
58
  T,
59
59
  E,
60
60
  m,
61
- C
61
+ D
62
62
  )
63
63
  });
64
64
  N(() => {
65
- u && O(u.total);
65
+ u && C(u.total);
66
66
  }, [u]), N(() => {
67
- D(1), O(void 0);
67
+ O(1), C(void 0);
68
68
  }, [T]), N(() => {
69
69
  y && w({
70
70
  title: o("ERROR_DEFAULT_TITLE"),
@@ -92,7 +92,7 @@ const _e = [
92
92
  }, [d, r]);
93
93
  const H = p(
94
94
  (e, t) => {
95
- t !== m ? ($(t), D(1), O(void 0)) : D(e);
95
+ t !== m ? (F(t), O(1), C(void 0)) : O(e);
96
96
  },
97
97
  [m]
98
98
  ), g = f(
@@ -153,8 +153,8 @@ const _e = [
153
153
  className: c.documentsTableBody,
154
154
  dataTestId: "documents-table",
155
155
  pageSize: m,
156
- totalItems: k,
157
- page: C,
156
+ totalItems: $,
157
+ page: D,
158
158
  onPageChange: H
159
159
  }
160
160
  ) }),
@@ -170,7 +170,7 @@ const _e = [
170
170
  size: "lg",
171
171
  testId: "document-view-modal",
172
172
  children: /* @__PURE__ */ s("div", { className: c.documentViewerContainer, children: h.map((e, t) => {
173
- const a = j(e.url), I = e.contentType?.toLowerCase().includes("pdf"), i = (e.contentType?.toLowerCase().includes("image") ?? !1) || pe.test(e.url ?? ""), v = P.has(t);
173
+ const a = j(e.url), I = e.contentType?.toLowerCase().includes("pdf"), i = (e.contentType?.toLowerCase().includes("image") ?? !1) || pe.test(e.url ?? ""), v = k.has(t);
174
174
  return a === "#" || v ? /* @__PURE__ */ _(
175
175
  "div",
176
176
  {
@@ -0,0 +1,198 @@
1
+ import { jsx as n, jsxs as W, Fragment as Z } from "react/jsx-runtime";
2
+ import { A as ee, u as re, b as te, w as oe, e as ae, v as se, l as ne, C as de, R as q, i as ie, c as ce, d as U, X as me, Q as le, y as ue, O as fe } from "./index-BrKymTP5.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 pe } from "react-i18next";
6
+ const be = "_formsTableBody_81hra_1", ge = "_customAccordianItem_81hra_6", O = {
7
+ formsTableBody: be,
8
+ customAccordianItem: ge
9
+ }, he = (c) => c ? c.extension?.find(
10
+ (p) => p.url === ee
11
+ )?.valueString : void 0, Ae = ({
12
+ episodeOfCareUuids: c,
13
+ encounterUuids: i,
14
+ config: p
15
+ }) => {
16
+ const { t: s } = pe(), m = re(), [l, E] = x(!1), [t, A] = x(null), { numberOfVisits: k, hideThumbnail: P = !1 } = p ?? {}, D = te(
17
+ c,
18
+ i
19
+ ), w = ye(), {
20
+ data: b = [],
21
+ isLoading: I,
22
+ isError: M,
23
+ error: H,
24
+ refetch: K
25
+ } = f({
26
+ queryKey: ["forms", m, c],
27
+ queryFn: () => oe(m, void 0, k),
28
+ enabled: !!m && !D
29
+ }), B = d(() => !i || i.length === 0 ? b : b.filter(
30
+ (e) => i.includes(e.encounterUuid)
31
+ ), [b, i]), { data: R = [] } = f({
32
+ queryKey: ["observationForms"],
33
+ queryFn: () => ae()
34
+ }), T = y(
35
+ (e) => R.find((r) => r.name === e)?.uuid,
36
+ [R]
37
+ ), g = d(() => {
38
+ if (t)
39
+ return T(t.formName);
40
+ }, [t, T]), {
41
+ isLoading: Q,
42
+ isError: j,
43
+ error: h
44
+ } = f({
45
+ queryKey: ["formMetadata", g],
46
+ queryFn: () => se(g),
47
+ enabled: !!g && l
48
+ }), {
49
+ data: v,
50
+ isLoading: V,
51
+ isError: $,
52
+ error: F
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 === m && e.updatedConcepts.size > 0 && (K(), w.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
61
+ },
62
+ [m]
63
+ );
64
+ const z = d(() => !v?.entry || !t?.formName ? [] : v.entry.filter((a) => a.resource?.resourceType === "Observation").map((a) => a.resource).filter((a) => {
65
+ const r = he(a);
66
+ return !r || r.includes(t.formName);
67
+ }), [v, t?.formName]), G = d(() => {
68
+ if (h)
69
+ return q(h).message;
70
+ if (F)
71
+ return q(F).message;
72
+ }, [h, F]), L = d(
73
+ () => [
74
+ { key: "recordedOn", header: s("RECORDED_ON") },
75
+ { key: "recordedBy", header: s("RECORDED_BY") }
76
+ ],
77
+ [s]
78
+ ), X = 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 N = o.providers.map((J) => J.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: N ?? "--",
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, N) => N.encounterDateTime - u.encounterDateTime
106
+ )
107
+ })
108
+ ).sort((r, o) => r.formName.localeCompare(o.formName));
109
+ }, [B, s]), C = y((e) => {
110
+ A(e), E(!0);
111
+ }, []), Y = y(() => {
112
+ E(!1), A(null);
113
+ }, []), S = y(
114
+ (e, a) => {
115
+ switch (a) {
116
+ case "recordedOn":
117
+ return /* @__PURE__ */ n(ce, { onClick: () => C(e), children: e.recordedOn });
118
+ case "recordedBy":
119
+ return e.recordedBy;
120
+ default:
121
+ return null;
122
+ }
123
+ },
124
+ [C]
125
+ );
126
+ return /* @__PURE__ */ W(Z, { children: [
127
+ /* @__PURE__ */ n("div", { "data-testid": "forms-table", children: I || M || _.length === 0 || D ? /* @__PURE__ */ n(
128
+ U,
129
+ {
130
+ headers: L,
131
+ ariaLabel: s("FORMS_HEADING"),
132
+ rows: [],
133
+ loading: I,
134
+ errorStateMessage: M ? H?.message : void 0,
135
+ emptyStateMessage: s("FORMS_UNAVAILABLE"),
136
+ renderCell: S,
137
+ className: O.formsTableBody,
138
+ dataTestId: "forms-table"
139
+ }
140
+ ) : /* @__PURE__ */ n(me, { 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: O.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: X,
158
+ emptyStateMessage: s("FORMS_UNAVAILABLE"),
159
+ renderCell: S,
160
+ className: O.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: Y,
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: z,
184
+ isLoading: Q || V,
185
+ isError: j || $,
186
+ errorMessage: G,
187
+ emptyStateMessage: s("NO_FORM_DATA_AVAILABLE"),
188
+ testIdPrefix: t.formName,
189
+ hideThumbnail: P
190
+ }
191
+ )
192
+ }
193
+ )
194
+ ] });
195
+ };
196
+ export {
197
+ Ae as default
198
+ };
@@ -1,13 +1,13 @@
1
- import { jsx as l, jsxs as C } from "react/jsx-runtime";
2
- import { o as V, v as D, t as k, g as w, p as K, h as Q, E as G, M as P, u as H, a as j, q as z, r as Y, I as J, i as W, s as X, w as Z, x, d as ee } from "./index-Cu7kAJjg.js";
1
+ import { jsx as l, jsxs as S } from "react/jsx-runtime";
2
+ import { f as V, g as D, t as k, h as K, o as Q, j as w, E as G, M as P, u as j, a as H, m as z, n as Y, C as J, p as W, q as X, s as Z, r as x, d as ee } from "./index-BrKymTP5.js";
3
3
  import { useQueries as te, useQuery as se } from "@tanstack/react-query";
4
- import { useRef as oe, useEffect as N, useMemo as g } from "react";
4
+ import { useRef as oe, useEffect as C, useMemo as g } from "react";
5
5
  import { useTranslation as U } from "react-i18next";
6
6
  const B = (t, i, c, d, u, r) => {
7
- const s = k(t, i, u), o = s.value, a = w(o);
7
+ const s = k(t, i, u), o = s.value, a = K(o);
8
8
  let n = o;
9
9
  a === "Image" && (n = /* @__PURE__ */ l(
10
- Q,
10
+ w,
11
11
  {
12
12
  imageSrc: o,
13
13
  alt: o,
@@ -26,7 +26,7 @@ const B = (t, i, c, d, u, r) => {
26
26
  provider: s.provider
27
27
  }), p = t.display, v = t.observationValue?.isAbnormal ? "abnormal-obs" : "obs", y = d ? `${d}-${v}-${p}-${c}-${i}` : `${v}-${p}-${c}-${i}`;
28
28
  return /* @__PURE__ */ l(
29
- K,
29
+ Q,
30
30
  {
31
31
  header: s.header,
32
32
  value: n,
@@ -62,7 +62,7 @@ const B = (t, i, c, d, u, r) => {
62
62
  }) => {
63
63
  const { t: d } = U(), u = (r, s, o) => {
64
64
  const a = V(r.encounterDetails, d);
65
- return /* @__PURE__ */ C(
65
+ return /* @__PURE__ */ S(
66
66
  D,
67
67
  {
68
68
  title: a,
@@ -106,7 +106,7 @@ const B = (t, i, c, d, u, r) => {
106
106
  )
107
107
  }
108
108
  );
109
- }, ne = "_observations_kfbhq_1", ie = "_title_kfbhq_12", S = {
109
+ }, ne = "_observations_kfbhq_1", ie = "_title_kfbhq_12", N = {
110
110
  observations: ne,
111
111
  title: ie
112
112
  }, ce = (t) => ["conceptUuid", t], de = (t, i) => ["observations", t, ...i], me = ({ config: t }) => {
@@ -114,14 +114,14 @@ const B = (t, i, c, d, u, r) => {
114
114
  conceptNames: c = [],
115
115
  conceptUuid: d = [],
116
116
  hideThumbnail: u = !1
117
- } = i, r = oe(/* @__PURE__ */ new Set()), s = H(), { addNotification: o } = j(), { t: a } = U(), n = te({
117
+ } = i, r = oe(/* @__PURE__ */ new Set()), s = j(), { addNotification: o } = H(), { t: a } = U(), n = te({
118
118
  queries: c.map((e) => ({
119
119
  queryKey: ce(e),
120
120
  queryFn: () => z(e),
121
121
  enabled: !!e
122
122
  }))
123
123
  });
124
- N(() => {
124
+ C(() => {
125
125
  n.forEach((e, m) => {
126
126
  if (e.isError && !r.current.has(m)) {
127
127
  const R = c[m];
@@ -150,7 +150,7 @@ const B = (t, i, c, d, u, r) => {
150
150
  ) && T();
151
151
  },
152
152
  [s, T]
153
- ), N(() => {
153
+ ), C(() => {
154
154
  O && o({
155
155
  title: a("ERROR_DEFAULT_TITLE"),
156
156
  message: a("ERROR_FETCHING_OBSERVATIONS"),
@@ -166,13 +166,13 @@ const B = (t, i, c, d, u, r) => {
166
166
  { key: "value", header: "value" },
167
167
  { key: "form", header: "form" }
168
168
  ], _ = y || !f, $ = O && f, F = (!v || v.entry?.length === 0 || p.length === 0) && f, L = $ ? a("ERROR_FETCHING_OBSERVATIONS") : null, M = F ? a("NO_OBSERVATIONS_FOUND") : void 0, q = I.length > 0 && !_ && !$, h = i.titleTranslationKey, E = h ? a(h) : "";
169
- return /* @__PURE__ */ C(
169
+ return /* @__PURE__ */ S(
170
170
  "div",
171
171
  {
172
172
  id: "observations",
173
173
  "data-testid": h ? `observations-${E}` : "observations",
174
174
  "aria-label": "observations-aria-label",
175
- className: S.observations,
175
+ className: N.observations,
176
176
  children: [
177
177
  /* @__PURE__ */ l(
178
178
  x,
@@ -180,7 +180,7 @@ const B = (t, i, c, d, u, r) => {
180
180
  id: "observations-title",
181
181
  testId: h ? `observations-title-${E}` : "observations-title",
182
182
  title: E,
183
- className: S.title,
183
+ className: N.title,
184
184
  children: /* @__PURE__ */ l("p", { children: E })
185
185
  }
186
186
  ),
@@ -1 +1 @@
1
- {"version":3,"file":"FormsTable.d.ts","sourceRoot":"","sources":["../../src/forms/FormsTable.tsx"],"names":[],"mappings":"AAyBA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAWhD;;;GAGG;AACH,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAiSrC,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;AAUhD;;;GAGG;AACH,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA+RrC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1,38 +1,8 @@
1
- import { Bundle, Observation } from 'fhir/r4';
2
- import { ExtractedObservation } from '../observations/models';
3
- export interface FormFieldData {
4
- obs: ExtractedObservation;
5
- comment?: string;
6
- formFieldPath?: string;
7
- }
1
+ import { Observation } from 'fhir/r4';
8
2
  /**
9
3
  * Extract formFieldPath from FHIR Observation extension
10
4
  * @param observation - FHIR Observation resource
11
5
  * @returns formFieldPath string or undefined
12
6
  */
13
7
  export declare const extractFormFieldPath: (observation: Observation | undefined) => string | undefined;
14
- /**
15
- * Extract comment from FHIR Observation note field
16
- * @param observation - FHIR Observation resource
17
- * @returns comment string or undefined
18
- */
19
- export declare const extractComment: (observation: Observation | undefined) => string | undefined;
20
- /**
21
- * Extract form field data (formFieldPath and comment) from a FHIR Observation
22
- * @param bundle - FHIR Bundle containing Observations
23
- * @param obsId - Observation ID to extract data for
24
- * @returns Object with formFieldPath and comment
25
- */
26
- export declare const getFormFieldPathAndComment: (bundle: Bundle<Observation>, obsId: string) => {
27
- formFieldPath?: string;
28
- comment?: string;
29
- };
30
- /**
31
- * Filter observations by form name using formFieldPath
32
- * Observations without formFieldPath are included (assumed to belong to the form)
33
- * @param bundle - FHIR Bundle containing Observations
34
- * @param formName - Name of the form to filter by
35
- * @returns Array of FormFieldData with observations filtered by form name
36
- */
37
- export declare const filterObservationsByFormName: (bundle: Bundle<Observation>, formName: string) => FormFieldData[];
38
8
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/forms/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,oBAAoB,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,aAAa,WAAW,GAAG,SAAS,KACnC,MAAM,GAAG,SAQX,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,GACzB,aAAa,WAAW,GAAG,SAAS,KACnC,MAAM,GAAG,SAGX,CAAC;AAgBF;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,GACrC,QAAQ,MAAM,CAAC,WAAW,CAAC,EAC3B,OAAO,MAAM,KACZ;IAAE,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAS5C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACvC,QAAQ,MAAM,CAAC,WAAW,CAAC,EAC3B,UAAU,MAAM,KACf,aAAa,EA6Bf,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/forms/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,aAAa,WAAW,GAAG,SAAS,KACnC,MAAM,GAAG,SAQX,CAAC"}