diff --git a/src/Components/Diagnosis/DiagnosesListAccordion.tsx b/src/Components/Diagnosis/DiagnosesListAccordion.tsx new file mode 100644 index 00000000000..603e622c1a4 --- /dev/null +++ b/src/Components/Diagnosis/DiagnosesListAccordion.tsx @@ -0,0 +1,107 @@ +import { + ActiveConditionVerificationStatuses, + ConditionVerificationStatus, + ConsultationDiagnosis, +} from "./types"; +import { useTranslation } from "react-i18next"; +import { classNames, compareBy } from "../../Utils/utils"; +import { useState } from "react"; +import CareIcon from "../../CAREUI/icons/CareIcon"; +import ButtonV2 from "../Common/components/ButtonV2"; + +interface Props { + diagnoses: ConsultationDiagnosis[]; +} + +type GroupedDiagnoses = Record< + ConditionVerificationStatus, + ConsultationDiagnosis[] +>; + +function groupDiagnoses(diagnoses: ConsultationDiagnosis[]) { + const groupedDiagnoses = {} as GroupedDiagnoses; + + for (const status of ActiveConditionVerificationStatuses) { + groupedDiagnoses[status] = diagnoses + .filter((d) => d.verification_status === status) + .sort(compareBy("is_principal")); + } + + return groupedDiagnoses; +} + +export default function DiagnosesListAccordion(props: Props) { + const [isVisible, setIsVisible] = useState(true); + const diagnoses = groupDiagnoses(props.diagnoses); + + return ( +
+
+ {!isVisible && ( + { + setIsVisible((prev) => !prev); + }} + > + + Expand Diagnoses + + )} +
+
+

+ Diagnoses +

+
+ {Object.entries(diagnoses).map( + ([status, diagnoses]) => + !!diagnoses.length && ( + + ) + )} +
+ { + setIsVisible(false); + }} + > + + Hide Diagnoses + +
+
+ ); +} + +const DiagnosesOfStatus = ({ diagnoses }: Props) => { + const { t } = useTranslation(); + + return ( +
+

+ {t(diagnoses[0].verification_status)} {t("diagnoses")}{" "} + ({t("icd11_as_recommended")}) +

+ +
+ ); +}; diff --git a/src/Components/Diagnosis/LegacyDiagnosesList.tsx b/src/Components/Diagnosis/LegacyDiagnosesList.tsx deleted file mode 100644 index e8beafe29ad..00000000000 --- a/src/Components/Diagnosis/LegacyDiagnosesList.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import { - ActiveConditionVerificationStatuses, - ConditionVerificationStatus, - ConsultationDiagnosis, -} from "./types"; -import { useTranslation } from "react-i18next"; -import { compareBy } from "../../Utils/utils"; - -interface Props { - diagnoses: ConsultationDiagnosis[]; -} - -type GroupedDiagnoses = Record< - ConditionVerificationStatus, - ConsultationDiagnosis[] ->; - -function groupDiagnoses(diagnoses: ConsultationDiagnosis[]) { - const groupedDiagnoses = {} as GroupedDiagnoses; - - for (const status of ActiveConditionVerificationStatuses) { - groupedDiagnoses[status] = diagnoses - .filter((d) => d.verification_status === status) - .sort(compareBy("is_principal")); - } - - return groupedDiagnoses; -} - -export default function LegacyDiagnosesList(props: Props) { - const diagnoses = groupDiagnoses(props.diagnoses); - - return ( -
- {Object.entries(diagnoses).map( - ([status, diagnoses]) => - !!diagnoses.length && ( - - ) - )} -
- ); -} - -const DiagnosesOfStatus = ({ diagnoses }: Props) => { - const { t } = useTranslation(); - - return ( -
-

- {t(diagnoses[0].verification_status)} {t("diagnoses")}{" "} - ({t("icd11_as_recommended")}) -

- -
- ); -}; diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx index 47d663f731d..071e7bfc1af 100644 --- a/src/Components/Facility/ConsultationDetails/index.tsx +++ b/src/Components/Facility/ConsultationDetails/index.tsx @@ -39,8 +39,7 @@ import PatientNotesSlideover from "../PatientNotesSlideover"; import { AssetBedModel } from "../../Assets/AssetTypes"; import PatientInfoCard from "../../Patient/PatientInfoCard"; import RelativeDateUserMention from "../../Common/RelativeDateUserMention"; -import LegacyDiagnosesList from "../../Diagnosis/LegacyDiagnosesList"; -import AccordionV2 from "../../Common/components/AccordionV2"; +import DiagnosesListAccordion from "../../Diagnosis/DiagnosesListAccordion"; const Loading = lazy(() => import("../../Common/Loading")); const PageTitle = lazy(() => import("../../Common/PageTitle")); @@ -404,20 +403,9 @@ export const ConsultationDetails = (props: any) => {
- - Diagnoses - - } - > -
- -
-
+