@bahmni/clinical-app 0.0.1-dev.119 → 0.0.1-dev.120

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 { aD as i } from "./index-aCQK8yvY.js";
1
+ import { ap as i } from "./index-DU0CcPEi.js";
2
2
  export {
3
3
  i as ClinicalApp
4
4
  };
@@ -154,14 +154,19 @@
154
154
  "INVESTIGATION_PANEL": "Panel",
155
155
  "INVESTIGATION_PRIORITY_URGENT": "Urgent",
156
156
  "IN_PROGRESS_STATUS": "In progress",
157
+ "LAB_TEST_ACTIONS": "Action",
157
158
  "LAB_TEST_ERROR_LOADING": "Error loading lab tests",
158
159
  "LAB_TEST_LOADING": "Loading lab tests...",
160
+ "LAB_TEST_NAME": "Test name",
159
161
  "LAB_TEST_ORDERED_BY": "Ordered By",
160
162
  "LAB_TEST_PANEL": "Panel",
163
+ "LAB_TEST_REFERENCE_RANGE": "Reference range",
164
+ "LAB_TEST_REPORTED_ON": "Reported on",
161
165
  "LAB_TEST_RESULT": "Result",
162
166
  "LAB_TEST_RESULTS_PENDING": "Results Pending",
163
167
  "LAB_TEST_UNAVAILABLE": "No lab investigations recorded",
164
168
  "LAB_TEST_URGENT": "Urgent",
169
+ "LAB_TEST_VIEW_ATTACHMENT": "View attachment",
165
170
  "LOADING_CLINICAL_CONFIG": "Loading clinical configuration...",
166
171
  "LOADING_CONCEPTS": "Loading concepts...",
167
172
  "LOADING_DASHBOARD_CONFIG": "Loading dashboard configuration...",
@@ -154,14 +154,19 @@
154
154
  "INVESTIGATION_PANEL": "Panel",
155
155
  "INVESTIGATION_PRIORITY_URGENT": "Urgente",
156
156
  "IN_PROGRESS_STATUS": "En progreso",
157
+ "LAB_TEST_ACTIONS": "Acción",
157
158
  "LAB_TEST_ERROR_LOADING": "Error al cargar pruebas de laboratorio",
158
159
  "LAB_TEST_LOADING": "Cargando pruebas de laboratorio...",
160
+ "LAB_TEST_NAME": "Nombre de la prueba",
159
161
  "LAB_TEST_ORDERED_BY": "Ordenado por",
160
162
  "LAB_TEST_PANEL": "Panel",
163
+ "LAB_TEST_REFERENCE_RANGE": "Rango de referencia",
164
+ "LAB_TEST_REPORTED_ON": "Informado el",
161
165
  "LAB_TEST_RESULT": "Resultado",
162
166
  "LAB_TEST_RESULTS_PENDING": "Resultados pendientes",
163
167
  "LAB_TEST_UNAVAILABLE": "No se registraron pruebas de laboratorio",
164
168
  "LAB_TEST_URGENT": "Urgente",
169
+ "LAB_TEST_VIEW_ATTACHMENT": "Ver adjunto",
165
170
  "LOADING_CLINICAL_CONFIG": "Cargando configuración clínica...",
166
171
  "LOADING_CONCEPTS": "Cargando conceptos...",
167
172
  "LOADING_DASHBOARD_CONFIG": "Cargando configuración del panel...",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bahmni/clinical-app",
3
- "version": "0.0.1-dev.119",
3
+ "version": "0.0.1-dev.120",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -1,527 +0,0 @@
1
- import { jsxs as I, jsx as b } from "react/jsx-runtime";
2
- import { g as F, n as w, r as H, Q as D, h as U, i as P, j as K, k as z, l as W, m as j, o as J, s as T, p as Q, t as X, v as Y, O as Z, x as ee, u as N, y as te, a as se, W as re, e as ne, z as ie, A as M, B as oe, V as ae, E as ue, F as le, G as ce } from "./index-aCQK8yvY.js";
3
- import * as R from "react";
4
- import { useRef as de, useEffect as C, useMemo as S } from "react";
5
- function _(e, s) {
6
- const t = new Set(s);
7
- return e.filter((r) => !t.has(r));
8
- }
9
- function he(e, s, t) {
10
- const r = e.slice(0);
11
- return r[s] = t, r;
12
- }
13
- var pe = class extends F {
14
- #r;
15
- #e;
16
- #n;
17
- #i;
18
- #t;
19
- #s;
20
- #o;
21
- #a;
22
- #u = [];
23
- constructor(e, s, t) {
24
- super(), this.#r = e, this.#i = t, this.#n = [], this.#t = [], this.#e = [], this.setQueries(s);
25
- }
26
- onSubscribe() {
27
- this.listeners.size === 1 && this.#t.forEach((e) => {
28
- e.subscribe((s) => {
29
- this.#h(e, s);
30
- });
31
- });
32
- }
33
- onUnsubscribe() {
34
- this.listeners.size || this.destroy();
35
- }
36
- destroy() {
37
- this.listeners = /* @__PURE__ */ new Set(), this.#t.forEach((e) => {
38
- e.destroy();
39
- });
40
- }
41
- setQueries(e, s) {
42
- if (this.#n = e, this.#i = s, process.env.NODE_ENV !== "production") {
43
- const t = e.map(
44
- (r) => this.#r.defaultQueryOptions(r).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.#t, r = this.#d(this.#n);
52
- this.#u = r, r.forEach(
53
- (o) => o.observer.setOptions(o.defaultedQueryOptions)
54
- );
55
- const n = r.map((o) => o.observer), i = n.map(
56
- (o) => o.getCurrentResult()
57
- ), a = n.some(
58
- (o, u) => o !== t[u]
59
- );
60
- t.length === n.length && !a || (this.#t = n, this.#e = i, this.hasListeners() && (_(t, n).forEach((o) => {
61
- o.destroy();
62
- }), _(n, t).forEach((o) => {
63
- o.subscribe((u) => {
64
- this.#h(o, u);
65
- });
66
- }), this.#p()));
67
- });
68
- }
69
- getCurrentResult() {
70
- return this.#e;
71
- }
72
- getQueries() {
73
- return this.#t.map((e) => e.getCurrentQuery());
74
- }
75
- getObservers() {
76
- return this.#t;
77
- }
78
- getOptimisticResult(e, s) {
79
- const t = this.#d(e), r = t.map(
80
- (n) => n.observer.getOptimisticResult(n.defaultedQueryOptions)
81
- );
82
- return [
83
- r,
84
- (n) => this.#c(n ?? r, s),
85
- () => this.#l(r, t)
86
- ];
87
- }
88
- #l(e, s) {
89
- return s.map((t, r) => {
90
- const n = e[r];
91
- return t.defaultedQueryOptions.notifyOnChangeProps ? n : t.observer.trackResult(n, (i) => {
92
- s.forEach((a) => {
93
- a.observer.trackProp(i);
94
- });
95
- });
96
- });
97
- }
98
- #c(e, s) {
99
- return s ? ((!this.#s || this.#e !== this.#a || s !== this.#o) && (this.#o = s, this.#a = this.#e, this.#s = H(
100
- this.#s,
101
- s(e)
102
- )), this.#s) : e;
103
- }
104
- #d(e) {
105
- const s = new Map(
106
- this.#t.map((r) => [r.options.queryHash, r])
107
- ), t = [];
108
- return e.forEach((r) => {
109
- const n = this.#r.defaultQueryOptions(r), i = s.get(n.queryHash);
110
- i ? t.push({
111
- defaultedQueryOptions: n,
112
- observer: i
113
- }) : t.push({
114
- defaultedQueryOptions: n,
115
- observer: new D(this.#r, n)
116
- });
117
- }), t;
118
- }
119
- #h(e, s) {
120
- const t = this.#t.indexOf(e);
121
- t !== -1 && (this.#e = he(this.#e, t, s), this.#p());
122
- }
123
- #p() {
124
- if (this.hasListeners()) {
125
- const e = this.#s, s = this.#l(this.#e, this.#u), t = this.#c(s, this.#i?.combine);
126
- e !== t && w.batch(() => {
127
- this.listeners.forEach((r) => {
128
- r(this.#e);
129
- });
130
- });
131
- }
132
- }
133
- };
134
- function ve({
135
- queries: e,
136
- ...s
137
- }, t) {
138
- const r = U(t), n = P(), i = K(), a = R.useMemo(
139
- () => e.map((l) => {
140
- const v = r.defaultQueryOptions(
141
- l
142
- );
143
- return v._optimisticResults = n ? "isRestoring" : "optimistic", v;
144
- }),
145
- [e, r, n]
146
- );
147
- a.forEach((l) => {
148
- z(l), W(l, i);
149
- }), j(i);
150
- const [o] = R.useState(
151
- () => new pe(
152
- r,
153
- a,
154
- s
155
- )
156
- ), [u, c, f] = o.getOptimisticResult(
157
- a,
158
- s.combine
159
- ), p = !n && s.subscribed !== !1;
160
- R.useSyncExternalStore(
161
- R.useCallback(
162
- (l) => p ? o.subscribe(w.batchCalls(l)) : J,
163
- [o, p]
164
- ),
165
- () => o.getCurrentResult(),
166
- () => o.getCurrentResult()
167
- ), R.useEffect(() => {
168
- o.setQueries(
169
- a,
170
- s
171
- );
172
- }, [a, s, o]);
173
- const E = u.some(
174
- (l, v) => T(a[v], l)
175
- ) ? u.flatMap((l, v) => {
176
- const h = a[v];
177
- if (h) {
178
- const O = new D(r, h);
179
- if (T(h, l))
180
- return Q(h, O, i);
181
- X(l, n) && Q(h, O, i);
182
- }
183
- return [];
184
- }) : [];
185
- if (E.length > 0)
186
- throw Promise.all(E);
187
- const m = u.find(
188
- (l, v) => {
189
- const h = a[v];
190
- return h && Y({
191
- result: l,
192
- errorResetBoundary: i,
193
- throwOnError: h.throwOnError,
194
- query: r.getQueryCache().get(h.queryHash),
195
- suspense: h.suspense
196
- });
197
- }
198
- );
199
- if (m?.error)
200
- throw m.error;
201
- return c(f());
202
- }
203
- const be = "normal", fe = "http://terminology.hl7.org/CodeSystem/referencerange-meaning", ge = "A", me = "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", ye = (e, s) => e?.date ? ie(e.date, s).formattedResult : s("DATE_ERROR_PARSE"), Oe = (e) => {
204
- if (!e.observationValue?.value)
205
- return "";
206
- const { value: s, unit: t } = e.observationValue;
207
- return t ? `${s} ${t}` : String(s);
208
- }, Re = (e) => {
209
- const s = e.display;
210
- if (!e.observationValue)
211
- return String(s);
212
- const { unit: t, referenceRange: r } = e.observationValue;
213
- if (!r)
214
- return String(s);
215
- const { low: n, high: i } = r;
216
- if (n && i) {
217
- const a = n.unit ? `${n.value} ${n.unit}` : t ? `${n.value} ${t}` : String(n.value), o = i.unit ? `${i.value} ${i.unit}` : t ? `${i.value} ${t}` : String(i.value);
218
- return `${s} (${a} - ${o})`;
219
- }
220
- if (n) {
221
- const a = n.unit ? `${n.value} ${n.unit}` : t ? `${n.value} ${t}` : String(n.value);
222
- return `${s} (>${a})`;
223
- }
224
- if (i) {
225
- const a = i.unit ? `${i.value} ${i.unit}` : t ? `${i.value} ${t}` : String(i.value);
226
- return `${s} (<${a})`;
227
- }
228
- return s;
229
- }, Ee = (e, s) => ({
230
- index: s,
231
- header: Re(e),
232
- value: Oe(e),
233
- provider: e.encounter?.provider
234
- }), $ = (e) => (typeof e == "string" ? e : e?.reference)?.split("/")?.pop();
235
- function Se(e) {
236
- return !e.interpretation || e.interpretation.length === 0 ? !1 : e.interpretation.some(
237
- (s) => s.coding?.some(
238
- (t) => t.system === me && t.code === ge
239
- )
240
- );
241
- }
242
- function we(e) {
243
- const {
244
- valueQuantity: s,
245
- valueCodeableConcept: t,
246
- valueString: r,
247
- valueBoolean: n,
248
- valueInteger: i,
249
- referenceRange: a
250
- } = e, o = Se(e);
251
- if (s) {
252
- const u = {
253
- value: s.value ?? "",
254
- unit: s.unit,
255
- type: "quantity",
256
- isAbnormal: o
257
- };
258
- if (a && a.length > 0) {
259
- const c = a.find(
260
- (f) => f.type?.coding?.some(
261
- (p) => p.system === fe && p.code === be
262
- )
263
- );
264
- c && (c.low || c.high) && (u.referenceRange = {
265
- low: c.low ? {
266
- value: c.low.value,
267
- unit: c.low.unit
268
- } : void 0,
269
- high: c.high ? {
270
- value: c.high.value,
271
- unit: c.high.unit
272
- } : void 0
273
- });
274
- }
275
- return u;
276
- }
277
- if (t)
278
- return {
279
- value: t.text ?? t.coding[0].display,
280
- type: "codeable",
281
- isAbnormal: o
282
- };
283
- if (r)
284
- return {
285
- value: r,
286
- type: "string",
287
- isAbnormal: o
288
- };
289
- if (n !== void 0)
290
- return {
291
- value: n,
292
- type: "boolean",
293
- isAbnormal: o
294
- };
295
- if (i !== void 0)
296
- return {
297
- value: i,
298
- type: "integer",
299
- isAbnormal: o
300
- };
301
- }
302
- function $e(e, s) {
303
- const t = s.get(e);
304
- if (t)
305
- return {
306
- id: t.id ?? e,
307
- type: t.type?.[0]?.coding?.[0]?.display ?? "Unknown",
308
- date: t.period?.start ?? "",
309
- provider: t.participant?.[0]?.individual?.display,
310
- location: t.location?.[0]?.location?.display
311
- };
312
- }
313
- function V(e, s, t) {
314
- const r = $(e.encounter), n = (e.hasMember ?? []).map((i) => $(i)).map((i) => i ? t.get(i) : void 0).filter((i) => !!i).map(
315
- (i) => V(i, s, t)
316
- );
317
- return {
318
- id: e.id,
319
- display: e.code?.text ?? e.code?.coding?.[0]?.display ?? "",
320
- observationValue: we(e),
321
- effectiveDateTime: e.effectiveDateTime,
322
- issued: e.issued,
323
- encounter: r ? $e(r, s) : void 0,
324
- members: n.length > 0 ? n : void 0
325
- };
326
- }
327
- function Te(e) {
328
- const s = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
329
- e.entry?.forEach(({ resource: a }) => {
330
- a?.id && (a.resourceType === "Encounter" ? s.set(a.id, a) : a.resourceType === "Observation" && (t.set(a.id, a), a.hasMember?.forEach((o) => {
331
- const u = $(o);
332
- u && r.add(u);
333
- })));
334
- });
335
- const n = [], i = [];
336
- return t.forEach((a, o) => {
337
- if (r.has(o)) return;
338
- const u = V(
339
- a,
340
- s,
341
- t
342
- );
343
- u.members?.length ? i.push({ ...u, children: u.members }) : n.push(u);
344
- }), { observations: n, groupedObservations: i };
345
- }
346
- function Qe(e) {
347
- const s = /* @__PURE__ */ new Map();
348
- return e.observations.forEach((t) => {
349
- if (!t.encounter?.id) return;
350
- const r = t.encounter.id;
351
- s.has(r) || s.set(r, {
352
- observations: [],
353
- groupedObservations: []
354
- }), s.get(r).observations.push(t);
355
- }), e.groupedObservations.forEach((t) => {
356
- if (!t.encounter?.id) return;
357
- const r = t.encounter.id;
358
- s.has(r) || s.set(r, {
359
- observations: [],
360
- groupedObservations: []
361
- }), s.get(r).groupedObservations.push(t);
362
- }), Array.from(s.entries()).map(([t, r]) => {
363
- const n = r.observations[0]?.encounter ?? r.groupedObservations[0]?.encounter;
364
- return {
365
- encounterId: t,
366
- encounterDetails: n,
367
- observations: r.observations,
368
- groupedObservations: r.groupedObservations
369
- };
370
- });
371
- }
372
- function Ce(e) {
373
- return [...e].sort((s, t) => {
374
- const r = s.encounterDetails?.date, n = t.encounterDetails?.date;
375
- return !r && !n ? 0 : r ? n ? new Date(n).getTime() - new Date(r).getTime() : -1 : 1;
376
- });
377
- }
378
- const q = (e, s, t) => {
379
- const r = Ee(e, s), n = r.value, i = oe(n);
380
- let a = n;
381
- i === "Image" && (a = /* @__PURE__ */ b(ue, { imageSrc: n, alt: n, id: `${n}-img` })), i === "Video" && (a = /* @__PURE__ */ b(le, { id: `${n}-video`, videoSrc: n }));
382
- const o = t("OBSERVATIONS_RECORDED_BY", {
383
- provider: r.provider
384
- }), u = e.observationValue?.isAbnormal ? `abnormal-obs-${e.id}` : `obs-${e.id}`;
385
- return /* @__PURE__ */ b(
386
- ae,
387
- {
388
- header: r.header,
389
- value: a,
390
- info: o,
391
- id: u,
392
- testId: `${u}-test-id`,
393
- ariaLabel: `${u}-aria-label`
394
- },
395
- `obs-${e.id}`
396
- );
397
- }, _e = (e, s, t) => /* @__PURE__ */ b(
398
- M,
399
- {
400
- title: e.display,
401
- id: `grouped-obs-${e.id}`,
402
- open: t,
403
- children: e.children.map(
404
- (r, n) => q(r, n, s)
405
- )
406
- },
407
- `grouped-obs-${e.id}`
408
- ), Ae = ({
409
- groupedData: e
410
- }) => {
411
- const { t: s } = N(), t = (r, n) => {
412
- const i = ye(r.encounterDetails, s);
413
- return /* @__PURE__ */ I(
414
- M,
415
- {
416
- title: i,
417
- id: `encounter-${r.encounterId}`,
418
- open: n,
419
- children: [
420
- r.observations.map(
421
- (a, o) => q(a, o, s)
422
- ),
423
- r.groupedObservations.map(
424
- (a) => _e(a, s, n)
425
- )
426
- ]
427
- },
428
- `encounter-${r.encounterId}`
429
- );
430
- };
431
- return /* @__PURE__ */ b(
432
- "div",
433
- {
434
- id: "obs-by-encounter",
435
- "data-testid": "obs-by-encounter-test-id",
436
- "aria-label": "obs-by-encounter-aria-label",
437
- children: e.map(
438
- (r, n) => t(r, n === 0)
439
- )
440
- }
441
- );
442
- }, Ie = "_observations_kfbhq_1", De = "_title_kfbhq_12", A = {
443
- observations: Ie,
444
- title: De
445
- }, Ne = (e) => ["conceptUuid", e], Me = (e, s) => ["observations", e, ...s], xe = ({ config: e }) => {
446
- const s = e, { conceptNames: t = [], conceptUuid: r = [] } = s, n = de(/* @__PURE__ */ new Set()), i = Z(), { addNotification: a } = ee(), { t: o } = N(), u = ve({
447
- queries: t.map((d) => ({
448
- queryKey: Ne(d),
449
- queryFn: () => te(d),
450
- enabled: !!d
451
- }))
452
- });
453
- C(() => {
454
- u.forEach((d, y) => {
455
- if (d.isError && !n.current.has(y)) {
456
- const G = t[y];
457
- a({
458
- title: o("ERROR_DEFAULT_TITLE"),
459
- message: o("ERROR_FETCHING_CONCEPT", { conceptName: G }),
460
- type: "error"
461
- }), n.current.add(y);
462
- } else d.isError || n.current.delete(y);
463
- });
464
- }, [u, t]);
465
- const c = S(() => u.map((d) => d.data?.uuid).filter((d) => !!d), [u]), f = S(() => [.../* @__PURE__ */ new Set([...c, ...r])], [c, r]), p = S(() => t.length === 0 ? !0 : u.every((d) => !d.isLoading), [u, t.length]), {
466
- data: g,
467
- isLoading: E,
468
- isError: m
469
- } = se({
470
- queryKey: Me(i, f),
471
- queryFn: () => ce(i, f),
472
- enabled: !!i && f.length > 0 && p
473
- });
474
- C(() => {
475
- m && a({
476
- title: o("ERROR_DEFAULT_TITLE"),
477
- message: o("ERROR_FETCHING_OBSERVATIONS"),
478
- type: "error"
479
- });
480
- }, [m]);
481
- const l = S(() => {
482
- if (!g) return [];
483
- const d = Te(g), y = Qe(d);
484
- return Ce(y);
485
- }, [g]), v = [
486
- { key: "name", header: "name" },
487
- { key: "value", header: "value" },
488
- { key: "form", header: "form" }
489
- ], h = E || !p, O = m && p, k = (!g || g.entry?.length === 0 || f.length === 0) && p, x = O ? o("ERROR_FETCHING_OBSERVATIONS") : null, B = k ? o("NO_OBSERVATIONS_FOUND") : void 0, L = l.length > 0 && !h && !O;
490
- return /* @__PURE__ */ I(
491
- "div",
492
- {
493
- id: "observations",
494
- "data-testid": "observations-test-id",
495
- "aria-label": "observations-aria-label",
496
- className: A.observations,
497
- children: [
498
- /* @__PURE__ */ b(
499
- re,
500
- {
501
- id: "observations-title",
502
- testId: "observations-title-test-id",
503
- title: o(s.titleTranslationKey),
504
- className: A.title,
505
- children: /* @__PURE__ */ b("p", { children: o(s.titleTranslationKey) })
506
- }
507
- ),
508
- L ? /* @__PURE__ */ b(Ae, { groupedData: l }) : /* @__PURE__ */ b(
509
- ne,
510
- {
511
- headers: v,
512
- rows: [],
513
- ariaLabel: o("OBSERVATIONS"),
514
- loading: h,
515
- errorStateMessage: x,
516
- emptyStateMessage: B
517
- }
518
- )
519
- ]
520
- }
521
- );
522
- };
523
- export {
524
- Ne as conceptUuidQueryKeys,
525
- xe as default,
526
- Me as observationsQueryKeys
527
- };