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

Data Migration #2763

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

Data Migration #2763

wants to merge 101 commits into from

Conversation

sainak
Copy link
Member

@sainak sainak commented Jan 21, 2025

Proposed Changes

  • Lost of data migration logic
  • More than 6k lines of code written with copilot and rewritten without it

Merge Checklist

  • Tests added/fixed
  • Update docs in /docs
  • Linting Complete
  • Any other necessary step

Only PR's with test cases included and passing lint and test pipelines will be reviewed

@ohcnetwork/care-backend-maintainers @ohcnetwork/care-backend-admins

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced data migration across core modules—including patient records, consultations, consents, prescriptions, daily rounds, and facility/asset management—improving data integrity and system reliability.
    • Expanded role-based access with new read-only roles for nurses, staff, and administrators.
    • Introduced a new configuration option to determine if the application is in a testing state.
    • Added support for tracking data migrations with a new MigrationTracking model.
    • Added new fields for migrated identifiers in various models, enhancing data tracking capabilities.
  • Chores

    • Updated backend schemas and migration tracking processes, alongside utility improvements, to streamline operations and support future enhancements.

Copy link
Contributor

coderabbitai bot commented Jan 21, 2025

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.
📝 Walkthrough

Walkthrough

This pull request broadens the ignore pattern in the .gitignore file and introduces a skip directive in one EMR models file. Multiple migration scripts have been added or enhanced to handle data transformations and reverse operations for organizations, users, facilities, patient registrations and consultations, notes, prescriptions, symptoms, diagnoses, file uploads, daily rounds, assets, and consent records. Core models have been updated with new fields to track migrated EMR identifiers, and a new migration tracking model has been added. Additional utilities, role definitions, and testing configuration variables are also introduced. Quite the busy little update, isn’t it?

Changes

File(s) Change Summary
.gitignore Updated ignore pattern for care_db.dump from a fixed filename to a wildcard pattern (care_db.dump*).
care/emr/models/__init__.py Added # isort: skip_file directive at the top to bypass import sorting.
care/facility/migrations/0477_*.py
.../0491_migrate_consent_records.py
Multiple migration scripts updated/created to migrate organizations, users, facilities, patient registrations, consultations, notes, prescriptions, symptoms, diagnoses, file uploads, daily rounds, assets, and consent records, including new functions, reverse functions, and a new migration tracking model.
care/facility/models/{__init__.py, asset.py, bed.py, migration_tracking.py, patient.py, patient_consultation.py} New fields for migrated EMR identifiers added in PatientRegistration, PatientNotes, Asset, Bed, AssetLocation, and PatientConsultation; added new model MigrationTracking and updated import and permission logic.
care/facility/utils.py Introduced new utility functions enable_auto_time and disable_auto_time for managing automatic timestamping on models.
care/security/roles/role.py Added new read-only roles (NURSE_READONLY_ROLE, STAFF_READONLY_ROLE, GEO_ADMIN_READONLY_ROLE) and updated role mapping logic for legacy roles.
config/settings/{base.py, test.py} Added a new TESTING configuration variable (set to False in base and True in test settings).

Sequence Diagram(s)

sequenceDiagram
    participant M as Migration Script
    participant Q as Query/Pagination
    participant T as Transformation Logic
    participant DB as Database
    M->>Q: Fetch batch of records to migrate
    Q-->>M: Return records
    M->>T: Transform data for new schema
    T-->>M: Return transformed records
    M->>DB: Bulk insert/update transformed data
    DB-->>M: Confirm write
    M->>M: Log migration completion
Loading

Suggested Reviewers

  • vigneshhari

Poem

In the maze of migrations our code took flight,
With fields and functions emerging in the night.
From rigid names to patterns set free,
Data sings its new migration melody.
A subtle nod (and a wink) to bugs left behind—
Cheers to changes, reformed and refined!

(May our migrations be as smooth as they are unavoidable.)


🪧 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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

codecov bot commented Jan 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 52.24%. Comparing base (f487f45) to head (c7958b2).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2763      +/-   ##
===========================================
+ Coverage    52.07%   52.24%   +0.16%     
===========================================
  Files          240      240              
  Lines        10819    10824       +5     
  Branches      1184     1184              
===========================================
+ Hits          5634     5655      +21     
+ Misses        5166     5147      -19     
- Partials        19       22       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sainak
Copy link
Member Author

sainak commented Mar 12, 2025

@coderabbitai pause

Copy link
Contributor

coderabbitai bot commented Mar 12, 2025

✅ Actions performed

Reviews paused.

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

Successfully merging this pull request may close these issues.

5 participants