Skip to content

Commit

Permalink
fix(Inpatient Record): change Inpatient Record layout
Browse files Browse the repository at this point in the history
Discharge btn visible before Discharge Summary creation
generate_billables on Schedule for Discharging
  • Loading branch information
akashkrishna619 authored and Sajinsr committed Jun 14, 2024
1 parent b66c2e4 commit a6a1c49
Show file tree
Hide file tree
Showing 15 changed files with 332 additions and 386 deletions.
13 changes: 8 additions & 5 deletions healthcare/healthcare/custom_doctype/payment_entry.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import frappe


@frappe.whitelist()
def set_paid_amount_in_treatment_counselling(doc, method):
if doc.treatment_counselling and doc.paid_amount:
treatment_counselling_doc = frappe.get_doc("Treatment Counselling", doc.treatment_counselling)
treatment_counselling_doc.paid_amount = doc.paid_amount
treatment_counselling_doc.outstanding_amount = treatment_counselling_doc.amount - treatment_counselling_doc.paid_amount
treatment_counselling_doc.save()
if doc.treatment_counselling and doc.paid_amount:
treatment_counselling_doc = frappe.get_doc("Treatment Counselling", doc.treatment_counselling)
treatment_counselling_doc.paid_amount = doc.paid_amount
treatment_counselling_doc.outstanding_amount = (
treatment_counselling_doc.amount - treatment_counselling_doc.paid_amount
)
treatment_counselling_doc.save()
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
class DischargeSummary(Document):
@frappe.whitelist()
def get_encounter_details(self):
encounters = frappe.get_all("Patient Encounter", {"inpatient_record": self.inpatient_record}, ["name"], pluck="name")
encounters = frappe.get_all(
"Patient Encounter", {"inpatient_record": self.inpatient_record}, ["name"], pluck="name"
)
all_medication_requests = []
all_service_requests = []
for encounter in encounters:
medication_requests = []
service_requests = []
filters = {"patient": self.patient, "docstatus":1}
filters = {"patient": self.patient, "docstatus": 1}
if encounter:
filters["order_group"] = encounter
medication_requests = frappe.get_all("Medication Request", filters, ["*"])
Expand All @@ -27,7 +29,9 @@ def get_encounter_details(self):
if service_request.template_dt == "Lab Test Template":
lab_test = frappe.db.get_value("Lab Test", {"service_request": service_request.name}, "name")
if lab_test:
subject = frappe.db.get_value("Patient Medical Record", {"reference_name": lab_test}, "subject")
subject = frappe.db.get_value(
"Patient Medical Record", {"reference_name": lab_test}, "subject"
)
if subject:
service_request["lab_details"] = subject

Expand All @@ -37,13 +41,15 @@ def validate(self):
self.validate_encounter_impression()

def on_submit(self):
self.status = "Approved"
self.db_set("status", "Approved")

def on_cancel(self):
self.status = "Cancelled"
self.db_set("status", "Cancelled")

def validate_encounter_impression(self):
encounter = frappe.get_last_doc("Patient Encounter", filters={"inpatient_record": self.inpatient_record})
encounter = frappe.get_last_doc(
"Patient Encounter", filters={"inpatient_record": self.inpatient_record}
)
if encounter:
if encounter.diagnosis:
self.diagnosis = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@
"valid_days",
"inpatient_settings_section",
"allow_discharge_despite_unbilled_services",
"allow_discharge_despite_pending_healthcare_services",
"column_break_bkvx",
"automatically_generate_billable",
"do_not_bill_inpatient_encounters",
"orders_tab",
"default_intent",
"column_break_1oy0",
"default_priority",
"automatically_generate_billable",
"laboratory_tab",
"sb_lab_settings",
"create_lab_test_on_si_submit",
Expand Down Expand Up @@ -409,11 +411,21 @@
"fieldname": "automatically_generate_billable",
"fieldtype": "Check",
"label": "Automatically Generate Billable"
},
{
"default": "0",
"fieldname": "allow_discharge_despite_pending_healthcare_services",
"fieldtype": "Check",
"label": "Allow Discharge Despite Pending Healthcare Services"
},
{
"fieldname": "column_break_bkvx",
"fieldtype": "Column Break"
}
],
"issingle": 1,
"links": [],
"modified": "2023-11-06 14:20:22.424895",
"modified": "2024-04-30 14:09:19.163643",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Healthcare Settings",
Expand Down
47 changes: 30 additions & 17 deletions healthcare/healthcare/doctype/inpatient_record/inpatient_record.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,16 @@ frappe.ui.form.on('Inpatient Record', {
if (!frm.doc.__islocal) {
if (frm.doc.status == 'Admitted') {
frm.add_custom_button(__('Schedule Discharge'), function() {
schedule_discharge(frm);
frappe.run_serially([
()=>schedule_discharge(frm),
()=>generate_billables(frm),
]);
});
frm.add_custom_button(__("Normal"), function() {
transfer_patient_dialog(frm);
},__('Transfer'));
frm.add_custom_button(__("Generate Billables"), function() {
frappe.call({
doc: frm.doc,
method: 'add_service_unit_rent_to_billable_items',
callback: function() {
frm.refresh();
}
})
generate_billables(frm);
});
if (!frm.doc.inpatient_occupancies.some(
e => e.transferred_for_procedure == 1 && e.left != 1)) {
Expand All @@ -90,14 +87,20 @@ frappe.ui.form.on('Inpatient Record', {
}, "Create");
}
})
frappe.db.get_value('Discharge Summary', {'docstatus': 1, 'inpatient_record': frm.doc.name}, 'name')
.then(r => {
if (r.message.name) {
frm.add_custom_button(__('Discharge'), function() {
discharge_patient(frm);
} );
}
})
frm.add_custom_button(__('Discharge'), function() {
frappe.db.get_value('Discharge Summary', {'docstatus': 1, 'inpatient_record': frm.doc.name}, 'name')
.then(r => {
if (r.message.name) {
discharge_patient(frm);
} else {
frappe.msgprint({
title: __("Discharge Summary Required"),
message: __("Discharge Summary is Required to Discharge"),
indicator: 'red'
});
}
})
});
}

if (!["Discharge Scheduled", "Cancelled", "Discharged"].includes(frm.doc.status)) {
Expand Down Expand Up @@ -620,7 +623,7 @@ var create_treatment_counselling = function(frm, args) {
frappe.call({
method: "healthcare.healthcare.doctype.inpatient_record.inpatient_record.create_treatment_counselling",
args: {
args: args
ip_order: args
},
freeze: true,
freeze_message: __("Creating Treatment Counselling"),
Expand All @@ -631,3 +634,13 @@ var create_treatment_counselling = function(frm, args) {
},
});
}

var generate_billables = function(frm) {
frappe.call({
doc: frm.doc,
method: 'add_service_unit_rent_to_billable_items',
callback: function() {
frm.refresh();
}
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
"chief_complaint",
"column_break_29",
"diagnosis",
"consumables_section",
"items",
"prescriptions_tab",
"medication_section",
"drug_prescription",
"investigations_section",
Expand Down Expand Up @@ -318,7 +317,7 @@
{
"depends_on": "eval:(doc.status != \"Admission Scheduled\")",
"fieldname": "sb_inpatient_occupancy",
"fieldtype": "Section Break",
"fieldtype": "Tab Break",
"label": "Inpatient Occupancy"
},
{
Expand Down Expand Up @@ -390,7 +389,7 @@
"collapsible": 1,
"depends_on": "eval:(doc.status == \"Discharge Scheduled\" || doc.status == \"Discharged\")",
"fieldname": "sb_discharge_details",
"fieldtype": "Section Break",
"fieldtype": "Tab Break",
"label": "Discharge Details"
},
{
Expand Down Expand Up @@ -446,12 +445,6 @@
"label": "Admission Nursing Checklist Template",
"options": "Nursing Checklist Template"
},
{
"collapsible": 1,
"fieldname": "consumables_section",
"fieldtype": "Section Break",
"label": "Consumables"
},
{
"fieldname": "items",
"fieldtype": "Table",
Expand Down Expand Up @@ -534,7 +527,7 @@
"link_fieldname": "inpatient_record"
}
],
"modified": "2023-06-05 12:08:38.552699",
"modified": "2024-04-30 12:33:23.396599",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Inpatient Record",
Expand Down
Loading

0 comments on commit a6a1c49

Please sign in to comment.