@bahmni/widgets 0.0.1-dev.333 → 0.0.1-dev.334

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.
@@ -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 Z, z as X, Z as J, i as x, j as ee, P as te } from "./index-Cvg_wxJX.js";
2
+ import { u as W, a as Z, z as X, Z as J, i as x, j as ee, P as te } from "./index-iRMlne97.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";
@@ -1,81 +1,79 @@
1
1
  import { jsx as i, jsxs as oe, Fragment as te } from "react/jsx-runtime";
2
- import { b as se, u as ae, c as ne, T as de, _ as ie, v as ce, o as le, M as me, q as j, i as ue, Z as fe, j as k, d as ye, R as pe, P as be, O as he } from "./index-Cvg_wxJX.js";
3
- import { useQueryClient as ge, useQuery as b } from "@tanstack/react-query";
4
- import { useState as x, useMemo as d, useCallback as h } from "react";
2
+ import { u as se, c as ae, T as ne, _ as de, v as ie, o as ce, M as le, e as me, q as U, i as ue, Z as fe, j as k, b as ye, R as be, P as pe, O as ge } from "./index-iRMlne97.js";
3
+ import { useQueryClient as he, useQuery as b } from "@tanstack/react-query";
4
+ import { useState as j, useMemo as d, useCallback as p } from "react";
5
5
  import { useTranslation as Fe } from "react-i18next";
6
- const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_customAccordianItem__isszs", E = {
6
+ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_customAccordianItem__isszs", O = {
7
7
  formsTableBody: Ne,
8
8
  customAccordianItem: Oe
9
- }, ve = (m) => m ? m.extension?.find(
10
- (g) => g.url === se
11
- )?.valueString : void 0, Ae = ({
12
- episodeOfCareUuids: m,
13
- encounterUuids: c,
14
- config: g
9
+ }, Te = ({
10
+ episodeOfCareUuids: v,
11
+ encounterUuids: l,
12
+ config: H
15
13
  }) => {
16
- const { t: n } = Fe(), u = ae(), [y, M] = x(!1), [a, _] = x(null), {
14
+ const { t: n } = Fe(), m = se(), [f, M] = j(!1), [a, E] = j(null), {
17
15
  numberOfVisits: P,
18
16
  hideThumbnail: w = !1,
19
- forms: p
20
- } = g ?? {}, I = ne(
21
- m,
22
- c
23
- ), H = ge(), {
24
- data: T = [],
25
- isLoading: A,
26
- isError: D,
17
+ forms: y
18
+ } = H ?? {}, _ = ae(
19
+ v,
20
+ l
21
+ ), x = he(), {
22
+ data: I = [],
23
+ isLoading: T,
24
+ isError: A,
27
25
  error: K,
28
26
  refetch: V
29
27
  } = b({
30
- queryKey: ["forms", u, m],
31
- queryFn: () => de(u, void 0, P),
32
- enabled: !!u && !I
33
- }), B = d(() => {
34
- let e = T;
35
- return c && c.length > 0 && (e = e.filter(
36
- (o) => c.includes(o.encounterUuid)
37
- )), Array.isArray(p) && p.length > 0 && (e = e.filter(
38
- (o) => p.some((r) => r.toLowerCase() === o.formName.toLowerCase())
28
+ queryKey: ["forms", m, v],
29
+ queryFn: () => ne(m, void 0, P),
30
+ enabled: !!m && !_
31
+ }), D = d(() => {
32
+ let e = I;
33
+ return l && l.length > 0 && (e = e.filter(
34
+ (o) => l.includes(o.encounterUuid)
35
+ )), Array.isArray(y) && y.length > 0 && (e = e.filter(
36
+ (o) => y.some((r) => r.toLowerCase() === o.formName.toLowerCase())
39
37
  )), e;
40
- }, [T, c, p]), { data: R = [] } = b({
38
+ }, [I, l, y]), { data: B = [] } = b({
41
39
  queryKey: ["observationForms"],
42
- queryFn: () => ie()
43
- }), L = h(
44
- (e) => R.find((r) => r.name === e)?.uuid,
45
- [R]
46
- ), F = d(() => {
40
+ queryFn: () => de()
41
+ }), R = p(
42
+ (e) => B.find((r) => r.name === e)?.uuid,
43
+ [B]
44
+ ), g = d(() => {
47
45
  if (a)
48
- return L(a.formName);
49
- }, [a, L]), {
50
- data: l,
46
+ return R(a.formName);
47
+ }, [a, R]), {
48
+ data: c,
51
49
  isLoading: $,
52
50
  isError: z,
53
- error: N
51
+ error: h
54
52
  } = b({
55
- queryKey: ["formMetadata", F],
56
- queryFn: () => ce(F),
57
- enabled: !!F && y
53
+ queryKey: ["formMetadata", g],
54
+ queryFn: () => ie(g),
55
+ enabled: !!g && f
58
56
  }), {
59
- data: O,
57
+ data: F,
60
58
  isLoading: G,
61
59
  isError: Q,
62
- error: v
60
+ error: N
63
61
  } = b({
64
62
  queryKey: ["formsEncounterFHIR", a?.encounterUuid],
65
- queryFn: () => le(a.encounterUuid),
66
- enabled: !!a?.encounterUuid && y
63
+ queryFn: () => ce(a.encounterUuid),
64
+ enabled: !!a?.encounterUuid && f
67
65
  });
68
- me(
66
+ le(
69
67
  (e) => {
70
- e.patientUUID === u && e.updatedConcepts.size > 0 && (V(), H.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
68
+ e.patientUUID === m && e.updatedConcepts.size > 0 && (V(), x.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
71
69
  },
72
- [u]
70
+ [m]
73
71
  );
74
- const Z = d(() => !O?.entry || !a?.formName ? [] : O.entry.filter((o) => o.resource?.resourceType === "Observation").map((o) => o.resource).filter((o) => {
75
- const r = ve(o);
72
+ const Z = d(() => !F?.entry || !a?.formName ? [] : F.entry.filter((o) => o.resource?.resourceType === "Observation").map((o) => o.resource).filter((o) => {
73
+ const r = me(o);
76
74
  return !r || r.includes(a.formName);
77
- }), [O, a?.formName]), Y = d(() => {
78
- if (!l?.schema) return;
75
+ }), [F, a?.formName]), Y = d(() => {
76
+ if (!c?.schema) return;
79
77
  const e = [], o = (r) => {
80
78
  (r ?? []).forEach((t) => {
81
79
  const s = t;
@@ -83,28 +81,28 @@ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_cu
83
81
  });
84
82
  };
85
83
  return o(
86
- l.schema.controls ?? []
84
+ c.schema.controls ?? []
87
85
  ), e.length > 0 ? e : void 0;
88
- }, [l]), J = d(() => {
89
- if (!l?.schema) return;
86
+ }, [c]), J = d(() => {
87
+ if (!c?.schema) return;
90
88
  const e = {}, o = (r, t) => {
91
89
  for (const s of r)
92
90
  if (s.type === "section") {
93
- const f = s.label?.value ?? "Section";
94
- o(s.controls ?? [], f);
91
+ const u = s.label?.value ?? "Section";
92
+ o(s.controls ?? [], u);
95
93
  } else
96
94
  s.id != null && t && (e[String(s.id)] = t), s.controls && o(s.controls, t);
97
95
  };
98
96
  return o(
99
- l.schema.controls ?? [],
97
+ c.schema.controls ?? [],
100
98
  null
101
99
  ), Object.keys(e).length > 0 ? e : void 0;
102
- }, [l]), W = d(() => {
100
+ }, [c]), W = d(() => {
101
+ if (h)
102
+ return U(h).message;
103
103
  if (N)
104
- return j(N).message;
105
- if (v)
106
- return j(v).message;
107
- }, [N, v]), C = d(
104
+ return U(N).message;
105
+ }, [h, N]), L = d(
108
106
  () => [
109
107
  { key: "recordedOn", header: n("RECORDED_ON") },
110
108
  { key: "recordedBy", header: n("RECORDED_BY") }
@@ -116,17 +114,17 @@ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_cu
116
114
  { key: "recordedBy", sortable: !0 }
117
115
  ],
118
116
  []
119
- ), S = d(() => {
120
- const e = B.reduce(
117
+ ), C = d(() => {
118
+ const e = D.reduce(
121
119
  (r, t) => {
122
120
  const s = t.formName;
123
121
  r[s] ??= [];
124
- const f = t.providers.map((re) => re.providerName).filter(Boolean).join(", ");
122
+ const u = t.providers.map((re) => re.providerName).filter(Boolean).join(", ");
125
123
  return r[s].push({
126
124
  id: t.encounterUuid,
127
125
  formName: t.formName,
128
126
  recordedOn: ue(t.encounterDateTime, n, !0).formattedResult,
129
- recordedBy: f ?? "--",
127
+ recordedBy: u ?? "--",
130
128
  encounterDateTime: t.encounterDateTime,
131
129
  encounterUuid: t.encounterUuid
132
130
  }), r;
@@ -137,15 +135,15 @@ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_cu
137
135
  ([r, t]) => ({
138
136
  formName: r,
139
137
  records: t.sort(
140
- (s, f) => f.encounterDateTime - s.encounterDateTime
138
+ (s, u) => u.encounterDateTime - s.encounterDateTime
141
139
  )
142
140
  })
143
141
  ).sort((r, t) => r.formName.localeCompare(t.formName));
144
- }, [B, n]), q = h((e) => {
145
- _(e), M(!0);
146
- }, []), ee = h(() => {
147
- M(!1), _(null);
148
- }, []), U = h(
142
+ }, [D, n]), q = p((e) => {
143
+ E(e), M(!0);
144
+ }, []), ee = p(() => {
145
+ M(!1), E(null);
146
+ }, []), S = p(
149
147
  (e, o) => {
150
148
  switch (o) {
151
149
  case "recordedOn":
@@ -159,40 +157,40 @@ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_cu
159
157
  [q]
160
158
  );
161
159
  return /* @__PURE__ */ oe(te, { children: [
162
- /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: A || D || S.length === 0 || I ? /* @__PURE__ */ i(
160
+ /* @__PURE__ */ i("div", { id: "forms-table", "data-testid": "forms-table", children: T || A || C.length === 0 || _ ? /* @__PURE__ */ i(
163
161
  k,
164
162
  {
165
- headers: C,
163
+ headers: L,
166
164
  ariaLabel: n("FORMS_HEADING"),
167
165
  rows: [],
168
- loading: A,
169
- errorStateMessage: D ? K?.message : void 0,
166
+ loading: T,
167
+ errorStateMessage: A ? K?.message : void 0,
170
168
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
171
- renderCell: U,
172
- className: E.formsTableBody,
169
+ renderCell: S,
170
+ className: O.formsTableBody,
173
171
  dataTestId: "forms-table"
174
172
  }
175
- ) : /* @__PURE__ */ i(ye, { align: "start", children: S.map((e, o) => {
173
+ ) : /* @__PURE__ */ i(ye, { align: "start", children: C.map((e, o) => {
176
174
  const { formName: r, records: t } = e;
177
175
  return /* @__PURE__ */ i(
178
- pe,
176
+ be,
179
177
  {
180
178
  title: r,
181
- className: E.customAccordianItem,
179
+ className: O.customAccordianItem,
182
180
  testId: `accordian-title-${r}`,
183
181
  open: o === 0,
184
182
  children: /* @__PURE__ */ i(
185
183
  k,
186
184
  {
187
- headers: C,
185
+ headers: L,
188
186
  ariaLabel: n("FORMS_HEADING"),
189
187
  rows: t,
190
188
  loading: !1,
191
189
  errorStateMessage: "",
192
190
  sortable: X,
193
191
  emptyStateMessage: n("FORMS_UNAVAILABLE"),
194
- renderCell: U,
195
- className: E.formsTableBody,
192
+ renderCell: S,
193
+ className: O.formsTableBody,
196
194
  dataTestId: `forms-table-${r}`
197
195
  }
198
196
  )
@@ -200,12 +198,12 @@ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_cu
200
198
  r
201
199
  );
202
200
  }) }) }),
203
- y && a && /* @__PURE__ */ i(
204
- be,
201
+ f && a && /* @__PURE__ */ i(
202
+ pe,
205
203
  {
206
204
  id: "modalIdForActionAreaLayout",
207
205
  portalId: "main-display-area",
208
- open: y,
206
+ open: f,
209
207
  onRequestClose: ee,
210
208
  modalHeading: a.formName,
211
209
  modalLabel: `${a.recordedOn} | ${a.recordedBy}`,
@@ -213,7 +211,7 @@ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_cu
213
211
  size: "md",
214
212
  testId: "form-details-modal",
215
213
  children: /* @__PURE__ */ i(
216
- he,
214
+ ge,
217
215
  {
218
216
  observations: Z,
219
217
  isLoading: $ || G,
@@ -231,5 +229,5 @@ const Ne = "FormsTable-module_formsTableBody__SvGha", Oe = "FormsTable-module_cu
231
229
  ] });
232
230
  };
233
231
  export {
234
- Ae as default
232
+ Te as default
235
233
  };
@@ -1,5 +1,5 @@
1
1
  import { jsx as d, jsxs as N } from "react/jsx-runtime";
2
- import { f as H, J as D, t as K, s as V, F as k, X as w, e as j, Q as q, u as G, a as P, g as z, h as J, M as X, k as Y, l as W, m as Z, n as x, j as ee } from "./index-Cvg_wxJX.js";
2
+ import { f as H, J as D, t as K, s as V, F as k, X as w, d as j, Q as q, u as G, a as P, g as z, h as J, M as X, k as Y, l as W, m as Z, n as x, j as ee } from "./index-iRMlne97.js";
3
3
  import { useQueries as te, useQuery as se } from "@tanstack/react-query";
4
4
  import { useRef as oe, useEffect as S, useMemo as g } from "react";
5
5
  import { useTranslation as U } from "react-i18next";
@@ -5,4 +5,14 @@ import { Observation } from 'fhir/r4';
5
5
  * @returns formFieldPath string or undefined
6
6
  */
7
7
  export declare const extractFormFieldPath: (observation: Observation | undefined) => string | undefined;
8
+ /**
9
+ * Extract the form name from an observation's form-namespace-path extension.
10
+ *
11
+ * The path value is `{namespace}^{formName}.{version}/{fieldPath}`
12
+ * (e.g. `Bahmni^Vitals.1/10-0`) or `{formName}.{version}/{fieldPath}`
13
+ * (e.g. `Vitals.1/1-0`). Returns the bare form name (e.g. `Vitals`), stripping
14
+ * a single trailing `.{version}` segment (OpenMRS form versions are integers),
15
+ * or undefined if the value is absent/malformed.
16
+ */
17
+ export declare const extractFormName: (observation: Observation | undefined) => string | undefined;
8
18
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/forms/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,aAAa,WAAW,GAAG,SAAS,KACnC,MAAM,GAAG,SAQX,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/forms/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,aAAa,WAAW,GAAG,SAAS,KACnC,MAAM,GAAG,SAQX,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAC1B,aAAa,WAAW,GAAG,SAAS,KACnC,MAAM,GAAG,SAYX,CAAC"}