@bahmni/widgets 0.0.1-dev.198 → 0.0.1-dev.201

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,10 +1,10 @@
1
1
  import { jsx as s, jsxs as l, Fragment as k } from "react/jsx-runtime";
2
- import { u as V, a as H, b as P, F as q, j as z, c as G, y as Y } from "./index-ByYJKxXq.js";
3
- import { useQuery as K } from "@tanstack/react-query";
4
- import { useState as C, useCallback as E, useEffect as M, useMemo as f } from "react";
5
- import { useTranslation as Q } from "react-i18next";
6
- const W = "_documentsTableBody_1voj8_1", X = "_viewAttachmentsLink_1voj8_11", J = "_documentViewerContainer_1voj8_15", Z = "_attachmentItem_1voj8_23", x = "_attachmentCounter_1voj8_27", ee = "_attachmentError_1voj8_36", te = "_documentIframe_1voj8_44", ne = "_documentImage_1voj8_50", c = {
7
- documentsTableBody: W,
2
+ import { u as V, a as H, v as P, F as q, W as z, c as G, y as W } from "./index-DXZBHaBY.js";
3
+ import { useQuery as Y } from "@tanstack/react-query";
4
+ import { useState as C, useCallback as E, useEffect as L, useMemo as f } from "react";
5
+ import { useTranslation as K } from "react-i18next";
6
+ const Q = "_documentsTableBody_1voj8_1", X = "_viewAttachmentsLink_1voj8_11", J = "_documentViewerContainer_1voj8_15", Z = "_attachmentItem_1voj8_23", x = "_attachmentCounter_1voj8_27", ee = "_attachmentError_1voj8_36", te = "_documentIframe_1voj8_44", ne = "_documentImage_1voj8_50", c = {
7
+ documentsTableBody: Q,
8
8
  viewAttachmentsLink: X,
9
9
  documentViewerContainer: J,
10
10
  attachmentItem: Z,
@@ -19,7 +19,7 @@ const W = "_documentsTableBody_1voj8_1", X = "_viewAttachmentsLink_1voj8_11", J
19
19
  uploadedBy: "DOCUMENTS_UPLOADED_BY",
20
20
  action: "DOCUMENTS_ACTION"
21
21
  };
22
- function U(t) {
22
+ function M(t) {
23
23
  return !t || t.includes(":") ? "#" : `/openmrs/auth?requested_document=/document_images/${t}`;
24
24
  }
25
25
  function oe(t, u) {
@@ -34,35 +34,35 @@ const re = [
34
34
  "uploadedOn",
35
35
  "uploadedBy",
36
36
  "action"
37
- ], se = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, v = (t) => t.attachments.length > 0 ? t.attachments : t.documentUrl ? [{ url: t.documentUrl, contentType: t.contentType }] : [], ue = ({ config: t, encounterUuids: u }) => {
37
+ ], se = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, U = (t) => t.attachments.length > 0 ? t.attachments : t.documentUrl ? [{ url: t.documentUrl, contentType: t.contentType }] : [], ue = ({ config: t, encounterUuids: u }) => {
38
38
  const [d, g] = C(!1), [a, O] = C(
39
39
  null
40
40
  ), [w, T] = C(
41
41
  /* @__PURE__ */ new Set()
42
- ), p = V(), { t: n } = Q(), { addNotification: y } = H(), S = E((e) => {
42
+ ), p = V(), { t: n } = K(), { addNotification: y } = H(), S = E((e) => {
43
43
  O(e), g(!0);
44
44
  }, []), b = E(() => {
45
45
  g(!1), O(null), T(/* @__PURE__ */ new Set());
46
- }, []), L = E((e) => {
46
+ }, []), v = E((e) => {
47
47
  T((o) => new Set(o).add(e));
48
- }, []), { data: j, isLoading: B, isError: I, error: A } = K({
48
+ }, []), { data: B, isLoading: j, isError: I, error: A } = Y({
49
49
  queryKey: ["documents", p, u],
50
50
  enabled: !!p,
51
51
  queryFn: () => P(p, u)
52
52
  });
53
- M(() => {
53
+ L(() => {
54
54
  I && y({
55
55
  title: n("ERROR_DEFAULT_TITLE"),
56
56
  message: A?.message ?? "",
57
57
  type: "error"
58
58
  });
59
- }, [I, A, y, n]), M(() => {
59
+ }, [I, A, y, n]), L(() => {
60
60
  const e = new AbortController();
61
61
  return (async () => {
62
62
  if (!d || !a) return;
63
- const r = /* @__PURE__ */ new Set(), _ = v(a);
63
+ const r = /* @__PURE__ */ new Set(), _ = U(a);
64
64
  for (let m = 0; m < _.length; m++) {
65
- const N = U(_[m].url);
65
+ const N = M(_[m].url);
66
66
  try {
67
67
  (await fetch(N, {
68
68
  method: "HEAD",
@@ -85,7 +85,7 @@ const re = [
85
85
  })),
86
86
  [h]
87
87
  ), i = f(
88
- () => a ? v(a) : [],
88
+ () => a ? U(a) : [],
89
89
  [a]
90
90
  ), $ = E(
91
91
  (e, o) => {
@@ -124,8 +124,8 @@ const re = [
124
124
  {
125
125
  headers: F,
126
126
  ariaLabel: n("DOCUMENTS_TABLE_HEADING"),
127
- rows: j ?? [],
128
- loading: B,
127
+ rows: B ?? [],
128
+ loading: j,
129
129
  errorStateMessage: I ? A?.message : null,
130
130
  sortable: R,
131
131
  emptyStateMessage: n("DOCUMENTS_NO_RECORDS"),
@@ -135,7 +135,7 @@ const re = [
135
135
  }
136
136
  ) }),
137
137
  d && a && /* @__PURE__ */ s(
138
- Y,
138
+ W,
139
139
  {
140
140
  id: "modalIdForActionAreaLayout",
141
141
  portalId: "main-display-area",
@@ -146,7 +146,7 @@ const re = [
146
146
  size: "lg",
147
147
  testId: "document-view-modal",
148
148
  children: /* @__PURE__ */ s("div", { className: c.documentViewerContainer, children: i.map((e, o) => {
149
- const r = U(e.url), _ = e.contentType?.toLowerCase().includes("pdf"), m = (e.contentType?.toLowerCase().includes("image") ?? !1) || se.test(e.url ?? ""), N = w.has(o);
149
+ const r = M(e.url), _ = e.contentType?.toLowerCase().includes("pdf"), m = (e.contentType?.toLowerCase().includes("image") ?? !1) || se.test(e.url ?? ""), N = w.has(o);
150
150
  return r === "#" || N ? /* @__PURE__ */ l(
151
151
  "div",
152
152
  {
@@ -179,7 +179,7 @@ const re = [
179
179
  src: r,
180
180
  alt: a.documentIdentifier,
181
181
  className: c.documentImage,
182
- onError: () => L(o)
182
+ onError: () => v(o)
183
183
  }
184
184
  ) : /* @__PURE__ */ s(
185
185
  "iframe",
@@ -187,7 +187,7 @@ const re = [
187
187
  src: _ ? `${r}#toolbar=0` : r,
188
188
  className: c.documentIframe,
189
189
  title: a.documentIdentifier,
190
- onError: () => L(o)
190
+ onError: () => v(o)
191
191
  }
192
192
  )
193
193
  ]
@@ -1,6 +1,6 @@
1
1
  import { jsxs as b, jsx as o, Fragment as j } from "react/jsx-runtime";
2
- import { f as K, d as R, Z as ae, r as oe, o as se, e as ne, g as de, i as ie, u as le, h as ce, W as me, K as ue, Y as pe, k as be, l as fe, j as _e, F as ye, c as P, m as he, n as $e, y as ge, D as Ne, R as k } from "./index-ByYJKxXq.js";
3
- import { useQueryClient as ve, useQuery as O } from "@tanstack/react-query";
2
+ import { f as K, b as R, d as ae, r as oe, o as se, e as ne, g as de, h as ie, u as le, J as ce, s as me, i as ue, n as pe, j as be, k as fe, W as _e, F as ye, c as P, l as he, m as $e, y as ge, D as ve, R as k } from "./index-DXZBHaBY.js";
3
+ import { useQueryClient as Ne, useQuery as O } from "@tanstack/react-query";
4
4
  import { useState as H, useMemo as g, useCallback as L } from "react";
5
5
  import { useTranslation as V } from "react-i18next";
6
6
  const Fe = "_formsTableBody_1pd36_1", Oe = "_customAccordianItem_1pd36_6", Le = "_formContent_1pd36_18", Re = "_formDetailsContainer_1pd36_25", Me = "_observation_1pd36_30", Ce = "_groupContainer_1pd36_39", De = "_rowContainer_1pd36_43", Te = "_groupLabel_1pd36_48", Ve = "_rowLabel_1pd36_58", we = "_rowValue_1pd36_67", Ie = "_groupMembers_1pd36_75", Ee = "_memberRow_1pd36_81", Be = "_memberLabel_1pd36_86", Ae = "_memberValue_1pd36_94", Ge = "_abnormalValue_1pd36_102", Se = "_commentSection_1pd36_110", qe = "_commentText_1pd36_116", Ue = "_nestedGroup_1pd36_125", xe = "_nestedGroupLabel_1pd36_132", Pe = "_nestedGroupMembers_1pd36_141", s = {
@@ -40,7 +40,7 @@ const Fe = "_formsTableBody_1pd36_1", Oe = "_customAccordianItem_1pd36_6", Le =
40
40
  n && d ? i = ` (${r} - ${a})` : n ? i = ` (>${r})` : d && (i = ` (<${a})`);
41
41
  const u = e.observationValue?.isAbnormal === !0;
42
42
  return { rangeString: i, isAbnormal: u };
43
- }, Y = ({
43
+ }, z = ({
44
44
  member: e,
45
45
  depth: r = 0,
46
46
  memberIndex: a = 0,
@@ -69,15 +69,15 @@ const Fe = "_formsTableBody_1pd36_1", Oe = "_customAccordianItem_1pd36_6", Le =
69
69
  {
70
70
  className: s.nestedGroupMembers,
71
71
  "data-testid": `${c}obs-nested-group-members-${t}-${a}`,
72
- children: e.members?.map((N, v) => /* @__PURE__ */ o(
73
- Y,
72
+ children: e.members?.map((v, N) => /* @__PURE__ */ o(
73
+ z,
74
74
  {
75
- member: N,
75
+ member: v,
76
76
  depth: r + 1,
77
- memberIndex: v,
77
+ memberIndex: N,
78
78
  formName: n
79
79
  },
80
- `${N.id}`
80
+ `${v.id}`
81
81
  ))
82
82
  }
83
83
  )
@@ -173,7 +173,7 @@ const Fe = "_formsTableBody_1pd36_1", Oe = "_customAccordianItem_1pd36_6", Le =
173
173
  className: s.groupMembers,
174
174
  "data-testid": `${c}observation-group-members-${e.display}-${r}`,
175
175
  children: e.members?.map((_, y) => /* @__PURE__ */ o(
176
- Y,
176
+ z,
177
177
  {
178
178
  member: _,
179
179
  depth: 0,
@@ -245,7 +245,7 @@ const Fe = "_formsTableBody_1pd36_1", Oe = "_customAccordianItem_1pd36_6", Le =
245
245
  ].filter(
246
246
  ({ formFieldPath: d }) => !d || d.includes(r)
247
247
  );
248
- }, Xe = ({
248
+ }, Ze = ({
249
249
  episodeOfCareUuids: e,
250
250
  encounterUuids: r,
251
251
  config: a
@@ -253,12 +253,12 @@ const Fe = "_formsTableBody_1pd36_1", Oe = "_customAccordianItem_1pd36_6", Le =
253
253
  const { t: n } = V(), d = le(), [i, u] = H(!1), [t, c] = H(null), $ = a?.numberOfVisits, f = ce(
254
254
  e,
255
255
  r
256
- ), _ = ve(), {
256
+ ), _ = Ne(), {
257
257
  data: y = [],
258
- isLoading: N,
259
- isError: v,
260
- error: z,
261
- refetch: Z
258
+ isLoading: v,
259
+ isError: N,
260
+ error: J,
261
+ refetch: Y
262
262
  } = O({
263
263
  queryKey: ["forms", d, e],
264
264
  queryFn: () => me(d, void 0, $),
@@ -274,13 +274,13 @@ const Fe = "_formsTableBody_1pd36_1", Oe = "_customAccordianItem_1pd36_6", Le =
274
274
  ), M = g(() => {
275
275
  if (t)
276
276
  return E(t.formName);
277
- }, [t, E]), { isLoading: J, error: B } = O({
277
+ }, [t, E]), { isLoading: X, error: B } = O({
278
278
  queryKey: ["formMetadata", M],
279
279
  queryFn: () => pe(M),
280
280
  enabled: !!M && i
281
281
  }), {
282
282
  data: C,
283
- isLoading: X,
283
+ isLoading: Z,
284
284
  error: A
285
285
  } = O({
286
286
  queryKey: ["formsEncounterFHIR", t?.encounterUuid],
@@ -289,7 +289,7 @@ const Fe = "_formsTableBody_1pd36_1", Oe = "_customAccordianItem_1pd36_6", Le =
289
289
  });
290
290
  fe(
291
291
  (l) => {
292
- l.patientUUID === d && l.updatedConcepts.size > 0 && (Z(), _.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
292
+ l.patientUUID === d && l.updatedConcepts.size > 0 && (Y(), _.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
293
293
  },
294
294
  [d]
295
295
  );
@@ -351,14 +351,14 @@ const Fe = "_formsTableBody_1pd36_1", Oe = "_customAccordianItem_1pd36_6", Le =
351
351
  [U]
352
352
  );
353
353
  return /* @__PURE__ */ b(j, { children: [
354
- /* @__PURE__ */ o("div", { "data-testid": "forms-table", children: N || v || q.length === 0 || f ? /* @__PURE__ */ o(
354
+ /* @__PURE__ */ o("div", { "data-testid": "forms-table", children: v || N || q.length === 0 || f ? /* @__PURE__ */ o(
355
355
  P,
356
356
  {
357
357
  headers: S,
358
358
  ariaLabel: n("FORMS_HEADING"),
359
359
  rows: [],
360
- loading: N,
361
- errorStateMessage: v ? z?.message : void 0,
360
+ loading: v,
361
+ errorStateMessage: N ? J?.message : void 0,
362
362
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
363
363
  renderCell: x,
364
364
  className: s.formsTableBody,
@@ -404,7 +404,7 @@ const Fe = "_formsTableBody_1pd36_1", Oe = "_customAccordianItem_1pd36_6", Le =
404
404
  passiveModal: !0,
405
405
  size: "md",
406
406
  testId: "form-details-modal",
407
- children: /* @__PURE__ */ o("div", { className: s.formContent, children: J || X ? /* @__PURE__ */ o(Ne, { width: "100%", lineCount: 3 }) : B ? /* @__PURE__ */ o("div", { children: k(B).message ?? n("ERROR_FETCHING_FORM_METADATA") }) : A ? /* @__PURE__ */ o("div", { children: k(A).message ?? n("ERROR_FETCHING_FORM_DATA") }) : G.length > 0 ? /* @__PURE__ */ o("div", { className: s.formDetailsContainer, children: G.map(({ obs: l, comment: h }, m) => /* @__PURE__ */ o(
407
+ children: /* @__PURE__ */ o("div", { className: s.formContent, children: X || Z ? /* @__PURE__ */ o(ve, { width: "100%", lineCount: 3 }) : B ? /* @__PURE__ */ o("div", { children: k(B).message ?? n("ERROR_FETCHING_FORM_METADATA") }) : A ? /* @__PURE__ */ o("div", { children: k(A).message ?? n("ERROR_FETCHING_FORM_DATA") }) : G.length > 0 ? /* @__PURE__ */ o("div", { className: s.formDetailsContainer, children: G.map(({ obs: l, comment: h }, m) => /* @__PURE__ */ o(
408
408
  ke,
409
409
  {
410
410
  observation: l,
@@ -419,5 +419,5 @@ const Fe = "_formsTableBody_1pd36_1", Oe = "_customAccordianItem_1pd36_6", Le =
419
419
  ] });
420
420
  };
421
421
  export {
422
- Xe as default
422
+ Ze as default
423
423
  };
@@ -1,17 +1,17 @@
1
1
  import { jsx as d, jsxs as S } from "react/jsx-runtime";
2
- import { p as q, q as U, t as M, Z as V, J as k, r as w, o as K, e as G, u as P, a as H, Q as j, U as J, l as Z, g as z, s as Y, v as W, w as X, c as x } from "./index-ByYJKxXq.js";
2
+ import { p as q, q as C, t as M, d as V, w, r as G, o as K, e as Q, u as P, a as H, x as j, G as z, k as J, g as Y, z as W, A as X, B as Z, c as x } from "./index-DXZBHaBY.js";
3
3
  import { useQueries as ee, useQuery as te } from "@tanstack/react-query";
4
4
  import { useRef as se, useEffect as $, useMemo as h } from "react";
5
- import { useTranslation as C } from "react-i18next";
6
- const D = (t, c, i, l, r) => {
5
+ import { useTranslation as D } from "react-i18next";
6
+ const U = (t, c, i, l, r) => {
7
7
  const s = M(t, c, r), o = s.value, a = V(o);
8
8
  let n = o;
9
- a === "Image" && (n = /* @__PURE__ */ d(w, { imageSrc: o, alt: o, id: `${o}-img` })), a === "Video" && (n = /* @__PURE__ */ d(K, { id: `${o}-video`, videoSrc: o })), a === "PDF" && (n = /* @__PURE__ */ d(G, { id: `${o}-pdf`, src: o }));
9
+ a === "Image" && (n = /* @__PURE__ */ d(G, { imageSrc: o, alt: o, id: `${o}-img` })), a === "Video" && (n = /* @__PURE__ */ d(K, { id: `${o}-video`, videoSrc: o })), a === "PDF" && (n = /* @__PURE__ */ d(Q, { id: `${o}-pdf`, src: o }));
10
10
  const u = r("OBSERVATIONS_RECORDED_BY", {
11
11
  provider: s.provider
12
12
  }), b = t.display, p = t.observationValue?.isAbnormal ? "abnormal-obs" : "obs", f = l ? `${l}-${p}-${b}-${i}-${c}` : `${p}-${b}-${i}-${c}`;
13
13
  return /* @__PURE__ */ d(
14
- k,
14
+ w,
15
15
  {
16
16
  header: s.header,
17
17
  value: n,
@@ -23,13 +23,13 @@ const D = (t, c, i, l, r) => {
23
23
  `obs-${t.id}`
24
24
  );
25
25
  }, oe = (t, c, i, l, r, s) => /* @__PURE__ */ d(
26
- U,
26
+ C,
27
27
  {
28
28
  title: t.display,
29
29
  id: `grouped-obs-${t.display}-${l}`,
30
30
  open: i,
31
31
  children: t.members?.map(
32
- (o, a) => D(o, a, r, s, c)
32
+ (o, a) => U(o, a, r, s, c)
33
33
  )
34
34
  },
35
35
  `grouped-obs-${t.id}`
@@ -37,17 +37,17 @@ const D = (t, c, i, l, r) => {
37
37
  groupedData: t,
38
38
  title: c = ""
39
39
  }) => {
40
- const { t: i } = C(), l = (r, s, o) => {
40
+ const { t: i } = D(), l = (r, s, o) => {
41
41
  const a = q(r.encounterDetails, i);
42
42
  return /* @__PURE__ */ S(
43
- U,
43
+ C,
44
44
  {
45
45
  title: a,
46
46
  id: `encounter-${r.encounterId}`,
47
47
  open: s,
48
48
  children: [
49
49
  r.observations.map(
50
- (n, u) => D(n, u, o, c, i)
50
+ (n, u) => U(n, u, o, c, i)
51
51
  ),
52
52
  r.groupedObservations.map(
53
53
  (n, u) => oe(
@@ -79,7 +79,7 @@ const D = (t, c, i, l, r) => {
79
79
  observations: ae,
80
80
  title: ne
81
81
  }, ie = (t) => ["conceptUuid", t], ce = (t, c) => ["observations", t, ...c], me = ({ config: t }) => {
82
- const c = t, { conceptNames: i = [], conceptUuid: l = [] } = c, r = se(/* @__PURE__ */ new Set()), s = P(), { addNotification: o } = H(), { t: a } = C(), n = ee({
82
+ const c = t, { conceptNames: i = [], conceptUuid: l = [] } = c, r = se(/* @__PURE__ */ new Set()), s = P(), { addNotification: o } = H(), { t: a } = D(), n = ee({
83
83
  queries: i.map((e) => ({
84
84
  queryKey: ie(e),
85
85
  queryFn: () => j(e),
@@ -105,10 +105,10 @@ const D = (t, c, i, l, r) => {
105
105
  refetch: R
106
106
  } = te({
107
107
  queryKey: ce(s, b),
108
- queryFn: () => J(s, b),
108
+ queryFn: () => z(s, b),
109
109
  enabled: !!s && b.length > 0 && v
110
110
  });
111
- Z(
111
+ J(
112
112
  (e) => {
113
113
  e.patientUUID === s && e.updatedConcepts.size > 0 && [...e.updatedConcepts.keys()].some(
114
114
  (O) => b.includes(O)
@@ -124,13 +124,13 @@ const D = (t, c, i, l, r) => {
124
124
  }, [g]);
125
125
  const T = h(() => {
126
126
  if (!p) return [];
127
- const e = z(p), m = Y(e);
128
- return W(m);
127
+ const e = Y(p), m = W(e);
128
+ return X(m);
129
129
  }, [p]), B = [
130
130
  { key: "name", header: "name" },
131
131
  { key: "value", header: "value" },
132
132
  { key: "form", header: "form" }
133
- ], I = f || !v, _ = g && v, A = (!p || p.entry?.length === 0 || b.length === 0) && v, F = _ ? a("ERROR_FETCHING_OBSERVATIONS") : null, L = A ? a("NO_OBSERVATIONS_FOUND") : void 0, Q = T.length > 0 && !I && !_, E = c.titleTranslationKey, y = E ? a(E) : "";
133
+ ], I = f || !v, _ = g && v, A = (!p || p.entry?.length === 0 || b.length === 0) && v, F = _ ? a("ERROR_FETCHING_OBSERVATIONS") : null, L = A ? a("NO_OBSERVATIONS_FOUND") : void 0, k = T.length > 0 && !I && !_, E = c.titleTranslationKey, y = E ? a(E) : "";
134
134
  return /* @__PURE__ */ S(
135
135
  "div",
136
136
  {
@@ -140,7 +140,7 @@ const D = (t, c, i, l, r) => {
140
140
  className: N.observations,
141
141
  children: [
142
142
  /* @__PURE__ */ d(
143
- X,
143
+ Z,
144
144
  {
145
145
  id: "observations-title",
146
146
  testId: E ? `observations-title-${y}` : "observations-title",
@@ -149,7 +149,7 @@ const D = (t, c, i, l, r) => {
149
149
  children: /* @__PURE__ */ d("p", { children: y })
150
150
  }
151
151
  ),
152
- Q ? /* @__PURE__ */ d(re, { groupedData: T, title: y }) : /* @__PURE__ */ d(
152
+ k ? /* @__PURE__ */ d(re, { groupedData: T, title: y }) : /* @__PURE__ */ d(
153
153
  x,
154
154
  {
155
155
  headers: B,