@bahmni/widgets 0.0.1-dev.109 → 0.0.1-dev.110

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
- import { jsxs as _, jsx as t, Fragment as J } from "react/jsx-runtime";
2
- import { c as h, u as W, E as X, O as Z, P as ee, A as re, b as oe, i as te, R as ae, x as $, h as ne, d as se, a as de, y as ce, e as x, s as me } from "./index-Z7N8pibh.js";
1
+ import { jsxs as _, jsx as t, Fragment as Y } from "react/jsx-runtime";
2
+ import { c as h, u as W, O as X, x as Z, L as ee, M as re, A as oe, i as te, a as ae, J as $, e as ne, t as se, K as ce, b as de, d as x, s as me } from "./index-DnRlH7sS.js";
3
3
  import { useQuery as g } from "@tanstack/react-query";
4
4
  import { useState as U, useMemo as b, useCallback as N } from "react";
5
5
  import { createPortal as le } from "react-dom";
6
6
  import { useTranslation as ie } from "react-i18next";
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", De = "_abnormalValue_1pd36_102", we = "_commentSection_1pd36_110", Ce = "_commentText_1pd36_116", Fe = "_nestedGroup_1pd36_125", Te = "_nestedGroupLabel_1pd36_132", Ee = "_nestedGroupMembers_1pd36_141", r = {
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", De = "_abnormalValue_1pd36_102", Ce = "_commentSection_1pd36_110", Fe = "_commentText_1pd36_116", Te = "_nestedGroup_1pd36_125", ve = "_nestedGroupLabel_1pd36_132", Ee = "_nestedGroupMembers_1pd36_141", r = {
8
8
  formsTableBody: ue,
9
9
  customAccordianItem: pe,
10
10
  formContent: _e,
@@ -20,20 +20,20 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
20
20
  memberLabel: Oe,
21
21
  memberValue: Re,
22
22
  abnormalValue: De,
23
- commentSection: we,
24
- commentText: Ce,
25
- nestedGroup: Fe,
26
- nestedGroupLabel: Te,
23
+ commentSection: Ce,
24
+ commentText: Fe,
25
+ nestedGroup: Te,
26
+ nestedGroupLabel: ve,
27
27
  nestedGroupMembers: Ee
28
- }, ve = "ABNORMAL", q = (e) => {
29
- const s = e.concept?.units, d = e.concept?.lowNormal, o = e.concept?.hiNormal, l = d != null, i = o != null, p = l && i ? ` (${d} - ${o})` : l ? ` (>${d})` : i ? ` (<${o})` : "", a = e.interpretation && e.interpretation.toUpperCase() === ve;
28
+ }, we = "ABNORMAL", q = (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;
30
30
  return { units: s, rangeString: p, isAbnormal: a };
31
- }, P = ({
31
+ }, k = ({
32
32
  member: e,
33
33
  depth: s = 0
34
34
  }) => {
35
- const d = e.groupMembers && e.groupMembers.length > 0, o = e.conceptNameToDisplay ?? e.concept?.shortName ?? e.concept?.name;
36
- if (d)
35
+ const c = e.groupMembers && e.groupMembers.length > 0, o = e.conceptNameToDisplay ?? e.concept?.shortName ?? e.concept?.name;
36
+ if (c)
37
37
  return /* @__PURE__ */ _("div", { className: r.nestedGroup, children: [
38
38
  /* @__PURE__ */ t(
39
39
  "div",
@@ -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
- P,
47
+ k,
48
48
  {
49
49
  member: a,
50
50
  depth: s + 1
@@ -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 d = e.groupMembers && e.groupMembers.length > 0, { units: o, rangeString: l, isAbnormal: i } = q(e);
95
+ const c = e.groupMembers && e.groupMembers.length > 0, { units: o, rangeString: l, isAbnormal: i } = q(e);
96
96
  return /* @__PURE__ */ _(
97
97
  "div",
98
98
  {
@@ -101,23 +101,23 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
101
101
  /* @__PURE__ */ _(
102
102
  "div",
103
103
  {
104
- className: d ? r.groupContainer : r.rowContainer,
104
+ className: c ? r.groupContainer : r.rowContainer,
105
105
  children: [
106
106
  /* @__PURE__ */ _(
107
107
  "p",
108
108
  {
109
109
  className: h(
110
- d ? r.groupLabel : r.rowLabel,
111
- !d && i ? r.abnormalValue : ""
110
+ c ? r.groupLabel : r.rowLabel,
111
+ !c && i ? r.abnormalValue : ""
112
112
  ),
113
113
  children: [
114
114
  e.conceptNameToDisplay,
115
- !d && l && /* @__PURE__ */ t("span", { className: r.rangeInfo, children: l })
115
+ !c && l && /* @__PURE__ */ t("span", { className: r.rangeInfo, children: l })
116
116
  ]
117
117
  }
118
118
  ),
119
- d ? /* @__PURE__ */ t("div", { className: r.groupMembers, children: e.groupMembers?.map((p) => /* @__PURE__ */ t(
120
- P,
119
+ c ? /* @__PURE__ */ t("div", { className: r.groupMembers, children: e.groupMembers?.map((p) => /* @__PURE__ */ t(
120
+ k,
121
121
  {
122
122
  member: p,
123
123
  depth: 0
@@ -150,34 +150,34 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
150
150
  }, qe = ({
151
151
  episodeOfCareUuids: e,
152
152
  encounterUuids: s,
153
- config: d
153
+ config: c
154
154
  }) => {
155
- const { t: o } = ie(), l = W(), [i, p] = U(!1), [a, O] = U(null), k = d?.numberOfVisits, R = X(
155
+ const { t: o } = ie(), l = W(), [i, p] = U(!1), [a, O] = U(null), H = c?.numberOfVisits, R = X(
156
156
  e,
157
157
  s
158
158
  ), {
159
159
  data: y = [],
160
160
  isLoading: D,
161
- isError: w,
162
- error: H
161
+ isError: C,
162
+ error: K
163
163
  } = g({
164
164
  queryKey: ["forms", l, e],
165
- queryFn: () => Z(l, void 0, k),
165
+ queryFn: () => Z(l, void 0, H),
166
166
  enabled: !!l && !R
167
- }), C = b(() => !s || s.length === 0 ? y : y.filter(
167
+ }), F = b(() => !s || s.length === 0 ? y : y.filter(
168
168
  (n) => s.includes(n.encounterUuid)
169
- ), [y, s]), { data: F = [] } = g({
169
+ ), [y, s]), { data: T = [] } = g({
170
170
  queryKey: ["observationForms"],
171
171
  queryFn: ee
172
- }), T = N(
173
- (n) => F.find((c) => c.name === n)?.uuid,
174
- [F]
172
+ }), v = N(
173
+ (n) => T.find((d) => d.name === n)?.uuid,
174
+ [T]
175
175
  ), M = b(() => {
176
176
  if (a)
177
- return T(a.formName);
178
- }, [a, T]), {
177
+ return v(a.formName);
178
+ }, [a, v]), {
179
179
  data: Ie,
180
- isLoading: j,
180
+ isLoading: P,
181
181
  error: E
182
182
  } = g({
183
183
  queryKey: ["formMetadata", M],
@@ -185,8 +185,8 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
185
185
  enabled: !!M && i
186
186
  }), {
187
187
  data: L,
188
- isLoading: K,
189
- error: v
188
+ isLoading: j,
189
+ error: w
190
190
  } = g({
191
191
  queryKey: ["formsEncounter", a?.encounterUuid],
192
192
  queryFn: () => oe(a.encounterUuid, !0),
@@ -199,40 +199,40 @@ 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
- ), z = b(
202
+ ), J = b(
203
203
  () => [
204
204
  { key: "recordedOn", sortable: !0 },
205
205
  { key: "recordedBy", sortable: !0 }
206
206
  ],
207
207
  []
208
208
  ), V = b(() => {
209
- const n = C.reduce(
210
- (c, m) => {
209
+ const n = F.reduce(
210
+ (d, m) => {
211
211
  const f = m.formName;
212
- c[f] ??= [];
213
- const A = m.providers.map((Y) => Y.providerName).filter(Boolean).join(", ");
214
- return c[f].push({
212
+ d[f] ??= [];
213
+ const A = m.providers.map((Q) => Q.providerName).filter(Boolean).join(", ");
214
+ return d[f].push({
215
215
  id: m.encounterUuid,
216
216
  formName: m.formName,
217
217
  recordedOn: te(m.encounterDateTime, o, me).formattedResult,
218
218
  recordedBy: A ?? "--",
219
219
  encounterDateTime: m.encounterDateTime,
220
220
  encounterUuid: m.encounterUuid
221
- }), c;
221
+ }), d;
222
222
  },
223
223
  {}
224
224
  );
225
225
  return Object.entries(n).map(
226
- ([c, m]) => ({
227
- formName: c,
226
+ ([d, m]) => ({
227
+ formName: d,
228
228
  records: m.sort(
229
229
  (f, A) => A.encounterDateTime - f.encounterDateTime
230
230
  )
231
231
  })
232
- ).sort((c, m) => c.formName.localeCompare(m.formName));
233
- }, [C, o]), S = N((n) => {
232
+ ).sort((d, m) => d.formName.localeCompare(m.formName));
233
+ }, [F, o]), S = N((n) => {
234
234
  O(n), p(!0);
235
- }, []), Q = N(() => {
235
+ }, []), z = N(() => {
236
236
  p(!1), O(null);
237
237
  }, []), G = N(
238
238
  (n, u) => {
@@ -247,28 +247,28 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
247
247
  },
248
248
  [S]
249
249
  );
250
- return /* @__PURE__ */ _(J, { children: [
251
- /* @__PURE__ */ t("div", { "data-testid": "forms-table", children: D || w || V.length === 0 || R ? /* @__PURE__ */ t(
250
+ return /* @__PURE__ */ _(Y, { children: [
251
+ /* @__PURE__ */ t("div", { "data-testid": "forms-table", children: D || C || V.length === 0 || R ? /* @__PURE__ */ t(
252
252
  $,
253
253
  {
254
254
  headers: I,
255
255
  ariaLabel: o("FORMS_HEADING"),
256
256
  rows: [],
257
257
  loading: D,
258
- errorStateMessage: w ? H?.message : void 0,
258
+ errorStateMessage: C ? K?.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: c, records: m } = n;
265
+ const { formName: d, records: m } = n;
266
266
  return /* @__PURE__ */ t(
267
267
  se,
268
268
  {
269
- title: c,
269
+ title: d,
270
270
  className: r.customAccordianItem,
271
- testId: `accordian-title-${c}`,
271
+ testId: `accordian-title-${d}`,
272
272
  open: u === 0,
273
273
  children: /* @__PURE__ */ t(
274
274
  $,
@@ -278,7 +278,7 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
278
278
  rows: m,
279
279
  loading: !1,
280
280
  errorStateMessage: "",
281
- sortable: z,
281
+ sortable: J,
282
282
  emptyStateMessage: o("FORMS_UNAVAILABLE"),
283
283
  renderCell: G,
284
284
  className: r.formsTableBody,
@@ -286,22 +286,22 @@ const ue = "_formsTableBody_1pd36_1", pe = "_customAccordianItem_1pd36_6", _e =
286
286
  }
287
287
  )
288
288
  },
289
- c
289
+ d
290
290
  );
291
291
  }) }) }),
292
292
  i && a && le(
293
293
  /* @__PURE__ */ t(
294
- de,
294
+ ce,
295
295
  {
296
296
  id: "formDetailsModal",
297
297
  open: i,
298
- onRequestClose: Q,
298
+ onRequestClose: z,
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: j || K ? /* @__PURE__ */ t(ce, { width: "100%", lineCount: 3 }) : E ? /* @__PURE__ */ t("div", { children: x(E).message ?? o("ERROR_FETCHING_FORM_METADATA") }) : v ? /* @__PURE__ */ t("div", { children: x(v).message ?? o("ERROR_FETCHING_FORM_DATA") }) : B.length > 0 ? /* @__PURE__ */ t("div", { className: r.formDetailsContainer, children: B.map((n, u) => /* @__PURE__ */ t(
304
+ children: /* @__PURE__ */ t("div", { className: r.formContent, children: P || j ? /* @__PURE__ */ t(de, { width: "100%", lineCount: 3 }) : E ? /* @__PURE__ */ t("div", { children: x(E).message ?? o("ERROR_FETCHING_FORM_METADATA") }) : w ? /* @__PURE__ */ t("div", { children: x(w).message ?? o("ERROR_FETCHING_FORM_DATA") }) : B.length > 0 ? /* @__PURE__ */ t("div", { className: r.formDetailsContainer, children: B.map((n, u) => /* @__PURE__ */ t(
305
305
  Be,
306
306
  {
307
307
  observation: n,
@@ -0,0 +1,306 @@
1
+ import { jsx as l, jsxs as T } from "react/jsx-runtime";
2
+ import { f as B, g as $, l as L, h as F, C as x, z as k, u as q, j as Q, H as G, R as H, k as K, J as P } from "./index-DnRlH7sS.js";
3
+ import { useQueries as j, useQuery as J } from "@tanstack/react-query";
4
+ import { useRef as Y, useEffect as R, useMemo as m } from "react";
5
+ import { useTranslation as _ } from "react-i18next";
6
+ const z = "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
+ const { value: t, unit: n } = e.observationValue;
8
+ return n ? `${t} ${n}` : String(t);
9
+ }, ne = (e) => {
10
+ const { unit: t, referenceRange: n } = e.observationValue, r = e.display;
11
+ if (!n)
12
+ return String(r);
13
+ const { low: o, high: s } = n;
14
+ if (o && s) {
15
+ const i = o.unit ? `${o.value} ${o.unit}` : t ? `${o.value} ${t}` : String(o.value), a = s.unit ? `${s.value} ${s.unit}` : t ? `${s.value} ${t}` : String(s.value);
16
+ return `${r} (${i} - ${a})`;
17
+ }
18
+ if (o) {
19
+ const i = o.unit ? `${o.value} ${o.unit}` : t ? `${o.value} ${t}` : String(o.value);
20
+ return `${r} (>${i})`;
21
+ }
22
+ if (s) {
23
+ const i = s.unit ? `${s.value} ${s.unit}` : t ? `${s.value} ${t}` : String(s.value);
24
+ return `${r} (<${i})`;
25
+ }
26
+ return r;
27
+ }, re = (e, t) => ({
28
+ index: t,
29
+ header: ne(e),
30
+ value: te(e),
31
+ provider: e.encounter?.provider
32
+ }), b = (e) => (typeof e == "string" ? e : e?.reference)?.split("/")?.pop();
33
+ function oe(e) {
34
+ return !e.interpretation || e.interpretation.length === 0 ? !1 : e.interpretation.some(
35
+ (t) => t.coding?.some(
36
+ (n) => n.system === Z && n.code === X
37
+ )
38
+ );
39
+ }
40
+ function se(e) {
41
+ const { valueQuantity: t, valueCodeableConcept: n, valueString: r, referenceRange: o } = e, s = oe(e);
42
+ if (t) {
43
+ const i = {
44
+ value: t.value ?? "",
45
+ unit: t.unit,
46
+ type: "quantity",
47
+ isAbnormal: s
48
+ };
49
+ if (o && o.length > 0) {
50
+ const a = o.find(
51
+ (u) => u.type?.coding?.some(
52
+ (p) => p.system === W && p.code === z
53
+ )
54
+ );
55
+ a && (a.low || a.high) && (i.referenceRange = {
56
+ low: a.low ? {
57
+ value: a.low.value,
58
+ unit: a.low.unit
59
+ } : void 0,
60
+ high: a.high ? {
61
+ value: a.high.value,
62
+ unit: a.high.unit
63
+ } : void 0
64
+ });
65
+ }
66
+ return i;
67
+ }
68
+ if (n)
69
+ return {
70
+ value: n.text ?? n.coding[0].display,
71
+ type: "codeable",
72
+ isAbnormal: s
73
+ };
74
+ if (r)
75
+ return {
76
+ value: r,
77
+ type: "string",
78
+ isAbnormal: s
79
+ };
80
+ }
81
+ function ie(e, t) {
82
+ const n = t.get(e);
83
+ if (n)
84
+ return {
85
+ id: n.id ?? e,
86
+ type: n.type?.[0]?.coding?.[0]?.display ?? "Unknown",
87
+ date: n.period?.start ?? "",
88
+ provider: n.participant?.[0]?.individual?.display,
89
+ location: n.location?.[0]?.location?.display
90
+ };
91
+ }
92
+ function I(e, t, n) {
93
+ const r = b(e.encounter), o = (e.hasMember ?? []).map((s) => b(s)).map((s) => s ? n.get(s) : void 0).filter((s) => !!s).map(
94
+ (s) => I(s, t, n)
95
+ );
96
+ return {
97
+ id: e.id,
98
+ display: e.code?.text ?? e.code?.coding?.[0]?.display ?? "",
99
+ observationValue: se(e),
100
+ effectiveDateTime: e.effectiveDateTime,
101
+ issued: e.issued,
102
+ encounter: r ? ie(r, t) : void 0,
103
+ members: o.length > 0 ? o : void 0
104
+ };
105
+ }
106
+ function ae(e) {
107
+ const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
108
+ e.entry?.forEach(({ resource: i }) => {
109
+ i?.id && (i.resourceType === "Encounter" ? t.set(i.id, i) : i.resourceType === "Observation" && (n.set(i.id, i), i.hasMember?.forEach((a) => {
110
+ const u = b(a);
111
+ u && r.add(u);
112
+ })));
113
+ });
114
+ const o = [], s = [];
115
+ return n.forEach((i, a) => {
116
+ if (r.has(a)) return;
117
+ const u = I(
118
+ i,
119
+ t,
120
+ n
121
+ );
122
+ u.members?.length ? s.push({ ...u, children: u.members }) : o.push(u);
123
+ }), { observations: o, groupedObservations: s };
124
+ }
125
+ function ue(e) {
126
+ const t = /* @__PURE__ */ new Map();
127
+ return e.observations.forEach((n) => {
128
+ if (!n.encounter?.id) return;
129
+ const r = n.encounter.id;
130
+ t.has(r) || t.set(r, {
131
+ observations: [],
132
+ groupedObservations: []
133
+ }), t.get(r).observations.push(n);
134
+ }), e.groupedObservations.forEach((n) => {
135
+ if (!n.encounter?.id) return;
136
+ const r = n.encounter.id;
137
+ t.has(r) || t.set(r, {
138
+ observations: [],
139
+ groupedObservations: []
140
+ }), t.get(r).groupedObservations.push(n);
141
+ }), Array.from(t.entries()).map(([n, r]) => {
142
+ const o = r.observations[0]?.encounter ?? r.groupedObservations[0]?.encounter;
143
+ return {
144
+ encounterId: n,
145
+ encounterDetails: o,
146
+ observations: r.observations,
147
+ groupedObservations: r.groupedObservations
148
+ };
149
+ });
150
+ }
151
+ function ce(e) {
152
+ return [...e].sort((t, n) => {
153
+ const r = t.encounterDetails?.date, o = n.encounterDetails?.date;
154
+ return !r && !o ? 0 : r ? o ? new Date(o).getTime() - new Date(r).getTime() : -1 : 1;
155
+ });
156
+ }
157
+ const N = (e, t, n) => {
158
+ const r = re(e, t), o = r.value, s = L(o);
159
+ let i = o;
160
+ s === "Image" && (i = /* @__PURE__ */ l(x, { imageSrc: o, alt: o, id: `${o}-img` })), s === "Video" && (i = /* @__PURE__ */ l(k, { id: `${o}-video`, videoSrc: o }));
161
+ const a = n("OBSERVATIONS_RECORDED_BY", {
162
+ provider: r.provider
163
+ }), u = e.observationValue?.isAbnormal ? `abnormal-obs-${e.id}` : `obs-${e.id}`;
164
+ return /* @__PURE__ */ l(
165
+ F,
166
+ {
167
+ header: r.header,
168
+ value: i,
169
+ info: a,
170
+ id: u,
171
+ testId: `${u}-test-id`,
172
+ ariaLabel: `${u}-aria-label`
173
+ },
174
+ `obs-${e.id}`
175
+ );
176
+ }, le = (e, t, n) => /* @__PURE__ */ l(
177
+ $,
178
+ {
179
+ title: e.display,
180
+ id: `grouped-obs-${e.id}`,
181
+ open: n,
182
+ children: e.children.map(
183
+ (r, o) => N(r, o, t)
184
+ )
185
+ },
186
+ `grouped-obs-${e.id}`
187
+ ), de = ({
188
+ groupedData: e
189
+ }) => {
190
+ const { t } = _(), n = (r, o) => {
191
+ const s = ee(r.encounterDetails, t);
192
+ return /* @__PURE__ */ T(
193
+ $,
194
+ {
195
+ title: s,
196
+ id: `encounter-${r.encounterId}`,
197
+ open: o,
198
+ children: [
199
+ r.observations.map(
200
+ (i, a) => N(i, a, t)
201
+ ),
202
+ r.groupedObservations.map(
203
+ (i) => le(i, t, o)
204
+ )
205
+ ]
206
+ },
207
+ `encounter-${r.encounterId}`
208
+ );
209
+ };
210
+ return /* @__PURE__ */ l(
211
+ "div",
212
+ {
213
+ id: "obs-by-encounter",
214
+ "data-testid": "obs-by-encounter-test-id",
215
+ "aria-label": "obs-by-encounter-aria-label",
216
+ children: e.map(
217
+ (r, o) => n(r, o === 0)
218
+ )
219
+ }
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 = Y(/* @__PURE__ */ new Set()), s = q(), { addNotification: i } = Q(), { t: a } = _(), u = j({
226
+ queries: n.map((c) => ({
227
+ queryKey: fe(c),
228
+ queryFn: () => G(c),
229
+ enabled: !!c
230
+ }))
231
+ });
232
+ R(() => {
233
+ u.forEach((c, d) => {
234
+ if (c.isError && !o.current.has(d)) {
235
+ const U = n[d];
236
+ i({
237
+ title: a("ERROR_DEFAULT_TITLE"),
238
+ message: a("ERROR_FETCHING_CONCEPT", { conceptName: U }),
239
+ type: "error"
240
+ }), o.current.add(d);
241
+ } else c.isError || o.current.delete(d);
242
+ });
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,
246
+ isLoading: D,
247
+ isError: h
248
+ } = J({
249
+ queryKey: ge(s, f),
250
+ queryFn: () => H(s, f),
251
+ enabled: !!s && f.length > 0 && g
252
+ });
253
+ R(() => {
254
+ h && i({
255
+ title: a("ERROR_DEFAULT_TITLE"),
256
+ message: a("ERROR_FETCHING_OBSERVATIONS"),
257
+ type: "error"
258
+ });
259
+ }, [h]);
260
+ const E = m(() => {
261
+ if (!v) return [];
262
+ const c = ae(v), d = ue(c);
263
+ return ce(d);
264
+ }, [v]), A = [
265
+ { key: "name", header: "name" },
266
+ { key: "value", header: "value" },
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;
269
+ return /* @__PURE__ */ T(
270
+ "div",
271
+ {
272
+ id: "observations",
273
+ "data-testid": "observations-test-id",
274
+ "aria-label": "observations-aria-label",
275
+ className: S.observations,
276
+ children: [
277
+ /* @__PURE__ */ l(
278
+ K,
279
+ {
280
+ id: "observations-title",
281
+ testId: "observations-title-test-id",
282
+ title: a(t.titleTranslationKey),
283
+ className: S.title,
284
+ children: /* @__PURE__ */ l("p", { children: a(t.titleTranslationKey) })
285
+ }
286
+ ),
287
+ M ? /* @__PURE__ */ l(de, { groupedData: E }) : /* @__PURE__ */ l(
288
+ P,
289
+ {
290
+ headers: A,
291
+ rows: [],
292
+ ariaLabel: a("OBSERVATIONS"),
293
+ loading: y,
294
+ errorStateMessage: C,
295
+ emptyStateMessage: V
296
+ }
297
+ )
298
+ ]
299
+ }
300
+ );
301
+ };
302
+ export {
303
+ fe as conceptUuidQueryKeys,
304
+ Oe as default,
305
+ ge as observationsQueryKeys
306
+ };