From 14bb0553e3277d4b48eead36f7e79315ab6d3cab Mon Sep 17 00:00:00 2001 From: AdityaJ2305 Date: Tue, 11 Feb 2025 21:40:16 +0530 Subject: [PATCH 01/26] added borders rm bg --- src/components/Patient/MedicationStatementList.tsx | 4 ++-- src/components/Patient/TreatmentSummary.tsx | 12 ++++++------ src/components/Patient/allergy/list.tsx | 4 +++- src/components/Patient/diagnosis/list.tsx | 4 +++- src/components/Patient/symptoms/list.tsx | 4 +++- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/components/Patient/MedicationStatementList.tsx b/src/components/Patient/MedicationStatementList.tsx index c9ea302c21a..2b84c869f9e 100644 --- a/src/components/Patient/MedicationStatementList.tsx +++ b/src/components/Patient/MedicationStatementList.tsx @@ -136,7 +136,7 @@ export function MedicationStatementList({ if (isLoading) { return ( - + @@ -160,7 +160,7 @@ export function MedicationStatementList({ if (!filteredMedications?.length) { return ( - + diff --git a/src/components/Patient/TreatmentSummary.tsx b/src/components/Patient/TreatmentSummary.tsx index ad87eee91a6..96c9d8f4c2d 100644 --- a/src/components/Patient/TreatmentSummary.tsx +++ b/src/components/Patient/TreatmentSummary.tsx @@ -46,7 +46,7 @@ export default function TreatmentSummary({ -
+
{/* Header */}
@@ -191,7 +191,7 @@ export default function TreatmentSummary({ @@ -199,7 +199,7 @@ export default function TreatmentSummary({ @@ -207,12 +207,12 @@ export default function TreatmentSummary({ {/* Medications */} -
+

{t("medications")}

@@ -226,7 +226,7 @@ export default function TreatmentSummary({ {/* Medication Statements */} diff --git a/src/components/Patient/allergy/list.tsx b/src/components/Patient/allergy/list.tsx index 62695fe02e8..38708ad6f58 100644 --- a/src/components/Patient/allergy/list.tsx +++ b/src/components/Patient/allergy/list.tsx @@ -95,6 +95,7 @@ export function AllergyList({ facilityId={facilityId} patientId={patientId} encounterId={encounterId} + className={className} > @@ -118,6 +119,7 @@ export function AllergyList({ facilityId={facilityId} patientId={patientId} encounterId={encounterId} + className={className} >

{t("no_allergies_recorded")}

@@ -305,7 +307,7 @@ const AllergyListLayout = ({ isPrintPreview?: boolean; }) => { return ( - + @@ -71,6 +72,7 @@ export function DiagnosisList({ facilityId={facilityId} patientId={patientId} encounterId={encounterId} + className={className} >

{t("no_diagnoses_recorded")}

@@ -137,7 +139,7 @@ const DiagnosisListLayout = ({ isPrintPreview?: boolean; }) => { return ( - + @@ -70,6 +71,7 @@ export function SymptomsList({ facilityId={facilityId} patientId={patientId} encounterId={encounterId} + className={className} >

{t("no_symptoms_recorded")}

@@ -135,7 +137,7 @@ const SymptomListLayout = ({ isPrintPreview?: boolean; }) => { return ( - + Date: Wed, 12 Feb 2025 00:09:37 +0530 Subject: [PATCH 02/26] Update src/components/Patient/TreatmentSummary.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/components/Patient/TreatmentSummary.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Patient/TreatmentSummary.tsx b/src/components/Patient/TreatmentSummary.tsx index 96c9d8f4c2d..2709334ecf1 100644 --- a/src/components/Patient/TreatmentSummary.tsx +++ b/src/components/Patient/TreatmentSummary.tsx @@ -46,7 +46,7 @@ export default function TreatmentSummary({ -
+
{/* Header */}
From b2378894e2eb406d4dc4db59ae2e1889f3fbb6c4 Mon Sep 17 00:00:00 2001 From: AdityaJ2305 Date: Wed, 12 Feb 2025 17:44:27 +0530 Subject: [PATCH 03/26] check for medication --- public/locale/en.json | 1 + src/components/Medicine/MedicationsTable.tsx | 8 ++++++++ src/components/Patient/TreatmentSummary.tsx | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/public/locale/en.json b/public/locale/en.json index f4de7ad0663..04e259b9d6a 100644 --- a/public/locale/en.json +++ b/public/locale/en.json @@ -1407,6 +1407,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.", diff --git a/src/components/Medicine/MedicationsTable.tsx b/src/components/Medicine/MedicationsTable.tsx index 1fee30a06fe..a5ab27e1700 100644 --- a/src/components/Medicine/MedicationsTable.tsx +++ b/src/components/Medicine/MedicationsTable.tsx @@ -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, @@ -60,6 +61,13 @@ export const MedicationsTable = ({
); } + if (!medications?.results.length) { + return ( + +

{t("no_medication_recorded")}

+
+ ); + } return (
diff --git a/src/components/Patient/TreatmentSummary.tsx b/src/components/Patient/TreatmentSummary.tsx index 2709334ecf1..4682df98d34 100644 --- a/src/components/Patient/TreatmentSummary.tsx +++ b/src/components/Patient/TreatmentSummary.tsx @@ -212,8 +212,8 @@ export default function TreatmentSummary({ /> {/* Medications */} -
-

+

+

{t("medications")}

Date: Wed, 12 Feb 2025 21:45:27 +0530 Subject: [PATCH 04/26] rm color of badges on print --- .../Patient/MedicationStatementList.tsx | 8 ++--- src/components/Patient/allergy/list.tsx | 32 +++++++++++------ .../Patient/diagnosis/DiagnosisTable.tsx | 26 +++++++++----- src/components/Patient/diagnosis/list.tsx | 2 +- .../Patient/symptoms/SymptomTable.tsx | 34 +++++++++++++------ src/components/Patient/symptoms/list.tsx | 2 +- 6 files changed, 68 insertions(+), 36 deletions(-) diff --git a/src/components/Patient/MedicationStatementList.tsx b/src/components/Patient/MedicationStatementList.tsx index 2b84c869f9e..a8edc352e85 100644 --- a/src/components/Patient/MedicationStatementList.tsx +++ b/src/components/Patient/MedicationStatementList.tsx @@ -138,7 +138,7 @@ export function MedicationStatementList({ return ( {t("ongoing_medications")} @@ -161,13 +161,11 @@ export function MedicationStatementList({ if (!filteredMedications?.length) { return ( - + {t("ongoing_medications")}

{t("no_ongoing_medications")}

diff --git a/src/components/Patient/allergy/list.tsx b/src/components/Patient/allergy/list.tsx index 38708ad6f58..2e62b8bff43 100644 --- a/src/components/Patient/allergy/list.tsx +++ b/src/components/Patient/allergy/list.tsx @@ -150,9 +150,11 @@ export function AllergyList({ {t(allergy.clinical_status)} @@ -160,9 +162,13 @@ export function AllergyList({ {t(allergy.criticality)} @@ -170,9 +176,15 @@ export function AllergyList({ {t(allergy.verification_status)} @@ -307,7 +319,7 @@ const AllergyListLayout = ({ isPrintPreview?: boolean; }) => { return ( - + {t(diagnosis.clinical_status)} @@ -83,11 +89,15 @@ export function DiagnosisTable({ {t(diagnosis.verification_status)} diff --git a/src/components/Patient/diagnosis/list.tsx b/src/components/Patient/diagnosis/list.tsx index d65405c97fb..1a72756262d 100644 --- a/src/components/Patient/diagnosis/list.tsx +++ b/src/components/Patient/diagnosis/list.tsx @@ -139,7 +139,7 @@ const DiagnosisListLayout = ({ isPrintPreview?: boolean; }) => { return ( - + {t(symptom.severity)} @@ -84,9 +88,13 @@ export function SymptomTable({ {t(symptom.clinical_status)} @@ -94,11 +102,15 @@ export function SymptomTable({ {t(symptom.verification_status)} diff --git a/src/components/Patient/symptoms/list.tsx b/src/components/Patient/symptoms/list.tsx index 13671ff1ff3..1adf85ccef0 100644 --- a/src/components/Patient/symptoms/list.tsx +++ b/src/components/Patient/symptoms/list.tsx @@ -137,7 +137,7 @@ const SymptomListLayout = ({ isPrintPreview?: boolean; }) => { return ( - + Date: Thu, 13 Feb 2025 12:39:53 +0530 Subject: [PATCH 05/26] border for ongoing medication table --- src/components/Patient/MedicationStatementList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Patient/MedicationStatementList.tsx b/src/components/Patient/MedicationStatementList.tsx index a8edc352e85..d98143ea1df 100644 --- a/src/components/Patient/MedicationStatementList.tsx +++ b/src/components/Patient/MedicationStatementList.tsx @@ -174,7 +174,7 @@ export function MedicationStatementList({ } return ( - + From 5628f1324beb842b8fdbc84f7cea05c394879a3e Mon Sep 17 00:00:00 2001 From: AdityaJ2305 Date: Thu, 13 Feb 2025 12:55:48 +0530 Subject: [PATCH 06/26] rm badge color for ongoing medication --- src/components/Patient/MedicationStatementList.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/Patient/MedicationStatementList.tsx b/src/components/Patient/MedicationStatementList.tsx index d98143ea1df..5cbb8cbec22 100644 --- a/src/components/Patient/MedicationStatementList.tsx +++ b/src/components/Patient/MedicationStatementList.tsx @@ -64,9 +64,13 @@ function MedicationRow({ {statement.status} From 9a3336c95e43250eada8387d0dab7c31fd58477d Mon Sep 17 00:00:00 2001 From: AdityaJ2305 Date: Thu, 13 Feb 2025 14:32:25 +0530 Subject: [PATCH 07/26] minor css change --- src/components/Patient/MedicationStatementList.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/components/Patient/MedicationStatementList.tsx b/src/components/Patient/MedicationStatementList.tsx index 5cbb8cbec22..9a875228ae6 100644 --- a/src/components/Patient/MedicationStatementList.tsx +++ b/src/components/Patient/MedicationStatementList.tsx @@ -140,7 +140,7 @@ export function MedicationStatementList({ if (isLoading) { return ( - + @@ -164,13 +164,11 @@ export function MedicationStatementList({ if (!filteredMedications?.length) { return ( - - + + {t("ongoing_medications")} - +

{t("no_ongoing_medications")}

@@ -178,7 +176,7 @@ export function MedicationStatementList({ } return ( - + From 964bbd35b3803c5c46feffdd6a31b8a100af09c7 Mon Sep 17 00:00:00 2001 From: AdityaJ2305 Date: Thu, 13 Feb 2025 15:54:14 +0530 Subject: [PATCH 08/26] added border for questionnaire response --- .../QuestionnaireResponsesList.tsx | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx b/src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx index 2514c7bbdfe..f6f44177479 100644 --- a/src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx +++ b/src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx @@ -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 ( - +
@@ -317,7 +328,12 @@ export default function QuestionnaireResponsesList({ ) : (
{questionnarieResponses?.results?.length === 0 ? ( - +
{t("no_questionnaire_responses")}
@@ -327,7 +343,11 @@ export default function QuestionnaireResponsesList({ {questionnarieResponses?.results?.map( (item: QuestionnaireResponse) => (
  • - +
  • ), )} From 002ec2cd10ee220ae9b371d4b941c88e3dd6421a Mon Sep 17 00:00:00 2001 From: AdityaJ2305 Date: Fri, 14 Feb 2025 01:06:44 +0530 Subject: [PATCH 09/26] rm styling on questionnaire --- .../ConsultationDetails/QuestionnaireResponsesList.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx b/src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx index f6f44177479..86f9bdbedf8 100644 --- a/src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx +++ b/src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx @@ -211,7 +211,7 @@ function ResponseCard({
    @@ -328,12 +328,7 @@ export default function QuestionnaireResponsesList({ ) : (
    {questionnarieResponses?.results?.length === 0 ? ( - +
    {t("no_questionnaire_responses")}
    From bde6c687fc58d13a88cb2842e0715897b3a201b8 Mon Sep 17 00:00:00 2001 From: AdityaJ2305 Date: Sat, 15 Feb 2025 18:25:51 +0530 Subject: [PATCH 10/26] rm avatar --- src/components/Patient/allergy/list.tsx | 12 +++++++----- src/components/Patient/diagnosis/DiagnosisTable.tsx | 12 +++++++----- src/components/Patient/symptoms/SymptomTable.tsx | 12 +++++++----- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/components/Patient/allergy/list.tsx b/src/components/Patient/allergy/list.tsx index 2e62b8bff43..effc99adde1 100644 --- a/src/components/Patient/allergy/list.tsx +++ b/src/components/Patient/allergy/list.tsx @@ -219,11 +219,13 @@ export function AllergyList({
    - + {!isPrintPreview && ( + + )} {formatName(allergy.created_by)}
    diff --git a/src/components/Patient/diagnosis/DiagnosisTable.tsx b/src/components/Patient/diagnosis/DiagnosisTable.tsx index 62163371454..19d9a5c34e7 100644 --- a/src/components/Patient/diagnosis/DiagnosisTable.tsx +++ b/src/components/Patient/diagnosis/DiagnosisTable.tsx @@ -137,11 +137,13 @@ export function DiagnosisTable({
    - + {!isPrintPreview && ( + + )} {diagnosis.created_by.username}
    diff --git a/src/components/Patient/symptoms/SymptomTable.tsx b/src/components/Patient/symptoms/SymptomTable.tsx index c436de8417b..12a02bb17a0 100644 --- a/src/components/Patient/symptoms/SymptomTable.tsx +++ b/src/components/Patient/symptoms/SymptomTable.tsx @@ -145,11 +145,13 @@ export function SymptomTable({
    - + {!isPrintPreview && ( + + )} {symptom.created_by.username}
    From 0811ff97dbd384fee96c8b184eb17952f2703184 Mon Sep 17 00:00:00 2001 From: AdityaJ2305 Date: Sat, 15 Feb 2025 18:50:03 +0530 Subject: [PATCH 11/26] card for medication table --- src/components/Patient/TreatmentSummary.tsx | 39 ++++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/src/components/Patient/TreatmentSummary.tsx b/src/components/Patient/TreatmentSummary.tsx index 4682df98d34..a2f1f7af5b4 100644 --- a/src/components/Patient/TreatmentSummary.tsx +++ b/src/components/Patient/TreatmentSummary.tsx @@ -3,8 +3,12 @@ import { useQuery } from "@tanstack/react-query"; import { format } from "date-fns"; import { t } from "i18next"; +import { cn } from "@/lib/utils"; + import PrintPreview from "@/CAREUI/misc/PrintPreview"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; + import QuestionnaireResponsesList from "@/components/Facility/ConsultationDetails/QuestionnaireResponsesList"; import { MedicationsTable } from "@/components/Medicine/MedicationsTable"; import { AllergyList } from "@/components/Patient/allergy/list"; @@ -187,48 +191,57 @@ export default function TreatmentSummary({ {/* Medical Information */}
    +
    {/* Allergies */} +
    {/* Symptoms */} +
    {/* Diagnoses */} +
    {/* Medications */} -
    -

    - {t("medications")} -

    - -
    + + + {t("medications")} + + + + +
    +
    + {/* Medication Statements */} +
    {/* Questionnaire Responses Section */}
    From 829bcbb4a72fadd0c570f58a92b4a47a3b7d2bf8 Mon Sep 17 00:00:00 2001 From: AdityaJ2305 Date: Wed, 19 Feb 2025 20:06:39 +0530 Subject: [PATCH 12/26] created PrintTable comp --- src/components/Common/PrintTable.tsx | 57 ++++++++ src/components/Patient/allergy/list.tsx | 172 +++++++++++++++--------- 2 files changed, 165 insertions(+), 64 deletions(-) create mode 100644 src/components/Common/PrintTable.tsx diff --git a/src/components/Common/PrintTable.tsx b/src/components/Common/PrintTable.tsx new file mode 100644 index 00000000000..9afcc1a414e --- /dev/null +++ b/src/components/Common/PrintTable.tsx @@ -0,0 +1,57 @@ +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; +interface GenericTableProps { + headers: HeaderRow[]; + rows: tableRowType[] | undefined; +} + +export default function PrintTable({ headers, rows }: GenericTableProps) { + return ( +
    + + + {headers.map(({ key, title }, index) => ( + + {title} + + ))} + + + + {!!rows && + rows.map((row, index) => ( + + {headers.map(({ key }) => ( + {row[key] || "-"} + ))} + + ))} + +
    + ); +} diff --git a/src/components/Patient/allergy/list.tsx b/src/components/Patient/allergy/list.tsx index effc99adde1..419573b775d 100644 --- a/src/components/Patient/allergy/list.tsx +++ b/src/components/Patient/allergy/list.tsx @@ -32,6 +32,7 @@ import { } from "@/components/ui/table"; import { Avatar } from "@/components/Common/Avatar"; +import PrintTable from "@/components/Common/PrintTable"; import query from "@/Utils/request/query"; import { formatName } from "@/Utils/utils"; @@ -135,18 +136,19 @@ export function AllergyList({ function AllergyRow({ allergy }: AllergyRowProps) { return (
    {CATEGORY_ICONS[allergy.category ?? ""]}
    - - {allergy.code.display} - + {allergy.code.display} - - - - - - {t("allergen")} - - - {t("status")} - - - {t("criticality")} - - - {t("verification")} - - - {t("notes")} - - - {t("logged_by")} - - - - - {/* Valid entries */} - {filteredAllergies - .filter( - (allergy) => allergy.verification_status !== "entered_in_error", - ) - .map((allergy) => ( - - ))} - - {/* Entered in error entries */} - {showEnteredInError && - filteredAllergies - .filter( - (allergy) => allergy.verification_status === "entered_in_error", - ) - .map((allergy) => ( - - ))} - -
    - {hasEnteredInErrorRecords && !showEnteredInError && ( + {isPrintPreview ? ( + ({ + allergen: allergy.code.display, + status: t(allergy.clinical_status), + criticality: t(allergy.criticality), + verification: t(allergy.verification_status), + notes: allergy.note, + logged_by: formatName(allergy.created_by), + }))} + /> + ) : ( <> -
    -
    - -
    + + + + + + {t("allergen")} + + + {t("status")} + + + {t("criticality")} + + + {t("verification")} + + + {t("notes")} + + + {t("logged_by")} + + + + + {/* Valid entries */} + {filteredAllergies + .filter( + (allergy) => + allergy.verification_status !== "entered_in_error", + ) + .map((allergy) => ( + + ))} + + {/* Entered in error entries */} + {showEnteredInError && + filteredAllergies + .filter( + (allergy) => + allergy.verification_status === "entered_in_error", + ) + .map((allergy) => ( + + ))} + +
    + {hasEnteredInErrorRecords && !showEnteredInError && ( + <> +
    +
    + +
    + + )} )} @@ -321,7 +359,13 @@ const AllergyListLayout = ({ isPrintPreview?: boolean; }) => { return ( - + Date: Thu, 20 Feb 2025 14:31:56 +0530 Subject: [PATCH 13/26] Print Table for symptoms --- src/components/Common/PrintTable.tsx | 67 +++-- src/components/Patient/TreatmentSummary.tsx | 7 - src/components/Patient/allergy/list.tsx | 100 +++---- .../Patient/symptoms/SymptomTable.tsx | 271 ++++++++++-------- src/components/Patient/symptoms/list.tsx | 8 +- 5 files changed, 227 insertions(+), 226 deletions(-) diff --git a/src/components/Common/PrintTable.tsx b/src/components/Common/PrintTable.tsx index 9afcc1a414e..c61ee7d0467 100644 --- a/src/components/Common/PrintTable.tsx +++ b/src/components/Common/PrintTable.tsx @@ -23,35 +23,42 @@ interface GenericTableProps { export default function PrintTable({ headers, rows }: GenericTableProps) { return ( - - - - {headers.map(({ key, title }, index) => ( - - {title} - - ))} - - - - {!!rows && - rows.map((row, index) => ( - - {headers.map(({ key }) => ( - {row[key] || "-"} - ))} - - ))} - -
    +
    + + + + {headers.map(({ key, title }, index) => ( + + {title} + + ))} + + + + {!!rows && + rows.map((row, index) => ( + + {headers.map(({ key }) => ( + + {row[key] || "-"} + + ))} + + ))} + +
    +
    ); } diff --git a/src/components/Patient/TreatmentSummary.tsx b/src/components/Patient/TreatmentSummary.tsx index a2f1f7af5b4..cf7d55b570d 100644 --- a/src/components/Patient/TreatmentSummary.tsx +++ b/src/components/Patient/TreatmentSummary.tsx @@ -196,7 +196,6 @@ export default function TreatmentSummary({
    @@ -205,7 +204,6 @@ export default function TreatmentSummary({
    @@ -214,10 +212,8 @@ export default function TreatmentSummary({ -
    {/* Medications */} @@ -233,12 +229,9 @@ export default function TreatmentSummary({
    -
    - {/* Medication Statements */}
    diff --git a/src/components/Patient/allergy/list.tsx b/src/components/Patient/allergy/list.tsx index 419573b775d..4172d8bc7e9 100644 --- a/src/components/Patient/allergy/list.tsx +++ b/src/components/Patient/allergy/list.tsx @@ -76,7 +76,7 @@ export function AllergyList({ isPrintPreview = false, encounterStatus, }: AllergyListProps) { - const [showEnteredInError, setShowEnteredInError] = useState(isPrintPreview); + const [showEnteredInError, setShowEnteredInError] = useState(false); const { data: allergies, isLoading } = useQuery({ queryKey: ["allergies", patientId, encounterId, encounterStatus], @@ -139,8 +139,6 @@ export function AllergyList({ className={cn( "rounded-md overflow-hidden bg-gray-50", allergy.verification_status === "entered_in_error" && "opacity-50", - isPrintPreview && - "bg-transparent hover:bg-transparent divide-x divide-black", )} > @@ -152,11 +150,7 @@ export function AllergyList({ {t(allergy.clinical_status)} @@ -164,13 +158,9 @@ export function AllergyList({ {t(allergy.criticality)} @@ -178,15 +168,9 @@ export function AllergyList({ {t(allergy.verification_status)} @@ -194,40 +178,33 @@ export function AllergyList({ {allergy.note && (
    - {isPrintPreview ? ( - - {allergy.note} - - ) : ( - - - - - -

    - {allergy.note} -

    -
    -
    - )} + + + + + +

    + {allergy.note} +

    +
    +
    )}
    - {!isPrintPreview && ( - - )} + + {formatName(allergy.created_by)}
    @@ -264,20 +241,9 @@ export function AllergyList({ /> ) : ( <> - +
    - + {t("allergen")} @@ -369,7 +335,7 @@ const AllergyListLayout = ({ diff --git a/src/components/Patient/symptoms/SymptomTable.tsx b/src/components/Patient/symptoms/SymptomTable.tsx index 24d2f1c0519..5595797bb2d 100644 --- a/src/components/Patient/symptoms/SymptomTable.tsx +++ b/src/components/Patient/symptoms/SymptomTable.tsx @@ -17,7 +17,9 @@ import { } from "@/components/ui/table"; import { Avatar } from "@/components/Common/Avatar"; +import PrintTable from "@/components/Common/PrintTable"; +import { formatName } from "@/Utils/utils"; import { SYMPTOM_CLINICAL_STATUS_STYLES, SYMPTOM_SEVERITY_STYLES, @@ -35,129 +37,156 @@ export function SymptomTable({ isPrintPreview = false, }: SymptomTableProps) { return ( -
    - - - - {t("symptom")} - - - {t("severity")} - - - {t("status")} - - - {t("verification")} - - - {t("notes")} - - - {t("logged_by")} - - - - - {symptoms.map((symptom) => ( - - - {symptom.code.display} - - - {symptom.severity ? ( - - {t(symptom.severity)} - - ) : ( - "-" - )} - - - + {isPrintPreview ? ( + ({ + symptom: symptom.code.display, + severity: t(symptom.severity), + status: t(symptom.clinical_status), + verification: t(symptom.verification_status), + notes: symptom.note, + logged_by: formatName(symptom.created_by), + }))} + /> + ) : ( +
    + + + + {t("symptom")} + + + {t("severity")} + + + {t("status")} + + + {t("verification")} + + + {t("notes")} + + + {t("logged_by")} + + + + + {symptoms.map((symptom) => ( + - {t(symptom.clinical_status)} - - - - - {t(symptom.verification_status)} - - - - {symptom.note ? ( -
    - {isPrintPreview ? ( - {symptom.note} + + {symptom.code.display} + + + {symptom.severity ? ( + + {t(symptom.severity)} + + ) : ( + "-" + )} + + + + {t(symptom.clinical_status)} + + + + + {t(symptom.verification_status)} + + + + {symptom.note ? ( +
    + {isPrintPreview ? ( + {symptom.note} + ) : ( + + + + + +

    + {symptom.note} +

    +
    +
    + )} +
    ) : ( - - - - - -

    - {symptom.note} -

    -
    -
    + "-" )} -
    - ) : ( - "-" - )} -
    - -
    - {!isPrintPreview && ( - - )} - {symptom.created_by.username} -
    -
    -
    - ))} -
    -
    +
    + +
    + {!isPrintPreview && ( + + )} + + {symptom.created_by.username} + +
    +
    + + ))} + + + )} + ); } diff --git a/src/components/Patient/symptoms/list.tsx b/src/components/Patient/symptoms/list.tsx index 1adf85ccef0..f55aef90e00 100644 --- a/src/components/Patient/symptoms/list.tsx +++ b/src/components/Patient/symptoms/list.tsx @@ -137,7 +137,13 @@ const SymptomListLayout = ({ isPrintPreview?: boolean; }) => { return ( - + Date: Thu, 20 Feb 2025 14:45:59 +0530 Subject: [PATCH 14/26] Print Table for diagnosis --- .../Patient/diagnosis/DiagnosisTable.tsx | 247 ++++++++++-------- src/components/Patient/diagnosis/list.tsx | 10 +- src/components/Patient/symptoms/list.tsx | 2 + 3 files changed, 144 insertions(+), 115 deletions(-) diff --git a/src/components/Patient/diagnosis/DiagnosisTable.tsx b/src/components/Patient/diagnosis/DiagnosisTable.tsx index 19d9a5c34e7..342da9803cb 100644 --- a/src/components/Patient/diagnosis/DiagnosisTable.tsx +++ b/src/components/Patient/diagnosis/DiagnosisTable.tsx @@ -17,7 +17,9 @@ import { } from "@/components/ui/table"; import { Avatar } from "@/components/Common/Avatar"; +import PrintTable from "@/components/Common/PrintTable"; +import { formatName } from "@/Utils/utils"; import { DIAGNOSIS_CLINICAL_STATUS_STYLES, DIAGNOSIS_VERIFICATION_STATUS_STYLES, @@ -34,122 +36,139 @@ export function DiagnosisTable({ isPrintPreview = false, }: DiagnosisTableProps) { return ( - - - - - {t("diagnosis")} - - - {t("status")} - - - {t("verification")} - - - {t("onset")} - - - {t("notes")} - - - {t("logged_by")} - - - - - {diagnoses.map((diagnosis) => ( - - - {diagnosis.code.display} - - - - {t(diagnosis.clinical_status)} - - - - + {isPrintPreview ? ( + ({ + diagnosis: diagnosis.code.display, + status: t(diagnosis.clinical_status), + verification: t(diagnosis.verification_status), + onset: diagnosis.onset?.onset_datetime + ? new Date(diagnosis.onset.onset_datetime).toLocaleDateString() + : undefined, + notes: diagnosis.note, + logged_by: formatName(diagnosis.created_by), + }))} + /> + ) : ( +
    + + + + {t("diagnosis")} + + + {t("status")} + + + {t("verification")} + + + {t("onset")} + + + {t("notes")} + + + {t("logged_by")} + + + + + {diagnoses.map((diagnosis) => ( + - {t(diagnosis.verification_status)} - - - - {diagnosis.onset?.onset_datetime - ? new Date(diagnosis.onset.onset_datetime).toLocaleDateString() - : "-"} - - - {diagnosis.note ? ( -
    - {isPrintPreview ? ( - {diagnosis.note} + + {diagnosis.code.display} + + + + {t(diagnosis.clinical_status)} + + + + + {t(diagnosis.verification_status)} + + + + {diagnosis.onset?.onset_datetime + ? new Date( + diagnosis.onset.onset_datetime, + ).toLocaleDateString() + : "-"} + + + {diagnosis.note ? ( +
    + + + + + +

    + {diagnosis.note} +

    +
    +
    +
    ) : ( - - - - - -

    - {diagnosis.note} -

    -
    -
    + "-" )} -
    - ) : ( - "-" - )} -
    - -
    - {!isPrintPreview && ( - - )} - {diagnosis.created_by.username} -
    -
    -
    - ))} -
    -
    +
    + +
    + + + + {diagnosis.created_by.username} + +
    +
    + + ))} + + + )} + ); } diff --git a/src/components/Patient/diagnosis/list.tsx b/src/components/Patient/diagnosis/list.tsx index 1a72756262d..ce19ea358df 100644 --- a/src/components/Patient/diagnosis/list.tsx +++ b/src/components/Patient/diagnosis/list.tsx @@ -48,6 +48,7 @@ export function DiagnosisList({ patientId={patientId} encounterId={encounterId} className={className} + isPrintPreview={isPrintPreview} > @@ -73,6 +74,7 @@ export function DiagnosisList({ patientId={patientId} encounterId={encounterId} className={className} + isPrintPreview={isPrintPreview} >

    {t("no_diagnoses_recorded")}

    @@ -139,7 +141,13 @@ const DiagnosisListLayout = ({ isPrintPreview?: boolean; }) => { return ( - + @@ -72,6 +73,7 @@ export function SymptomsList({ patientId={patientId} encounterId={encounterId} className={className} + isPrintPreview={isPrintPreview} >

    {t("no_symptoms_recorded")}

    From d41eb85ba6f8e3208b4dddfa639b356165d820a9 Mon Sep 17 00:00:00 2001 From: AdityaJ2305 Date: Thu, 20 Feb 2025 15:18:12 +0530 Subject: [PATCH 15/26] ongoing medicine Print table --- .../Patient/MedicationStatementList.tsx | 248 +++++++++++------- src/components/Patient/TreatmentSummary.tsx | 4 - 2 files changed, 150 insertions(+), 102 deletions(-) diff --git a/src/components/Patient/MedicationStatementList.tsx b/src/components/Patient/MedicationStatementList.tsx index 3503f7ce196..66e45f5ad27 100644 --- a/src/components/Patient/MedicationStatementList.tsx +++ b/src/components/Patient/MedicationStatementList.tsx @@ -23,6 +23,7 @@ import { } from "@/components/ui/table"; import { Avatar } from "@/components/Common/Avatar"; +import PrintTable from "@/components/Common/PrintTable"; import query from "@/Utils/request/query"; import { formatDateTime, formatName } from "@/Utils/utils"; @@ -41,14 +42,9 @@ interface MedicationStatementListProps { interface MedicationRowProps { statement: MedicationStatementRead; isEnteredInError?: boolean; - isPrintPreview?: boolean; } -function MedicationRow({ - statement, - isEnteredInError, - isPrintPreview = false, -}: MedicationRowProps) { +function MedicationRow({ statement, isEnteredInError }: MedicationRowProps) { const { t } = useTranslation(); return ( @@ -64,13 +60,9 @@ function MedicationRow({ {statement.status} @@ -84,26 +76,22 @@ function MedicationRow({ {statement.note ? (
    - {isPrintPreview ? ( - {statement.note} - ) : ( - - - - - -

    - {statement.note} -

    -
    -
    - )} + + + + + +

    + {statement.note} +

    +
    +
    ) : ( "-" @@ -140,13 +128,24 @@ export function MedicationStatementList({ if (isLoading) { return ( - + {t("ongoing_medications")} - + @@ -164,11 +163,24 @@ export function MedicationStatementList({ if (!filteredMedications?.length) { return ( - - + + {t("ongoing_medications")} - +

    {t("no_ongoing_medications")}

    @@ -176,7 +188,13 @@ export function MedicationStatementList({ } return ( - + @@ -185,65 +203,99 @@ export function MedicationStatementList({ - - - - - {t("medication")} - - - {t("dosage")} - - - {t("status")} - - - {t("medication_taken_between")} - - - {t("reason")} - - - {t("notes")} - - - {t("logged_by")} - - - - - {[ - ...filteredMedications.filter( - (medication) => medication.status !== "entered_in_error", - ), - ...(showEnteredInError - ? filteredMedications.filter( - (medication) => medication.status === "entered_in_error", - ) - : []), - ].map((statement) => ( - - ))} - -
    - {hasEnteredInErrorRecords && !showEnteredInError && ( + {isPrintPreview ? ( + ({ + medication: + medication.medication.display ?? medication.medication.code, + dosage: medication.dosage_text, + status: medication.status, + medication_taken_between: [ + medication.effective_period?.start, + medication.effective_period?.end, + ] + .map((date) => formatDateTime(date)) + .join(" - "), + reason: medication.reason, + notes: medication.note, + logged_by: formatName(medication.created_by), + }))} + /> + ) : ( <> -
    -
    - -
    + + + + + {t("medication")} + + + {t("dosage")} + + + {t("status")} + + + {t("medication_taken_between")} + + + {t("reason")} + + + {t("notes")} + + + {t("logged_by")} + + + + + {[ + ...filteredMedications.filter( + (medication) => medication.status !== "entered_in_error", + ), + ...(showEnteredInError + ? filteredMedications.filter( + (medication) => + medication.status === "entered_in_error", + ) + : []), + ].map((statement) => ( + + ))} + +
    + {hasEnteredInErrorRecords && !showEnteredInError && ( + <> +
    +
    + +
    + + )} )} diff --git a/src/components/Patient/TreatmentSummary.tsx b/src/components/Patient/TreatmentSummary.tsx index cf7d55b570d..f288b158968 100644 --- a/src/components/Patient/TreatmentSummary.tsx +++ b/src/components/Patient/TreatmentSummary.tsx @@ -191,14 +191,12 @@ export default function TreatmentSummary({ {/* Medical Information */}
    -
    {/* Allergies */} -
    {/* Symptoms */} -
    {/* Diagnoses */} -
    {/* Questionnaire Responses Section */}
    From 25bd9d4c9114ea86aebdf3ed055da97e019a24d3 Mon Sep 17 00:00:00 2001 From: AdityaJ2305 Date: Thu, 20 Feb 2025 21:21:08 +0530 Subject: [PATCH 16/26] rm isPrintPreveiw from symptomstabel --- .../Patient/MedicationStatementList.tsx | 2 +- .../Patient/symptoms/SymptomTable.tsx | 75 ++++++++----------- 2 files changed, 31 insertions(+), 46 deletions(-) diff --git a/src/components/Patient/MedicationStatementList.tsx b/src/components/Patient/MedicationStatementList.tsx index 66e45f5ad27..343af171f70 100644 --- a/src/components/Patient/MedicationStatementList.tsx +++ b/src/components/Patient/MedicationStatementList.tsx @@ -117,7 +117,7 @@ export function MedicationStatementList({ isPrintPreview = false, }: MedicationStatementListProps) { const { t } = useTranslation(); - const [showEnteredInError, setShowEnteredInError] = useState(isPrintPreview); + const [showEnteredInError, setShowEnteredInError] = useState(false); const { data: medications, isLoading } = useQuery({ queryKey: ["medication_statements", patientId], diff --git a/src/components/Patient/symptoms/SymptomTable.tsx b/src/components/Patient/symptoms/SymptomTable.tsx index 5595797bb2d..8b45c5a4589 100644 --- a/src/components/Patient/symptoms/SymptomTable.tsx +++ b/src/components/Patient/symptoms/SymptomTable.tsx @@ -111,15 +111,9 @@ export function SymptomTable({ {t(symptom.clinical_status)} @@ -127,15 +121,11 @@ export function SymptomTable({ {t(symptom.verification_status)} @@ -143,26 +133,22 @@ export function SymptomTable({ {symptom.note ? (
    - {isPrintPreview ? ( - {symptom.note} - ) : ( - - - - - -

    - {symptom.note} -

    -
    -
    - )} + + + + + +

    + {symptom.note} +

    +
    +
    ) : ( "-" @@ -170,13 +156,12 @@ export function SymptomTable({
    - {!isPrintPreview && ( - - )} + + {symptom.created_by.username} From 2d594c9c9efd6ad99f95fce43d4b93d306204853 Mon Sep 17 00:00:00 2001 From: AdityaJ2305 Date: Thu, 20 Feb 2025 21:32:16 +0530 Subject: [PATCH 17/26] rm isPrintPreveiw from tables child --- .../Patient/diagnosis/DiagnosisTable.tsx | 238 +++++++---------- src/components/Patient/diagnosis/list.tsx | 83 ++++-- .../Patient/symptoms/SymptomTable.tsx | 249 ++++++++---------- src/components/Patient/symptoms/list.tsx | 80 ++++-- 4 files changed, 318 insertions(+), 332 deletions(-) diff --git a/src/components/Patient/diagnosis/DiagnosisTable.tsx b/src/components/Patient/diagnosis/DiagnosisTable.tsx index 342da9803cb..b80e0b6062a 100644 --- a/src/components/Patient/diagnosis/DiagnosisTable.tsx +++ b/src/components/Patient/diagnosis/DiagnosisTable.tsx @@ -17,9 +17,7 @@ import { } from "@/components/ui/table"; import { Avatar } from "@/components/Common/Avatar"; -import PrintTable from "@/components/Common/PrintTable"; -import { formatName } from "@/Utils/utils"; import { DIAGNOSIS_CLINICAL_STATUS_STYLES, DIAGNOSIS_VERIFICATION_STATUS_STYLES, @@ -28,147 +26,111 @@ import { interface DiagnosisTableProps { diagnoses: Diagnosis[]; - isPrintPreview?: boolean; } -export function DiagnosisTable({ - diagnoses, - isPrintPreview = false, -}: DiagnosisTableProps) { +export function DiagnosisTable({ diagnoses }: DiagnosisTableProps) { return ( - <> - {isPrintPreview ? ( - ({ - diagnosis: diagnosis.code.display, - status: t(diagnosis.clinical_status), - verification: t(diagnosis.verification_status), - onset: diagnosis.onset?.onset_datetime - ? new Date(diagnosis.onset.onset_datetime).toLocaleDateString() - : undefined, - notes: diagnosis.note, - logged_by: formatName(diagnosis.created_by), - }))} - /> - ) : ( - - - - - {t("diagnosis")} - - - {t("status")} - - - {t("verification")} - - - {t("onset")} - - - {t("notes")} - - - {t("logged_by")} - - - - - {diagnoses.map((diagnosis) => ( - + + + + {t("diagnosis")} + + + {t("status")} + + + {t("verification")} + + + {t("onset")} + + + {t("notes")} + + + {t("logged_by")} + + + + + {diagnoses.map((diagnosis) => ( + + + {diagnosis.code.display} + + + + {t(diagnosis.clinical_status)} + + + + - - {diagnosis.code.display} - - - - {t(diagnosis.clinical_status)} - - - - - {t(diagnosis.verification_status)} - - - - {diagnosis.onset?.onset_datetime - ? new Date( - diagnosis.onset.onset_datetime, - ).toLocaleDateString() - : "-"} - - - {diagnosis.note ? ( -
    - - - - - -

    - {diagnosis.note} -

    -
    -
    -
    - ) : ( - "-" - )} -
    - -
    - + {t(diagnosis.verification_status)} + + + + {diagnosis.onset?.onset_datetime + ? new Date(diagnosis.onset.onset_datetime).toLocaleDateString() + : "-"} + + + {diagnosis.note ? ( +
    + + + + + +

    + {diagnosis.note} +

    +
    +
    +
    + ) : ( + "-" + )} +
    + +
    + - - {diagnosis.created_by.username} - -
    -
    - - ))} - -
    - )} - + {diagnosis.created_by.username} +
    +
    + + ))} + + ); } diff --git a/src/components/Patient/diagnosis/list.tsx b/src/components/Patient/diagnosis/list.tsx index ce19ea358df..e45392bdb7b 100644 --- a/src/components/Patient/diagnosis/list.tsx +++ b/src/components/Patient/diagnosis/list.tsx @@ -11,7 +11,10 @@ import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Skeleton } from "@/components/ui/skeleton"; +import PrintTable from "@/components/Common/PrintTable"; + import query from "@/Utils/request/query"; +import { formatName } from "@/Utils/utils"; import diagnosisApi from "@/types/emr/diagnosis/diagnosisApi"; import { DiagnosisTable } from "./DiagnosisTable"; @@ -31,7 +34,7 @@ export function DiagnosisList({ className, isPrintPreview = false, }: DiagnosisListProps) { - const [showEnteredInError, setShowEnteredInError] = useState(isPrintPreview); + const [showEnteredInError, setShowEnteredInError] = useState(false); const { data: diagnoses, isLoading } = useQuery({ queryKey: ["diagnosis", patientId, encounterId], @@ -91,34 +94,60 @@ export function DiagnosisList({ className={className} isPrintPreview={isPrintPreview} > - diagnosis.verification_status !== "entered_in_error", - ), - ...(showEnteredInError - ? filteredDiagnoses.filter( - (diagnosis) => - diagnosis.verification_status === "entered_in_error", - ) - : []), - ]} - isPrintPreview={isPrintPreview} - /> + {isPrintPreview ? ( + ({ + diagnosis: diagnosis.code.display, + status: t(diagnosis.clinical_status), + verification: t(diagnosis.verification_status), + onset: diagnosis.onset?.onset_datetime + ? new Date(diagnosis.onset.onset_datetime).toLocaleDateString() + : undefined, + notes: diagnosis.note, + logged_by: formatName(diagnosis.created_by), + }))} + /> + ) : ( <> -
    -
    - -
    + + diagnosis.verification_status !== "entered_in_error", + ), + ...(showEnteredInError + ? filteredDiagnoses.filter( + (diagnosis) => + diagnosis.verification_status === "entered_in_error", + ) + : []), + ]} + /> + + {hasEnteredInErrorRecords && !showEnteredInError && ( + <> +
    +
    + +
    + + )} )} diff --git a/src/components/Patient/symptoms/SymptomTable.tsx b/src/components/Patient/symptoms/SymptomTable.tsx index 8b45c5a4589..759342338cb 100644 --- a/src/components/Patient/symptoms/SymptomTable.tsx +++ b/src/components/Patient/symptoms/SymptomTable.tsx @@ -17,9 +17,7 @@ import { } from "@/components/ui/table"; import { Avatar } from "@/components/Common/Avatar"; -import PrintTable from "@/components/Common/PrintTable"; -import { formatName } from "@/Utils/utils"; import { SYMPTOM_CLINICAL_STATUS_STYLES, SYMPTOM_SEVERITY_STYLES, @@ -29,149 +27,120 @@ import { interface SymptomTableProps { symptoms: Symptom[]; - isPrintPreview?: boolean; } -export function SymptomTable({ - symptoms, - isPrintPreview = false, -}: SymptomTableProps) { +export function SymptomTable({ symptoms }: SymptomTableProps) { return ( - <> - {isPrintPreview ? ( - ({ - symptom: symptom.code.display, - severity: t(symptom.severity), - status: t(symptom.clinical_status), - verification: t(symptom.verification_status), - notes: symptom.note, - logged_by: formatName(symptom.created_by), - }))} - /> - ) : ( - - - - - {t("symptom")} - - - {t("severity")} - - - {t("status")} - - - {t("verification")} - - - {t("notes")} - - - {t("logged_by")} - - - - - {symptoms.map((symptom) => ( - + + + + {t("symptom")} + + + {t("severity")} + + + {t("status")} + + + {t("verification")} + + + {t("notes")} + + + {t("logged_by")} + + + + + {symptoms.map((symptom) => ( + + + {symptom.code.display} + + + {symptom.severity ? ( + + {t(symptom.severity)} + + ) : ( + "-" + )} + + + - - {symptom.code.display} - - - {symptom.severity ? ( - - {t(symptom.severity)} - - ) : ( - "-" - )} - - - - {t(symptom.clinical_status)} - - - - - {t(symptom.verification_status)} - - - - {symptom.note ? ( -
    - - - - - -

    - {symptom.note} -

    -
    -
    -
    - ) : ( - "-" - )} -
    - -
    - + {t(symptom.clinical_status)} + + + + + {t(symptom.verification_status)} + + + + {symptom.note ? ( +
    + + + + + +

    + {symptom.note} +

    +
    +
    +
    + ) : ( + "-" + )} +
    + +
    + - - {symptom.created_by.username} - -
    -
    - - ))} - -
    - )} - + {symptom.created_by.username} +
    + + + ))} + + ); } diff --git a/src/components/Patient/symptoms/list.tsx b/src/components/Patient/symptoms/list.tsx index b5ac67abf4a..af210f40fcc 100644 --- a/src/components/Patient/symptoms/list.tsx +++ b/src/components/Patient/symptoms/list.tsx @@ -11,7 +11,10 @@ import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Skeleton } from "@/components/ui/skeleton"; +import PrintTable from "@/components/Common/PrintTable"; + import query from "@/Utils/request/query"; +import { formatName } from "@/Utils/utils"; import symptomApi from "@/types/emr/symptom/symptomApi"; import { SymptomTable } from "./SymptomTable"; @@ -31,7 +34,7 @@ export function SymptomsList({ className, isPrintPreview = false, }: SymptomsListProps) { - const [showEnteredInError, setShowEnteredInError] = useState(isPrintPreview); + const [showEnteredInError, setShowEnteredInError] = useState(false); const { data: symptoms, isLoading } = useQuery({ queryKey: ["symptoms", patientId, encounterId], @@ -90,33 +93,56 @@ export function SymptomsList({ className={className} isPrintPreview={isPrintPreview} > - symptom.verification_status !== "entered_in_error", - ), - ...(showEnteredInError - ? filteredSymptoms.filter( - (symptom) => symptom.verification_status === "entered_in_error", - ) - : []), - ]} - isPrintPreview={isPrintPreview} - /> - - {hasEnteredInErrorRecords && !showEnteredInError && ( + {isPrintPreview ? ( + ({ + symptom: symptom.code.display, + severity: t(symptom.severity), + status: t(symptom.clinical_status), + verification: t(symptom.verification_status), + notes: symptom.note, + logged_by: formatName(symptom.created_by), + }))} + /> + ) : ( <> -
    -
    - -
    + symptom.verification_status !== "entered_in_error", + ), + ...(showEnteredInError + ? filteredSymptoms.filter( + (symptom) => + symptom.verification_status === "entered_in_error", + ) + : []), + ]} + /> + + {hasEnteredInErrorRecords && !showEnteredInError && ( + <> +
    +
    + +
    + + )} )} From 75e9f8de3ab53d003302f086b5ad05007145c8fc Mon Sep 17 00:00:00 2001 From: AdityaJ2305 Date: Thu, 20 Feb 2025 21:45:18 +0530 Subject: [PATCH 18/26] onGoinging medication count --- src/components/Patient/MedicationStatementList.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/Patient/MedicationStatementList.tsx b/src/components/Patient/MedicationStatementList.tsx index 343af171f70..27c229d2641 100644 --- a/src/components/Patient/MedicationStatementList.tsx +++ b/src/components/Patient/MedicationStatementList.tsx @@ -199,7 +199,9 @@ export function MedicationStatementList({ className={cn("px-4 pt-4 pb-2", isPrintPreview && "px-0 py-2")} > - {t("ongoing_medications")} ({filteredMedications.length}) + {t("ongoing_medications")} ( + {isPrintPreview ? medications?.count : filteredMedications.length} ?? + {""}) From 68e2e2ffd21db67481908f5205f9195921dbb078 Mon Sep 17 00:00:00 2001 From: AdityaJ2305 Date: Thu, 20 Feb 2025 22:03:25 +0530 Subject: [PATCH 19/26] created MedicationStatementLayout --- .../Patient/MedicationStatementList.tsx | 288 +++++++++--------- 1 file changed, 145 insertions(+), 143 deletions(-) diff --git a/src/components/Patient/MedicationStatementList.tsx b/src/components/Patient/MedicationStatementList.tsx index 27c229d2641..a199b588396 100644 --- a/src/components/Patient/MedicationStatementList.tsx +++ b/src/components/Patient/MedicationStatementList.tsx @@ -1,4 +1,5 @@ import { useQuery } from "@tanstack/react-query"; +import { t } from "i18next"; import { useState } from "react"; import { useTranslation } from "react-i18next"; @@ -113,7 +114,7 @@ function MedicationRow({ statement, isEnteredInError }: MedicationRowProps) { export function MedicationStatementList({ patientId, - className, + className = "", isPrintPreview = false, }: MedicationStatementListProps) { const { t } = useTranslation(); @@ -128,27 +129,12 @@ export function MedicationStatementList({ if (isLoading) { return ( - - - {t("ongoing_medications")} - - - - - + + ); } @@ -163,144 +149,160 @@ export function MedicationStatementList({ if (!filteredMedications?.length) { return ( - - - {t("ongoing_medications")} - - -

    {t("no_ongoing_medications")}

    -
    -
    +

    {t("no_ongoing_medications")}

    + ); } + return ( + + {isPrintPreview ? ( + ({ + medication: + medication.medication.display ?? medication.medication.code, + dosage: medication.dosage_text, + status: medication.status, + medication_taken_between: [ + medication.effective_period?.start, + medication.effective_period?.end, + ] + .map((date) => formatDateTime(date)) + .join(" - "), + reason: medication.reason, + notes: medication.note, + logged_by: formatName(medication.created_by), + }))} + /> + ) : ( + <> + + + + + {t("medication")} + + + {t("dosage")} + + + {t("status")} + + + {t("medication_taken_between")} + + + {t("reason")} + + + {t("notes")} + + + {t("logged_by")} + + + + + {[ + ...filteredMedications.filter( + (medication) => medication.status !== "entered_in_error", + ), + ...(showEnteredInError + ? filteredMedications.filter( + (medication) => medication.status === "entered_in_error", + ) + : []), + ].map((statement) => ( + + ))} + +
    + {hasEnteredInErrorRecords && !showEnteredInError && ( + <> +
    +
    + +
    + + )} + + )} + + ); +} + +const MedicationStatementListLayout = ({ + children, + className, + isPrintPreview = false, + medicationsCount, +}: { + children: React.ReactNode; + className?: string; + isPrintPreview?: boolean; + medicationsCount?: number | undefined; +}) => { return ( - {t("ongoing_medications")} ( - {isPrintPreview ? medications?.count : filteredMedications.length} ?? - {""}) + {" "} + {t("ongoing_medications")} ({medicationsCount && medicationsCount}) - - {isPrintPreview ? ( - ({ - medication: - medication.medication.display ?? medication.medication.code, - dosage: medication.dosage_text, - status: medication.status, - medication_taken_between: [ - medication.effective_period?.start, - medication.effective_period?.end, - ] - .map((date) => formatDateTime(date)) - .join(" - "), - reason: medication.reason, - notes: medication.note, - logged_by: formatName(medication.created_by), - }))} - /> - ) : ( - <> - - - - - {t("medication")} - - - {t("dosage")} - - - {t("status")} - - - {t("medication_taken_between")} - - - {t("reason")} - - - {t("notes")} - - - {t("logged_by")} - - - - - {[ - ...filteredMedications.filter( - (medication) => medication.status !== "entered_in_error", - ), - ...(showEnteredInError - ? filteredMedications.filter( - (medication) => - medication.status === "entered_in_error", - ) - : []), - ].map((statement) => ( - - ))} - -
    - {hasEnteredInErrorRecords && !showEnteredInError && ( - <> -
    -
    - -
    - - )} - + + {children} ); -} +}; From 807e0beaaa1015a8d9d13c157d139dda3c406ad3 Mon Sep 17 00:00:00 2001 From: AdityaJ2305 Date: Fri, 21 Feb 2025 13:29:41 +0530 Subject: [PATCH 20/26] Print table for Medication talbe --- src/components/Medicine/MedicationsTable.tsx | 36 +++++++++++++++++++- src/components/Patient/TreatmentSummary.tsx | 9 +++-- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/components/Medicine/MedicationsTable.tsx b/src/components/Medicine/MedicationsTable.tsx index a5ab27e1700..f4154388a46 100644 --- a/src/components/Medicine/MedicationsTable.tsx +++ b/src/components/Medicine/MedicationsTable.tsx @@ -12,6 +12,7 @@ import { TableRow, } from "@/components/ui/table"; +import PrintTable from "@/components/Common/PrintTable"; import { reverseFrequencyOption } from "@/components/Questionnaire/QuestionTypes/MedicationRequestQuestion"; import query from "@/Utils/request/query"; @@ -39,11 +40,13 @@ export function getFrequencyDisplay( interface MedicationsTableProps { patientId: string; encounterId: string; + isPrintPreview?: boolean; } export const MedicationsTable = ({ patientId, encounterId, + isPrintPreview = false, }: MedicationsTableProps) => { const { t } = useTranslation(); @@ -68,7 +71,38 @@ export const MedicationsTable = ({ ); } - return ( + + return isPrintPreview ? ( + { + const instruction = medication.dosage_instruction[0]; + const frequency = getFrequencyDisplay(instruction?.timing); + const dosage = formatDosage(instruction); + const duration = instruction?.timing?.repeat?.bounds_duration; + const remarks = formatSig(instruction); + const notes = medication.note; + return { + medicine: medication.medication?.display, + dosage: dosage, + frequency: instruction?.as_needed_boolean + ? `${t("as_needed_prn")} (${instruction?.as_needed_for?.display ?? "-"})` + : (frequency?.meaning ?? "-") + + (instruction?.additional_instruction?.[0]?.display + ? `, ${instruction.additional_instruction[0].display}` + : ""), + duration: duration ? `${duration.value} ${duration.unit}` : "-", + instructions: `${remarks || "-"}${notes ? ` (${t("note")}: ${notes})` : ""}`, + }; + })} + /> + ) : (
    diff --git a/src/components/Patient/TreatmentSummary.tsx b/src/components/Patient/TreatmentSummary.tsx index f288b158968..df287d52ecb 100644 --- a/src/components/Patient/TreatmentSummary.tsx +++ b/src/components/Patient/TreatmentSummary.tsx @@ -3,8 +3,6 @@ import { useQuery } from "@tanstack/react-query"; import { format } from "date-fns"; import { t } from "i18next"; -import { cn } from "@/lib/utils"; - import PrintPreview from "@/CAREUI/misc/PrintPreview"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; @@ -213,14 +211,15 @@ export default function TreatmentSummary({ /> {/* Medications */} - - + + {t("medications")} - + From 5459641038e19a750d58323f97bf378ff45b817c Mon Sep 17 00:00:00 2001 From: AdityaJ2305 Date: Sat, 22 Feb 2025 19:46:10 +0530 Subject: [PATCH 21/26] minor changes --- src/components/Common/PrintTable.tsx | 7 ++++--- src/components/Medicine/MedicationsTable.tsx | 2 ++ src/components/Patient/MedicationStatementList.tsx | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/Common/PrintTable.tsx b/src/components/Common/PrintTable.tsx index c61ee7d0467..e7c57133774 100644 --- a/src/components/Common/PrintTable.tsx +++ b/src/components/Common/PrintTable.tsx @@ -27,11 +27,12 @@ export default function PrintTable({ headers, rows }: GenericTableProps) {
    - {headers.map(({ key, title }, index) => ( + {headers.map(({ key, title, width }, index) => ( @@ -49,7 +50,7 @@ export default function PrintTable({ headers, rows }: GenericTableProps) { > {headers.map(({ key }) => ( {row[key] || "-"} diff --git a/src/components/Medicine/MedicationsTable.tsx b/src/components/Medicine/MedicationsTable.tsx index f4154388a46..4149a4d55c7 100644 --- a/src/components/Medicine/MedicationsTable.tsx +++ b/src/components/Medicine/MedicationsTable.tsx @@ -76,6 +76,7 @@ export const MedicationsTable = ({ - {" "} - {t("ongoing_medications")} ({medicationsCount && medicationsCount}) + {t("ongoing_medications")}{" "} + {medicationsCount ? `(${medicationsCount})` : ""} Date: Sun, 23 Feb 2025 19:22:58 +0530 Subject: [PATCH 22/26] css update --- src/components/Patient/TreatmentSummary.tsx | 45 ++++++++++++--------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/src/components/Patient/TreatmentSummary.tsx b/src/components/Patient/TreatmentSummary.tsx index df287d52ecb..0ec561f3020 100644 --- a/src/components/Patient/TreatmentSummary.tsx +++ b/src/components/Patient/TreatmentSummary.tsx @@ -70,36 +70,39 @@ export default function TreatmentSummary({ {/* Patient Details */} -
    +
    -
    +
    {t("patient")} : - {encounter.patient.name} + + {encounter.patient.name} +
    -
    +
    {`${t("age")} / ${t("sex")}`} : - + {`${formatPatientAge(encounter.patient, true)}, ${t(`GENDER__${encounter.patient.gender}`)}`}
    -
    +
    {t("encounter_class")} : {t(`encounter_class__${encounter.encounter_class}`)}
    -
    +
    {t("priority")} : {t(`encounter_priority__${encounter.priority}`)}
    + {encounter.hospitalization?.admit_source && ( -
    +
    {t("admission_source")} : @@ -110,14 +113,14 @@ export default function TreatmentSummary({
    )} {encounter.hospitalization?.re_admission && ( -
    +
    {t("readmission")} : {t("yes")}
    )} {encounter.hospitalization?.diet_preference && ( -
    +
    {t("diet_preference")} : @@ -128,16 +131,19 @@ export default function TreatmentSummary({
    )}
    + + {/* Right Column */}
    -
    +
    {t("mobile_number")} : - + {encounter.patient.phone_number}
    + {encounter.period?.start && ( -
    +
    {t("encounter_date")} : @@ -148,22 +154,25 @@ export default function TreatmentSummary({
    )} -
    + +
    {t("status")} : {t(`encounter_status__${encounter.status}`)}
    -
    + +
    {t("consulting_doctor")} : {formatName(encounter.created_by)}
    + {encounter.external_identifier && ( -
    +
    {t("external_id")} : @@ -171,8 +180,9 @@ export default function TreatmentSummary({
    )} + {encounter.hospitalization?.discharge_disposition && ( -
    +
    {t("discharge_disposition")} @@ -186,7 +196,6 @@ export default function TreatmentSummary({ )}
    - {/* Medical Information */}
    {/* Allergies */} From 7f05a466bbb315a94a26aa07d9b7e33a74155330 Mon Sep 17 00:00:00 2001 From: AdityaJ2305 Date: Sun, 23 Feb 2025 23:32:18 +0530 Subject: [PATCH 23/26] move printtable to treatment summary --- src/Routers/routes/ConsultationRoutes.tsx | 8 +- .../QuestionnaireResponsesList.tsx | 2 +- src/components/Medicine/MedicationsTable.tsx | 37 +-- .../Patient/MedicationStatementList.tsx | 201 +++++-------- src/components/Patient/TreatmentSummary.tsx | 271 +++++++++++++++--- src/components/Patient/allergy/list.tsx | 189 +++++------- src/components/Patient/diagnosis/list.tsx | 114 +++----- src/components/Patient/symptoms/list.tsx | 111 ++----- 8 files changed, 440 insertions(+), 493 deletions(-) diff --git a/src/Routers/routes/ConsultationRoutes.tsx b/src/Routers/routes/ConsultationRoutes.tsx index 119ac148aa9..080b90a0a54 100644 --- a/src/Routers/routes/ConsultationRoutes.tsx +++ b/src/Routers/routes/ConsultationRoutes.tsx @@ -16,8 +16,12 @@ const consultationRoutes: AppRoutes = { /> ), "/facility/:facilityId/patient/:patientId/encounter/:encounterId/treatment_summary": - ({ facilityId, encounterId }) => ( - + ({ facilityId, encounterId, patientId }) => ( + ), "/facility/:facilityId/patient/:patientId/encounter/:encounterId/questionnaire": ({ facilityId, encounterId, patientId }) => ( diff --git a/src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx b/src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx index 86f9bdbedf8..48d1cc0bc98 100644 --- a/src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx +++ b/src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx @@ -211,7 +211,7 @@ function ResponseCard({
    diff --git a/src/components/Medicine/MedicationsTable.tsx b/src/components/Medicine/MedicationsTable.tsx index 4149a4d55c7..13d94abb8fa 100644 --- a/src/components/Medicine/MedicationsTable.tsx +++ b/src/components/Medicine/MedicationsTable.tsx @@ -12,7 +12,6 @@ import { TableRow, } from "@/components/ui/table"; -import PrintTable from "@/components/Common/PrintTable"; import { reverseFrequencyOption } from "@/components/Questionnaire/QuestionTypes/MedicationRequestQuestion"; import query from "@/Utils/request/query"; @@ -40,13 +39,11 @@ export function getFrequencyDisplay( interface MedicationsTableProps { patientId: string; encounterId: string; - isPrintPreview?: boolean; } export const MedicationsTable = ({ patientId, encounterId, - isPrintPreview = false, }: MedicationsTableProps) => { const { t } = useTranslation(); @@ -72,39 +69,7 @@ export const MedicationsTable = ({ ); } - return isPrintPreview ? ( - { - const instruction = medication.dosage_instruction[0]; - const frequency = getFrequencyDisplay(instruction?.timing); - const dosage = formatDosage(instruction); - const duration = instruction?.timing?.repeat?.bounds_duration; - const remarks = formatSig(instruction); - const notes = medication.note; - return { - medicine: medication.medication?.display, - status: t(medication.status), - dosage: dosage, - frequency: instruction?.as_needed_boolean - ? `${t("as_needed_prn")} (${instruction?.as_needed_for?.display ?? "-"})` - : (frequency?.meaning ?? "-") + - (instruction?.additional_instruction?.[0]?.display - ? `, ${instruction.additional_instruction[0].display}` - : ""), - duration: duration ? `${duration.value} ${duration.unit}` : "-", - instructions: `${remarks || "-"}${notes ? ` (${t("note")}: ${notes})` : ""}`, - }; - })} - /> - ) : ( + return (
    diff --git a/src/components/Patient/MedicationStatementList.tsx b/src/components/Patient/MedicationStatementList.tsx index 19a0b43d2a3..606c00962d7 100644 --- a/src/components/Patient/MedicationStatementList.tsx +++ b/src/components/Patient/MedicationStatementList.tsx @@ -24,7 +24,6 @@ import { } from "@/components/ui/table"; import { Avatar } from "@/components/Common/Avatar"; -import PrintTable from "@/components/Common/PrintTable"; import query from "@/Utils/request/query"; import { formatDateTime, formatName } from "@/Utils/utils"; @@ -37,7 +36,6 @@ import medicationStatementApi from "@/types/emr/medicationStatement/medicationSt interface MedicationStatementListProps { patientId: string; className?: string; - isPrintPreview?: boolean; } interface MedicationRowProps { @@ -115,7 +113,6 @@ function MedicationRow({ statement, isEnteredInError }: MedicationRowProps) { export function MedicationStatementList({ patientId, className = "", - isPrintPreview = false, }: MedicationStatementListProps) { const { t } = useTranslation(); const [showEnteredInError, setShowEnteredInError] = useState(false); @@ -129,10 +126,7 @@ export function MedicationStatementList({ if (isLoading) { return ( - + ); @@ -149,10 +143,7 @@ export function MedicationStatementList({ if (!filteredMedications?.length) { return ( - +

    {t("no_ongoing_medications")}

    ); @@ -160,106 +151,71 @@ export function MedicationStatementList({ return ( - {isPrintPreview ? ( - ({ - medication: - medication.medication.display ?? medication.medication.code, - dosage: medication.dosage_text, - status: medication.status, - medication_taken_between: [ - medication.effective_period?.start, - medication.effective_period?.end, - ] - .map((date) => formatDateTime(date)) - .join(" - "), - reason: medication.reason, - notes: medication.note, - logged_by: formatName(medication.created_by), - }))} - /> - ) : ( - <> -
    - - - - {t("medication")} - - - {t("dosage")} - - - {t("status")} - - - {t("medication_taken_between")} - - - {t("reason")} - - - {t("notes")} - - - {t("logged_by")} - - - - - {[ - ...filteredMedications.filter( - (medication) => medication.status !== "entered_in_error", - ), - ...(showEnteredInError - ? filteredMedications.filter( - (medication) => medication.status === "entered_in_error", - ) - : []), - ].map((statement) => ( - - ))} - -
    - {hasEnteredInErrorRecords && !showEnteredInError && ( - <> -
    -
    - -
    - - )} - - )} + <> + + + + + {t("medication")} + + + {t("dosage")} + + + {t("status")} + + + {t("medication_taken_between")} + + + {t("reason")} + + + {t("notes")} + + + {t("logged_by")} + + + + + {[ + ...filteredMedications.filter( + (medication) => medication.status !== "entered_in_error", + ), + ...(showEnteredInError + ? filteredMedications.filter( + (medication) => medication.status === "entered_in_error", + ) + : []), + ].map((statement) => ( + + ))} + +
    + {hasEnteredInErrorRecords && !showEnteredInError && ( + <> +
    +
    + +
    + + )} + ); } @@ -267,42 +223,21 @@ export function MedicationStatementList({ const MedicationStatementListLayout = ({ children, className, - isPrintPreview = false, medicationsCount, }: { children: React.ReactNode; className?: string; - isPrintPreview?: boolean; medicationsCount?: number | undefined; }) => { return ( - - + + {t("ongoing_medications")}{" "} {medicationsCount ? `(${medicationsCount})` : ""} - - {children} - + {children} ); }; diff --git a/src/components/Patient/TreatmentSummary.tsx b/src/components/Patient/TreatmentSummary.tsx index 0ec561f3020..7a0335fda86 100644 --- a/src/components/Patient/TreatmentSummary.tsx +++ b/src/components/Patient/TreatmentSummary.tsx @@ -7,26 +7,56 @@ import PrintPreview from "@/CAREUI/misc/PrintPreview"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import PrintTable from "@/components/Common/PrintTable"; import QuestionnaireResponsesList from "@/components/Facility/ConsultationDetails/QuestionnaireResponsesList"; -import { MedicationsTable } from "@/components/Medicine/MedicationsTable"; -import { AllergyList } from "@/components/Patient/allergy/list"; -import { DiagnosisList } from "@/components/Patient/diagnosis/list"; -import { SymptomsList } from "@/components/Patient/symptoms/list"; +import { getFrequencyDisplay } from "@/components/Medicine/MedicationsTable"; +import { formatDosage, formatSig } from "@/components/Medicine/utils"; import api from "@/Utils/request/api"; import query from "@/Utils/request/query"; -import { formatName, formatPatientAge } from "@/Utils/utils"; - -import { MedicationStatementList } from "./MedicationStatementList"; +import { formatDateTime, formatName, formatPatientAge } from "@/Utils/utils"; +import allergyIntoleranceApi from "@/types/emr/allergyIntolerance/allergyIntoleranceApi"; +import diagnosisApi from "@/types/emr/diagnosis/diagnosisApi"; +import { completedEncounterStatus } from "@/types/emr/encounter"; +import medicationRequestApi from "@/types/emr/medicationRequest/medicationRequestApi"; +import medicationStatementApi from "@/types/emr/medicationStatement/medicationStatementApi"; +import symptomApi from "@/types/emr/symptom/symptomApi"; interface TreatmentSummaryProps { facilityId: string; encounterId: string; + + patientId: string; } +const SectionLayout = ({ + children, + title, +}: { + title: string; + children: React.ReactNode; +}) => { + return ( + + + {title} + + {children} + + ); +}; + +const EmptyState = ({ message }: { message: string }) => { + return ( + +

    {message}

    +
    + ); +}; export default function TreatmentSummary({ facilityId, encounterId, + patientId, }: TreatmentSummaryProps) { const { data: encounter } = useQuery({ queryKey: ["encounter", encounterId], @@ -36,6 +66,51 @@ export default function TreatmentSummary({ }), }); + const { data: allergies } = useQuery({ + queryKey: ["allergies", patientId, encounterId], + queryFn: query(allergyIntoleranceApi.getAllergy, { + pathParams: { patientId }, + queryParams: { + encounter: ( + encounter?.status + ? completedEncounterStatus.includes(encounter.status) + : false + ) + ? encounterId + : undefined, + }, + }), + }); + + const { data: symptoms } = useQuery({ + queryKey: ["symptoms", patientId, encounterId], + queryFn: query(symptomApi.listSymptoms, { + pathParams: { patientId }, + queryParams: encounterId ? { encounter: encounterId } : undefined, + }), + }); + + const { data: diagnoses } = useQuery({ + queryKey: ["diagnosis", patientId, encounterId], + queryFn: query(diagnosisApi.listDiagnosis, { + pathParams: { patientId }, + queryParams: encounterId ? { encounter: encounterId } : undefined, + }), + }); + + const { data: medications } = useQuery({ + queryKey: ["medication_requests", patientId, encounterId], + queryFn: query(medicationRequestApi.list, { + pathParams: { patientId }, + queryParams: { encounter: encounterId, limit: 50, offset: 0 }, + }), + }); + const { data: medicationStatement } = useQuery({ + queryKey: ["medication_statements", patientId], + queryFn: query(medicationStatementApi.list, { + pathParams: { patientId }, + }), + }); if (!encounter) { return (
    @@ -199,46 +274,168 @@ export default function TreatmentSummary({ {/* Medical Information */}
    {/* Allergies */} - + + {allergies?.count ? ( + ({ + allergen: allergy.code.display, + status: t(allergy.clinical_status), + criticality: t(allergy.criticality), + verification: t(allergy.verification_status), + notes: allergy.note, + logged_by: formatName(allergy.created_by), + }))} + /> + ) : ( + + )} + {/* Symptoms */} - + + + {symptoms?.count ? ( + ({ + symptom: symptom.code.display, + severity: t(symptom.severity), + status: t(symptom.clinical_status), + verification: t(symptom.verification_status), + notes: symptom.note, + logged_by: formatName(symptom.created_by), + }))} + /> + ) : ( + + )} + {/* Diagnoses */} - + + {diagnoses?.count ? ( + ({ + diagnosis: diagnosis.code.display, + status: t(diagnosis.clinical_status), + verification: t(diagnosis.verification_status), + onset: diagnosis.onset?.onset_datetime + ? new Date( + diagnosis.onset.onset_datetime, + ).toLocaleDateString() + : undefined, + notes: diagnosis.note, + logged_by: formatName(diagnosis.created_by), + }))} + /> + ) : ( + + )} + {/* Medications */} - - - {t("medications")} - - - + {!medications?.results.length ? ( + { + const instruction = medication.dosage_instruction[0]; + const frequency = getFrequencyDisplay(instruction?.timing); + const dosage = formatDosage(instruction); + const duration = + instruction?.timing?.repeat?.bounds_duration; + const remarks = formatSig(instruction); + const notes = medication.note; + return { + medicine: medication.medication?.display, + status: t(medication.status), + dosage: dosage, + frequency: instruction?.as_needed_boolean + ? `${t("as_needed_prn")} (${instruction?.as_needed_for?.display ?? "-"})` + : (frequency?.meaning ?? "-") + + (instruction?.additional_instruction?.[0]?.display + ? `, ${instruction.additional_instruction[0].display}` + : ""), + duration: duration + ? `${duration.value} ${duration.unit}` + : "-", + instructions: `${remarks || "-"}${notes ? ` (${t("note")}: ${notes})` : ""}`, + }; + })} /> - - + ) : ( + + )} +
    {/* Medication Statements */} - + + {!medications?.results.length ? ( + ({ + medication: + medication.medication.display ?? medication.medication.code, + dosage: medication.dosage_text, + status: medication.status, + medication_taken_between: [ + medication.effective_period?.start, + medication.effective_period?.end, + ] + .map((date) => formatDateTime(date)) + .join(" - "), + reason: medication.reason, + notes: medication.note, + logged_by: formatName(medication.created_by), + }))} + /> + ) : ( + + )} + {/* Questionnaire Responses Section */}
    diff --git a/src/components/Patient/allergy/list.tsx b/src/components/Patient/allergy/list.tsx index 4172d8bc7e9..4e4fe877a90 100644 --- a/src/components/Patient/allergy/list.tsx +++ b/src/components/Patient/allergy/list.tsx @@ -32,7 +32,6 @@ import { } from "@/components/ui/table"; import { Avatar } from "@/components/Common/Avatar"; -import PrintTable from "@/components/Common/PrintTable"; import query from "@/Utils/request/query"; import { formatName } from "@/Utils/utils"; @@ -51,7 +50,7 @@ interface AllergyListProps { patientId: string; encounterId?: string; className?: string; - isPrintPreview?: boolean; + encounterStatus?: Encounter["status"]; } @@ -73,7 +72,6 @@ export function AllergyList({ patientId, encounterId, className, - isPrintPreview = false, encounterStatus, }: AllergyListProps) { const [showEnteredInError, setShowEnteredInError] = useState(false); @@ -96,7 +94,6 @@ export function AllergyList({ facilityId={facilityId} patientId={patientId} encounterId={encounterId} - className={className} > @@ -120,7 +117,6 @@ export function AllergyList({ facilityId={facilityId} patientId={patientId} encounterId={encounterId} - className={className} >

    {t("no_allergies_recorded")}

    @@ -136,21 +132,24 @@ export function AllergyList({ function AllergyRow({ allergy }: AllergyRowProps) { return (
    {CATEGORY_ICONS[allergy.category ?? ""]}
    - {allergy.code.display} + + {allergy.code.display} + {t(allergy.clinical_status)} @@ -204,7 +203,6 @@ export function AllergyList({ className="w-4 h-4" imageUrl={allergy.created_by.profile_picture_url} /> - {formatName(allergy.created_by)}
    @@ -218,91 +216,65 @@ export function AllergyList({ patientId={patientId} encounterId={encounterId} className={className} - isPrintPreview={isPrintPreview} > - {isPrintPreview ? ( - ({ - allergen: allergy.code.display, - status: t(allergy.clinical_status), - criticality: t(allergy.criticality), - verification: t(allergy.verification_status), - notes: allergy.note, - logged_by: formatName(allergy.created_by), - }))} - /> - ) : ( - <> - - - - - - {t("allergen")} - - - {t("status")} - - - {t("criticality")} - - - {t("verification")} - - - {t("notes")} - - - {t("logged_by")} - - - - - {/* Valid entries */} - {filteredAllergies - .filter( - (allergy) => - allergy.verification_status !== "entered_in_error", - ) - .map((allergy) => ( - - ))} +
    + + + + + {t("allergen")} + + + {t("status")} + + + {t("criticality")} + + + {t("verification")} + + + {t("notes")} + + + {t("logged_by")} + + + + + {/* Valid entries */} + {filteredAllergies + .filter( + (allergy) => allergy.verification_status !== "entered_in_error", + ) + .map((allergy) => ( + + ))} - {/* Entered in error entries */} - {showEnteredInError && - filteredAllergies - .filter( - (allergy) => - allergy.verification_status === "entered_in_error", - ) - .map((allergy) => ( - - ))} - -
    - {hasEnteredInErrorRecords && !showEnteredInError && ( - <> -
    -
    - -
    - - )} + {/* Entered in error entries */} + {showEnteredInError && + filteredAllergies + .filter( + (allergy) => allergy.verification_status === "entered_in_error", + ) + .map((allergy) => ( + + ))} + + + {hasEnteredInErrorRecords && !showEnteredInError && ( + <> +
    +
    + +
    )} @@ -315,30 +287,16 @@ const AllergyListLayout = ({ encounterId, children, className, - isPrintPreview = false, }: { facilityId?: string; patientId: string; encounterId?: string; children: ReactNode; className?: string; - isPrintPreview?: boolean; }) => { return ( - - + + {t("allergies")} {facilityId && encounterId && ( )} - - {children} - + {children} ); }; diff --git a/src/components/Patient/diagnosis/list.tsx b/src/components/Patient/diagnosis/list.tsx index e45392bdb7b..cb682456b02 100644 --- a/src/components/Patient/diagnosis/list.tsx +++ b/src/components/Patient/diagnosis/list.tsx @@ -11,10 +11,7 @@ import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Skeleton } from "@/components/ui/skeleton"; -import PrintTable from "@/components/Common/PrintTable"; - import query from "@/Utils/request/query"; -import { formatName } from "@/Utils/utils"; import diagnosisApi from "@/types/emr/diagnosis/diagnosisApi"; import { DiagnosisTable } from "./DiagnosisTable"; @@ -24,7 +21,6 @@ interface DiagnosisListProps { encounterId?: string; facilityId?: string; className?: string; - isPrintPreview?: boolean; } export function DiagnosisList({ @@ -32,7 +28,6 @@ export function DiagnosisList({ encounterId, facilityId, className, - isPrintPreview = false, }: DiagnosisListProps) { const [showEnteredInError, setShowEnteredInError] = useState(false); @@ -51,7 +46,6 @@ export function DiagnosisList({ patientId={patientId} encounterId={encounterId} className={className} - isPrintPreview={isPrintPreview} > @@ -77,7 +71,6 @@ export function DiagnosisList({ patientId={patientId} encounterId={encounterId} className={className} - isPrintPreview={isPrintPreview} >

    {t("no_diagnoses_recorded")}

    @@ -92,64 +85,39 @@ export function DiagnosisList({ patientId={patientId} encounterId={encounterId} className={className} - isPrintPreview={isPrintPreview} > - {isPrintPreview ? ( - + + diagnosis.verification_status !== "entered_in_error", + ), + ...(showEnteredInError + ? filteredDiagnoses.filter( + (diagnosis) => + diagnosis.verification_status === "entered_in_error", + ) + : []), ]} - rows={diagnoses?.results.map((diagnosis) => ({ - diagnosis: diagnosis.code.display, - status: t(diagnosis.clinical_status), - verification: t(diagnosis.verification_status), - onset: diagnosis.onset?.onset_datetime - ? new Date(diagnosis.onset.onset_datetime).toLocaleDateString() - : undefined, - notes: diagnosis.note, - logged_by: formatName(diagnosis.created_by), - }))} /> - ) : ( - <> - - diagnosis.verification_status !== "entered_in_error", - ), - ...(showEnteredInError - ? filteredDiagnoses.filter( - (diagnosis) => - diagnosis.verification_status === "entered_in_error", - ) - : []), - ]} - /> - {hasEnteredInErrorRecords && !showEnteredInError && ( - <> -
    -
    - -
    - - )} - - )} + {hasEnteredInErrorRecords && !showEnteredInError && ( + <> +
    +
    + +
    + + )} + ); } @@ -160,28 +128,17 @@ const DiagnosisListLayout = ({ encounterId, children, className, - isPrintPreview = false, }: { facilityId?: string; patientId: string; encounterId?: string; children: ReactNode; className?: string; - isPrintPreview?: boolean; }) => { return ( - + {t("diagnoses")} {facilityId && encounterId && ( @@ -194,14 +151,7 @@ const DiagnosisListLayout = ({ )} - - {children} - + {children} ); }; diff --git a/src/components/Patient/symptoms/list.tsx b/src/components/Patient/symptoms/list.tsx index af210f40fcc..891154584f1 100644 --- a/src/components/Patient/symptoms/list.tsx +++ b/src/components/Patient/symptoms/list.tsx @@ -11,10 +11,7 @@ import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Skeleton } from "@/components/ui/skeleton"; -import PrintTable from "@/components/Common/PrintTable"; - import query from "@/Utils/request/query"; -import { formatName } from "@/Utils/utils"; import symptomApi from "@/types/emr/symptom/symptomApi"; import { SymptomTable } from "./SymptomTable"; @@ -24,7 +21,6 @@ interface SymptomsListProps { encounterId?: string; facilityId?: string; className?: string; - isPrintPreview?: boolean; } export function SymptomsList({ @@ -32,7 +28,6 @@ export function SymptomsList({ encounterId, facilityId, className, - isPrintPreview = false, }: SymptomsListProps) { const [showEnteredInError, setShowEnteredInError] = useState(false); @@ -50,8 +45,6 @@ export function SymptomsList({ facilityId={facilityId} patientId={patientId} encounterId={encounterId} - className={className} - isPrintPreview={isPrintPreview} > @@ -75,8 +68,6 @@ export function SymptomsList({ facilityId={facilityId} patientId={patientId} encounterId={encounterId} - className={className} - isPrintPreview={isPrintPreview} >

    {t("no_symptoms_recorded")}

    @@ -91,58 +82,33 @@ export function SymptomsList({ patientId={patientId} encounterId={encounterId} className={className} - isPrintPreview={isPrintPreview} > - {isPrintPreview ? ( - ({ - symptom: symptom.code.display, - severity: t(symptom.severity), - status: t(symptom.clinical_status), - verification: t(symptom.verification_status), - notes: symptom.note, - logged_by: formatName(symptom.created_by), - }))} - /> - ) : ( + symptom.verification_status !== "entered_in_error", + ), + ...(showEnteredInError + ? filteredSymptoms.filter( + (symptom) => symptom.verification_status === "entered_in_error", + ) + : []), + ]} + /> + + {hasEnteredInErrorRecords && !showEnteredInError && ( <> - symptom.verification_status !== "entered_in_error", - ), - ...(showEnteredInError - ? filteredSymptoms.filter( - (symptom) => - symptom.verification_status === "entered_in_error", - ) - : []), - ]} - /> - - {hasEnteredInErrorRecords && !showEnteredInError && ( - <> -
    -
    - -
    - - )} +
    +
    + +
    )} @@ -155,30 +121,16 @@ const SymptomListLayout = ({ encounterId, children, className, - isPrintPreview = false, }: { facilityId?: string; patientId: string; encounterId?: string; children: ReactNode; className?: string; - isPrintPreview?: boolean; }) => { return ( - - + + {t("symptoms")} {facilityId && encounterId && ( )} - - {children} - + {children} ); }; From af299a46f28c39d6448a826716bcd03925574a20 Mon Sep 17 00:00:00 2001 From: AdityaJ2305 Date: Sun, 23 Feb 2025 23:40:06 +0530 Subject: [PATCH 24/26] minor fixes --- src/components/Patient/TreatmentSummary.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Patient/TreatmentSummary.tsx b/src/components/Patient/TreatmentSummary.tsx index 7a0335fda86..905fef3d144 100644 --- a/src/components/Patient/TreatmentSummary.tsx +++ b/src/components/Patient/TreatmentSummary.tsx @@ -353,13 +353,13 @@ export default function TreatmentSummary({ }))} /> ) : ( - + )} {/* Medications */} - {!medications?.results.length ? ( + {medications?.results.length ? ( - {!medications?.results.length ? ( + {medicationStatement?.results.length ? ( Date: Mon, 24 Feb 2025 00:17:10 +0530 Subject: [PATCH 25/26] minor fixes --- .../QuestionnaireResponsesList.tsx | 9 ++- src/components/Patient/TreatmentSummary.tsx | 75 ++++++++++--------- 2 files changed, 45 insertions(+), 39 deletions(-) diff --git a/src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx b/src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx index 48d1cc0bc98..c6fc5667222 100644 --- a/src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx +++ b/src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx @@ -211,7 +211,7 @@ function ResponseCard({
    @@ -328,7 +328,12 @@ export default function QuestionnaireResponsesList({ ) : (
    {questionnarieResponses?.results?.length === 0 ? ( - +
    {t("no_questionnaire_responses")}
    diff --git a/src/components/Patient/TreatmentSummary.tsx b/src/components/Patient/TreatmentSummary.tsx index 905fef3d144..baa49645a1f 100644 --- a/src/components/Patient/TreatmentSummary.tsx +++ b/src/components/Patient/TreatmentSummary.tsx @@ -398,44 +398,45 @@ export default function TreatmentSummary({ )} -
    - {/* Medication Statements */} - - {medicationStatement?.results.length ? ( - ({ - medication: - medication.medication.display ?? medication.medication.code, - dosage: medication.dosage_text, - status: medication.status, - medication_taken_between: [ - medication.effective_period?.start, - medication.effective_period?.end, - ] - .map((date) => formatDateTime(date)) - .join(" - "), - reason: medication.reason, - notes: medication.note, - logged_by: formatName(medication.created_by), - }))} - /> - ) : ( - - )} - + {/* Medication Statements */} + + {medicationStatement?.results.length ? ( + ({ + medication: + medication.medication.display ?? + medication.medication.code, + dosage: medication.dosage_text, + status: medication.status, + medication_taken_between: [ + medication.effective_period?.start, + medication.effective_period?.end, + ] + .map((date) => formatDateTime(date)) + .join(" - "), + reason: medication.reason, + notes: medication.note, + logged_by: formatName(medication.created_by), + }))} + /> + ) : ( + + )} + +
    {/* Questionnaire Responses Section */}
    From 4d1dd2226551cb64a7cdb5191b0e12401a0917ea Mon Sep 17 00:00:00 2001 From: AdityaJ2305 Date: Mon, 24 Feb 2025 00:35:32 +0530 Subject: [PATCH 26/26] loading state handled --- src/components/Patient/TreatmentSummary.tsx | 42 ++++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/src/components/Patient/TreatmentSummary.tsx b/src/components/Patient/TreatmentSummary.tsx index baa49645a1f..01c3757b21f 100644 --- a/src/components/Patient/TreatmentSummary.tsx +++ b/src/components/Patient/TreatmentSummary.tsx @@ -2,6 +2,7 @@ import careConfig from "@careConfig"; import { useQuery } from "@tanstack/react-query"; import { format } from "date-fns"; import { t } from "i18next"; +import { Loader } from "lucide-react"; import PrintPreview from "@/CAREUI/misc/PrintPreview"; @@ -66,7 +67,7 @@ export default function TreatmentSummary({ }), }); - const { data: allergies } = useQuery({ + const { data: allergies, isLoading: allergiesLoading } = useQuery({ queryKey: ["allergies", patientId, encounterId], queryFn: query(allergyIntoleranceApi.getAllergy, { pathParams: { patientId }, @@ -82,7 +83,7 @@ export default function TreatmentSummary({ }), }); - const { data: symptoms } = useQuery({ + const { data: symptoms, isLoading: symptomsLoading } = useQuery({ queryKey: ["symptoms", patientId, encounterId], queryFn: query(symptomApi.listSymptoms, { pathParams: { patientId }, @@ -90,7 +91,7 @@ export default function TreatmentSummary({ }), }); - const { data: diagnoses } = useQuery({ + const { data: diagnoses, isLoading: diagnosesLoading } = useQuery({ queryKey: ["diagnosis", patientId, encounterId], queryFn: query(diagnosisApi.listDiagnosis, { pathParams: { patientId }, @@ -98,19 +99,21 @@ export default function TreatmentSummary({ }), }); - const { data: medications } = useQuery({ + const { data: medications, isLoading: medicationsLoading } = useQuery({ queryKey: ["medication_requests", patientId, encounterId], queryFn: query(medicationRequestApi.list, { pathParams: { patientId }, queryParams: { encounter: encounterId, limit: 50, offset: 0 }, }), }); - const { data: medicationStatement } = useQuery({ - queryKey: ["medication_statements", patientId], - queryFn: query(medicationStatementApi.list, { - pathParams: { patientId }, - }), - }); + const { data: medicationStatement, isLoading: medicationStatementLoading } = + useQuery({ + queryKey: ["medication_statements", patientId], + queryFn: query(medicationStatementApi.list, { + pathParams: { patientId }, + }), + }); + if (!encounter) { return (
    @@ -119,6 +122,25 @@ export default function TreatmentSummary({ ); } + const isLoading = + allergiesLoading || + diagnosesLoading || + symptomsLoading || + medicationsLoading || + medicationStatementLoading; + + if (isLoading) { + return ( + +
    + +
    +
    + ); + } + return (