@uxland/primary-shell 5.6.5 → 5.6.6

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
@@ -11638,11 +11638,14 @@ const areSameDiagnostics = (te, J) => {
11638
11638
  return !1;
11639
11639
  const X = te.map((ne) => ne.codi).sort(), re = J.map((ne) => ne.codi).sort();
11640
11640
  return X.every((ne, oe) => ne === re[oe]);
11641
- }, hasValidDiagnostic = (te) => te != null && typeof te.codi == "string" && typeof te.cataleg == "string" && typeof te.descripcio == "string", hasValidDiagnostics = (te) => te == null ? !0 : Array.isArray(te) && te.every(hasValidDiagnostic), isSameVisit = (te, J) => {
11642
- var oe, de, ce, he, ue, pe, fe, ge, me, ve, be, ye, we, Se, Ce, _e, Ae, Le;
11643
- const X = ((oe = te.professional) == null ? void 0 : oe.id) === ((de = J.professional) == null ? void 0 : de.id) && ((he = (ce = te.professional) == null ? void 0 : ce.role) == null ? void 0 : he.id) === ((pe = (ue = J.professional) == null ? void 0 : ue.role) == null ? void 0 : pe.id) && ((ge = (fe = te.professional) == null ? void 0 : fe.speciality) == null ? void 0 : ge.id) === ((ve = (me = J.professional) == null ? void 0 : me.speciality) == null ? void 0 : ve.id), re = ((be = te.ep) == null ? void 0 : be.id) === ((ye = J.ep) == null ? void 0 : ye.id) && ((we = te.up) == null ? void 0 : we.id) === ((Se = J.up) == null ? void 0 : Se.id) && ((Ce = te.center) == null ? void 0 : Ce.id) === ((_e = J.center) == null ? void 0 : _e.id) && ((Ae = te.service) == null ? void 0 : Ae.id) === ((Le = J.service) == null ? void 0 : Le.id), ne = new Date(te.date).toDateString() === new Date(J.date).toDateString();
11644
- return X && re && ne;
11645
- }, withinEightHours = (te, J) => Math.abs(new Date(te).getTime() - new Date(J).getTime()) <= 8 * 60 * 60 * 1e3;
11641
+ }, hasValidDiagnostic = (te) => te != null && typeof te.codi == "string" && typeof te.cataleg == "string" && typeof te.descripcio == "string", hasValidDiagnostics = (te) => te == null ? !0 : Array.isArray(te) && te.every(hasValidDiagnostic), dateStringCache = /* @__PURE__ */ new Map(), dateObjectCache = /* @__PURE__ */ new Map(), getDateString = (te) => (dateStringCache.has(te) || dateStringCache.set(te, new Date(te).toDateString()), dateStringCache.get(te)), getDateObject = (te) => (dateObjectCache.has(te) || dateObjectCache.set(te, new Date(te)), dateObjectCache.get(te)), createVisitKey = (te) => {
11642
+ var ne, oe, de, ce, he, ue, pe, fe, ge;
11643
+ const J = `${((ne = te.professional) == null ? void 0 : ne.id) || "null"}-${((de = (oe = te.professional) == null ? void 0 : oe.role) == null ? void 0 : de.id) || "null"}-${((he = (ce = te.professional) == null ? void 0 : ce.speciality) == null ? void 0 : he.id) || "null"}`, X = `${((ue = te.ep) == null ? void 0 : ue.id) || "null"}-${((pe = te.up) == null ? void 0 : pe.id) || "null"}-${((fe = te.center) == null ? void 0 : fe.id) || "null"}-${((ge = te.service) == null ? void 0 : ge.id) || "null"}`, re = getDateString(te.date);
11644
+ return `${J}|${X}|${re}`;
11645
+ }, withinEightHours = (te, J) => {
11646
+ const X = getDateObject(te).getTime(), re = getDateObject(J).getTime();
11647
+ return Math.abs(X - re) <= 8 * 60 * 60 * 1e3;
11648
+ };
11646
11649
  function groupByValidDiagnostics(te) {
11647
11650
  te.forEach((J) => {
11648
11651
  const X = [], re = [];
@@ -11667,21 +11670,33 @@ function groupByValidDiagnostics(te) {
11667
11670
  });
11668
11671
  }
11669
11672
  const groupActivityHistoryItems = (te) => {
11670
- const J = [];
11671
- return te == null || te.forEach((X) => {
11672
- let re = !1;
11673
- for (const ne of J) {
11674
- const oe = ne.items[0], de = ne.items[ne.items.length - 1];
11675
- if (isSameVisit(oe, X) && withinEightHours(oe.date, X.date) && withinEightHours(de.date, X.date)) {
11676
- ne.items.push(X), re = !0;
11677
- break;
11673
+ if (!(te != null && te.length)) return [];
11674
+ dateStringCache.clear(), dateObjectCache.clear();
11675
+ const J = /* @__PURE__ */ new Map();
11676
+ te.forEach((re) => {
11677
+ const ne = createVisitKey(re);
11678
+ if (!J.has(ne))
11679
+ J.set(ne, {
11680
+ idGroup: Math.random().toString(36).substr(2, 9),
11681
+ items: [re]
11682
+ });
11683
+ else {
11684
+ const oe = J.get(ne), de = oe.items[0], ce = oe.items[oe.items.length - 1];
11685
+ if (withinEightHours(de.date, re.date) && withinEightHours(ce.date, re.date))
11686
+ oe.items.push(re);
11687
+ else {
11688
+ let he = 1, ue = `${ne}_${he}`;
11689
+ for (; J.has(ue); )
11690
+ he++, ue = `${ne}_${he}`;
11691
+ J.set(ue, {
11692
+ idGroup: Math.random().toString(36).substr(2, 9),
11693
+ items: [re]
11694
+ });
11678
11695
  }
11679
11696
  }
11680
- re || J.push({
11681
- idGroup: Math.random().toString(36).substr(2, 9),
11682
- items: [X]
11683
- });
11684
- }), groupByValidDiagnostics(J), J;
11697
+ });
11698
+ const X = Array.from(J.values());
11699
+ return groupByValidDiagnostics(X), X;
11685
11700
  }, sortGroupsByMostRecentDate = (te) => {
11686
11701
  const J = (oe) => oe.reduce((de, ce) => {
11687
11702
  const he = new Date(ce.date);