Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes high cpu usage in medicines tab, pagination not working, incorrect last modified date and type errors #7472

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Common/hooks/useRangePagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const useRangePagination = ({ bounds, perPage, ...props }: Props) => {

useEffect(() => {
setCurrentRange(getInitialBounds(bounds, perPage, props.defaultEnd));
}, [bounds, perPage, props.defaultEnd]);
}, [JSON.stringify(bounds), perPage, props.defaultEnd]);

const next = () => {
const { end } = currentRange;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const MedicineAdministrationSheet = ({ readonly, is_prn }: Props) => {
<SubHeading
title={is_prn ? "PRN Prescriptions" : "Prescriptions"}
lastModified={
prescriptions?.[0]?.last_administered_on ??
prescriptions?.[0]?.last_administration?.created_date ??
prescriptions?.[0]?.modified_date
}
options={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ export function computeActivityBounds(prescriptions: Prescription[]) {
)
);

// get end by finding latest of all presciption's last_administered_on
// get end by finding latest of all presciption's last administration time
const end = new Date(
prescriptions
.filter((prescription) => prescription.last_administered_on)
.filter((prescription) => prescription.last_administration?.created_date)
.reduce(
(latest, curr) =>
curr.last_administered_on && curr.last_administered_on > latest
? curr.last_administered_on
curr.last_administration?.created_date &&
curr.last_administration?.created_date > latest
? curr.last_administration?.created_date
: latest,
prescriptions[0]?.created_date ?? new Date()
)
Expand Down
Loading