@bahmni/registration-app 0.0.1-dev.210 → 0.0.1-dev.214

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