-
Notifications
You must be signed in to change notification settings - Fork 523
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
Populate encounter edit options based on questionnaire tags #9927
Populate encounter edit options based on questionnaire tags #9927
Conversation
Caution Review failedThe pull request is closed. WalkthroughThe pull request introduces a custom hook Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
Finishing Touches
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for care-ohc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/hooks/useQuestionnaireOptions.ts (1)
11-16
: Consider internationalizing the default option title.The default option's title "Update Encounter" should be internationalized to maintain consistency with the rest of the application's UI text, as mentioned in the PR checklist.
const DEFAULT_OPTIONS: EditQuestionnaireOption[] = [ { slug: "encounter", - title: "Update Encounter", + title: t("update_encounter"), }, ];src/components/Patient/PatientInfoCard.tsx (1)
33-33
: Consider extracting the questionnaire tag as a constant.The "encounter_actions" slug should be defined as a constant to avoid magic strings and make it easier to maintain.
+const ENCOUNTER_ACTIONS_TAG = "encounter_actions" as const; + export default function PatientInfoCard(props: PatientInfoCardProps) { // ... - const questionnaireOptions = useQuestionnaireOptions(["encounter_actions"]); + const questionnaireOptions = useQuestionnaireOptions([ENCOUNTER_ACTIONS_TAG]);Also applies to: 53-53
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/components/Patient/PatientInfoCard.tsx
(3 hunks)src/hooks/useQuestionnaireOptions.ts
(1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/hooks/useQuestionnaireOptions.ts
[error] 36-36: Avoid the use of spread (...
) syntax on accumulators.
Spread syntax should be avoided on accumulators (like those in .reduce
) because it causes a time complexity of O(n^2)
.
Consider methods such as .splice or .push instead.
(lint/performance/noAccumulatingSpread)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: cypress-run (1)
🔇 Additional comments (3)
src/hooks/useQuestionnaireOptions.ts (2)
1-9
: LGTM! Well-structured imports and interface definition.The imports are appropriate, and the interface is well-typed for the questionnaire options.
18-28
: LGTM! Well-implemented query configuration.The useQueries implementation is clean, type-safe, and follows react-query best practices.
src/components/Patient/PatientInfoCard.tsx (1)
Line range hint
318-329
: LGTM! Clean dropdown implementation with proper translations.The dropdown menu implementation correctly maps over the questionnaire options and uses proper translations and routing.
👋 Hi, @Jacobjeevan, This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there. |
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/components/Patient/PatientInfoCard.tsx (2)
54-54
: Consider documenting the "encounter_actions" slug.The hook usage is correct. However, it would be helpful to add a comment explaining what types of options are fetched using the "encounter_actions" slug, making it easier for other developers to understand the purpose and potentially add more slugs in the future.
+ // Fetch questionnaire options for encounter actions (e.g., forms, assessments) const questionnaireOptions = useQuestionnaireOptions(["encounter_actions"]);
Line range hint
319-328
: Consider adding error handling for empty or loading states.The dropdown menu implementation looks good. However, it might be worth handling cases where:
- The options are still loading
- The API request failed
- No options were returned
+ {questionnaireOptions.length === 0 ? ( + <DropdownMenuItem disabled> + {t("no_questionnaire_options_available")} + </DropdownMenuItem> + ) : ( questionnaireOptions.map((option) => ( <DropdownMenuItem key={option.slug} asChild> <Link href={`/facility/${encounter.facility.id}/patient/${patient.id}/encounter/${encounter.id}/questionnaire/${option.slug}`} className="cursor-pointer text-gray-800" > {t(option.title)} </Link> </DropdownMenuItem> )) + )}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/components/Patient/PatientInfoCard.tsx
(3 hunks)
🧰 Additional context used
📓 Learnings (1)
src/components/Patient/PatientInfoCard.tsx (1)
Learnt from: Jacobjeevan
PR: ohcnetwork/care_fe#9927
File: src/hooks/useQuestionnaireOptions.ts:30-42
Timestamp: 2025-01-13T12:24:08.854Z
Learning: The `useQuestionnaireOptions` hook in `src/hooks/useQuestionnaireOptions.ts` is specifically designed for populating dropdown options. Performance optimizations for array operations (like avoiding spread in reduce) are unnecessary as the data size will always be within a reasonable range for dropdown usage.
🔇 Additional comments (1)
src/components/Patient/PatientInfoCard.tsx (1)
33-34
: LGTM!The import statement follows the project's conventions and is correctly placed in the custom hooks section.
src/hooks/useQuestionnaireOptions.ts
Outdated
const queries = useQueries({ | ||
queries: slugs.map((slug) => ({ | ||
queryKey: ["questionnaire", slug] as const, | ||
queryFn: query(questionnaireApi.list, { | ||
queryParams: { | ||
tag_slug: slug, | ||
}, | ||
}), | ||
})), | ||
}); |
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.
batch_request was an option
@Jacobjeevan Your efforts have helped advance digital healthcare and TeleICU systems. 🚀 Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! 🙌 |
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit
New Features
Improvements
Removed Features