fix (Vital Signs): Patient Medical Record not found

This commit is contained in:
Rucha Mahabal 2020-03-06 12:21:18 +05:30
parent 33fec1df54
commit 11117810c5
4 changed files with 121 additions and 832 deletions

View File

@ -201,7 +201,8 @@ let create_vital_signs = function (frm) {
} }
frappe.route_options = { frappe.route_options = {
'patient': frm.doc.patient, 'patient': frm.doc.patient,
'appointment': frm.doc.appointment 'appointment': frm.doc.appointment,
'encounter': frm.doc.name
}; };
frappe.new_doc('Vital Signs'); frappe.new_doc('Vital Signs');
}; };

View File

@ -1,49 +1,56 @@
// Copyright (c) 2016, ESS LLP and contributors // Copyright (c) 2016, ESS LLP and contributors
// For license information, please see license.txt // For license information, please see license.txt
frappe.ui.form.on("Vital Signs", "height", function(frm) { frappe.ui.form.on('Vital Signs', {
refresh: function(frm) {
},
height: function(frm) {
if (frm.doc.height && frm.doc.weight) { if (frm.doc.height && frm.doc.weight) {
calculate_bmi(frm); calculate_bmi(frm);
} }
}); },
frappe.ui.form.on("Vital Signs", "weight", function(frm) { weight: function(frm) {
if (frm.doc.height && frm.doc.weight) { if (frm.doc.height && frm.doc.weight) {
calculate_bmi(frm); calculate_bmi(frm);
} }
},
bp_systolic: function(frm) {
if (frm.doc.bp_systolic && frm.doc.bp_diastolic) {
set_bp(frm);
}
},
bp_diastolic: function(frm) {
if (frm.doc.bp_systolic && frm.doc.bp_diastolic) {
set_bp(frm);
}
}
}); });
var calculate_bmi = function(frm){ let calculate_bmi = function(frm){
// Reference https://en.wikipedia.org/wiki/Body_mass_index // Reference https://en.wikipedia.org/wiki/Body_mass_index
// bmi = weight (in Kg) / height * height (in Meter) // bmi = weight (in Kg) / height * height (in Meter)
var bmi = (frm.doc.weight/(frm.doc.height*frm.doc.height)).toFixed(2); let bmi = (frm.doc.weight / (frm.doc.height * frm.doc.height)).toFixed(2);
var bmi_note = null; let bmi_note = null;
if (bmi<18.5) { if (bmi<18.5) {
bmi_note = "Underweight"; bmi_note = 'Underweight';
} else if (bmi>=18.5 && bmi<25) { } else if (bmi>=18.5 && bmi<25) {
bmi_note = "Normal"; bmi_note = 'Normal';
} else if (bmi>=25 && bmi<30) { } else if (bmi>=25 && bmi<30) {
bmi_note = "Overweight"; bmi_note = 'Overweight';
} else if (bmi>=30) { } else if (bmi>=30) {
bmi_note = "Obese"; bmi_note = 'Obese';
} }
frappe.model.set_value(frm.doctype,frm.docname, "bmi", bmi); frappe.model.set_value(frm.doctype,frm.docname, 'bmi', bmi);
frappe.model.set_value(frm.doctype,frm.docname, "nutrition_note", bmi_note); frappe.model.set_value(frm.doctype,frm.docname, 'nutrition_note', bmi_note);
}; };
frappe.ui.form.on("Vital Signs", "bp_systolic", function(frm) { let set_bp = function(frm){
if(frm.doc.bp_systolic && frm.doc.bp_diastolic){ let bp = frm.doc.bp_systolic+ '/' + frm.doc.bp_diastolic + ' mmHg';
set_bp(frm); frappe.model.set_value(frm.doctype,frm.docname, 'bp', bp);
}
});
frappe.ui.form.on("Vital Signs", "bp_diastolic", function(frm) {
if(frm.doc.bp_systolic && frm.doc.bp_diastolic){
set_bp(frm);
}
});
var set_bp = function(frm){
var bp = frm.doc.bp_systolic+"/"+frm.doc.bp_diastolic+" mmHg";
frappe.model.set_value(frm.doctype,frm.docname, "bp", bp);
}; };

File diff suppressed because it is too large Load Diff

View File

@ -16,34 +16,34 @@ class VitalSigns(Document):
def insert_vital_signs_to_medical_record(doc): def insert_vital_signs_to_medical_record(doc):
subject = set_subject_field(doc) subject = set_subject_field(doc)
medical_record = frappe.new_doc("Patient Medical Record") medical_record = frappe.new_doc('Patient Medical Record')
medical_record.patient = doc.patient medical_record.patient = doc.patient
medical_record.subject = subject medical_record.subject = subject
medical_record.status = "Open" medical_record.status = 'Open'
medical_record.communication_date = doc.signs_date medical_record.communication_date = doc.signs_date
medical_record.reference_doctype = "Vital Signs" medical_record.reference_doctype = 'Vital Signs'
medical_record.reference_name = doc.name medical_record.reference_name = doc.name
medical_record.reference_owner = doc.owner medical_record.reference_owner = doc.owner
medical_record.save(ignore_permissions=True) medical_record.save(ignore_permissions=True)
def delete_vital_signs_from_medical_record(doc): def delete_vital_signs_from_medical_record(doc):
medical_record_id = frappe.db.sql("select name from `tabPatient Medical Record` where reference_name=%s",(doc.name)) medical_record = frappe.db.get_value('Patient Medical Record', {'reference_name': doc.name})
if medical_record_id and medical_record_id[0][0]: if medical_record:
frappe.delete_doc("Patient Medical Record", medical_record_id[0][0]) frappe.delete_doc('Patient Medical Record', medical_record)
def set_subject_field(doc): def set_subject_field(doc):
subject = "" subject = ''
if(doc.temperature): if(doc.temperature):
subject += "Temperature: \n"+ cstr(doc.temperature)+". " subject += 'Temperature: \n'+ cstr(doc.temperature)+'. '
if(doc.pulse): if(doc.pulse):
subject += "Pulse: \n"+ cstr(doc.pulse)+". " subject += 'Pulse: \n'+ cstr(doc.pulse)+'. '
if(doc.respiratory_rate): if(doc.respiratory_rate):
subject += "Respiratory Rate: \n"+ cstr(doc.respiratory_rate)+". " subject += 'Respiratory Rate: \n'+ cstr(doc.respiratory_rate)+'. '
if(doc.bp): if(doc.bp):
subject += "BP: \n"+ cstr(doc.bp)+". " subject += 'BP: \n'+ cstr(doc.bp)+'. '
if(doc.bmi): if(doc.bmi):
subject += "BMI: \n"+ cstr(doc.bmi)+". " subject += 'BMI: \n'+ cstr(doc.bmi)+'. '
if(doc.nutrition_note): if(doc.nutrition_note):
subject += "Note: \n"+ cstr(doc.nutrition_note)+". " subject += 'Note: \n'+ cstr(doc.nutrition_note)+'. '
return subject return subject