@bahmni/registration-app 0.0.1-dev.190 → 0.0.1-dev.192

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