@bahmni/widgets 0.0.1-dev.191 → 0.0.1-dev.193

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