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

Treatment Summary UI Enhancement #10563

Open
wants to merge 50 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
14bb055
added borders rm bg
AdityaJ2305 Feb 11, 2025
de537ef
Update src/components/Patient/TreatmentSummary.tsx
AdityaJ2305 Feb 11, 2025
c5f0919
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 11, 2025
879c27d
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 12, 2025
b237889
check for medication
AdityaJ2305 Feb 12, 2025
e1e2a51
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 12, 2025
c8a45cb
rm color of badges on print
AdityaJ2305 Feb 12, 2025
95e6c00
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 13, 2025
00e246c
border for ongoing medication table
AdityaJ2305 Feb 13, 2025
5628f13
rm badge color for ongoing medication
AdityaJ2305 Feb 13, 2025
f293a73
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 13, 2025
9a3336c
minor css change
AdityaJ2305 Feb 13, 2025
650eb1b
Merge branch 'treatment_summary_ui_enhancement' of https://github.com…
AdityaJ2305 Feb 13, 2025
8a0a587
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 13, 2025
964bbd3
added border for questionnaire response
AdityaJ2305 Feb 13, 2025
8456c68
Merge branch 'treatment_summary_ui_enhancement' of https://github.com…
AdityaJ2305 Feb 13, 2025
817d9dc
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 13, 2025
002ec2c
rm styling on questionnaire
AdityaJ2305 Feb 13, 2025
033d212
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 14, 2025
e114ebd
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 15, 2025
bde6c68
rm avatar
AdityaJ2305 Feb 15, 2025
0811ff9
card for medication table
AdityaJ2305 Feb 15, 2025
99c93b6
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 17, 2025
fdeb510
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 17, 2025
c4a2a90
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 17, 2025
786f226
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 18, 2025
357305a
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 18, 2025
6a27a68
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 18, 2025
f8b16e1
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 19, 2025
829bcbb
created PrintTable comp
AdityaJ2305 Feb 19, 2025
41b3d9a
Print Table for symptoms
AdityaJ2305 Feb 20, 2025
611a7c6
Print Table for diagnosis
AdityaJ2305 Feb 20, 2025
d41eb85
ongoing medicine Print table
AdityaJ2305 Feb 20, 2025
fa152ad
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 20, 2025
d2b99ef
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 20, 2025
25bd9d4
rm isPrintPreveiw from symptomstabel
AdityaJ2305 Feb 20, 2025
2d594c9
rm isPrintPreveiw from tables child
AdityaJ2305 Feb 20, 2025
75e9f8d
onGoinging medication count
AdityaJ2305 Feb 20, 2025
68e2e2f
created MedicationStatementLayout
AdityaJ2305 Feb 20, 2025
9333f7a
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 20, 2025
9d9d02d
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 21, 2025
807e0be
Print table for Medication talbe
AdityaJ2305 Feb 21, 2025
9af9fe5
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 21, 2025
a27a0e2
Merge branch 'develop' into treatment_summary_ui_enhancement
AdityaJ2305 Feb 22, 2025
5459641
minor changes
AdityaJ2305 Feb 22, 2025
2655e4f
css update
AdityaJ2305 Feb 23, 2025
7f05a46
move printtable to treatment summary
AdityaJ2305 Feb 23, 2025
af299a4
minor fixes
AdityaJ2305 Feb 23, 2025
e43ee9a
minor fixes
AdityaJ2305 Feb 23, 2025
4d1dd22
loading state handled
AdityaJ2305 Feb 23, 2025
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
1 change: 1 addition & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,7 @@
"no_log_update_delta": "No changes since previous log update",
"no_log_updates": "No log updates found",
"no_medical_history_available": "No Medical History Available",
"no_medication_recorded": "No Medication Recorded",
"no_medications_found_for_this_encounter": "No medications found for this encounter.",
"no_medications_to_administer": "No medications to administer",
"no_notices_for_you": "No notices for you.",
Expand Down
8 changes: 6 additions & 2 deletions src/Routers/routes/ConsultationRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ const consultationRoutes: AppRoutes = {
/>
),
"/facility/:facilityId/patient/:patientId/encounter/:encounterId/treatment_summary":
({ facilityId, encounterId }) => (
<TreatmentSummary facilityId={facilityId} encounterId={encounterId} />
({ facilityId, encounterId, patientId }) => (
<TreatmentSummary
facilityId={facilityId}
encounterId={encounterId}
patientId={patientId}
/>
),
"/facility/:facilityId/patient/:patientId/encounter/:encounterId/questionnaire":
({ facilityId, encounterId, patientId }) => (
Expand Down
65 changes: 65 additions & 0 deletions src/components/Common/PrintTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { cn } from "@/lib/utils";

import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";

type HeaderRow = {
title: string;
key: string;
width?: number;
};

type tableRowType = Record<string, string | undefined>;
interface GenericTableProps {
headers: HeaderRow[];
rows: tableRowType[] | undefined;
}

export default function PrintTable({ headers, rows }: GenericTableProps) {
return (
<div className="overflow-hidden rounded-lg border border-gray">
<Table className="w-full">
<TableHeader>
<TableRow className="bg-transparent hover:bg-transparent divide-x divide-gray border-b-gray">
{headers.map(({ key, title, width }, index) => (
<TableHead
className={cn(
index == 0 && "first:rounded-l-md",
"h-auto py-1 pl-2 pr-2 text-black text-center ",
width && `w-${width}`,
)}
key={key}
>
{title}
</TableHead>
))}
</TableRow>
</TableHeader>
<TableBody>
{!!rows &&
rows.map((row, index) => (
<TableRow
key={index}
className="bg-transparent hover:bg-transparent divide-x divide-gray"
>
{headers.map(({ key }) => (
<TableCell
className="break-words whitespace-normal text-center"
key={key}
>
{row[key] || "-"}
</TableCell>
))}
</TableRow>
))}
</TableBody>
</Table>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,23 @@ function StructuredResponseBadge({
);
}

function ResponseCard({ item }: { item: QuestionnaireResponse }) {
function ResponseCard({
item,
isPrintPreview,
}: {
item: QuestionnaireResponse;
isPrintPreview?: boolean;
}) {
const isStructured = !item.questionnaire;
const structuredType = Object.keys(item.structured_responses || {})[0];

return (
<Card className="flex flex-col py-3 px-4 transition-colors hover:bg-muted/50">
<Card
className={cn(
"flex flex-col py-3 px-4 transition-colors hover:bg-muted/50",
isPrintPreview && "shadow-none",
)}
>
<div className="flex items-start justify-between">
<div className="space-y-1">
<div className="flex items-center gap-2 text-xs text-gray-500">
Expand Down Expand Up @@ -317,7 +328,12 @@ export default function QuestionnaireResponsesList({
) : (
<div>
{questionnarieResponses?.results?.length === 0 ? (
<Card className="p-6">
<Card
className={cn(
"p-6",
isPrintPreview && "shadow-none border-gray",
)}
>
<div className="text-lg font-medium text-gray-500">
{t("no_questionnaire_responses")}
</div>
Expand All @@ -327,7 +343,11 @@ export default function QuestionnaireResponsesList({
{questionnarieResponses?.results?.map(
(item: QuestionnaireResponse) => (
<li key={item.id} className="w-full">
<ResponseCard key={item.id} item={item} />
<ResponseCard
key={item.id}
item={item}
isPrintPreview={isPrintPreview}
/>
</li>
),
)}
Expand Down
9 changes: 9 additions & 0 deletions src/components/Medicine/MedicationsTable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useQuery } from "@tanstack/react-query";
import { useTranslation } from "react-i18next";

import { CardContent } from "@/components/ui/card";
import { Skeleton } from "@/components/ui/skeleton";
import {
Table,
Expand Down Expand Up @@ -60,6 +61,14 @@ export const MedicationsTable = ({
</div>
);
}
if (!medications?.results.length) {
return (
<CardContent className="p-2">
<p className="text-gray-500">{t("no_medication_recorded")}</p>
</CardContent>
);
}

return (
<div className="border rounded-lg overflow-hidden">
<Table>
Expand Down
119 changes: 55 additions & 64 deletions src/components/Patient/MedicationStatementList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useQuery } from "@tanstack/react-query";
import { t } from "i18next";
import { useState } from "react";
import { useTranslation } from "react-i18next";

Expand Down Expand Up @@ -35,20 +36,14 @@ import medicationStatementApi from "@/types/emr/medicationStatement/medicationSt
interface MedicationStatementListProps {
patientId: string;
className?: string;
isPrintPreview?: boolean;
}

interface MedicationRowProps {
statement: MedicationStatementRead;
isEnteredInError?: boolean;
isPrintPreview?: boolean;
}

function MedicationRow({
statement,
isEnteredInError,
isPrintPreview = false,
}: MedicationRowProps) {
function MedicationRow({ statement, isEnteredInError }: MedicationRowProps) {
const { t } = useTranslation();

return (
Expand Down Expand Up @@ -80,26 +75,22 @@ function MedicationRow({
<TableCell className="max-w-[200px]">
{statement.note ? (
<div className="flex items-center gap-2">
{isPrintPreview ? (
<span className="text-gray-950">{statement.note}</span>
) : (
<Popover>
<PopoverTrigger asChild>
<Button
variant="outline"
size="sm"
className="h-7 text-xs shrink-0"
>
{t("see_note")}
</Button>
</PopoverTrigger>
<PopoverContent className="w-80 p-4">
<p className="text-sm text-gray-700 whitespace-pre-wrap">
{statement.note}
</p>
</PopoverContent>
</Popover>
)}
<Popover>
<PopoverTrigger asChild>
<Button
variant="outline"
size="sm"
className="h-7 text-xs shrink-0"
>
{t("see_note")}
</Button>
</PopoverTrigger>
<PopoverContent className="w-80 p-4">
<p className="text-sm text-gray-700 whitespace-pre-wrap">
{statement.note}
</p>
</PopoverContent>
</Popover>
</div>
) : (
"-"
Expand All @@ -121,11 +112,10 @@ function MedicationRow({

export function MedicationStatementList({
patientId,
className,
isPrintPreview = false,
className = "",
}: MedicationStatementListProps) {
const { t } = useTranslation();
const [showEnteredInError, setShowEnteredInError] = useState(isPrintPreview);
const [showEnteredInError, setShowEnteredInError] = useState(false);

const { data: medications, isLoading } = useQuery({
queryKey: ["medication_statements", patientId],
Expand All @@ -136,16 +126,9 @@ export function MedicationStatementList({

if (isLoading) {
return (
<Card className={cn("border-none rounded-sm", className)}>
<CardHeader
className={cn("px-4 pt-4 pb-2", isPrintPreview && "px-0 py-2")}
>
<CardTitle>{t("ongoing_medications")}</CardTitle>
</CardHeader>
<CardContent className="px-2 pb-2">
<Skeleton className="h-[100px] w-full" />
</CardContent>
</Card>
<MedicationStatementListLayout className={className}>
<Skeleton className="h-[100px] w-full" />
</MedicationStatementListLayout>
);
}

Expand All @@ -160,31 +143,18 @@ export function MedicationStatementList({

if (!filteredMedications?.length) {
return (
<Card className={cn("border-none rounded-sm", className)}>
<CardHeader
className={cn("px-4 pt-4 pb-2", isPrintPreview && "px-0 py-2")}
>
<CardTitle>{t("ongoing_medications")}</CardTitle>
</CardHeader>
<CardContent
className={cn("px-2 pb-3 pt-2", isPrintPreview && "px-0 py-0")}
>
<p className="text-gray-500">{t("no_ongoing_medications")}</p>
</CardContent>
</Card>
<MedicationStatementListLayout className={className}>
<p className="text-gray-500">{t("no_ongoing_medications")}</p>
</MedicationStatementListLayout>
);
}

return (
<Card className={cn("border-none rounded-sm", className)}>
<CardHeader
className={cn("px-4 pt-4 pb-2", isPrintPreview && "px-0 py-2")}
>
<CardTitle>
{t("ongoing_medications")} ({filteredMedications.length})
</CardTitle>
</CardHeader>
<CardContent className={cn("px-2 pb-2", isPrintPreview && "px-0 py-0")}>
<MedicationStatementListLayout
medicationsCount={filteredMedications.length}
className={className}
>
<>
<Table className="border-separate border-spacing-y-0.5">
<TableHeader>
<TableRow className="rounded-md overflow-hidden bg-gray-100">
Expand Down Expand Up @@ -226,7 +196,6 @@ export function MedicationStatementList({
key={statement.id}
statement={statement}
isEnteredInError={statement.status === "entered_in_error"}
isPrintPreview={isPrintPreview}
/>
))}
</TableBody>
Expand All @@ -246,7 +215,29 @@ export function MedicationStatementList({
</div>
</>
)}
</CardContent>
</Card>
</>
</MedicationStatementListLayout>
);
}

const MedicationStatementListLayout = ({
children,
className,
medicationsCount,
}: {
children: React.ReactNode;
className?: string;
medicationsCount?: number | undefined;
}) => {
return (
<Card className={cn("rounded-sm ", className)}>
<CardHeader className="px-4 pt-4 pb-2">
<CardTitle>
{t("ongoing_medications")}{" "}
{medicationsCount ? `(${medicationsCount})` : ""}
</CardTitle>
</CardHeader>
<CardContent className="px-2 pb-2">{children}</CardContent>
</Card>
);
};
Loading
Loading