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

Fix: Distinguish Active and Ended Medicines #10963

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
AlertDialogHeader,
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { Badge } from "@/components/ui/badge";
import { Button, buttonVariants } from "@/components/ui/button";
import {
Collapsible,
Expand Down Expand Up @@ -182,6 +183,12 @@ export function MedicationRequestQuestion({
questionnaireResponse.question_id,
);
};
const sortedMedications = [...medications].sort((a, b) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Current logic would result in "active", "ended" and then everything else.

const statusOrder = { active: 0, ended: 1 };
const aOrder = statusOrder[a.status as keyof typeof statusOrder] ?? 2;
const bOrder = statusOrder[b.status as keyof typeof statusOrder] ?? 2;
return aOrder - bOrder;
});

return (
<div className="space-y-4">
Expand Down Expand Up @@ -263,7 +270,7 @@ export function MedicationRequestQuestion({
"bg-transparent": !desktopLayout,
})}
>
{medications.map((medication, index) => (
{sortedMedications.map((medication, index) => (
<React.Fragment key={index}>
{!desktopLayout ? (
<Collapsible
Expand Down Expand Up @@ -516,10 +523,29 @@ const MedicationRequestGridRow: React.FC<MedicationRequestGridRowProps> = ({
)}
>
{/* Medicine Name */}
<div className="lg:p-4 lg:px-2 lg:py-1 flex items-center justify-between lg:justify-start lg:col-span-1 lg:border-r font-medium overflow-hidden text-sm">
<span className="break-words line-clamp-2 hidden lg:block">
<div className="lg:p-4 lg:px-2 lg:py-1 flex items-center justify-between lg:justify-start lg:col-span-1 lg:border-r font-medium overflow-hidden text-sm gap-x-2">
<span
className={`break-words line-clamp-2 hidden lg:block ${
medication.status === "ended" ? "text-gray-500" : ""
}`}
>
{medication.medication?.display}
</span>
<span>
{(medication.status === "active" ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, only showing badge for active or ended.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complete the merge checklist as well.

medication.status === "ended") && (
<Badge
variant={medication.status === "active" ? "primary" : "outline"}
className={`inline-flex items-center gap-1 ${
medication.status === "ended"
? "bg-gray-50/50 text-gray-500 border-gray-200"
: ""
}`}
>
{t(medication.status)}
</Badge>
)}
</span>
</div>
{/* Dosage */}
<div className="lg:px-2 lg:py-1 lg:border-r overflow-hidden">
Expand Down
Loading