Skip to content

Commit

Permalink
dont show mg twice and show discontinued
Browse files Browse the repository at this point in the history
  • Loading branch information
Pranshu1902 committed Apr 29, 2024
1 parent 5863ea4 commit 51d1339
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/Components/Medicine/MedicinePrescriptionSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ export default function ConsultationMedicineLogs({
const getDetailsMessage = (prescription: Prescription) => {
const message = `Details: ${
prescription.base_dosage != null
? `Base Dosage: ${prescription.base_dosage} mg, `
? `Base Dosage: ${prescription.base_dosage}, `
: ""
}${prescription.route != null ? `Route: ${prescription.route}, ` : ""}${
prescription.dosage_type != null
? `Dosage Type: ${prescription.dosage_type}, `
: ""
}${
prescription.target_dosage != null
? `Target Dosage: ${prescription.target_dosage} mg, `
? `Target Dosage: ${prescription.target_dosage}, `
: ""
}${
prescription.instruction_on_titration != null
Expand All @@ -150,13 +150,16 @@ export default function ConsultationMedicineLogs({
: ""
}${
prescription.max_dosage != null
? `Max Dosage: ${prescription.max_dosage} mg, `
? `Max Dosage: ${prescription.max_dosage}, `
: ""
}${
prescription.min_hours_between_doses != null
? `Min Hours Between Doses: ${prescription.min_hours_between_doses}, `
: ""
}`.replace(/, $/, "");
}${prescription.discontinued ? "Discontinued: Yes, " : ""}`.replace(
/, $/,
"",
);

return message;
};
Expand All @@ -183,7 +186,7 @@ export default function ConsultationMedicineLogs({
// Check for changes in base dosage
if (prevPrescription.base_dosage !== currentPrescription.base_dosage) {
changesForPrescription.push(
`Base dosage changed to ${currentPrescription.base_dosage} mg from ${prevPrescription.base_dosage} mg`,
`Base dosage changed to ${currentPrescription.base_dosage} from ${prevPrescription.base_dosage}`,
);
}

Expand Down Expand Up @@ -278,6 +281,11 @@ export default function ConsultationMedicineLogs({
);
}

// Check if discontinued
if (currentPrescription.discontinued && !prevPrescription.discontinued) {
changesForPrescription.push("Prescription was discontinued");
}

// If there are changes, add them to the changes array
if (changesForPrescription.length > 0) {
const message = `Changes: ${changesForPrescription.join(", ")}`;
Expand Down

0 comments on commit 51d1339

Please sign in to comment.