@bahmni/appointments-app 0.0.1-dev.186 → 0.0.1-dev.187

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,8 +1,8 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
- import { $ as C, a0 as E, a1 as S, u as M, a as f, a2 as L, a3 as y, a4 as N, a5 as g, a6 as I } from "./index-DkkyqBOR.js";
2
+ import { z as E, B as C, C as M, u as S, a as f, O as L, D as y, E as N, I as g, M as I } from "./index-BcyBWCkX.js";
3
3
  import { useMemo as o } from "react";
4
- const R = C(
5
- E,
4
+ const R = E(
5
+ C,
6
6
  "useAppointmentsConfig",
7
7
  "AppointmentsConfigProvider"
8
8
  ), l = [
@@ -11,28 +11,28 @@ const R = C(
11
11
  "speciality",
12
12
  "durationMins",
13
13
  "description"
14
- ], h = "_tableContainer_jtyg5_1", D = "_table_jtyg5_1", c = {
15
- tableContainer: h,
16
- table: D
14
+ ], D = "_tableContainer_jtyg5_1", h = "_table_jtyg5_1", c = {
15
+ tableContainer: D,
16
+ table: h
17
17
  };
18
- function v(t) {
19
- return t.filter((a) => !l.includes(a));
18
+ function O(t) {
19
+ return t.filter((n) => !l.includes(n));
20
20
  }
21
- function O(t, a) {
21
+ function v(t, n) {
22
22
  return [
23
23
  ...t.map((e) => ({
24
24
  key: e,
25
- header: a(
26
- `ADMIN_ALL_SERVICES_COLUMN_${S(e)}`
25
+ header: n(
26
+ `ADMIN_ALL_SERVICES_COLUMN_${M(e)}`
27
27
  )
28
28
  })),
29
29
  {
30
30
  key: "actions",
31
- header: a("ADMIN_ALL_SERVICES_COLUMN_ACTIONS")
31
+ header: n("ADMIN_ALL_SERVICES_COLUMN_ACTIONS")
32
32
  }
33
33
  ];
34
34
  }
35
- function T(t, a) {
35
+ function T(t, n) {
36
36
  return t.map((e) => ({
37
37
  id: e.uuid,
38
38
  name: e.name,
@@ -41,28 +41,28 @@ function T(t, a) {
41
41
  durationMins: e.durationMins,
42
42
  description: e.description,
43
43
  attributes: Object.fromEntries(
44
- a.map((n) => [
45
- n,
46
- e.attributes?.find((i) => i.attributeType === n)?.value ?? null
44
+ n.map((a) => [
45
+ a,
46
+ e.attributes?.find((i) => i.attributeType === a)?.value ?? null
47
47
  ])
48
48
  )
49
49
  }));
50
50
  }
51
- const B = () => {
52
- const { t } = M(), { appointmentsConfig: a } = R(), e = a?.serviceTableFields ?? [
51
+ const j = () => {
52
+ const { t } = S(), { appointmentsConfig: n } = R(), e = n?.serviceTableFields ?? [
53
53
  ...l
54
- ], n = o(
55
- () => v(e),
54
+ ], a = o(
55
+ () => O(e),
56
56
  [e]
57
57
  ), { data: i, isLoading: m, isError: p } = f({
58
58
  queryKey: ["allAppointmentServices"],
59
59
  queryFn: I
60
60
  }), d = o(
61
- () => O(e, t),
61
+ () => v(e, t),
62
62
  [e]
63
63
  ), _ = o(
64
- () => T(i ?? [], n),
65
- [i, n]
64
+ () => T(i ?? [], a),
65
+ [i, a]
66
66
  ), b = (u, s) => s === "actions" ? null : l.includes(s) ? u[s] ?? "-" : u.attributes[s] ?? "-", A = [
67
67
  { id: "home", label: t("BREADCRUMB_HOME"), href: L },
68
68
  { id: "admin", label: t("BREADCRUMB_ADMIN"), isCurrentPage: !0 }
@@ -90,5 +90,5 @@ const B = () => {
90
90
  );
91
91
  };
92
92
  export {
93
- B as default
93
+ j as default
94
94
  };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { aV as t } from "./index-DkkyqBOR.js";
1
+ import { aH as t } from "./index-BcyBWCkX.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.186",
3
+ "version": "0.0.1-dev.187",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -1,369 +0,0 @@
1
- import { jsxs as D, jsx as v } from "react/jsx-runtime";
2
- import { n as U, o as w, r as P, Q as L, c as V, s as K, t as G, v as j, w as W, z as J, A as X, B as T, D as N, E as Y, H as Z, M as ee, p as se, u as M, I as te, a as re, S as ie, e as ne, J as oe, L as ae, R as ue, b as ce, N as le, W as k, X as he, h as de, Z as pe, y as be, x as fe, k as ye, _ as ve } from "./index-DkkyqBOR.js";
3
- import * as E from "react";
4
- import { useRef as me, useEffect as I, useMemo as C } from "react";
5
- function $(e, s) {
6
- const t = new Set(s);
7
- return e.filter((i) => !t.has(i));
8
- }
9
- function Re(e, s, t) {
10
- const i = e.slice(0);
11
- return i[s] = t, i;
12
- }
13
- var Oe = class extends U {
14
- #r;
15
- #e;
16
- #i;
17
- #n;
18
- #s;
19
- #t;
20
- #o;
21
- #a;
22
- #u = [];
23
- constructor(e, s, t) {
24
- super(), this.#r = e, this.#n = t, this.#i = [], this.#s = [], this.#e = [], this.setQueries(s);
25
- }
26
- onSubscribe() {
27
- this.listeners.size === 1 && this.#s.forEach((e) => {
28
- e.subscribe((s) => {
29
- this.#d(e, s);
30
- });
31
- });
32
- }
33
- onUnsubscribe() {
34
- this.listeners.size || this.destroy();
35
- }
36
- destroy() {
37
- this.listeners = /* @__PURE__ */ new Set(), this.#s.forEach((e) => {
38
- e.destroy();
39
- });
40
- }
41
- setQueries(e, s) {
42
- if (this.#i = e, this.#n = s, process.env.NODE_ENV !== "production") {
43
- const t = e.map(
44
- (i) => this.#r.defaultQueryOptions(i).queryHash
45
- );
46
- new Set(t).size !== t.length && console.warn(
47
- "[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior."
48
- );
49
- }
50
- w.batch(() => {
51
- const t = this.#s, i = this.#h(this.#i);
52
- this.#u = i, i.forEach(
53
- (n) => n.observer.setOptions(n.defaultedQueryOptions)
54
- );
55
- const r = i.map((n) => n.observer), o = r.map(
56
- (n) => n.getCurrentResult()
57
- ), a = r.some(
58
- (n, u) => n !== t[u]
59
- );
60
- t.length === r.length && !a || (this.#s = r, this.#e = o, this.hasListeners() && ($(t, r).forEach((n) => {
61
- n.destroy();
62
- }), $(r, t).forEach((n) => {
63
- n.subscribe((u) => {
64
- this.#d(n, u);
65
- });
66
- }), this.#p()));
67
- });
68
- }
69
- getCurrentResult() {
70
- return this.#e;
71
- }
72
- getQueries() {
73
- return this.#s.map((e) => e.getCurrentQuery());
74
- }
75
- getObservers() {
76
- return this.#s;
77
- }
78
- getOptimisticResult(e, s) {
79
- const t = this.#h(e), i = t.map(
80
- (r) => r.observer.getOptimisticResult(r.defaultedQueryOptions)
81
- );
82
- return [
83
- i,
84
- (r) => this.#l(r ?? i, s),
85
- () => this.#c(i, t)
86
- ];
87
- }
88
- #c(e, s) {
89
- return s.map((t, i) => {
90
- const r = e[i];
91
- return t.defaultedQueryOptions.notifyOnChangeProps ? r : t.observer.trackResult(r, (o) => {
92
- s.forEach((a) => {
93
- a.observer.trackProp(o);
94
- });
95
- });
96
- });
97
- }
98
- #l(e, s) {
99
- return s ? ((!this.#t || this.#e !== this.#a || s !== this.#o) && (this.#o = s, this.#a = this.#e, this.#t = P(
100
- this.#t,
101
- s(e)
102
- )), this.#t) : e;
103
- }
104
- #h(e) {
105
- const s = new Map(
106
- this.#s.map((i) => [i.options.queryHash, i])
107
- ), t = [];
108
- return e.forEach((i) => {
109
- const r = this.#r.defaultQueryOptions(i), o = s.get(r.queryHash);
110
- o ? t.push({
111
- defaultedQueryOptions: r,
112
- observer: o
113
- }) : t.push({
114
- defaultedQueryOptions: r,
115
- observer: new L(this.#r, r)
116
- });
117
- }), t;
118
- }
119
- #d(e, s) {
120
- const t = this.#s.indexOf(e);
121
- t !== -1 && (this.#e = Re(this.#e, t, s), this.#p());
122
- }
123
- #p() {
124
- if (this.hasListeners()) {
125
- const e = this.#t, s = this.#c(this.#e, this.#u), t = this.#l(s, this.#n?.combine);
126
- e !== t && w.batch(() => {
127
- this.listeners.forEach((i) => {
128
- i(this.#e);
129
- });
130
- });
131
- }
132
- }
133
- };
134
- function ge({
135
- queries: e,
136
- ...s
137
- }, t) {
138
- const i = V(t), r = K(), o = G(), a = E.useMemo(
139
- () => e.map((l) => {
140
- const d = i.defaultQueryOptions(
141
- l
142
- );
143
- return d._optimisticResults = r ? "isRestoring" : "optimistic", d;
144
- }),
145
- [e, i, r]
146
- );
147
- a.forEach((l) => {
148
- j(l), W(l, o);
149
- }), J(o);
150
- const [n] = E.useState(
151
- () => new Oe(
152
- i,
153
- a,
154
- s
155
- )
156
- ), [u, p, b] = n.getOptimisticResult(
157
- a,
158
- s.combine
159
- ), f = !r && s.subscribed !== !1;
160
- E.useSyncExternalStore(
161
- E.useCallback(
162
- (l) => f ? n.subscribe(w.batchCalls(l)) : X,
163
- [n, f]
164
- ),
165
- () => n.getCurrentResult(),
166
- () => n.getCurrentResult()
167
- ), E.useEffect(() => {
168
- n.setQueries(
169
- a,
170
- s
171
- );
172
- }, [a, s, n]);
173
- const S = u.some(
174
- (l, d) => T(a[d], l)
175
- ) ? u.flatMap((l, d) => {
176
- const h = a[d];
177
- if (h) {
178
- const O = new L(i, h);
179
- if (T(h, l))
180
- return N(h, O, o);
181
- Y(l, r) && N(h, O, o);
182
- }
183
- return [];
184
- }) : [];
185
- if (S.length > 0)
186
- throw Promise.all(S);
187
- const R = u.find(
188
- (l, d) => {
189
- const h = a[d];
190
- return h && Z({
191
- result: l,
192
- errorResetBoundary: o,
193
- throwOnError: h.throwOnError,
194
- query: i.getQueryCache().get(h.queryHash),
195
- suspense: h.suspense
196
- });
197
- }
198
- );
199
- if (R?.error)
200
- throw R.error;
201
- return p(b());
202
- }
203
- const z = (e, s, t, i, r) => {
204
- const o = he(e, s), a = o.value, n = de(a);
205
- let u = a;
206
- n === "Image" && (u = /* @__PURE__ */ v(be, { imageSrc: a, alt: a, id: `${a}-img` })), n === "Video" && (u = /* @__PURE__ */ v(fe, { id: `${a}-video`, videoSrc: a })), n === "PDF" && (u = /* @__PURE__ */ v(ye, { id: `${a}-pdf`, src: a }));
207
- const p = r("OBSERVATIONS_RECORDED_BY", {
208
- provider: o.provider
209
- }), b = e.display, f = e.observationValue?.isAbnormal ? "abnormal-obs" : "obs", y = i ? `${i}-${f}-${b}-${t}-${s}` : `${f}-${b}-${t}-${s}`;
210
- return /* @__PURE__ */ v(
211
- pe,
212
- {
213
- header: o.header,
214
- value: u,
215
- info: p,
216
- id: y,
217
- testId: y,
218
- ariaLabel: y
219
- },
220
- `obs-${e.id}`
221
- );
222
- }, Ee = (e, s, t, i, r, o) => /* @__PURE__ */ v(
223
- k,
224
- {
225
- title: e.display,
226
- id: `grouped-obs-${e.display}-${i}`,
227
- open: t,
228
- children: e.members?.map(
229
- (a, n) => z(a, n, r, o, s)
230
- )
231
- },
232
- `grouped-obs-${e.id}`
233
- ), Se = ({
234
- groupedData: e,
235
- title: s = ""
236
- }) => {
237
- const { t } = M(), i = (r, o, a) => {
238
- const n = le(r.encounterDetails, t);
239
- return /* @__PURE__ */ D(
240
- k,
241
- {
242
- title: n,
243
- id: `encounter-${r.encounterId}`,
244
- open: o,
245
- children: [
246
- r.observations.map(
247
- (u, p) => z(u, p, a, s, t)
248
- ),
249
- r.groupedObservations.map(
250
- (u, p) => Ee(
251
- u,
252
- t,
253
- o,
254
- p,
255
- a,
256
- s
257
- )
258
- )
259
- ]
260
- },
261
- `encounter-${r.encounterId}`
262
- );
263
- };
264
- return /* @__PURE__ */ v(
265
- "div",
266
- {
267
- id: "obs-by-encounter",
268
- "data-testid": "obs-by-encounter-test-id",
269
- "aria-label": "obs-by-encounter-aria-label",
270
- children: e.map(
271
- (r, o) => i(r, o === 0, o)
272
- )
273
- }
274
- );
275
- }, Qe = "_observations_kfbhq_1", Ce = "_title_kfbhq_12", q = {
276
- observations: Qe,
277
- title: Ce
278
- }, we = (e) => ["conceptUuid", e], _e = (e, s) => ["observations", e, ...s], $e = ({ config: e }) => {
279
- const s = e, { conceptNames: t = [], conceptUuid: i = [] } = s, r = me(/* @__PURE__ */ new Set()), o = ee(), { addNotification: a } = se(), { t: n } = M(), u = ge({
280
- queries: t.map((c) => ({
281
- queryKey: we(c),
282
- queryFn: () => te(c),
283
- enabled: !!c
284
- }))
285
- });
286
- I(() => {
287
- u.forEach((c, m) => {
288
- if (c.isError && !r.current.has(m)) {
289
- const H = t[m];
290
- a({
291
- title: n("ERROR_DEFAULT_TITLE"),
292
- message: n("ERROR_FETCHING_CONCEPT", { conceptName: H }),
293
- type: "error"
294
- }), r.current.add(m);
295
- } else c.isError || r.current.delete(m);
296
- });
297
- }, [u, t]);
298
- const p = C(() => u.map((c) => c.data?.uuid).filter((c) => !!c), [u]), b = C(() => [.../* @__PURE__ */ new Set([...p, ...i])], [p, i]), f = C(() => t.length === 0 ? !0 : u.every((c) => !c.isLoading), [u, t.length]), {
299
- data: y,
300
- isLoading: S,
301
- isError: R,
302
- refetch: l
303
- } = re({
304
- queryKey: _e(o, b),
305
- queryFn: () => ve(o, b),
306
- enabled: !!o && b.length > 0 && f
307
- });
308
- ie(
309
- (c) => {
310
- c.patientUUID === o && c.updatedConcepts.size > 0 && [...c.updatedConcepts.keys()].some(
311
- (m) => b.includes(m)
312
- ) && l();
313
- },
314
- [o, l]
315
- ), I(() => {
316
- R && a({
317
- title: n("ERROR_DEFAULT_TITLE"),
318
- message: n("ERROR_FETCHING_OBSERVATIONS"),
319
- type: "error"
320
- });
321
- }, [R]);
322
- const d = C(() => {
323
- if (!y) return [];
324
- const c = ne(y), m = oe(c);
325
- return ae(m);
326
- }, [y]), h = [
327
- { key: "name", header: "name" },
328
- { key: "value", header: "value" },
329
- { key: "form", header: "form" }
330
- ], O = S || !f, _ = R && f, A = (!y || y.entry?.length === 0 || b.length === 0) && f, x = _ ? n("ERROR_FETCHING_OBSERVATIONS") : null, B = A ? n("NO_OBSERVATIONS_FOUND") : void 0, F = d.length > 0 && !O && !_, Q = s.titleTranslationKey, g = Q ? n(Q) : "";
331
- return /* @__PURE__ */ D(
332
- "div",
333
- {
334
- id: "observations",
335
- "data-testid": Q ? `observations-${g}` : "observations",
336
- "aria-label": "observations-aria-label",
337
- className: q.observations,
338
- children: [
339
- /* @__PURE__ */ v(
340
- ue,
341
- {
342
- id: "observations-title",
343
- testId: Q ? `observations-title-${g}` : "observations-title",
344
- title: g,
345
- className: q.title,
346
- children: /* @__PURE__ */ v("p", { children: g })
347
- }
348
- ),
349
- F ? /* @__PURE__ */ v(Se, { groupedData: d, title: g }) : /* @__PURE__ */ v(
350
- ce,
351
- {
352
- headers: h,
353
- rows: [],
354
- ariaLabel: n("OBSERVATIONS"),
355
- loading: O,
356
- errorStateMessage: x,
357
- emptyStateMessage: B,
358
- dataTestId: "observations-table"
359
- }
360
- )
361
- ]
362
- }
363
- );
364
- };
365
- export {
366
- we as conceptUuidQueryKeys,
367
- $e as default,
368
- _e as observationsQueryKeys
369
- };