From f5ee9f04c6d6738ffd7f2c9fb9ca986d4ee5b9b2 Mon Sep 17 00:00:00 2001 From: Khavin Shankar Date: Mon, 8 Jul 2024 15:06:56 +0530 Subject: [PATCH 1/8] disable expired patients in patient transfer form --- src/Components/Facility/TransferPatientDialog.tsx | 2 ++ src/Components/Facility/models.tsx | 1 + 2 files changed, 3 insertions(+) diff --git a/src/Components/Facility/TransferPatientDialog.tsx b/src/Components/Facility/TransferPatientDialog.tsx index 05d08635b01..3aede6dff84 100644 --- a/src/Components/Facility/TransferPatientDialog.tsx +++ b/src/Components/Facility/TransferPatientDialog.tsx @@ -59,6 +59,7 @@ const TransferPatientDialog = (props: Props) => { return { id: patient.patient_id as unknown as number, text: `${patient.name} (${patient.gender})`, + disabled: patient.is_expired, }; }); @@ -171,6 +172,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} diff --git a/src/Components/Facility/models.tsx b/src/Components/Facility/models.tsx index 74a0d4a0f26..6eb9b92e3ae 100644 --- a/src/Components/Facility/models.tsx +++ b/src/Components/Facility/models.tsx @@ -202,6 +202,7 @@ export interface DupPatientModel { date_of_birth: string; year_of_birth: number; state_id: number; + is_expired: boolean; } export interface InventoryItemsModel { From d2c351ffc721cf939249668ddf831a50323263ac Mon Sep 17 00:00:00 2001 From: Khavin Shankar Date: Mon, 8 Jul 2024 15:10:04 +0530 Subject: [PATCH 2/8] altered warning text and color in discharge patient modal --- src/Components/Facility/DischargeModal.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index 0be7b4eabd8..a2181ee67d9 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -210,9 +210,12 @@ const DischargeModal = ({ title={

Discharge patient from CARE

- + -

Caution: this action is irreversible.

+

+ Caution: Once a patient is marked as expired, the patient file + cannot be transferred or edited. Please proceed with caution. +

} From 644a232f6abd0a35c2dce0451fb05847cd08143d Mon Sep 17 00:00:00 2001 From: Khavin Shankar Date: Tue, 9 Jul 2024 09:47:22 +0530 Subject: [PATCH 3/8] added caution message based on expired condition in discharge modal --- src/Components/Facility/DischargeModal.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index a2181ee67d9..3b7a802d981 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -213,8 +213,9 @@ const DischargeModal = ({

- Caution: Once a patient is marked as expired, the patient file - cannot be transferred or edited. Please proceed with caution. + {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."}

From 37e33692e4be1a58061602a8ac7cb67e41489b29 Mon Sep 17 00:00:00 2001 From: Khavin Shankar Date: Tue, 9 Jul 2024 14:24:59 +0530 Subject: [PATCH 4/8] show expired for expired patients in transfer modal --- src/Components/Facility/TransferPatientDialog.tsx | 6 +++++- src/Components/Form/MultiSelectMenuV2.tsx | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Components/Facility/TransferPatientDialog.tsx b/src/Components/Facility/TransferPatientDialog.tsx index 3aede6dff84..3ead082c610 100644 --- a/src/Components/Facility/TransferPatientDialog.tsx +++ b/src/Components/Facility/TransferPatientDialog.tsx @@ -58,7 +58,11 @@ const TransferPatientDialog = (props: Props) => { const patientOptions: Array = 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, }; }); diff --git a/src/Components/Form/MultiSelectMenuV2.tsx b/src/Components/Form/MultiSelectMenuV2.tsx index 419664f98e9..32c41bf88ff 100644 --- a/src/Components/Form/MultiSelectMenuV2.tsx +++ b/src/Components/Form/MultiSelectMenuV2.tsx @@ -158,10 +158,10 @@ const MultiSelectMenuV2 = (props: Props) => { className={classNames( "text-sm font-normal", option.disabled - ? "text-gray-700" + ? "text-gray-500" : active ? "text-primary-200" - : "text-gray-700", + : "text-gray-500", )} > {option.description} @@ -226,7 +226,7 @@ export const dropdownOptionClassNames = ({ !disabled && active && "bg-primary-500 text-white", !disabled && !active && selected && "text-primary-500", !disabled && !active && !selected && "text-gray-900", - disabled && "cursor-not-allowed text-gray-800", + disabled && "cursor-not-allowed text-gray-600", selected ? "font-semibold" : "font-normal", ); }; From 2231339db019d9792acfd3dece45596de2296ad7 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Tue, 16 Jul 2024 22:30:53 +0530 Subject: [PATCH 5/8] fix incorrect merge conflict resolve --- src/Components/Form/MultiSelectMenuV2.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Components/Form/MultiSelectMenuV2.tsx b/src/Components/Form/MultiSelectMenuV2.tsx index 253c00e9cd7..a3d4c6099ab 100644 --- a/src/Components/Form/MultiSelectMenuV2.tsx +++ b/src/Components/Form/MultiSelectMenuV2.tsx @@ -157,11 +157,9 @@ const MultiSelectMenuV2 = (props: Props) => {

{option.description} From 2a098a551c1d929cb5be3192ea23af0908f7831e Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Tue, 16 Jul 2024 22:31:33 +0530 Subject: [PATCH 6/8] revert logic (since it works) --- src/Components/Form/MultiSelectMenuV2.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Components/Form/MultiSelectMenuV2.tsx b/src/Components/Form/MultiSelectMenuV2.tsx index a3d4c6099ab..9ab2f4d55c7 100644 --- a/src/Components/Form/MultiSelectMenuV2.tsx +++ b/src/Components/Form/MultiSelectMenuV2.tsx @@ -157,9 +157,11 @@ const MultiSelectMenuV2 = (props: Props) => {

{option.description} From 778634976354da187003d91a26bf1ceaefc0334d Mon Sep 17 00:00:00 2001 From: Khavin Shankar Date: Wed, 17 Jul 2024 17:07:08 +0530 Subject: [PATCH 7/8] fixed cypress fails --- .../patient_spec/patient_registration.cy.ts | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_registration.cy.ts b/cypress/e2e/patient_spec/patient_registration.cy.ts index 17c9b0b3679..ae3dec0433c 100644 --- a/cypress/e2e/patient_spec/patient_registration.cy.ts +++ b/cypress/e2e/patient_spec/patient_registration.cy.ts @@ -254,23 +254,7 @@ describe("Patient Creation with consultation", () => { }); it("Patient Registration using the transfer with no consultation", () => { - // transfer the patient and no consulation - patientPage.createPatient(); - patientPage.selectFacility(patientTransferFacility); - patientPage.patientformvisibility(); - patientPage.typePatientPhoneNumber(patientTransferPhoneNumber); - patientTransfer.clickAdmitPatientRecordButton(); - patientTransfer.clickTransferPopupContinueButton(); - patientTransfer.clickTransferPatientNameList(patientTransferName); - patientTransfer.clickTransferPatientYOB(yearOfBirth); - patientTransfer.clickTransferSubmitButton(); - patientTransfer.verifyFacilitySuccessfullMessage(); - patientTransfer.clickConsultationCancelButton(); - cy.wait(3000); - // allow the transfer button of a patient - patientTransfer.clickAllowPatientTransferButton(); - // Verify the patient error message for the same facility - cy.awaitUrl("/patients"); + // check for error when patient is transferred with an active consultation patientPage.createPatient(); patientPage.selectFacility(patientTransferFacility); patientPage.patientformvisibility(); From 211602f56a4163fb93f08f39949e81298d6927e0 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Wed, 17 Jul 2024 20:51:42 +0530 Subject: [PATCH 8/8] modified the cypress test and updated the package --- .../patient_spec/patient_registration.cy.ts | 23 ++++++++++++-- cypress/pageobject/Patient/PatientTransfer.ts | 30 ++----------------- cypress/support/index.ts | 1 + package-lock.json | 21 +++++++++---- package.json | 3 +- 5 files changed, 42 insertions(+), 36 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_registration.cy.ts b/cypress/e2e/patient_spec/patient_registration.cy.ts index ae3dec0433c..f94dbbe46cd 100644 --- a/cypress/e2e/patient_spec/patient_registration.cy.ts +++ b/cypress/e2e/patient_spec/patient_registration.cy.ts @@ -254,7 +254,7 @@ describe("Patient Creation with consultation", () => { }); it("Patient Registration using the transfer with no consultation", () => { - // check for error when patient is transferred with an active consultation + // transfer the patient with no consulation and verify the transfer to a new facility patientPage.createPatient(); patientPage.selectFacility(patientTransferFacility); patientPage.patientformvisibility(); @@ -264,7 +264,26 @@ describe("Patient Creation with consultation", () => { patientTransfer.clickTransferPatientNameList(patientTransferName); patientTransfer.clickTransferPatientYOB(yearOfBirth); patientTransfer.clickTransferSubmitButton(); - patientTransfer.verifyFacilityErrorMessage(); + cy.verifyNotification( + "Patient Dummy Patient 10 (Male) transferred successfully", + ); + patientTransfer.clickConsultationCancelButton(); + // allow the transfer button of a patient + patientTransfer.clickAllowPatientTransferButton(); + // Verify the patient error message for the same facility + cy.awaitUrl("/patients"); + patientPage.createPatient(); + patientPage.selectFacility(patientTransferFacility); + patientPage.patientformvisibility(); + patientPage.typePatientPhoneNumber(patientTransferPhoneNumber); + patientTransfer.clickAdmitPatientRecordButton(); + patientTransfer.clickTransferPopupContinueButton(); + patientTransfer.clickTransferPatientNameList(patientTransferName); + patientTransfer.clickTransferPatientYOB(yearOfBirth); + patientTransfer.clickTransferSubmitButton(); + 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", () => { diff --git a/cypress/pageobject/Patient/PatientTransfer.ts b/cypress/pageobject/Patient/PatientTransfer.ts index 4c884ee2427..0bdd55e9880 100644 --- a/cypress/pageobject/Patient/PatientTransfer.ts +++ b/cypress/pageobject/Patient/PatientTransfer.ts @@ -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; diff --git a/cypress/support/index.ts b/cypress/support/index.ts index 9ddfd0c819a..c9af6a02c96 100644 --- a/cypress/support/index.ts +++ b/cypress/support/index.ts @@ -1,3 +1,4 @@ +/// import "./commands"; declare global { diff --git a/package-lock.json b/package-lock.json index 93346b978e6..2458c891d41 100644 --- a/package-lock.json +++ b/package-lock.json @@ -72,6 +72,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", @@ -87,7 +88,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", @@ -6222,6 +6223,16 @@ "@types/node": "*" } }, + "node_modules/@types/cypress": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@types/cypress/-/cypress-1.1.3.tgz", + "integrity": "sha512-OXe0Gw8LeCflkG1oPgFpyrYWJmEKqYncBsD/J0r17r0ETx/TnIGDNLwXt/pFYSYuYTpzcq1q3g62M9DrfsBL4g==", + "deprecated": "This is a stub types definition for cypress (https://cypress.io). cypress provides its own type definitions, so you don't need @types/cypress installed!", + "dev": true, + "dependencies": { + "cypress": "*" + } + }, "node_modules/@types/debug": { "version": "4.1.12", "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", @@ -9129,9 +9140,9 @@ "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" }, "node_modules/cypress": { - "version": "13.9.0", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.9.0.tgz", - "integrity": "sha512-atNjmYfHsvTuCaxTxLZr9xGoHz53LLui3266WWxXJHY7+N6OdwJdg/feEa3T+buez9dmUXHT1izCOklqG82uCQ==", + "version": "13.13.1", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.13.1.tgz", + "integrity": "sha512-8F9UjL5MDUdgC/S5hr8CGLHbS5gGht5UOV184qc2pFny43fnkoaKxlzH/U6//zmGu/xRTaKimNfjknLT8+UDFg==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -9174,7 +9185,7 @@ "request-progress": "^3.0.0", "semver": "^7.5.3", "supports-color": "^8.1.1", - "tmp": "~0.2.1", + "tmp": "~0.2.3", "untildify": "^4.0.0", "yauzl": "^2.10.0" }, diff --git a/package.json b/package.json index 59fd5cd89e8..aa8d3f5df01 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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",