Skip to content

feat: Add ordered-by practitioner fields to Therapy Plan and populate them from Patient Encounter - #975

Merged
Sajinsr merged 3 commits into
earthians:developfrom
md-umair-21:therapy-plan
May 11, 2026
Merged

feat: Add ordered-by practitioner fields to Therapy Plan and populate them from Patient Encounter#975
Sajinsr merged 3 commits into
earthians:developfrom
md-umair-21:therapy-plan

Conversation

@md-umair-21

@md-umair-21 md-umair-21 commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

This PR adds ordering practitioner details to Therapy Plan and ensures they are populated when a Therapy Plan is created from a Patient Encounter.

Changes:-
Added two new fields to Therapy Plan:
1)Ordered By Practitioner (practitioner)
2)Ordered By Practitioner Name (practitioner_name)

Updated create_therapy_plan in patient_encounter.py (line 409)
Populated the above fields as :
doc.practitioner = encounter.practitioner
doc.practitioner_name = encounter.practitioner_name

Also updated test_therapy_plan.py to populate practitioner fields in test plan.

Why:-
Therapy Plans should capture who ordered the plan for better traceability and consistency with other healthcare documents.
Without this change, the newly added Therapy Plan fields remained empty when the plan was created from a Patient Encounter.

Impact:-
New Therapy Plans created from Patient Encounters will automatically store the ordering practitioner and practitioner name.
Existing Therapy Plans are not affected.

image

Closes Issue #587
no-docs

@coderabbitai

coderabbitai Bot commented Apr 25, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 58d0b6f3-afbf-4a00-ae73-f6057e5ddcb5

📥 Commits

Reviewing files that changed from the base of the PR and between ed4c7da and c118afd.

📒 Files selected for processing (3)
  • healthcare/healthcare/doctype/patient_encounter/patient_encounter.py
  • healthcare/healthcare/doctype/therapy_plan/test_therapy_plan.py
  • healthcare/healthcare/doctype/therapy_plan/therapy_plan.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • healthcare/healthcare/doctype/patient_encounter/patient_encounter.py
  • healthcare/healthcare/doctype/therapy_plan/therapy_plan.json

Walkthrough

Added practitioner fields to the Therapy Plan DocType and updated Patient Encounter creation logic to populate them. The Therapy Plan JSON now includes a column_break_vlgf, a required practitioner Link to Healthcare Practitioner (in list view and standard filter, set once, indexed), and a read-only practitioner_name fetched from the linked practitioner. The create_therapy_plan code in Patient Encounter now sets doc.practitioner and doc.practitioner_name when creating a Therapy Plan.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main change: adding practitioner fields to Therapy Plan and populating them from Patient Encounter.
Description check ✅ Passed The description is well-related to the changeset, explaining the purpose, changes made, rationale, and impact of adding practitioner fields to Therapy Plan.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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)
healthcare/healthcare/doctype/patient_encounter/patient_encounter.py (1)

417-418: Setting practitioner_name is redundant — fetch_from will populate it on save.

The new practitioner_name field in therapy_plan.json declares "fetch_from": "practitioner.practitioner_name", so Frappe auto-populates it from the Healthcare Practitioner record on save. Copying it from the encounter here is unnecessary and could even diverge from the source of truth if the practitioner's name has been updated since the encounter was created. Consider only setting practitioner and letting the fetch_from handle the name.

♻️ Proposed simplification
 		doc.practitioner = encounter.practitioner
-		doc.practitioner_name = encounter.practitioner_name
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@healthcare/healthcare/doctype/patient_encounter/patient_encounter.py` around
lines 417 - 418, Remove the redundant manual assignment of practitioner_name on
the Therapy Plan document: keep setting doc.practitioner =
encounter.practitioner but delete the doc.practitioner_name =
encounter.practitioner_name line so the field configured with "fetch_from":
"practitioner.practitioner_name" in therapy_plan.json can auto-populate the name
on save; update any related comments to reflect that practitioner_name is
derived via fetch_from.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@healthcare/healthcare/doctype/therapy_plan/therapy_plan.json`:
- Around line 158-168: The tests fail because the Therapy Plan field
"practitioner" is now required; update the test helper function
create_therapy_plan() to populate the practitioner (and practitioner_name)
fields when constructing the Therapy Plan so .save() passes validation;
specifically modify create_therapy_plan() used by test_status() and
test_therapy_plan_from_template() to set practitioner to an existing Healthcare
Practitioner (or create a test practitioner fixture) and set practitioner_name
accordingly; also ensure any other test helpers creating Therapy Plan instances
follow the same change to avoid save-time validation errors.

---

Nitpick comments:
In `@healthcare/healthcare/doctype/patient_encounter/patient_encounter.py`:
- Around line 417-418: Remove the redundant manual assignment of
practitioner_name on the Therapy Plan document: keep setting doc.practitioner =
encounter.practitioner but delete the doc.practitioner_name =
encounter.practitioner_name line so the field configured with "fetch_from":
"practitioner.practitioner_name" in therapy_plan.json can auto-populate the name
on save; update any related comments to reflect that practitioner_name is
derived via fetch_from.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6749aa18-4801-421e-a930-838bb4b191e5

📥 Commits

Reviewing files that changed from the base of the PR and between f868b85 and ed4c7da.

📒 Files selected for processing (2)
  • healthcare/healthcare/doctype/patient_encounter/patient_encounter.py
  • healthcare/healthcare/doctype/therapy_plan/therapy_plan.json

Comment thread healthcare/healthcare/doctype/therapy_plan/therapy_plan.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants