fix (Vital Signs): Patient Medical Record not found
This commit is contained in:
parent
33fec1df54
commit
11117810c5
@ -201,7 +201,8 @@ let create_vital_signs = function (frm) {
|
||||
}
|
||||
frappe.route_options = {
|
||||
'patient': frm.doc.patient,
|
||||
'appointment': frm.doc.appointment
|
||||
'appointment': frm.doc.appointment,
|
||||
'encounter': frm.doc.name
|
||||
};
|
||||
frappe.new_doc('Vital Signs');
|
||||
};
|
||||
|
@ -1,49 +1,56 @@
|
||||
// Copyright (c) 2016, ESS LLP and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on("Vital Signs", "height", function(frm) {
|
||||
if(frm.doc.height && frm.doc.weight){
|
||||
calculate_bmi(frm);
|
||||
frappe.ui.form.on('Vital Signs', {
|
||||
refresh: function(frm) {
|
||||
|
||||
},
|
||||
|
||||
height: function(frm) {
|
||||
if (frm.doc.height && frm.doc.weight) {
|
||||
calculate_bmi(frm);
|
||||
}
|
||||
},
|
||||
|
||||
weight: function(frm) {
|
||||
if (frm.doc.height && frm.doc.weight) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
frappe.ui.form.on("Vital Signs", "weight", function(frm) {
|
||||
if(frm.doc.height && frm.doc.weight){
|
||||
calculate_bmi(frm);
|
||||
}
|
||||
});
|
||||
|
||||
var calculate_bmi = function(frm){
|
||||
let calculate_bmi = function(frm){
|
||||
// Reference https://en.wikipedia.org/wiki/Body_mass_index
|
||||
// bmi = weight (in Kg) / height * height (in Meter)
|
||||
var bmi = (frm.doc.weight/(frm.doc.height*frm.doc.height)).toFixed(2);
|
||||
var bmi_note = null;
|
||||
if(bmi<18.5){
|
||||
bmi_note = "Underweight";
|
||||
}else if(bmi>=18.5 && bmi<25){
|
||||
bmi_note = "Normal";
|
||||
}else if(bmi>=25 && bmi<30){
|
||||
bmi_note = "Overweight";
|
||||
}else if(bmi>=30){
|
||||
bmi_note = "Obese";
|
||||
let bmi = (frm.doc.weight / (frm.doc.height * frm.doc.height)).toFixed(2);
|
||||
let bmi_note = null;
|
||||
|
||||
if (bmi<18.5) {
|
||||
bmi_note = 'Underweight';
|
||||
} else if (bmi>=18.5 && bmi<25) {
|
||||
bmi_note = 'Normal';
|
||||
} else if (bmi>=25 && bmi<30) {
|
||||
bmi_note = 'Overweight';
|
||||
} else if (bmi>=30) {
|
||||
bmi_note = 'Obese';
|
||||
}
|
||||
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, 'bmi', bmi);
|
||||
frappe.model.set_value(frm.doctype,frm.docname, 'nutrition_note', bmi_note);
|
||||
};
|
||||
|
||||
frappe.ui.form.on("Vital Signs", "bp_systolic", function(frm) {
|
||||
if(frm.doc.bp_systolic && frm.doc.bp_diastolic){
|
||||
set_bp(frm);
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
let set_bp = function(frm){
|
||||
let 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
@ -16,34 +16,34 @@ class VitalSigns(Document):
|
||||
|
||||
def insert_vital_signs_to_medical_record(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.subject = subject
|
||||
medical_record.status = "Open"
|
||||
medical_record.status = 'Open'
|
||||
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_owner = doc.owner
|
||||
medical_record.save(ignore_permissions=True)
|
||||
|
||||
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))
|
||||
if medical_record_id and medical_record_id[0][0]:
|
||||
frappe.delete_doc("Patient Medical Record", medical_record_id[0][0])
|
||||
medical_record = frappe.db.get_value('Patient Medical Record', {'reference_name': doc.name})
|
||||
if medical_record:
|
||||
frappe.delete_doc('Patient Medical Record', medical_record)
|
||||
|
||||
def set_subject_field(doc):
|
||||
subject = ""
|
||||
subject = ''
|
||||
if(doc.temperature):
|
||||
subject += "Temperature: \n"+ cstr(doc.temperature)+". "
|
||||
subject += 'Temperature: \n'+ cstr(doc.temperature)+'. '
|
||||
if(doc.pulse):
|
||||
subject += "Pulse: \n"+ cstr(doc.pulse)+". "
|
||||
subject += 'Pulse: \n'+ cstr(doc.pulse)+'. '
|
||||
if(doc.respiratory_rate):
|
||||
subject += "Respiratory Rate: \n"+ cstr(doc.respiratory_rate)+". "
|
||||
subject += 'Respiratory Rate: \n'+ cstr(doc.respiratory_rate)+'. '
|
||||
if(doc.bp):
|
||||
subject += "BP: \n"+ cstr(doc.bp)+". "
|
||||
subject += 'BP: \n'+ cstr(doc.bp)+'. '
|
||||
if(doc.bmi):
|
||||
subject += "BMI: \n"+ cstr(doc.bmi)+". "
|
||||
subject += 'BMI: \n'+ cstr(doc.bmi)+'. '
|
||||
if(doc.nutrition_note):
|
||||
subject += "Note: \n"+ cstr(doc.nutrition_note)+". "
|
||||
subject += 'Note: \n'+ cstr(doc.nutrition_note)+'. '
|
||||
|
||||
return subject
|
||||
|
Loading…
x
Reference in New Issue
Block a user