@bahmni/clinical-app 0.0.1-dev.424 → 0.0.1-dev.426

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 { cT as c } from "./index-Bue3rusE.js";
1
+ import { cR as c } from "./index-DtI3QOMb.js";
2
2
  export {
3
3
  c as ClinicalApp
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bahmni/clinical-app",
3
- "version": "0.0.1-dev.424",
3
+ "version": "0.0.1-dev.426",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -1,272 +0,0 @@
1
- import { jsx as n, jsxs as P, Fragment as ge } from "react/jsx-runtime";
2
- import { u as he, g as Te, s as Ne, e as Oe, v as be, V as Ie, X as Ae, A as Ee, h as _e, m as Fe, a as Me, b as ve, M as Be, S as $, w as Se, _ as K, c as j, q as Ce, Y as z, P as De, F as Le, p as Ue, d as Re, Z as qe } from "./index-Bue3rusE.js";
3
- import { useQueryClient as we, useQuery as N } from "@tanstack/react-query";
4
- import { useState as Q, useMemo as i, useCallback as d } from "react";
5
- const Ve = "FormsTable-module_formsTableBody__SvGha", ke = "FormsTable-module_modalHeading__wnTmA", He = "FormsTable-module_customAccordianItem__isszs", O = {
6
- formsTableBody: Ve,
7
- modalHeading: ke,
8
- customAccordianItem: He
9
- }, xe = "startConsultation", je = ({
10
- episodeOfCareUuids: M,
11
- encounterUuids: l,
12
- config: Z,
13
- disableActions: X = !1,
14
- activeEncounterUuid: y = null
15
- }) => {
16
- const { t } = he(), m = Te(), [p, v] = Q(!1), [o, B] = Q(null), {
17
- numberOfVisits: Y,
18
- hideThumbnail: J = !1,
19
- forms: g
20
- } = Z ?? {}, W = Ne(
21
- qe.EDIT_OBSERVATIONS
22
- ), { userPrivileges: h } = Oe(), b = W && !X && !!y, S = be(
23
- M,
24
- l
25
- ), ee = we(), {
26
- data: C = [],
27
- isLoading: D,
28
- isError: L,
29
- error: re,
30
- refetch: ae
31
- } = N({
32
- queryKey: ["forms", m, M],
33
- queryFn: () => Ie(m, void 0, Y),
34
- enabled: !!m && !S
35
- }), U = i(() => {
36
- let e = C;
37
- return l && l.length > 0 && (e = e.filter(
38
- (r) => l.includes(r.encounterUuid)
39
- )), Array.isArray(g) && g.length > 0 && (e = e.filter(
40
- (r) => g.some((a) => a.toLowerCase() === r.formName.toLowerCase())
41
- )), e;
42
- }, [C, l, g]), { data: T = [] } = N({
43
- queryKey: ["observationForms"],
44
- queryFn: () => Ae()
45
- }), R = d(
46
- (e) => {
47
- const r = T.find((s) => s.name === e);
48
- if (!r?.privileges || r.privileges.length === 0) return !0;
49
- if (!h || h.length === 0) return !1;
50
- const a = new Set(h.map((s) => s.name));
51
- return r.privileges.some(
52
- (s) => a.has(s.privilegeName) && s.editable
53
- );
54
- },
55
- [T, h]
56
- ), u = d(
57
- (e) => !y || e.encounterUuid !== y ? !1 : R(e.formName),
58
- [y, R]
59
- ), q = d(
60
- (e) => T.find((r) => r.name === e)?.uuid,
61
- [T]
62
- ), I = i(() => {
63
- if (o)
64
- return q(o.formName);
65
- }, [o, q]), {
66
- data: w,
67
- isLoading: oe,
68
- isError: te,
69
- error: A
70
- } = N({
71
- queryKey: ["formMetadata", I],
72
- queryFn: () => Ee(I),
73
- enabled: !!I && p
74
- }), {
75
- data: E,
76
- isLoading: se,
77
- isError: ne,
78
- error: _
79
- } = N({
80
- queryKey: ["formsEncounterFHIR", o?.encounterUuid],
81
- queryFn: () => _e(o.encounterUuid),
82
- enabled: !!o?.encounterUuid && p
83
- });
84
- Fe(
85
- (e) => {
86
- e.patientUUID === m && (ae(), ee.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
87
- },
88
- [m]
89
- );
90
- const ie = i(() => !E?.entry || !o?.formName ? [] : E.entry.filter((e) => e.resource?.resourceType === "Observation").map((e) => e.resource).filter((e) => Me(e) ? ve(e)?.toLowerCase() === o.formName.toLowerCase() : !0), [E, o?.formName]), { controlOrder: de, sectionMap: le, conceptDatatypeMap: me } = i(
91
- () => Be(w?.schema),
92
- [w]
93
- ), ue = i(() => {
94
- if (A)
95
- return $(A).message;
96
- if (_)
97
- return $(_).message;
98
- }, [A, _]), c = i(
99
- () => [
100
- { key: "recordedOn", header: t("RECORDED_ON") },
101
- { key: "recordedBy", header: t("RECORDED_BY") }
102
- ],
103
- [t]
104
- ), V = i(
105
- () => [...c, { key: "actions", header: t("ACTIONS") }],
106
- [c, t]
107
- ), ce = d(
108
- (e) => b && e.some((r) => u(r)) ? V : c,
109
- [b, u, V, c]
110
- ), fe = c, ye = i(
111
- () => [
112
- { key: "recordedOn", sortable: !0 },
113
- { key: "recordedBy", sortable: !0 }
114
- ],
115
- []
116
- ), k = i(() => {
117
- const e = U.reduce(
118
- (r, a) => {
119
- const s = a.formName;
120
- r[s] ??= [];
121
- const f = a.providers.map((pe) => pe.providerName).filter(Boolean).join(", ");
122
- return r[s].push({
123
- id: a.encounterUuid,
124
- formName: a.formName,
125
- recordedOn: Se(a.encounterDateTime, t, !0).formattedResult,
126
- recordedBy: f ?? "--",
127
- encounterDateTime: a.encounterDateTime,
128
- encounterUuid: a.encounterUuid
129
- }), r;
130
- },
131
- {}
132
- );
133
- return Object.entries(e).map(
134
- ([r, a]) => ({
135
- formName: r,
136
- records: a.sort(
137
- (s, f) => f.encounterDateTime - s.encounterDateTime
138
- )
139
- })
140
- ).sort((r, a) => r.formName.localeCompare(a.formName));
141
- }, [U, t]), H = d((e) => {
142
- B(e), v(!0);
143
- }, []), x = d(() => {
144
- v(!1), B(null);
145
- }, []), F = d((e) => {
146
- globalThis.dispatchEvent(
147
- new CustomEvent(xe, {
148
- detail: {
149
- editOnly: "observationForms",
150
- editTitle: "EDIT_OBSERVATION_FORM_TITLE",
151
- sourceEncounterUuid: e.encounterUuid,
152
- formName: e.formName,
153
- directFormMode: !0
154
- }
155
- })
156
- );
157
- }, []), G = d(
158
- (e, r) => {
159
- switch (r) {
160
- case "recordedOn":
161
- return /* @__PURE__ */ n(Ce, { onClick: () => H(e), children: e.recordedOn });
162
- case "recordedBy":
163
- return e.recordedBy;
164
- case "actions":
165
- return u(e) ? /* @__PURE__ */ n(
166
- K,
167
- {
168
- label: t("EDIT_OBSERVATION_FORM"),
169
- kind: "ghost",
170
- size: "sm",
171
- testId: `edit-form-${e.encounterUuid}`,
172
- onClick: () => F(e),
173
- children: /* @__PURE__ */ n(j, {})
174
- }
175
- ) : null;
176
- default:
177
- return null;
178
- }
179
- },
180
- [H, F, u, t]
181
- );
182
- return /* @__PURE__ */ P(ge, { children: [
183
- /* @__PURE__ */ n("div", { id: "forms-table", "data-testid": "forms-table", children: D || L || k.length === 0 || S ? /* @__PURE__ */ n(
184
- z,
185
- {
186
- headers: fe,
187
- ariaLabel: t("FORMS_HEADING"),
188
- rows: [],
189
- loading: D,
190
- errorStateMessage: L ? re?.message : void 0,
191
- emptyStateMessage: t("FORMS_UNAVAILABLE"),
192
- renderCell: G,
193
- className: O.formsTableBody,
194
- dataTestId: "forms-table"
195
- }
196
- ) : /* @__PURE__ */ n(De, { align: "start", children: k.map((e, r) => {
197
- const { formName: a, records: s } = e, f = ce(s);
198
- return /* @__PURE__ */ n(
199
- Le,
200
- {
201
- title: a,
202
- className: O.customAccordianItem,
203
- testId: `accordian-title-${a}`,
204
- open: r === 0,
205
- children: /* @__PURE__ */ n(
206
- z,
207
- {
208
- headers: f,
209
- ariaLabel: t("FORMS_HEADING"),
210
- rows: s,
211
- loading: !1,
212
- errorStateMessage: "",
213
- sortable: ye,
214
- emptyStateMessage: t("FORMS_UNAVAILABLE"),
215
- renderCell: G,
216
- className: O.formsTableBody,
217
- dataTestId: `forms-table-${a}`
218
- }
219
- )
220
- },
221
- a
222
- );
223
- }) }) }),
224
- p && o && /* @__PURE__ */ n(
225
- Ue,
226
- {
227
- id: "modalIdForActionAreaLayout",
228
- portalId: "main-display-area",
229
- open: p,
230
- onRequestClose: x,
231
- modalHeading: /* @__PURE__ */ P("div", { className: O.modalHeading, children: [
232
- /* @__PURE__ */ n("span", { children: o.formName }),
233
- b && u(o) && /* @__PURE__ */ n(
234
- K,
235
- {
236
- label: t("EDIT_OBSERVATION_FORM"),
237
- kind: "ghost",
238
- size: "sm",
239
- testId: `edit-form-modal-${o.encounterUuid}`,
240
- onClick: () => {
241
- x(), F(o);
242
- },
243
- children: /* @__PURE__ */ n(j, {})
244
- }
245
- )
246
- ] }),
247
- modalLabel: `${o.recordedOn} | ${o.recordedBy}`,
248
- passiveModal: !0,
249
- size: "md",
250
- testId: "form-details-modal",
251
- children: /* @__PURE__ */ n(
252
- Re,
253
- {
254
- observations: ie,
255
- isLoading: oe || se,
256
- isError: te || ne,
257
- errorMessage: ue,
258
- emptyStateMessage: t("NO_FORM_DATA_AVAILABLE"),
259
- testIdPrefix: o.formName,
260
- hideThumbnail: J,
261
- controlOrder: de,
262
- sectionMap: le,
263
- conceptDatatypeMap: me
264
- }
265
- )
266
- }
267
- )
268
- ] });
269
- };
270
- export {
271
- je as default
272
- };
@@ -1,246 +0,0 @@
1
- import { jsxs as I, jsx as n } from "react/jsx-runtime";
2
- import { g as M, z as j, u as B, f as x, v as G, y as H, E as Y, m as J, i as P, L as W, T as X, O as Z, j as ee, Y as ae, k as se, Q as U, C as re, B as te, w as ie, D as oe, l as ne, R as de, n as le } from "./index-Bue3rusE.js";
3
- import { useQueries as ue, useQuery as ce } from "@tanstack/react-query";
4
- import { useRef as me, useEffect as A, useMemo as g } from "react";
5
- const pe = "Observations-module_observations__RKSyo", be = "Observations-module_title__TJL3z", ve = "Observations-module_wrapper__muk2L", he = "Observations-module_secondary__14nuS", O = {
6
- observations: pe,
7
- title: be,
8
- wrapper: ve,
9
- secondary: he
10
- }, V = (s, l, o, d, c, r) => {
11
- const t = re(s, l, c), e = t.value, m = te(e);
12
- let i = e;
13
- m === "Image" && (i = /* @__PURE__ */ n(
14
- ne,
15
- {
16
- imageSrc: e,
17
- alt: e,
18
- id: `${e}-img`,
19
- hideThumbnail: r
20
- }
21
- )), m === "Video" && (i = /* @__PURE__ */ n(
22
- de,
23
- {
24
- id: `${e}-video`,
25
- videoSrc: e,
26
- hideThumbnail: r
27
- }
28
- )), m === "PDF" && (i = /* @__PURE__ */ n(le, { id: `${e}-pdf`, src: e }));
29
- const p = /* @__PURE__ */ I("div", { className: O.wrapper, children: [
30
- /* @__PURE__ */ n("span", { children: t.header.display }),
31
- t.header.referenceRange && /* @__PURE__ */ n("span", { className: O.secondary, children: t.header.referenceRange })
32
- ] }), u = c("OBSERVATIONS_RECORDED_BY", {
33
- provider: t.provider
34
- }), b = s.effectiveDateTime ? ie(s.effectiveDateTime, c, !0).formattedResult : void 0, f = /* @__PURE__ */ I("div", { className: O.wrapper, children: [
35
- /* @__PURE__ */ n("span", { children: u }),
36
- b && /* @__PURE__ */ n("span", { className: O.secondary, children: b })
37
- ] }), v = s.display, h = s.observationValue?.isAbnormal ? "abnormal-obs" : "obs", R = d ? `${d}-${h}-${v}-${o}-${l}` : `${h}-${v}-${o}-${l}`;
38
- return /* @__PURE__ */ n(
39
- oe,
40
- {
41
- header: p,
42
- value: i,
43
- info: f,
44
- id: R,
45
- testId: R,
46
- ariaLabel: R
47
- },
48
- `obs-${s.id}`
49
- );
50
- }, ye = (s, l, o, d, c, r, t) => /* @__PURE__ */ n(
51
- U,
52
- {
53
- title: s.display,
54
- id: `grouped-obs-${s.display}-${d}`,
55
- open: o,
56
- children: s.members?.map(
57
- (e, m) => V(
58
- e,
59
- m,
60
- c,
61
- r,
62
- l,
63
- t
64
- )
65
- )
66
- },
67
- `grouped-obs-${s.id}`
68
- ), Oe = ({
69
- groupedData: s,
70
- title: l = "",
71
- hideThumbnail: o
72
- }) => {
73
- const { t: d } = B(), c = (r, t, e) => {
74
- const m = se(r.encounterDetails, d);
75
- return /* @__PURE__ */ I(
76
- U,
77
- {
78
- title: m,
79
- id: `encounter-${r.encounterId}`,
80
- open: t,
81
- children: [
82
- r.observations.map(
83
- (i, p) => V(
84
- i,
85
- p,
86
- e,
87
- l,
88
- d,
89
- o
90
- )
91
- ),
92
- r.groupedObservations.map(
93
- (i, p) => ye(
94
- i,
95
- d,
96
- t,
97
- p,
98
- e,
99
- l,
100
- o
101
- )
102
- )
103
- ]
104
- },
105
- `encounter-${r.encounterId}`
106
- );
107
- };
108
- return /* @__PURE__ */ n(
109
- "div",
110
- {
111
- id: "obs-by-encounter",
112
- "data-testid": "obs-by-encounter-test-id",
113
- "aria-label": "obs-by-encounter-aria-label",
114
- children: s.map(
115
- (r, t) => c(r, t === 0, t)
116
- )
117
- }
118
- );
119
- }, Re = (s) => ["conceptUuid", s], Te = (s, l, o, d) => [
120
- "observations",
121
- s,
122
- ...l,
123
- o,
124
- d
125
- ], Ie = ({
126
- config: s,
127
- episodeOfCareUuids: l,
128
- encounterUuids: o
129
- }) => {
130
- const d = s, {
131
- conceptNames: c = [],
132
- conceptUuid: r = [],
133
- hideThumbnail: t = !1,
134
- scope: e = "all"
135
- } = d, m = me(/* @__PURE__ */ new Set()), i = M(), { addNotification: p } = j(), { t: u } = B(), b = ue({
136
- queries: c.map((a) => ({
137
- queryKey: Re(a),
138
- queryFn: () => x(a),
139
- enabled: !!a
140
- }))
141
- });
142
- A(() => {
143
- const a = b.some((z) => z.isError), y = m.current.size > 0;
144
- a && !y ? (p({
145
- title: u("ERROR_DEFAULT_TITLE"),
146
- message: u("ERROR_FETCHING_OBSERVATIONS"),
147
- type: "error"
148
- }), m.current.add(0)) : !a && y && m.current.clear();
149
- }, [b, p, u]);
150
- const f = g(() => b.map((a) => a.data?.uuid).filter((a) => !!a), [b]), v = g(() => [.../* @__PURE__ */ new Set([...f, ...r])], [f, r]), h = g(() => c.length === 0 ? !0 : b.every((a) => !a.isLoading), [b, c.length]), R = e === "latest" || e === "latest-encounter", w = G(
151
- l,
152
- o
153
- ), {
154
- data: T,
155
- isLoading: C,
156
- isError: S,
157
- refetch: N
158
- } = ce({
159
- queryKey: Te(
160
- i,
161
- v,
162
- o,
163
- e
164
- ),
165
- queryFn: () => R ? H(
166
- i,
167
- v,
168
- o
169
- ) : Y(
170
- i,
171
- v,
172
- o
173
- ),
174
- enabled: !!i && v.length > 0 && h && !w
175
- });
176
- J(
177
- (a) => {
178
- a.patientUUID === i && a.updatedConcepts.size > 0 && [...a.updatedConcepts.keys()].some(
179
- (y) => v.includes(y)
180
- ) && N();
181
- },
182
- [i, N]
183
- ), A(() => {
184
- S && p({
185
- title: u("ERROR_DEFAULT_TITLE"),
186
- message: u("ERROR_FETCHING_OBSERVATIONS"),
187
- type: "error"
188
- });
189
- }, [S]);
190
- const $ = g(() => {
191
- if (!T) return [];
192
- let a = P(T);
193
- e === "latest-encounter" && (a = W(a));
194
- const y = X(a);
195
- return Z(y);
196
- }, [T, e]), F = [
197
- { key: "name", header: "name" },
198
- { key: "value", header: "value" },
199
- { key: "form", header: "form" }
200
- ], L = C || !h, D = S && h, k = (!T || T.entry?.length === 0 || v.length === 0) && h, K = D ? u("ERROR_FETCHING_OBSERVATIONS") : null, Q = k ? u("NO_OBSERVATIONS_FOUND") : void 0, q = $.length > 0 && !L && !D, E = d.titleTranslationKey, _ = E ? u(E) : "";
201
- return /* @__PURE__ */ I(
202
- "div",
203
- {
204
- id: "observations",
205
- "data-testid": E ? `observations-${_}` : "observations",
206
- "aria-label": "observations-aria-label",
207
- className: O.observations,
208
- children: [
209
- /* @__PURE__ */ n(
210
- ee,
211
- {
212
- id: "observations-title",
213
- testId: E ? `observations-title-${_}` : "observations-title",
214
- title: _,
215
- className: O.title,
216
- children: /* @__PURE__ */ n("p", { children: _ })
217
- }
218
- ),
219
- q ? /* @__PURE__ */ n(
220
- Oe,
221
- {
222
- groupedData: $,
223
- title: _,
224
- hideThumbnail: t
225
- }
226
- ) : /* @__PURE__ */ n(
227
- ae,
228
- {
229
- headers: F,
230
- rows: [],
231
- ariaLabel: u("OBSERVATIONS"),
232
- loading: L,
233
- errorStateMessage: K,
234
- emptyStateMessage: Q ?? u("NO_OBSERVATIONS_AVAILABLE"),
235
- dataTestId: "observations-table"
236
- }
237
- )
238
- ]
239
- }
240
- );
241
- };
242
- export {
243
- Re as conceptUuidQueryKeys,
244
- Ie as default,
245
- Te as observationsQueryKeys
246
- };