Skip to content

Commit

Permalink
Merge branch 'develop' into issues/8516/Adding-cache-control-headers
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwansh01 authored Sep 24, 2024
2 parents a91e227 + 7878cd6 commit faddfe7
Show file tree
Hide file tree
Showing 28 changed files with 867 additions and 147 deletions.
56 changes: 56 additions & 0 deletions cypress/e2e/patient_spec/PatientBedManagement.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import LoginPage from "../../pageobject/Login/LoginPage";
import { PatientPage } from "../../pageobject/Patient/PatientCreation";
import PatientLogupdate from "../../pageobject/Patient/PatientLogupdate";
import { PatientConsultationPage } from "../../pageobject/Patient/PatientConsultation";

describe("Patient swtich bed functionality", () => {
const loginPage = new LoginPage();
const patientPage = new PatientPage();
const patientLogupdate = new PatientLogupdate();
const patientConsultationPage = new PatientConsultationPage();
const switchBedOne = "Dummy Bed 4";
const switchBedTwo = "Dummy Bed 1";
const switchBedThree = "Dummy Bed 3";
const switchPatientOne = "Dummy Patient 6";
const switchPatientTwo = "Dummy Patient 7";

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

beforeEach(() => {
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/patients");
});

it("Assign a bed for a admitted patient from update consultation page", () => {
// Open the update consultation page and assign a bed
patientPage.visitPatient(switchPatientTwo);
patientConsultationPage.clickEditConsultationButton();
patientLogupdate.selectBed(switchBedThree);
// verify the notification
cy.verifyNotification("Bed allocated successfully");
});

it("Assign a bed for a admitted patient from patient dashboard", () => {
// Assign a bed to a patient
patientPage.visitPatient(switchPatientOne);
patientLogupdate.clickSwitchBed();
patientLogupdate.selectBed(switchBedOne);
cy.verifyNotification("Bed allocated successfully");
// Clear the bed and reassign
patientLogupdate.clickSwitchBed();
cy.get("#clear-button").click();
patientLogupdate.selectBed(switchBedTwo);
cy.verifyNotification("Bed allocated successfully");
// verify the card is reflected
patientLogupdate.clickSwitchBed();
cy.verifyContentPresence("#previousbed-list", [switchBedOne, switchBedTwo]);
});

afterEach(() => {
cy.saveLocalStorage();
});
});
42 changes: 42 additions & 0 deletions cypress/e2e/patient_spec/PatientHomepage.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import LoginPage from "../../pageobject/Login/LoginPage";
import PatientHome from "../../pageobject/Patient/PatientHome";

describe("Patient Homepage present functionalities", () => {
const loginPage = new LoginPage();
const patientHome = new PatientHome();

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

beforeEach(() => {
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/patients");
});

it("Verify the functionality of the patient tab pagination", () => {
let firstPatientPageOne: string;
cy.get('[data-cy="patient"]')
.first()
.invoke("text")
.then((patientOne: string) => {
firstPatientPageOne = patientOne.trim();
patientHome.clickNextPage();
patientHome.verifySecondPageUrl();
cy.get('[data-cy="patient"]')
.first()
.invoke("text")
.then((patientTwo: string) => {
const firstPatientPageTwo = patientTwo.trim();
expect(firstPatientPageOne).not.to.eq(firstPatientPageTwo);
patientHome.clickPreviousPage();
});
});
});

afterEach(() => {
cy.saveLocalStorage();
});
});
14 changes: 14 additions & 0 deletions cypress/pageobject/Patient/PatientHome.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class PatientHome {
clickNextPage() {
cy.get("#next-pages").click();
}

verifySecondPageUrl() {
cy.url().should("include", "/patients?page=2");
}

clickPreviousPage() {
cy.get("#prev-pages").click();
}
}
export default PatientHome;
6 changes: 5 additions & 1 deletion cypress/pageobject/Patient/PatientLogupdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ class PatientLogupdate {
cy.wait(2000);
}

clickSwitchBed() {
cy.get("#switch-bed").click();
}

selectRoundType(roundType: string) {
cy.clickAndSelectOption("#rounds_type", roundType);
}

selectBed(bed: string) {
cy.searchAndSelectOption("input[name='bed']", bed);
cy.submitButton("Update");
cy.get("#update-switchbed").click();
cy.wait(2000);
}

Expand Down
2 changes: 1 addition & 1 deletion src/CAREUI/display/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const TimelineContext = createContext("");

export default function Timeline({ className, children, name }: TimelineProps) {
return (
<div className={className} id="list">
<div className={className} id="previousbed-list">
<ol role="list" className="space-y-6">
<TimelineContext.Provider value={name}>
{children}
Expand Down
16 changes: 15 additions & 1 deletion src/Common/constants.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { PatientCategory } from "../Components/Facility/models";
import {
PatientCategory,
SpokeRelationship,
} from "../Components/Facility/models";
import { SortOption } from "../Components/Common/SortDropdown";
import { dateQueryString } from "../Utils/utils";
import { IconName } from "../CAREUI/icons/CareIcon";
Expand Down Expand Up @@ -1517,6 +1520,17 @@ export const DEFAULT_ALLOWED_EXTENSIONS = [
"application/vnd.oasis.opendocument.spreadsheet,application/pdf",
];

export const SPOKE_RELATION_TYPES = [
{
text: "Regular",
value: SpokeRelationship.REGULAR,
},
{
text: "Tele ICU",
value: SpokeRelationship.TELE_ICU,
},
];

export const HumanBodyPaths = {
anterior: [
{
Expand Down
6 changes: 6 additions & 0 deletions src/Components/Common/FacilitySelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ interface FacilitySelectProps {
selected?: FacilityModel | FacilityModel[] | null;
setSelected: (selected: FacilityModel | FacilityModel[] | null) => void;
allowNone?: boolean;
placeholder?: string;
filter?: (facilities: FacilityModel) => boolean;
}

export const FacilitySelect = (props: FacilitySelectProps) => {
Expand All @@ -44,6 +46,8 @@ export const FacilitySelect = (props: FacilitySelectProps) => {
allowNone = false,
freeText = false,
errors = "",
placeholder,
filter,
} = props;

const facilitySearch = useCallback(
Expand Down Expand Up @@ -82,6 +86,7 @@ export const FacilitySelect = (props: FacilitySelectProps) => {

return (
<AutoCompleteAsync
placeholder={placeholder}
name={name}
required={required}
multiple={multiple}
Expand All @@ -97,6 +102,7 @@ export const FacilitySelect = (props: FacilitySelectProps) => {
compareBy="id"
className={className}
error={errors}
filter={filter}
/>
);
};
11 changes: 10 additions & 1 deletion src/Components/Common/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const StatelessSidebar = ({
const [lastIndicatorPosition, setLastIndicatorPosition] = useState(0);
const [isOverflowVisible, setOverflowVisisble] = useState(false);

useEffect(() => {
const updateIndicator = () => {
if (!indicatorRef.current) return;
const index = NavItems.findIndex((item) => item.to === activeLink);
const navItemCount = NavItems.length + (careConfig.urls.dashboard ? 2 : 1); // +2 for notification and dashboard
Expand All @@ -94,8 +94,17 @@ const StatelessSidebar = ({
} else {
indicatorRef.current.style.display = "none";
}
};

useEffect(() => {
updateIndicator();
}, [activeLink, lastIndicatorPosition]);

useEffect(() => {
addEventListener("resize", updateIndicator);
return () => removeEventListener("resize", updateIndicator);
}, []);

const handleOverflow = (value: boolean) => {
setOverflowVisisble(value);
};
Expand Down
71 changes: 41 additions & 30 deletions src/Components/Facility/ConsultationDoctorNotes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import CareIcon from "../../../CAREUI/icons/CareIcon";
import { NonReadOnlyUsers } from "../../../Utils/AuthorizeFor";
import { useMessageListener } from "../../../Common/hooks/useMessageListener";
import PatientConsultationNotesList from "../PatientConsultationNotesList.js";
import { PatientNoteStateType } from "../models.js";
import { PatientNoteStateType, PaitentNotesReplyModel } from "../models.js";
import routes from "../../../Redux/api.js";
import request from "../../../Utils/request/request.js";
import useQuery from "../../../Utils/request/useQuery.js";
Expand All @@ -15,6 +15,7 @@ import { classNames, isAppleDevice, keysOf } from "../../../Utils/utils.js";
import AutoExpandingTextInputFormField from "../../Form/FormFields/AutoExpandingTextInputFormField.js";
import { PATIENT_NOTES_THREADS } from "../../../Common/constants.js";
import useAuthUser from "../../../Common/hooks/useAuthUser.js";
import DoctorNoteReplyPreviewCard from "../DoctorNoteReplyPreviewCard.js";
import { t } from "i18next";

interface ConsultationDoctorNotesProps {
Expand All @@ -39,6 +40,9 @@ const ConsultationDoctorNotes = (props: ConsultationDoctorNotesProps) => {
const [facilityName, setFacilityName] = useState("");
const [patientName, setPatientName] = useState("");
const [focused, setFocused] = useState(false);
const [reply_to, setReplyTo] = useState<PaitentNotesReplyModel | undefined>(
undefined,
);

const initialData: PatientNoteStateType = {
notes: [],
Expand All @@ -65,6 +69,7 @@ const ConsultationDoctorNotes = (props: ConsultationDoctorNotesProps) => {
note: noteField,
thread,
consultation: consultationId,
reply_to: reply_to?.id,
},
});

Expand All @@ -73,6 +78,7 @@ const ConsultationDoctorNotes = (props: ConsultationDoctorNotesProps) => {
setState({ ...state, cPage: 1 });
setNoteField("");
setReload(true);
setReplyTo(undefined);
}
};

Expand Down Expand Up @@ -145,36 +151,41 @@ const ConsultationDoctorNotes = (props: ConsultationDoctorNotesProps) => {
reload={reload}
setReload={setReload}
thread={thread}
setReplyTo={setReplyTo}
/>

<div className="relative mx-4 flex items-center">
<AutoExpandingTextInputFormField
id="doctor_consultation_notes"
maxHeight={160}
rows={2}
name="note"
value={noteField}
onChange={(e) => setNoteField(e.value)}
className="w-full grow"
innerClassName="pr-10"
errorClassName="hidden"
placeholder={t("notes_placeholder")}
disabled={!patientActive}
onFocus={() => setFocused(true)}
onBlur={() => setFocused(false)}
/>
<ButtonV2
onClick={onAddNote}
border={false}
className="absolute right-2"
ghost
size="small"
disabled={!patientActive}
authorizeFor={NonReadOnlyUsers}
>
<CareIcon icon="l-message" className="text-lg" />
</ButtonV2>
</div>
<DoctorNoteReplyPreviewCard
parentNote={reply_to}
cancelReply={() => setReplyTo(undefined)}
>
<div className="relative mx-4 flex items-center">
<AutoExpandingTextInputFormField
id="doctor_consultation_notes"
maxHeight={160}
rows={2}
name="note"
value={noteField}
onChange={(e) => setNoteField(e.value)}
className="w-full grow"
innerClassName="pr-10"
errorClassName="hidden"
placeholder={t("notes_placeholder")}
disabled={!patientActive}
onFocus={() => setFocused(true)}
onBlur={() => setFocused(false)}
/>
<ButtonV2
onClick={onAddNote}
border={false}
className="absolute right-2"
ghost
size="small"
disabled={!patientActive}
authorizeFor={NonReadOnlyUsers}
>
<CareIcon icon="l-message" className="text-lg" />
</ButtonV2>
</div>
</DoctorNoteReplyPreviewCard>
</div>
</Page>
);
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Facility/Consultations/Beds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ const Beds = (props: BedsProps) => {
</div>
<div className="mt-4 flex flex-row justify-end">
<div>
<ButtonV2 variant="primary" type="submit">
<ButtonV2 variant="primary" type="submit" id="update-switchbed">
<CareIcon icon="l-bed" className="text-xl" />
Update
</ButtonV2>
Expand Down
21 changes: 14 additions & 7 deletions src/Components/Facility/DoctorNote.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import InfiniteScroll from "react-infinite-scroll-component";
import CircularProgress from "../Common/components/CircularProgress";
import PatientNoteCard from "./PatientNoteCard";
import { PatientNoteStateType } from "./models";
import { PatientNoteStateType, PatientNotesModel } from "./models";
import DoctorNoteReplyPreviewCard from "./DoctorNoteReplyPreviewCard";

interface DoctorNoteProps {
state: PatientNoteStateType;
setReload: any;
handleNext: () => void;
disableEdit?: boolean;
setReplyTo?: (reply_to: PatientNotesModel | undefined) => void;
}

const DoctorNote = (props: DoctorNoteProps) => {
const { state, handleNext, setReload, disableEdit } = props;
const { state, handleNext, setReload, disableEdit, setReplyTo } = props;

return (
<div
Expand All @@ -33,12 +35,17 @@ const DoctorNote = (props: DoctorNoteProps) => {
scrollableTarget="patient-notes-list"
>
{state.notes.map((note) => (
<PatientNoteCard
note={note}
<DoctorNoteReplyPreviewCard
key={note.id}
setReload={setReload}
disableEdit={disableEdit}
/>
parentNote={note.reply_to_object}
>
<PatientNoteCard
note={note}
setReload={setReload}
disableEdit={disableEdit}
setReplyTo={setReplyTo}
/>
</DoctorNoteReplyPreviewCard>
))}
</InfiniteScroll>
) : (
Expand Down
Loading

0 comments on commit faddfe7

Please sign in to comment.