Skip to content

Commit

Permalink
Merge branch 'develop' into facility_delete
Browse files Browse the repository at this point in the history
  • Loading branch information
xakep8 authored Nov 29, 2023
2 parents cabaab5 + bf4920c commit 8f796f5
Show file tree
Hide file tree
Showing 24 changed files with 859 additions and 728 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/facility_spec/facility.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("Facility Creation", () => {
facilityPage.fillPhoneNumber("9898469865");
facilityPage.submitForm();

facilityPage.selectBedType("Non-Covid Oxygen beds");
facilityPage.selectBedType("Oxygen beds");
facilityPage.fillTotalCapacity("10");
facilityPage.fillCurrentlyOccupied("5");
facilityPage.saveAndExitBedCapacityForm();
Expand Down
66 changes: 66 additions & 0 deletions cypress/e2e/facility_spec/facility_homepage.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// FacilityCreation
import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress";
import LoginPage from "../../pageobject/Login/LoginPage";
import FacilityHome from "../../pageobject/Facility/FacilityHome";
import ManageUserPage from "../../pageobject/Users/ManageUserPage";
import FacilityPage from "../../pageobject/Facility/FacilityCreation";

describe("Facility Creation", () => {
const loginPage = new LoginPage();
const facilityHome = new FacilityHome();
const facilityPage = new FacilityPage();
const manageUserPage = new ManageUserPage();
const facilitiesAlias = "downloadFacilitiesCSV";
const capacitiesAlias = "downloadCapacitiesCSV";
const doctorsAlias = "downloadDoctorsCSV";
const triagesAlias = "downloadTriagesCSV";
const facilityname = "Dummy Facility 1";

before(() => {
loginPage.loginAsDisctrictAdmin();
cy.saveLocalStorage();
});

beforeEach(() => {
cy.restoreLocalStorage();
cy.awaitUrl("/facility");
});

it("Search a facility in homepage", () => {
manageUserPage.typeFacilitySearch(facilityname);
facilityPage.verifyFacilityBadgeContent(facilityname);
manageUserPage.assertFacilityInCard(facilityname);
facilityHome.verifyURLContains(facilityname);
});

it("Verify Facility Export Functionality", () => {
// Download the Facilities CSV
facilityHome.csvDownloadIntercept(facilitiesAlias, "");
facilityHome.clickExportButton();
facilityHome.clickMenuItem("Facilities");
facilityHome.verifyDownload(facilitiesAlias);
facilityHome.clickSearchButton(); // to avoid flaky test, as sometimes, the test is unable to focus on the object
// Download the Capacities CSV
facilityHome.csvDownloadIntercept(capacitiesAlias, "&capacity");
facilityHome.clickExportButton();
facilityHome.clickMenuItem("Capacities");
facilityHome.verifyDownload(capacitiesAlias);
facilityHome.clickSearchButton();
// Download the Doctors CSV
facilityHome.csvDownloadIntercept(doctorsAlias, "&doctors");
facilityHome.clickExportButton();
facilityHome.clickMenuItem("Doctors");
facilityHome.verifyDownload(doctorsAlias);
facilityHome.clickSearchButton();
// Download the Triages CSV
facilityHome.csvDownloadIntercept(triagesAlias, "&triage");
facilityHome.clickExportButton();
facilityHome.clickMenuItem("Triages");
facilityHome.verifyDownload(triagesAlias);
facilityHome.clickSearchButton();
});

afterEach(() => {
cy.saveLocalStorage();
});
});
40 changes: 40 additions & 0 deletions cypress/pageobject/Facility/FacilityHome.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// cypress/support/pageObjects/FacilityHome.ts

class FacilityHome {
// Selectors
exportButton = "#export-button";
searchButton = "#search";
menuItem = "[role='menuitem']";

// Operations
clickExportButton() {
cy.get(this.exportButton).click();
}

clickSearchButton() {
cy.get(this.searchButton).click();
}

clickMenuItem(itemName: string) {
cy.get(this.menuItem).contains(itemName).click();
}

csvDownloadIntercept(alias: string, queryParam: string) {
cy.intercept("GET", `**/api/v1/facility/?csv${queryParam}`).as(alias);
}

verifyDownload(alias: string) {
cy.wait(`@${alias}`).its("response.statusCode").should("eq", 200);
}

getURL() {
return cy.url();
}

verifyURLContains(searchText) {
const encodedText = encodeURIComponent(searchText).replace(/%20/g, "+");
this.getURL().should("include", `search=${encodedText}`);
}
}

export default FacilityHome;
3 changes: 2 additions & 1 deletion cypress/pageobject/Patient/PatientConsultation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ export class PatientConsultationPage {
}

clickDischargePatient() {
cy.get("#discharge_patient_from_care").click();
cy.get("#show-more").click();
cy.contains("p", "Discharge from CARE").click();
}

selectDischargeReason(reason: string) {
Expand Down
8 changes: 4 additions & 4 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ export const getBedTypes = ({
: [];

return [
{ id: 1, text: "Non-Covid Ordinary Beds" },
{ id: 150, text: "Non-Covid Oxygen beds" },
{ id: 10, text: "Non-Covid ICU (ICU without ventilator)" },
{ id: 20, text: "Non-Covid Ventilator (ICU with ventilator)" },
{ id: 1, text: "Ordinary Beds" },
{ id: 150, text: "Oxygen beds" },
{ id: 10, text: "ICU (ICU without ventilator)" },
{ id: 20, text: "Ventilator (ICU with ventilator)" },
{ id: 30, text: "Covid Ordinary Beds" },
{ id: 120, text: "Covid Oxygen beds" },
{ id: 110, text: "Covid ICU (ICU without ventilator)" },
Expand Down
10 changes: 0 additions & 10 deletions src/Common/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ export const parseOptionId: (
return textArray.join(", ");
};

export const getDimensionOrDash = (
value: number | string | null | undefined,
unit: string
) => {
if (value === undefined || value === null || value === 0 || value === "0") {
return "-";
}
return value + unit;
};

export const deepEqual = (x: any, y: any): boolean => {
if (x === y) return true;

Expand Down
2 changes: 1 addition & 1 deletion src/Components/Common/Export.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const ExportMenu = ({
const { isExporting, exportFile } = useExport();

return (
<div key="export-menu">
<div key="export-menu" id="export-button">
<DropdownMenu
disabled={isExporting || disabled}
title={isExporting ? "Exporting..." : label}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Common/LocationSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface LocationSelectProps {
name: string;
disabled?: boolean;
margin?: string;
errors: string;
errors?: string;
className?: string;
searchAll?: boolean;
multiple?: boolean;
Expand Down
86 changes: 8 additions & 78 deletions src/Components/Facility/ConsultationDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ import {
} from "../../../Redux/actions";
import { statusType, useAbortableEffect } from "../../../Common/utils";
import { lazy, useCallback, useState } from "react";
import ButtonV2 from "../../Common/components/ButtonV2";
import CareIcon from "../../../CAREUI/icons/CareIcon";
import DischargeModal from "../DischargeModal";
import DischargeSummaryModal from "../DischargeSummaryModal";
import DoctorVideoSlideover from "../DoctorVideoSlideover";
import { make as Link } from "../../Common/components/Link.bs";
import PatientInfoCard from "../../Patient/PatientInfoCard";
Expand All @@ -25,7 +21,6 @@ import { formatDateTime, relativeTime } from "../../../Utils/utils";

import { navigate, useQueryParams } from "raviger";
import { useDispatch } from "react-redux";
import { useTranslation } from "react-i18next";
import { triggerGoal } from "../../../Integrations/Plausible";
import useAuthUser from "../../../Common/hooks/useAuthUser";
import { ConsultationUpdatesTab } from "./ConsultationUpdatesTab";
Expand Down Expand Up @@ -73,7 +68,6 @@ const TABS = {
};

export const ConsultationDetails = (props: any) => {
const { t } = useTranslation();
const { facilityId, patientId, consultationId } = props;
const tab = props.tab.toUpperCase() as keyof typeof TABS;
const dispatch: any = useDispatch();
Expand All @@ -86,9 +80,6 @@ export const ConsultationDetails = (props: any) => {
);
const [patientData, setPatientData] = useState<PatientModel>({});
const [activeShiftingData, setActiveShiftingData] = useState<Array<any>>([]);
const [openDischargeSummaryDialog, setOpenDischargeSummaryDialog] =
useState(false);
const [openDischargeDialog, setOpenDischargeDialog] = useState(false);
const [isCameraAttached, setIsCameraAttached] = useState(false);

const getPatientGender = (patientData: any) =>
Expand Down Expand Up @@ -197,19 +188,6 @@ export const ConsultationDetails = (props: any) => {

const SelectedTab = TABS[tab];

const hasActiveShiftingRequest = () => {
if (activeShiftingData.length > 0) {
return [
"PENDING",
"APPROVED",
"DESTINATION APPROVED",
"PATIENT TO BE PICKED UP",
].includes(activeShiftingData[activeShiftingData.length - 1].status);
}

return false;
};

if (isLoading) {
return <Loading />;
}
Expand Down Expand Up @@ -272,18 +250,6 @@ export const ConsultationDetails = (props: any) => {

return (
<div>
<DischargeSummaryModal
consultation={consultationData}
show={openDischargeSummaryDialog}
onClose={() => setOpenDischargeSummaryDialog(false)}
/>

<DischargeModal
show={openDischargeDialog}
onClose={() => setOpenDischargeDialog(false)}
consultationData={consultationData}
/>

<div className="px-2 pb-2">
<nav className="relative flex flex-wrap items-start justify-between">
<PageTitle
Expand All @@ -307,34 +273,6 @@ export const ConsultationDetails = (props: any) => {
<div className="flex w-full flex-col min-[1150px]:w-min min-[1150px]:flex-row min-[1150px]:items-center">
{!consultationData.discharge_date && (
<>
{hasActiveShiftingRequest() ? (
<ButtonV2
onClick={() =>
navigate(
`/shifting/${
activeShiftingData[activeShiftingData.length - 1].id
}`
)
}
className="btn btn-primary mx-1 w-full p-1.5 px-4 hover:text-white"
>
<CareIcon className="care-l-ambulance h-5 w-5" />
Track Shifting
</ButtonV2>
) : (
<ButtonV2
id="create_shift_request"
onClick={() =>
navigate(
`/facility/${patientData.facility}/patient/${patientData.id}/shift/new`
)
}
className="btn btn-primary mx-1 w-full p-1.5 px-4 hover:text-white"
>
<CareIcon className="care-l-ambulance h-5 w-5" />
Shift Patient
</ButtonV2>
)}
<button
onClick={() => {
triggerGoal("Doctor Connect Clicked", {
Expand Down Expand Up @@ -371,7 +309,13 @@ export const ConsultationDetails = (props: any) => {
</Link>
<Link
id="patient_doctor_notes"
onClick={() => setShowPatientNotesPopup(true)}
onClick={() =>
showPatientNotesPopup
? navigate(
`/facility/${facilityId}/patient/${patientId}/notes`
)
: setShowPatientNotesPopup(true)
}
className="btn btn-primary m-1 w-full hover:text-white"
>
Doctor&apos;s Notes
Expand All @@ -385,6 +329,7 @@ export const ConsultationDetails = (props: any) => {
consultation={consultationData}
fetchPatientData={fetchData}
consultationId={consultationId}
activeShiftingData={activeShiftingData}
showAbhaProfile={qParams["show-abha-profile"] === "true"}
/>

Expand Down Expand Up @@ -448,21 +393,6 @@ export const ConsultationDetails = (props: any) => {
</div>
)}
</div>
<div className="flex h-full w-full flex-col justify-end gap-2 text-right lg:flex-row">
<ButtonV2 onClick={() => setOpenDischargeSummaryDialog(true)}>
<i className="fas fa-clipboard-list"></i>
<span>{t("discharge_summary")}</span>
</ButtonV2>

<ButtonV2
id="discharge_patient_from_care"
onClick={() => setOpenDischargeDialog(true)}
disabled={!!consultationData.discharge_date}
>
<i className="fas fa-hospital-user"></i>
<span>{t("discharge_from_care")}</span>
</ButtonV2>
</div>
</div>
<div className="flex flex-col justify-between gap-2 p-4 md:flex-row">
<div className="font-base flex flex-col text-xs leading-relaxed text-gray-700">
Expand Down
Loading

0 comments on commit 8f796f5

Please sign in to comment.