Skip to content

Commit

Permalink
fixes #6341; bin medicine administrations by 4:1 hrs
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed Oct 4, 2023
1 parent 4f02469 commit 1f75446
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/Components/Medicine/PrescriptionAdministrationsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from "../../Utils/utils";
import useRangePagination from "../../Common/hooks/useRangePagination";
import EditPrescriptionForm from "./EditPrescriptionForm";
import useBreakpoints from "../../Common/hooks/useBreakpoints";

interface DateRange {
start: Date;
Expand Down Expand Up @@ -48,13 +49,18 @@ export default function PrescriptionAdministrationsTable({
const { t } = useTranslation();

const [state, setState] = useState<State>();
const daysPerPage = useBreakpoints({
default: 1,
xl: 2,
"2xl": 3,
});
const pagination = useRangePagination({
bounds: state?.administrationsTimeBounds ?? {
start: new Date(),
end: new Date(),
},
perPage: 24 * 60 * 60 * 1000,
slots: 24,
perPage: daysPerPage * 24 * 60 * 60 * 1000, // 1 day
slots: (daysPerPage * 24) / 4, // Grouped by 4 hours
defaultEnd: true,
});
const [showBulkAdminister, setShowBulkAdminister] = useState(false);
Expand Down Expand Up @@ -600,12 +606,12 @@ function getAdministrationBounds(prescriptions: Prescription[]) {
)
);

// floor start to previous hour
start.setMinutes(0, 0, 0);
// floor start to 00:00 of the day
start.setHours(0, 0, 0, 0);

// ceil end to next hour
end.setMinutes(0, 0, 0);
end.setHours(end.getHours() + 1);
// ceil end to 00:00 of the next day
end.setHours(0, 0, 0, 0);
end.setDate(end.getDate() + 1);

return { start, end };
}

0 comments on commit 1f75446

Please sign in to comment.