@bahmni/widgets 0.0.1-dev.117 → 0.0.1-dev.118

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,8 +1,8 @@
1
- import { jsxs as _, jsx as t, Fragment as Y } from "react/jsx-runtime";
2
- import { c as h, u as W, C as X, F as Z, q as ee, U as re, I as oe, l as te, i as ae, J as $, e as ne, t as se, K as ce, a as de, b as U, d as me } from "./index-D-YpLeDp.js";
1
+ import { jsxs as _, jsx as t, Fragment as J } from "react/jsx-runtime";
2
+ import { c as h, u as W, C as X, F as Z, q as ee, U as re, I as oe, l as te, e as ae, P as $, i as ne, f as se, p as ce, a as de, b as U, d as le } from "./index-Ciduksrd.js";
3
3
  import { useQuery as g } from "@tanstack/react-query";
4
4
  import { useState as q, useMemo as b, useCallback as N } from "react";
5
- import { createPortal as le } from "react-dom";
5
+ import { createPortal as me } from "react-dom";
6
6
  import { useTranslation as ie } from "react-i18next";
7
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", Ne = "_rowContainer_1pd36_43", he = "_groupLabel_1pd36_48", ye = "_rowLabel_1pd36_58", Me = "_rowValue_1pd36_67", Le = "_groupMembers_1pd36_75", Ae = "_memberRow_1pd36_81", Oe = "_memberLabel_1pd36_86", Re = "_memberValue_1pd36_94", Ce = "_abnormalValue_1pd36_102", De = "_commentSection_1pd36_110", Fe = "_commentText_1pd36_116", Te = "_nestedGroup_1pd36_125", ve = "_nestedGroupLabel_1pd36_132", Ee = "_nestedGroupMembers_1pd36_141", r = {
8
8
  formsTableBody: ue,
@@ -26,9 +26,9 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
26
26
  nestedGroupLabel: ve,
27
27
  nestedGroupMembers: Ee
28
28
  }, we = "ABNORMAL", x = (e) => {
29
- const s = e.concept?.units, c = e.concept?.lowNormal, o = e.concept?.hiNormal, l = c != null, i = o != null, p = l && i ? ` (${c} - ${o})` : l ? ` (>${c})` : i ? ` (<${o})` : "", a = e.interpretation && e.interpretation.toUpperCase() === we;
29
+ const s = e.concept?.units, c = e.concept?.lowNormal, o = e.concept?.hiNormal, m = c != null, i = o != null, p = m && i ? ` (${c} - ${o})` : m ? ` (>${c})` : i ? ` (<${o})` : "", a = e.interpretation && e.interpretation.toUpperCase() === we;
30
30
  return { units: s, rangeString: p, isAbnormal: a };
31
- }, k = ({
31
+ }, P = ({
32
32
  member: e,
33
33
  depth: s = 0
34
34
  }) => {
@@ -44,7 +44,7 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
44
44
  }
45
45
  ),
46
46
  /* @__PURE__ */ t("div", { className: r.nestedGroupMembers, children: e.groupMembers?.map((a) => /* @__PURE__ */ t(
47
- k,
47
+ P,
48
48
  {
49
49
  member: a,
50
50
  depth: s + 1
@@ -52,7 +52,7 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
52
52
  `${a.concept.uuid}`
53
53
  )) })
54
54
  ] });
55
- const { units: l, rangeString: i, isAbnormal: p } = x(e);
55
+ const { units: m, rangeString: i, isAbnormal: p } = x(e);
56
56
  return /* @__PURE__ */ _(
57
57
  "div",
58
58
  {
@@ -81,7 +81,7 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
81
81
  ),
82
82
  children: [
83
83
  e.valueAsString,
84
- l && ` ${l}`
84
+ m && ` ${m}`
85
85
  ]
86
86
  }
87
87
  )
@@ -92,7 +92,7 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
92
92
  observation: e,
93
93
  index: s
94
94
  }) => {
95
- const c = e.groupMembers && e.groupMembers.length > 0, { units: o, rangeString: l, isAbnormal: i } = x(e);
95
+ const c = e.groupMembers && e.groupMembers.length > 0, { units: o, rangeString: m, isAbnormal: i } = x(e);
96
96
  return /* @__PURE__ */ _(
97
97
  "div",
98
98
  {
@@ -112,12 +112,12 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
112
112
  ),
113
113
  children: [
114
114
  e.conceptNameToDisplay,
115
- !c && l && /* @__PURE__ */ t("span", { className: r.rangeInfo, children: l })
115
+ !c && m && /* @__PURE__ */ t("span", { className: r.rangeInfo, children: m })
116
116
  ]
117
117
  }
118
118
  ),
119
119
  c ? /* @__PURE__ */ t("div", { className: r.groupMembers, children: e.groupMembers?.map((p) => /* @__PURE__ */ t(
120
- k,
120
+ P,
121
121
  {
122
122
  member: p,
123
123
  depth: 0
@@ -152,18 +152,18 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
152
152
  encounterUuids: s,
153
153
  config: c
154
154
  }) => {
155
- const { t: o } = ie(), l = W(), [i, p] = q(!1), [a, O] = q(null), H = c?.numberOfVisits, R = X(
155
+ const { t: o } = ie(), m = W(), [i, p] = q(!1), [a, O] = q(null), k = c?.numberOfVisits, R = X(
156
156
  e,
157
157
  s
158
158
  ), {
159
159
  data: y = [],
160
160
  isLoading: C,
161
161
  isError: D,
162
- error: K
162
+ error: H
163
163
  } = g({
164
- queryKey: ["forms", l, e],
165
- queryFn: () => Z(l, void 0, H),
166
- enabled: !!l && !R
164
+ queryKey: ["forms", m, e],
165
+ queryFn: () => Z(m, void 0, k),
166
+ enabled: !!m && !R
167
167
  }), F = b(() => !s || s.length === 0 ? y : y.filter(
168
168
  (n) => s.includes(n.encounterUuid)
169
169
  ), [y, s]), { data: T = [] } = g({
@@ -177,7 +177,7 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
177
177
  return v(a.formName);
178
178
  }, [a, v]), {
179
179
  data: Be,
180
- isLoading: P,
180
+ isLoading: j,
181
181
  error: E
182
182
  } = g({
183
183
  queryKey: ["formMetadata", M],
@@ -185,7 +185,7 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
185
185
  enabled: !!M && i
186
186
  }), {
187
187
  data: L,
188
- isLoading: j,
188
+ isLoading: K,
189
189
  error: w
190
190
  } = g({
191
191
  queryKey: ["formsEncounter", a?.encounterUuid],
@@ -199,7 +199,7 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
199
199
  { key: "recordedBy", header: o("FORM_RECORDED_BY") }
200
200
  ],
201
201
  [o]
202
- ), J = b(
202
+ ), z = b(
203
203
  () => [
204
204
  { key: "recordedOn", sortable: !0 },
205
205
  { key: "recordedBy", sortable: !0 }
@@ -207,32 +207,32 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
207
207
  []
208
208
  ), V = b(() => {
209
209
  const n = F.reduce(
210
- (d, m) => {
211
- const f = m.formName;
210
+ (d, l) => {
211
+ const f = l.formName;
212
212
  d[f] ??= [];
213
- const A = m.providers.map((Q) => Q.providerName).filter(Boolean).join(", ");
213
+ const A = l.providers.map((Y) => Y.providerName).filter(Boolean).join(", ");
214
214
  return d[f].push({
215
- id: m.encounterUuid,
216
- formName: m.formName,
217
- recordedOn: te(m.encounterDateTime, o, me).formattedResult,
215
+ id: l.encounterUuid,
216
+ formName: l.formName,
217
+ recordedOn: te(l.encounterDateTime, o, le).formattedResult,
218
218
  recordedBy: A ?? "--",
219
- encounterDateTime: m.encounterDateTime,
220
- encounterUuid: m.encounterUuid
219
+ encounterDateTime: l.encounterDateTime,
220
+ encounterUuid: l.encounterUuid
221
221
  }), d;
222
222
  },
223
223
  {}
224
224
  );
225
225
  return Object.entries(n).map(
226
- ([d, m]) => ({
226
+ ([d, l]) => ({
227
227
  formName: d,
228
- records: m.sort(
228
+ records: l.sort(
229
229
  (f, A) => A.encounterDateTime - f.encounterDateTime
230
230
  )
231
231
  })
232
- ).sort((d, m) => d.formName.localeCompare(m.formName));
232
+ ).sort((d, l) => d.formName.localeCompare(l.formName));
233
233
  }, [F, o]), S = N((n) => {
234
234
  O(n), p(!0);
235
- }, []), z = N(() => {
235
+ }, []), Q = N(() => {
236
236
  p(!1), O(null);
237
237
  }, []), G = N(
238
238
  (n, u) => {
@@ -247,7 +247,7 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
247
247
  },
248
248
  [S]
249
249
  );
250
- return /* @__PURE__ */ _(Y, { children: [
250
+ return /* @__PURE__ */ _(J, { children: [
251
251
  /* @__PURE__ */ t("div", { "data-testid": "forms-table", children: C || D || V.length === 0 || R ? /* @__PURE__ */ t(
252
252
  $,
253
253
  {
@@ -255,14 +255,14 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
255
255
  ariaLabel: o("FORMS_HEADING"),
256
256
  rows: [],
257
257
  loading: C,
258
- errorStateMessage: D ? K?.message : void 0,
258
+ errorStateMessage: D ? H?.message : void 0,
259
259
  emptyStateMessage: o("FORMS_UNAVAILABLE"),
260
260
  renderCell: G,
261
261
  className: r.formsTableBody,
262
262
  "data-testid": "sortable-data-table"
263
263
  }
264
264
  ) : /* @__PURE__ */ t(ne, { align: "start", children: V.map((n, u) => {
265
- const { formName: d, records: m } = n;
265
+ const { formName: d, records: l } = n;
266
266
  return /* @__PURE__ */ t(
267
267
  se,
268
268
  {
@@ -275,10 +275,10 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
275
275
  {
276
276
  headers: B,
277
277
  ariaLabel: o("FORMS_HEADING"),
278
- rows: m,
278
+ rows: l,
279
279
  loading: !1,
280
280
  errorStateMessage: "",
281
- sortable: J,
281
+ sortable: z,
282
282
  emptyStateMessage: o("FORMS_UNAVAILABLE"),
283
283
  renderCell: G,
284
284
  className: r.formsTableBody,
@@ -289,19 +289,19 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
289
289
  d
290
290
  );
291
291
  }) }) }),
292
- i && a && le(
292
+ i && a && me(
293
293
  /* @__PURE__ */ t(
294
294
  ce,
295
295
  {
296
296
  id: "formDetailsModal",
297
297
  open: i,
298
- onRequestClose: z,
298
+ onRequestClose: Q,
299
299
  modalHeading: a.formName,
300
300
  modalLabel: `${a.recordedOn} | ${a.recordedBy}`,
301
301
  passiveModal: !0,
302
302
  size: "md",
303
303
  testId: "form-details-modal",
304
- children: /* @__PURE__ */ t("div", { className: r.formContent, children: P || j ? /* @__PURE__ */ t(de, { width: "100%", lineCount: 3 }) : E ? /* @__PURE__ */ t("div", { children: U(E).message ?? o("ERROR_FETCHING_FORM_METADATA") }) : w ? /* @__PURE__ */ t("div", { children: U(w).message ?? o("ERROR_FETCHING_FORM_DATA") }) : I.length > 0 ? /* @__PURE__ */ t("div", { className: r.formDetailsContainer, children: I.map((n, u) => /* @__PURE__ */ t(
304
+ children: /* @__PURE__ */ t("div", { className: r.formContent, children: j || K ? /* @__PURE__ */ t(de, { width: "100%", lineCount: 3 }) : E ? /* @__PURE__ */ t("div", { children: U(E).message ?? o("ERROR_FETCHING_FORM_METADATA") }) : w ? /* @__PURE__ */ t("div", { children: U(w).message ?? o("ERROR_FETCHING_FORM_DATA") }) : I.length > 0 ? /* @__PURE__ */ t("div", { className: r.formDetailsContainer, children: I.map((n, u) => /* @__PURE__ */ t(
305
305
  Ie,
306
306
  {
307
307
  observation: n,
@@ -1,9 +1,9 @@
1
1
  import { jsx as l, jsxs as T } from "react/jsx-runtime";
2
- import { f as U, L as $, p as B, s as F, g as x, z as G, u as q, h as Q, G as k, O as K, R as P, J as H } from "./index-D-YpLeDp.js";
3
- import { useQueries as Y, useQuery as j } from "@tanstack/react-query";
4
- import { useRef as z, useEffect as R, useMemo as m } from "react";
2
+ import { g as B, h as $, j as F, v as L, m as x, k as G, u as k, n as q, G as P, O as Q, y as K, P as H } from "./index-Ciduksrd.js";
3
+ import { useQueries as j, useQuery as Y } from "@tanstack/react-query";
4
+ import { useRef as z, useEffect as R, useMemo as g } from "react";
5
5
  import { useTranslation as _ } from "react-i18next";
6
- const J = "normal", W = "http://terminology.hl7.org/CodeSystem/referencerange-meaning", X = "A", Z = "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", ee = (e, t) => e?.date ? U(e.date, t).formattedResult : t("DATE_ERROR_PARSE"), te = (e) => {
6
+ const J = "normal", W = "http://terminology.hl7.org/CodeSystem/referencerange-meaning", X = "A", Z = "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", ee = (e, t) => e?.date ? B(e.date, t).formattedResult : t("DATE_ERROR_PARSE"), te = (e) => {
7
7
  const { value: t, unit: n } = e.observationValue;
8
8
  return n ? `${t} ${n}` : String(t);
9
9
  }, ne = (e) => {
@@ -49,7 +49,7 @@ function se(e) {
49
49
  if (o && o.length > 0) {
50
50
  const a = o.find(
51
51
  (u) => u.type?.coding?.some(
52
- (p) => p.system === W && p.code === J
52
+ (v) => v.system === W && v.code === J
53
53
  )
54
54
  );
55
55
  a && (a.low || a.high) && (i.referenceRange = {
@@ -155,14 +155,14 @@ function ce(e) {
155
155
  });
156
156
  }
157
157
  const N = (e, t, n) => {
158
- const r = re(e, t), o = r.value, s = B(o);
158
+ const r = re(e, t), o = r.value, s = F(o);
159
159
  let i = o;
160
160
  s === "Image" && (i = /* @__PURE__ */ l(x, { imageSrc: o, alt: o, id: `${o}-img` })), s === "Video" && (i = /* @__PURE__ */ l(G, { id: `${o}-video`, videoSrc: o }));
161
161
  const a = n("OBSERVATIONS_RECORDED_BY", {
162
162
  provider: r.provider
163
163
  }), u = e.observationValue?.isAbnormal ? `abnormal-obs-${e.id}` : `obs-${e.id}`;
164
164
  return /* @__PURE__ */ l(
165
- F,
165
+ L,
166
166
  {
167
167
  header: r.header,
168
168
  value: i,
@@ -218,37 +218,37 @@ const N = (e, t, n) => {
218
218
  )
219
219
  }
220
220
  );
221
- }, pe = "_observations_kfbhq_1", ve = "_title_kfbhq_12", S = {
222
- observations: pe,
223
- title: ve
224
- }, fe = (e) => ["conceptUuid", e], ge = (e, t) => ["observations", e, ...t], Oe = ({ config: e }) => {
225
- const t = e, { conceptNames: n = [], conceptUuid: r = [] } = t, o = z(/* @__PURE__ */ new Set()), s = q(), { addNotification: i } = Q(), { t: a } = _(), u = Y({
221
+ }, ve = "_observations_kfbhq_1", pe = "_title_kfbhq_12", S = {
222
+ observations: ve,
223
+ title: pe
224
+ }, fe = (e) => ["conceptUuid", e], me = (e, t) => ["observations", e, ...t], Oe = ({ config: e }) => {
225
+ const t = e, { conceptNames: n = [], conceptUuid: r = [] } = t, o = z(/* @__PURE__ */ new Set()), s = k(), { addNotification: i } = q(), { t: a } = _(), u = j({
226
226
  queries: n.map((c) => ({
227
227
  queryKey: fe(c),
228
- queryFn: () => k(c),
228
+ queryFn: () => P(c),
229
229
  enabled: !!c
230
230
  }))
231
231
  });
232
232
  R(() => {
233
233
  u.forEach((c, d) => {
234
234
  if (c.isError && !o.current.has(d)) {
235
- const L = n[d];
235
+ const U = n[d];
236
236
  i({
237
237
  title: a("ERROR_DEFAULT_TITLE"),
238
- message: a("ERROR_FETCHING_CONCEPT", { conceptName: L }),
238
+ message: a("ERROR_FETCHING_CONCEPT", { conceptName: U }),
239
239
  type: "error"
240
240
  }), o.current.add(d);
241
241
  } else c.isError || o.current.delete(d);
242
242
  });
243
243
  }, [u, n]);
244
- const p = m(() => u.map((c) => c.data?.uuid).filter((c) => !!c), [u]), f = m(() => [.../* @__PURE__ */ new Set([...p, ...r])], [p, r]), g = m(() => n.length === 0 ? !0 : u.every((c) => !c.isLoading), [u, n.length]), {
245
- data: v,
244
+ const v = g(() => u.map((c) => c.data?.uuid).filter((c) => !!c), [u]), f = g(() => [.../* @__PURE__ */ new Set([...v, ...r])], [v, r]), m = g(() => n.length === 0 ? !0 : u.every((c) => !c.isLoading), [u, n.length]), {
245
+ data: p,
246
246
  isLoading: D,
247
247
  isError: h
248
- } = j({
249
- queryKey: ge(s, f),
250
- queryFn: () => K(s, f),
251
- enabled: !!s && f.length > 0 && g
248
+ } = Y({
249
+ queryKey: me(s, f),
250
+ queryFn: () => Q(s, f),
251
+ enabled: !!s && f.length > 0 && m
252
252
  });
253
253
  R(() => {
254
254
  h && i({
@@ -257,15 +257,15 @@ const N = (e, t, n) => {
257
257
  type: "error"
258
258
  });
259
259
  }, [h]);
260
- const E = m(() => {
261
- if (!v) return [];
262
- const c = ae(v), d = ue(c);
260
+ const y = g(() => {
261
+ if (!p) return [];
262
+ const c = ae(p), d = ue(c);
263
263
  return ce(d);
264
- }, [v]), A = [
264
+ }, [p]), A = [
265
265
  { key: "name", header: "name" },
266
266
  { key: "value", header: "value" },
267
267
  { key: "form", header: "form" }
268
- ], y = D || !g, O = h && g, w = (!v || v.entry?.length === 0 || f.length === 0) && g, C = O ? a("ERROR_FETCHING_OBSERVATIONS") : null, V = w ? a("NO_OBSERVATIONS_FOUND") : void 0, M = E.length > 0 && !y && !O;
268
+ ], E = D || !m, O = h && m, w = (!p || p.entry?.length === 0 || f.length === 0) && m, C = O ? a("ERROR_FETCHING_OBSERVATIONS") : null, V = w ? a("NO_OBSERVATIONS_FOUND") : void 0, M = y.length > 0 && !E && !O;
269
269
  return /* @__PURE__ */ T(
270
270
  "div",
271
271
  {
@@ -275,7 +275,7 @@ const N = (e, t, n) => {
275
275
  className: S.observations,
276
276
  children: [
277
277
  /* @__PURE__ */ l(
278
- P,
278
+ K,
279
279
  {
280
280
  id: "observations-title",
281
281
  testId: "observations-title-test-id",
@@ -284,13 +284,13 @@ const N = (e, t, n) => {
284
284
  children: /* @__PURE__ */ l("p", { children: a(t.titleTranslationKey) })
285
285
  }
286
286
  ),
287
- M ? /* @__PURE__ */ l(de, { groupedData: E }) : /* @__PURE__ */ l(
287
+ M ? /* @__PURE__ */ l(de, { groupedData: y }) : /* @__PURE__ */ l(
288
288
  H,
289
289
  {
290
290
  headers: A,
291
291
  rows: [],
292
292
  ariaLabel: a("OBSERVATIONS"),
293
- loading: y,
293
+ loading: E,
294
294
  errorStateMessage: C,
295
295
  emptyStateMessage: V
296
296
  }
@@ -302,5 +302,5 @@ const N = (e, t, n) => {
302
302
  export {
303
303
  fe as conceptUuidQueryKeys,
304
304
  Oe as default,
305
- ge as observationsQueryKeys
305
+ me as observationsQueryKeys
306
306
  };