feat: set title for appointment, encounter, procedure and vitals

This commit is contained in:
anoop 2020-04-27 23:42:22 +05:30
parent ca6f3ec977
commit 0f541cb7ab
9 changed files with 113 additions and 34 deletions

View File

@ -8,6 +8,7 @@
"engine": "InnoDB",
"field_order": [
"naming_series",
"title",
"appointment",
"procedure_template",
"column_break_30",
@ -279,11 +280,21 @@
{
"fieldname": "column_break_34",
"fieldtype": "Column Break"
},
{
"allow_on_submit": 1,
"fieldname": "title",
"fieldtype": "Data",
"hidden": 1,
"label": "Title",
"no_copy": 1,
"print_hide": 1,
"read_only": 1
}
],
"is_submittable": 1,
"links": [],
"modified": "2020-04-24 22:53:13.156901",
"modified": "2020-04-27 21:36:23.796924",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Clinical Procedure",
@ -320,6 +331,6 @@
"restrict_to_domain": "Healthcare",
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "patient_name",
"title_field": "title",
"track_changes": 1
}

View File

@ -16,6 +16,7 @@ from frappe.model.mapper import get_mapped_doc
class ClinicalProcedure(Document):
def validate(self):
self.set_status()
self.set_title()
if self.consume_stock:
self.set_actual_qty()
@ -50,6 +51,9 @@ class ClinicalProcedure(Document):
elif self.docstatus == 2:
self.status = 'Cancelled'
def set_title(self):
self.title = _('{0} - {1}').format(self.patient_name or self.patient, self.procedure_template)[:100]
def complete_procedure(self):
if self.consume_stock and self.items:
stock_entry = make_stock_entry(self)

View File

@ -10,6 +10,7 @@
"engine": "InnoDB",
"field_order": [
"naming_series",
"title",
"status",
"patient",
"patient_name",
@ -26,6 +27,7 @@
"get_prescribed_therapies",
"therapy_plan",
"practitioner",
"practitioner_name",
"department",
"section_break_12",
"appointment_type",
@ -327,10 +329,26 @@
{
"fieldname": "column_break_36",
"fieldtype": "Column Break"
},
{
"fieldname": "title",
"fieldtype": "Data",
"hidden": 1,
"label": "Title",
"no_copy": 1,
"print_hide": 1,
"read_only": 1
},
{
"fetch_from": "practitioner.practitioner_name",
"fieldname": "practitioner_name",
"fieldtype": "Data",
"label": "Practitioner Name",
"read_only": 1
}
],
"links": [],
"modified": "2020-04-25 17:23:49.841975",
"modified": "2020-04-27 21:36:06.404062",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Patient Appointment",
@ -378,7 +396,7 @@
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "patient",
"title_field": "title",
"track_changes": 1,
"track_seen": 1
}

View File

@ -21,6 +21,7 @@ class PatientAppointment(Document):
self.set_appointment_datetime()
self.validate_customer_created()
self.set_status()
self.set_title()
def after_insert(self):
self.update_prescription_details()
@ -28,6 +29,11 @@ class PatientAppointment(Document):
self.update_fee_validity()
send_confirmation_msg(self)
def set_title(self):
self.title = _('{0} with {1} on {2}').format(self.patient_name or self.patient,
self.practitioner_name or self.practitioner,
frappe.utils.format_datetime(self.appointment_datetime))[:100]
def set_status(self):
today = getdate()
appointment_date = getdate(self.appointment_date)

View File

@ -157,24 +157,25 @@ frappe.ui.form.on('Patient Encounter', {
if (data.message.dob) {
age = calculate_age(data.message.dob);
}
frappe.model.set_value(frm.doctype, frm.docname, 'patient_mame', data.message.patient_mame);
frappe.model.set_value(frm.doctype, frm.docname, 'patient_age', age);
frappe.model.set_value(frm.doctype, frm.docname, 'patient_sex', data.message.sex);
if (data.message.inpatient_record) {
frappe.model.set_value(frm.doctype, frm.docname, 'inpatient_record', data.message.inpatient_record);
frappe.model.set_value(frm.doctype, frm.docname, 'inpatient_status', data.message.inpatient_status);
} else {
frappe.model.set_value(frm.doctype, frm.docname, 'inpatient_record', '');
frappe.model.set_value(frm.doctype, frm.docname, 'inpatient_status', '');
}
let values = {
'patient_age': age,
'patient_name':data.message.patient_name,
'patient_sex': data.message.sex,
'inpatient_record': data.message.inpatient_record,
'inpatient_status': data.message.inpatient_status
};
frm.set_value(values);
}
});
} else {
frappe.model.set_value(frm.doctype, frm.docname, 'patient_mame', '');
frappe.model.set_value(frm.doctype, frm.docname, 'patient_sex', '');
frappe.model.set_value(frm.doctype, frm.docname, 'patient_age', '');
frappe.model.set_value(frm.doctype, frm.docname, 'inpatient_record', '');
frappe.model.set_value(frm.doctype, frm.docname, 'inpatient_status', '');
let values = {
'patient_age': '',
'patient_name':'',
'patient_sex': '',
'inpatient_record': '',
'inpatient_status': ''
};
frm.set_value(values);
}
}
});
@ -226,7 +227,6 @@ let create_vital_signs = function (frm) {
}
frappe.route_options = {
'patient': frm.doc.patient,
'appointment': frm.doc.appointment,
'encounter': frm.doc.name,
'company': frm.doc.company
};

View File

@ -11,6 +11,7 @@
"engine": "InnoDB",
"field_order": [
"naming_series",
"title",
"appointment",
"appointment_type",
"patient",
@ -311,11 +312,21 @@
"in_list_view": 1,
"label": "Practitioner Name",
"read_only": 1
},
{
"allow_on_submit": 1,
"fieldname": "title",
"fieldtype": "Data",
"hidden": 1,
"label": "Title",
"no_copy": 1,
"print_hide": 1,
"read_only": 1
}
],
"is_submittable": 1,
"links": [],
"modified": "2020-04-27 18:59:25.713887",
"modified": "2020-04-27 21:58:29.789797",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Patient Encounter",
@ -342,7 +353,7 @@
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "patient_name",
"title_field": "title",
"track_changes": 1,
"track_seen": 1
}

View File

@ -10,6 +10,9 @@ from frappe.utils import cstr
from frappe import _
class PatientEncounter(Document):
def validate(self):
self.set_title()
def on_update(self):
if self.appointment:
frappe.db.set_value('Patient Appointment', self.appointment, 'status', 'Closed')
@ -26,6 +29,10 @@ class PatientEncounter(Document):
def on_submit(self):
create_therapy_plan(self)
def set_title(self):
self.title = _('{0} with {1}').format(self.patient_name or self.patient,
self.practitioner_name or self.practitioner)[:100]
def create_therapy_plan(encounter):
if len(encounter.therapies):
doc = frappe.new_doc('Therapy Plan')

View File

@ -2,15 +2,22 @@
"actions": [],
"allow_copy": 1,
"allow_import": 1,
"autoname": "naming_series:",
"beta": 1,
"creation": "2017-02-02 11:00:24.853005",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"naming_series",
"title",
"patient",
"patient_name",
"inpatient_record",
"appointment",
"encounter",
"column_break_2",
"company",
"signs_date",
"signs_time",
"sb_vs",
@ -32,11 +39,6 @@
"column_break_14",
"nutrition_note",
"sb_references",
"inpatient_record",
"appointment",
"encounter",
"column_break_28",
"company",
"amended_from"
],
"fields": [
@ -70,7 +72,8 @@
"fieldname": "appointment",
"fieldtype": "Link",
"in_filter": 1,
"label": "Appointment",
"label": "Patient Appointment",
"no_copy": 1,
"options": "Patient Appointment",
"print_hide": 1,
"read_only": 1
@ -83,8 +86,7 @@
"no_copy": 1,
"options": "Patient Encounter",
"print_hide": 1,
"read_only": 1,
"report_hide": 1
"read_only": 1
},
{
"fieldname": "column_break_2",
@ -237,13 +239,26 @@
"fieldtype": "Section Break"
},
{
"fieldname": "column_break_28",
"fieldtype": "Column Break"
"fieldname": "naming_series",
"fieldtype": "Select",
"label": "Series",
"options": "HLC-VTS-.YYYY.-",
"reqd": 1
},
{
"allow_on_submit": 1,
"fieldname": "title",
"fieldtype": "Data",
"hidden": 1,
"label": "Title",
"no_copy": 1,
"print_hide": 1,
"read_only": 1
}
],
"is_submittable": 1,
"links": [],
"modified": "2020-04-03 23:06:29.786184",
"modified": "2020-04-27 23:18:08.278064",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Vital Signs",
@ -283,7 +298,7 @@
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "patient",
"title_field": "title",
"track_changes": 1,
"track_seen": 1
}

View File

@ -9,12 +9,19 @@ from frappe.utils import cstr
from frappe import _
class VitalSigns(Document):
def validate(self):
self.set_title()
def on_submit(self):
insert_vital_signs_to_medical_record(self)
def on_cancel(self):
delete_vital_signs_from_medical_record(self)
def set_title(self):
self.title = _('{0} on {1} {2}').format(self.patient_name or self.patient,
frappe.utils.format_date(self.signs_date), frappe.utils.format_time(self.signs_time))[:100]
def insert_vital_signs_to_medical_record(doc):
subject = set_subject_field(doc)
medical_record = frappe.new_doc('Patient Medical Record')