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