@bahmni/appointments-app 0.0.1-dev.212 → 0.0.1-dev.215

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,6 +1,6 @@
1
- import { jsx as r, jsxs as p, Fragment as Y } from "react/jsx-runtime";
2
- import { c as K, u as Q, e as W, a as X, V as J, C as Z, x as ee, L as te, b as ae } from "./index-DIv6b2ab.js";
3
- import { useState as l, useCallback as h, useEffect as C, useMemo as T } from "react";
1
+ import { jsx as r, jsxs as _, Fragment as Y } from "react/jsx-runtime";
2
+ import { c as K, u as Q, e as W, a as J, H as X, T as Z, x as ee, R as te, p as ae } from "./index-CU8j8cbs.js";
3
+ import { useState as l, useCallback as h, useEffect as f, useMemo as T } from "react";
4
4
  const ne = "_documentsTableBody_1voj8_1", oe = "_viewAttachmentsLink_1voj8_11", re = "_documentViewerContainer_1voj8_15", de = "_attachmentItem_1voj8_23", se = "_attachmentCounter_1voj8_27", ce = "_attachmentError_1voj8_36", ie = "_documentIframe_1voj8_44", le = "_documentImage_1voj8_50", d = {
5
5
  documentsTableBody: ne,
6
6
  viewAttachmentsLink: oe,
@@ -17,7 +17,7 @@ const ne = "_documentsTableBody_1voj8_1", oe = "_viewAttachmentsLink_1voj8_11",
17
17
  uploadedBy: "DOCUMENTS_UPLOADED_BY",
18
18
  action: "DOCUMENTS_ACTION"
19
19
  };
20
- function j(a) {
20
+ function R(a) {
21
21
  return !a || a.includes(":") ? "#" : `/openmrs/auth?requested_document=/document_images/${a}`;
22
22
  }
23
23
  function ue(a, g) {
@@ -26,29 +26,29 @@ function ue(a, g) {
26
26
  header: g(me[s])
27
27
  }));
28
28
  }
29
- const _e = [
29
+ const pe = [
30
30
  "documentIdentifier",
31
31
  "documentType",
32
32
  "uploadedOn",
33
33
  "uploadedBy",
34
34
  "action"
35
- ], 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 }] : [], Ee = ({ config: a, encounterUuids: g }) => {
36
- const [s, L] = l(!1), [o, w] = l(
35
+ ], _e = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, j = (a) => a.attachments.length > 0 ? a.attachments : a.documentUrl ? [{ url: a.documentUrl, contentType: a.contentType }] : [], Ee = ({ config: a, encounterUuids: g }) => {
36
+ const [s, w] = l(!1), [o, L] = l(
37
37
  null
38
- ), [R, f] = l(
38
+ ), [B, I] = l(
39
39
  /* @__PURE__ */ new Set()
40
- ), E = K(), { t: n } = Q(), { addNotification: U } = W(), $ = Number(a?.pageSize) || 5, [I, A] = l(1), [m, V] = l($), [k, y] = l(void 0), b = h((e) => {
41
- w(e), L(!0);
42
- }, []), F = h(() => {
43
- L(!1), w(null), f(/* @__PURE__ */ new Set());
44
- }, []), M = h((e) => {
45
- f((t) => new Set(t).add(e));
46
- }, []), { data: u, isLoading: H, isError: D, error: v } = X({
40
+ ), E = K(), { t: n } = Q(), { addNotification: U } = W(), $ = Number(a?.pageSize) || 5, [C, A] = l(1), [m, k] = l($), [H, y] = l(void 0), M = h((e) => {
41
+ L(e), w(!0);
42
+ }, []), V = h(() => {
43
+ w(!1), L(null), I(/* @__PURE__ */ new Set());
44
+ }, []), b = h((e) => {
45
+ I((t) => new Set(t).add(e));
46
+ }, []), { data: u, isLoading: F, isError: D, error: v } = J({
47
47
  queryKey: [
48
48
  "documents",
49
49
  E,
50
50
  g,
51
- I,
51
+ C,
52
52
  m
53
53
  ],
54
54
  enabled: !!E,
@@ -56,26 +56,26 @@ const _e = [
56
56
  E,
57
57
  g,
58
58
  m,
59
- I
59
+ C
60
60
  )
61
61
  });
62
- C(() => {
62
+ f(() => {
63
63
  u && y(u.total);
64
- }, [u]), C(() => {
64
+ }, [u]), f(() => {
65
65
  A(1), y(void 0);
66
- }, [E]), C(() => {
66
+ }, [E]), f(() => {
67
67
  D && U({
68
68
  title: n("ERROR_DEFAULT_TITLE"),
69
69
  message: v?.message ?? "",
70
70
  type: "error"
71
71
  });
72
- }, [D, v, U, n]), C(() => {
72
+ }, [D, v, U, n]), f(() => {
73
73
  const e = new AbortController();
74
74
  return (async () => {
75
75
  if (!s || !o) return;
76
- const t = /* @__PURE__ */ new Set(), c = B(o);
76
+ const t = /* @__PURE__ */ new Set(), c = j(o);
77
77
  for (let i = 0; i < c.length; i++) {
78
- const S = j(c[i].url);
78
+ const S = R(c[i].url);
79
79
  try {
80
80
  (await fetch(S, {
81
81
  method: "HEAD",
@@ -85,16 +85,16 @@ const _e = [
85
85
  O instanceof Error && O.name !== "AbortError" && t.add(i);
86
86
  }
87
87
  }
88
- e.signal.aborted || f(t);
88
+ e.signal.aborted || I(t);
89
89
  })(), () => e.abort();
90
90
  }, [s, o]);
91
91
  const q = h(
92
92
  (e, t) => {
93
- t !== m ? (V(t), A(1), y(void 0)) : A(e);
93
+ t !== m ? (k(t), A(1), y(void 0)) : A(e);
94
94
  },
95
95
  [m]
96
96
  ), N = T(
97
- () => a?.fields ?? _e,
97
+ () => a?.fields ?? pe,
98
98
  [a?.fields]
99
99
  ), x = T(() => [...u?.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), [u]), P = T(() => ue(N, n), [N, n]), z = T(
100
100
  () => N.map((e) => ({
@@ -102,8 +102,8 @@ const _e = [
102
102
  sortable: e !== "action"
103
103
  })),
104
104
  [N]
105
- ), _ = T(
106
- () => o ? B(o) : [],
105
+ ), p = T(
106
+ () => o ? j(o) : [],
107
107
  [o]
108
108
  ), G = h(
109
109
  (e, t) => {
@@ -122,9 +122,9 @@ const _e = [
122
122
  return e.uploadedBy ?? n("DOCUMENTS_NOT_AVAILABLE");
123
123
  case "action":
124
124
  return e.attachments.length > 0 || e.documentUrl ? /* @__PURE__ */ r(
125
- J,
125
+ X,
126
126
  {
127
- onClick: () => b(e),
127
+ onClick: () => M(e),
128
128
  className: d.viewAttachmentsLink,
129
129
  "data-testid": `view-attachments-${e.id}`,
130
130
  children: n("DOCUMENTS_VIEW_ATTACHMENTS")
@@ -134,16 +134,16 @@ const _e = [
134
134
  return null;
135
135
  }
136
136
  },
137
- [b, n]
137
+ [M, n]
138
138
  );
139
- return /* @__PURE__ */ p(Y, { children: [
139
+ return /* @__PURE__ */ _(Y, { children: [
140
140
  /* @__PURE__ */ r("div", { "data-testid": "documents-table", children: /* @__PURE__ */ r(
141
141
  ee,
142
142
  {
143
143
  headers: P,
144
144
  ariaLabel: n("DOCUMENTS_TABLE_HEADING"),
145
145
  rows: x,
146
- loading: H,
146
+ loading: F,
147
147
  errorStateMessage: D ? v?.message : null,
148
148
  sortable: z,
149
149
  emptyStateMessage: n("DOCUMENTS_NO_RECORDS"),
@@ -151,8 +151,8 @@ const _e = [
151
151
  className: d.documentsTableBody,
152
152
  dataTestId: "documents-table",
153
153
  pageSize: m,
154
- totalItems: k,
155
- page: I,
154
+ totalItems: H,
155
+ page: C,
156
156
  onPageChange: q
157
157
  }
158
158
  ) }),
@@ -162,38 +162,38 @@ const _e = [
162
162
  id: "modalIdForActionAreaLayout",
163
163
  portalId: "main-display-area",
164
164
  open: s,
165
- onRequestClose: F,
165
+ onRequestClose: V,
166
166
  modalHeading: o.documentIdentifier,
167
167
  passiveModal: !0,
168
168
  size: "lg",
169
169
  testId: "document-view-modal",
170
- children: /* @__PURE__ */ r("div", { className: d.documentViewerContainer, children: _.map((e, t) => {
171
- const c = j(e.url), i = e.contentType?.toLowerCase().includes("pdf"), S = (e.contentType?.toLowerCase().includes("image") ?? !1) || pe.test(e.url ?? ""), O = R.has(t);
172
- return c === "#" || O ? /* @__PURE__ */ p(
170
+ children: /* @__PURE__ */ r("div", { className: d.documentViewerContainer, children: p.map((e, t) => {
171
+ const c = R(e.url), i = e.contentType?.toLowerCase().includes("pdf"), S = (e.contentType?.toLowerCase().includes("image") ?? !1) || _e.test(e.url ?? ""), O = B.has(t);
172
+ return c === "#" || O ? /* @__PURE__ */ _(
173
173
  "div",
174
174
  {
175
175
  className: d.attachmentError,
176
176
  "data-testid": `attachment-error-${t}`,
177
177
  children: [
178
- _.length > 1 && /* @__PURE__ */ p("p", { className: d.attachmentCounter, children: [
178
+ p.length > 1 && /* @__PURE__ */ _("p", { className: d.attachmentCounter, children: [
179
179
  t + 1,
180
180
  "/",
181
- _.length
181
+ p.length
182
182
  ] }),
183
183
  /* @__PURE__ */ r("p", { children: n("DOCUMENTS_ERROR_LOADING_ATTACHMENT") })
184
184
  ]
185
185
  },
186
186
  `${o.id}-${e.url}`
187
- ) : /* @__PURE__ */ p(
187
+ ) : /* @__PURE__ */ _(
188
188
  "div",
189
189
  {
190
190
  className: d.attachmentItem,
191
191
  "data-testid": `attachment-item-${t}`,
192
192
  children: [
193
- _.length > 1 && /* @__PURE__ */ p("p", { className: d.attachmentCounter, children: [
193
+ p.length > 1 && /* @__PURE__ */ _("p", { className: d.attachmentCounter, children: [
194
194
  t + 1,
195
195
  "/",
196
- _.length
196
+ p.length
197
197
  ] }),
198
198
  S ? /* @__PURE__ */ r(
199
199
  "img",
@@ -201,7 +201,7 @@ const _e = [
201
201
  src: c,
202
202
  alt: o.documentIdentifier,
203
203
  className: d.documentImage,
204
- onError: () => M(t)
204
+ onError: () => b(t)
205
205
  }
206
206
  ) : /* @__PURE__ */ r(
207
207
  "iframe",
@@ -209,7 +209,7 @@ const _e = [
209
209
  src: i ? `${c}#toolbar=0` : c,
210
210
  className: d.documentIframe,
211
211
  title: o.documentIdentifier,
212
- onError: () => M(t)
212
+ onError: () => b(t)
213
213
  }
214
214
  )
215
215
  ]
@@ -0,0 +1,434 @@
1
+ import { jsx as o, jsxs as _, Fragment as j } from "react/jsx-runtime";
2
+ import { u as M, c as te, i as oe, b as ne, a as F, w as se, T as de, H as me, x as P, j as ie, F as le, R as ce, I as ue, Z as H, l as be, G as K, d as A, f as pe, k as _e, P as fe, B as he, s as $e, h as ge, g as ve, m as ye, n as Ne } from "./index-CU8j8cbs.js";
3
+ import { useState as k, useMemo as y, useCallback as R } from "react";
4
+ const Te = "_formsTableBody_1pd36_1", Fe = "_customAccordianItem_1pd36_6", Re = "_formContent_1pd36_18", Ae = "_formDetailsContainer_1pd36_25", Le = "_observation_1pd36_30", Ce = "_groupContainer_1pd36_39", Ie = "_rowContainer_1pd36_43", Oe = "_groupLabel_1pd36_48", Me = "_rowLabel_1pd36_58", we = "_rowValue_1pd36_67", xe = "_groupMembers_1pd36_75", Ve = "_memberRow_1pd36_81", De = "_memberLabel_1pd36_86", Se = "_memberValue_1pd36_94", Be = "_abnormalValue_1pd36_102", Ee = "_commentSection_1pd36_110", Ge = "_commentText_1pd36_116", Ue = "_nestedGroup_1pd36_125", qe = "_nestedGroupLabel_1pd36_132", Pe = "_nestedGroupMembers_1pd36_141", n = {
5
+ formsTableBody: Te,
6
+ customAccordianItem: Fe,
7
+ formContent: Re,
8
+ formDetailsContainer: Ae,
9
+ observation: Le,
10
+ groupContainer: Ce,
11
+ rowContainer: Ie,
12
+ groupLabel: Oe,
13
+ rowLabel: Me,
14
+ rowValue: we,
15
+ groupMembers: xe,
16
+ memberRow: Ve,
17
+ memberLabel: De,
18
+ memberValue: Se,
19
+ abnormalValue: Be,
20
+ commentSection: Ee,
21
+ commentText: Ge,
22
+ nestedGroup: Ue,
23
+ nestedGroupLabel: qe,
24
+ nestedGroupMembers: Pe
25
+ }, z = (e, r) => {
26
+ const t = pe(e);
27
+ return t === "Image" ? /* @__PURE__ */ o(
28
+ _e,
29
+ {
30
+ imageSrc: e,
31
+ alt: e,
32
+ id: `${e}-img`,
33
+ hideThumbnail: r
34
+ }
35
+ ) : t === "Video" ? /* @__PURE__ */ o(
36
+ fe,
37
+ {
38
+ id: `${e}-video`,
39
+ videoSrc: e,
40
+ hideThumbnail: r
41
+ }
42
+ ) : t === "PDF" ? /* @__PURE__ */ o(he, { id: `${e}-pdf`, src: e }) : e;
43
+ }, Q = (e) => {
44
+ const r = e.observationValue?.referenceRange?.low?.value, t = e.observationValue?.referenceRange?.high?.value, a = r != null, i = t != null;
45
+ let s = "";
46
+ a && i ? s = ` (${r} - ${t})` : a ? s = ` (>${r})` : i && (s = ` (<${t})`);
47
+ const p = e.observationValue?.isAbnormal === !0;
48
+ return { rangeString: s, isAbnormal: p };
49
+ }, Z = ({
50
+ member: e,
51
+ depth: r = 0,
52
+ memberIndex: t = 0,
53
+ formName: a = "",
54
+ comment: i,
55
+ hideThumbnail: s
56
+ }) => {
57
+ const { t: p } = M(), d = e.members && e.members.length > 0, u = e.display, c = a ? `${a}-` : "";
58
+ if (d)
59
+ return /* @__PURE__ */ _(
60
+ "div",
61
+ {
62
+ className: n.nestedGroup,
63
+ "data-testid": `${c}obs-nested-group-${u}-${t}`,
64
+ children: [
65
+ /* @__PURE__ */ o(
66
+ "div",
67
+ {
68
+ className: n.nestedGroupLabel,
69
+ "data-testid": `${c}obs-nested-group-label-${u}-${t}`,
70
+ style: { paddingLeft: `${r * 16}px` },
71
+ children: u
72
+ }
73
+ ),
74
+ /* @__PURE__ */ o(
75
+ "div",
76
+ {
77
+ className: n.nestedGroupMembers,
78
+ "data-testid": `${c}obs-nested-group-members-${u}-${t}`,
79
+ children: e.members?.map((N, T) => /* @__PURE__ */ o(
80
+ Z,
81
+ {
82
+ member: N,
83
+ depth: r + 1,
84
+ memberIndex: T,
85
+ formName: a,
86
+ hideThumbnail: s
87
+ },
88
+ `${N.id}`
89
+ ))
90
+ }
91
+ )
92
+ ]
93
+ }
94
+ );
95
+ const { rangeString: g, isAbnormal: f } = Q(e), h = K(e, p), $ = h ? z(h, s) : null;
96
+ return /* @__PURE__ */ _(j, { children: [
97
+ /* @__PURE__ */ _(
98
+ "div",
99
+ {
100
+ className: n.memberRow,
101
+ "data-testid": `${c}obs-member-row-${u}-${t}`,
102
+ style: { paddingLeft: `${r * 16}px` },
103
+ children: [
104
+ /* @__PURE__ */ _(
105
+ "p",
106
+ {
107
+ className: A(
108
+ n.memberLabel,
109
+ f ? n.abnormalValue : ""
110
+ ),
111
+ "data-testid": `${c}obs-member-label-${u}-${t}`,
112
+ children: [
113
+ u,
114
+ g
115
+ ]
116
+ }
117
+ ),
118
+ /* @__PURE__ */ o(
119
+ "div",
120
+ {
121
+ className: A(
122
+ n.memberValue,
123
+ f ? n.abnormalValue : ""
124
+ ),
125
+ "data-testid": `${c}obs-member-value-${u}-${t}`,
126
+ children: $
127
+ }
128
+ )
129
+ ]
130
+ }
131
+ ),
132
+ i && /* @__PURE__ */ o(
133
+ "div",
134
+ {
135
+ className: n.commentSection,
136
+ "data-testid": `${c}obs-member-comment-${u}-${t}`,
137
+ style: { paddingLeft: `${r * 16}px` },
138
+ children: /* @__PURE__ */ _("span", { className: n.commentText, children: [
139
+ i,
140
+ e.encounter?.provider && ` - by ${e.encounter.provider}`
141
+ ] })
142
+ }
143
+ )
144
+ ] });
145
+ }, He = ({
146
+ observation: e,
147
+ index: r,
148
+ formName: t = "",
149
+ comment: a,
150
+ hideThumbnail: i
151
+ }) => {
152
+ const { t: s } = M(), p = e.members && e.members.length > 0, { rangeString: d, isAbnormal: u } = Q(e), c = t ? `${t}-` : "", g = K(e, s), f = g ? z(g, i) : null;
153
+ return /* @__PURE__ */ _(
154
+ "div",
155
+ {
156
+ className: n.observation,
157
+ "data-testid": `${c}observation-item-${e.display}-${r}`,
158
+ children: [
159
+ /* @__PURE__ */ _(
160
+ "div",
161
+ {
162
+ className: p ? n.groupContainer : n.rowContainer,
163
+ "data-testid": `${c}observation-container-${e.display}-${r}`,
164
+ children: [
165
+ /* @__PURE__ */ _(
166
+ "p",
167
+ {
168
+ className: A(
169
+ p ? n.groupLabel : n.rowLabel,
170
+ !p && u ? n.abnormalValue : ""
171
+ ),
172
+ "data-testid": `${c}observation-label-${e.display}-${r}`,
173
+ children: [
174
+ e.display,
175
+ !p && d && /* @__PURE__ */ o("span", { className: n.rangeInfo, children: d })
176
+ ]
177
+ }
178
+ ),
179
+ p ? /* @__PURE__ */ o(
180
+ "div",
181
+ {
182
+ className: n.groupMembers,
183
+ "data-testid": `${c}observation-group-members-${e.display}-${r}`,
184
+ children: e.members?.map((h, $) => /* @__PURE__ */ o(
185
+ Z,
186
+ {
187
+ member: h,
188
+ depth: 0,
189
+ memberIndex: $,
190
+ formName: t,
191
+ hideThumbnail: i
192
+ },
193
+ `${h.id}`
194
+ ))
195
+ }
196
+ ) : /* @__PURE__ */ o(
197
+ "div",
198
+ {
199
+ className: A(
200
+ n.rowValue,
201
+ u ? n.abnormalValue : ""
202
+ ),
203
+ "data-testid": `${c}observation-value-${e.display}-${r}`,
204
+ children: f
205
+ }
206
+ )
207
+ ]
208
+ }
209
+ ),
210
+ a && /* @__PURE__ */ o(
211
+ "div",
212
+ {
213
+ className: n.commentSection,
214
+ "data-testid": `${c}observation-comment-${e.display}-${r}`,
215
+ children: /* @__PURE__ */ _("span", { className: n.commentText, children: [
216
+ a,
217
+ e.encounter?.provider && ` - by ${e.encounter.provider}`
218
+ ] })
219
+ }
220
+ )
221
+ ]
222
+ },
223
+ `${e.id}-${r}`
224
+ );
225
+ }, ke = (e) => e ? e.extension?.find(
226
+ (r) => r.url === $e
227
+ )?.valueString : void 0, je = (e) => {
228
+ if (e)
229
+ return e.note?.[0]?.text;
230
+ }, Ke = (e, r) => e.entry?.find((t) => t.resource?.id === r)?.resource, O = (e, r) => {
231
+ const t = Ke(e, r);
232
+ return t ? {
233
+ formFieldPath: ke(t),
234
+ comment: je(t)
235
+ } : {};
236
+ }, ze = (e, r) => {
237
+ if (!e?.entry || !r)
238
+ return [];
239
+ const t = be(e);
240
+ return [
241
+ ...t.observations.map((a) => {
242
+ const { formFieldPath: i, comment: s } = O(
243
+ e,
244
+ a.id
245
+ );
246
+ return { obs: a, formFieldPath: i, comment: s };
247
+ }),
248
+ ...t.groupedObservations.flatMap((a) => {
249
+ const { formFieldPath: i } = O(e, a.id);
250
+ return (a.members ?? []).map((s) => {
251
+ const { comment: p } = O(e, s.id);
252
+ return { obs: s, formFieldPath: i, comment: p };
253
+ });
254
+ })
255
+ ].filter(
256
+ ({ formFieldPath: a }) => !a || a.includes(r)
257
+ );
258
+ }, Je = ({
259
+ episodeOfCareUuids: e,
260
+ encounterUuids: r,
261
+ config: t
262
+ }) => {
263
+ const { t: a } = M(), i = te(), [s, p] = k(!1), [d, u] = k(null), { numberOfVisits: c, hideThumbnail: g = !1 } = t ?? {}, f = oe(
264
+ e,
265
+ r
266
+ ), h = ne(), {
267
+ data: $ = [],
268
+ isLoading: N,
269
+ isError: T,
270
+ error: Y,
271
+ refetch: J
272
+ } = F({
273
+ queryKey: ["forms", i, e],
274
+ queryFn: () => ge(i, void 0, c),
275
+ enabled: !!i && !f
276
+ }), w = y(() => !r || r.length === 0 ? $ : $.filter(
277
+ (m) => r.includes(m.encounterUuid)
278
+ ), [$, r]), { data: x = [] } = F({
279
+ queryKey: ["observationForms"],
280
+ queryFn: () => ve()
281
+ }), V = R(
282
+ (m) => x.find((b) => b.name === m)?.uuid,
283
+ [x]
284
+ ), L = y(() => {
285
+ if (d)
286
+ return V(d.formName);
287
+ }, [d, V]), { isLoading: W, error: D } = F({
288
+ queryKey: ["formMetadata", L],
289
+ queryFn: () => ye(L),
290
+ enabled: !!L && s
291
+ }), {
292
+ data: C,
293
+ isLoading: X,
294
+ error: S
295
+ } = F({
296
+ queryKey: ["formsEncounterFHIR", d?.encounterUuid],
297
+ queryFn: () => Ne(d.encounterUuid),
298
+ enabled: !!d?.encounterUuid && s
299
+ });
300
+ se(
301
+ (m) => {
302
+ m.patientUUID === i && m.updatedConcepts.size > 0 && (J(), h.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
303
+ },
304
+ [i]
305
+ );
306
+ const B = y(() => !C || !d?.formName ? [] : ze(
307
+ C,
308
+ d.formName
309
+ ), [C, d?.formName]), E = y(
310
+ () => [
311
+ { key: "recordedOn", header: a("FORM_RECORDED_ON") },
312
+ { key: "recordedBy", header: a("FORM_RECORDED_BY") }
313
+ ],
314
+ [a]
315
+ ), ee = y(
316
+ () => [
317
+ { key: "recordedOn", sortable: !0 },
318
+ { key: "recordedBy", sortable: !0 }
319
+ ],
320
+ []
321
+ ), G = y(() => {
322
+ const m = w.reduce(
323
+ (b, l) => {
324
+ const v = l.formName;
325
+ b[v] ??= [];
326
+ const I = l.providers.map((ae) => ae.providerName).filter(Boolean).join(", ");
327
+ return b[v].push({
328
+ id: l.encounterUuid,
329
+ formName: l.formName,
330
+ recordedOn: de(l.encounterDateTime, a, !0).formattedResult,
331
+ recordedBy: I ?? "--",
332
+ encounterDateTime: l.encounterDateTime,
333
+ encounterUuid: l.encounterUuid
334
+ }), b;
335
+ },
336
+ {}
337
+ );
338
+ return Object.entries(m).map(
339
+ ([b, l]) => ({
340
+ formName: b,
341
+ records: l.sort(
342
+ (v, I) => I.encounterDateTime - v.encounterDateTime
343
+ )
344
+ })
345
+ ).sort((b, l) => b.formName.localeCompare(l.formName));
346
+ }, [w, a]), U = R((m) => {
347
+ u(m), p(!0);
348
+ }, []), re = R(() => {
349
+ p(!1), u(null);
350
+ }, []), q = R(
351
+ (m, b) => {
352
+ switch (b) {
353
+ case "recordedOn":
354
+ return /* @__PURE__ */ o(me, { onClick: () => U(m), children: m.recordedOn });
355
+ case "recordedBy":
356
+ return m.recordedBy;
357
+ default:
358
+ return null;
359
+ }
360
+ },
361
+ [U]
362
+ );
363
+ return /* @__PURE__ */ _(j, { children: [
364
+ /* @__PURE__ */ o("div", { "data-testid": "forms-table", children: N || T || G.length === 0 || f ? /* @__PURE__ */ o(
365
+ P,
366
+ {
367
+ headers: E,
368
+ ariaLabel: a("FORMS_HEADING"),
369
+ rows: [],
370
+ loading: N,
371
+ errorStateMessage: T ? Y?.message : void 0,
372
+ emptyStateMessage: a("FORMS_UNAVAILABLE"),
373
+ renderCell: q,
374
+ className: n.formsTableBody,
375
+ dataTestId: "forms-table"
376
+ }
377
+ ) : /* @__PURE__ */ o(ie, { align: "start", children: G.map((m, b) => {
378
+ const { formName: l, records: v } = m;
379
+ return /* @__PURE__ */ o(
380
+ le,
381
+ {
382
+ title: l,
383
+ className: n.customAccordianItem,
384
+ testId: `accordian-title-${l}`,
385
+ open: b === 0,
386
+ children: /* @__PURE__ */ o(
387
+ P,
388
+ {
389
+ headers: E,
390
+ ariaLabel: a("FORMS_HEADING"),
391
+ rows: v,
392
+ loading: !1,
393
+ errorStateMessage: "",
394
+ sortable: ee,
395
+ emptyStateMessage: a("FORMS_UNAVAILABLE"),
396
+ renderCell: q,
397
+ className: n.formsTableBody,
398
+ dataTestId: `forms-table-${l}`
399
+ }
400
+ )
401
+ },
402
+ l
403
+ );
404
+ }) }) }),
405
+ s && d && /* @__PURE__ */ o(
406
+ ce,
407
+ {
408
+ id: "modalIdForActionAreaLayout",
409
+ portalId: "main-display-area",
410
+ open: s,
411
+ onRequestClose: re,
412
+ modalHeading: d.formName,
413
+ modalLabel: `${d.recordedOn} | ${d.recordedBy}`,
414
+ passiveModal: !0,
415
+ size: "md",
416
+ testId: "form-details-modal",
417
+ children: /* @__PURE__ */ o("div", { className: n.formContent, children: W || X ? /* @__PURE__ */ o(ue, { width: "100%", lineCount: 3 }) : D ? /* @__PURE__ */ o("div", { children: H(D).message ?? a("ERROR_FETCHING_FORM_METADATA") }) : S ? /* @__PURE__ */ o("div", { children: H(S).message ?? a("ERROR_FETCHING_FORM_DATA") }) : B.length > 0 ? /* @__PURE__ */ o("div", { className: n.formDetailsContainer, children: B.map(({ obs: m, comment: b }, l) => /* @__PURE__ */ o(
418
+ He,
419
+ {
420
+ observation: m,
421
+ index: l,
422
+ formName: d.formName,
423
+ comment: b,
424
+ hideThumbnail: g
425
+ },
426
+ `${m.id}`
427
+ )) }) : /* @__PURE__ */ o("div", { children: a("NO_FORM_DATA_AVAILABLE") }) })
428
+ }
429
+ )
430
+ ] });
431
+ };
432
+ export {
433
+ Je as default
434
+ };
@@ -1,5 +1,5 @@
1
- import { c, T as l, P as m, a as u, D as v, Q as i } from "./YPM2AS64-tg45YSAK.js";
2
- import { Y as d, _ as f, a0 as e } from "./index-DIv6b2ab.js";
1
+ import { c, T as l, P as m, a as u, D as v, Q as i } from "./YPM2AS64-Bpoe3cvd.js";
2
+ import { _ as d, $ as f, a0 as e } from "./index-CU8j8cbs.js";
3
3
  var p = (a) => {
4
4
  const [r, t] = 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-tg45YSAK.js";
2
- import { Y as v, _ as C, a0 as e } from "./index-DIv6b2ab.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-Bpoe3cvd.js";
2
+ import { _ as v, $ as C, a0 as e } from "./index-CU8j8cbs.js";
3
3
  var h = (t) => {
4
4
  const [r, o] = s({
5
5
  prefix: "TanstackQueryDevtools"