Skip to content

Commit

Permalink
Merge branch 'develop' into fix#6328
Browse files Browse the repository at this point in the history
  • Loading branch information
shyamprakash123 committed Oct 17, 2023
2 parents 949d809 + 8ad1353 commit c65907b
Show file tree
Hide file tree
Showing 26 changed files with 578 additions and 363 deletions.
33 changes: 33 additions & 0 deletions cypress/e2e/assets_spec/assets_manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import { AssetSearchPage } from "../../pageobject/Asset/AssetSearch";
import FacilityPage from "../../pageobject/Facility/FacilityCreation";
import { AssetFilters } from "../../pageobject/Asset/AssetFilters";

function addDaysToDate(numberOfDays: number) {
const inputDate = new Date();
inputDate.setDate(inputDate.getDate() + numberOfDays);
return inputDate.toISOString().split("T")[0];
}

describe("Asset", () => {
const assetPage = new AssetPage();
const loginPage = new LoginPage();
Expand All @@ -26,6 +32,33 @@ describe("Asset", () => {
cy.awaitUrl("/assets");
});

it("Verify Asset Warranty Expiry Label", () => {
assetSearchPage.typeSearchKeyword(assetname);
assetSearchPage.pressEnter();
assetSearchPage.verifyBadgeContent(assetname);
assetSearchPage.clickAssetByName(assetname);
assetPage.clickupdatedetailbutton();
assetPage.scrollintoWarrantyDetails();
assetPage.enterWarrantyExpiryDate(addDaysToDate(100)); // greater than 3 months
assetPage.clickassetupdatebutton();
assetPage.verifyWarrantyExpiryLabel("");
assetPage.clickupdatedetailbutton();
assetPage.scrollintoWarrantyDetails();
assetPage.enterWarrantyExpiryDate(addDaysToDate(80)); // less than 3 months
assetPage.clickassetupdatebutton();
assetPage.verifyWarrantyExpiryLabel("3 months");
assetPage.clickupdatedetailbutton();
assetPage.scrollintoWarrantyDetails();
assetPage.enterWarrantyExpiryDate(addDaysToDate(20)); // less than 1 month
assetPage.clickassetupdatebutton();
assetPage.verifyWarrantyExpiryLabel("1 month");
assetPage.clickupdatedetailbutton();
assetPage.scrollintoWarrantyDetails();
assetPage.enterWarrantyExpiryDate(addDaysToDate(100)); // check for greater than 3 months again to verify the label is removed
assetPage.clickassetupdatebutton();
assetPage.verifyWarrantyExpiryLabel("");
});

it("Create & Edit a service history and verify reflection", () => {
assetSearchPage.typeSearchKeyword(assetname);
assetSearchPage.pressEnter();
Expand Down
29 changes: 26 additions & 3 deletions cypress/pageobject/Asset/AssetCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class AssetPage {

configureVitalAsset(hostName: string, localIp: string) {
cy.get("[data-testid=asset-configure-button]").click();
cy.get("#middlewareHostname").type(hostName);
cy.get("#middleware_hostname").type(hostName);
cy.get("#localipAddress").type(localIp);
}

Expand Down Expand Up @@ -285,16 +285,39 @@ export class AssetPage {
cy.get("#notes").scrollIntoView();
}

enterAssetNotes(text) {
enterAssetNotes(text: string) {
cy.get("#notes").click().clear();
cy.get("#notes").click().type(text);
}

enterAssetservicedate(text) {
enterAssetservicedate(text: string) {
cy.get("input[name='last_serviced_on']").click();
cy.get("#date-input").click().type(text);
}

scrollintoWarrantyDetails() {
cy.get("#warranty-details").scrollIntoView();
}

enterWarrantyExpiryDate(text: string) {
cy.get("#WarrantyAMCExpiry").click();
cy.get("#WarrantyAMCExpiry").click().type(text);
}

verifyWarrantyExpiryLabel(duration: string) {
if (duration === "") {
cy.get("#warranty-amc-expired-red").should("not.exist");
cy.get("#warranty-amc-expiring-soon-orange").should("not.exist");
cy.get("#warranty-amc-expiring-soon-yellow").should("not.exist");
} else if (duration === "expired") {
cy.get("#warranty-amc-expired-red").should("be.visible");
} else if (duration === "1 month") {
cy.get("#warranty-amc-expiring-soon-orange").should("be.visible");
} else if (duration === "3 months") {
cy.get("#warranty-amc-expiring-soon-yellow").should("be.visible");
}
}

clickassetupdatebutton() {
cy.get("#submit").click();
}
Expand Down
2 changes: 2 additions & 0 deletions src/CAREUI/display/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface Props {
text: string;
tooltip?: string;
className?: string;
id?: string;
}

export default function Chip({
Expand All @@ -21,6 +22,7 @@ export default function Chip({
}: Props) {
return (
<span
id={props?.id}
className={classNames(
"inline-flex items-center gap-2 font-medium leading-4",

Expand Down
2 changes: 1 addition & 1 deletion src/CAREUI/misc/PaginatedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function useContextualized<TItem>() {
return ctx as PaginatedListContext<TItem>;
}

interface Props<TItem> extends QueryOptions {
interface Props<TItem> extends QueryOptions<PaginatedResponse<TItem>> {
route: QueryRoute<PaginatedResponse<TItem>>;
perPage?: number;
children: (ctx: PaginatedListContext<TItem>) => JSX.Element | JSX.Element[];
Expand Down
1 change: 1 addition & 0 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ export const TELEMEDICINE_ACTIONS = [
{ id: 60, text: "COMPLETE", desc: "Complete" },
{ id: 70, text: "REVIEW", desc: "Review" },
{ id: 80, text: "NOT_REACHABLE", desc: "Not Reachable" },
{ id: 90, text: "DISCHARGE_RECOMMENDED", desc: "Discharge Recommended" },
];

export const FRONTLINE_WORKER = [
Expand Down
41 changes: 32 additions & 9 deletions src/Components/Assets/AssetType/HL7Monitor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,16 @@ const HL7Monitor = (props: HL7MonitorProps) => {
});
} else {
Notification.Error({
msg: "Something went wrong..!",
msg: "Something went wrong!",
});
}
} else {
setIpAddress_error("Please Enter a Valid IP address !!");
setIpAddress_error("IP address is invalid");
}
};

const middleware = middlewareHostname || facilityMiddlewareHostname;
const fallbackMiddleware =
asset?.location_object?.middleware_address || facilityMiddlewareHostname;

if (isLoading) return <Loading />;
return (
Expand All @@ -93,11 +94,29 @@ const HL7Monitor = (props: HL7MonitorProps) => {
<Card className="flex w-full flex-col">
<form onSubmit={handleSubmit}>
<h2 className="mb-2 text-lg font-bold">Connection</h2>
<div className="flex flex-col">
<div className="flex flex-col gap-2">
<TextFormField
name="middlewareHostname"
label="Middleware Hostname"
placeholder={facilityMiddlewareHostname}
name="middleware_hostname"
label={
<div className="flex flex-row gap-1">
<p>Middleware Hostname</p>
{!middlewareHostname && (
<div className="tooltip">
<CareIcon
icon="l-info-circle"
className="tooltip text-indigo-500 hover:text-indigo-600"
/>
<span className="tooltip-text w-56 whitespace-normal">
Middleware hostname sourced from{" "}
{asset?.location_object?.middleware_address
? "asset location"
: "asset facility"}
</span>
</div>
)}
</div>
}
placeholder={fallbackMiddleware}
value={middlewareHostname}
onChange={(e) => setMiddlewareHostname(e.value)}
errorClassName="hidden"
Expand Down Expand Up @@ -127,12 +146,16 @@ const HL7Monitor = (props: HL7MonitorProps) => {

{assetType === "HL7MONITOR" && (
<HL7PatientVitalsMonitor
socketUrl={`wss://${middleware}/observations/${localipAddress}`}
socketUrl={`wss://${
middlewareHostname || fallbackMiddleware
}/observations/${localipAddress}`}
/>
)}
{assetType === "VENTILATOR" && (
<VentilatorPatientVitalsMonitor
socketUrl={`wss://${middleware}/observations/${localipAddress}`}
socketUrl={`wss://${
middlewareHostname || fallbackMiddleware
}/observations/${localipAddress}`}
/>
)}
</div>
Expand Down
30 changes: 26 additions & 4 deletions src/Components/Assets/AssetType/ONVIFCamera.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import TextFormField from "../../Form/FormFields/TextFormField";
import { Submit } from "../../Common/components/ButtonV2";
import { SyntheticEvent } from "react";
import useAuthUser from "../../../Common/hooks/useAuthUser";
import CareIcon from "../../../CAREUI/icons/CareIcon";

interface Props {
assetId: string;
Expand Down Expand Up @@ -90,11 +91,11 @@ const ONVIFCamera = ({ assetId, facilityId, asset, onUpdated }: Props) => {
Notification.Success({ msg: "Asset Configured Successfully" });
onUpdated?.();
} else {
Notification.Error({ msg: "Something went wrong..!" });
Notification.Error({ msg: "Something went wrong!" });
}
setLoadingSetConfiguration(false);
} else {
setIpAddress_error("Please Enter a Valid Camera address !!");
setIpAddress_error("IP address is invalid");
}
};

Expand Down Expand Up @@ -139,6 +140,9 @@ const ONVIFCamera = ({ assetId, facilityId, asset, onUpdated }: Props) => {
setLoadingAddPreset(false);
};

const fallbackMiddleware =
asset?.location_object?.middleware_address || facilityMiddlewareHostname;

if (isLoading) return <Loading />;

return (
Expand All @@ -148,8 +152,26 @@ const ONVIFCamera = ({ assetId, facilityId, asset, onUpdated }: Props) => {
<div className="grid grid-cols-1 gap-x-4 lg:grid-cols-2">
<TextFormField
name="middleware_hostname"
label="Hospital Middleware Hostname"
autoComplete="off"
label={
<div className="flex flex-row gap-1">
<p>Middleware Hostname</p>
{!middlewareHostname && (
<div className="tooltip">
<CareIcon
icon="l-info-circle"
className="tooltip text-indigo-500 hover:text-indigo-600"
/>
<span className="tooltip-text w-56 whitespace-normal">
Middleware hostname sourced from{" "}
{asset?.location_object?.middleware_address
? "asset location"
: "asset facility"}
</span>
</div>
)}
</div>
}
placeholder={fallbackMiddleware}
value={middlewareHostname}
onChange={({ value }) => setMiddlewareHostname(value)}
/>
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Assets/AssetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ export const warrantyAmcValidityChip = (
if (warrantyAmcEndDate < today) {
return (
<Chip
id="warranty-amc-expired-red"
variant="danger"
startIcon="l-times-circle"
text="AMC/Warranty Expired"
Expand All @@ -524,6 +525,7 @@ export const warrantyAmcValidityChip = (
} else if (days <= 30) {
return (
<Chip
id="warranty-amc-expiring-soon-orange"
variant="custom"
className="border-orange-300 bg-orange-100 text-orange-900"
startIcon="l-exclamation-circle"
Expand All @@ -533,6 +535,7 @@ export const warrantyAmcValidityChip = (
} else if (days <= 90) {
return (
<Chip
id="warranty-amc-expiring-soon-yellow"
variant="warning"
startIcon="l-exclamation-triangle"
text="AMC/Warranty Expiring Soon"
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 @@ -44,7 +44,7 @@ export const ExportMenu = ({
<DropdownMenu
disabled={isExporting || disabled}
title={isExporting ? "Exporting..." : label}
icon={<CareIcon className="care-l-import" />}
icon={<CareIcon className="care-l-export" />}
className="tooltip border-primary-500 bg-white text-primary-500 hover:bg-primary-100 enabled:border"
>
{exportItems.map((item) => (
Expand Down
35 changes: 22 additions & 13 deletions src/Components/ExternalResult/ExternalResultUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import _ from "lodash";
import { navigate } from "raviger";
import { lazy, useState } from "react";
import CSVReader from "react-csv-reader";
import { useDispatch } from "react-redux";
import useConfig from "../../Common/hooks/useConfig";
import { externalResultUploadCsv } from "../../Redux/actions";
import * as Notification from "../../Utils/Notifications.js";
const PageTitle = lazy(() => import("../Common/PageTitle"));
import { useTranslation } from "react-i18next";
import { Cancel, Submit } from "../Common/components/ButtonV2";
import useAppHistory from "../../Common/hooks/useAppHistory";
import request from "../../Utils/request/request";
import routes from "../../Redux/api";
import { IExternalResult } from "./models";

export default function ExternalResultUpload() {
const { sample_format_external_result_import } = useConfig();
const dispatch: any = useDispatch();
// for disabling save button once clicked
const [loading, setLoading] = useState(false);
const [csvData, setCsvData] = useState(new Array<any>());
const [csvData, setCsvData] = useState(new Array<IExternalResult>());
const [errors, setErrors] = useState<any>([]);
const handleForce = (data: any) => {
setCsvData(data);
Expand All @@ -32,26 +32,35 @@ export default function ExternalResultUpload() {
header.toLowerCase().replace(/\W/g, "_"),
};

const handleSubmit = (e: any) => {
const handleSubmit = async (e: any) => {
e.preventDefault();
setLoading(true);
const valid = true;
if (csvData.length !== 0) {
const data = {
sample_tests: csvData,
};

if (csvData.length !== 0) {
if (valid) {
setErrors([]);
dispatch(externalResultUploadCsv(data)).then((resp: any) => {
if (resp && resp.status === 202) {

try {
const { res, data } = await request(routes.externalResultUploadCsv, {
body: {
sample_tests: csvData,
},
});

if (res && res.status === 202) {
setLoading(false);
navigate("/external_results");
} else {
setErrors(resp.data.map((err: any) => Object.entries(err)));
if (data) {
setErrors(data.map((err: any) => Object.entries(err)));
}
setLoading(false);
}
});
} catch (error) {
console.error("An error occurred:", error);
setLoading(false);
}
} else {
setLoading(false);
}
Expand Down
Loading

0 comments on commit c65907b

Please sign in to comment.