Skip to content

Commit

Permalink
fixes dependency on field last_administered_on that no longer exists
Browse files Browse the repository at this point in the history
fixes #7466
  • Loading branch information
rithviknishad committed Mar 25, 2024
1 parent 6392aed commit d48f0b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
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
9 changes: 5 additions & 4 deletions src/Components/Medicine/MedicineAdministrationSheet/utils.ts
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

0 comments on commit d48f0b7

Please sign in to comment.