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

Displaying camera feed without preset in Patient consultation page#8901 #8922

Conversation

Mahendar0701
Copy link
Contributor

Proposed Changes

image

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

@Mahendar0701 Mahendar0701 requested a review from a team as a code owner October 24, 2024 19:01
Copy link

netlify bot commented Oct 24, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit e1ac77c
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/671a9990eacc64000847e119
😎 Deploy Preview https://deploy-preview-8922--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@bodhish
Copy link
Member

bodhish commented Oct 25, 2024

@Mahendar0701 complete #8856 before talking up other issues

@Mahendar0701
Copy link
Contributor Author

@Mahendar0701 complete #8856 before talking up other issues

Yeah I m working on it too

@bodhish
Copy link
Member

bodhish commented Oct 27, 2024

Please push updates to the branch when you are working @Mahendar0701

@Mahendar0701
Copy link
Contributor Author

Please push updates to the branch when you are working @Mahendar0701

I have updated my PR #8856 yesterday

Comment on lines +55 to +60
const bedsQuery = useQuery(routes.listAssetBeds, {
query: {
bed_object: bedObjectId,
limit: 50,
},
});
Copy link
Member

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.

Suggested change
const bedsQuery = useQuery(routes.listAssetBeds, {
query: {
bed_object: bedObjectId,
limit: 50,
},
});
const assetBedsQuery = useQuery(routes.listAssetBeds, {
query: {
bed_object: bedObjectId,
limit: 50,
},
});

Comment on lines +54 to +60
const bedObjectId = props.consultationData.current_bed?.bed_object?.id || "";
const bedsQuery = useQuery(routes.listAssetBeds, {
query: {
bed_object: bedObjectId,
limit: 50,
},
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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,
});

Comment on lines +62 to +68
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]);
Copy link
Member

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.

Suggested change
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]);

Copy link
Contributor Author

@Mahendar0701 Mahendar0701 Oct 28, 2024

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.

Comment on lines +169 to +171
if (bedsQuery.loading) {
return <div>Loading bed/asset...</div>;
}
Copy link
Member

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.

Suggested change
if (bedsQuery.loading) {
return <div>Loading bed/asset...</div>;
}

@nihal467
Copy link
Member

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

@nihal467 nihal467 closed this Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants