Skip to content

Commit

Permalink
update(OH2-216): Remove current admission from admission table and ad…
Browse files Browse the repository at this point in the history
…d current admission component
  • Loading branch information
SteveGT96 committed Sep 15, 2023
1 parent d20293c commit b9703b2
Show file tree
Hide file tree
Showing 12 changed files with 669 additions and 630 deletions.
12 changes: 11 additions & 1 deletion src/components/accessories/admission/PatientAdmission.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import PatientAdmissionTable from "./admissionTable/AdmissionTable";
import { isEmpty } from "lodash";
import { usePermission } from "../../../libraries/permissionUtils/usePermission";
import { getLastOpd } from "../../../state/opds/actions";
import { CurrentAdmission } from "../currentAdmission/CurrentAdmission";

const PatientAdmission: FC = () => {
const { t } = useTranslation();
Expand All @@ -31,6 +32,7 @@ const PatientAdmission: FC = () => {
const infoBoxRef = useRef<HTMLDivElement>(null);
const [shouldResetForm, setShouldResetForm] = useState(false);
const [creationMode, setCreationMode] = useState(true);
const [isEditingCurrent, setIsEditingCurrent] = useState(false);
const [showForm, setShowForm] = useState(false);
const [admissionToEdit, setAdmissionToEdit] =
useState<AdmissionDTO | undefined>();
Expand Down Expand Up @@ -188,11 +190,16 @@ const PatientAdmission: FC = () => {
scrollToElement(null);
};

const onCurrentAdmissionChange = (value: boolean) => {
setIsEditingCurrent(value);
};

return (
<div className="patientAdmission">
{patient?.status === PatientDTOStatusEnum.I && (
<InfoBox type="info" message={t("admission.patientalreadyadmitted")} />
)}
<CurrentAdmission onEditChange={onCurrentAdmissionChange} />
{open && (
<AdmissionForm
fields={fields}
Expand Down Expand Up @@ -224,7 +231,10 @@ const PatientAdmission: FC = () => {
/>

<ConfirmationDialog
isOpen={createStatus === "SUCCESS" || updateStatus === "SUCCESS"}
isOpen={
(createStatus === "SUCCESS" || updateStatus === "SUCCESS") &&
!isEditingCurrent
}
title={creationMode ? t("admission.created") : t("admission.updated")}
icon={checkIcon}
info={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ const PatientAdmissionTable: FunctionComponent<IOwnProps> = ({

const data = useSelector<IState, AdmissionDTO[]>((state) =>
state.admissions.getPatientAdmissions.data
? state.admissions.getPatientAdmissions.data
? state.admissions.getPatientAdmissions.data.filter(
(e) => state.admissions.currentAdmissionByPatientId.data?.id !== e.id
)
: []
);

Expand Down
Loading

0 comments on commit b9703b2

Please sign in to comment.