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

Production Release: January Week 2 #6998

Merged
merged 12 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
56 changes: 52 additions & 4 deletions cypress/e2e/facility_spec/inventory.cy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress";
import FacilityPage from "../../pageobject/Facility/FacilityCreation";
import LoginPage from "../../pageobject/Login/LoginPage";
import FacilityHome from "../../pageobject/Facility/FacilityHome";

describe("Inventory Management Section", () => {
const facilityPage = new FacilityPage();
const loginPage = new LoginPage();
const facilityHome = new FacilityHome();

before(() => {
loginPage.loginAsDisctrictAdmin();
Expand All @@ -16,18 +18,64 @@ describe("Inventory Management Section", () => {
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/");
cy.viewport(1280, 720);
});

it("Adds Inventory", () => {
facilityPage.visitAlreadyCreatedFacility();
facilityPage.clickManageFacilityDropdown();
facilityPage.clickInventoryManagementOption();
});

it("Add New Inventory | Modify data and delete last entry ", () => {
// add a new item
facilityPage.clickManageInventory();
facilityPage.fillInventoryDetails("Liquid Oxygen", "Add Stock", "120");
facilityPage.fillInventoryDetails("PPE", "Add Stock", "10");
facilityPage.clickAddInventory();
facilityPage.verifySuccessNotification("Inventory created successfully");
facilityPage.clickManageInventory();
// modify the new item
facilityPage.fillInventoryDetails("PPE", "Use Stock", "5");
facilityPage.clickAddInventory();
facilityPage.verifySuccessNotification("Inventory created successfully");
// verify the new modification
facilityPage.verifyPpeQuantity("PPE");
facilityPage.verifyPpeQuantity("5");
// delete the last Entry
facilityPage.clickPpeQuantity();
facilityPage.clickLastEntry();
// verify the last entry deletion
facilityPage.verifyStockInRow("#row-0", "Added Stock");
facilityPage.verifyStockInRow("#row-1", "Used Stock");
cy.wait(3000);
facilityHome.navigateBack();
facilityPage.verifyPpeQuantity("PPE");
});

it("Add New Inventory | Verify Backend and manual Minimum", () => {
// Add Inventory
facilityPage.clickManageInventory();
facilityPage.fillInventoryDetails("PPE", "Add Stock", "5");
facilityPage.clickAddInventory();
facilityPage.verifySuccessNotification("Inventory created successfully");
// Verify Backend minimum badge
facilityPage.verifyBadgeWithText(".badge-danger", "Low Stock");
// modify with manual minimum badge
facilityPage.clickAddMinimumQuanitity();
cy.wait(3000);
cy.get("body").then(($body) => {
if ($body.find("#update-minimum-quantity").is(":visible")) {
// If the 'update-minimum-quantity' element is visible, click it
facilityPage.clickUpdateMinimumQuantity();
facilityPage.setQuantity("5");
facilityPage.clickSaveUpdateMinimumQuantity();
} else {
// Otherwise, click the 'set-minimum-quantity' element
facilityPage.clickSetMinimumQuantity();
facilityPage.fillInventoryMinimumDetails("PPE", "1");
facilityPage.clickSetButton();
facilityPage.verifySuccessNotification(
"Minimum quantiy updated successfully"
);
}
});
});
afterEach(() => {
cy.saveLocalStorage();
});
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/facility_spec/locations.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import FacilityLocation from "../../pageobject/Facility/FacilityLocation";
import { AssetPagination } from "../../pageobject/Asset/AssetPagination";
import FacilityHome from "../../pageobject/Facility/FacilityHome";


describe("Location Management Section", () => {
const assetPage = new AssetPage();
const userCreationPage = new UserCreationPage();
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/patient_spec/patient_crud.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
emergency_phone_number,
phone_number,
} from "../../pageobject/constants";
const yearOfBirth = "2023";
const yearOfBirth = "2001";

const calculateAge = () => {
const currentYear = new Date().getFullYear();
Expand Down
50 changes: 50 additions & 0 deletions cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,12 @@ class FacilityPage {
cy.get("[name='quantity']").type(quantity);
}

fillInventoryMinimumDetails(name: string, quantity: string) {
cy.get("div#id").click();
cy.get("div#id ul li").contains(name).click();
cy.get("[name='quantity']").type(quantity);
}

clickAddInventory() {
cy.intercept("POST", "**/api/v1/facility/*/inventory/").as(
"createInventory"
Expand All @@ -380,6 +386,10 @@ class FacilityPage {
cy.wait("@createInventory").its("response.statusCode").should("eq", 201);
}

clickSetButton() {
cy.get("#submit").contains("Set").click();
}

fillResourceRequestDetails(
name: string,
phone_number: string,
Expand Down Expand Up @@ -443,6 +453,46 @@ class FacilityPage {
}
});
}

verifyPpeQuantity(text: string) {
cy.get("#PPE").contains(text).should("be.visible");
}

clickPpeQuantity() {
cy.get("#PPE").click();
}

clickLastEntry() {
cy.get("#delete-last-entry").click();
}

verifyStockInRow(rowId: string, stockText: string) {
cy.get(rowId).contains(stockText).should("be.visible");
}

verifyBadgeWithText(badgeClass: string, text: string) {
cy.get(badgeClass).contains(text).should("exist");
}

clickAddMinimumQuanitity() {
cy.get("#add-minimum-quantity").click();
}

clickUpdateMinimumQuantity() {
cy.get("#update-minimum-quantity").first().click();
}

setQuantity(quantity: string) {
cy.get("#quantity").click().clear().click().type(quantity);
}

clickSaveUpdateMinimumQuantity() {
cy.get("#save-update-minimumquanitity").click();
}

clickSetMinimumQuantity() {
cy.get("#set-minimum-quantity").click();
}
}

export default FacilityPage;
6 changes: 5 additions & 1 deletion src/Components/CameraFeed/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MutableRefObject } from "react";
import { AssetData } from "../Assets/AssetTypes";
import { AssetClass, AssetData } from "../Assets/AssetTypes";
import { getCameraConfig } from "../../Utils/transformUtils";
import { isIOS } from "../../Utils/utils";

Expand All @@ -18,6 +18,10 @@ export const calculateVideoDelay = (
};

export const getStreamUrl = (asset: AssetData) => {
if (asset.asset_class !== AssetClass.ONVIF) {
throw "getStreamUrl can be invoked only for ONVIF Assets";
}

const config = getCameraConfig(asset);
const host = asset.resolved_middleware?.hostname;
const uuid = config.accessKey;
Expand Down
47 changes: 29 additions & 18 deletions src/Components/Common/BloodPressureFormField.tsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,41 @@
import { FieldValidator } from "../Form/FieldValidators";
import FormField from "../Form/FormFields/FormField";
import RangeAutocompleteFormField from "../Form/FormFields/RangeAutocompleteFormField";
import {
FieldChangeEvent,
FormFieldBaseProps,
useFormFieldPropsResolver,
} from "../Form/FormFields/Utils";
import { DailyRoundsModel } from "../Patient/models";

export interface BloodPressure {
systolic: number;
diastolic: number;
}
type BloodPressure = NonNullable<DailyRoundsModel["bp"]>;

type Props = FormFieldBaseProps<Partial<BloodPressure>>;
type Props = FormFieldBaseProps<BloodPressure>;

export default function BloodPressureFormField(props: Props) {
const field = useFormFieldPropsResolver(props as any);

const handleChange = (event: FieldChangeEvent<number>) => {
field.onChange({
name: field.name,
value: {
...field.value,
[event.name]: event.value ?? -1,
},
});
const value: BloodPressure = {
...field.value,
[event.name]: event.value,
};
value.mean = meanArterialPressure(value);
field.onChange({ name: field.name, value });
};

const map =
!!props.value?.diastolic &&
!!props.value.systolic &&
meanArterialPressure(props.value as BloodPressure);
meanArterialPressure(props.value);

return (
<FormField
field={{
...field,
labelSuffix:
map && map !== -1 ? (
<span className="font-medium">MAP: {map.toFixed(1)}</span>
) : undefined,
labelSuffix: map ? (
<span className="font-medium">MAP: {map.toFixed(1)}</span>
) : undefined,
}}
>
<div className="flex flex-row items-center">
Expand Down Expand Up @@ -108,5 +105,19 @@ export const meanArterialPressure = ({
diastolic,
systolic,
}: BloodPressure) => {
return (2 * diastolic + systolic) / 3;
if (diastolic != null && systolic != null) {
return (2 * diastolic + systolic) / 3;
}
};

export const BloodPressureValidator: FieldValidator<BloodPressure> = (bp) => {
if (Object.values(bp).every((v) => v == null)) {
return;
}
if (bp.diastolic == null) {
return "Diastolic is missing. Either specify both or clear both.";
}
if (bp.systolic == null) {
return "Systolic is missing. Either specify both or clear both.";
}
};
3 changes: 3 additions & 0 deletions src/Components/ExternalResult/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export interface ILocalBodies {
export interface IDeleteExternalResult {
detail: string;
}
export interface IDeleteBedCapacity {
detail: string;
}

export interface IPartialUpdateExternalResult {
address: string;
Expand Down
Loading
Loading