diff --git a/cypress/e2e/patient_spec/PatientHomepage.cy.ts b/cypress/e2e/patient_spec/PatientHomepage.cy.ts index 0cf5936594d..188b6bc9457 100644 --- a/cypress/e2e/patient_spec/PatientHomepage.cy.ts +++ b/cypress/e2e/patient_spec/PatientHomepage.cy.ts @@ -4,6 +4,24 @@ import PatientHome from "../../pageobject/Patient/PatientHome"; describe("Patient Homepage present functionalities", () => { const loginPage = new LoginPage(); const patientHome = new PatientHome(); + const patientGender = "Male"; + const patientCategory = "Moderate"; + const patientMinimumAge = "18"; + const patientMaximumAge = "24"; + const patientLastAdmittedBed = "No bed assigned"; + const PatientLastConsentType = "No consents"; + const patientTelemedicinePerference = "No"; + const patientReviewStatus = "No"; + const patientMedicoStatus = "Non-Medico-Legal"; + const patientIcdDiagnosis = "1A00"; + const facilityName = "Dummy Facility 40"; + const facilityType = "Private Hospital"; + const facilityLsgBody = "Aikaranad Grama Panchayat, Ernakulam District"; + const facilityDistrict = "Ernakulam"; + const patientFromDate = "01122023"; + const patientToDate = "07122023"; + const patientFromDateBadge = "2023-12-01"; + const patientToDateBadge = "2023-12-07"; before(() => { loginPage.loginAsDisctrictAdmin(); @@ -16,6 +34,116 @@ describe("Patient Homepage present functionalities", () => { cy.awaitUrl("/patients"); }); + it("Date based advance filters applied in the patient tab", () => { + patientHome.clickPatientAdvanceFilters(); + patientHome.typePatientCreatedBeforeDate(patientFromDate); + patientHome.typePatientCreatedAfterDate(patientToDate); + patientHome.typePatientModifiedBeforeDate(patientFromDate); + patientHome.typePatientModifiedAfterDate(patientToDate); + patientHome.typePatientAdmitedBeforeDate(patientFromDate); + patientHome.typePatientAdmitedAfterDate(patientToDate); + patientHome.clickPatientFilterApply(); + patientHome.verifyTotalPatientCount("1"); + // verify the badge and clear the count + patientHome.verifyPatientCreatedBeforeDate(patientToDateBadge); + patientHome.verifyPatientCreatedAfterDate(patientFromDateBadge); + patientHome.verifyPatientModifiedBeforeDate(patientToDateBadge); + patientHome.verifyPatientModifiedAfterDate(patientFromDateBadge); + patientHome.verifyPatientAdmittedBeforeDate(patientToDateBadge); + patientHome.verifyPatientAdmittedAfterDate(patientFromDateBadge); + cy.clearAllFilters(); + patientHome.verifyTotalPatientCount("1"); + }); + + it("Facility Geography based advance filters applied in the patient tab", () => { + patientHome.clickPatientAdvanceFilters(); + patientHome.typeFacilityName(facilityName); + patientHome.selectFacilityType(facilityType); + patientHome.typeFacilityLsgBody(facilityLsgBody); + patientHome.typeFacilityDistrict(facilityDistrict); + patientHome.clickPatientFilterApply(); + patientHome.verifyTotalPatientCount("1"); + // Clear the badges and verify the patient count along with badges + patientHome.verifyFacilityNameBadgeContent(facilityName); + patientHome.verifyFacilityTypeBadgeContent(facilityType); + patientHome.verifyFacilityLsgBadgeContent(facilityLsgBody); + patientHome.verifyFacilityDistrictContent(facilityDistrict); + cy.clearAllFilters(); + patientHome.verifyTotalPatientCount("1"); + }); + + it("Patient diagnosis based advance filters applied in the patient tab", () => { + // Patient Filtering based on icd-11 data + patientHome.clickPatientAdvanceFilters(); + patientHome.selectAnyIcdDiagnosis(patientIcdDiagnosis, patientIcdDiagnosis); + patientHome.selectConfirmedIcdDiagnosis( + patientIcdDiagnosis, + patientIcdDiagnosis, + ); + patientHome.selectUnconfirmedIcdDiagnosis( + patientIcdDiagnosis, + patientIcdDiagnosis, + ); + patientHome.selectProvisionalIcdDiagnosis( + patientIcdDiagnosis, + patientIcdDiagnosis, + ); + patientHome.selectDifferentialIcdDiagnosis( + patientIcdDiagnosis, + patientIcdDiagnosis, + ); + patientHome.clickPatientFilterApply(); + patientHome.verifyTotalPatientCount("0"); + // verify the badges presence in the platform + patientHome.verifyAnyDiagnosisBadgeContent(patientIcdDiagnosis); + patientHome.verifyConfirmedDiagnosisBadgeContent(patientIcdDiagnosis); + patientHome.verifyUnconfirmedDiagnosisBadgeContent(patientIcdDiagnosis); + patientHome.verifyProvisionalDiagnosisBadgeContent(patientIcdDiagnosis); + patientHome.verifyDifferentialDiagnosisBadgeContent(patientIcdDiagnosis); + // Clear the badges and verify the patient count along with badges + cy.clearAllFilters(); + patientHome.verifyTotalPatientCount("1"); + // Apply Any and confirmed diagonsis to verify patient count 17 + patientHome.clickPatientAdvanceFilters(); + patientHome.selectAnyIcdDiagnosis(patientIcdDiagnosis, patientIcdDiagnosis); + patientHome.selectConfirmedIcdDiagnosis( + patientIcdDiagnosis, + patientIcdDiagnosis, + ); + patientHome.clickPatientFilterApply(); + patientHome.verifyTotalPatientCount("1"); + }); + + it("Patient Details based advance filters applied in the patient tab", () => { + // Patient Filtering based on patient details + patientHome.clickPatientAdvanceFilters(); + patientHome.selectPatientGenderfilter(patientGender); + patientHome.selectPatientCategoryfilter(patientCategory); + patientHome.typePatientMinimumAgeFilter(patientMinimumAge); + patientHome.typePatientMaximumAgeFilter(patientMaximumAge); + patientHome.selectPatientLastAdmittedBed(patientLastAdmittedBed); + patientHome.selectPatientLastConsentType(PatientLastConsentType); + patientHome.selectPatientTelemedicineFilter(patientTelemedicinePerference); + patientHome.selectPatientReviewFilter(patientReviewStatus); + patientHome.selectPatientMedicoFilter(patientMedicoStatus); + patientHome.clickPatientFilterApply(); + cy.get("a[data-cy='patient']").should("contain.text", "Dummy Patient"); + patientHome.verifyTotalPatientCount("1"); + // Verify the presence of badges + patientHome.verifyGenderBadgeContent(patientGender); + patientHome.verifyCategoryBadgeContent(patientCategory); + patientHome.verifyMinAgeBadgeContent(patientMinimumAge); + patientHome.verifyMaxAgeBadgeContent(patientMaximumAge); + patientHome.verifyLastAdmittedBedBadgeContent(patientLastAdmittedBed); + patientHome.verifyLastConsentTypeBadgeContent("No Consents"); + patientHome.verifyTelemedicineBadgeContent("false"); + patientHome.verifyReviewMissedBadgeContent("false"); + patientHome.verifyMedicoBadgeContent("false"); + // Clear the badges and verify the patient count along with badges + cy.clearAllFilters(); + patientHome.verifyTotalPatientCount("1"); + }); + it("Export the live patient list based on a date range", () => { patientHome.clickPatientExport(); cy.verifyNotification("Please select a seven day period"); diff --git a/cypress/pageobject/Patient/PatientConsultation.ts b/cypress/pageobject/Patient/PatientConsultation.ts index 21da5243500..71a0fbb3909 100644 --- a/cypress/pageobject/Patient/PatientConsultation.ts +++ b/cypress/pageobject/Patient/PatientConsultation.ts @@ -26,15 +26,15 @@ export class PatientConsultationPage { } selectPatientReferance(referance: string) { - cy.searchAndSelectOption("#referred_to", referance); + cy.typeAndSelectOption("#referred_to", referance); } selectBed(bedNo: string) { - cy.searchAndSelectOption("#bed", bedNo); + cy.typeAndSelectOption("#bed", bedNo); } selectPatientWard(ward: string) { - cy.searchAndSelectOption("#transferred_from_location", ward); + cy.typeAndSelectOption("#transferred_from_location", ward); } selectPatientSuggestion(suggestion: string) { @@ -50,7 +50,7 @@ export class PatientConsultationPage { } selectPatientDiagnosis(icdCode: string, statusId: string) { - cy.searchAndSelectOption("#icd11-search", icdCode); + cy.typeAndSelectOption("#icd11-search", icdCode); cy.get("#diagnosis-list") .contains("Add as") .scrollIntoView() @@ -99,7 +99,7 @@ export class PatientConsultationPage { } typeReferringFacility(referringFacility: string) { - cy.searchAndSelectOption("#referred_from_facility", referringFacility); + cy.typeAndSelectOption("#referred_from_facility", referringFacility); } clickEditConsultationButton() { diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index 0ec505a47a0..a583844a632 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -22,7 +22,7 @@ export class PatientPage { } selectFacility(facilityName: string) { - cy.searchAndSelectOption("input[name='facilities']", facilityName); + cy.typeAndSelectOption("input[name='facilities']", facilityName); cy.submitButton("Select"); } @@ -114,7 +114,7 @@ export class PatientPage { } selectPatientOccupation(occupation: string) { - cy.searchAndSelectOption("#occupation", occupation); + cy.typeAndSelectOption("#occupation", occupation); } selectSocioeconomicStatus(value: string) { diff --git a/cypress/pageobject/Patient/PatientDischarge.ts b/cypress/pageobject/Patient/PatientDischarge.ts index eda6a379a3f..70a6d550887 100644 --- a/cypress/pageobject/Patient/PatientDischarge.ts +++ b/cypress/pageobject/Patient/PatientDischarge.ts @@ -14,7 +14,7 @@ class PatientDischarge { } typeReferringFacility(facility: string) { - cy.searchAndSelectOption("#facility-referredto", facility); + cy.typeAndSelectOption("#facility-referredto", facility); } clickClearButton() { diff --git a/cypress/pageobject/Patient/PatientHome.ts b/cypress/pageobject/Patient/PatientHome.ts index 4f953adf78b..a69a96c3f77 100644 --- a/cypress/pageobject/Patient/PatientHome.ts +++ b/cypress/pageobject/Patient/PatientHome.ts @@ -30,6 +30,14 @@ class PatientHome { cy.wait("@getPatients").its("response.statusCode").should("eq", 200); } + typePatientCreatedBeforeDate(startDate: string) { + cy.clickAndTypeDate("input[name='created_date_start']", startDate); + } + + typePatientCreatedAfterDate(endDate: string) { + cy.clickAndTypeDate("input[name='created_date_end']", endDate); + } + typePatientModifiedBeforeDate(startDate: string) { cy.clickAndTypeDate("input[name='modified_date_start']", startDate); } @@ -37,5 +45,211 @@ class PatientHome { typePatientModifiedAfterDate(endDate: string) { cy.clickAndTypeDate("input[name='modified_date_end']", endDate); } + + typePatientAdmitedBeforeDate(startDate: string) { + cy.clickAndTypeDate( + "input[name='last_consultation_encounter_date_start']", + startDate, + ); + } + + typePatientAdmitedAfterDate(endDate: string) { + cy.clickAndTypeDate( + "input[name='last_consultation_encounter_date_end']", + endDate, + ); + } + + clickPatientAdvanceFilters() { + cy.get("#advanced-filter").click(); + } + + selectPatientGenderfilter(gender: string) { + cy.clickAndSelectOption("#gender-advancefilter", gender); + } + + selectPatientCategoryfilter(category: string) { + cy.clickAndSelectOption("#category-advancefilter", category); + } + + typePatientMinimumAgeFilter(minage: string) { + cy.get("#age_min").type(minage); + } + + typePatientMaximumAgeFilter(maxage: string) { + cy.get("#age_max").type(maxage); + } + + selectPatientLastAdmittedBed(bed: string) { + cy.clickAndMultiSelectOption( + "#last_consultation_admitted_bed_type_list", + bed, + ); + } + + selectPatientLastConsentType(consent: string) { + cy.clickAndMultiSelectOption("#last_consultation__consent_types", consent); + } + + selectPatientTelemedicineFilter(telemedicine: string) { + cy.clickAndSelectOption("#telemedicine-advancefilter", telemedicine); + } + + selectPatientReviewFilter(review: string) { + cy.clickAndSelectOption("#review-advancefilter", review); + } + + selectPatientMedicoFilter(medico: string) { + cy.clickAndSelectOption("#medico-advancefilter", medico); + } + + verifyGenderBadgeContent(expectedText: string) { + cy.get("[data-testid='Gender']").should("contain", expectedText); + } + + verifyCategoryBadgeContent(expectedText: string) { + cy.get("[data-testid='Category']").should("contain", expectedText); + } + + verifyMinAgeBadgeContent(expectedText: string) { + cy.get("[data-testid='Age min']").should("contain", expectedText); + } + + verifyMaxAgeBadgeContent(expectedText: string) { + cy.get("[data-testid='Age max']").should("contain", expectedText); + } + + verifyLastAdmittedBedBadgeContent(expectedText: string) { + cy.get("[data-testid='Bed Type']").should("contain", expectedText); + } + + verifyLastConsentTypeBadgeContent(expectedText: string) { + cy.get("[data-testid='Has Consent']").should("contain", expectedText); + } + + verifyTelemedicineBadgeContent(expectedText: string) { + cy.get("[data-testid='Telemedicine']").should("contain", expectedText); + } + + verifyReviewMissedBadgeContent(expectedText: string) { + cy.get("[data-testid='Review Missed']").should("contain", expectedText); + } + + verifyMedicoBadgeContent(expectedText: string) { + cy.get("[data-testid='Is Medico-Legal Case']").should( + "contain", + expectedText, + ); + } + + verifyTotalPatientCount(count: string) { + cy.get("#total-patientcount").should("contain", count); + } + + selectAnyIcdDiagnosis(input: string, random: string) { + cy.typeAndMultiSelectOption("#diagnoses", input, random); + } + + selectConfirmedIcdDiagnosis(input: string, confirmed: string) { + cy.typeAndMultiSelectOption("#diagnoses_confirmed", input, confirmed); + } + + selectUnconfirmedIcdDiagnosis(input: string, unconfirmed: string) { + cy.typeAndMultiSelectOption("#diagnoses_unconfirmed", input, unconfirmed); + } + + selectProvisionalIcdDiagnosis(input: string, unconfirmed: string) { + cy.typeAndMultiSelectOption("#diagnoses_provisional", input, unconfirmed); + } + + selectDifferentialIcdDiagnosis(input: string, unconfirmed: string) { + cy.typeAndMultiSelectOption("#diagnoses_differential", input, unconfirmed); + } + + typeFacilityName(facilityName: string) { + cy.typeAndSelectOption("input[name='facility']", facilityName); + } + + selectFacilityType(facilityType: string) { + cy.clickAndSelectOption("#facility-type", facilityType); + } + + typeFacilityLsgBody(lsgbody: string) { + cy.typeAndSelectOption("#facility-lsgbody", lsgbody); + } + + typeFacilityDistrict(district: string) { + cy.typeAndSelectOption("#facility-district", district); + } + + verifyAnyDiagnosisBadgeContent(expectedText: string) { + cy.get("[data-testid='Diagnoses (of any verification status)']").should( + "contain", + expectedText, + ); + } + + verifyConfirmedDiagnosisBadgeContent(expectedText: string) { + cy.get("[data-testid='Confirmed Diagnoses']").should( + "contain", + expectedText, + ); + } + + verifyUnconfirmedDiagnosisBadgeContent(expectedText: string) { + cy.get("[data-testid='Unconfirmed Diagnoses']").should( + "contain", + expectedText, + ); + } + + verifyProvisionalDiagnosisBadgeContent(expectedText: string) { + cy.get("[data-testid='Provisional Diagnoses']").should( + "contain", + expectedText, + ); + } + + verifyDifferentialDiagnosisBadgeContent(expectedText: string) { + cy.get("[data-testid='Differential Diagnoses']").should( + "contain", + expectedText, + ); + } + + verifyFacilityNameBadgeContent(expectedText: string) { + cy.get("[data-testid='Facility']").should("contain", expectedText); + } + + verifyFacilityTypeBadgeContent(expectedText: string) { + cy.get("[data-testid='Facility Type']").should("contain", expectedText); + } + + verifyFacilityLsgBadgeContent(expectedText: string) { + cy.get("[data-testid='LSG Body']").should("contain", expectedText); + } + + verifyFacilityDistrictContent(expectedText: string) { + cy.get("[data-testid='District']").should("contain", expectedText); + } + + verifyPatientCreatedAfterDate(expectedText: string) { + cy.get("[data-testid='Created after']").should("contain", expectedText); + } + verifyPatientCreatedBeforeDate(expectedText: string) { + cy.get("[data-testid='Created before']").should("contain", expectedText); + } + verifyPatientModifiedAfterDate(expectedText: string) { + cy.get("[data-testid='Modified after']").should("contain", expectedText); + } + verifyPatientModifiedBeforeDate(expectedText: string) { + cy.get("[data-testid='Modified before']").should("contain", expectedText); + } + verifyPatientAdmittedBeforeDate(expectedText: string) { + cy.get("[data-testid='Admitted before']").should("contain", expectedText); + } + verifyPatientAdmittedAfterDate(expectedText: string) { + cy.get("[data-testid='Admitted after']").should("contain", expectedText); + } } export default PatientHome; diff --git a/cypress/pageobject/Patient/PatientLogupdate.ts b/cypress/pageobject/Patient/PatientLogupdate.ts index b2822d03353..857fe7dd972 100644 --- a/cypress/pageobject/Patient/PatientLogupdate.ts +++ b/cypress/pageobject/Patient/PatientLogupdate.ts @@ -14,7 +14,7 @@ class PatientLogupdate { } selectBed(bed: string) { - cy.searchAndSelectOption("input[name='bed']", bed); + cy.typeAndSelectOption("input[name='bed']", bed); cy.get("#update-switchbed").click(); cy.wait(2000); } @@ -43,27 +43,27 @@ class PatientLogupdate { } typeSystolic(systolic: string) { - cy.searchAndSelectOption("#systolic", systolic); + cy.typeAndSelectOption("#systolic", systolic); } typeDiastolic(diastolic: string) { - cy.searchAndSelectOption("#diastolic", diastolic); + cy.typeAndSelectOption("#diastolic", diastolic); } typePulse(pulse: string) { - cy.searchAndSelectOption("#pulse", pulse); + cy.typeAndSelectOption("#pulse", pulse); } typeTemperature(temperature: string) { - cy.searchAndSelectOption("#temperature", temperature); + cy.typeAndSelectOption("#temperature", temperature); } typeRespiratory(respiratory: string) { - cy.searchAndSelectOption("#resp", respiratory); + cy.typeAndSelectOption("#resp", respiratory); } typeSpo2(spo: string) { - cy.searchAndSelectOption("#ventilator_spo2", spo); + cy.typeAndSelectOption("#ventilator_spo2", spo); } selectRhythm(rhythm: string) { diff --git a/cypress/pageobject/Patient/PatientPrescription.ts b/cypress/pageobject/Patient/PatientPrescription.ts index 403d361e55c..d801b360aba 100644 --- a/cypress/pageobject/Patient/PatientPrescription.ts +++ b/cypress/pageobject/Patient/PatientPrescription.ts @@ -16,7 +16,7 @@ export class PatientPrescription { } selectMedicine(medicine: string) { - cy.searchAndSelectOption( + cy.typeAndSelectOption( "div#medicine_object input[placeholder='Select'][role='combobox']", medicine, ); diff --git a/cypress/pageobject/Patient/PatientTreatmentPlan.ts b/cypress/pageobject/Patient/PatientTreatmentPlan.ts index 70af5604776..0bbddbf70bc 100644 --- a/cypress/pageobject/Patient/PatientTreatmentPlan.ts +++ b/cypress/pageobject/Patient/PatientTreatmentPlan.ts @@ -4,7 +4,7 @@ class PatientTreatmentPlan { } fillTreatingPhysican(doctor: string) { - cy.searchAndSelectOption("#treating_physician", doctor); + cy.typeAndSelectOption("#treating_physician", doctor); } selectReviewAfter(time: string) { @@ -20,7 +20,7 @@ class PatientTreatmentPlan { } assignTelemedicineDoctor(doctor: string) { - cy.searchAndSelectOption("#assigned_to", doctor); + cy.typeAndSelectOption("#assigned_to", doctor); } clickAddProcedure() { diff --git a/cypress/pageobject/Users/ManageUserPage.ts b/cypress/pageobject/Users/ManageUserPage.ts index a9ac1374085..efa0d90142c 100644 --- a/cypress/pageobject/Users/ManageUserPage.ts +++ b/cypress/pageobject/Users/ManageUserPage.ts @@ -8,11 +8,11 @@ export class ManageUserPage { } selectFacilityFromDropdown(facilityName: string) { - cy.searchAndSelectOption("input[name='facility']", facilityName); + cy.typeAndSelectOption("input[name='facility']", facilityName); } selectSkillFromDropdown(skill: string) { - cy.searchAndSelectOption("input[name='skill']", skill); + cy.typeAndSelectOption("input[name='skill']", skill); } clickLinkFacility() { diff --git a/cypress/pageobject/Users/UserSearch.ts b/cypress/pageobject/Users/UserSearch.ts index 0c214e92706..d72c00c0de7 100644 --- a/cypress/pageobject/Users/UserSearch.ts +++ b/cypress/pageobject/Users/UserSearch.ts @@ -53,11 +53,11 @@ export class UserPage { } selectState(state: string) { - cy.searchAndSelectOption("#state input", state); + cy.typeAndSelectOption("#state input", state); } selectDistrict(district: string) { - cy.searchAndSelectOption("#district input", district); + cy.typeAndSelectOption("#district input", district); } typeInPhoneNumber(phone: string) { @@ -69,7 +69,7 @@ export class UserPage { } selectHomeFacility(facility: string) { - cy.searchAndSelectOption("input[name='home_facility']", facility); + cy.typeAndSelectOption("input[name='home_facility']", facility); } applyFilter() { diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 320f19d8b0e..da78361f6e8 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -127,7 +127,7 @@ Cypress.Commands.add("submitButton", (buttonText = "Submit") => { }); Cypress.Commands.add( - "searchAndSelectOption", + "typeAndSelectOption", (element: string, referance: string) => { cy.get(element) .click() diff --git a/cypress/support/index.ts b/cypress/support/index.ts index d660246324f..b2895871872 100644 --- a/cypress/support/index.ts +++ b/cypress/support/index.ts @@ -15,7 +15,7 @@ declare global { getAttached(selector: string): Chainable; clearAllFilters(): Chainable; submitButton(buttonText?: string): Chainable; - searchAndSelectOption( + typeAndSelectOption( element: string, referance: string, ): Chainable; diff --git a/src/Components/Patient/DiagnosesFilter.tsx b/src/Components/Patient/DiagnosesFilter.tsx index 1217e821389..ba58a549dac 100644 --- a/src/Components/Patient/DiagnosesFilter.tsx +++ b/src/Components/Patient/DiagnosesFilter.tsx @@ -68,6 +68,7 @@ export default function DiagnosesFilter(props: Props) { return ( {
-
+
Gender o.text} @@ -304,6 +305,7 @@ export default function PatientFilter(props: any) {
Category o.text} @@ -407,6 +409,7 @@ export default function PatientFilter(props: any) {
Telemedicine o.text} @@ -423,6 +426,7 @@ export default function PatientFilter(props: any) {
Respiratory Support o.text} @@ -455,6 +459,7 @@ export default function PatientFilter(props: any) { <> Review Missed (o === "true" ? "Yes" : "No")} @@ -469,6 +474,7 @@ export default function PatientFilter(props: any) {
Is Medico-Legal Case @@ -484,6 +490,7 @@ export default function PatientFilter(props: any) { />
{!props.dischargePage && ( -
+
Facility Facility type o.text} @@ -640,6 +648,7 @@ export default function PatientFilter(props: any) { LSG Body
-
+
District