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

Patient Detail Tabs: Org List Access #10121

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Jacobjeevan
Copy link
Contributor

@Jacobjeevan Jacobjeevan commented Jan 23, 2025

Proposed Changes

  • Fixes Facility ID is undefined in Patient Details for Staff #10109
    • Use a sep list to render tabs for patient page when accessed directly (i.e. without related facility Id, from an org listing page, i.e.: url would be patient/id rather than facility/facilityId/patient/id).
    • Allowing patient detail edit on above access (i.e. edit button on patient details page used to be facility specific).
    • Hides appointments tab for direct patient listing (appointments are facility specific).
    • All the other tabs are not facility exclusive, so keeping them but let me know if I missed something.

@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

Release Notes

  • New Features

    • Added a new route for patient updates
    • Enhanced patient tab navigation with facility-specific routing
  • Improvements

    • Updated patient registration process to handle optional facility ID
    • Improved localization with new "No updates found" message
    • Refined patient home and details tab navigation logic
  • Bug Fixes

    • Resolved routing inconsistencies in patient-related components

Copy link
Contributor

coderabbitai bot commented Jan 23, 2025

Walkthrough

This pull request introduces changes across multiple files to enhance patient routing and tab management. The modifications include updating localization files, adjusting patient routes, and modifying components to support more flexible patient and facility-specific navigation. The changes primarily focus on improving the handling of patient-related routes and tabs, with a particular emphasis on conditionally managing routes based on facility context.

Changes

File Change Summary
public/locale/en.json Added new localization key "no_updates_found" with value "No updates found"
src/Routers/routes/PatientRoutes.tsx - Updated import to include facilityPatientTabs
- Added new route /patient/:id/update
- Modified route generation to use facilityPatientTabs
src/components/Patient/PatientDetailsTab/Demography.tsx Updated handleEditClick to conditionally navigate based on facilityId
src/components/Patient/PatientDetailsTab/index.tsx - Restructured patientTabs into commonTabs
- Introduced new facilityPatientTabs
- Redefined patientTabs using commonTabs
src/components/Patient/PatientHome.tsx - Updated imports and props to support facilityPatientTabs
- Conditionally select tabs based on facilityId
src/components/Patient/PatientRegistration.tsx - Made facilityId optional in props interface
- Added conditional check for facilityId in onSubmit

Sequence Diagram

sequenceDiagram
    participant User
    participant PatientRoutes
    participant PatientHome
    participant PatientRegistration

    User->>PatientRoutes: Navigate to patient page
    PatientRoutes->>PatientHome: Render with tabs
    alt Facility Context Exists
        PatientHome->>PatientHome: Use facilityPatientTabs
    else No Facility Context
        PatientHome->>PatientHome: Use patientTabs
    end
    User->>PatientHome: Select tab/action
    alt Edit Patient
        PatientHome->>PatientRegistration: Open registration with optional facilityId
    end
Loading

Possibly related PRs

Suggested labels

tested, changes required

Suggested reviewers

  • rithviknishad

Poem

🐰 A rabbit's tale of patient care,
Routes that dance with flair and flair!
Tabs that shift like morning dew,
Facility context, now shining through
Localization's gentle cheer! 🏥


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

Copy link

netlify bot commented Jan 23, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit d2b668d
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67922e2349d19c0008b1a87c
😎 Deploy Preview https://deploy-preview-10121--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 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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 074d97a and d2b668d.

📒 Files selected for processing (6)
  • public/locale/en.json (1 hunks)
  • src/Routers/routes/PatientRoutes.tsx (2 hunks)
  • src/components/Patient/PatientDetailsTab/Demography.tsx (1 hunks)
  • src/components/Patient/PatientDetailsTab/index.tsx (2 hunks)
  • src/components/Patient/PatientHome.tsx (5 hunks)
  • src/components/Patient/PatientRegistration.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)
🔇 Additional comments (15)
src/components/Patient/PatientDetailsTab/index.tsx (3)

Line range hint 19-49: LGTM! Well-structured common tabs configuration.

The separation of common tabs into a dedicated array improves code organization and maintainability.


59-59: LGTM! Clean separation of patient-only tabs.

The spread operator effectively creates a separate array for patient-only context.


50-58: Verify tab order in facilityPatientTabs.

The implementation correctly places the appointments tab after demography. However, let's verify this is the intended order for facility context.

✅ Verification successful

Tab order in facilityPatientTabs is logically structured

The current order (demography → appointments → encounters → health-profile) follows a natural progression from basic patient information to facility-specific interactions to clinical data. This structure aligns with good UX principles and maintains a logical flow of information.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if there are any UI tests or documentation specifying the expected tab order

rg -A 5 "tab.*order" --type=md
rg -A 5 "tab.*order" --type=test

Length of output: 96


Script:

#!/bin/bash
# Find commonTabs definition and related test/story files
echo "=== Searching for commonTabs definition ==="
rg -p "const commonTabs.*=" --type=typescript -A 10

echo -e "\n=== Looking for PatientDetailsTab related files ==="
fd -e tsx -e ts "PatientDetailsTab.*\.(test|spec|stories)\." 

echo -e "\n=== Searching for tab-related patterns in tsx files ==="
rg "tabs.*=.*\[" --type=typescript -A 5

Length of output: 571


Script:

#!/bin/bash
# Search with correct file extensions and broader patterns
echo "=== Searching for commonTabs definition ==="
rg -p "const commonTabs" -g "*.{ts,tsx}" -A 10

echo -e "\n=== Looking for tab configurations ==="
rg "tabs.*=.*\[" -g "*.{ts,tsx}" -A 5

echo -e "\n=== Looking for PatientDetailsTab files ==="
fd . -e ts -e tsx | rg -i "patientdetailstab"

Length of output: 2152

src/Routers/routes/PatientRoutes.tsx (4)

2-5: LGTM! Clean import organization.

The imports correctly include both tab configurations needed for routing.


25-25: LGTM! New route supports direct patient access.

The new update route correctly handles the patient-only context.


26-31: LGTM! Patient routes use appropriate tabs.

The route generation correctly uses patientTabs for direct patient access.


Line range hint 38-44: LGTM! Facility routes use facility-specific tabs.

The route generation correctly uses facilityPatientTabs for facility context.

src/components/Patient/PatientHome.tsx (5)

12-15: LGTM! Clean import organization.

The imports correctly include both tab configurations needed for rendering.


26-26: LGTM! Type safety for page prop.

The union type correctly supports routes from both tab configurations.


46-46: LGTM! Clean conditional tab selection.

The ternary operator effectively selects the appropriate tab set based on context.


59-67: LGTM! Appointment scheduling only in facility context.

The conditional rendering aligns with PR objectives by showing appointment scheduling only in facility context.


109-116: LGTM! Context-aware link generation.

The conditional href generation correctly handles both facility and direct patient contexts.

src/components/Patient/PatientDetailsTab/Demography.tsx (1)

40-46: LGTM! Context-aware navigation in edit handler.

The conditional navigation correctly handles both facility and direct patient contexts.

src/components/Patient/PatientRegistration.tsx (1)

63-63: LGTM! Interface change aligns with PR objectives.

Making facilityId optional allows the component to handle direct patient access routes without facility context.

public/locale/en.json (1)

1455-1455: LGTM! Translation key addition is clear and follows conventions.

The new translation key "no_updates_found" with its value is well-named and provides clear user feedback.

Comment on lines +227 to +233
if (facilityId) {
createPatient({
...values,
facility: facilityId,
ward_old: undefined,
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for missing facilityId case.

The code correctly checks for facilityId before creating a patient, but doesn't handle the case when facilityId is undefined. Consider adding error feedback for users.

 if (facilityId) {
   createPatient({
     ...values,
     facility: facilityId,
     ward_old: undefined,
   });
+} else {
+  toast.error(t("facility_required_for_patient_creation"));
 }

Committable suggestion skipped: line range outside the PR's diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Facility ID is undefined in Patient Details for Staff
1 participant