Skip to content

fix(patient-appointment): missing Patient Encounter series when created from Patient Appointment#1050

Open
md-umair-21 wants to merge 1 commit into
earthians:developfrom
md-umair-21:series-encount
Open

fix(patient-appointment): missing Patient Encounter series when created from Patient Appointment#1050
md-umair-21 wants to merge 1 commit into
earthians:developfrom
md-umair-21:series-encount

Conversation

@md-umair-21

Copy link
Copy Markdown
Contributor

Issue:
When Patient Encounter was created from the Create Patient Encounter button on Patient Appointment, the form opened through open_mapped_doc. That path mapped field values from the appointment, but it skipped the normal new_doc default initialization, so naming_series stayed blank. A blank series can cause incorrect naming/sequence behavior when the encounter is saved. The normal or independent patient encounter were properly setting series field correctly, issue is with encounter created from appointment.

Before fix:
image

Fix:
Changed the Patient Encounter create action in Patient Appointment set frappe.route_options with the appointment-derived values and open the form with frappe.new_doc("Patient Encounter"). This keeps the encounter fields prefilled and allows Frappe to apply the default naming_series correctly.

After fix:
image

Note:-
Also required for version-16 branch, the above issue also exists there.

@coderabbitai

coderabbitai Bot commented Jun 24, 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: 08f9266e-9f57-40e6-a402-ecb84cfe25fc

📥 Commits

Reviewing files that changed from the base of the PR and between 2ca3a92 and c749de7.

📒 Files selected for processing (1)
  • healthcare/healthcare/doctype/patient_appointment/patient_appointment.js

Walkthrough

The Patient Encounter custom button handler in patient_appointment.js is changed to call a new local helper create_patient_encounter(frm) instead of frappe.model.open_mapped_doc(...). The new helper validates that frm.doc.patient is set (raising an error otherwise), populates frappe.route_options with appointment-related fields (patient, practitioner, department, sex, invoiced, company, appointment type, insurance details, inpatient record, and encounter date/time), and then opens a new Patient Encounter document via frappe.new_doc.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main fix: Patient Encounter series initialization when created from Patient Appointment.
Description check ✅ Passed The description accurately explains the bug, the fix, and the affected flow in Patient Appointment.
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.


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.

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.

1 participant