From 02cee9757b53af77abbf0618fc5903189028574f Mon Sep 17 00:00:00 2001 From: Steve Tsala <45661418+SteveGT96@users.noreply.github.com> Date: Thu, 12 Oct 2023 16:25:45 +0100 Subject: [PATCH] OH2-240: Improve discharge page (#525) --- .../currentAdmission/CurrentAdmission.tsx | 7 ++--- .../CurrentAdmissionData.tsx | 19 +++++--------- .../accessories/currentAdmission/types.ts | 2 +- .../discharge/PatientDischarge.tsx | 24 ++++++++++------- .../discharge/dischargeForm/DischargeForm.tsx | 26 +++++++++---------- 5 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/components/accessories/currentAdmission/CurrentAdmission.tsx b/src/components/accessories/currentAdmission/CurrentAdmission.tsx index 36ead8e96..e165ca913 100644 --- a/src/components/accessories/currentAdmission/CurrentAdmission.tsx +++ b/src/components/accessories/currentAdmission/CurrentAdmission.tsx @@ -13,7 +13,6 @@ import { IOwnProps } from "./types"; export const CurrentAdmission: FunctionComponent = ({ onEditChange, }) => { - const { t } = useTranslation(); const dispatch = useDispatch(); const [editionMode, setEditionMode] = useState(false); const currentAdmission = useSelector( @@ -50,14 +49,16 @@ export const CurrentAdmission: FunctionComponent = ({ }; useEffect(() => { - onEditChange(editionMode); + if (onEditChange) { + onEditChange(editionMode); + } }, [editionMode]); return (
{currentAdmission && !editionMode && ( )} diff --git a/src/components/accessories/currentAdmission/currentAdmissionData/CurrentAdmissionData.tsx b/src/components/accessories/currentAdmission/currentAdmissionData/CurrentAdmissionData.tsx index d2eab5242..d23b83818 100644 --- a/src/components/accessories/currentAdmission/currentAdmissionData/CurrentAdmissionData.tsx +++ b/src/components/accessories/currentAdmission/currentAdmissionData/CurrentAdmissionData.tsx @@ -2,20 +2,13 @@ import { IconButton } from "@material-ui/core"; import { Edit } from "@material-ui/icons"; import React, { FunctionComponent } from "react"; import { useTranslation } from "react-i18next"; -import { useDispatch, useSelector } from "react-redux"; -import { AdmissionDTO, PatientDTO } from "../../../../generated"; -import { parseDate } from "../../../../libraries/formDataHandling/functions"; -import { IState } from "../../../../types"; -import Button from "../../button/Button"; -import TextField from "../../textField/TextField"; +import { AdmissionDTO } from "../../../../generated"; import "../styles.scss"; -import AutocompleteField from "../../autocompleteField/AutocompleteField"; -import DateField from "../../dateField/DateField"; import isEmpty from "lodash.isempty"; import { renderDate } from "../../../../libraries/formatUtils/dataFormatting"; interface IOwnProps { - onEdit: () => void; + onEdit?: () => void; admission: AdmissionDTO; } @@ -28,9 +21,11 @@ export const CurrentAdmissionData: FunctionComponent = ({ return (
- - - + {onEdit && ( + + + + )}
{!isEmpty(admission?.ward?.description) && ( diff --git a/src/components/accessories/currentAdmission/types.ts b/src/components/accessories/currentAdmission/types.ts index a5a849d04..0379c2438 100644 --- a/src/components/accessories/currentAdmission/types.ts +++ b/src/components/accessories/currentAdmission/types.ts @@ -1,3 +1,3 @@ export interface IOwnProps { - onEditChange: (value: boolean) => void; + onEditChange?: (value: boolean) => void; } diff --git a/src/components/accessories/discharge/PatientDischarge.tsx b/src/components/accessories/discharge/PatientDischarge.tsx index 431d849c0..b603c980a 100644 --- a/src/components/accessories/discharge/PatientDischarge.tsx +++ b/src/components/accessories/discharge/PatientDischarge.tsx @@ -18,6 +18,7 @@ import { useFields } from "./useFields"; import DischargeForm from "./dischargeForm/DischargeForm"; import { getPatientThunk } from "../../../state/patients/actions"; import { parseDate } from "../../../libraries/formDataHandling/functions"; +import { CurrentAdmission } from "../currentAdmission/CurrentAdmission"; const PatientDischarge: FC = () => { const { t } = useTranslation(); @@ -106,16 +107,19 @@ const PatientDischarge: FC = () => { return (
{currentAdmissionStatus === "SUCCESS" && ( - + <> + + + )} {currentAdmissionStatus === "SUCCESS_EMPTY" && (
diff --git a/src/components/accessories/discharge/dischargeForm/DischargeForm.tsx b/src/components/accessories/discharge/dischargeForm/DischargeForm.tsx index 5fe529a76..6176a71ca 100644 --- a/src/components/accessories/discharge/dischargeForm/DischargeForm.tsx +++ b/src/components/accessories/discharge/dischargeForm/DischargeForm.tsx @@ -238,19 +238,6 @@ const DischargeForm: FC = ({
-
- -
= ({ disabled={isLoading} />
+
+ +