-
Notifications
You must be signed in to change notification settings - Fork 423
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
Displaying camera feed without preset in Patient consultation page#8901 #8922
Conversation
✅ Deploy Preview for care-ohc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@Mahendar0701 complete #8856 before talking up other issues |
Yeah I m working on it too |
Please push updates to the branch when you are working @Mahendar0701 |
I have updated my PR #8856 yesterday |
const bedsQuery = useQuery(routes.listAssetBeds, { | ||
query: { | ||
bed_object: bedObjectId, | ||
limit: 50, | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use proper names to avoid confusions. You are using the Asset Beds list API and not Beds list API.
const bedsQuery = useQuery(routes.listAssetBeds, { | |
query: { | |
bed_object: bedObjectId, | |
limit: 50, | |
}, | |
}); | |
const assetBedsQuery = useQuery(routes.listAssetBeds, { | |
query: { | |
bed_object: bedObjectId, | |
limit: 50, | |
}, | |
}); |
const bedObjectId = props.consultationData.current_bed?.bed_object?.id || ""; | ||
const bedsQuery = useQuery(routes.listAssetBeds, { | ||
query: { | ||
bed_object: bedObjectId, | ||
limit: 50, | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const bedObjectId = props.consultationData.current_bed?.bed_object?.id || ""; | |
const bedsQuery = useQuery(routes.listAssetBeds, { | |
query: { | |
bed_object: bedObjectId, | |
limit: 50, | |
}, | |
}); | |
const bedId = props.consultationData.current_bed?.bed_object?.id; | |
const bedsQuery = useQuery(routes.listAssetBeds, { | |
query: { | |
bed_object: bedId ?? "", | |
limit: 50, | |
}, | |
prefetch: !!bedId, | |
}); |
const bedLocationId = bed?.location_object?.id; | ||
|
||
const matchingAsset = useMemo(() => { | ||
return bedsQuery.data?.results.find( | ||
(bedItem) => bedItem.asset_object?.location_object?.id === bedLocationId, | ||
)?.asset_object; | ||
}, [bedsQuery.data, bedLocationId]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if bedsQuery (better known as assetBedsQuery) is already filtered by a bed, why filter by location? We do not allow linking an asset with a bed with different locations anyhow in the first place.
const bedLocationId = bed?.location_object?.id; | |
const matchingAsset = useMemo(() => { | |
return bedsQuery.data?.results.find( | |
(bedItem) => bedItem.asset_object?.location_object?.id === bedLocationId, | |
)?.asset_object; | |
}, [bedsQuery.data, bedLocationId]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rithviknishad
Now i found that assetBedsQuery is not filtering by bed.
I need to filter the fetched values by bedId and asset_class.
const filteredAssets = useMemo(() => {
return assetBedsQuery.data?.results.filter(
(bedItem) =>
bedItem.bed_object?.id === bedId &&
bedItem.asset_object?.asset_class === "ONVIF"
);
}, [assetBedsQuery.data, bedId]);
However, I have a question: if a bed has multiple cameras, should I display all camera assets? I am getting multiple camera assets.
if (bedsQuery.loading) { | ||
return <div>Loading bed/asset...</div>; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add it as an or condition in line 165 along with presetsQuery.loading
.
if (bedsQuery.loading) { | |
return <div>Loading bed/asset...</div>; | |
} |
Displaying the camera feed without a preset assigned to the bed is not a good approach, so closing the PR as the linked issues are closed |
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
Merge Checklist