@bahmni/appointments-app 0.0.1-dev.401 → 0.0.1-dev.405

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,7 +1,7 @@
1
1
  import { jsx as r, jsxs as p, Fragment as G } from "react/jsx-runtime";
2
- import { g as Q, u as Y, C as W, B as J, q as X, w as Z, K as ee, p as te } from "./index-BtK4jcwc.js";
2
+ import { v as Q, u as Y, z as J, J as W, q as X, w as Z, K as ee, p as te } from "./index-CDAgqrus.js";
3
3
  import { useQuery as ae } from "@tanstack/react-query";
4
- import { useState as l, useCallback as h, useEffect as D, useMemo as _ } from "react";
4
+ import { useState as l, useCallback as h, useEffect as I, useMemo as _ } from "react";
5
5
  const ne = "DocumentsTable-module_documentsTableBody__6iR3w", oe = "DocumentsTable-module_viewAttachmentsLink__aQ1on", re = "DocumentsTable-module_documentViewerContainer__F5m8D", de = "DocumentsTable-module_attachmentItem__17KA7", se = "DocumentsTable-module_attachmentCounter__WFiI3", me = "DocumentsTable-module_attachmentError__RI4U2", ce = "DocumentsTable-module_documentIframe__ptq5I", le = "DocumentsTable-module_documentImage__KQVgS", d = {
6
6
  documentsTableBody: ne,
7
7
  viewAttachmentsLink: oe,
@@ -18,13 +18,13 @@ const ne = "DocumentsTable-module_documentsTableBody__6iR3w", oe = "DocumentsTab
18
18
  uploadedBy: "DOCUMENTS_UPLOADED_BY",
19
19
  attachments: "DOCUMENTS_ATTACHMENTS"
20
20
  };
21
- function B(a) {
21
+ function R(a) {
22
22
  return !a || a.includes(":") ? "#" : `/openmrs/auth?requested_document=/document_images/${a}`;
23
23
  }
24
- function ie(a, g) {
24
+ function ie(a, E) {
25
25
  return a.map((s) => ({
26
26
  key: s,
27
- header: g(ue[s])
27
+ header: E(ue[s])
28
28
  }));
29
29
  }
30
30
  const Te = [
@@ -33,78 +33,78 @@ const Te = [
33
33
  "attachments",
34
34
  "uploadedOn",
35
35
  "uploadedBy"
36
- ], pe = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, R = (a) => a.attachments.length > 0 ? a.attachments : a.documentUrl ? [{ url: a.documentUrl, contentType: a.contentType }] : [], Ne = ({ config: a, encounterUuids: g }) => {
36
+ ], pe = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, B = (a) => a.attachments.length > 0 ? a.attachments : a.documentUrl ? [{ url: a.documentUrl, contentType: a.contentType }] : [], Ne = ({ config: a, encounterUuids: E }) => {
37
37
  const [s, w] = l(!1), [o, U] = l(
38
38
  null
39
- ), [$, I] = l(
39
+ ), [$, O] = l(
40
40
  /* @__PURE__ */ new Set()
41
- ), E = Q(), { t: n } = Y(), { addNotification: L } = W(), k = Number(a?.pageSize) || 5, [O, f] = l(1), [u, V] = l(k), [q, A] = l(void 0), M = h((e) => {
41
+ ), g = Q(), { t: n } = Y(), { addNotification: L } = J(), k = Number(a?.pageSize) || 5, [f, C] = l(1), [u, V] = l(k), [q, A] = l(void 0), M = h((e) => {
42
42
  U(e), w(!0);
43
43
  }, []), F = h(() => {
44
- w(!1), U(null), I(/* @__PURE__ */ new Set());
44
+ w(!1), U(null), O(/* @__PURE__ */ new Set());
45
45
  }, []), v = h((e) => {
46
- I((t) => new Set(t).add(e));
46
+ O((t) => new Set(t).add(e));
47
47
  }, []), { data: i, isLoading: H, isError: y, error: b } = ae({
48
48
  queryKey: [
49
49
  "documents",
50
- E,
51
50
  g,
52
- O,
51
+ E,
52
+ f,
53
53
  u
54
54
  ],
55
- enabled: !!E,
56
- queryFn: () => J(
57
- E,
55
+ enabled: !!g,
56
+ queryFn: () => W(
58
57
  g,
58
+ E,
59
59
  u,
60
- O
60
+ f
61
61
  )
62
62
  });
63
- D(() => {
63
+ I(() => {
64
64
  i && A(i.total);
65
- }, [i]), D(() => {
66
- f(1), A(void 0);
67
- }, [E]), D(() => {
65
+ }, [i]), I(() => {
66
+ C(1), A(void 0);
67
+ }, [g]), I(() => {
68
68
  y && L({
69
69
  title: n("ERROR_DEFAULT_TITLE"),
70
70
  message: b?.message ?? "",
71
71
  type: "error"
72
72
  });
73
- }, [y, b, L, n]), D(() => {
73
+ }, [y, b, L, n]), I(() => {
74
74
  const e = new AbortController();
75
75
  return (async () => {
76
76
  if (!s || !o) return;
77
- const t = /* @__PURE__ */ new Set(), m = R(o);
77
+ const t = /* @__PURE__ */ new Set(), m = B(o);
78
78
  for (let c = 0; c < m.length; c++) {
79
- const S = B(m[c].url);
79
+ const S = R(m[c].url);
80
80
  try {
81
81
  (await fetch(S, {
82
82
  method: "HEAD",
83
83
  signal: e.signal
84
84
  })).ok || t.add(c);
85
- } catch (C) {
86
- C instanceof Error && C.name !== "AbortError" && t.add(c);
85
+ } catch (D) {
86
+ D instanceof Error && D.name !== "AbortError" && t.add(c);
87
87
  }
88
88
  }
89
- e.signal.aborted || I(t);
89
+ e.signal.aborted || O(t);
90
90
  })(), () => e.abort();
91
91
  }, [s, o]);
92
- const K = h(
92
+ const z = h(
93
93
  (e, t) => {
94
- t !== u ? (V(t), f(1), A(void 0)) : f(e);
94
+ t !== u ? (V(t), C(1), A(void 0)) : C(e);
95
95
  },
96
96
  [u]
97
97
  ), N = _(
98
98
  () => a?.fields ?? Te,
99
99
  [a?.fields]
100
- ), j = _(() => [...i?.documents ?? []].sort((e, t) => !e.uploadedOn && !t.uploadedOn ? 0 : e.uploadedOn ? t.uploadedOn ? new Date(t.uploadedOn).getTime() - new Date(e.uploadedOn).getTime() : -1 : 1), [i]), P = _(() => ie(N, n), [N, n]), z = _(
100
+ ), K = _(() => [...i?.documents ?? []].sort((e, t) => !e.uploadedOn && !t.uploadedOn ? 0 : e.uploadedOn ? t.uploadedOn ? new Date(t.uploadedOn).getTime() - new Date(e.uploadedOn).getTime() : -1 : 1), [i]), j = _(() => ie(N, n), [N, n]), P = _(
101
101
  () => N.map((e) => ({
102
102
  key: e,
103
103
  sortable: e !== "attachments"
104
104
  })),
105
105
  [N]
106
106
  ), T = _(
107
- () => o ? R(o) : [],
107
+ () => o ? B(o) : [],
108
108
  [o]
109
109
  ), x = h(
110
110
  (e, t) => {
@@ -141,20 +141,20 @@ const Te = [
141
141
  /* @__PURE__ */ r("div", { "data-testid": "documents-table", children: /* @__PURE__ */ r(
142
142
  ee,
143
143
  {
144
- headers: P,
144
+ headers: j,
145
145
  ariaLabel: n("DOCUMENTS_TABLE_HEADING"),
146
- rows: j,
146
+ rows: K,
147
147
  loading: H,
148
148
  errorStateMessage: y ? b?.message : null,
149
- sortable: z,
149
+ sortable: P,
150
150
  emptyStateMessage: n("DOCUMENTS_NO_RECORDS"),
151
151
  renderCell: x,
152
152
  className: d.documentsTableBody,
153
153
  dataTestId: "documents-table",
154
154
  pageSize: u,
155
155
  totalItems: q,
156
- page: O,
157
- onPageChange: K
156
+ page: f,
157
+ onPageChange: z
158
158
  }
159
159
  ) }),
160
160
  s && o && /* @__PURE__ */ r(
@@ -169,8 +169,8 @@ const Te = [
169
169
  size: "lg",
170
170
  testId: "document-view-modal",
171
171
  children: /* @__PURE__ */ r("div", { className: d.documentViewerContainer, children: T.map((e, t) => {
172
- const m = B(e.url), c = e.contentType?.toLowerCase().includes("pdf"), S = (e.contentType?.toLowerCase().includes("image") ?? !1) || pe.test(e.url ?? ""), C = $.has(t);
173
- return m === "#" || C ? /* @__PURE__ */ p(
172
+ const m = R(e.url), c = e.contentType?.toLowerCase().includes("pdf"), S = (e.contentType?.toLowerCase().includes("image") ?? !1) || pe.test(e.url ?? ""), D = $.has(t);
173
+ return m === "#" || D ? /* @__PURE__ */ p(
174
174
  "div",
175
175
  {
176
176
  className: d.attachmentError,
@@ -1,50 +1,50 @@
1
1
  import { jsx as i, jsxs as P, Fragment as ye } from "react/jsx-runtime";
2
- import { u as ge, g as be, e as Ne, a as Oe, v as Te, k as Ee, o as Ie, Z as ve, F as Ae, m as _e, Y as Fe, G as Se, b as $, w as Be, N as x, E as G, q as Me, K as Y, c as Re, P as Ce, p as Le, d as Ue, n as ke } from "./index-BtK4jcwc.js";
3
- import { useQueryClient as De, useQuery as O } from "@tanstack/react-query";
2
+ import { u as ge, v as be, e as Oe, a as Ne, b as Te, Y as Ie, d as Ae, c as Ee, f as ve, m as _e, g as Fe, h as Se, i as $, w as Me, A as x, V as Y, q as Re, K as G, P as Be, F as Ce, p as Le, j as Ue, k as De } from "./index-CDAgqrus.js";
3
+ import { useQueryClient as ke, useQuery as N } from "@tanstack/react-query";
4
4
  import { useState as Q, useMemo as d, useCallback as c } from "react";
5
- const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_modalHeading__wnTmA", He = "FormsTable-module_customAccordianItem__isszs", T = {
5
+ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_modalHeading__wnTmA", Ve = "FormsTable-module_customAccordianItem__isszs", T = {
6
6
  formsTableBody: qe,
7
7
  modalHeading: we,
8
- customAccordianItem: He
9
- }, Ve = "startConsultation", $e = ({
10
- episodeOfCareUuids: B,
8
+ customAccordianItem: Ve
9
+ }, He = "startConsultation", $e = ({
10
+ episodeOfCareUuids: M,
11
11
  encounterUuids: m,
12
- config: Z,
13
- disableActions: X = !1,
12
+ config: X,
13
+ disableActions: Z = !1,
14
14
  activeEncounterUuid: h = null
15
15
  }) => {
16
- const { t: n } = ge(), u = be(), [y, M] = Q(!1), [s, R] = Q(null), {
16
+ const { t: n } = ge(), u = be(), [y, R] = Q(!1), [s, B] = Q(null), {
17
17
  numberOfVisits: J,
18
18
  hideThumbnail: W = !1,
19
19
  forms: g
20
- } = Z ?? {}, ee = Ne(
21
- ke.EDIT_OBSERVATIONS
22
- ), { userPrivileges: b } = Oe(), E = ee && !X && !!h, C = Te(
23
- B,
20
+ } = X ?? {}, ee = Oe(
21
+ De.EDIT_OBSERVATIONS
22
+ ), { userPrivileges: b } = Ne(), I = ee && !Z && !!h, C = Te(
23
+ M,
24
24
  m
25
- ), re = De(), {
25
+ ), re = ke(), {
26
26
  data: L = [],
27
27
  isLoading: U,
28
- isError: k,
28
+ isError: D,
29
29
  error: oe,
30
30
  refetch: ae
31
- } = O({
32
- queryKey: ["forms", u, B],
33
- queryFn: () => Ee(u, void 0, J),
31
+ } = N({
32
+ queryKey: ["forms", u, M],
33
+ queryFn: () => Ie(u, void 0, J),
34
34
  enabled: !!u && !C
35
- }), D = d(() => {
35
+ }), k = d(() => {
36
36
  let e = L;
37
37
  return m && m.length > 0 && (e = e.filter(
38
38
  (r) => m.includes(r.encounterUuid)
39
39
  )), Array.isArray(g) && g.length > 0 && (e = e.filter(
40
40
  (r) => g.some((o) => o.toLowerCase() === r.formName.toLowerCase())
41
41
  )), e;
42
- }, [L, m, g]), { data: N = [] } = O({
42
+ }, [L, m, g]), { data: O = [] } = N({
43
43
  queryKey: ["observationForms"],
44
- queryFn: () => Ie()
44
+ queryFn: () => Ae()
45
45
  }), q = c(
46
46
  (e) => {
47
- const r = N.find((t) => t.name === e);
47
+ const r = O.find((t) => t.name === e);
48
48
  if (!r?.privileges || r.privileges.length === 0) return !0;
49
49
  if (!b || b.length === 0) return !1;
50
50
  const o = new Set(b.map((t) => t.name));
@@ -52,33 +52,33 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
52
52
  (t) => o.has(t.privilegeName) && t.editable
53
53
  );
54
54
  },
55
- [N, b]
55
+ [O, b]
56
56
  ), f = c(
57
57
  (e) => !h || e.encounterUuid !== h ? !1 : q(e.formName),
58
58
  [h, q]
59
59
  ), w = c(
60
- (e) => N.find((r) => r.name === e)?.uuid,
61
- [N]
62
- ), I = d(() => {
60
+ (e) => O.find((r) => r.name === e)?.uuid,
61
+ [O]
62
+ ), A = d(() => {
63
63
  if (s)
64
64
  return w(s.formName);
65
65
  }, [s, w]), {
66
66
  data: l,
67
67
  isLoading: te,
68
68
  isError: se,
69
- error: v
70
- } = O({
71
- queryKey: ["formMetadata", I],
72
- queryFn: () => ve(I),
73
- enabled: !!I && y
69
+ error: E
70
+ } = N({
71
+ queryKey: ["formMetadata", A],
72
+ queryFn: () => Ee(A),
73
+ enabled: !!A && y
74
74
  }), {
75
- data: A,
75
+ data: v,
76
76
  isLoading: ne,
77
77
  isError: ie,
78
78
  error: _
79
- } = O({
79
+ } = N({
80
80
  queryKey: ["formsEncounterFHIR", s?.encounterUuid],
81
- queryFn: () => Ae(s.encounterUuid),
81
+ queryFn: () => ve(s.encounterUuid),
82
82
  enabled: !!s?.encounterUuid && y
83
83
  });
84
84
  _e(
@@ -87,7 +87,7 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
87
87
  },
88
88
  [u]
89
89
  );
90
- const de = d(() => !A?.entry || !s?.formName ? [] : A.entry.filter((e) => e.resource?.resourceType === "Observation").map((e) => e.resource).filter((e) => Fe(e) ? Se(e)?.toLowerCase() === s.formName.toLowerCase() : !0), [A, s?.formName]), le = d(() => {
90
+ const de = d(() => !v?.entry || !s?.formName ? [] : v.entry.filter((e) => e.resource?.resourceType === "Observation").map((e) => e.resource).filter((e) => Fe(e) ? Se(e)?.toLowerCase() === s.formName.toLowerCase() : !0), [v, s?.formName]), le = d(() => {
91
91
  if (!l?.schema) return;
92
92
  const e = [], r = (o) => {
93
93
  (o ?? []).forEach((t) => {
@@ -124,30 +124,30 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
124
124
  l.schema.controls ?? []
125
125
  ), Object.keys(e).length > 0 ? e : void 0;
126
126
  }, [l]), ue = d(() => {
127
- if (v)
128
- return $(v).message;
127
+ if (E)
128
+ return $(E).message;
129
129
  if (_)
130
130
  return $(_).message;
131
- }, [v, _]), p = d(
131
+ }, [E, _]), p = d(
132
132
  () => [
133
133
  { key: "recordedOn", header: n("RECORDED_ON") },
134
134
  { key: "recordedBy", header: n("RECORDED_BY") }
135
135
  ],
136
136
  [n]
137
- ), H = d(
137
+ ), V = d(
138
138
  () => [...p, { key: "actions", header: n("ACTIONS") }],
139
139
  [p, n]
140
140
  ), fe = c(
141
- (e) => E && e.some((r) => f(r)) ? H : p,
142
- [E, f, H, p]
141
+ (e) => I && e.some((r) => f(r)) ? V : p,
142
+ [I, f, V, p]
143
143
  ), pe = p, he = d(
144
144
  () => [
145
145
  { key: "recordedOn", sortable: !0 },
146
146
  { key: "recordedBy", sortable: !0 }
147
147
  ],
148
148
  []
149
- ), V = d(() => {
150
- const e = D.reduce(
149
+ ), H = d(() => {
150
+ const e = k.reduce(
151
151
  (r, o) => {
152
152
  const t = o.formName;
153
153
  r[t] ??= [];
@@ -155,7 +155,7 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
155
155
  return r[t].push({
156
156
  id: o.encounterUuid,
157
157
  formName: o.formName,
158
- recordedOn: Be(o.encounterDateTime, n, !0).formattedResult,
158
+ recordedOn: Me(o.encounterDateTime, n, !0).formattedResult,
159
159
  recordedBy: a ?? "--",
160
160
  encounterDateTime: o.encounterDateTime,
161
161
  encounterUuid: o.encounterUuid
@@ -171,13 +171,13 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
171
171
  )
172
172
  })
173
173
  ).sort((r, o) => r.formName.localeCompare(o.formName));
174
- }, [D, n]), j = c((e) => {
175
- R(e), M(!0);
176
- }, []), K = c(() => {
177
- M(!1), R(null);
174
+ }, [k, n]), K = c((e) => {
175
+ B(e), R(!0);
176
+ }, []), j = c(() => {
177
+ R(!1), B(null);
178
178
  }, []), F = c((e) => {
179
179
  globalThis.dispatchEvent(
180
- new CustomEvent(Ve, {
180
+ new CustomEvent(He, {
181
181
  detail: {
182
182
  editOnly: "observationForms",
183
183
  editTitle: "EDIT_OBSERVATION_FORM_TITLE",
@@ -191,7 +191,7 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
191
191
  (e, r) => {
192
192
  switch (r) {
193
193
  case "recordedOn":
194
- return /* @__PURE__ */ i(Me, { onClick: () => j(e), children: e.recordedOn });
194
+ return /* @__PURE__ */ i(Re, { onClick: () => K(e), children: e.recordedOn });
195
195
  case "recordedBy":
196
196
  return e.recordedBy;
197
197
  case "actions":
@@ -203,30 +203,30 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
203
203
  size: "sm",
204
204
  testId: `edit-form-${e.encounterUuid}`,
205
205
  onClick: () => F(e),
206
- children: /* @__PURE__ */ i(G, {})
206
+ children: /* @__PURE__ */ i(Y, {})
207
207
  }
208
208
  ) : null;
209
209
  default:
210
210
  return null;
211
211
  }
212
212
  },
213
- [j, F, f, n]
213
+ [K, F, f, n]
214
214
  );
215
215
  return /* @__PURE__ */ P(ye, { children: [
216
- /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: U || k || V.length === 0 || C ? /* @__PURE__ */ i(
217
- Y,
216
+ /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: U || D || H.length === 0 || C ? /* @__PURE__ */ i(
217
+ G,
218
218
  {
219
219
  headers: pe,
220
220
  ariaLabel: n("FORMS_HEADING"),
221
221
  rows: [],
222
222
  loading: U,
223
- errorStateMessage: k ? oe?.message : void 0,
223
+ errorStateMessage: D ? oe?.message : void 0,
224
224
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
225
225
  renderCell: z,
226
226
  className: T.formsTableBody,
227
227
  dataTestId: "forms-table"
228
228
  }
229
- ) : /* @__PURE__ */ i(Re, { align: "start", children: V.map((e, r) => {
229
+ ) : /* @__PURE__ */ i(Be, { align: "start", children: H.map((e, r) => {
230
230
  const { formName: o, records: t } = e, a = fe(t);
231
231
  return /* @__PURE__ */ i(
232
232
  Ce,
@@ -236,7 +236,7 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
236
236
  testId: `accordian-title-${o}`,
237
237
  open: r === 0,
238
238
  children: /* @__PURE__ */ i(
239
- Y,
239
+ G,
240
240
  {
241
241
  headers: a,
242
242
  ariaLabel: n("FORMS_HEADING"),
@@ -260,10 +260,10 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
260
260
  id: "modalIdForActionAreaLayout",
261
261
  portalId: "main-display-area",
262
262
  open: y,
263
- onRequestClose: K,
263
+ onRequestClose: j,
264
264
  modalHeading: /* @__PURE__ */ P("div", { className: T.modalHeading, children: [
265
265
  /* @__PURE__ */ i("span", { children: s.formName }),
266
- E && f(s) && /* @__PURE__ */ i(
266
+ I && f(s) && /* @__PURE__ */ i(
267
267
  x,
268
268
  {
269
269
  label: n("EDIT_OBSERVATION_FORM"),
@@ -271,9 +271,9 @@ const qe = "FormsTable-module_formsTableBody__SvGha", we = "FormsTable-module_mo
271
271
  size: "sm",
272
272
  testId: `edit-form-modal-${s.encounterUuid}`,
273
273
  onClick: () => {
274
- K(), F(s);
274
+ j(), F(s);
275
275
  },
276
- children: /* @__PURE__ */ i(G, {})
276
+ children: /* @__PURE__ */ i(Y, {})
277
277
  }
278
278
  )
279
279
  ] }),
@@ -1,5 +1,5 @@
1
- import { c, T as l, P as m, a as u, D as v, Q as i } from "./YPM2AS64-PInLdgeX.js";
2
- import { an as p, ao as d, ap as e } from "./index-BtK4jcwc.js";
1
+ import { c, T as l, P as m, a as u, D as v, Q as i } from "./YPM2AS64-BSMOwRa0.js";
2
+ import { an as p, ao as d, ap as e } from "./index-CDAgqrus.js";
3
3
  var f = (a) => {
4
4
  const [r, o] = c({
5
5
  prefix: "TanstackQueryDevtools"
@@ -1,5 +1,5 @@
1
- import { c as s, T as c, P as u, a as i, b as m, C as P, Q as d } from "./YPM2AS64-PInLdgeX.js";
2
- import { an as v, ao as C, ap as e } from "./index-BtK4jcwc.js";
1
+ import { c as s, T as c, P as u, a as i, b as m, C as P, Q as d } from "./YPM2AS64-BSMOwRa0.js";
2
+ import { an as v, ao as C, ap as e } from "./index-CDAgqrus.js";
3
3
  var h = (t) => {
4
4
  const [r, o] = s({
5
5
  prefix: "TanstackQueryDevtools"
@@ -0,0 +1,213 @@
1
+ import { jsxs as $, jsx as u } from "react/jsx-runtime";
2
+ import { v as q, z as G, u as N, l as k, G as x, m as z, n as Q, o as w, s as H, r as M, K as j, t as P, _ as A, x as J, C as Y, y as W, E as X, B as Z, D as ee } from "./index-CDAgqrus.js";
3
+ import { useQueries as ae, useQuery as re } from "@tanstack/react-query";
4
+ import { useRef as te, useEffect as f, useMemo as O } from "react";
5
+ const L = (a, n, d, l, b, o) => {
6
+ const r = J(a, n, b), t = r.value, s = Y(t);
7
+ let i = t;
8
+ s === "Image" && (i = /* @__PURE__ */ u(
9
+ X,
10
+ {
11
+ imageSrc: t,
12
+ alt: t,
13
+ id: `${t}-img`,
14
+ hideThumbnail: o
15
+ }
16
+ )), s === "Video" && (i = /* @__PURE__ */ u(
17
+ Z,
18
+ {
19
+ id: `${t}-video`,
20
+ videoSrc: t,
21
+ hideThumbnail: o
22
+ }
23
+ )), s === "PDF" && (i = /* @__PURE__ */ u(ee, { id: `${t}-pdf`, src: t }));
24
+ const m = b("OBSERVATIONS_RECORDED_BY", {
25
+ provider: r.provider
26
+ }), p = a.display, h = a.observationValue?.isAbnormal ? "abnormal-obs" : "obs", c = l ? `${l}-${h}-${p}-${d}-${n}` : `${h}-${p}-${d}-${n}`;
27
+ return /* @__PURE__ */ u(
28
+ W,
29
+ {
30
+ header: r.header,
31
+ value: i,
32
+ info: m,
33
+ id: c,
34
+ testId: c,
35
+ ariaLabel: c
36
+ },
37
+ `obs-${a.id}`
38
+ );
39
+ }, se = (a, n, d, l, b, o, r) => /* @__PURE__ */ u(
40
+ A,
41
+ {
42
+ title: a.display,
43
+ id: `grouped-obs-${a.display}-${l}`,
44
+ open: d,
45
+ children: a.members?.map(
46
+ (t, s) => L(
47
+ t,
48
+ s,
49
+ b,
50
+ o,
51
+ n,
52
+ r
53
+ )
54
+ )
55
+ },
56
+ `grouped-obs-${a.id}`
57
+ ), oe = ({
58
+ groupedData: a,
59
+ title: n = "",
60
+ hideThumbnail: d
61
+ }) => {
62
+ const { t: l } = N(), b = (o, r, t) => {
63
+ const s = P(o.encounterDetails, l);
64
+ return /* @__PURE__ */ $(
65
+ A,
66
+ {
67
+ title: s,
68
+ id: `encounter-${o.encounterId}`,
69
+ open: r,
70
+ children: [
71
+ o.observations.map(
72
+ (i, m) => L(
73
+ i,
74
+ m,
75
+ t,
76
+ n,
77
+ l,
78
+ d
79
+ )
80
+ ),
81
+ o.groupedObservations.map(
82
+ (i, m) => se(
83
+ i,
84
+ l,
85
+ r,
86
+ m,
87
+ t,
88
+ n,
89
+ d
90
+ )
91
+ )
92
+ ]
93
+ },
94
+ `encounter-${o.encounterId}`
95
+ );
96
+ };
97
+ return /* @__PURE__ */ u(
98
+ "div",
99
+ {
100
+ id: "obs-by-encounter",
101
+ "data-testid": "obs-by-encounter-test-id",
102
+ "aria-label": "obs-by-encounter-aria-label",
103
+ children: a.map(
104
+ (o, r) => b(o, r === 0, r)
105
+ )
106
+ }
107
+ );
108
+ }, ie = "Observations-module_observations__RKSyo", ne = "Observations-module_title__TJL3z", S = {
109
+ observations: ie,
110
+ title: ne
111
+ }, de = (a) => ["conceptUuid", a], le = (a, n) => ["observations", a, ...n], pe = ({ config: a }) => {
112
+ const n = a, {
113
+ conceptNames: d = [],
114
+ conceptUuid: l = [],
115
+ hideThumbnail: b = !1
116
+ } = n, o = te(/* @__PURE__ */ new Set()), r = q(), { addNotification: t } = G(), { t: s } = N(), i = ae({
117
+ queries: d.map((e) => ({
118
+ queryKey: de(e),
119
+ queryFn: () => k(e),
120
+ enabled: !!e
121
+ }))
122
+ });
123
+ f(() => {
124
+ i.forEach((e, y) => {
125
+ if (e.isError && !o.current.has(y)) {
126
+ const U = d[y];
127
+ t({
128
+ title: s("ERROR_DEFAULT_TITLE"),
129
+ message: s("ERROR_FETCHING_CONCEPT", { conceptName: U }),
130
+ type: "error"
131
+ }), o.current.add(y);
132
+ } else e.isError || o.current.delete(y);
133
+ });
134
+ }, [i, d]);
135
+ const m = O(() => i.map((e) => e.data?.uuid).filter((e) => !!e), [i]), p = O(() => [.../* @__PURE__ */ new Set([...m, ...l])], [m, l]), h = O(() => d.length === 0 ? !0 : i.every((e) => !e.isLoading), [i, d.length]), {
136
+ data: c,
137
+ isLoading: D,
138
+ isError: T,
139
+ refetch: R
140
+ } = re({
141
+ queryKey: le(r, p),
142
+ queryFn: () => x(r, p),
143
+ enabled: !!r && p.length > 0 && h
144
+ });
145
+ z(
146
+ (e) => {
147
+ e.patientUUID === r && e.updatedConcepts.size > 0 && [...e.updatedConcepts.keys()].some(
148
+ (y) => p.includes(y)
149
+ ) && R();
150
+ },
151
+ [r, R]
152
+ ), f(() => {
153
+ T && t({
154
+ title: s("ERROR_DEFAULT_TITLE"),
155
+ message: s("ERROR_FETCHING_OBSERVATIONS"),
156
+ type: "error"
157
+ });
158
+ }, [T]);
159
+ const _ = O(() => {
160
+ if (!c) return [];
161
+ const e = Q(c), y = w(e);
162
+ return H(y);
163
+ }, [c]), V = [
164
+ { key: "name", header: "name" },
165
+ { key: "value", header: "value" },
166
+ { key: "form", header: "form" }
167
+ ], g = D || !h, I = T && h, B = (!c || c.entry?.length === 0 || p.length === 0) && h, C = I ? s("ERROR_FETCHING_OBSERVATIONS") : null, F = B ? s("NO_OBSERVATIONS_FOUND") : void 0, K = _.length > 0 && !g && !I, E = n.titleTranslationKey, v = E ? s(E) : "";
168
+ return /* @__PURE__ */ $(
169
+ "div",
170
+ {
171
+ id: "observations",
172
+ "data-testid": E ? `observations-${v}` : "observations",
173
+ "aria-label": "observations-aria-label",
174
+ className: S.observations,
175
+ children: [
176
+ /* @__PURE__ */ u(
177
+ M,
178
+ {
179
+ id: "observations-title",
180
+ testId: E ? `observations-title-${v}` : "observations-title",
181
+ title: v,
182
+ className: S.title,
183
+ children: /* @__PURE__ */ u("p", { children: v })
184
+ }
185
+ ),
186
+ K ? /* @__PURE__ */ u(
187
+ oe,
188
+ {
189
+ groupedData: _,
190
+ title: v,
191
+ hideThumbnail: b
192
+ }
193
+ ) : /* @__PURE__ */ u(
194
+ j,
195
+ {
196
+ headers: V,
197
+ rows: [],
198
+ ariaLabel: s("OBSERVATIONS"),
199
+ loading: g,
200
+ errorStateMessage: C,
201
+ emptyStateMessage: F ?? s("NO_OBSERVATIONS_AVAILABLE"),
202
+ dataTestId: "observations-table"
203
+ }
204
+ )
205
+ ]
206
+ }
207
+ );
208
+ };
209
+ export {
210
+ de as conceptUuidQueryKeys,
211
+ pe as default,
212
+ le as observationsQueryKeys
213
+ };
@@ -1,4 +1,4 @@
1
- import { aq as we, ar as z, as as xt, at as B, ao as q, ap as y, au as Ro, av as ye, aw as R, ax as _, ay as k, az as N, aA as A, aB as bs, aC as ir, aD as $e, aE as U, aF as Hn, aG as Vn, aH as dt, aI as D, aJ as xs, aK as cn, aL as Be, aM as ws, aN as qt, aO as zt, aP as $s, aQ as Cs, aR as $n, aS as Ss, aT as Nr, aU as Bt, aV as zo, aW as ks, aX as Es, aY as j, aZ as Ur, a_ as Ms, a$ as Ds, b0 as sr, b1 as As, b2 as Ts, b3 as zn, b4 as Fs, b5 as Is, b6 as Z, b7 as Ps, b8 as Ls } from "./index-BtK4jcwc.js";
1
+ import { aq as we, ar as z, as as xt, at as B, ao as q, ap as y, au as Ro, av as ye, aw as R, ax as _, ay as k, az as N, aA as A, aB as bs, aC as ir, aD as $e, aE as U, aF as Hn, aG as Vn, aH as dt, aI as D, aJ as xs, aK as cn, aL as Be, aM as ws, aN as qt, aO as zt, aP as $s, aQ as Cs, aR as $n, aS as Ss, aT as Nr, aU as Bt, aV as zo, aW as ks, aX as Es, aY as j, aZ as Ur, a_ as Ms, a$ as Ds, b0 as sr, b1 as As, b2 as Ts, b3 as zn, b4 as Fs, b5 as Is, b6 as Z, b7 as Ps, b8 as Ls } from "./index-CDAgqrus.js";
2
2
  var Os = (e) => e != null, qs = (e) => e.filter(Os);
3
3
  function _s(e) {
4
4
  return (...t) => {