Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabled view files and assign volunteer for discharged patients #9278

Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/components/Patient/PatientHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import Loading from "../Common/Loading";
import Page from "../Common/Page";
import { SkillModel, UserBareMinimum } from "../Users/models";
import { patientTabs } from "./PatientDetailsTab";
import { isPatientDischarged } from "./Utils";
import { isPatientMandatoryDataFilled } from "./Utils";
import { AssignedToObjectModel, PatientModel, SampleTestModel } from "./models";

Expand Down Expand Up @@ -501,6 +502,7 @@ export const PatientHome = (props: {
className="w-full bg-white font-semibold text-green-800 hover:bg-secondary-200"
id="upload-patient-files"
size="large"
disabled={isPatientDischarged(patientData, facilityId)}
onClick={() =>
navigate(
`/facility/${patientData?.facility}/patient/${id}/files`,
Expand All @@ -519,7 +521,10 @@ export const PatientHome = (props: {
<ButtonV2
id="assign-volunteer"
onClick={() => setOpenAssignVolunteerDialog(true)}
disabled={false}
disabled={isPatientDischarged(
patientData,
facilityId,
)}
authorizeFor={NonReadOnlyUsers}
className="w-full bg-white font-semibold text-green-800 hover:bg-secondary-200"
size="large"
Expand Down
10 changes: 10 additions & 0 deletions src/components/Patient/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@ export function isPatientMandatoryDataFilled(patient: PatientModel) {
patient.blood_group
);
}
export const isPatientDischarged = (
patientData: PatientModel,
facilityId: string | undefined,
) => {
if (!patientData.is_active) return true;
if (facilityId !== patientData.facility_object?.id.toString()) {
return true;
}
return false;
nithish1018 marked this conversation as resolved.
Show resolved Hide resolved
};
Loading