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

Fix: Breadcrumbs redirection to patient edit consultation form #8985

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

shauryag2002
Copy link
Contributor

@shauryag2002 shauryag2002 commented Nov 2, 2024

Proposed Changes

@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

Summary by CodeRabbit

  • New Features

    • Introduced a breadcrumb navigation entry for easier access to consultation details.
    • Updated the ConfirmDialog to dynamically display patient code status for consent records.
    • Added a new breadcrumb entry in the ConsultationDetails component for direct navigation to the consultation update page.
  • Improvements

    • Cleaned up URL structure by modifying the backUrl.
    • Enhanced upload handling logic for better interaction with existing consent records.
    • Updated rendering logic for consultation tab buttons to conditionally display based on consultation state and user permissions.
    • Minor formatting adjustments for improved clarity in tab navigation.

- Added Consultation breadcrumb with URI for updating consultation
- Updated backUrl for consultation update
Fixes ohcnetwork#8765
@shauryag2002 shauryag2002 requested a review from a team as a code owner November 2, 2024 19:04
Copy link

netlify bot commented Nov 2, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 2610ee6
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/674759d6b61a4d0009ca0018
😎 Deploy Preview https://deploy-preview-8985--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.

Copy link
Contributor

coderabbitai bot commented Nov 5, 2024

Walkthrough

The changes in PatientConsentRecords.tsx introduce a breadcrumb entry for consultations to enhance navigation to existing patient consultations. The backUrl has been updated to remove trailing slashes for cleaner URLs. The ConfirmDialog component's description now dynamically reflects the patient code status of consent records. Additionally, adjustments to the handleUpload function ensure it operates correctly based on existing consent records and their statuses, while maintaining the overall structure and functionality of the component.

Changes

File Change Summary
src/components/Patient/PatientConsentRecords.tsx Added breadcrumb entry for consultations; updated backUrl; modified ConfirmDialog description; adjusted handleUpload logic.
src/components/Facility/ConsultationDetails/index.tsx Added breadcrumb entry for consultations; updated tab rendering logic based on consultation state and user permissions.

Assessment against linked issues

Objective Addressed Explanation
Breadcrumbs should redirect to the patient's existing consultation page (#8759)

Possibly related PRs

  • Fixed delete button size in asset details & consent record pages #8996: The changes in PatientConsentRecords.tsx include updates to the ConfirmDialog component and the handleUpload function, which are also relevant to the consent record management mentioned in this PR.
  • Fix bug with recursion #9100: This PR involves changes to the ConsultationDetails component, which is relevant as the main PR also updates the ConsultationDetails component by adding a breadcrumb entry for consultation navigation.

Suggested labels

needs review

Suggested reviewers

  • rithviknishad
  • shivankacker

Poem

In the land of health, where records do flow,
A breadcrumb appears, guiding us so!
With a click, we find, the consultations we seek,
A clearer path forward, no longer oblique.
So hop with delight, for changes are here,
Navigating consent, brings us all cheer! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 977140f and 2610ee6.

📒 Files selected for processing (1)
  • src/components/Facility/ConsultationDetails/index.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Facility/ConsultationDetails/index.tsx

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@nihal467
Copy link
Member

nihal467 commented Nov 6, 2024

image
image

  • the issue still exist, can you recheck the PR

@nihal467
Copy link
Member

@shauryag2002 what is the status on the PR ?

@shauryag2002
Copy link
Contributor Author

@shauryag2002 what is the status on the PR ?

I am little busy past few days, resolving requested changes today!

@github-actions github-actions bot added needs-triage question Further information is requested and removed stale labels Nov 16, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
src/components/Facility/ConsultationDetails/index.tsx (1)

Based on the search results, I can now provide a conclusive response about the backUrl behavior:

The backUrl="/patients" is inconsistent with the navigation pattern in the codebase

The search results show that similar patient-related views follow a more specific navigation pattern:

  • Patient home uses: backUrl={facilityId ? /facility/${facilityId}/patients : "/patients"}
  • Other patient-related views consistently navigate back to facility-specific paths

The current implementation should be updated to:

backUrl={`/facility/${facilityId}/patients`}

This change would:

  • Maintain consistency with the rest of the codebase's navigation patterns
  • Keep users within the context of the current facility
  • Provide a better user experience by returning to the facility-specific patient list
🔗 Analysis chain

Line range hint 209-224: Verify the backUrl behavior in PageTitle

While the consultation breadcrumb changes look good, let's verify that the backUrl="/patients" is the intended behavior. Should users be redirected to the general patients list, or would it be more appropriate to return to the specific patient's details?

Let's check for consistency in backUrl usage across similar views:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other PageTitle components with backUrl props to verify consistency
rg -A 2 'backUrl=' --type tsx

Length of output: 57


Script:

#!/bin/bash
# Search for PageTitle components with backUrl props using a more general pattern
rg -A 2 'backUrl.*=' --type ts --type tsx --type jsx

Length of output: 82


Script:

#!/bin/bash
# Search for PageTitle component usage patterns
rg -A 2 '<PageTitle' --type ts --type tsx --type jsx

Length of output: 82


Script:

#!/bin/bash
# Find all files that might contain PageTitle component
fd -e tsx -e ts -e jsx PageTitle

Length of output: 70


Script:

#!/bin/bash
# Search for navigation patterns in consultation related files
rg -A 2 'consultation.*navigation|navigation.*consultation' --type ts --type tsx

Length of output: 110


Script:

#!/bin/bash
# Let's examine the PageTitle component implementation
cat src/components/Common/PageTitle.tsx

Length of output: 2088


Script:

#!/bin/bash
# Search for navigation patterns without file type restrictions
rg -A 2 'backUrl.*=|<PageTitle'

Length of output: 16116


Script:

#!/bin/bash
# Search for consultation-related files
fd consultation

Length of output: 1684

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ed92f6a and 18141a8.

📒 Files selected for processing (2)
  • src/components/Facility/ConsultationDetails/index.tsx (1 hunks)
  • src/components/Patient/PatientConsentRecords.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Patient/PatientConsentRecords.tsx
🔇 Additional comments (1)
src/components/Facility/ConsultationDetails/index.tsx (1)

214-217: LGTM! The breadcrumb navigation fix looks correct.

The addition of the consultation breadcrumb with the proper update URI addresses the navigation issue described in #8759. The implementation correctly redirects users to the consultation update form instead of creating a new consultation.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (4)
src/components/Facility/ConsultationDetails/index.tsx (4)

195-197: Improve template literal formatting

The tab button styling logic is correct, but the formatting could be improved for better readability.

Apply this formatting fix:

  const tabButtonClasses = (selected: boolean) =>
    `capitalize min-w-max-content cursor-pointer font-bold whitespace-nowrap ${
      selected === true
        ? "border-primary-500 hover:border-secondary-300 text-primary-600 border-b-2"
        : "text-secondary-700 hover:text-secondary-700"
    }`;
🧰 Tools
🪛 GitHub Check: lint

[failure] 195-195:
Insert ⏎······


[failure] 196-196:
Insert ··


[failure] 197-197:
Insert ··


Line range hint 386-397: Extract camera feed visibility logic into a separate function

The current implementation has multiple nested conditions that could be simplified for better maintainability.

Consider extracting the visibility logic into a dedicated function:

+ const shouldShowFeedTab = () => {
+   return (
+     isCameraAttached &&
+     !consultationData?.discharge_date &&
+     consultationData?.current_bed?.bed_object?.id &&
+     CameraFeedPermittedUserTypes.includes(authUser.user_type)
+   );
+ };

  if (p === "FEED") {
-   if (
-     isCameraAttached === false || // No camera attached
-     consultationData?.discharge_date || // Discharged
-     !consultationData?.current_bed?.bed_object?.id || // Not admitted to bed
-     !CameraFeedPermittedUserTypes.includes(
-       authUser.user_type,
-     )
-   )
-     return null; // Hide feed tab
+   if (!shouldShowFeedTab()) return null;
  }
🧰 Tools
🪛 GitHub Check: lint

[failure] 195-195:
Insert ⏎······


[failure] 196-196:
Insert ··


[failure] 197-197:
Insert ··


279-280: Fix indentation in navigation path

The navigation logic is correct, but the indentation should be consistent.

Apply this formatting fix:

  ? navigate(
-     `/facility/${facilityId}/patient/${patientId}/consultation/${consultationId}/notes`,
+   `/facility/${facilityId}/patient/${patientId}/consultation/${consultationId}/notes`,
  )
🧰 Tools
🪛 GitHub Check: lint

[failure] 279-279:
Insert ··


[failure] 280-280:
Replace ···················· with ······················


316-323: Simplify date display logic

The date display logic could be more concise while maintaining readability.

Consider this simplified version:

- <div className="text-3xl font-bold">
-   {relativeTime(
-     consultationData.discharge_date
-       ? consultationData.discharge_date
-       : consultationData.encounter_date,
-   )}
- </div>
+ <div className="text-3xl font-bold">
+   {relativeTime(consultationData.discharge_date ?? consultationData.encounter_date)}
+ </div>
🧰 Tools
🪛 GitHub Check: lint

[failure] 316-316:
Delete ··


[failure] 317-317:
Delete ··


[failure] 318-318:
Delete ··

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 18141a8 and af1a663.

📒 Files selected for processing (1)
  • src/components/Facility/ConsultationDetails/index.tsx (4 hunks)
🧰 Additional context used
🪛 GitHub Check: lint
src/components/Facility/ConsultationDetails/index.tsx

[failure] 195-195:
Insert ⏎······


[failure] 196-196:
Insert ··


[failure] 197-197:
Insert ··


[failure] 224-224:
Insert ··


[failure] 225-225:
Insert ··


[failure] 279-279:
Insert ··


[failure] 280-280:
Replace ···················· with ······················


[failure] 316-316:
Delete ··


[failure] 317-317:
Delete ··


[failure] 318-318:
Delete ··

🔇 Additional comments (1)
src/components/Facility/ConsultationDetails/index.tsx (1)

216-219: LGTM: Breadcrumb navigation fix implemented correctly

The addition of the consultation breadcrumb with the correct update URI should resolve the redirection issue described in #8759.

Let's verify the breadcrumb navigation paths:

✅ Verification successful

Breadcrumb navigation path is consistent with router configuration

The verification confirms that:

  1. The consultation update path /facility/${facilityId}/patient/${patientId}/consultation/${consultationId}/update is correctly defined in ConsultationRoutes.tsx
  2. The same path pattern is consistently used across other components that need to link to the consultation update form
  3. No conflicting or inconsistent navigation paths were found

The breadcrumb implementation aligns with the established routing structure and will correctly redirect users to the consultation update form, fixing issue #8759.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistency of consultation update paths across the codebase

# Search for other consultation update path patterns
rg -l "consultation/\$\{[^}]+\}/update"

# Search for potential conflicting navigation paths
rg "consultation.*update" --type tsx

Length of output: 107


Script:

#!/bin/bash
# Search for consultation update paths with proper file type
rg -t ts -t tsx "consultation.*update"

# Search for router configurations and navigation paths
rg -t ts -t tsx "consultation.*route|path.*consultation"

# Look for breadcrumb configurations
rg -t ts -t tsx "breadcrumb.*consultation|consultation.*breadcrumb"

Length of output: 253


Script:

#!/bin/bash
# Search for consultation paths and breadcrumbs without file type restrictions
rg "consultation.*update"

# Find all TypeScript/React files that might contain consultation routes
fd "\.(tsx?|jsx?)$" | xargs rg "consultation.*route|path.*consultation"

# Look for breadcrumb configurations
fd "\.(tsx?|jsx?)$" | xargs rg "breadcrumb.*consultation|consultation.*breadcrumb"

Length of output: 17286

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
src/components/Facility/ConsultationDetails/index.tsx (2)

424-424: Consider extracting FEED tab visibility logic to improve readability.

The current implementation has multiple nested conditions that could be simplified for better maintainability.

Consider extracting the visibility logic to a custom hook or helper function:

+const useFeedTabVisibility = (
+  isCameraAttached: boolean,
+  consultationData: ConsultationModel,
+  userType: string
+) => {
+  return (
+    isCameraAttached &&
+    !consultationData?.discharge_date &&
+    consultationData?.current_bed?.bed_object?.id &&
+    CameraFeedPermittedUserTypes.includes(userType)
+  );
+};

 export const ConsultationDetails = (props: any) => {
   // ... existing code ...
+  const showFeedTab = useFeedTabVisibility(
+    isCameraAttached,
+    consultationData,
+    authUser.user_type
+  );

   // Replace the existing condition with:
   if (p === "FEED" && !showFeedTab) return null;
🧰 Tools
🪛 GitHub Check: lint

[failure] 424-424:
Insert


424-424: Add newline at end of file.

Add a newline character at the end of the file to comply with coding standards.

 };
+
🧰 Tools
🪛 GitHub Check: lint

[failure] 424-424:
Insert

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between af1a663 and e9f04f0.

📒 Files selected for processing (1)
  • src/components/Facility/ConsultationDetails/index.tsx (2 hunks)
🧰 Additional context used
🪛 GitHub Check: lint
src/components/Facility/ConsultationDetails/index.tsx

[failure] 424-424:
Insert

🔇 Additional comments (1)
src/components/Facility/ConsultationDetails/index.tsx (1)

217-220: LGTM! Verify the consultation update route.

The breadcrumb implementation looks correct and aligns with the PR objective to fix navigation issues.

Let's verify the consultation update route exists and handles updates correctly:

✅ Verification successful

Based on the search results, I can now generate the final response as we have found the route definition in src/Routers/routes/ConsultationRoutes.tsx:

The consultation update route exists and is properly configured

The breadcrumb URI /facility/${facilityId}/patient/${patientId}/consultation/${id}/update matches the defined route in src/Routers/routes/ConsultationRoutes.tsx:

"/facility/:facilityId/patient/:patientId/consultation/:id/update": ({
    facilityId,
    patientId,
    id,
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consultation update route exists in the router configuration
# Expected: Find route definition for consultation update

# Search for route definition
rg -A 3 "consultation/:consultationId/update"

Length of output: 45


Script:

#!/bin/bash
# Let's try different approaches to find the route definition

# 1. Search for consultation route patterns more broadly
rg -A 3 "consultation.*update"

# 2. Look for router configuration files
fd "router|routes" --type f

# 3. Search for consultation route components
rg -A 3 "path.*consultation"

Length of output: 47976

@bodhish bodhish added needs testing and removed question Further information is requested test failed needs-triage labels Nov 25, 2024
@nihal467
Copy link
Member

LGTM

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Nov 27, 2024
Copy link

👋 Hi, @shauryag2002,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@github-actions github-actions bot removed the merge conflict pull requests with merge conflict label Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Breadcrumbs redirection to patient edit consultation form is not working as expected
5 participants