@bahmni/appointments-app 0.0.1-dev.215 → 0.0.1-dev.217

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,6 +1,6 @@
1
- import { jsx as r, jsxs as _, Fragment as Y } from "react/jsx-runtime";
2
- import { c as K, u as Q, e as W, a as J, H as X, T as Z, x as ee, R as te, p as ae } from "./index-CU8j8cbs.js";
3
- import { useState as l, useCallback as h, useEffect as f, useMemo as T } from "react";
1
+ import { jsx as r, jsxs as h, Fragment as Y } from "react/jsx-runtime";
2
+ import { u as K, a as Q, e as W, b as J, E as X, T as Z, h as ee, c as te, y as ae } from "./index-B7yw-zcZ.js";
3
+ import { useState as l, useCallback as p, useEffect as f, useMemo as T } from "react";
4
4
  const ne = "_documentsTableBody_1voj8_1", oe = "_viewAttachmentsLink_1voj8_11", re = "_documentViewerContainer_1voj8_15", de = "_attachmentItem_1voj8_23", se = "_attachmentCounter_1voj8_27", ce = "_attachmentError_1voj8_36", ie = "_documentIframe_1voj8_44", le = "_documentImage_1voj8_50", d = {
5
5
  documentsTableBody: ne,
6
6
  viewAttachmentsLink: oe,
@@ -17,53 +17,53 @@ const ne = "_documentsTableBody_1voj8_1", oe = "_viewAttachmentsLink_1voj8_11",
17
17
  uploadedBy: "DOCUMENTS_UPLOADED_BY",
18
18
  action: "DOCUMENTS_ACTION"
19
19
  };
20
- function R(a) {
20
+ function j(a) {
21
21
  return !a || a.includes(":") ? "#" : `/openmrs/auth?requested_document=/document_images/${a}`;
22
22
  }
23
- function ue(a, g) {
23
+ function ue(a, E) {
24
24
  return a.map((s) => ({
25
25
  key: s,
26
- header: g(me[s])
26
+ header: E(me[s])
27
27
  }));
28
28
  }
29
- const pe = [
29
+ const _e = [
30
30
  "documentIdentifier",
31
31
  "documentType",
32
32
  "uploadedOn",
33
33
  "uploadedBy",
34
34
  "action"
35
- ], _e = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, j = (a) => a.attachments.length > 0 ? a.attachments : a.documentUrl ? [{ url: a.documentUrl, contentType: a.contentType }] : [], Ee = ({ config: a, encounterUuids: g }) => {
35
+ ], he = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, B = (a) => a.attachments.length > 0 ? a.attachments : a.documentUrl ? [{ url: a.documentUrl, contentType: a.contentType }] : [], ge = ({ config: a, encounterUuids: E }) => {
36
36
  const [s, w] = l(!1), [o, L] = l(
37
37
  null
38
- ), [B, I] = l(
38
+ ), [R, I] = l(
39
39
  /* @__PURE__ */ new Set()
40
- ), E = K(), { t: n } = Q(), { addNotification: U } = W(), $ = Number(a?.pageSize) || 5, [C, A] = l(1), [m, k] = l($), [H, y] = l(void 0), M = h((e) => {
40
+ ), g = K(), { t: n } = Q(), { addNotification: U } = W(), $ = Number(a?.pageSize) || 5, [C, y] = l(1), [m, k] = l($), [V, A] = l(void 0), b = p((e) => {
41
41
  L(e), w(!0);
42
- }, []), V = h(() => {
42
+ }, []), F = p(() => {
43
43
  w(!1), L(null), I(/* @__PURE__ */ new Set());
44
- }, []), b = h((e) => {
44
+ }, []), M = p((e) => {
45
45
  I((t) => new Set(t).add(e));
46
- }, []), { data: u, isLoading: F, isError: D, error: v } = J({
46
+ }, []), { data: u, isLoading: H, isError: D, error: v } = J({
47
47
  queryKey: [
48
48
  "documents",
49
- E,
50
49
  g,
50
+ E,
51
51
  C,
52
52
  m
53
53
  ],
54
- enabled: !!E,
54
+ enabled: !!g,
55
55
  queryFn: () => ae(
56
- E,
57
56
  g,
57
+ E,
58
58
  m,
59
59
  C
60
60
  )
61
61
  });
62
62
  f(() => {
63
- u && y(u.total);
63
+ u && A(u.total);
64
64
  }, [u]), f(() => {
65
- A(1), y(void 0);
66
- }, [E]), f(() => {
65
+ y(1), A(void 0);
66
+ }, [g]), f(() => {
67
67
  D && U({
68
68
  title: n("ERROR_DEFAULT_TITLE"),
69
69
  message: v?.message ?? "",
@@ -73,9 +73,9 @@ const pe = [
73
73
  const e = new AbortController();
74
74
  return (async () => {
75
75
  if (!s || !o) return;
76
- const t = /* @__PURE__ */ new Set(), c = j(o);
76
+ const t = /* @__PURE__ */ new Set(), c = B(o);
77
77
  for (let i = 0; i < c.length; i++) {
78
- const S = R(c[i].url);
78
+ const S = j(c[i].url);
79
79
  try {
80
80
  (await fetch(S, {
81
81
  method: "HEAD",
@@ -88,24 +88,24 @@ const pe = [
88
88
  e.signal.aborted || I(t);
89
89
  })(), () => e.abort();
90
90
  }, [s, o]);
91
- const q = h(
91
+ const q = p(
92
92
  (e, t) => {
93
- t !== m ? (k(t), A(1), y(void 0)) : A(e);
93
+ t !== m ? (k(t), y(1), A(void 0)) : y(e);
94
94
  },
95
95
  [m]
96
96
  ), N = T(
97
- () => a?.fields ?? pe,
97
+ () => a?.fields ?? _e,
98
98
  [a?.fields]
99
- ), x = T(() => [...u?.documents ?? []].sort((e, t) => !e.uploadedOn && !t.uploadedOn ? 0 : e.uploadedOn ? t.uploadedOn ? new Date(t.uploadedOn).getTime() - new Date(e.uploadedOn).getTime() : -1 : 1), [u]), P = T(() => ue(N, n), [N, n]), z = T(
99
+ ), P = T(() => [...u?.documents ?? []].sort((e, t) => !e.uploadedOn && !t.uploadedOn ? 0 : e.uploadedOn ? t.uploadedOn ? new Date(t.uploadedOn).getTime() - new Date(e.uploadedOn).getTime() : -1 : 1), [u]), z = T(() => ue(N, n), [N, n]), x = T(
100
100
  () => N.map((e) => ({
101
101
  key: e,
102
102
  sortable: e !== "action"
103
103
  })),
104
104
  [N]
105
- ), p = T(
106
- () => o ? j(o) : [],
105
+ ), _ = T(
106
+ () => o ? B(o) : [],
107
107
  [o]
108
- ), G = h(
108
+ ), G = p(
109
109
  (e, t) => {
110
110
  switch (t) {
111
111
  case "documentIdentifier":
@@ -124,7 +124,7 @@ const pe = [
124
124
  return e.attachments.length > 0 || e.documentUrl ? /* @__PURE__ */ r(
125
125
  X,
126
126
  {
127
- onClick: () => M(e),
127
+ onClick: () => b(e),
128
128
  className: d.viewAttachmentsLink,
129
129
  "data-testid": `view-attachments-${e.id}`,
130
130
  children: n("DOCUMENTS_VIEW_ATTACHMENTS")
@@ -134,24 +134,24 @@ const pe = [
134
134
  return null;
135
135
  }
136
136
  },
137
- [M, n]
137
+ [b, n]
138
138
  );
139
- return /* @__PURE__ */ _(Y, { children: [
139
+ return /* @__PURE__ */ h(Y, { children: [
140
140
  /* @__PURE__ */ r("div", { "data-testid": "documents-table", children: /* @__PURE__ */ r(
141
141
  ee,
142
142
  {
143
- headers: P,
143
+ headers: z,
144
144
  ariaLabel: n("DOCUMENTS_TABLE_HEADING"),
145
- rows: x,
146
- loading: F,
145
+ rows: P,
146
+ loading: H,
147
147
  errorStateMessage: D ? v?.message : null,
148
- sortable: z,
148
+ sortable: x,
149
149
  emptyStateMessage: n("DOCUMENTS_NO_RECORDS"),
150
150
  renderCell: G,
151
151
  className: d.documentsTableBody,
152
152
  dataTestId: "documents-table",
153
153
  pageSize: m,
154
- totalItems: H,
154
+ totalItems: V,
155
155
  page: C,
156
156
  onPageChange: q
157
157
  }
@@ -162,38 +162,38 @@ const pe = [
162
162
  id: "modalIdForActionAreaLayout",
163
163
  portalId: "main-display-area",
164
164
  open: s,
165
- onRequestClose: V,
165
+ onRequestClose: F,
166
166
  modalHeading: o.documentIdentifier,
167
167
  passiveModal: !0,
168
168
  size: "lg",
169
169
  testId: "document-view-modal",
170
- children: /* @__PURE__ */ r("div", { className: d.documentViewerContainer, children: p.map((e, t) => {
171
- const c = R(e.url), i = e.contentType?.toLowerCase().includes("pdf"), S = (e.contentType?.toLowerCase().includes("image") ?? !1) || _e.test(e.url ?? ""), O = B.has(t);
172
- return c === "#" || O ? /* @__PURE__ */ _(
170
+ children: /* @__PURE__ */ r("div", { className: d.documentViewerContainer, children: _.map((e, t) => {
171
+ const c = j(e.url), i = e.contentType?.toLowerCase().includes("pdf"), S = (e.contentType?.toLowerCase().includes("image") ?? !1) || he.test(e.url ?? ""), O = R.has(t);
172
+ return c === "#" || O ? /* @__PURE__ */ h(
173
173
  "div",
174
174
  {
175
175
  className: d.attachmentError,
176
176
  "data-testid": `attachment-error-${t}`,
177
177
  children: [
178
- p.length > 1 && /* @__PURE__ */ _("p", { className: d.attachmentCounter, children: [
178
+ _.length > 1 && /* @__PURE__ */ h("p", { className: d.attachmentCounter, children: [
179
179
  t + 1,
180
180
  "/",
181
- p.length
181
+ _.length
182
182
  ] }),
183
183
  /* @__PURE__ */ r("p", { children: n("DOCUMENTS_ERROR_LOADING_ATTACHMENT") })
184
184
  ]
185
185
  },
186
186
  `${o.id}-${e.url}`
187
- ) : /* @__PURE__ */ _(
187
+ ) : /* @__PURE__ */ h(
188
188
  "div",
189
189
  {
190
190
  className: d.attachmentItem,
191
191
  "data-testid": `attachment-item-${t}`,
192
192
  children: [
193
- p.length > 1 && /* @__PURE__ */ _("p", { className: d.attachmentCounter, children: [
193
+ _.length > 1 && /* @__PURE__ */ h("p", { className: d.attachmentCounter, children: [
194
194
  t + 1,
195
195
  "/",
196
- p.length
196
+ _.length
197
197
  ] }),
198
198
  S ? /* @__PURE__ */ r(
199
199
  "img",
@@ -201,7 +201,7 @@ const pe = [
201
201
  src: c,
202
202
  alt: o.documentIdentifier,
203
203
  className: d.documentImage,
204
- onError: () => b(t)
204
+ onError: () => M(t)
205
205
  }
206
206
  ) : /* @__PURE__ */ r(
207
207
  "iframe",
@@ -209,7 +209,7 @@ const pe = [
209
209
  src: i ? `${c}#toolbar=0` : c,
210
210
  className: d.documentIframe,
211
211
  title: o.documentIdentifier,
212
- onError: () => b(t)
212
+ onError: () => M(t)
213
213
  }
214
214
  )
215
215
  ]
@@ -222,5 +222,5 @@ const pe = [
222
222
  ] });
223
223
  };
224
224
  export {
225
- Ee as default
225
+ ge as default
226
226
  };
@@ -0,0 +1,196 @@
1
+ import { jsx as o, jsxs as J, Fragment as W } from "react/jsx-runtime";
2
+ import { a as Z, u as ee, d as re, f as ae, b as c, g as te, V as R, T as se, E as oe, h as q, q as ne, U as de, c as ie, L as ue, i as me, j as le, k as ce, v as fe, w as ye } from "./index-B7yw-zcZ.js";
3
+ import { useState as C, useMemo as d, useCallback as f } from "react";
4
+ const be = "_formsTableBody_81hra_1", ge = "_customAccordianItem_81hra_6", A = {
5
+ formsTableBody: be,
6
+ customAccordianItem: ge
7
+ }, he = (u) => u ? u.extension?.find(
8
+ (n) => n.url === me
9
+ )?.valueString : void 0, Oe = ({
10
+ episodeOfCareUuids: u,
11
+ encounterUuids: n,
12
+ config: S
13
+ }) => {
14
+ const { t: s } = Z(), m = ee(), [l, O] = C(!1), [t, E] = C(null), { numberOfVisits: k, hideThumbnail: V = !1 } = S ?? {}, I = re(
15
+ u,
16
+ n
17
+ ), j = ae(), {
18
+ data: y = [],
19
+ isLoading: T,
20
+ isError: L,
21
+ error: w,
22
+ refetch: H
23
+ } = c({
24
+ queryKey: ["forms", m, u],
25
+ queryFn: () => le(m, void 0, k),
26
+ enabled: !!m && !I
27
+ }), B = d(() => !n || n.length === 0 ? y : y.filter(
28
+ (e) => n.includes(e.encounterUuid)
29
+ ), [y, n]), { data: _ = [] } = c({
30
+ queryKey: ["observationForms"],
31
+ queryFn: () => ce()
32
+ }), v = f(
33
+ (e) => _.find((r) => r.name === e)?.uuid,
34
+ [_]
35
+ ), b = d(() => {
36
+ if (t)
37
+ return v(t.formName);
38
+ }, [t, v]), {
39
+ isLoading: K,
40
+ isError: x,
41
+ error: g
42
+ } = c({
43
+ queryKey: ["formMetadata", b],
44
+ queryFn: () => fe(b),
45
+ enabled: !!b && l
46
+ }), {
47
+ data: h,
48
+ isLoading: $,
49
+ isError: Q,
50
+ error: p
51
+ } = c({
52
+ queryKey: ["formsEncounterFHIR", t?.encounterUuid],
53
+ queryFn: () => ye(t.encounterUuid),
54
+ enabled: !!t?.encounterUuid && l
55
+ });
56
+ te(
57
+ (e) => {
58
+ e.patientUUID === m && e.updatedConcepts.size > 0 && (H(), j.invalidateQueries({ queryKey: ["formsEncounterFHIR"] }));
59
+ },
60
+ [m]
61
+ );
62
+ const z = d(() => !h?.entry || !t?.formName ? [] : h.entry.filter((e) => e.resource?.resourceType === "Observation").map((e) => e.resource).filter((e) => {
63
+ const r = he(e);
64
+ return !r || r.includes(t.formName);
65
+ }), [h, t?.formName]), G = d(() => {
66
+ if (g)
67
+ return R(g).message;
68
+ if (p)
69
+ return R(p).message;
70
+ }, [g, p]), F = d(
71
+ () => [
72
+ { key: "recordedOn", header: s("RECORDED_ON") },
73
+ { key: "recordedBy", header: s("RECORDED_BY") }
74
+ ],
75
+ [s]
76
+ ), P = d(
77
+ () => [
78
+ { key: "recordedOn", sortable: !0 },
79
+ { key: "recordedBy", sortable: !0 }
80
+ ],
81
+ []
82
+ ), M = d(() => {
83
+ const e = B.reduce(
84
+ (r, a) => {
85
+ const i = a.formName;
86
+ r[i] ??= [];
87
+ const N = a.providers.map((X) => X.providerName).filter(Boolean).join(", ");
88
+ return r[i].push({
89
+ id: a.encounterUuid,
90
+ formName: a.formName,
91
+ recordedOn: se(a.encounterDateTime, s, !0).formattedResult,
92
+ recordedBy: N ?? "--",
93
+ encounterDateTime: a.encounterDateTime,
94
+ encounterUuid: a.encounterUuid
95
+ }), r;
96
+ },
97
+ {}
98
+ );
99
+ return Object.entries(e).map(
100
+ ([r, a]) => ({
101
+ formName: r,
102
+ records: a.sort(
103
+ (i, N) => N.encounterDateTime - i.encounterDateTime
104
+ )
105
+ })
106
+ ).sort((r, a) => r.formName.localeCompare(a.formName));
107
+ }, [B, s]), U = f((e) => {
108
+ E(e), O(!0);
109
+ }, []), Y = f(() => {
110
+ O(!1), E(null);
111
+ }, []), D = f(
112
+ (e, r) => {
113
+ switch (r) {
114
+ case "recordedOn":
115
+ return /* @__PURE__ */ o(oe, { onClick: () => U(e), children: e.recordedOn });
116
+ case "recordedBy":
117
+ return e.recordedBy;
118
+ default:
119
+ return null;
120
+ }
121
+ },
122
+ [U]
123
+ );
124
+ return /* @__PURE__ */ J(W, { children: [
125
+ /* @__PURE__ */ o("div", { "data-testid": "forms-table", children: T || L || M.length === 0 || I ? /* @__PURE__ */ o(
126
+ q,
127
+ {
128
+ headers: F,
129
+ ariaLabel: s("FORMS_HEADING"),
130
+ rows: [],
131
+ loading: T,
132
+ errorStateMessage: L ? w?.message : void 0,
133
+ emptyStateMessage: s("FORMS_UNAVAILABLE"),
134
+ renderCell: D,
135
+ className: A.formsTableBody,
136
+ dataTestId: "forms-table"
137
+ }
138
+ ) : /* @__PURE__ */ o(ne, { align: "start", children: M.map((e, r) => {
139
+ const { formName: a, records: i } = e;
140
+ return /* @__PURE__ */ o(
141
+ de,
142
+ {
143
+ title: a,
144
+ className: A.customAccordianItem,
145
+ testId: `accordian-title-${a}`,
146
+ open: r === 0,
147
+ children: /* @__PURE__ */ o(
148
+ q,
149
+ {
150
+ headers: F,
151
+ ariaLabel: s("FORMS_HEADING"),
152
+ rows: i,
153
+ loading: !1,
154
+ errorStateMessage: "",
155
+ sortable: P,
156
+ emptyStateMessage: s("FORMS_UNAVAILABLE"),
157
+ renderCell: D,
158
+ className: A.formsTableBody,
159
+ dataTestId: `forms-table-${a}`
160
+ }
161
+ )
162
+ },
163
+ a
164
+ );
165
+ }) }) }),
166
+ l && t && /* @__PURE__ */ o(
167
+ ie,
168
+ {
169
+ id: "modalIdForActionAreaLayout",
170
+ portalId: "main-display-area",
171
+ open: l,
172
+ onRequestClose: Y,
173
+ modalHeading: t.formName,
174
+ modalLabel: `${t.recordedOn} | ${t.recordedBy}`,
175
+ passiveModal: !0,
176
+ size: "md",
177
+ testId: "form-details-modal",
178
+ children: /* @__PURE__ */ o(
179
+ ue,
180
+ {
181
+ observations: z,
182
+ isLoading: K || $,
183
+ isError: x || Q,
184
+ errorMessage: G,
185
+ emptyStateMessage: s("NO_FORM_DATA_AVAILABLE"),
186
+ testIdPrefix: t.formName,
187
+ hideThumbnail: V
188
+ }
189
+ )
190
+ }
191
+ )
192
+ ] });
193
+ };
194
+ export {
195
+ Oe as default
196
+ };
@@ -1,5 +1,5 @@
1
- import { c, T as l, P as m, a as u, D as v, Q as i } from "./YPM2AS64-Bpoe3cvd.js";
2
- import { _ as d, $ as f, a0 as e } from "./index-CU8j8cbs.js";
1
+ import { c, T as l, P as m, a as u, D as v, Q as i } from "./YPM2AS64-D8cIIvPg.js";
2
+ import { W as d, X as f, Y as e } from "./index-B7yw-zcZ.js";
3
3
  var p = (a) => {
4
4
  const [r, t] = c({
5
5
  prefix: "TanstackQueryDevtools"
@@ -1,5 +1,5 @@
1
- import { c as s, T as c, P as u, a as i, b as m, C as P, Q as d } from "./YPM2AS64-Bpoe3cvd.js";
2
- import { _ as v, $ as C, a0 as e } from "./index-CU8j8cbs.js";
1
+ import { c as s, T as c, P as u, a as i, b as m, C as P, Q as d } from "./YPM2AS64-D8cIIvPg.js";
2
+ import { W as v, X as C, Y as e } from "./index-B7yw-zcZ.js";
3
3
  var h = (t) => {
4
4
  const [r, o] = s({
5
5
  prefix: "TanstackQueryDevtools"