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