care icon indicating copy to clipboard operation
care copied to clipboard

encounter and patient export and import options

Open praffq opened this issue 6 months ago • 2 comments

Proposed Changes

  • import and export capabilities for Encounter and Patient records within the admin interface, allowing easy data transfer through the admin panel.

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

  • New Features
    • Added import and export capabilities for Encounter and Patient records within the admin interface, allowing easy data transfer through the admin panel.
    • Enhanced admin interface for Encounter and Patient models with improved list displays and search options.
  • Chores
    • Introduced a new dependency to support data import/export features.
    • Updated application settings to enable the new import/export functionality.
  • Style
    • Improved display of Patient records by showing the patient's name in listings.

praffq avatar Jun 11 '25 07:06 praffq

[!IMPORTANT]

Review skipped

Review was skipped due to path filters

:no_entry: Files ignored due to path filters (1)
  • Pipfile.lock is excluded by !**/*.lock

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

Adds django-import-export to the project, integrates import/export admin resources for Encounter and Patient, exposes admin modules via package init, and adds a Patient.str method; Pipfile and settings updated accordingly.

Changes

Cohort / File(s) Summary
Dependencies
Pipfile
Added django-import-export==4.3.7; tightened pins for pydantic-extra-types==2.10.2 and evalidate==2.0.5.
Settings
config/settings/base.py
Added "import_export" to THIRD_PARTY_APPS.
Admin package init
care/emr/admin/__init__.py
Added wildcard imports to re-export encounter and patient admin modules.
Encounter admin
care/emr/admin/encounter.py
New EncounterResource (import-export resource with FK widgets) and EncounterAdmin (registered, list display, search).
Patient admin
care/emr/admin/patient.py
New PatientResource (import-export resource with FK widget for geo_organization) and PatientAdmin (registered).
Model repr
care/emr/models/patient.py
Added __str__ method returning the patient's name.

Sequence Diagram(s)

sequenceDiagram
    participant AdminUser
    participant DjangoAdmin
    participant ImportExportLib as ImportExport
    participant DB

    AdminUser->>DjangoAdmin: Open Patient/Encounter admin
    DjangoAdmin->>ImportExport: Initialize resource (PatientResource/EncounterResource)
    AdminUser->>DjangoAdmin: Trigger Import or Export
    DjangoAdmin->>ImportExport: Run import/export process
    ImportExport->>DB: Read/Write records (FK resolution via external_id)
    DB-->>ImportExport: Return data/status
    ImportExport-->>DjangoAdmin: Return result
    DjangoAdmin-->>AdminUser: Show outcome

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

In admin rooms where rows align,
Resources map each foreign sign.
Patients and encounters now stroll through the gate,
Pipfile pinned, settings updated — and yes, you're welcome, mate.

✨ Finishing Touches
🧪 Generate unit tests
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment
  • [ ] Commit unit tests in branch prafful/feat/import-export-patient

🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

coderabbitai[bot] avatar Jun 11 '25 07:06 coderabbitai[bot]

Codecov Report

Attention: Patch coverage is 97.56098% with 1 line in your changes missing coverage. Please review.

Project coverage is 51.40%. Comparing base (0bb8837) to head (9865369).

Files with missing lines Patch % Lines
care/emr/models/patient.py 50.00% 1 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3069      +/-   ##
===========================================
+ Coverage    51.23%   51.40%   +0.16%     
===========================================
  Files          251      254       +3     
  Lines        11387    11428      +41     
  Branches      1282     1282              
===========================================
+ Hits          5834     5874      +40     
- Misses        5532     5533       +1     
  Partials        21       21              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

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

codecov[bot] avatar Jun 11 '25 07:06 codecov[bot]