@eka-care/medical-records-ui 1.2.9 → 1.2.11
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 +68 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2910,11 +2910,55 @@ function toCollectionFilter(filters) {
|
|
|
2910
2910
|
if (filters.types.length) filter.documentType = filters.types;
|
|
2911
2911
|
if (filters.documentDateFrom != null) filter.dateFrom = toSeconds(filters.documentDateFrom);
|
|
2912
2912
|
if (filters.documentDateTo != null) filter.dateTo = toSeconds(filters.documentDateTo);
|
|
2913
|
-
const search = filters.search.trim();
|
|
2914
|
-
if (search) filter.search = search;
|
|
2915
2913
|
return Object.keys(filter).length ? filter : void 0;
|
|
2916
2914
|
}
|
|
2917
2915
|
|
|
2916
|
+
// src/views/hooks/smart-records/searchCollection.ts
|
|
2917
|
+
var isRecord = (item) => "document_id" in item.data;
|
|
2918
|
+
function recordText(data, labelOf) {
|
|
2919
|
+
return [_nullishCoalesce(_optionalChain([data, 'access', _207 => _207.metadata, 'optionalAccess', _208 => _208.title]), () => ( "")), labelOf(_nullishCoalesce(data.document_type, () => ( ""))), ..._nullishCoalesce(_optionalChain([data, 'access', _209 => _209.metadata, 'optionalAccess', _210 => _210.tags]), () => ( []))];
|
|
2920
|
+
}
|
|
2921
|
+
function caseText(item) {
|
|
2922
|
+
return [_nullishCoalesce(_nullishCoalesce(item.title, () => ( _optionalChain([item, 'access', _211 => _211.data, 'access', _212 => _212.item, 'optionalAccess', _213 => _213.display_name]))), () => ( ""))];
|
|
2923
|
+
}
|
|
2924
|
+
function searchCollection(groups, query, labelOf) {
|
|
2925
|
+
const q = query.trim().toLowerCase();
|
|
2926
|
+
if (!q) return groups;
|
|
2927
|
+
const has = (texts) => texts.some((t) => t.toLowerCase().includes(q));
|
|
2928
|
+
const nameMatchedCases = /* @__PURE__ */ new Set();
|
|
2929
|
+
const matchedRecordsByCase = /* @__PURE__ */ new Map();
|
|
2930
|
+
const selfMatchedRecords = /* @__PURE__ */ new Set();
|
|
2931
|
+
for (const group of groups) {
|
|
2932
|
+
for (const item of group.items) {
|
|
2933
|
+
if (isRecord(item)) {
|
|
2934
|
+
if (!has(recordText(item.data, labelOf))) continue;
|
|
2935
|
+
selfMatchedRecords.add(item.id);
|
|
2936
|
+
for (const caseId of _nullishCoalesce(item.data.cases, () => ( []))) {
|
|
2937
|
+
const list = matchedRecordsByCase.get(caseId);
|
|
2938
|
+
if (list) list.push(item.id);
|
|
2939
|
+
else matchedRecordsByCase.set(caseId, [item.id]);
|
|
2940
|
+
}
|
|
2941
|
+
} else if (has(caseText(item))) {
|
|
2942
|
+
nameMatchedCases.add(item.id);
|
|
2943
|
+
}
|
|
2944
|
+
}
|
|
2945
|
+
}
|
|
2946
|
+
const keepRecord = (item) => selfMatchedRecords.has(item.id) || (_nullishCoalesce(item.data.cases, () => ( []))).some((id) => nameMatchedCases.has(id));
|
|
2947
|
+
const keepCase = (item) => {
|
|
2948
|
+
if (nameMatchedCases.has(item.id)) return item;
|
|
2949
|
+
const matched2 = matchedRecordsByCase.get(item.id);
|
|
2950
|
+
return matched2 ? { ...item, matchedRecordIds: matched2 } : null;
|
|
2951
|
+
};
|
|
2952
|
+
return groups.map((group) => ({
|
|
2953
|
+
...group,
|
|
2954
|
+
items: group.items.flatMap((item) => {
|
|
2955
|
+
if (isRecord(item)) return keepRecord(item) ? [item] : [];
|
|
2956
|
+
const kept = keepCase(item);
|
|
2957
|
+
return kept ? [kept] : [];
|
|
2958
|
+
})
|
|
2959
|
+
})).filter((group) => group.items.length > 0);
|
|
2960
|
+
}
|
|
2961
|
+
|
|
2918
2962
|
// src/views/hooks/smart-records/sidebarCollection.ts
|
|
2919
2963
|
var ROW_KIND = { Record: "record", Case: "case" };
|
|
2920
2964
|
var UNKNOWN_KEY = "unknown";
|
|
@@ -2961,10 +3005,10 @@ function buildSidebarRows(groups, labelOf) {
|
|
|
2961
3005
|
kind: ROW_KIND.Case,
|
|
2962
3006
|
id: item.id,
|
|
2963
3007
|
date: _nullishCoalesce(newest, () => ( item.date)),
|
|
2964
|
-
title: item.title || _optionalChain([data, 'access',
|
|
3008
|
+
title: item.title || _optionalChain([data, 'access', _214 => _214.item, 'optionalAccess', _215 => _215.display_name]) || "Untitled case",
|
|
2965
3009
|
typeCode: "",
|
|
2966
3010
|
isSmart: false,
|
|
2967
|
-
caseTypeCode: _nullishCoalesce(_optionalChain([data, 'access',
|
|
3011
|
+
caseTypeCode: _nullishCoalesce(_optionalChain([data, 'access', _216 => _216.item, 'optionalAccess', _217 => _217.type]), () => ( "")),
|
|
2968
3012
|
recordCount: linked.length,
|
|
2969
3013
|
...matched2 ? { matchCount: matched2.length } : {}
|
|
2970
3014
|
};
|
|
@@ -3010,13 +3054,14 @@ function useSidebarCollection({ limit } = {}) {
|
|
|
3010
3054
|
const { store, labelOf } = _chunk7XNJKV4Hjs.useSdk.call(void 0, );
|
|
3011
3055
|
const groups = _zustand.useStore.call(void 0, store, (s) => s.collection.groups);
|
|
3012
3056
|
const filters = _zustand.useStore.call(void 0, store, (s) => s.filters);
|
|
3013
|
-
const
|
|
3057
|
+
const searched = _react.useMemo.call(void 0, () => searchCollection(groups, filters.search, labelOf), [groups, filters.search, labelOf]);
|
|
3058
|
+
const rows = _react.useMemo.call(void 0, () => buildSidebarRows(searched, labelOf), [searched, labelOf]);
|
|
3014
3059
|
const months = _react.useMemo.call(void 0, () => groupRowsByMonth(limit === void 0 ? rows : rows.slice(0, limit)), [rows, limit]);
|
|
3015
3060
|
return {
|
|
3016
3061
|
rows,
|
|
3017
3062
|
months,
|
|
3018
|
-
latestId: _nullishCoalesce(_optionalChain([rows, 'access',
|
|
3019
|
-
matchingRecordCount: _react.useMemo.call(void 0, () => countRecordItems(
|
|
3063
|
+
latestId: _nullishCoalesce(_optionalChain([rows, 'access', _218 => _218[0], 'optionalAccess', _219 => _219.id]), () => ( null)),
|
|
3064
|
+
matchingRecordCount: _react.useMemo.call(void 0, () => countRecordItems(searched), [searched]),
|
|
3020
3065
|
hasActiveFilter: hasSidebarFilter(filters),
|
|
3021
3066
|
search: filters.search
|
|
3022
3067
|
};
|
|
@@ -3124,12 +3169,11 @@ function useRecordsConnection() {
|
|
|
3124
3169
|
function useCollectionConnection(enabled = true) {
|
|
3125
3170
|
const { bid, patientId, store } = _chunk7XNJKV4Hjs.useSdk.call(void 0, );
|
|
3126
3171
|
const loadedKeyRef = _react.useRef.call(void 0, null);
|
|
3127
|
-
const search = _zustand.useStore.call(void 0, store, (s) => s.filters.search);
|
|
3128
3172
|
const types = _zustand.useStore.call(void 0, store, (s) => s.filters.types);
|
|
3129
3173
|
const documentDateFrom = _zustand.useStore.call(void 0, store, (s) => s.filters.documentDateFrom);
|
|
3130
3174
|
const documentDateTo = _zustand.useStore.call(void 0, store, (s) => s.filters.documentDateTo);
|
|
3131
|
-
const filterRef = _react.useRef.call(void 0, toCollectionFilter({
|
|
3132
|
-
filterRef.current = toCollectionFilter({
|
|
3175
|
+
const filterRef = _react.useRef.call(void 0, toCollectionFilter({ types, documentDateFrom, documentDateTo }));
|
|
3176
|
+
filterRef.current = toCollectionFilter({ types, documentDateFrom, documentDateTo });
|
|
3133
3177
|
const apply = _react.useCallback.call(void 0,
|
|
3134
3178
|
(groups) => store.getState().collection.setGroups(groups),
|
|
3135
3179
|
[store]
|
|
@@ -3177,7 +3221,7 @@ function useCollectionConnection(enabled = true) {
|
|
|
3177
3221
|
return;
|
|
3178
3222
|
}
|
|
3179
3223
|
reload();
|
|
3180
|
-
}, [enabled,
|
|
3224
|
+
}, [enabled, types, documentDateFrom, documentDateTo, reload]);
|
|
3181
3225
|
_react.useEffect.call(void 0, () => {
|
|
3182
3226
|
if (!enabled) return;
|
|
3183
3227
|
const unsubscribeDocs = _chunk7XNJKV4Hjs.getCore.call(void 0, ).subscribe("documents:changed", reload);
|
|
@@ -3197,7 +3241,7 @@ function resolveContentType(file) {
|
|
|
3197
3241
|
if (t === "image/jpeg" || t === "image/jpg" || t === "image/png" || t === "application/pdf") {
|
|
3198
3242
|
return t;
|
|
3199
3243
|
}
|
|
3200
|
-
const ext = _optionalChain([file, 'access',
|
|
3244
|
+
const ext = _optionalChain([file, 'access', _220 => _220.name, 'access', _221 => _221.split, 'call', _222 => _222("."), 'access', _223 => _223.pop, 'call', _224 => _224(), 'optionalAccess', _225 => _225.toLowerCase, 'call', _226 => _226()]);
|
|
3201
3245
|
if (ext === "pdf") return "application/pdf";
|
|
3202
3246
|
if (ext === "png") return "image/png";
|
|
3203
3247
|
if (ext === "jpg" || ext === "jpeg") return "image/jpeg";
|
|
@@ -3236,12 +3280,12 @@ function useUploadConnection() {
|
|
|
3236
3280
|
patientId
|
|
3237
3281
|
});
|
|
3238
3282
|
const queue2 = store.getState().uploadQueue;
|
|
3239
|
-
if (res.message === "queued_offline" || !_optionalChain([res, 'access',
|
|
3283
|
+
if (res.message === "queued_offline" || !_optionalChain([res, 'access', _227 => _227.batch_response, 'optionalAccess', _228 => _228.length])) {
|
|
3240
3284
|
throw new Error("No internet connection. Your upload will retry automatically when you're back online.");
|
|
3241
3285
|
}
|
|
3242
3286
|
localIds.forEach((id, i) => {
|
|
3243
|
-
const documentId = _nullishCoalesce(_optionalChain([res, 'access',
|
|
3244
|
-
const errorDetails = _optionalChain([res, 'access',
|
|
3287
|
+
const documentId = _nullishCoalesce(_optionalChain([res, 'access', _229 => _229.batch_response, 'optionalAccess', _230 => _230[i], 'optionalAccess', _231 => _231.document_id]), () => ( ""));
|
|
3288
|
+
const errorDetails = _optionalChain([res, 'access', _232 => _232.batch_response, 'optionalAccess', _233 => _233[i], 'optionalAccess', _234 => _234.error_details]);
|
|
3245
3289
|
if (errorDetails) {
|
|
3246
3290
|
queue2.markFailed(id);
|
|
3247
3291
|
} else {
|
|
@@ -3384,7 +3428,7 @@ function useFilteredRecordIds2() {
|
|
|
3384
3428
|
|
|
3385
3429
|
|
|
3386
3430
|
var HighlightedText = _react.memo.call(void 0, function HighlightedText2({ text, query }) {
|
|
3387
|
-
const q = _nullishCoalesce(_optionalChain([query, 'optionalAccess',
|
|
3431
|
+
const q = _nullishCoalesce(_optionalChain([query, 'optionalAccess', _235 => _235.trim, 'call', _236 => _236(), 'access', _237 => _237.toLowerCase, 'call', _238 => _238()]), () => ( ""));
|
|
3388
3432
|
const start = q ? text.toLowerCase().indexOf(q) : -1;
|
|
3389
3433
|
if (start < 0) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: text });
|
|
3390
3434
|
const end = start + q.length;
|
|
@@ -3553,7 +3597,7 @@ var SidebarSearchField = _react.memo.call(void 0, function SidebarSearchField2({
|
|
|
3553
3597
|
function summarize(options, value) {
|
|
3554
3598
|
if (value.length === 0) return "All";
|
|
3555
3599
|
if (value.length > 2) return `${value.length} types`;
|
|
3556
|
-
return value.map((id) => _nullishCoalesce(_optionalChain([options, 'access',
|
|
3600
|
+
return value.map((id) => _nullishCoalesce(_optionalChain([options, 'access', _239 => _239.find, 'call', _240 => _240((o) => o.id === id), 'optionalAccess', _241 => _241.display_name]), () => ( id))).join(", ");
|
|
3557
3601
|
}
|
|
3558
3602
|
function SidebarTypeSelect({ options, value, onChange }) {
|
|
3559
3603
|
const [open, setOpen] = _react.useState.call(void 0, false);
|
|
@@ -3562,7 +3606,7 @@ function SidebarTypeSelect({ options, value, onChange }) {
|
|
|
3562
3606
|
_react.useEffect.call(void 0, () => {
|
|
3563
3607
|
if (!open) return;
|
|
3564
3608
|
const onMouseDown = (e) => {
|
|
3565
|
-
if (!_optionalChain([rootRef, 'access',
|
|
3609
|
+
if (!_optionalChain([rootRef, 'access', _242 => _242.current, 'optionalAccess', _243 => _243.contains, 'call', _244 => _244(e.target)])) setOpen(false);
|
|
3566
3610
|
};
|
|
3567
3611
|
document.addEventListener("mousedown", onMouseDown);
|
|
3568
3612
|
return () => document.removeEventListener("mousedown", onMouseDown);
|
|
@@ -3636,7 +3680,7 @@ function SidebarFilterPopover({ containerRef, onClose }) {
|
|
|
3636
3680
|
}));
|
|
3637
3681
|
_react.useEffect.call(void 0, () => {
|
|
3638
3682
|
const handler = (e) => {
|
|
3639
|
-
if (_optionalChain([containerRef, 'access',
|
|
3683
|
+
if (_optionalChain([containerRef, 'access', _245 => _245.current, 'optionalAccess', _246 => _246.contains, 'call', _247 => _247(e.target)])) return;
|
|
3640
3684
|
onClose();
|
|
3641
3685
|
};
|
|
3642
3686
|
document.addEventListener("mousedown", handler);
|
|
@@ -4030,24 +4074,24 @@ function SmartRecordsViewInner({
|
|
|
4030
4074
|
onToastRef.current = onToast;
|
|
4031
4075
|
onViewChangeRef.current = onViewChange;
|
|
4032
4076
|
_react.useEffect.call(void 0, () => {
|
|
4033
|
-
_optionalChain([onViewChangeRef, 'access',
|
|
4077
|
+
_optionalChain([onViewChangeRef, 'access', _248 => _248.current, 'optionalCall', _249 => _249(mainView)]);
|
|
4034
4078
|
}, [mainView]);
|
|
4035
4079
|
const [selectedCaseId, setSelectedCaseId] = _react.useState.call(void 0, null);
|
|
4036
4080
|
const [uploadOpen, setUploadOpen] = _react.useState.call(void 0, false);
|
|
4037
4081
|
const stableCopyToNote = _react.useCallback.call(void 0,
|
|
4038
|
-
(text, anchor, vitalsRows) => _optionalChain([onCopyToNoteRef, 'access',
|
|
4082
|
+
(text, anchor, vitalsRows) => _optionalChain([onCopyToNoteRef, 'access', _250 => _250.current, 'optionalCall', _251 => _251(text, anchor, vitalsRows)]),
|
|
4039
4083
|
[]
|
|
4040
4084
|
);
|
|
4041
4085
|
const stableCopyVitalsToNote = _react.useCallback.call(void 0,
|
|
4042
|
-
(text) => _optionalChain([onCopyVitalsToNoteRef, 'access',
|
|
4086
|
+
(text) => _optionalChain([onCopyVitalsToNoteRef, 'access', _252 => _252.current, 'optionalCall', _253 => _253(text)]),
|
|
4043
4087
|
[]
|
|
4044
4088
|
);
|
|
4045
4089
|
const stableToast = _react.useCallback.call(void 0,
|
|
4046
|
-
(message, type) => _optionalChain([onToastRef, 'access',
|
|
4090
|
+
(message, type) => _optionalChain([onToastRef, 'access', _254 => _254.current, 'optionalCall', _255 => _255(message, type)]),
|
|
4047
4091
|
[]
|
|
4048
4092
|
);
|
|
4049
4093
|
const attachToContext = _react.useCallback.call(void 0, (documentId, name, visitId) => {
|
|
4050
|
-
void _optionalChain([onAddToContextRef, 'access',
|
|
4094
|
+
void _optionalChain([onAddToContextRef, 'access', _256 => _256.current, 'optionalCall', _257 => _257([visitId ? { documentId, name, visitId } : { documentId, name }])]);
|
|
4051
4095
|
}, []);
|
|
4052
4096
|
const handleSelectCase = _react.useCallback.call(void 0,
|
|
4053
4097
|
(caseId) => {
|