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

Block expired patients from being transfered #8123

Merged
merged 9 commits into from
Jul 17, 2024
11 changes: 7 additions & 4 deletions cypress/e2e/patient_spec/patient_registration.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ describe("Patient Creation with consultation", () => {
});

it("Patient Registration using the transfer with no consultation", () => {
// transfer the patient and no consulation
// transfer the patient with no consulation and verify the transfer to a new facility
patientPage.createPatient();
patientPage.selectFacility(patientTransferFacility);
patientPage.patientformvisibility();
Expand All @@ -264,9 +264,10 @@ describe("Patient Creation with consultation", () => {
patientTransfer.clickTransferPatientNameList(patientTransferName);
patientTransfer.clickTransferPatientYOB(yearOfBirth);
patientTransfer.clickTransferSubmitButton();
patientTransfer.verifyFacilitySuccessfullMessage();
cy.verifyNotification(
"Patient Dummy Patient 10 (Male) transferred successfully",
);
patientTransfer.clickConsultationCancelButton();
cy.wait(3000);
// allow the transfer button of a patient
patientTransfer.clickAllowPatientTransferButton();
// Verify the patient error message for the same facility
Expand All @@ -280,7 +281,9 @@ describe("Patient Creation with consultation", () => {
patientTransfer.clickTransferPatientNameList(patientTransferName);
patientTransfer.clickTransferPatientYOB(yearOfBirth);
patientTransfer.clickTransferSubmitButton();
patientTransfer.verifyFacilityErrorMessage();
cy.verifyNotification(
"Patient - Patient transfer cannot be completed because the patient has an active consultation in the same facility",
);
});

it("Patient Registration using External Result Import", () => {
Expand Down
30 changes: 2 additions & 28 deletions cypress/pageobject/Patient/PatientTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,44 +19,18 @@ class PatientTransfer {

clickTransferSubmitButton() {
cy.get("#submit-transferpatient").click();
cy.wait(2000);
}

clickConsultationCancelButton() {
cy.get("#cancel").scrollIntoView();
cy.get("#cancel").click();
cy.wait(2000);
}

clickAllowPatientTransferButton() {
cy.get("#patient-allow-transfer").click();
}

verifyFacilitySuccessfullMessage() {
cy.get(".pnotify")
.should("exist")
.within(() => {
cy.get(".pnotify-text")
.invoke("text")
.then((text) => {
expect(text.trim()).to.match(
/^Patient Dummy Patient 10 \(Male\) transferred successfully$/i,
);
});
});
}

verifyFacilityErrorMessage() {
cy.get(".pnotify")
.should("exist")
.within(() => {
cy.get(".pnotify-text")
.invoke("text")
.then((text) => {
expect(text).to.match(
/Patient - Patient transfer cannot be completed because the patient has an active consultation in the same facility/,
);
});
});
}
}

export default PatientTransfer;
1 change: 1 addition & 0 deletions cypress/support/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// <reference types="cypress" />
import "./commands";

declare global {
Expand Down
21 changes: 16 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/forms": "^0.5.7",
"@tailwindcss/typography": "^0.5.13",
"@types/cypress": "^1.1.3",
"@types/echarts": "^4.9.22",
"@types/google.maps": "^3.55.8",
"@types/lodash-es": "^4.17.12",
Expand All @@ -127,7 +128,7 @@
"@typescript-eslint/parser": "^5.61.0",
"@vitejs/plugin-react-swc": "^3.6.0",
"autoprefixer": "^10.4.19",
"cypress": "^13.9.0",
"cypress": "^13.13.1",
"cypress-localstorage-commands": "^2.2.5",
"cypress-split": "^1.23.2",
"eslint": "^8.44.0",
Expand Down
8 changes: 6 additions & 2 deletions src/Components/Facility/DischargeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,13 @@ const DischargeModal = ({
title={
<div>
<p>Discharge patient from CARE</p>
<span className="mt-1 flex gap-1 text-sm font-medium text-warning-500">
<span className="mt-1 flex gap-1 text-sm font-medium text-danger-500">
<CareIcon icon="l-exclamation-triangle" className="text-base" />
<p>Caution: this action is irreversible.</p>
<p>
{new_discharge_reason === 3 // Expired
? "Caution: Once a patient is marked as expired, the patient file cannot be transferred or edited. Please proceed with caution."
: "Caution: This action is irrevesible. Please proceed with caution."}
</p>
</span>
</div>
}
Expand Down
8 changes: 7 additions & 1 deletion src/Components/Facility/TransferPatientDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ const TransferPatientDialog = (props: Props) => {
const patientOptions: Array<OptionsType> = patientList.map((patient) => {
return {
id: patient.patient_id as unknown as number,
text: `${patient.name} (${patient.gender})`,
text: [
patient.name,
`(${patient.gender})`,
patient.is_expired ? "(Expired)" : "",
].join(" "),
disabled: patient.is_expired,
};
});

Expand Down Expand Up @@ -171,6 +176,7 @@ const TransferPatientDialog = (props: Props) => {
options={patientOptions}
optionLabel={(patient) => patient.text}
optionValue={(patient) => patient.id}
optionDisabled={(patient) => patient.disabled ?? false}
value={state.form.patient}
onChange={handleChange}
error={state.errors.patient}
Expand Down
1 change: 1 addition & 0 deletions src/Components/Facility/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export interface DupPatientModel {
date_of_birth: string;
year_of_birth: number;
state_id: number;
is_expired: boolean;
}

export interface InventoryItemsModel {
Expand Down
6 changes: 3 additions & 3 deletions src/Components/Form/MultiSelectMenuV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ const MultiSelectMenuV2 = <T, V>(props: Props<T, V>) => {
className={classNames(
"text-sm font-normal",
option.disabled
? "text-secondary-700"
? "text-secondary-500"
: active
? "text-primary-200"
: "text-secondary-700",
: "text-secondary-500",
)}
>
{option.description}
Expand Down Expand Up @@ -226,7 +226,7 @@ export const dropdownOptionClassNames = ({
!disabled && active && "bg-primary-500 text-white",
!disabled && !active && selected && "text-primary-500",
!disabled && !active && !selected && "text-secondary-900",
disabled && "cursor-not-allowed text-secondary-800",
disabled && "cursor-not-allowed text-secondary-600",
selected ? "font-semibold" : "font-normal",
);
};
Loading