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 Age and Facility Location Edits #10260

Merged

Conversation

Jacobjeevan
Copy link
Contributor

@Jacobjeevan Jacobjeevan commented Jan 28, 2025

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

Summary by CodeRabbit

  • New Features

    • None
  • Bug Fixes

    • Improved age calculation logic across patient-related components.
    • Enhanced handling of latitude and longitude values in facility forms.
  • Refactor

    • Removed age property from patient model.
    • Modified patient age calculation to rely on birth year/date instead of pre-defined age.
    • Removed the option to edit patient details directly from the demographic information.
  • Documentation

    • None
  • Tests

    • None
  • Chores

    • None

@Jacobjeevan Jacobjeevan requested a review from a team as a code owner January 28, 2025 15:42
Copy link
Contributor

coderabbitai bot commented Jan 28, 2025

Walkthrough

This pull request introduces modifications to patient age calculation and facility form handling across multiple files. The changes focus on improving how patient ages are derived by removing the direct age property from the patient model and ensuring proper type conversion for latitude and longitude fields. The modifications aim to enhance data accuracy and consistency in patient registration and facility management components.

Changes

File Change Summary
src/Utils/utils.ts Removed immediate return of age in formatPatientAge function
src/components/Facility/FacilityForm.tsx Convert latitude and longitude to numbers using Number() when loading facility data
src/components/Patient/PatientRegistration.tsx Calculate age based on year_of_birth instead of using direct age field
src/types/emr/patient.ts Removed age property from PatientModel interface
src/components/Patient/PatientDetailsTab/Demography.tsx Removed button for updating patient details

Assessment against linked issues

Objective Addressed Explanation
Auto-fill DOB and age in patient edit form [#10257] The removal of the age property may prevent auto-filling of age in the edit form.
Manage Lat and Lon field state properly [#10256]

Possibly related issues

Possibly related PRs

Suggested labels

changes required

Suggested reviewers

  • rithviknishad
  • nihal467

Poem

🐰 A rabbit's tale of code so bright,
Where ages dance and forms take flight,
Latitude, longitude, precise and true,
Data transformed, a coder's breakthrough!
Precision hops, errors take flight! 🌟


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2ac3366 and 74d5441.

📒 Files selected for processing (1)
  • src/components/Patient/PatientDetailsTab/Demography.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • src/components/Patient/PatientDetailsTab/Demography.tsx
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Redirect rules - care-ohc
  • GitHub Check: Header rules - care-ohc
  • GitHub Check: Pages changed - care-ohc
  • GitHub Check: Test
  • GitHub Check: OSSAR-Scan
  • GitHub Check: CodeQL-Build
  • GitHub Check: cypress-run (1)

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 28, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 74d5441
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67990d16c740a40008009ab4
😎 Deploy Preview https://deploy-preview-10260--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

🧹 Nitpick comments (1)
src/components/Patient/PatientRegistration.tsx (1)

Line range hint 559-563: Update age input warning message.

Since the backend no longer returns age data, consider updating the warning message to emphasize the importance of accurate birth year input.

-    {t("age_input_warning")}
-    <br />
-    <b>{t("age_input_warning_bold")}</b>
+    {t("year_of_birth_warning")}
+    <br />
+    <b>{t("year_of_birth_warning_bold")}</b>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0c3342f and f0b2539.

📒 Files selected for processing (4)
  • src/Utils/utils.ts (0 hunks)
  • src/components/Facility/FacilityForm.tsx (1 hunks)
  • src/components/Patient/PatientRegistration.tsx (1 hunks)
  • src/types/emr/patient.ts (0 hunks)
💤 Files with no reviewable changes (2)
  • src/types/emr/patient.ts
  • src/Utils/utils.ts
✅ Files skipped from review due to trivial changes (1)
  • src/components/Facility/FacilityForm.tsx
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Label linked issues
  • GitHub Check: Redirect rules - care-ohc
  • GitHub Check: Header rules - care-ohc
  • GitHub Check: Pages changed - care-ohc
  • GitHub Check: Test
  • GitHub Check: OSSAR-Scan
  • GitHub Check: CodeQL-Build
  • GitHub Check: cypress-run (1)
🔇 Additional comments (3)
src/components/Patient/PatientRegistration.tsx (3)

Line range hint 1-694: Implementation aligns with PR objectives.

The changes successfully remove direct age usage and switch to year-based age calculation. The form handling and validation are robust, with good error handling and user feedback.


Line range hint 63-70: Review age validation constraints.

The age validation in the schema allows ages between 1-120 years. Ensure this aligns with the backend constraints since the PR mentions changes to age handling.

✅ Verification successful

Age validation constraints are correctly implemented

The age validation in the schema (1-120 years) is consistent with standard medical practice and is properly implemented across the codebase. The validation supports both age and date of birth input methods with appropriate constraints.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for age validation in backend code
rg -A 5 'age.*validation|year_of_birth.*validation'

Length of output: 1064


Script:

#!/bin/bash
# Search for zod schema definitions and age-related validations
ast-grep --pattern 'z.object({
  $$$
})'

# Backup search using ripgrep for age and year_of_birth fields
rg -A 10 'z\.number\(\).*age|z\.date\(\).*birth|schema.*age|schema.*birth'

Length of output: 26370


287-287: Verify age calculation edge cases.

The age calculation new Date().getFullYear() - patientQuery.data.year_of_birth! might be inaccurate for patients born late in the year. Consider using a more precise calculation that takes into account the month and day.

Consider using a utility function for consistent age calculation:

-? new Date().getFullYear() - patientQuery.data.year_of_birth!
+? calculateAge(patientQuery.data.year_of_birth!)

+// Add to utils.ts
+export function calculateAge(yearOfBirth: number) {
+  const today = new Date();
+  return today.getFullYear() - yearOfBirth;
+}

src/components/Patient/PatientRegistration.tsx Outdated Show resolved Hide resolved
@nihal467
Copy link
Member

nihal467 commented Jan 28, 2025

  • the age and dob user preference should be allowed, currently once a user add a dob, cant switch to age in patient details page
  • on edit facility page, we can't keep the facility latitude and longitude null

@nihal467
Copy link
Member

Conditionally Approving this temporary fix, as the mentioned issues need backend changes

@rithviknishad rithviknishad merged commit 25cdaf6 into ohcnetwork:develop Jan 29, 2025
19 checks passed
Copy link

@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! 🙌

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