@bahmni/appointments-app 0.0.1-dev.215 → 0.0.1-dev.217

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