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