@eka-care/medical-records-ui 1.2.3 → 1.2.5
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 +39 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2125,7 +2125,8 @@ var SmartRecordsSidebar = _react.memo.call(void 0, function SmartRecordsSidebar2
|
|
|
2125
2125
|
onRefresh,
|
|
2126
2126
|
isRefreshing,
|
|
2127
2127
|
openDayKey = null,
|
|
2128
|
-
onSelectVisitDay = noop2
|
|
2128
|
+
onSelectVisitDay = noop2,
|
|
2129
|
+
onViewByChange = noop2
|
|
2129
2130
|
}) {
|
|
2130
2131
|
const { store } = _chunkTAUICEVAjs.useSdk.call(void 0, );
|
|
2131
2132
|
const { selectRecord } = _chunkZJMFXE5Rjs.useSmartRecordsActions.call(void 0, );
|
|
@@ -2183,10 +2184,14 @@ var SmartRecordsSidebar = _react.memo.call(void 0, function SmartRecordsSidebar2
|
|
|
2183
2184
|
setCollapsed((c) => !c);
|
|
2184
2185
|
}, []);
|
|
2185
2186
|
const toggleBucket = _react.useCallback.call(void 0, () => setBucketOpen((o) => !o), []);
|
|
2186
|
-
const handleViewByChange = _react.useCallback.call(void 0,
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2187
|
+
const handleViewByChange = _react.useCallback.call(void 0,
|
|
2188
|
+
(next) => {
|
|
2189
|
+
setBucketOpen(false);
|
|
2190
|
+
setChosenView(next);
|
|
2191
|
+
onViewByChange(next);
|
|
2192
|
+
},
|
|
2193
|
+
[onViewByChange]
|
|
2194
|
+
);
|
|
2190
2195
|
const openSearch = _react.useCallback.call(void 0, () => {
|
|
2191
2196
|
setBucketOpen(false);
|
|
2192
2197
|
setSearchOpen(true);
|
|
@@ -2435,6 +2440,11 @@ var SmartUploadModal2 = _react.lazy.call(void 0,
|
|
|
2435
2440
|
default: m.SmartUploadModal
|
|
2436
2441
|
}))
|
|
2437
2442
|
);
|
|
2443
|
+
function newestRecord(state) {
|
|
2444
|
+
const records = state.records.ids.map((id) => state.records.byId[id]).filter((r) => !!r);
|
|
2445
|
+
if (records.length === 0) return null;
|
|
2446
|
+
return records.reduce((newest, r) => r.createdAtEpoch > newest.createdAtEpoch ? r : newest);
|
|
2447
|
+
}
|
|
2438
2448
|
function SmartRecordsView(props) {
|
|
2439
2449
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SmartRecordsViewInner, { ...props });
|
|
2440
2450
|
}
|
|
@@ -2551,12 +2561,32 @@ function SmartRecordsViewInner({
|
|
|
2551
2561
|
return;
|
|
2552
2562
|
}
|
|
2553
2563
|
if (casesStatus === "idle" || casesStatus === "loading") return;
|
|
2554
|
-
const
|
|
2555
|
-
if (
|
|
2556
|
-
const latest = records.reduce((newest, r) => r.createdAtEpoch > newest.createdAtEpoch ? r : newest);
|
|
2564
|
+
const latest = newestRecord(state);
|
|
2565
|
+
if (!latest) return;
|
|
2557
2566
|
didInitRef.current = true;
|
|
2558
2567
|
selectRecord(latest.id, latest.isSmart);
|
|
2559
2568
|
}, [recordsCount, store, handleSelectCase, selectRecord, casesStatus]);
|
|
2569
|
+
const handleViewByChange = _react.useCallback.call(void 0,
|
|
2570
|
+
(view) => {
|
|
2571
|
+
const state = store.getState();
|
|
2572
|
+
if (view === "care-contexts") {
|
|
2573
|
+
const firstCaseId = state.cases.ids[0];
|
|
2574
|
+
if (firstCaseId) handleSelectCase(firstCaseId);
|
|
2575
|
+
else handleClearCaseSelection();
|
|
2576
|
+
return;
|
|
2577
|
+
}
|
|
2578
|
+
if (view === "visits") {
|
|
2579
|
+
const newestDay = timelineDays.find((d) => d.recordCount > 0);
|
|
2580
|
+
if (newestDay) handleSelectVisitDay(newestDay.dayKey);
|
|
2581
|
+
else handleClearCaseSelection();
|
|
2582
|
+
return;
|
|
2583
|
+
}
|
|
2584
|
+
const latest = newestRecord(state);
|
|
2585
|
+
handleClearCaseSelection();
|
|
2586
|
+
if (latest) selectRecord(latest.id, latest.isSmart);
|
|
2587
|
+
},
|
|
2588
|
+
[store, timelineDays, handleSelectCase, handleClearCaseSelection, handleSelectVisitDay, selectRecord]
|
|
2589
|
+
);
|
|
2560
2590
|
const openUpload = _react.useCallback.call(void 0, () => setUploadOpen(true), []);
|
|
2561
2591
|
const closeUpload = _react.useCallback.call(void 0, () => setUploadOpen(false), []);
|
|
2562
2592
|
const handleConfirmDelete = _react.useCallback.call(void 0, async () => {
|
|
@@ -2648,6 +2678,7 @@ function SmartRecordsViewInner({
|
|
|
2648
2678
|
openRecordId: "recordId" in mainView ? mainView.recordId : null,
|
|
2649
2679
|
openDayKey,
|
|
2650
2680
|
onSelectVisitDay: handleSelectVisitDay,
|
|
2681
|
+
onViewByChange: handleViewByChange,
|
|
2651
2682
|
onRefresh: handleRefresh,
|
|
2652
2683
|
isRefreshing: recordsStatus === "loading",
|
|
2653
2684
|
sourceRefreshedAt,
|