@bahmni/widgets 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.
Files changed (32) hide show
  1. package/dist/{DocumentsTable-CQyui8ZK.js → DocumentsTable-GvC6scVM.js} +1 -1
  2. package/dist/FormsTable-B9TtLrXO.js +253 -0
  3. package/dist/{Observations-BTpd1e1r.js → Observations-D5ZO8XdZ.js} +18 -18
  4. package/dist/forms/FormsTable.d.ts.map +1 -1
  5. package/dist/{index-DuVUtfIr.js → index-CqoTcOeh.js} +21031 -20850
  6. package/dist/index.css +1 -1
  7. package/dist/index.d.ts +2 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +58 -54
  10. package/dist/moduleTiles/AppTile/AppTile.d.ts +10 -0
  11. package/dist/moduleTiles/AppTile/AppTile.d.ts.map +1 -0
  12. package/dist/moduleTiles/AppTile/__tests__/__mocks__/AppTileMocks.d.ts +7 -0
  13. package/dist/moduleTiles/AppTile/__tests__/__mocks__/AppTileMocks.d.ts.map +1 -0
  14. package/dist/moduleTiles/AppTile/index.d.ts +2 -0
  15. package/dist/moduleTiles/AppTile/index.d.ts.map +1 -0
  16. package/dist/moduleTiles/ModuleTileGrid/ModuleTileGrid.d.ts +25 -0
  17. package/dist/moduleTiles/ModuleTileGrid/ModuleTileGrid.d.ts.map +1 -0
  18. package/dist/moduleTiles/ModuleTileGrid/__tests__/__mocks__/moduleTileGridMocks.d.ts +12 -0
  19. package/dist/moduleTiles/ModuleTileGrid/__tests__/__mocks__/moduleTileGridMocks.d.ts.map +1 -0
  20. package/dist/moduleTiles/ModuleTileGrid/index.d.ts +2 -0
  21. package/dist/moduleTiles/ModuleTileGrid/index.d.ts.map +1 -0
  22. package/dist/moduleTiles/constants.d.ts +3 -0
  23. package/dist/moduleTiles/constants.d.ts.map +1 -0
  24. package/dist/moduleTiles/index.d.ts +4 -0
  25. package/dist/moduleTiles/index.d.ts.map +1 -0
  26. package/dist/observationsRenderer/ObservationsRenderer.d.ts +1 -3
  27. package/dist/observationsRenderer/ObservationsRenderer.d.ts.map +1 -1
  28. package/dist/observationsRenderer/hooks/useFormSchemaData.d.ts +9 -0
  29. package/dist/observationsRenderer/hooks/useFormSchemaData.d.ts.map +1 -0
  30. package/dist/tasks/views/ViewFormData/ViewFormData.d.ts.map +1 -1
  31. package/package.json +1 -1
  32. package/dist/FormsTable-dvLt_RSh.js +0 -273
@@ -1,5 +1,5 @@
1
1
  import { jsx as r, jsxs as T, Fragment as Y } from "react/jsx-runtime";
2
- import { u as W, a as X, n as J, V as Z, p as x, b as ee, F as te } from "./index-DuVUtfIr.js";
2
+ import { u as W, a as X, n as J, V as Z, p as x, b as ee, F as te } from "./index-CqoTcOeh.js";
3
3
  import { useQuery as ne } from "@tanstack/react-query";
4
4
  import { useState as l, useCallback as _, useEffect as I, useMemo as p } from "react";
5
5
  import { useTranslation as ae } from "react-i18next";
@@ -0,0 +1,253 @@
1
+ import { jsx as n, jsxs as P, Fragment as ie } from "react/jsx-runtime";
2
+ import { u as de, c as le, d as me, x as ce, C as ue, N as fe, h as be, W as he, e as Ne, f as ye, G as Oe, p as ge, g as q, B as x, V as pe, b as G, r as Te, i as Ee, F as Ie, O as Fe, j as Ae } from "./index-CqoTcOeh.js";
3
+ import { useQueryClient as _e, useQuery as F } from "@tanstack/react-query";
4
+ import { useState as $, useMemo as i, useCallback as d } from "react";
5
+ import { useTranslation as Re } from "react-i18next";
6
+ const ve = "FormsTable-module_formsTableBody__SvGha", Ce = "FormsTable-module_modalHeading__wnTmA", De = "FormsTable-module_customAccordianItem__isszs", y = {
7
+ formsTableBody: ve,
8
+ modalHeading: Ce,
9
+ customAccordianItem: De
10
+ }, Le = "startConsultation", He = ({
11
+ episodeOfCareUuids: A,
12
+ encounterUuids: m,
13
+ config: j,
14
+ disableActions: z = !1,
15
+ activeEncounterUuid: b = null
16
+ }) => {
17
+ const { t: o } = Re(), c = de(), [O, _] = $(!1), [a, R] = $(null), {
18
+ numberOfVisits: K,
19
+ hideThumbnail: Q = !1,
20
+ forms: h
21
+ } = j ?? {}, W = le(
22
+ Ae.EDIT_OBSERVATIONS
23
+ ), { userPrivileges: N } = me(), g = W && !z && !!b, v = ce(
24
+ A,
25
+ m
26
+ ), Y = _e(), {
27
+ data: C = [],
28
+ isLoading: D,
29
+ isError: L,
30
+ error: J,
31
+ refetch: X
32
+ } = F({
33
+ queryKey: ["forms", c, A],
34
+ queryFn: () => ue(c, void 0, K),
35
+ enabled: !!c && !v
36
+ }), B = i(() => {
37
+ let e = C;
38
+ return m && m.length > 0 && (e = e.filter(
39
+ (t) => m.includes(t.encounterUuid)
40
+ )), Array.isArray(h) && h.length > 0 && (e = e.filter(
41
+ (t) => h.some((s) => s.toLowerCase() === t.formName.toLowerCase())
42
+ )), e;
43
+ }, [C, m, h]), { data: S = [] } = F({
44
+ queryKey: ["observationForms"],
45
+ queryFn: () => fe()
46
+ }), M = d(
47
+ (e) => {
48
+ const t = S.find(
49
+ (r) => r.name.toLowerCase() === e.toLowerCase()
50
+ );
51
+ if (!t?.privileges || t.privileges.length === 0) return !0;
52
+ if (!N || N.length === 0) return !1;
53
+ const s = new Set(N.map((r) => r.name));
54
+ return t.privileges.some(
55
+ (r) => s.has(r.privilegeName) && r.editable
56
+ );
57
+ },
58
+ [S, N]
59
+ ), u = d(
60
+ (e) => !b || e.encounterUuid !== b ? !1 : M(e.formName),
61
+ [b, M]
62
+ ), {
63
+ data: p,
64
+ isLoading: Z,
65
+ isError: ee,
66
+ error: T
67
+ } = F({
68
+ queryKey: ["formsEncounterFHIR", a?.encounterUuid],
69
+ queryFn: () => be(a.encounterUuid),
70
+ enabled: !!a?.encounterUuid && O
71
+ });
72
+ he(
73
+ (e) => {
74
+ e.patientUUID === c && (X(), Y.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
75
+ },
76
+ [c]
77
+ );
78
+ const re = i(() => !p?.entry || !a?.formName ? [] : p.entry.filter((t) => t.resource?.resourceType === "Observation").map((t) => t.resource).filter((t) => Ne(t) ? ye(t)?.toLowerCase() === a.formName.toLowerCase() : !0), [p, a?.formName]), te = i(() => {
79
+ if (T)
80
+ return Oe(T).message;
81
+ }, [T]), f = i(
82
+ () => [
83
+ { key: "recordedOn", header: o("RECORDED_ON") },
84
+ { key: "recordedBy", header: o("RECORDED_BY") }
85
+ ],
86
+ [o]
87
+ ), w = i(
88
+ () => [...f, { key: "actions", header: o("ACTIONS") }],
89
+ [f, o]
90
+ ), se = d(
91
+ (e) => g && e.some((s) => u(s)) ? w : f,
92
+ [g, u, w, f]
93
+ ), oe = f, ae = i(
94
+ () => [
95
+ { key: "recordedOn", sortable: !0 },
96
+ { key: "recordedBy", sortable: !0 }
97
+ ],
98
+ []
99
+ ), U = i(() => {
100
+ const e = B.reduce(
101
+ (s, r) => {
102
+ const l = r.formName;
103
+ s[l] ??= [];
104
+ const I = r.providers.map((ne) => ne.providerName).filter(Boolean).join(", ");
105
+ return s[l].push({
106
+ id: r.encounterUuid,
107
+ formName: r.formName,
108
+ recordedOn: ge(r.encounterDateTime, o, !0).formattedResult,
109
+ recordedBy: I ?? "--",
110
+ encounterDateTime: r.encounterDateTime,
111
+ encounterUuid: r.encounterUuid
112
+ }), s;
113
+ },
114
+ {}
115
+ );
116
+ return Object.entries(e).map(
117
+ ([s, r]) => ({
118
+ formName: s,
119
+ records: r.sort(
120
+ (l, I) => I.encounterDateTime - l.encounterDateTime
121
+ )
122
+ })
123
+ ).sort((s, r) => s.formName.localeCompare(r.formName));
124
+ }, [B, o]), H = d((e) => {
125
+ R(e), _(!0);
126
+ }, []), V = d(() => {
127
+ _(!1), R(null);
128
+ }, []), E = d((e) => {
129
+ globalThis.dispatchEvent(
130
+ new CustomEvent(Le, {
131
+ detail: {
132
+ editOnly: "observationForms",
133
+ editTitle: "EDIT_OBSERVATION_FORM_TITLE",
134
+ sourceEncounterUuid: e.encounterUuid,
135
+ formName: e.formName,
136
+ directFormMode: !0
137
+ }
138
+ })
139
+ );
140
+ }, []), k = d(
141
+ (e, t) => {
142
+ switch (t) {
143
+ case "recordedOn":
144
+ return /* @__PURE__ */ n(pe, { onClick: () => H(e), children: e.recordedOn });
145
+ case "recordedBy":
146
+ return e.recordedBy;
147
+ case "actions":
148
+ return u(e) ? /* @__PURE__ */ n(
149
+ q,
150
+ {
151
+ label: o("EDIT_OBSERVATION_FORM"),
152
+ kind: "ghost",
153
+ size: "sm",
154
+ testId: `edit-form-${e.encounterUuid}`,
155
+ onClick: () => E(e),
156
+ children: /* @__PURE__ */ n(x, {})
157
+ }
158
+ ) : null;
159
+ default:
160
+ return null;
161
+ }
162
+ },
163
+ [H, E, u, o]
164
+ );
165
+ return /* @__PURE__ */ P(ie, { children: [
166
+ /* @__PURE__ */ n("div", { id: "forms-table", "data-testid": "forms-table", children: D || L || U.length === 0 || v ? /* @__PURE__ */ n(
167
+ G,
168
+ {
169
+ headers: oe,
170
+ ariaLabel: o("FORMS_HEADING"),
171
+ rows: [],
172
+ loading: D,
173
+ errorStateMessage: L ? J?.message : void 0,
174
+ emptyStateMessage: o("FORMS_UNAVAILABLE"),
175
+ renderCell: k,
176
+ className: y.formsTableBody,
177
+ dataTestId: "forms-table"
178
+ }
179
+ ) : /* @__PURE__ */ n(Te, { align: "start", children: U.map((e, t) => {
180
+ const { formName: s, records: r } = e, l = se(r);
181
+ return /* @__PURE__ */ n(
182
+ Ee,
183
+ {
184
+ title: s,
185
+ className: y.customAccordianItem,
186
+ testId: `accordian-title-${s}`,
187
+ open: t === 0,
188
+ children: /* @__PURE__ */ n(
189
+ G,
190
+ {
191
+ headers: l,
192
+ ariaLabel: o("FORMS_HEADING"),
193
+ rows: r,
194
+ loading: !1,
195
+ errorStateMessage: "",
196
+ sortable: ae,
197
+ emptyStateMessage: o("FORMS_UNAVAILABLE"),
198
+ renderCell: k,
199
+ className: y.formsTableBody,
200
+ dataTestId: `forms-table-${s}`
201
+ }
202
+ )
203
+ },
204
+ s
205
+ );
206
+ }) }) }),
207
+ O && a && /* @__PURE__ */ n(
208
+ Ie,
209
+ {
210
+ id: "modalIdForActionAreaLayout",
211
+ portalId: "main-display-area",
212
+ open: O,
213
+ onRequestClose: V,
214
+ modalHeading: /* @__PURE__ */ P("div", { className: y.modalHeading, children: [
215
+ /* @__PURE__ */ n("span", { children: a.formName }),
216
+ g && u(a) && /* @__PURE__ */ n(
217
+ q,
218
+ {
219
+ label: o("EDIT_OBSERVATION_FORM"),
220
+ kind: "ghost",
221
+ size: "sm",
222
+ testId: `edit-form-modal-${a.encounterUuid}`,
223
+ onClick: () => {
224
+ V(), E(a);
225
+ },
226
+ children: /* @__PURE__ */ n(x, {})
227
+ }
228
+ )
229
+ ] }),
230
+ modalLabel: `${a.recordedOn} | ${a.recordedBy}`,
231
+ passiveModal: !0,
232
+ size: "md",
233
+ testId: "form-details-modal",
234
+ children: /* @__PURE__ */ n(
235
+ Fe,
236
+ {
237
+ observations: re,
238
+ isLoading: Z,
239
+ isError: ee,
240
+ errorMessage: te,
241
+ emptyStateMessage: o("NO_FORM_DATA_AVAILABLE"),
242
+ testIdPrefix: a.formName,
243
+ hideThumbnail: Q,
244
+ formName: a.formName
245
+ }
246
+ )
247
+ }
248
+ )
249
+ ] });
250
+ };
251
+ export {
252
+ He as default
253
+ };
@@ -1,5 +1,5 @@
1
1
  import { jsx as i, jsxs as S } from "react/jsx-runtime";
2
- import { l as z, D as F, t as G, m as x, p as H, o as P, T as j, R as W, S as J, u as Y, a as X, q as Z, x as ee, s as se, v as te, W as re, w as ae, y as oe, z as ne, A as ie, E as ce, b as le } from "./index-DuVUtfIr.js";
2
+ import { k as z, D as F, t as G, l as x, p as H, m as P, T as j, R as W, S as J, u as Y, a as X, o as Z, x as ee, q as se, s as te, W as re, v as ae, w as oe, y as ne, z as ie, A as ce, b as le } from "./index-CqoTcOeh.js";
3
3
  import { useQueries as de, useQuery as ue } from "@tanstack/react-query";
4
4
  import { useRef as pe, useEffect as C, useMemo as I } from "react";
5
5
  import { useTranslation as w } from "react-i18next";
@@ -117,7 +117,7 @@ const be = "Observations-module_observations__RKSyo", me = "Observations-module_
117
117
  )
118
118
  }
119
119
  );
120
- }, Ee = (t) => ["conceptUuid", t], he = (t, l, n, c) => [
120
+ }, he = (t) => ["conceptUuid", t], Ee = (t, l, n, c) => [
121
121
  "observations",
122
122
  t,
123
123
  ...l,
@@ -135,7 +135,7 @@ const be = "Observations-module_observations__RKSyo", me = "Observations-module_
135
135
  scope: e = "all"
136
136
  } = c, p = pe(/* @__PURE__ */ new Set()), o = Y(), { addNotification: b } = X(), { t: d } = w(), m = de({
137
137
  queries: u.map((s) => ({
138
- queryKey: Ee(s),
138
+ queryKey: he(s),
139
139
  queryFn: () => Z(s),
140
140
  enabled: !!s
141
141
  }))
@@ -152,12 +152,12 @@ const be = "Observations-module_observations__RKSyo", me = "Observations-module_
152
152
  l,
153
153
  n
154
154
  ), {
155
- data: E,
155
+ data: h,
156
156
  isLoading: V,
157
157
  isError: N,
158
158
  refetch: D
159
159
  } = ue({
160
- queryKey: he(
160
+ queryKey: Ee(
161
161
  o,
162
162
  v,
163
163
  n,
@@ -189,21 +189,21 @@ const be = "Observations-module_observations__RKSyo", me = "Observations-module_
189
189
  });
190
190
  }, [N]);
191
191
  const A = I(() => {
192
- if (!E) return [];
193
- let s = ae(E);
192
+ if (!h) return [];
193
+ let s = ae(h);
194
194
  e === "latest-encounter" && (s = oe(s));
195
195
  const R = ne(s);
196
196
  return ie(R);
197
- }, [E, e]), K = [
197
+ }, [h, e]), k = [
198
198
  { key: "name", header: "name" },
199
199
  { key: "value", header: "value" },
200
200
  { key: "form", header: "form" }
201
- ], L = V || !f, B = N && f, M = (!E || E.entry?.length === 0 || v.length === 0) && f, k = B ? d("ERROR_FETCHING_OBSERVATIONS") : null, q = M ? d("NO_OBSERVATIONS_FOUND") : void 0, Q = A.length > 0 && !L && !B, g = c.titleTranslationKey, h = g ? d(g) : "";
201
+ ], L = V || !f, B = N && f, K = (!h || h.entry?.length === 0 || v.length === 0) && f, M = B ? d("ERROR_FETCHING_OBSERVATIONS") : null, q = K ? d("NO_OBSERVATIONS_FOUND") : void 0, Q = A.length > 0 && !L && !B, g = c.titleTranslationKey, E = g ? d(g) : "";
202
202
  return /* @__PURE__ */ S(
203
203
  "div",
204
204
  {
205
205
  id: "observations",
206
- "data-testid": g ? `observations-${h}` : "observations",
206
+ "data-testid": g ? `observations-${E}` : "observations",
207
207
  "aria-label": "observations-aria-label",
208
208
  className: y.observations,
209
209
  children: [
@@ -211,27 +211,27 @@ const be = "Observations-module_observations__RKSyo", me = "Observations-module_
211
211
  ce,
212
212
  {
213
213
  id: "observations-title",
214
- testId: g ? `observations-title-${h}` : "observations-title",
215
- title: h,
214
+ testId: g ? `observations-title-${E}` : "observations-title",
215
+ title: E,
216
216
  className: y.title,
217
- children: /* @__PURE__ */ i("p", { children: h })
217
+ children: /* @__PURE__ */ i("p", { children: E })
218
218
  }
219
219
  ),
220
220
  Q ? /* @__PURE__ */ i(
221
221
  Oe,
222
222
  {
223
223
  groupedData: A,
224
- title: h,
224
+ title: E,
225
225
  hideThumbnail: a
226
226
  }
227
227
  ) : /* @__PURE__ */ i(
228
228
  le,
229
229
  {
230
- headers: K,
230
+ headers: k,
231
231
  rows: [],
232
232
  ariaLabel: d("OBSERVATIONS"),
233
233
  loading: L,
234
- errorStateMessage: k,
234
+ errorStateMessage: M,
235
235
  emptyStateMessage: q ?? d("NO_OBSERVATIONS_AVAILABLE"),
236
236
  dataTestId: "observations-table"
237
237
  }
@@ -241,7 +241,7 @@ const be = "Observations-module_observations__RKSyo", me = "Observations-module_
241
241
  );
242
242
  };
243
243
  export {
244
- Ee as conceptUuidQueryKeys,
244
+ he as conceptUuidQueryKeys,
245
245
  Se as default,
246
- he as observationsQueryKeys
246
+ Ee as observationsQueryKeys
247
247
  };
@@ -1 +1 @@
1
- {"version":3,"file":"FormsTable.d.ts","sourceRoot":"","sources":["../../src/forms/FormsTable.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAI9D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAgBhD,uEAAuE;AACvE,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAwZrC,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"FormsTable.d.ts","sourceRoot":"","sources":["../../src/forms/FormsTable.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAI9D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAehD,uEAAuE;AACvE,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAqXrC,CAAC;AAEF,eAAe,UAAU,CAAC"}