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

📷 Support for linking multiple cameras to a bed #8253

Merged
merged 33 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e5f923a
Switch to using newer camera feed component and remove old components…
rithviknishad Aug 5, 2024
24b41d1
remove unused code
rithviknishad Aug 5, 2024
a62e532
Merge branch 'develop' into rithviknishad/feat/migrate-configure-camera
rithviknishad Aug 7, 2024
382983c
Merge branch 'develop' into rithviknishad/feat/migrate-configure-camera
rithviknishad Aug 8, 2024
45f4c42
Merge branch 'develop' into rithviknishad/feat/migrate-configure-camera
rithviknishad Aug 20, 2024
3b466d6
Merge remote-tracking branch 'origin/develop' into rithviknishad/feat…
sainak Sep 18, 2024
a958669
Merge branch 'develop' into rithviknishad/feat/migrate-configure-camera
rithviknishad Sep 26, 2024
175ee66
add camera preset configure page
rithviknishad Sep 28, 2024
f649039
update asset configure, add camera preset configure for beds
rithviknishad Sep 29, 2024
e744ac4
add link to camera preset configure from bed management
rithviknishad Sep 29, 2024
0601baf
remove unused type
rithviknishad Sep 30, 2024
7088f8d
use host unreachable instead of authn. error
rithviknishad Sep 30, 2024
566e3ab
Merge branch 'develop' into rithviknishad/feat/migrate-configure-camera
rithviknishad Oct 1, 2024
046cfff
Merge branch 'develop' into rithviknishad/feat/migrate-configure-camera
rithviknishad Oct 1, 2024
7ffe232
Support for configuring presets of beds from asset configure page
rithviknishad Oct 3, 2024
0a7b279
cleanup
rithviknishad Oct 3, 2024
a8be173
adds i18n
rithviknishad Oct 3, 2024
c66e216
Merge branch 'develop' into rithviknishad/feat/migrate-configure-camera
rithviknishad Oct 4, 2024
b65b790
remove boundary preset support
rithviknishad Oct 7, 2024
06c2876
Merge branch 'develop' into rithviknishad/feat/migrate-configure-camera
rithviknishad Oct 7, 2024
530233f
Merge branch 'develop' into rithviknishad/feat/migrate-configure-camera
rithviknishad Oct 8, 2024
52ff6d0
Merge develop
rithviknishad Oct 8, 2024
7a77822
fix cypress
rithviknishad Oct 8, 2024
61fdd73
Merge branch 'develop' into rithviknishad/feat/migrate-configure-camera
rithviknishad Oct 8, 2024
2ceb7a7
use 2 separate APIs to list asset/bed specific presets
rithviknishad Oct 8, 2024
1dcb583
Merge branch 'develop' into rithviknishad/feat/migrate-configure-camera
rithviknishad Oct 10, 2024
d757d87
fix changes
rithviknishad Oct 10, 2024
cbda140
fix incorrect key for update preset in consultation feed
rithviknishad Oct 10, 2024
a268c2a
adds support for suggestion chips
rithviknishad Oct 10, 2024
f29f38b
Merge branch 'develop' into rithviknishad/feat/migrate-configure-camera
khavinshankar Oct 13, 2024
88a2b94
Merge branch 'develop' into rithviknishad/feat/migrate-configure-camera
rithviknishad Oct 15, 2024
5cd8a14
Merge remote-tracking branch 'origin' into rithviknishad/feat/migrate…
rithviknishad Oct 16, 2024
034f9b5
Merge branch 'develop' into rithviknishad/feat/migrate-configure-camera
rithviknishad Oct 18, 2024
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
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
Loading