@bahmni/services 0.0.1-dev.395 → 0.0.1-dev.401

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 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAU7C,QAAA,MAAM,MAAM,EAAE,aAA8B,CAAC;AAiD7C,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAU7C,QAAA,MAAM,MAAM,EAAE,aAA8B,CAAC;AAkD7C,eAAe,MAAM,CAAC"}
@@ -21,17 +21,20 @@ export declare function getEncounterSessionDuration(): Promise<number>;
21
21
  * Filters encounters to find those belonging to the active visit
22
22
  * @param encounters - Array of encounters to filter
23
23
  * @param patientUUID - Patient UUID
24
+ * @param currentEpisodeEncounterUuids - Array of known encounters UUIDs of current EOC
24
25
  * @returns Promise resolving to encounter within active visit or null
25
26
  */
26
- export declare function filterByActiveVisit(encounters: Encounter[], patientUUID: string): Promise<Encounter | null>;
27
+ export declare function filterByActiveVisit(encounters: Encounter[], patientUUID: string, currentEpisodeEncounterUuids?: string[]): Promise<Encounter | null>;
27
28
  /**
28
29
  * Finds an active encounter within the session duration for a patient and practitioner
29
30
  * @param patientUUID - Patient UUID
30
31
  * @param practitionerUUID - Practitioner UUID (optional, for practitioner-specific sessions)
31
32
  * @param sessionDurationMinutes - Session duration in minutes (optional, will fetch from config if not provided)
33
+ * @param encounterTypeUUID - Encounter type UUID (optional, filters by type)
34
+ * @param currentEpisodeEncounterUuids - The current episode of care's own known encounter UUIDs
32
35
  * @returns Promise resolving to active encounter or null
33
36
  */
34
- export declare function findActiveEncounterInSession(patientUUID: string, practitionerUUID?: string, sessionDurationMinutes?: number, encounterTypeUUID?: string): Promise<Encounter | null>;
37
+ export declare function findActiveEncounterInSession(patientUUID: string, practitionerUUID?: string, sessionDurationMinutes?: number, encounterTypeUUID?: string, currentEpisodeEncounterUuids?: string[]): Promise<Encounter | null>;
35
38
  /**
36
39
  * Checks if there is an active encounter session for a patient and practitioner
37
40
  * @param patientUUID - Patient UUID
@@ -1 +1 @@
1
- {"version":3,"file":"encounterSessionService.d.ts","sourceRoot":"","sources":["../../src/encounterSessionService/encounterSessionService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAU,MAAM,SAAS,CAAC;AAQ5C,UAAU,qBAAqB;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,SAAS,EAAE,CAAC,CAkBtB;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,IAAI,OAAO,CAAC,MAAM,CAAC,CAUnE;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,SAAS,EAAE,EACvB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAkB3B;AAED;;;;;;GAMG;AACH,wBAAsB,4BAA4B,CAChD,WAAW,EAAE,MAAM,EACnB,gBAAgB,CAAC,EAAE,MAAM,EACzB,sBAAsB,CAAC,EAAE,MAAM,EAC/B,iBAAiB,CAAC,EAAE,MAAM,GACzB,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAiC3B;AAED;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,WAAW,EAAE,MAAM,EACnB,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,OAAO,CAAC,CAMlB"}
1
+ {"version":3,"file":"encounterSessionService.d.ts","sourceRoot":"","sources":["../../src/encounterSessionService/encounterSessionService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAU,MAAM,SAAS,CAAC;AAQ5C,UAAU,qBAAqB;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,SAAS,EAAE,CAAC,CAkBtB;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,IAAI,OAAO,CAAC,MAAM,CAAC,CAUnE;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,SAAS,EAAE,EACvB,WAAW,EAAE,MAAM,EACnB,4BAA4B,CAAC,EAAE,MAAM,EAAE,GACtC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAsB3B;AAED;;;;;;;;GAQG;AACH,wBAAsB,4BAA4B,CAChD,WAAW,EAAE,MAAM,EACnB,gBAAgB,CAAC,EAAE,MAAM,EACzB,sBAAsB,CAAC,EAAE,MAAM,EAC/B,iBAAiB,CAAC,EAAE,MAAM,EAC1B,4BAA4B,CAAC,EAAE,MAAM,EAAE,GACtC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAqC3B;AAED;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,WAAW,EAAE,MAAM,EACnB,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,OAAO,CAAC,CAMlB"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/errorHandling/utils.ts"],"names":[],"mappings":"AA2CA,eAAO,MAAM,2BAA2B,4BAA4B,CAAC;AAsBrE;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,OAAO,OAAO,KACb;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CA+FlC,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/errorHandling/utils.ts"],"names":[],"mappings":"AA2CA,eAAO,MAAM,2BAA2B,4BAA4B,CAAC;AAsBrE;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,OAAO,OAAO,KACb;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAqGlC,CAAC"}
package/dist/index.js CHANGED
@@ -2267,26 +2267,26 @@ function yi(t) {
2267
2267
  return yi(ot(t, s));
2268
2268
  }, r;
2269
2269
  }
2270
- const me = yi(Gt);
2271
- me.Axios = rt;
2272
- me.CanceledError = Kt;
2273
- me.CancelToken = Sl;
2274
- me.isCancel = li;
2275
- me.VERSION = ms;
2276
- me.toFormData = nn;
2277
- me.AxiosError = z;
2278
- me.Cancel = me.CanceledError;
2279
- me.all = function(e) {
2270
+ const he = yi(Gt);
2271
+ he.Axios = rt;
2272
+ he.CanceledError = Kt;
2273
+ he.CancelToken = Sl;
2274
+ he.isCancel = li;
2275
+ he.VERSION = ms;
2276
+ he.toFormData = nn;
2277
+ he.AxiosError = z;
2278
+ he.Cancel = he.CanceledError;
2279
+ he.all = function(e) {
2280
2280
  return Promise.all(e);
2281
2281
  };
2282
- me.spread = Ol;
2283
- me.isAxiosError = Al;
2284
- me.mergeConfig = ot;
2285
- me.AxiosHeaders = Pe;
2286
- me.formToJSON = (t) => ui(A.isHTMLForm(t) ? new FormData(t) : t);
2287
- me.getAdapter = mi.getAdapter;
2288
- me.HttpStatusCode = Qn;
2289
- me.default = me;
2282
+ he.spread = Ol;
2283
+ he.isAxiosError = Al;
2284
+ he.mergeConfig = ot;
2285
+ he.AxiosHeaders = Pe;
2286
+ he.formToJSON = (t) => ui(A.isHTMLForm(t) ? new FormData(t) : t);
2287
+ he.getAdapter = mi.getAdapter;
2288
+ he.HttpStatusCode = Qn;
2289
+ he.default = he;
2290
2290
  const {
2291
2291
  Axios: Xw,
2292
2292
  AxiosError: Zw,
@@ -2305,7 +2305,7 @@ const {
2305
2305
  getAdapter: fE,
2306
2306
  mergeConfig: pE,
2307
2307
  create: hE
2308
- } = me, Pl = (t) => typeof t == "object" && t !== null && "resourceType" in t && t.resourceType === "OperationOutcome", Nl = (t) => {
2308
+ } = he, Pl = (t) => typeof t == "object" && t !== null && "resourceType" in t && t.resourceType === "OperationOutcome", Nl = (t) => {
2309
2309
  if (!t.issue || !Array.isArray(t.issue))
2310
2310
  return null;
2311
2311
  for (const e of t.issue)
@@ -2318,7 +2318,7 @@ const {
2318
2318
  return { title: e, message: r };
2319
2319
  if (typeof t == "string")
2320
2320
  r = t;
2321
- else if (me.isAxiosError(t)) {
2321
+ else if (he.isAxiosError(t)) {
2322
2322
  const n = t;
2323
2323
  if (n?.response) {
2324
2324
  const s = n.response.status, o = n.response.config ?? n.config;
@@ -2341,9 +2341,12 @@ const {
2341
2341
  case 401:
2342
2342
  e = "Unauthorized", r = "You are not authorized to perform this action. Please log in again.";
2343
2343
  break;
2344
- case 403:
2345
- e = "Unauthorized", r = "You are not authorized to perform this action. Please log in again.";
2344
+ case 403: {
2345
+ e = "Forbidden";
2346
+ const a = n.response.data;
2347
+ r = a?.error?.message ?? a?.message ?? "You are not authorized to perform this action.";
2346
2348
  break;
2349
+ }
2347
2350
  case 404:
2348
2351
  e = "Not Found", r = "The requested resource was not found.";
2349
2352
  break;
@@ -2487,15 +2490,15 @@ const Bl = process.env.PUBLIC_URL ?? "/", ne = "/openmrs/ws/fhir2/R4", W = "/ope
2487
2490
  return e;
2488
2491
  }
2489
2492
  return t;
2490
- }, Gl = (t) => t.includes("/openmrs/ws"), Kl = (t) => t.includes(Es), Wl = (t) => t.url ?? t.baseURL ?? "", Ke = me.create();
2493
+ }, Gl = (t) => t.includes("/openmrs/ws"), Kl = (t) => t.includes(Es), Wl = (t) => t.url ?? t.baseURL ?? "", Ke = he.create();
2491
2494
  Ke.defaults.headers.common["Content-Type"] = "application/json";
2492
2495
  Ke.interceptors.request.use(
2493
2496
  function(t) {
2494
2497
  return t;
2495
2498
  },
2496
2499
  function(t) {
2497
- const { title: e, message: r } = Yr(t);
2498
- return Promise.reject(`${e}: ${r}`);
2500
+ const { message: e } = Yr(t);
2501
+ throw new Error(e);
2499
2502
  }
2500
2503
  );
2501
2504
  Ke.interceptors.response.use(
@@ -2504,15 +2507,21 @@ Ke.interceptors.response.use(
2504
2507
  const e = Wl(t.config);
2505
2508
  return Gl(e) && !Kl(e) && !Cl.includes(t.config.responseType) && (t.data = Xn(t.data)), t;
2506
2509
  } catch (e) {
2507
- const { title: r, message: n } = Yr(e);
2508
- return Promise.reject(`${r}: ${n}`);
2510
+ const { message: r } = Yr(e);
2511
+ throw new Error(r);
2509
2512
  }
2510
2513
  },
2511
- function(t) {
2512
- if (me.isAxiosError(t) && t.response?.status === 401)
2513
- return globalThis.location.href = Ei, Promise.reject(t);
2514
- const { title: e, message: r } = Yr(t);
2515
- return r.startsWith("ERROR_") || /^[A-Z_]+$/.test(r) ? Promise.reject(new Error(r)) : Promise.reject(`${e}: ${r}`);
2514
+ async function(t) {
2515
+ if (he.isAxiosError(t) && t.response?.status === 401)
2516
+ throw globalThis.location.href = Ei, t;
2517
+ if (he.isAxiosError(t) && t.response?.data instanceof Blob)
2518
+ try {
2519
+ const r = await t.response.data.text();
2520
+ t.response.data = JSON.parse(r);
2521
+ } catch {
2522
+ }
2523
+ const { message: e } = Yr(t);
2524
+ throw new Error(e);
2516
2525
  }
2517
2526
  );
2518
2527
  const B = async (t, e) => (await Ke.get(t, e)).data, ge = async (t, e) => (await Ke.post(t, e)).data, Ti = async (t, e) => (await Ke.put(t, e)).data, gE = async (t, e) => (await Ke.patch(t, e)).data, Ri = async (t) => (await Ke.delete(t)).data, Q = (t) => typeof t == "string", It = () => {
@@ -6235,7 +6244,7 @@ function _e(t, e) {
6235
6244
  rest: t.rest
6236
6245
  };
6237
6246
  }
6238
- function he(t, e) {
6247
+ function me(t, e) {
6239
6248
  const r = e.match(t);
6240
6249
  return r ? {
6241
6250
  value: parseInt(r[0], 10),
@@ -6258,34 +6267,34 @@ function qe(t, e) {
6258
6267
  };
6259
6268
  }
6260
6269
  function Ji(t) {
6261
- return he(Ee.anyDigitsSigned, t);
6270
+ return me(Ee.anyDigitsSigned, t);
6262
6271
  }
6263
6272
  function we(t, e) {
6264
6273
  switch (t) {
6265
6274
  case 1:
6266
- return he(Ee.singleDigit, e);
6275
+ return me(Ee.singleDigit, e);
6267
6276
  case 2:
6268
- return he(Ee.twoDigits, e);
6277
+ return me(Ee.twoDigits, e);
6269
6278
  case 3:
6270
- return he(Ee.threeDigits, e);
6279
+ return me(Ee.threeDigits, e);
6271
6280
  case 4:
6272
- return he(Ee.fourDigits, e);
6281
+ return me(Ee.fourDigits, e);
6273
6282
  default:
6274
- return he(new RegExp("^\\d{1," + t + "}"), e);
6283
+ return me(new RegExp("^\\d{1," + t + "}"), e);
6275
6284
  }
6276
6285
  }
6277
6286
  function Zr(t, e) {
6278
6287
  switch (t) {
6279
6288
  case 1:
6280
- return he(Ee.singleDigitSigned, e);
6289
+ return me(Ee.singleDigitSigned, e);
6281
6290
  case 2:
6282
- return he(Ee.twoDigitsSigned, e);
6291
+ return me(Ee.twoDigitsSigned, e);
6283
6292
  case 3:
6284
- return he(Ee.threeDigitsSigned, e);
6293
+ return me(Ee.threeDigitsSigned, e);
6285
6294
  case 4:
6286
- return he(Ee.fourDigitsSigned, e);
6295
+ return me(Ee.fourDigitsSigned, e);
6287
6296
  default:
6288
- return he(new RegExp("^-?\\d{1," + t + "}"), e);
6297
+ return me(new RegExp("^-?\\d{1," + t + "}"), e);
6289
6298
  }
6290
6299
  }
6291
6300
  function Os(t) {
@@ -6594,7 +6603,7 @@ class Jp extends ue {
6594
6603
  // 1, 2, ..., 12
6595
6604
  case "M":
6596
6605
  return _e(
6597
- he(Ee.month, e),
6606
+ me(Ee.month, e),
6598
6607
  s
6599
6608
  );
6600
6609
  // 01, 02, ..., 12
@@ -6642,7 +6651,7 @@ class Qp extends ue {
6642
6651
  // 1, 2, ..., 12
6643
6652
  case "L":
6644
6653
  return _e(
6645
- he(Ee.month, e),
6654
+ me(Ee.month, e),
6646
6655
  s
6647
6656
  );
6648
6657
  // 01, 02, ..., 12
@@ -6706,7 +6715,7 @@ class Zp extends ue {
6706
6715
  parse(e, r, n) {
6707
6716
  switch (r) {
6708
6717
  case "w":
6709
- return he(Ee.week, e);
6718
+ return me(Ee.week, e);
6710
6719
  case "wo":
6711
6720
  return n.ordinalNumber(e, { unit: "week" });
6712
6721
  default:
@@ -6744,7 +6753,7 @@ class th extends ue {
6744
6753
  parse(e, r, n) {
6745
6754
  switch (r) {
6746
6755
  case "I":
6747
- return he(Ee.week, e);
6756
+ return me(Ee.week, e);
6748
6757
  case "Io":
6749
6758
  return n.ordinalNumber(e, { unit: "week" });
6750
6759
  default:
@@ -6794,7 +6803,7 @@ class sh extends ue {
6794
6803
  parse(e, r, n) {
6795
6804
  switch (r) {
6796
6805
  case "d":
6797
- return he(Ee.date, e);
6806
+ return me(Ee.date, e);
6798
6807
  case "do":
6799
6808
  return n.ordinalNumber(e, { unit: "date" });
6800
6809
  default:
@@ -6830,7 +6839,7 @@ class oh extends ue {
6830
6839
  switch (r) {
6831
6840
  case "D":
6832
6841
  case "DD":
6833
- return he(Ee.dayOfYear, e);
6842
+ return me(Ee.dayOfYear, e);
6834
6843
  case "Do":
6835
6844
  return n.ordinalNumber(e, { unit: "date" });
6836
6845
  default:
@@ -7245,7 +7254,7 @@ class hh extends ue {
7245
7254
  parse(e, r, n) {
7246
7255
  switch (r) {
7247
7256
  case "h":
7248
- return he(Ee.hour12h, e);
7257
+ return me(Ee.hour12h, e);
7249
7258
  case "ho":
7250
7259
  return n.ordinalNumber(e, { unit: "hour" });
7251
7260
  default:
@@ -7266,7 +7275,7 @@ class mh extends ue {
7266
7275
  parse(e, r, n) {
7267
7276
  switch (r) {
7268
7277
  case "H":
7269
- return he(Ee.hour23h, e);
7278
+ return me(Ee.hour23h, e);
7270
7279
  case "Ho":
7271
7280
  return n.ordinalNumber(e, { unit: "hour" });
7272
7281
  default:
@@ -7286,7 +7295,7 @@ class gh extends ue {
7286
7295
  parse(e, r, n) {
7287
7296
  switch (r) {
7288
7297
  case "K":
7289
- return he(Ee.hour11h, e);
7298
+ return me(Ee.hour11h, e);
7290
7299
  case "Ko":
7291
7300
  return n.ordinalNumber(e, { unit: "hour" });
7292
7301
  default:
@@ -7306,7 +7315,7 @@ class yh extends ue {
7306
7315
  parse(e, r, n) {
7307
7316
  switch (r) {
7308
7317
  case "k":
7309
- return he(Ee.hour24h, e);
7318
+ return me(Ee.hour24h, e);
7310
7319
  case "ko":
7311
7320
  return n.ordinalNumber(e, { unit: "hour" });
7312
7321
  default:
@@ -7327,7 +7336,7 @@ class wh extends ue {
7327
7336
  parse(e, r, n) {
7328
7337
  switch (r) {
7329
7338
  case "m":
7330
- return he(Ee.minute, e);
7339
+ return me(Ee.minute, e);
7331
7340
  case "mo":
7332
7341
  return n.ordinalNumber(e, { unit: "minute" });
7333
7342
  default:
@@ -7347,7 +7356,7 @@ class Eh extends ue {
7347
7356
  parse(e, r, n) {
7348
7357
  switch (r) {
7349
7358
  case "s":
7350
- return he(Ee.second, e);
7359
+ return me(Ee.second, e);
7351
7360
  case "so":
7352
7361
  return n.ordinalNumber(e, { unit: "second" });
7353
7362
  default:
@@ -13454,30 +13463,34 @@ async function yc() {
13454
13463
  return 30;
13455
13464
  }
13456
13465
  }
13457
- async function nw(t, e) {
13466
+ async function nw(t, e, r) {
13458
13467
  if (!t.length) return null;
13459
13468
  try {
13460
- const r = await mn(e);
13461
- return r ? t.find((n) => {
13462
- const s = n.partOf?.reference?.split("/")[1];
13463
- return r.id === s;
13469
+ const n = await mn(e);
13470
+ return n ? t.find((s) => {
13471
+ const o = s.partOf?.reference?.split("/")[1];
13472
+ return n.id !== o ? !1 : r ? !!s.id && r.includes(s.id) : !0;
13464
13473
  }) ?? null : null;
13465
13474
  } catch {
13466
13475
  return null;
13467
13476
  }
13468
13477
  }
13469
- async function Jb(t, e, r, n) {
13478
+ async function Jb(t, e, r, n, s) {
13470
13479
  try {
13471
13480
  if (!t) return null;
13472
- const s = r ?? await yc(), a = `ge${new Date(Date.now() - s * 60 * 1e3).toISOString()}`, i = {
13481
+ const o = r ?? await yc(), i = `ge${new Date(Date.now() - o * 60 * 1e3).toISOString()}`, c = {
13473
13482
  patient: t,
13474
13483
  _tag: "encounter",
13475
- _lastUpdated: a,
13484
+ _lastUpdated: i,
13476
13485
  type: n
13477
13486
  };
13478
- e && (i.participant = e);
13479
- const c = await os(i);
13480
- return c.length === 0 ? null : await nw(c, t);
13487
+ e && (c.participant = e);
13488
+ const u = await os(c);
13489
+ return u.length === 0 ? null : await nw(
13490
+ u,
13491
+ t,
13492
+ s
13493
+ );
13481
13494
  } catch {
13482
13495
  return null;
13483
13496
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bahmni/services",
3
- "version": "0.0.1-dev.395",
3
+ "version": "0.0.1-dev.401",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",