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

Fixed Multi-selection functionality. #9345

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
72c25c7
Fix multi-selection, closes #9144
Jeffrin2005 Dec 10, 2024
5e98869
Merge branch 'develop' into multiselection
Jeffrin2005 Dec 10, 2024
e8499fd
updated , closes 9144
Jeffrin2005 Dec 10, 2024
db2fb4c
updated index.tsx
Jeffrin2005 Dec 11, 2024
2098454
updated index.tsx
Jeffrin2005 Dec 13, 2024
7d99ffe
Merge branch 'develop' into multiselection
Jeffrin2005 Dec 17, 2024
b9c2913
final Board.tsx
Jeffrin2005 Dec 18, 2024
e721590
Switch out all the ButtonV2s and used button
Jeffrin2005 Dec 19, 2024
c2fe3a9
Merge branch 'multiselection' of https://github.com/Jeffrin2005/care_…
Jeffrin2005 Dec 19, 2024
7cd8d7f
button instead of buttonV2
Jeffrin2005 Dec 21, 2024
d869d1b
Merge branch 'develop' into multiselection
Jeffrin2005 Dec 21, 2024
aa51880
Final-updated shadcn button
Jeffrin2005 Dec 23, 2024
102bc74
Merge branch 'multiselection' of https://github.com/Jeffrin2005/care_…
Jeffrin2005 Dec 23, 2024
9a73618
orginal-used shadcn button
Jeffrin2005 Dec 23, 2024
1f667e2
Final-Latest-used shadcn Button
Jeffrin2005 Dec 23, 2024
fc1ff52
used_variant=primary,secondary
Jeffrin2005 Dec 23, 2024
de35c4d
Merge branch 'develop' into multiselection
nihal467 Dec 24, 2024
1ad5032
Merge branch 'develop' into multiselection
nihal467 Dec 24, 2024
b900f6f
latest-investigation
Jeffrin2005 Dec 26, 2024
db0e22e
Merge branch 'develop' into multiselection
Jeffrin2005 Dec 28, 2024
bad7863
Correct Failing Test Case
Jeffrin2005 Dec 28, 2024
0faeb64
Merge branch 'multiselection' of https://github.com/Jeffrin2005/care_…
Jeffrin2005 Dec 28, 2024
f52117b
Correct Failing Test case
Jeffrin2005 Dec 28, 2024
564a461
changed patientInvestigation.ts
Jeffrin2005 Dec 28, 2024
18fcf32
final test fail
Jeffrin2005 Dec 28, 2024
ce00cdf
latest check
Jeffrin2005 Dec 28, 2024
a2d1d38
final
Jeffrin2005 Dec 28, 2024
e6702d0
latest-final
Jeffrin2005 Dec 28, 2024
6c91c63
final1
Jeffrin2005 Dec 28, 2024
0c9da17
cypress test fail
Jeffrin2005 Dec 28, 2024
623dfa0
cypress3 test
Jeffrin2005 Dec 28, 2024
762c1ea
final2
Jeffrin2005 Dec 28, 2024
6a67690
orginal
Jeffrin2005 Dec 28, 2024
34d40da
latest1
Jeffrin2005 Dec 28, 2024
e9129e5
finall
Jeffrin2005 Dec 28, 2024
ec73916
rever
Jeffrin2005 Dec 28, 2024
33653fb
orginal
Jeffrin2005 Dec 28, 2024
a971c59
test final
Jeffrin2005 Dec 28, 2024
21601fe
temp1
Jeffrin2005 Dec 28, 2024
6d63a69
Test final
Jeffrin2005 Dec 28, 2024
a920771
Final commit of tests
Jeffrin2005 Dec 28, 2024
d6fe9b4
test1
Jeffrin2005 Dec 28, 2024
197c9a9
UP1
Jeffrin2005 Dec 28, 2024
4c56047
FINAL_COMMIT
Jeffrin2005 Dec 28, 2024
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
173 changes: 156 additions & 17 deletions cypress/e2e/patient_spec/PatientInvestigation.cy.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
import { PatientPage } from "pageobject/Patient/PatientCreation";
import PatientInvestigation from "pageobject/Patient/PatientInvestigation";
import { advanceFilters } from "pageobject/utils/advanceFilterHelpers";
import { pageNavigation } from "pageobject/utils/paginationHelpers";

import LoginPage from "../../pageobject/Login/LoginPage";
import PatientHome from "../../pageobject/Patient/PatientHome";

describe("Patient Investigation Creation from Patient consultation page", () => {
Comment on lines +1 to 6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Rename the file to match its contents

The filename PatientInvestigation.cy.ts suggests tests for patient investigations, but the actual content tests patient homepage functionalities. Consider renaming the file to PatientHome.cy.ts or PatientHomepage.cy.ts for better clarity.

describe("Patient Homepage present functionalities", () => {
const loginPage = new LoginPage();
const patientPage = new PatientPage();
const patientInvestigation = new PatientInvestigation();
const patientName = "Dummy Patient Thirteen";
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.loginByRole("districtAdmin");
Expand All @@ -20,18 +37,140 @@ describe("Patient Investigation Creation from Patient consultation page", () =>
cy.awaitUrl("/patients");
});

it("Create a investigation for a patient and verify its reflection", () => {
patientPage.visitPatient(patientName);
patientInvestigation.clickInvestigationTab();
patientInvestigation.clickLogLabResults();
patientInvestigation.selectInvestigationOption([
"Haematology",
"Urine Test",
]);
cy.clickSubmitButton("Save Investigation");
cy.verifyNotification("Please Enter at least one value");
it("Date based advance filters applied in the patient tab", () => {
advanceFilters.clickAdvancedFiltersButton();
patientHome.typePatientCreatedBeforeDate(patientFromDate);
patientHome.typePatientCreatedAfterDate(patientToDate);
patientHome.typePatientModifiedBeforeDate(patientFromDate);
patientHome.typePatientModifiedAfterDate(patientToDate);
patientHome.typePatientAdmitedBeforeDate(patientFromDate);
patientHome.typePatientAdmitedAfterDate(patientToDate);
patientHome.clickPatientFilterApply();
// 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();
});

it("Facility Geography based advance filters applied in the patient tab", () => {
advanceFilters.clickAdvancedFiltersButton();
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();
});

it("Patient diagnosis based advance filters applied in the patient tab", () => {
// Patient Filtering based on icd-11 data
advanceFilters.clickAdvancedFiltersButton();
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();
// Apply Any and confirmed diagonsis to verify patient count 17
advanceFilters.clickAdvancedFiltersButton();
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
advanceFilters.clickAdvancedFiltersButton();
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");
// 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();
});

it("Export the live patient list based on a date range", () => {
patientHome.clickPatientExport();
cy.verifyNotification("Please select a seven day period");
cy.closeNotification();
// Temporary workflow for investigation since we dont have dummy data and moving away from existing module
patientHome.typePatientModifiedBeforeDate("01122023");
patientHome.typePatientModifiedAfterDate("07122023");
patientHome.clickPatientFilterApply();
patientHome.interceptPatientExportRequest();
patientHome.clickPatientExport();
patientHome.verifyPatientExportRequest();
});

it("Test Pagination on Patient List Page", () => {
let firstPatientPageOne: string;
cy.get('[data-cy="patient"]')
.first()
.invoke("text")
.then((patientOne: string) => {
firstPatientPageOne = patientOne.trim();
pageNavigation.navigateToNextPage();
pageNavigation.verifyCurrentPageNumber(2);
cy.get('[data-cy="patient"]')
.first()
.invoke("text")
.then((patientTwo: string) => {
const firstPatientPageTwo = patientTwo.trim();
expect(firstPatientPageOne).not.to.eq(firstPatientPageTwo);
pageNavigation.navigateToPreviousPage();
});
});
});

afterEach(() => {
Expand Down
77 changes: 41 additions & 36 deletions src/components/Facility/Investigations/Reports/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useCallback, useReducer, useState } from "react";
import { useTranslation } from "react-i18next";

import ButtonV2 from "@/components/Common/ButtonV2";
import { Button } from "@/components/ui/button";

import CircularProgress from "@/components/Common/CircularProgress";
import Loading from "@/components/Common/Loading";
import Page from "@/components/Common/Page";
Expand Down Expand Up @@ -53,42 +54,36 @@ const initialState: InitialState = {

const investigationReportsReducer = (state = initialState, action: any) => {
switch (action.type) {
case "set_investigation_groups": {
case "set_investigation_groups":
return {
...state,
investigationGroups: action.payload,
};
}
case "set_selected_group": {
case "set_selected_group":
return {
...state,
selectedGroup: action.payload,
};
}
case "set_investigations": {
case "set_investigations":
return {
...state,
investigations: action.payload,
};
}
case "set_selected_investigations": {
case "set_selected_investigations":
return {
...state,
selectedInvestigations: action.payload,
};
}
case "set_investigation_table_data": {
case "set_investigation_table_data":
return {
...state,
investigationTableData: action.payload,
};
}
case "set_loading": {
case "set_loading":
return {
...state,
isLoading: action.payload,
};
}
default:
return state;
}
Expand All @@ -113,6 +108,10 @@ const InvestigationReports = ({ id }: any) => {
selectedInvestigations,
} = state as InitialState;

const clearSelectedInvestigations = () => {
dispatch({ type: "set_selected_investigations", payload: [] });
};

const fetchInvestigationsData = useCallback(
async (
onSuccess: (
Expand Down Expand Up @@ -314,14 +313,13 @@ const InvestigationReports = ({ id }: any) => {
/>
</div>
{!isLoading.investigationLoading && (
<ButtonV2
<Button
onClick={() => fetchInvestigation()}
disabled={getTestDisabled}
variant="primary"
className="my-2.5"
>
{t("get_tests")}
</ButtonV2>
</Button>
)}
{!!isLoading.investigationLoading && (
<CircularProgress className="text-primary-500" />
Expand All @@ -342,23 +340,31 @@ const InvestigationReports = ({ id }: any) => {
})
}
optionLabel={(option) => option.name}
optionValue={(option) => option}
optionValue={(option) => option.external_id}
isLoading={isLoading.investigationLoading}
placeholder={t("select_investigations")}
selectAll={true}
/>
</div>

<ButtonV2
onClick={() => {
setSessionPage(1);
handleGenerateReports(1);
}}
disabled={generateReportDisabled}
variant="primary"
className="my-2.5"
>
{t("generate_report")}
</ButtonV2>
<div className="flex space-x-2">
<Button
onClick={() => {
setSessionPage(1);
handleGenerateReports(1);
}}
disabled={generateReportDisabled}
variant="primary"
>
{t("generate_report")}
</Button>
<Button
onClick={clearSelectedInvestigations}
disabled={!selectedInvestigations.length}
variant="secondary"
>
{t("clear")}
</Button>
</div>
</>
)}
{isLoading.tableData && (
Expand All @@ -370,19 +376,19 @@ const InvestigationReports = ({ id }: any) => {
{!!investigationTableData.length && (
<>
<div className="my-2.5">
<ButtonV2
<Button
onClick={() => handleSessionPage("NEXT")}
disabled={prevSessionDisabled}
>
{isLoading.tableData ? "Loading..." : t("next_sessions")}
</ButtonV2>
<ButtonV2
</Button>
<Button
onClick={() => handleSessionPage("PREV")}
disabled={nextSessionDisabled}
className="ml-3"
>
{isLoading.tableData ? "Loading..." : t("prev_sessions")}
</ButtonV2>
</Button>
</div>

<ReportTable
Expand All @@ -396,14 +402,13 @@ const InvestigationReports = ({ id }: any) => {
/>

{!loadMoreDisabled && (
<ButtonV2
<Button
disabled={loadMoreDisabled}
onClick={handleLoadMore}
className="my-2.5 w-full"
variant="primary"
>
{t("load_more")}
</ButtonV2>
</Button>
)}
</>
)}
Expand Down
Loading
Loading