Skip to content

Commit

Permalink
Merge branch 'develop' into rithviknishad/fix/camera-feed-enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad authored Jul 24, 2024
2 parents 15ace8c + fe63a07 commit 6d7a1f3
Show file tree
Hide file tree
Showing 37 changed files with 646 additions and 473 deletions.
1 change: 0 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"extends": [
"eslint:recommended",
"plugin:react-hooks/recommended",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:i18next/recommended",
Expand Down
4 changes: 4 additions & 0 deletions cypress/e2e/patient_spec/patient_discharge.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe("Patient Discharge based on multiple reason", () => {
patientDischarge.clickDischarge();
patientDischarge.selectDischargeReason(patientDischargeReason4);
cy.submitButton("Confirm Discharge");
cy.submitButton("Acknowledge & Submit");
cy.verifyNotification("Patient Discharged Successfully");
cy.closeNotification();
// Verify the consultation dashboard reflection
Expand All @@ -53,6 +54,7 @@ describe("Patient Discharge based on multiple reason", () => {
patientDischarge.typeDischargeNote(patientDeathCause);
patientDischarge.typeDoctorName(doctorName);
cy.submitButton("Confirm Discharge");
cy.submitButton("Acknowledge & Submit");
cy.verifyNotification("Patient Discharged Successfully");
cy.closeNotification();
// Verify the consultation dashboard reflection
Expand All @@ -77,6 +79,7 @@ describe("Patient Discharge based on multiple reason", () => {
patientDischarge.typeReferringFacility(referringFreetextFacility);
cy.wait(2000);
cy.submitButton("Confirm Discharge");
cy.submitButton("Acknowledge & Submit");
cy.wait(2000);
cy.verifyNotification("Patient Discharged Successfully");
cy.closeNotification();
Expand Down Expand Up @@ -108,6 +111,7 @@ describe("Patient Discharge based on multiple reason", () => {
cy.closeNotification();
// submit the discharge pop-up
cy.submitButton("Confirm Discharge");
cy.submitButton("Acknowledge & Submit");
cy.wait(2000);
cy.verifyNotification("Patient Discharged Successfully");
cy.closeNotification();
Expand Down
11 changes: 7 additions & 4 deletions cypress/e2e/patient_spec/patient_registration.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ describe("Patient Creation with consultation", () => {
});

it("Patient Registration using the transfer with no consultation", () => {
// transfer the patient and no consulation
// transfer the patient with no consulation and verify the transfer to a new facility
patientPage.createPatient();
patientPage.selectFacility(patientTransferFacility);
patientPage.patientformvisibility();
Expand All @@ -264,9 +264,10 @@ describe("Patient Creation with consultation", () => {
patientTransfer.clickTransferPatientNameList(patientTransferName);
patientTransfer.clickTransferPatientYOB(yearOfBirth);
patientTransfer.clickTransferSubmitButton();
patientTransfer.verifyFacilitySuccessfullMessage();
cy.verifyNotification(
"Patient Dummy Patient 10 (Male) transferred successfully",
);
patientTransfer.clickConsultationCancelButton();
cy.wait(3000);
// allow the transfer button of a patient
patientTransfer.clickAllowPatientTransferButton();
// Verify the patient error message for the same facility
Expand All @@ -280,7 +281,9 @@ describe("Patient Creation with consultation", () => {
patientTransfer.clickTransferPatientNameList(patientTransferName);
patientTransfer.clickTransferPatientYOB(yearOfBirth);
patientTransfer.clickTransferSubmitButton();
patientTransfer.verifyFacilityErrorMessage();
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", () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/pageobject/Patient/PatientPrescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class PatientPrescription {
}

clickAdministerButton() {
cy.get("#administer-medicine").should("be.visible");
cy.get("#administer-medicine").scrollIntoView().should("be.visible");
cy.verifyAndClickElement("#administer-medicine", "Administer");
}

Expand Down
30 changes: 2 additions & 28 deletions cypress/pageobject/Patient/PatientTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
1 change: 1 addition & 0 deletions cypress/support/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// <reference types="cypress" />
import "./commands";

declare global {
Expand Down
21 changes: 16 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
9 changes: 9 additions & 0 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ export const USER_TYPE_OPTIONS = [
{ id: "StateAdmin", role: "State Admin", readOnly: false },
] as const;

export const USER_LAST_ACTIVE_OPTIONS = [
{ id: 1, text: "24 hours" },
{ id: 7, text: "7 days" },
{ id: 30, text: "30 days" },
{ id: 90, text: "90 days" },
{ id: 365, text: "1 Year" },
{ id: "never", text: "Never" },
];

export type UserRole = (typeof USER_TYPE_OPTIONS)[number]["id"];

export const USER_TYPES = USER_TYPE_OPTIONS.map((o) => o.id);
Expand Down
17 changes: 17 additions & 0 deletions src/Common/hooks/useConfirmedAction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useState } from "react";

export default function useConfirmedAction(action: () => Promise<void>) {
const [showConfirmation, setShowConfirmation] = useState(false);

return {
requestConfirmation: () => setShowConfirmation(true),
submit: action,

confirmationProps: {
onClose: () => setShowConfirmation(false),
show: showConfirmation,
onConfirm: action,
action: "Submit",
},
};
}
8 changes: 6 additions & 2 deletions src/Common/hooks/useFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,17 @@ export default function useFilters({
return acc;
}, [] as string[]);

const show = activeFilters.length > 0 || children;

return (
<div className="col-span-3 my-2 flex w-full flex-wrap items-center gap-2">
<div
className={`col-span-3 my-2 flex w-full flex-wrap items-center gap-2 ${show ? "" : "hidden"}`}
>
{compiledBadges.map((props) => (
<FilterBadge {...props} name={t(props.name)} key={props.name} />
))}
{children}
{(activeFilters.length >= 1 || children) && (
{show && (
<button
id="clear-all-filters"
className="rounded-full border border-secondary-300 bg-white px-2 py-1 text-xs text-secondary-600 hover:text-secondary-800"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import useFilters from "../../../Common/hooks/useFilters";
import { Fragment } from "react";
import CareIcon from "../../../CAREUI/icons/CareIcon";
import useSlug from "../../../Common/hooks/useSlug";
import { useTranslation } from "react-i18next";

interface Props {
perPageLimit: number;
Expand All @@ -16,6 +17,7 @@ interface Props {
}

const LiveMonitoringFilters = (props: Props) => {
const { t } = useTranslation();
const facilityId = useSlug("facility");
const { qParams, updateQuery, removeFilter, updatePage } = useFilters({
limit: props.perPageLimit,
Expand All @@ -25,9 +27,9 @@ const LiveMonitoringFilters = (props: Props) => {
<div className="flex flex-row-reverse items-center gap-4 md:flex-row">
<Popover className="relative">
<Popover.Button>
<ButtonV2 variant="secondary" border>
<ButtonV2 variant={qParams.location ? "primary" : "secondary"} border>
<CareIcon icon="l-setting" className="text-lg" />
Settings and Filters
{t("settings_and_filters")}
</ButtonV2>
</Popover.Button>
<Transition
Expand Down Expand Up @@ -73,37 +75,6 @@ const LiveMonitoringFilters = (props: Props) => {
/>
</div>
</div>
{/* <CheckBoxFormField
name="in_use_by_consultation"
label="Hide cameras without patient"
value={qParams.in_use_by_consultation === "true"}
onChange={({ name, value }) => {
if (value) {
updateQuery({ [name]: value });
} else {
removeFilter(name);
}
}}
labelClassName="text-sm"
errorClassName="hidden"
/>
<CheckBoxFormField
name="is_working"
label="Camera is Working"
value={
qParams.is_working === "true" ||
qParams.is_working === undefined
}
onChange={({ name, value }) => {
if (value) {
updateQuery({ [name]: value });
} else {
removeFilter(name);
}
}}
labelClassName="text-sm"
errorClassName="hidden"
/> */}
<ButtonV2
variant="secondary"
border
Expand Down
21 changes: 14 additions & 7 deletions src/Components/Facility/CentralNursingStation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ export default function CentralNursingStation({ facilityId }: Props) {
asset_class: "HL7MONITOR",
ordering: qParams.ordering || "bed__name",
bed_is_occupied:
(qParams.hide_monitors_without_patient ?? "true") === "true" ||
undefined,
qParams.monitors_without_patient === "true" ? undefined : "true",
},
});

Expand Down Expand Up @@ -81,9 +80,17 @@ export default function CentralNursingStation({ facilityId }: Props) {
<div className="flex flex-row-reverse items-center gap-4 md:flex-row">
<Popover className="relative">
<Popover.Button>
<ButtonV2 variant="secondary" border>
<ButtonV2
variant={
qParams.location ||
qParams.monitors_without_patient === "true"
? "primary"
: "secondary"
}
border
>
<CareIcon icon="l-setting" className="text-lg" />
Settings and Filters
{t("settings_and_filters")}
</ButtonV2>
</Popover.Button>
<Transition
Expand Down Expand Up @@ -150,10 +157,10 @@ export default function CentralNursingStation({ facilityId }: Props) {
errorClassName="hidden"
/>
<CheckBoxFormField
name="hide_monitors_without_patient"
label="Hide Monitors without Patient"
name="monitors_without_patient"
label="Include monitors without patient"
value={JSON.parse(
qParams.hide_monitors_without_patient ?? true,
qParams.monitors_without_patient ?? "false",
)}
onChange={(e) => updateQuery({ [e.name]: `${e.value}` })}
labelClassName="text-sm"
Expand Down
6 changes: 4 additions & 2 deletions src/Components/Facility/ConsultationDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,10 @@ export const ConsultationDetails = (props: any) => {
}

const tabButtonClasses = (selected: boolean) =>
`capitalize min-w-max-content cursor-pointer border-transparent text-secondary-700 hover:text-secondary-700 hover:border-secondary-300 font-bold whitespace-nowrap ${
selected === true ? "border-primary-500 text-primary-600 border-b-2" : ""
`capitalize min-w-max-content cursor-pointer font-bold whitespace-nowrap ${
selected === true
? "border-primary-500 hover:border-secondary-300 text-primary-600 border-b-2"
: "text-secondary-700 hover:text-secondary-700"
}`;

return (
Expand Down
Loading

0 comments on commit 6d7a1f3

Please sign in to comment.