Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into arunava_iam
Browse files Browse the repository at this point in the history
This merge brings in the latest changes from the upstream develop branch, ensuring
that my feature branch is up to date with the latest updates and fixes.
  • Loading branch information
i0am0arunava committed Oct 18, 2024
2 parents a2f868f + b373a0d commit 6d16b91
Show file tree
Hide file tree
Showing 33 changed files with 976 additions and 1,491 deletions.
2 changes: 1 addition & 1 deletion cypress/pageobject/Asset/AssetCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export class AssetPage {
}

clickConfigureAsset() {
cy.get("#submit").contains("Set Configuration").click();
cy.get("#submit").contains("Update").click();
}

clickConfigureVital() {
Expand Down
12 changes: 10 additions & 2 deletions src/CAREUI/interactive/KeyboardShortcut.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ export default function KeyboardShortcut(props: Props) {
)}
{(props.altShortcuts || [props.shortcut]).map((shortcut, idx, arr) => (
<>
<kbd className="hidden items-center px-1.5 font-sans font-medium text-zinc-300 shadow lg:inline-flex">
<kbd
key={`shortcut-${idx}`}
className="hidden items-center px-1.5 font-sans font-medium text-zinc-300 shadow lg:inline-flex"
>
{shortcut.map((key, idx, keys) => (
<>
{SHORTCUT_KEY_MAP[key] || key}
Expand All @@ -42,7 +45,12 @@ export default function KeyboardShortcut(props: Props) {
))}
</kbd>
{idx !== arr.length - 1 && (
<span className="text-zinc-300/60">or</span>
<span
key={`shortcut-separator-${idx}`}
className="text-zinc-300/60"
>
or
</span>
)}
</>
))}
Expand Down
14 changes: 0 additions & 14 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -839,20 +839,6 @@ export const LOCATION_BED_TYPES = [
{ id: "REGULAR", name: "Regular" },
] as const;

export const ASSET_META_TYPE = [
{ id: "CAMERA", text: "Camera(ONVIF)" },
{ id: "HL7MONITOR", text: "Vitals Monitor(HL7)" },
];

export const CAMERA_TYPE = [
{ id: "HIKVISION", text: "ONVIF Camera (HIKVISION)" },
];

export const GENDER: { [key: number]: string } = GENDER_TYPES.reduce(
(acc, curr) => ({ ...acc, [curr.id]: curr.text }),
{},
);

export type CameraPTZ = {
icon?: IconName;
label: string;
Expand Down
19 changes: 6 additions & 13 deletions src/Components/Assets/AssetConfigure.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Loading from "../Common/Loading";
import HL7Monitor from "./AssetType/HL7Monitor";
import ONVIFCamera from "./AssetType/ONVIFCamera";
import ConfigureCamera from "../CameraFeed/ConfigureCamera";
import Page from "../Common/components/Page";
import useQuery from "../../Utils/request/useQuery";
import routes from "../../Redux/api";
Expand All @@ -11,13 +11,11 @@ interface AssetConfigureProps {
}

const AssetConfigure = ({ assetId, facilityId }: AssetConfigureProps) => {
const {
data: asset,
loading,
refetch,
} = useQuery(routes.getAsset, { pathParams: { external_id: assetId } });
const { data: asset, refetch } = useQuery(routes.getAsset, {
pathParams: { external_id: assetId },
});

if (loading || !asset) {
if (!asset) {
return <Loading />;
}

Expand Down Expand Up @@ -63,12 +61,7 @@ const AssetConfigure = ({ assetId, facilityId }: AssetConfigureProps) => {
}}
backUrl={`/facility/${facilityId}/assets/${assetId}`}
>
<ONVIFCamera
asset={asset}
assetId={assetId}
facilityId={facilityId}
onUpdated={() => refetch()}
/>
<ConfigureCamera asset={asset} onUpdated={() => refetch()} />
</Page>
);
};
Expand Down
83 changes: 81 additions & 2 deletions src/Components/Assets/AssetType/HL7Monitor.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { SyntheticEvent, useEffect, useState } from "react";
import { AssetData, ResolvedMiddleware } from "../AssetTypes";
import { AssetClass, AssetData, ResolvedMiddleware } from "../AssetTypes";
import * as Notification from "../../../Utils/Notifications.js";
import MonitorConfigure from "../configure/MonitorConfigure";
import Loading from "../../Common/Loading";
import { checkIfValidIP } from "../../../Common/validation";
import Card from "../../../CAREUI/display/Card";
Expand All @@ -13,6 +12,10 @@ import VentilatorPatientVitalsMonitor from "../../VitalsMonitor/VentilatorPatien
import useAuthUser from "../../../Common/hooks/useAuthUser";
import request from "../../../Utils/request/request";
import routes from "../../../Redux/api";
import { BedModel } from "../../Facility/models";
import useQuery from "../../../Utils/request/useQuery";
import { FieldLabel } from "../../Form/FormFields/FormField";
import { BedSelect } from "../../Common/BedSelect";

interface HL7MonitorProps {
assetId: string;
Expand Down Expand Up @@ -151,3 +154,79 @@ const HL7Monitor = (props: HL7MonitorProps) => {
);
};
export default HL7Monitor;

const saveLink = async (assetId: string, bedId: string) => {
await request(routes.createAssetBed, {
body: {
asset: assetId,
bed: bedId,
},
});
Notification.Success({ msg: "AssetBed Link created successfully" });
};
const updateLink = async (
assetbedId: string,
assetId: string,
bed: BedModel,
) => {
await request(routes.partialUpdateAssetBed, {
pathParams: { external_id: assetbedId },
body: {
asset: assetId,
bed: bed.id ?? "",
},
});
Notification.Success({ msg: "AssetBed Link updated successfully" });
};

function MonitorConfigure({ asset }: { asset: AssetData }) {
const [bed, setBed] = useState<BedModel>({});
const [shouldUpdateLink, setShouldUpdateLink] = useState(false);
const { data: assetBed } = useQuery(routes.listAssetBeds, {
query: { asset: asset.id },
onResponse: ({ res, data }) => {
if (res?.status === 200 && data && data.results.length > 0) {
setBed(data.results[0].bed_object);
setShouldUpdateLink(true);
}
},
});

return (
<form
onSubmit={(e) => {
e.preventDefault();
if (shouldUpdateLink) {
updateLink(
assetBed?.results[0].id as string,
asset.id as string,
bed as BedModel,
);
} else {
saveLink(asset.id as string, bed?.id as string);
}
}}
>
<div className="flex flex-col">
<div className="w-full">
<FieldLabel className="">Bed</FieldLabel>
<BedSelect
name="bed"
setSelected={(selected) => setBed(selected as BedModel)}
selected={bed}
error=""
multiple={false}
location={asset?.location_object?.id}
facility={asset?.location_object?.facility?.id}
not_occupied_by_asset_type={AssetClass.HL7MONITOR}
className="w-full"
/>
</div>
<Submit className="mt-6 w-full shrink-0">
<CareIcon icon="l-bed" className="text-lg" />
{shouldUpdateLink ? "Update Bed" : "Save Bed"}
</Submit>
</div>
</form>
);
}
Loading

0 comments on commit 6d16b91

Please sign in to comment.