@bahmni/registration-app 0.0.1-dev.145 → 0.0.1-dev.148

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,6 +1,6 @@
1
- import { ap as s, an as p, ao as E } from "./index-Bz9hJQp5.js";
1
+ import { at as e, ar as r, as as t } from "./index-BA_3C-qM.js";
2
2
  export {
3
- s as IDENTIFIER_TYPES_QUERY_KEY,
4
- p as RegistrationApp,
5
- E as useIdentifierTypes
3
+ e as IDENTIFIER_TYPES_QUERY_KEY,
4
+ r as RegistrationApp,
5
+ t as useIdentifierTypes
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bahmni/registration-app",
3
- "version": "0.0.1-dev.145",
3
+ "version": "0.0.1-dev.148",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -1,338 +0,0 @@
1
- import { jsxs as _, jsx as b } from "react/jsx-runtime";
2
- import { V as F, b as U, u as I, X as k, Q, c as x, $ as G, G as K, C as w, J as H, f as X, T as j, O as J } from "./index-Bz9hJQp5.js";
3
- import { useQueries as P, useQuery as Y } from "@tanstack/react-query";
4
- import { useRef as Z, useEffect as S, useMemo as h } from "react";
5
- const z = "normal", W = "http://terminology.hl7.org/CodeSystem/referencerange-meaning", ee = "A", te = "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", ne = (e, n) => e?.date ? K(e.date, n).formattedResult : n("DATE_ERROR_PARSE"), re = (e) => {
6
- if (!e.observationValue?.value)
7
- return "";
8
- const { value: n, unit: t } = e.observationValue;
9
- return t ? `${n} ${t}` : String(n);
10
- }, oe = (e) => {
11
- const n = e.display;
12
- if (!e.observationValue)
13
- return String(n);
14
- const { unit: t, referenceRange: a } = e.observationValue;
15
- if (!a)
16
- return String(n);
17
- const { low: r, high: o } = a;
18
- if (r && o) {
19
- const i = r.unit ? `${r.value} ${r.unit}` : t ? `${r.value} ${t}` : String(r.value), s = o.unit ? `${o.value} ${o.unit}` : t ? `${o.value} ${t}` : String(o.value);
20
- return `${n} (${i} - ${s})`;
21
- }
22
- if (r) {
23
- const i = r.unit ? `${r.value} ${r.unit}` : t ? `${r.value} ${t}` : String(r.value);
24
- return `${n} (>${i})`;
25
- }
26
- if (o) {
27
- const i = o.unit ? `${o.value} ${o.unit}` : t ? `${o.value} ${t}` : String(o.value);
28
- return `${n} (<${i})`;
29
- }
30
- return n;
31
- }, ae = (e, n) => ({
32
- index: n,
33
- header: oe(e),
34
- value: re(e),
35
- provider: e.encounter?.provider
36
- }), $ = (e) => (typeof e == "string" ? e : e?.reference)?.split("/")?.pop();
37
- function ie(e) {
38
- return !e.interpretation || e.interpretation.length === 0 ? !1 : e.interpretation.some(
39
- (n) => n.coding?.some(
40
- (t) => t.system === te && t.code === ee
41
- )
42
- );
43
- }
44
- function se(e) {
45
- const {
46
- valueQuantity: n,
47
- valueCodeableConcept: t,
48
- valueString: a,
49
- valueBoolean: r,
50
- valueInteger: o,
51
- referenceRange: i
52
- } = e, s = ie(e);
53
- if (n) {
54
- const u = {
55
- value: n.value ?? "",
56
- unit: n.unit,
57
- type: "quantity",
58
- isAbnormal: s
59
- };
60
- if (i && i.length > 0) {
61
- const l = i.find(
62
- (v) => v.type?.coding?.some(
63
- (c) => c.system === W && c.code === z
64
- )
65
- );
66
- l && (l.low || l.high) && (u.referenceRange = {
67
- low: l.low ? {
68
- value: l.low.value,
69
- unit: l.low.unit
70
- } : void 0,
71
- high: l.high ? {
72
- value: l.high.value,
73
- unit: l.high.unit
74
- } : void 0
75
- });
76
- }
77
- return u;
78
- }
79
- if (t)
80
- return {
81
- value: t.text ?? t.coding[0].display,
82
- type: "codeable",
83
- isAbnormal: s
84
- };
85
- if (a)
86
- return {
87
- value: a,
88
- type: "string",
89
- isAbnormal: s
90
- };
91
- if (r !== void 0)
92
- return {
93
- value: r,
94
- type: "boolean",
95
- isAbnormal: s
96
- };
97
- if (o !== void 0)
98
- return {
99
- value: o,
100
- type: "integer",
101
- isAbnormal: s
102
- };
103
- }
104
- function ue(e, n) {
105
- const t = n.get(e);
106
- if (t)
107
- return {
108
- id: t.id ?? e,
109
- type: t.type?.[0]?.coding?.[0]?.display ?? "Unknown",
110
- date: t.period?.start ?? "",
111
- provider: t.participant?.[0]?.individual?.display,
112
- location: t.location?.[0]?.location?.display
113
- };
114
- }
115
- function A(e, n, t) {
116
- const a = $(e.encounter), r = (e.hasMember ?? []).map((o) => $(o)).map((o) => o ? t.get(o) : void 0).filter((o) => !!o).map(
117
- (o) => A(o, n, t)
118
- );
119
- return {
120
- id: e.id,
121
- display: e.code?.text ?? e.code?.coding?.[0]?.display ?? "",
122
- observationValue: se(e),
123
- effectiveDateTime: e.effectiveDateTime,
124
- issued: e.issued,
125
- encounter: a ? ue(a, n) : void 0,
126
- members: r.length > 0 ? r : void 0
127
- };
128
- }
129
- function le(e) {
130
- const n = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set();
131
- e.entry?.forEach(({ resource: i }) => {
132
- i?.id && (i.resourceType === "Encounter" ? n.set(i.id, i) : i.resourceType === "Observation" && (t.set(i.id, i), i.hasMember?.forEach((s) => {
133
- const u = $(s);
134
- u && a.add(u);
135
- })));
136
- });
137
- const r = [], o = [];
138
- return t.forEach((i, s) => {
139
- if (a.has(s)) return;
140
- const u = A(
141
- i,
142
- n,
143
- t
144
- );
145
- u.members?.length ? o.push({ ...u, children: u.members }) : r.push(u);
146
- }), { observations: r, groupedObservations: o };
147
- }
148
- function de(e) {
149
- const n = /* @__PURE__ */ new Map();
150
- return e.observations.forEach((t) => {
151
- if (!t.encounter?.id) return;
152
- const a = t.encounter.id;
153
- n.has(a) || n.set(a, {
154
- observations: [],
155
- groupedObservations: []
156
- }), n.get(a).observations.push(t);
157
- }), e.groupedObservations.forEach((t) => {
158
- if (!t.encounter?.id) return;
159
- const a = t.encounter.id;
160
- n.has(a) || n.set(a, {
161
- observations: [],
162
- groupedObservations: []
163
- }), n.get(a).groupedObservations.push(t);
164
- }), Array.from(n.entries()).map(([t, a]) => {
165
- const r = a.observations[0]?.encounter ?? a.groupedObservations[0]?.encounter;
166
- return {
167
- encounterId: t,
168
- encounterDetails: r,
169
- observations: a.observations,
170
- groupedObservations: a.groupedObservations
171
- };
172
- });
173
- }
174
- function ce(e) {
175
- return [...e].sort((n, t) => {
176
- const a = n.encounterDetails?.date, r = t.encounterDetails?.date;
177
- return !a && !r ? 0 : a ? r ? new Date(r).getTime() - new Date(a).getTime() : -1 : 1;
178
- });
179
- }
180
- const D = (e, n, t, a, r) => {
181
- const o = ae(e, n), i = o.value, s = H(i);
182
- let u = i;
183
- s === "Image" && (u = /* @__PURE__ */ b(j, { imageSrc: i, alt: i, id: `${i}-img` })), s === "Video" && (u = /* @__PURE__ */ b(J, { id: `${i}-video`, videoSrc: i }));
184
- const l = r("OBSERVATIONS_RECORDED_BY", {
185
- provider: o.provider
186
- }), v = e.display, c = e.observationValue?.isAbnormal ? "abnormal-obs" : "obs", p = a ? `${a}-${c}-${v}-${t}-${n}` : `${c}-${v}-${t}-${n}`;
187
- return /* @__PURE__ */ b(
188
- X,
189
- {
190
- header: o.header,
191
- value: u,
192
- info: l,
193
- id: p,
194
- testId: p,
195
- ariaLabel: p
196
- },
197
- `obs-${e.id}`
198
- );
199
- }, ve = (e, n, t, a, r, o) => /* @__PURE__ */ b(
200
- w,
201
- {
202
- title: e.display,
203
- id: `grouped-obs-${e.display}-${a}`,
204
- open: t,
205
- children: e.children.map(
206
- (i, s) => D(i, s, r, o, n)
207
- )
208
- },
209
- `grouped-obs-${e.id}`
210
- ), pe = ({
211
- groupedData: e,
212
- title: n = ""
213
- }) => {
214
- const { t } = I(), a = (r, o, i) => {
215
- const s = ne(r.encounterDetails, t);
216
- return /* @__PURE__ */ _(
217
- w,
218
- {
219
- title: s,
220
- id: `encounter-${r.encounterId}`,
221
- open: o,
222
- children: [
223
- r.observations.map(
224
- (u, l) => D(u, l, i, n, t)
225
- ),
226
- r.groupedObservations.map(
227
- (u, l) => ve(
228
- u,
229
- t,
230
- o,
231
- l,
232
- i,
233
- n
234
- )
235
- )
236
- ]
237
- },
238
- `encounter-${r.encounterId}`
239
- );
240
- };
241
- return /* @__PURE__ */ b(
242
- "div",
243
- {
244
- id: "obs-by-encounter",
245
- "data-testid": "obs-by-encounter-test-id",
246
- "aria-label": "obs-by-encounter-aria-label",
247
- children: e.map(
248
- (r, o) => a(r, o === 0, o)
249
- )
250
- }
251
- );
252
- }, be = "_observations_kfbhq_1", ge = "_title_kfbhq_12", T = {
253
- observations: be,
254
- title: ge
255
- }, me = (e) => ["conceptUuid", e], fe = (e, n) => ["observations", e, ...n], Oe = ({ config: e }) => {
256
- const n = e, { conceptNames: t = [], conceptUuid: a = [] } = n, r = Z(/* @__PURE__ */ new Set()), o = F(), { addNotification: i } = U(), { t: s } = I(), u = P({
257
- queries: t.map((d) => ({
258
- queryKey: me(d),
259
- queryFn: () => k(d),
260
- enabled: !!d
261
- }))
262
- });
263
- S(() => {
264
- u.forEach((d, g) => {
265
- if (d.isError && !r.current.has(g)) {
266
- const B = t[g];
267
- i({
268
- title: s("ERROR_DEFAULT_TITLE"),
269
- message: s("ERROR_FETCHING_CONCEPT", { conceptName: B }),
270
- type: "error"
271
- }), r.current.add(g);
272
- } else d.isError || r.current.delete(g);
273
- });
274
- }, [u, t]);
275
- const l = h(() => u.map((d) => d.data?.uuid).filter((d) => !!d), [u]), v = h(() => [.../* @__PURE__ */ new Set([...l, ...a])], [l, a]), c = h(() => t.length === 0 ? !0 : u.every((d) => !d.isLoading), [u, t.length]), {
276
- data: p,
277
- isLoading: N,
278
- isError: y
279
- } = Y({
280
- queryKey: fe(o, v),
281
- queryFn: () => Q(o, v),
282
- enabled: !!o && v.length > 0 && c
283
- });
284
- S(() => {
285
- y && i({
286
- title: s("ERROR_DEFAULT_TITLE"),
287
- message: s("ERROR_FETCHING_OBSERVATIONS"),
288
- type: "error"
289
- });
290
- }, [y]);
291
- const E = h(() => {
292
- if (!p) return [];
293
- const d = le(p), g = de(d);
294
- return ce(g);
295
- }, [p]), V = [
296
- { key: "name", header: "name" },
297
- { key: "value", header: "value" },
298
- { key: "form", header: "form" }
299
- ], O = N || !c, R = y && c, C = (!p || p.entry?.length === 0 || v.length === 0) && c, L = R ? s("ERROR_FETCHING_OBSERVATIONS") : null, M = C ? s("NO_OBSERVATIONS_FOUND") : void 0, q = E.length > 0 && !O && !R, f = n.titleTranslationKey, m = f ? s(f) : "";
300
- return /* @__PURE__ */ _(
301
- "div",
302
- {
303
- id: "observations",
304
- "data-testid": f ? `observations-${m}` : "observations",
305
- "aria-label": "observations-aria-label",
306
- className: T.observations,
307
- children: [
308
- /* @__PURE__ */ b(
309
- x,
310
- {
311
- id: "observations-title",
312
- testId: f ? `observations-title-${m}` : "observations-title",
313
- title: m,
314
- className: T.title,
315
- children: /* @__PURE__ */ b("p", { children: m })
316
- }
317
- ),
318
- q ? /* @__PURE__ */ b(pe, { groupedData: E, title: m }) : /* @__PURE__ */ b(
319
- G,
320
- {
321
- headers: V,
322
- rows: [],
323
- ariaLabel: s("OBSERVATIONS"),
324
- loading: O,
325
- errorStateMessage: L,
326
- emptyStateMessage: M,
327
- dataTestId: "observations-table"
328
- }
329
- )
330
- ]
331
- }
332
- );
333
- };
334
- export {
335
- me as conceptUuidQueryKeys,
336
- Oe as default,
337
- fe as observationsQueryKeys
338
- };