Skip to content

added discharge summary advice field to encounter #2971

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

Merged

Conversation

praffq
Copy link
Contributor

@praffq praffq commented Apr 3, 2025

Proposed Changes

Architecture changes

  • Remove this section if not used

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
    • Encounter records now include an optional field for entering discharge summary advice, offering enhanced flexibility to record additional guidance during patient care.
    • The patient discharge summary PDF template now conditionally displays discharge summary advice when available, enhancing the information provided to patients.

@praffq praffq requested a review from a team as a code owner April 3, 2025 16:51
Copy link
Contributor

coderabbitai bot commented Apr 3, 2025

📝 Walkthrough

Walkthrough

This update introduces a new field, discharge_summary_advice, into the Django application's encounter-related components. The field is added as a TextField in the encounter model with allowances for null and blank values. A corresponding migration file ensures proper schema update order. Additionally, the API specification for encounters is updated to include the new attribute. No changes to the control flow or existing business logic have been made, because why complicate things, right?

Changes

File(s) Change Summary
care/emr/migrations/...0029_encounter_discharge_summary_advice.py,
care/emr/models/encounter.py
Added new discharge_summary_advice field to the Encounter model as a TextField allowing null and blank values.
care/emr/resources/encounter/spec.py Updated EncounterSpecBase to include the new attribute `discharge_summary_advice: str
care/emr/reports/discharge_summary.py Modified get_discharge_summary_data function to include "discharge_summary_advice": encounter.discharge_summary_advice.
care/templates/reports/patient_discharge_summary_pdf_template.typ Adjusted PDF template to conditionally display discharge summary advice with a new section.

Suggested reviewers

  • vigneshhari

Poem

A new field steps onto the stage,
"Discharge_summary_advice" takes its rightful page.
Migration and model now share the load,
A tiny update lightening our code.
Cheers to progress—it's not rocket science, just a nudge!
🚀😏


📜 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 28d711b and 4bf62fe.

📒 Files selected for processing (2)
  • care/emr/reports/discharge_summary.py (1 hunks)
  • care/templates/reports/patient_discharge_summary_pdf_template.typ (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test / Test
  • GitHub Check: Analyze (python)
🔇 Additional comments (2)
care/emr/reports/discharge_summary.py (1)

144-144: Oh look, a new field added to the dictionary. How nice.

The addition of discharge_summary_advice to the dictionary returned by get_discharge_summary_data is straightforward and correctly implements the requested feature. It simply passes through the value from the encounter object to the template context.

care/templates/reports/patient_discharge_summary_pdf_template.typ (1)

218-226: Finally adding the display for that advice field we've apparently been "needing".

The implementation correctly adds a conditional section to display the discharge summary advice only when it's available. The formatting with a header and code block is appropriate, and the spacing with line breaks and a horizontal line maintains the document's visual hierarchy.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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
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 (3)
care/emr/migrations/0029_encounter_discharge_summary_advice.py (2)

9-9: Quote style inconsistency

I see you're using single quotes here while the project might prefer double quotes. I guess static analysis tools also flagged this. It's not a big deal, but it would be nice if you could be consistent with the project's style guide.

-        ('emr', '0028_alter_encounter_care_team'),
+        ("emr", "0028_alter_encounter_care_team"),
🧰 Tools
🪛 Ruff (0.8.2)

9-9: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


9-9: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


14-16: Migration looks good but has quote inconsistencies

The migration properly adds the new field. Again, there's that tiny issue with single vs double quotes that static analysis caught.

-            model_name='encounter',
-            name='discharge_summary_advice',
+            model_name="encounter",
+            name="discharge_summary_advice",
🧰 Tools
🪛 Ruff (0.8.2)

14-14: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


15-15: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)

care/emr/models/encounter.py (1)

31-31: New field implementation looks good

The addition of the discharge_summary_advice field to the Encounter model is correctly implemented as a TextField with null and blank attributes set to True. It would be slightly more helpful if you added a comment explaining what this field is used for, especially since it's related to clinical discharge information.

-    discharge_summary_advice = models.TextField(null=True, blank=True)
+    # Field to store advice given to patient upon discharge
+    discharge_summary_advice = models.TextField(null=True, blank=True)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 08ccd63 and 28d711b.

📒 Files selected for processing (3)
  • care/emr/migrations/0029_encounter_discharge_summary_advice.py (1 hunks)
  • care/emr/models/encounter.py (1 hunks)
  • care/emr/resources/encounter/spec.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
care/emr/migrations/0029_encounter_discharge_summary_advice.py

9-9: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


9-9: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


14-14: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


15-15: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test / Test
  • GitHub Check: Analyze (python)
🔇 Additional comments (1)
care/emr/resources/encounter/spec.py (1)

65-65: Field looks good, but a comment would be helpful

The addition of the discharge_summary_advice field to the EncounterSpecBase class is appropriate. It might be just a tiny bit more helpful if you added a comment explaining the purpose and usage of this field for future developers.

@vigneshhari
Copy link
Member

Need this in the discharge summary

Copy link

codecov bot commented Apr 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 51.89%. Comparing base (d7a886a) to head (4bf62fe).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #2971   +/-   ##
========================================
  Coverage    51.88%   51.89%           
========================================
  Files          243      243           
  Lines        10949    10951    +2     
  Branches      1206     1206           
========================================
+ Hits          5681     5683    +2     
  Misses        5249     5249           
  Partials        19       19           

☔ 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.

@vigneshhari vigneshhari merged commit 25e754b into develop Apr 7, 2025
8 checks passed
@vigneshhari vigneshhari deleted the prafful/feat/adding-treatment-summary-advice-field branch April 7, 2025 11:21
vigneshhari added a commit that referenced this pull request Apr 16, 2025
* Fix permission issue with chronic condition

* Multiple clinical condition filters

* Clean up codebase

* Clean up codebase

* Allow booking appointment for ongoing slot (#2934)

Allow booking for ongoing slot

* Fix edge case with organization structuring

* Move death_datetime to deceased_datetime

* added update specs for patient (#2947)

* Add missing device permissions

* Allow hard deleting users that have not logged in

* Show only non-deleted users

* Show deleted flag in spec

* Commented some tests after validation error change

* Add name-based filtration in files (#2958)

* Update Redis URL to use CERT_NONE for SSL certificate requirements (#2964)

* Retrieve External Id in QuestionnaireTag (#2954)

added externalId in tag

* updated specs for desc (#2957)

* Sort the Resources by created date (#2960)

order_resources_by_created_date

* Task to cleanup expired `TokenSlot` objects and Skip creating slots in the past (#2955)

* added validations and tests for enable when in questionnaire (#2941)

* added validations and tests

* update to remove values instead of raising errors

* making tags in questionnaire optional

* Auto-set Sort index ohcnetwork/roadmap#64

* added treating doctors and validation for consent (#2956)

* Rename treating doctors to care_team, fix tests, optimisations

* Add roles to care team.

* fixed the custom class validator (#2968)

* Fix issues with Valueset validation

* Deny same user repeating in the same care team.

* Deny same user repeating in the same care team.

* Username validation added

* update treatment summary for care team (#2970)

* Exclude deleted users in token booking's available users API (#2969)

* Fix issue with redis

* Adds support for searching users in `FacilityUsersViewSet` (#2974)

* Allow to update geo org for the user (#2975)

* List the drawing files based on the modified_date (#2972)

* Update facility org cache in add/remove managing org (#2979)

* added discharge summary advice field to encounter (#2971)

* added discharge summary advice field to encounter

* adding discharge summary advice to discharge summary pdf

* used max instead of count to generate sort index (#2981)

* Add timezone awareness validation for start and end dates in PeriodSpec (#2980)

* Fix typo in class name (#2977)

* Fix test cases for period spec (#2982)

* fixed recent views duplications (#2984)

* fixed recent views duplications

* update from comments

* fixed tests and enable when nested cases (#2967)

* fixed encounter update for not updating discharge summary advice with null (#2988)

* Fix cache key formatting in ResourceManager (#2989)

fix: correct cache key formatting in ResourceManager

* Fix test workflow for accurate failure reporting and Docker image loading (#2996)

* Fix the test workflow to show the correct failed step and load the docker image during build

* operators

* Fix role and role-permission deletion logic (#2995)

* Fix role and role-permission deletion logic to avoid deleting non system roles

* fix

* Prevent duplicate users in scheduling's available users API (#2985)

* Perform distinct on `user_id` for available users query

* simplify available_users query by reducing unnecessary joins

---------

Co-authored-by: Rithvik Nishad <[email protected]>
Co-authored-by: Prafful Sharma <[email protected]>
Co-authored-by: Nikhila C <[email protected]>
Co-authored-by: Areeb Ahmed <[email protected]>
Co-authored-by: Jacob John Jeevan <[email protected]>
Co-authored-by: Aditya Jindal <[email protected]>
Co-authored-by: Aakash Singh <[email protected]>
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.

Backend to store Discharge Summary Advice
2 participants