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

Remove pin-code autofill feature #10291

Merged
merged 5 commits into from
Jan 31, 2025

Conversation

rithviknishad
Copy link
Member

@rithviknishad rithviknishad commented Jan 30, 2025

Proposed Changes

  • Remove pin-code autofill feature

@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

  • Removed Features

    • Eliminated pincode-based autofill functionality across multiple components.
    • Removed automatic state and district retrieval from pincode.
    • Removed demographic details such as nationality, state, and district from the patient details view.
  • Code Cleanup

    • Simplified component logic in Facility and Patient registration forms.
    • Removed unused utility functions and custom hooks related to pincode handling.
    • Streamlined user management logic by removing complex checks.
    • Updated patient data model across various components and utilities.
  • Impact

    • Users will no longer see automatic location suggestions based on pincode input.
    • Form interactions may require more manual input for location details.
    • Patient data representation has shifted to a new structure, affecting how patient information is displayed and processed.

@rithviknishad rithviknishad requested a review from a team as a code owner January 30, 2025 11:30
Copy link
Contributor

coderabbitai bot commented Jan 30, 2025

Walkthrough

This pull request involves the removal of pincode-related functionality across multiple files. The changes primarily eliminate the getPincodeDetails function, the useStateAndDistrictFromPincode hook, and associated state management logic in components like FacilityForm and PatientRegistration. New functionality has been introduced with the stringifyGeoOrganization function, which constructs a string representation of an organization's hierarchy. Overall, the modifications streamline the codebase by removing unused logic and updating data types related to patient management.

Changes

File Change Summary
src/Utils/utils.ts Removed getPincodeDetails function and toast import; added stringifyGeoOrganization function
src/components/Facility/FacilityForm.tsx Removed extractHierarchyLevels, useStateAndDistrictFromPincode hook, and related pincode autofill logic; simplified props destructuring
src/components/Patient/PatientRegistration.tsx Deleted showAutoFilledPincode state and related pincode autofill effects
src/hooks/useStateAndDistrictFromPincode.ts Completely removed custom hook for fetching state and district from pincode
src/Providers/PatientUserProvider.tsx Updated types from AppointmentPatient to Patient in context management
src/Utils/permissions.ts Removed checkIfStateOrDistrictAdminInSameLocation function; simplified editUserPermissions logic
src/Utils/request/api.tsx Updated API return types from AppointmentPatient to Patient
src/common/constants.tsx Removed HEADER_CONTENT_TYPES and ADMIN_USER_TYPES constants
src/components/Common/FacilitySelect.tsx Removed district and state props from BaseFacilitySelectProps interface
src/components/Patient/PatientDetailsTab/Demography.tsx Removed code related to displaying patient demographic details
src/components/Users/UserListAndCard.tsx Removed showDistrictColumn prop from UserListHeader component
src/components/Users/models.tsx Removed local_body, district, and state properties from UserModel and UserAssignedModel types
src/components/ui/sidebar/patient-nav.tsx Updated selectedUser type in generatePatientLinks function from AppointmentPatient to Patient
src/pages/Appointments/AppointmentDetail.tsx Updated patient address display to use stringifyGeoOrganization
src/pages/Encounters/EncounterShow.tsx Removed commented-out code for patient details and encounter data handling
src/pages/Facility/hooks/useFacilityFilters.ts Completely removed custom hook for managing facility filters
src/pages/Patient/Utils.tsx Removed AppointmentPatient type and its import
src/pages/PublicAppointments/PatientRegistration.tsx Updated patient type in createPatient mutation from AppointmentPatient to Patient
src/pages/PublicAppointments/PatientSelect.tsx Updated query and function parameter types from AppointmentPatient to Patient
src/types/emr/patient.ts Removed local_body, district, and state properties from PatientModel interface
src/types/scheduling/schedule.ts Updated patient type in Appointment interface from AppointmentPatient to Patient
cypress/e2e/facility_spec/facility_creation.cy.ts Updated LOCATION_HIERARCHY to include state and district properties
cypress/pageObject/facility/FacilityCreation.ts Modified fillLocationHierarchy method to accept new state and district parameters

Suggested Labels

tested

Poem

🐰 Farewell, Pincode Magic! 🌍
Bits of code now fade away,
Autofill dreams take flight today
No more toast, no more surprise
Simplicity now claims the prize!
Hop along, clean code's delight! 🚀


📜 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 2dd94c4 and fb76909.

📒 Files selected for processing (2)
  • cypress/e2e/facility_spec/facility_creation.cy.ts (1 hunks)
  • cypress/pageObject/facility/FacilityCreation.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: cypress-run (1)
  • GitHub Check: OSSAR-Scan
🔇 Additional comments (2)
cypress/e2e/facility_spec/facility_creation.cy.ts (1)

6-7: LGTM! The changes align with the updated method signature.

The addition of state and district properties to LOCATION_HIERARCHY correctly supports the expanded location hierarchy structure required by the updated fillLocationHierarchy method.

cypress/pageObject/facility/FacilityCreation.ts (1)

129-140: LGTM! The method signature and implementation are well-structured.

The changes correctly:

  • Update the method signature to include state and district
  • Use cy.typeAndSelectOption consistently for all location fields
  • Maintain chainability by returning this
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit fb76909
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/679c943f731ea30008568502
😎 Deploy Preview https://deploy-preview-10291--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

cloudflare-workers-and-pages bot commented Jan 30, 2025

Deploying care-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: fb76909
Status: ✅  Deploy successful!
Preview URL: https://8c4bb0d7.care-fe.pages.dev
Branch Preview URL: https://rithviknishad-fix-remove-pin.care-fe.pages.dev

View logs

Copy link

cypress bot commented Jan 30, 2025

CARE    Run #4531

Run Properties:  status check passed Passed #4531  •  git commit fb769098a3: Remove pin-code autofill feature
Project CARE
Branch Review rithviknishad/fix/remove-pincode-autofill
Run status status check passed Passed #4531
Run duration 06m 09s
Commit git commit fb769098a3: Remove pin-code autofill feature
Committer Rithvik Nishad
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 10
View all changes introduced in this branch ↗︎

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

🧹 Nitpick comments (2)
src/components/Facility/FacilityForm.tsx (2)

52-55: Clean up unused interface property.

The organizationId prop is defined in the FacilityProps interface but is not used in the component. Consider removing it to maintain a clean interface.

 interface FacilityProps {
-  organizationId?: string;
   facilityId?: string;
   onSubmitSuccess?: () => void;
 }

Line range hint 290-305: Consider adding pattern validation for pincode input.

While the maxLength validation is good, consider adding pattern validation to ensure only numeric input:

 <Input
   data-cy="facility-pincode"
   placeholder="Enter pincode"
   maxLength={6}
+  pattern="[0-9]*"
+  inputMode="numeric"
   {...field}
 />
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5edb84e and 46877a7.

📒 Files selected for processing (4)
  • src/Utils/utils.ts (0 hunks)
  • src/components/Facility/FacilityForm.tsx (1 hunks)
  • src/components/Patient/PatientRegistration.tsx (0 hunks)
  • src/hooks/useStateAndDistrictFromPincode.ts (0 hunks)
💤 Files with no reviewable changes (3)
  • src/Utils/utils.ts
  • src/hooks/useStateAndDistrictFromPincode.ts
  • src/components/Patient/PatientRegistration.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: cypress-run (1)
  • GitHub Check: Cloudflare Pages: care-fe
🔇 Additional comments (3)
src/components/Facility/FacilityForm.tsx (3)

Line range hint 60-75: LGTM! Pincode validation maintained.

The form schema correctly maintains pincode validation while removing the auto-population functionality, aligning with the PR objective.


Line range hint 130-138: LGTM! Clean submission logic.

The form submission logic is well-structured and properly handles both creation and updates.


Line range hint 1-450: Verify complete removal of autofill functionality.

Let's verify that all autofill-related code has been completely removed from the codebase.

✅ Verification successful

Autofill functionality has been successfully removed

The verification confirms that all pincode autofill functionality has been completely removed from the active codebase. The only remaining traces are inactive elements (commented code and translation strings) that don't affect the application's behavior.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to pincode autofill functionality
echo "Searching for potential remaining autofill references..."
rg -i "autofill|useStateAndDistrictFromPincode|getPincodeDetails" --type ts --type tsx

echo "Checking for any TODO comments related to pincode..."
rg -i "todo.*pincode|fixme.*pincode" --type ts --type tsx

Length of output: 442


Script:

#!/bin/bash
# Search without file type restrictions
echo "Searching for autofill related code..."
rg -i "autofill|useStateAndDistrictFromPincode|getPincodeDetails"

echo "Checking for pincode-related API endpoints..."
rg -i "pincode.*api|api.*pincode" 

echo "Checking for TODO comments..."
rg -i "todo.*pincode|fixme.*pincode"

# Check for any utility functions related to pincode
echo "Checking for pincode utility functions..."
ast-grep --pattern 'function $_(pincode$_) { $$$ }'

Length of output: 1494

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/pages/PublicAppointments/PatientSelect.tsx (1)

178-178: Update function name reference.

Update the function call to match the corrected name getPatientDoBorAge.

-                      {getPatienDoBorAge(patient)}
+                      {getPatientDoBorAge(patient)}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 46877a7 and 2dd94c4.

📒 Files selected for processing (18)
  • src/Providers/PatientUserProvider.tsx (3 hunks)
  • src/Utils/permissions.ts (1 hunks)
  • src/Utils/request/api.tsx (3 hunks)
  • src/Utils/utils.ts (2 hunks)
  • src/common/constants.tsx (0 hunks)
  • src/components/Common/FacilitySelect.tsx (1 hunks)
  • src/components/Patient/PatientDetailsTab/Demography.tsx (0 hunks)
  • src/components/Users/UserListAndCard.tsx (2 hunks)
  • src/components/Users/models.tsx (0 hunks)
  • src/components/ui/sidebar/patient-nav.tsx (2 hunks)
  • src/pages/Appointments/AppointmentDetail.tsx (3 hunks)
  • src/pages/Encounters/EncounterShow.tsx (0 hunks)
  • src/pages/Facility/hooks/useFacilityFilters.ts (0 hunks)
  • src/pages/Patient/Utils.tsx (0 hunks)
  • src/pages/PublicAppointments/PatientRegistration.tsx (2 hunks)
  • src/pages/PublicAppointments/PatientSelect.tsx (4 hunks)
  • src/types/emr/patient.ts (0 hunks)
  • src/types/scheduling/schedule.ts (2 hunks)
💤 Files with no reviewable changes (7)
  • src/types/emr/patient.ts
  • src/components/Users/models.tsx
  • src/components/Patient/PatientDetailsTab/Demography.tsx
  • src/pages/Facility/hooks/useFacilityFilters.ts
  • src/pages/Patient/Utils.tsx
  • src/pages/Encounters/EncounterShow.tsx
  • src/common/constants.tsx
🧰 Additional context used
📓 Learnings (1)
src/components/Users/UserListAndCard.tsx (1)
Learnt from: Jacobjeevan
PR: ohcnetwork/care_fe#9080
File: src/components/Users/UserListAndCard.tsx:306-312
Timestamp: 2024-11-22T10:44:19.282Z
Learning: The `getDistrict` function in `src/components/Users/UserListAndCard.tsx` returns a JSX element styled specifically for the card view and should not be reused in the list view.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)
🔇 Additional comments (14)
src/Utils/permissions.ts (1)

27-27: LGTM! Function logic simplified.

The simplified permission check aligns with the removal of location-based checks, making the code more maintainable.

src/components/Common/FacilitySelect.tsx (1)

101-101: LGTM! Simplified facility label display.

Removed district information from facility labels as part of removing location-based features.

src/pages/Appointments/AppointmentDetail.tsx (2)

57-57: LGTM! Added import for new utility function.

Added import for stringifyGeoOrganization to handle address formatting.


335-335: LGTM! Improved address formatting.

Replaced manual address concatenation with the stringifyGeoOrganization utility function, which provides a more maintainable way to display hierarchical location data.

src/Utils/utils.ts (1)

276-286: LGTM! Well-implemented utility function.

The stringifyGeoOrganization function:

  • Cleanly handles the organization hierarchy traversal
  • Safely handles undefined cases
  • Uses clear variable names
  • Provides a consistent format for location strings
src/components/ui/sidebar/patient-nav.tsx (1)

9-9: LGTM! Type migration looks good.

The change from AppointmentPatient to Patient type is consistent with the codebase-wide refactoring.

Also applies to: 18-18

src/types/scheduling/schedule.ts (1)

4-4: LGTM! Type updates are consistent.

The migration from AppointmentPatient to Patient type in the Appointment interface maintains consistency with the broader refactoring effort.

Also applies to: 143-143

src/components/Users/UserListAndCard.tsx (1)

Line range hint 131-194: LGTM! Component simplification improves maintainability.

The removal of the district column and related props aligns with the PR objective of removing location-related features. The component is now more focused and maintainable.

src/pages/PublicAppointments/PatientRegistration.tsx (2)

36-37: LGTM! Import changes align with the new patient type system.

The changes correctly update the imports to use the new Patient type while retaining the AppointmentPatientRegister type for registration.


175-175: LGTM! Type update in mutation callback.

The mutation callback correctly uses the new Patient type, maintaining consistency with the API response type.

src/Utils/request/api.tsx (1)

625-625: LGTM! API route return types updated consistently.

The return types for both getPatient and createPatient routes have been correctly updated to use the new Patient type, maintaining consistency across the API layer.

Also applies to: 636-636

src/Providers/PatientUserProvider.tsx (3)

10-10: LGTM! Context type definitions updated correctly.

The type definitions have been properly updated to use the new Patient type throughout the context interface.

Also applies to: 13-15


28-29: LGTM! State initialization aligned with new types.

The state hooks have been correctly updated to use the new Patient type for both the patients array and selected patient.


46-46: LGTM! Local storage handling updated.

The local storage parsing has been properly typed to use the new Patient type.

@nihal467
Copy link
Member

LGTM , verify at public page, facility, user and patient creation

@nihal467 nihal467 added tested reviewed reviewed by a core member and removed needs testing needs review labels Jan 31, 2025
@gigincg gigincg merged commit 71439ba into develop Jan 31, 2025
25 checks passed
@gigincg gigincg deleted the rithviknishad/fix/remove-pincode-autofill branch January 31, 2025 11:11
Copy link

@rithviknishad 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
Labels
reviewed reviewed by a core member tested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants