fix: non-empty service unit set as empty after booking appointment
This commit is contained in:
parent
50b67792ca
commit
4dd6f0ae9b
@ -1,6 +1,6 @@
|
|||||||
// 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.provide("erpnext.queries");
|
frappe.provide('erpnext.queries');
|
||||||
frappe.ui.form.on('Patient Appointment', {
|
frappe.ui.form.on('Patient Appointment', {
|
||||||
setup: function(frm) {
|
setup: function(frm) {
|
||||||
frm.custom_make_buttons = {
|
frm.custom_make_buttons = {
|
||||||
@ -8,24 +8,32 @@ frappe.ui.form.on('Patient Appointment', {
|
|||||||
'Patient Encounter': 'Patient Encounter'
|
'Patient Encounter': 'Patient Encounter'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onload: function(frm) {
|
||||||
|
if (frm.is_new()) {
|
||||||
|
frm.set_value('appointment_time', null);
|
||||||
|
frm.disable_save();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
frm.set_query("patient", function () {
|
frm.set_query('patient', function () {
|
||||||
return {
|
return {
|
||||||
filters: {"status": "Active"}
|
filters: {'status': 'Active'}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
frm.set_query("practitioner", function() {
|
frm.set_query('practitioner', function() {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
'department': frm.doc.department
|
'department': frm.doc.department
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
frm.set_query("service_unit", function(){
|
frm.set_query('service_unit', function(){
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
"is_group": false,
|
'is_group': 0,
|
||||||
"allow_appointments": true
|
'allow_appointments': 1
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -42,127 +50,104 @@ frappe.ui.form.on('Patient Appointment', {
|
|||||||
frm.page.set_primary_action(__('Save'), () => frm.save());
|
frm.page.set_primary_action(__('Save'), () => frm.save());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(frm.doc.patient){
|
if (frm.doc.patient) {
|
||||||
frm.add_custom_button(__('Patient History'), function() {
|
frm.add_custom_button(__('Patient History'), function() {
|
||||||
frappe.route_options = {"patient": frm.doc.patient};
|
frappe.route_options = {'patient': frm.doc.patient};
|
||||||
frappe.set_route("patient_history");
|
frappe.set_route('patient_history');
|
||||||
},__("View"));
|
},__('View'));
|
||||||
}
|
}
|
||||||
if(frm.doc.status == "Open"){
|
|
||||||
|
if (frm.doc.status == 'Open' || (frm.doc.status == 'Scheduled' && !frm.doc.__islocal)) {
|
||||||
frm.add_custom_button(__('Cancel'), function() {
|
frm.add_custom_button(__('Cancel'), function() {
|
||||||
btn_update_status(frm, "Cancelled");
|
update_status(frm, 'Cancelled');
|
||||||
});
|
});
|
||||||
frm.add_custom_button(__('Reschedule'), function() {
|
frm.add_custom_button(__('Reschedule'), function() {
|
||||||
check_and_set_availability(frm);
|
check_and_set_availability(frm);
|
||||||
});
|
});
|
||||||
if(frm.doc.procedure_template){
|
|
||||||
frm.add_custom_button(__("Procedure"),function(){
|
if (frm.doc.procedure_template) {
|
||||||
btn_create_procedure(frm);
|
frm.add_custom_button(__('Procedure'), function(){
|
||||||
},"Create");
|
create_procedure(frm);
|
||||||
}
|
},'Create');
|
||||||
else{
|
} else {
|
||||||
frm.add_custom_button(__("Patient Encounter"),function(){
|
frm.add_custom_button(__('Patient Encounter'), function() {
|
||||||
btn_create_encounter(frm);
|
create_encounter(frm);
|
||||||
},"Create");
|
},'Create');
|
||||||
}
|
}
|
||||||
|
|
||||||
frm.add_custom_button(__('Vital Signs'), function() {
|
frm.add_custom_button(__('Vital Signs'), function() {
|
||||||
btn_create_vital_signs(frm);
|
create_vital_signs(frm);
|
||||||
},"Create");
|
},'Create');
|
||||||
}
|
}
|
||||||
if(frm.doc.status == "Scheduled" && !frm.doc.__islocal){
|
|
||||||
frm.add_custom_button(__('Cancel'), function() {
|
|
||||||
btn_update_status(frm, "Cancelled");
|
|
||||||
});
|
|
||||||
frm.add_custom_button(__('Reschedule'), function() {
|
|
||||||
check_and_set_availability(frm);
|
|
||||||
});
|
|
||||||
if(frm.doc.procedure_template){
|
|
||||||
frm.add_custom_button(__("Procedure"),function(){
|
|
||||||
btn_create_procedure(frm);
|
|
||||||
},"Create");
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
frm.add_custom_button(__("Patient Encounter"),function(){
|
|
||||||
btn_create_encounter(frm);
|
|
||||||
},"Create");
|
|
||||||
}
|
|
||||||
|
|
||||||
frm.add_custom_button(__('Vital Signs'), function() {
|
if (frm.doc.status == 'Pending') {
|
||||||
btn_create_vital_signs(frm);
|
|
||||||
},"Create");
|
|
||||||
}
|
|
||||||
if(frm.doc.status == "Pending"){
|
|
||||||
frm.add_custom_button(__('Set Open'), function() {
|
frm.add_custom_button(__('Set Open'), function() {
|
||||||
btn_update_status(frm, "Open");
|
update_status(frm, 'Open');
|
||||||
});
|
});
|
||||||
frm.add_custom_button(__('Cancel'), function() {
|
frm.add_custom_button(__('Cancel'), function() {
|
||||||
btn_update_status(frm, "Cancelled");
|
update_status(frm, 'Cancelled');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
frm.set_df_property("get_procedure_from_encounter", "read_only", frm.doc.__islocal ? 0 : 1);
|
|
||||||
frappe.db.get_value('Healthcare Settings', {name: 'Healthcare Settings'}, 'manage_appointment_invoice_automatically', (r) => {
|
frappe.db.get_value('Healthcare Settings', {name: 'Healthcare Settings'}, 'manage_appointment_invoice_automatically', (settings) => {
|
||||||
if(r.manage_appointment_invoice_automatically == 1){
|
if (settings.manage_appointment_invoice_automatically) {
|
||||||
frm.set_df_property("mode_of_payment", "hidden", 0);
|
frm.set_df_property('mode_of_payment', 'hidden', 0);
|
||||||
frm.set_df_property("paid_amount", "hidden", 0);
|
frm.set_df_property('paid_amount', 'hidden', 0);
|
||||||
frm.set_df_property("mode_of_payment", "reqd", 1);
|
frm.set_df_property('mode_of_payment', 'reqd', 1);
|
||||||
frm.set_df_property("paid_amount", "reqd", 1);
|
frm.set_df_property('paid_amount', 'reqd', 1);
|
||||||
}
|
} else {
|
||||||
else{
|
frm.set_df_property('mode_of_payment', 'hidden', 1);
|
||||||
frm.set_df_property("mode_of_payment", "hidden", 1);
|
frm.set_df_property('paid_amount', 'hidden', 1);
|
||||||
frm.set_df_property("paid_amount", "hidden", 1);
|
frm.set_df_property('mode_of_payment', 'reqd', 0);
|
||||||
frm.set_df_property("mode_of_payment", "reqd", 0);
|
frm.set_df_property('paid_amount', 'reqd', 0);
|
||||||
frm.set_df_property("paid_amount", "reqd", 0);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onload:function(frm){
|
|
||||||
if(frm.is_new()) {
|
|
||||||
frm.set_value("appointment_time", null);
|
|
||||||
frm.disable_save();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
get_procedure_from_encounter: function(frm) {
|
get_procedure_from_encounter: function(frm) {
|
||||||
get_procedure_prescribed(frm);
|
get_prescribed_procedure(frm);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var check_and_set_availability = function(frm) {
|
let check_and_set_availability = function(frm) {
|
||||||
var selected_slot = null;
|
let selected_slot = null;
|
||||||
var service_unit = null;
|
let service_unit = null;
|
||||||
var duration = null;
|
let duration = null;
|
||||||
|
|
||||||
show_availability();
|
show_availability();
|
||||||
|
|
||||||
function show_empty_state(practitioner, appointment_date) {
|
function show_empty_state(practitioner, appointment_date) {
|
||||||
frappe.msgprint({
|
frappe.msgprint({
|
||||||
title: __('Not Available'),
|
title: __('Not Available'),
|
||||||
message: __("Healthcare Practitioner {0} not available on {1}", [practitioner.bold(), appointment_date.bold()]),
|
message: __('Healthcare Practitioner {0} not available on {1}', [practitioner.bold(), appointment_date.bold()]),
|
||||||
indicator: 'red'
|
indicator: 'red'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_availability() {
|
function show_availability() {
|
||||||
let selected_practitioner = '';
|
let selected_practitioner = '';
|
||||||
var d = new frappe.ui.Dialog({
|
let d = new frappe.ui.Dialog({
|
||||||
title: __("Available slots"),
|
title: __('Available slots'),
|
||||||
fields: [
|
fields: [
|
||||||
{ fieldtype: 'Link', options: 'Medical Department', reqd:1, fieldname: 'department', label: 'Medical Department'},
|
{ fieldtype: 'Link', options: 'Medical Department', reqd: 1, fieldname: 'department', label: 'Medical Department'},
|
||||||
{ fieldtype: 'Column Break'},
|
{ fieldtype: 'Column Break'},
|
||||||
{ fieldtype: 'Link', options: 'Healthcare Practitioner', reqd:1, fieldname: 'practitioner', label: 'Healthcare Practitioner'},
|
{ fieldtype: 'Link', options: 'Healthcare Practitioner', reqd: 1, fieldname: 'practitioner', label: 'Healthcare Practitioner'},
|
||||||
{ fieldtype: 'Column Break'},
|
{ fieldtype: 'Column Break'},
|
||||||
{ fieldtype: 'Date', reqd:1, fieldname: 'appointment_date', label: 'Date'},
|
{ fieldtype: 'Date', reqd: 1, fieldname: 'appointment_date', label: 'Date'},
|
||||||
{ fieldtype: 'Section Break'},
|
{ fieldtype: 'Section Break'},
|
||||||
{ fieldtype: 'HTML', fieldname: 'available_slots'}
|
{ fieldtype: 'HTML', fieldname: 'available_slots'}
|
||||||
|
|
||||||
],
|
],
|
||||||
primary_action_label: __("Book"),
|
primary_action_label: __('Book'),
|
||||||
primary_action: function() {
|
primary_action: function() {
|
||||||
frm.set_value('appointment_time', selected_slot);
|
frm.set_value('appointment_time', selected_slot);
|
||||||
frm.set_value('service_unit', service_unit || '');
|
|
||||||
frm.set_value('duration', duration);
|
frm.set_value('duration', duration);
|
||||||
frm.set_value('practitioner', d.get_value('practitioner'));
|
frm.set_value('practitioner', d.get_value('practitioner'));
|
||||||
frm.set_value('department', d.get_value('department'));
|
frm.set_value('department', d.get_value('department'));
|
||||||
frm.set_value('appointment_date', d.get_value('appointment_date'));
|
frm.set_value('appointment_date', d.get_value('appointment_date'));
|
||||||
|
if (service_unit) {
|
||||||
|
frm.set_value('service_unit', service_unit);
|
||||||
|
}
|
||||||
d.hide();
|
d.hide();
|
||||||
frm.enable_save();
|
frm.enable_save();
|
||||||
frm.save();
|
frm.save();
|
||||||
@ -177,16 +162,16 @@ var check_and_set_availability = function(frm) {
|
|||||||
'appointment_date': frm.doc.appointment_date
|
'appointment_date': frm.doc.appointment_date
|
||||||
});
|
});
|
||||||
|
|
||||||
d.fields_dict["department"].df.onchange = () => {
|
d.fields_dict['department'].df.onchange = () => {
|
||||||
d.set_values({
|
d.set_values({
|
||||||
'practitioner': ''
|
'practitioner': ''
|
||||||
});
|
});
|
||||||
var department = d.get_value('department');
|
let department = d.get_value('department');
|
||||||
if(department){
|
if (department) {
|
||||||
d.fields_dict.practitioner.get_query = function() {
|
d.fields_dict.practitioner.get_query = function() {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
"department": department
|
'department': department
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -198,13 +183,13 @@ var check_and_set_availability = function(frm) {
|
|||||||
|
|
||||||
// Field Change Handler
|
// Field Change Handler
|
||||||
|
|
||||||
var fd = d.fields_dict;
|
let fd = d.fields_dict;
|
||||||
|
|
||||||
d.fields_dict["appointment_date"].df.onchange = () => {
|
d.fields_dict['appointment_date'].df.onchange = () => {
|
||||||
show_slots(d, fd);
|
show_slots(d, fd);
|
||||||
};
|
};
|
||||||
d.fields_dict["practitioner"].df.onchange = () => {
|
d.fields_dict['practitioner'].df.onchange = () => {
|
||||||
if(d.get_value('practitioner') && d.get_value('practitioner') != selected_practitioner){
|
if (d.get_value('practitioner') && d.get_value('practitioner') != selected_practitioner) {
|
||||||
selected_practitioner = d.get_value('practitioner');
|
selected_practitioner = d.get_value('practitioner');
|
||||||
show_slots(d, fd);
|
show_slots(d, fd);
|
||||||
}
|
}
|
||||||
@ -213,8 +198,8 @@ var check_and_set_availability = function(frm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function show_slots(d, fd) {
|
function show_slots(d, fd) {
|
||||||
if (d.get_value('appointment_date') && d.get_value('practitioner')){
|
if (d.get_value('appointment_date') && d.get_value('practitioner')) {
|
||||||
fd.available_slots.html("");
|
fd.available_slots.html('');
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: 'erpnext.healthcare.doctype.patient_appointment.patient_appointment.get_availability_data',
|
method: 'erpnext.healthcare.doctype.patient_appointment.patient_appointment.get_availability_data',
|
||||||
args: {
|
args: {
|
||||||
@ -222,13 +207,13 @@ var check_and_set_availability = function(frm) {
|
|||||||
date: d.get_value('appointment_date')
|
date: d.get_value('appointment_date')
|
||||||
},
|
},
|
||||||
callback: (r) => {
|
callback: (r) => {
|
||||||
var data = r.message;
|
let data = r.message;
|
||||||
if(data.slot_details.length > 0) {
|
if (data.slot_details.length > 0) {
|
||||||
var $wrapper = d.fields_dict.available_slots.$wrapper;
|
let $wrapper = d.fields_dict.available_slots.$wrapper;
|
||||||
|
|
||||||
// make buttons for each slot
|
// make buttons for each slot
|
||||||
var slot_details = data.slot_details;
|
let slot_details = data.slot_details;
|
||||||
var slot_html = "";
|
let slot_html = '';
|
||||||
for (let i = 0; i < slot_details.length; i++) {
|
for (let i = 0; i < slot_details.length; i++) {
|
||||||
slot_html = slot_html + `<label>${slot_details[i].slot_name}</label>`;
|
slot_html = slot_html + `<label>${slot_details[i].slot_name}</label>`;
|
||||||
slot_html = slot_html + `<br/>` + slot_details[i].avail_slot.map(slot => {
|
slot_html = slot_html + `<br/>` + slot_details[i].avail_slot.map(slot => {
|
||||||
@ -242,14 +227,14 @@ var check_and_set_availability = function(frm) {
|
|||||||
let booked_moment = moment(booked.appointment_time, 'HH:mm:ss');
|
let booked_moment = moment(booked.appointment_time, 'HH:mm:ss');
|
||||||
let end_time = booked_moment.clone().add(booked.duration, 'minutes');
|
let end_time = booked_moment.clone().add(booked.duration, 'minutes');
|
||||||
// Deal with 0 duration appointments
|
// Deal with 0 duration appointments
|
||||||
if(booked_moment.isSame(slot_start_time) || booked_moment.isBetween(slot_start_time, slot_to_time)){
|
if (booked_moment.isSame(slot_start_time) || booked_moment.isBetween(slot_start_time, slot_to_time)) {
|
||||||
if(booked.duration == 0){
|
if(booked.duration == 0){
|
||||||
disabled = 'disabled="disabled"';
|
disabled = 'disabled="disabled"';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check for overlaps considering appointment duration
|
// Check for overlaps considering appointment duration
|
||||||
if(slot_start_time.isBefore(end_time) && slot_to_time.isAfter(booked_moment)){
|
if (slot_start_time.isBefore(end_time) && slot_to_time.isAfter(booked_moment)) {
|
||||||
// There is an overlap
|
// There is an overlap
|
||||||
disabled = 'disabled="disabled"';
|
disabled = 'disabled="disabled"';
|
||||||
return false;
|
return false;
|
||||||
@ -273,7 +258,7 @@ var check_and_set_availability = function(frm) {
|
|||||||
|
|
||||||
// blue button when clicked
|
// blue button when clicked
|
||||||
$wrapper.on('click', 'button', function() {
|
$wrapper.on('click', 'button', function() {
|
||||||
var $btn = $(this);
|
let $btn = $(this);
|
||||||
$wrapper.find('button').removeClass('btn-primary');
|
$wrapper.find('button').removeClass('btn-primary');
|
||||||
$btn.addClass('btn-primary');
|
$btn.addClass('btn-primary');
|
||||||
selected_slot = $btn.attr('data-name');
|
selected_slot = $btn.attr('data-name');
|
||||||
@ -283,52 +268,57 @@ var check_and_set_availability = function(frm) {
|
|||||||
d.get_primary_btn().attr('disabled', null);
|
d.get_primary_btn().attr('disabled', null);
|
||||||
});
|
});
|
||||||
|
|
||||||
}else {
|
} else {
|
||||||
// fd.available_slots.html("Please select a valid date.".bold())
|
// fd.available_slots.html('Please select a valid date.'.bold())
|
||||||
show_empty_state(d.get_value('practitioner'), d.get_value('appointment_date'));
|
show_empty_state(d.get_value('practitioner'), d.get_value('appointment_date'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
freeze: true,
|
freeze: true,
|
||||||
freeze_message: __("Fetching records......")
|
freeze_message: __('Fetching records......')
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
fd.available_slots.html("Appointment date and Healthcare Practitioner are Mandatory".bold());
|
fd.available_slots.html('Appointment date and Healthcare Practitioner are Mandatory'.bold());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var get_procedure_prescribed = function(frm){
|
let get_prescribed_procedure = function(frm) {
|
||||||
if(frm.doc.patient){
|
if (frm.doc.patient) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method:"erpnext.healthcare.doctype.patient_appointment.patient_appointment.get_procedure_prescribed",
|
method: 'erpnext.healthcare.doctype.patient_appointment.patient_appointment.get_procedure_prescribed',
|
||||||
args: {patient: frm.doc.patient},
|
args: {patient: frm.doc.patient},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if (r.message && r.message.length) {
|
if (r.message && r.message.length) {
|
||||||
show_procedure_templates(frm, r.message);
|
show_procedure_templates(frm, r.message);
|
||||||
} else {
|
} else {
|
||||||
frappe.msgprint(__("No Prescribed Procedures found for the selected patient"));
|
frappe.msgprint({
|
||||||
|
title: __('Not Found'),
|
||||||
|
message: __('No Prescribed Procedures found for the selected Patient')
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else{
|
frappe.msgprint({
|
||||||
frappe.msgprint(__("Please select Patient to get prescribed procedure"));
|
title: __('Not Allowed'),
|
||||||
|
message: __('Please select Patient first')
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var show_procedure_templates = function(frm, result){
|
let show_procedure_templates = function(frm, result){
|
||||||
var d = new frappe.ui.Dialog({
|
let d = new frappe.ui.Dialog({
|
||||||
title: __("Prescribed Procedures"),
|
title: __('Prescribed Procedures'),
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
fieldtype: "HTML", fieldname: "procedure_template"
|
fieldtype: 'HTML', fieldname: 'procedure_template'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
var html_field = d.fields_dict.procedure_template.$wrapper;
|
let html_field = d.fields_dict.procedure_template.$wrapper;
|
||||||
html_field.empty();
|
html_field.empty();
|
||||||
$.each(result, function(x, y){
|
$.each(result, function(x, y) {
|
||||||
var row = $(repl('<div class="col-xs-12" style="padding-top:12px; text-align:center;" >\
|
let row = $(repl('<div class="col-xs-12" style="padding-top:12px; text-align:center;" >\
|
||||||
<div class="col-xs-5"> %(encounter)s <br> %(consulting_practitioner)s <br> %(encounter_date)s </div>\
|
<div class="col-xs-5"> %(encounter)s <br> %(consulting_practitioner)s <br> %(encounter_date)s </div>\
|
||||||
<div class="col-xs-5"> %(procedure_template)s <br>%(practitioner)s <br> %(date)s</div>\
|
<div class="col-xs-5"> %(procedure_template)s <br>%(practitioner)s <br> %(date)s</div>\
|
||||||
<div class="col-xs-2">\
|
<div class="col-xs-2">\
|
||||||
@ -340,76 +330,75 @@ var show_procedure_templates = function(frm, result){
|
|||||||
encounter:y[2], consulting_practitioner:y[3], encounter_date:y[4],
|
encounter:y[2], consulting_practitioner:y[3], encounter_date:y[4],
|
||||||
practitioner:y[5]? y[5]:'', date: y[6]? y[6]:'', department: y[7]? y[7]:''})).appendTo(html_field);
|
practitioner:y[5]? y[5]:'', date: y[6]? y[6]:'', department: y[7]? y[7]:''})).appendTo(html_field);
|
||||||
row.find("a").click(function() {
|
row.find("a").click(function() {
|
||||||
frm.doc.procedure_template = $(this).attr("data-procedure-template");
|
frm.doc.procedure_template = $(this).attr('data-procedure-template');
|
||||||
frm.doc.procedure_prescription = $(this).attr("data-name");
|
frm.doc.procedure_prescription = $(this).attr('data-name');
|
||||||
frm.doc.practitioner = $(this).attr("data-practitioner");
|
frm.doc.practitioner = $(this).attr('data-practitioner');
|
||||||
frm.doc.appointment_date = $(this).attr("data-date");
|
frm.doc.appointment_date = $(this).attr('data-date');
|
||||||
frm.doc.department = $(this).attr("data-department");
|
frm.doc.department = $(this).attr('data-department');
|
||||||
refresh_field("procedure_template");
|
refresh_field('procedure_template');
|
||||||
refresh_field("procedure_prescription");
|
refresh_field('procedure_prescription');
|
||||||
refresh_field("appointment_date");
|
refresh_field('appointment_date');
|
||||||
refresh_field("practitioner");
|
refresh_field('practitioner');
|
||||||
refresh_field("department");
|
refresh_field('department');
|
||||||
d.hide();
|
d.hide();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
if(!result){
|
if (!result) {
|
||||||
var msg = "There are no procedure prescribed for "+frm.doc.patient;
|
let msg = 'There are no procedure prescribed for '+frm.doc.patient;
|
||||||
$(repl('<div class="col-xs-12" style="padding-top:20px;" >%(msg)s</div></div>', {msg: msg})).appendTo(html_field);
|
$(repl('<div class="col-xs-12" style="padding-top:20px;" >%(msg)s</div></div>', {msg: msg})).appendTo(html_field);
|
||||||
}
|
}
|
||||||
d.show();
|
d.show();
|
||||||
};
|
};
|
||||||
|
|
||||||
var btn_create_procedure = function(frm){
|
let create_procedure = function(frm) {
|
||||||
var doc = frm.doc;
|
let doc = frm.doc;
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method:"erpnext.healthcare.doctype.clinical_procedure.clinical_procedure.create_procedure",
|
method: 'erpnext.healthcare.doctype.clinical_procedure.clinical_procedure.create_procedure',
|
||||||
args: {appointment: doc.name},
|
args: {appointment: doc.name},
|
||||||
callback: function(data){
|
callback: function(data) {
|
||||||
if(!data.exc){
|
if (!data.exc) {
|
||||||
var doclist = frappe.model.sync(data.message);
|
let doclist = frappe.model.sync(data.message);
|
||||||
frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
|
frappe.set_route('Form', doclist[0].doctype, doclist[0].name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var btn_create_encounter = function(frm){
|
let create_encounter = function(frm) {
|
||||||
var doc = frm.doc;
|
let doc = frm.doc;
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method:"erpnext.healthcare.doctype.patient_appointment.patient_appointment.create_encounter",
|
method: 'erpnext.healthcare.doctype.patient_appointment.patient_appointment.create_encounter',
|
||||||
args: {appointment: doc.name},
|
args: {appointment: doc.name},
|
||||||
callback: function(data){
|
callback: function(data){
|
||||||
if(!data.exc){
|
if (!data.exc) {
|
||||||
var doclist = frappe.model.sync(data.message);
|
let doclist = frappe.model.sync(data.message);
|
||||||
frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
|
frappe.set_route('Form', doclist[0].doctype, doclist[0].name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var btn_create_vital_signs = function (frm) {
|
let create_vital_signs = function(frm) {
|
||||||
if(!frm.doc.patient){
|
if (!frm.doc.patient) {
|
||||||
frappe.throw(__("Please select patient"));
|
frappe.throw(__('Please select patient'));
|
||||||
}
|
}
|
||||||
frappe.route_options = {
|
frappe.route_options = {
|
||||||
"patient": frm.doc.patient,
|
'patient': frm.doc.patient,
|
||||||
"appointment": frm.doc.name,
|
'appointment': frm.doc.name,
|
||||||
};
|
};
|
||||||
frappe.new_doc("Vital Signs");
|
frappe.new_doc('Vital Signs');
|
||||||
};
|
};
|
||||||
|
|
||||||
var btn_update_status = function(frm, status){
|
let update_status = function(frm, status){
|
||||||
var doc = frm.doc;
|
let doc = frm.doc;
|
||||||
frappe.confirm(__('Are you sure you want to cancel this appointment?'),
|
frappe.confirm(__('Are you sure you want to cancel this appointment?'),
|
||||||
function() {
|
function() {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method:
|
method: 'erpnext.healthcare.doctype.patient_appointment.patient_appointment.update_status',
|
||||||
"erpnext.healthcare.doctype.patient_appointment.patient_appointment.update_status",
|
|
||||||
args: {appointment_id: doc.name, status:status},
|
args: {appointment_id: doc.name, status:status},
|
||||||
callback: function(data){
|
callback: function(data) {
|
||||||
if(!data.exc){
|
if (!data.exc) {
|
||||||
frm.reload_doc();
|
frm.reload_doc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -418,60 +407,60 @@ var btn_update_status = function(frm, status){
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
frappe.ui.form.on("Patient Appointment", "practitioner", function(frm) {
|
frappe.ui.form.on('Patient Appointment', 'practitioner', function(frm) {
|
||||||
if(frm.doc.practitioner){
|
if (frm.doc.practitioner) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
"method": "frappe.client.get",
|
method: 'frappe.client.get',
|
||||||
args: {
|
args: {
|
||||||
doctype: "Healthcare Practitioner",
|
doctype: 'Healthcare Practitioner',
|
||||||
name: frm.doc.practitioner
|
name: frm.doc.practitioner
|
||||||
},
|
},
|
||||||
callback: function (data) {
|
callback: function (data) {
|
||||||
frappe.model.set_value(frm.doctype,frm.docname, "department",data.message.department);
|
frappe.model.set_value(frm.doctype, frm.docname, 'department', data.message.department);
|
||||||
frappe.model.set_value(frm.doctype,frm.docname, "paid_amount",data.message.op_consulting_charge);
|
frappe.model.set_value(frm.doctype, frm.docname, 'paid_amount', data.message.op_consulting_charge);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.form.on("Patient Appointment", "patient", function(frm) {
|
frappe.ui.form.on('Patient Appointment', 'patient', function(frm) {
|
||||||
if(frm.doc.patient){
|
if (frm.doc.patient) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
"method": "frappe.client.get",
|
method: 'frappe.client.get',
|
||||||
args: {
|
args: {
|
||||||
doctype: "Patient",
|
doctype: 'Patient',
|
||||||
name: frm.doc.patient
|
name: frm.doc.patient
|
||||||
},
|
},
|
||||||
callback: function (data) {
|
callback: function (data) {
|
||||||
var age = null;
|
let age = null;
|
||||||
if(data.message.dob){
|
if (data.message.dob) {
|
||||||
age = calculate_age(data.message.dob);
|
age = calculate_age(data.message.dob);
|
||||||
}
|
}
|
||||||
frappe.model.set_value(frm.doctype,frm.docname, "patient_age", age);
|
frappe.model.set_value(frm.doctype,frm.docname, 'patient_age', age);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.form.on("Patient Appointment", "appointment_type", function(frm) {
|
frappe.ui.form.on('Patient Appointment', 'appointment_type', function(frm) {
|
||||||
if(frm.doc.appointment_type) {
|
if (frm.doc.appointment_type) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
"method": "frappe.client.get",
|
method: 'frappe.client.get',
|
||||||
args: {
|
args: {
|
||||||
doctype: "Appointment Type",
|
doctype: 'Appointment Type',
|
||||||
name: frm.doc.appointment_type
|
name: frm.doc.appointment_type
|
||||||
},
|
},
|
||||||
callback: function (data) {
|
callback: function(data) {
|
||||||
frappe.model.set_value(frm.doctype,frm.docname, "duration",data.message.default_duration);
|
frappe.model.set_value(frm.doctype,frm.docname, 'duration',data.message.default_duration);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var calculate_age = function(birth) {
|
let calculate_age = function(birth) {
|
||||||
var ageMS = Date.parse(Date()) - Date.parse(birth);
|
let ageMS = Date.parse(Date()) - Date.parse(birth);
|
||||||
var age = new Date();
|
let age = new Date();
|
||||||
age.setTime(ageMS);
|
age.setTime(ageMS);
|
||||||
var years = age.getFullYear() - 1970;
|
let years = age.getFullYear() - 1970;
|
||||||
return years + " Year(s) " + age.getMonth() + " Month(s) " + age.getDate() + " Day(s)";
|
return years + ' Year(s) ' + age.getMonth() + ' Month(s) ' + age.getDate() + ' Day(s)';
|
||||||
};
|
};
|
||||||
|
|||||||
@ -9,10 +9,11 @@
|
|||||||
"document_type": "Document",
|
"document_type": "Document",
|
||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"inpatient_record",
|
|
||||||
"patient",
|
"patient",
|
||||||
"appointment_type",
|
"patient_name",
|
||||||
"duration",
|
"patient_sex",
|
||||||
|
"patient_age",
|
||||||
|
"inpatient_record",
|
||||||
"column_break_1",
|
"column_break_1",
|
||||||
"status",
|
"status",
|
||||||
"procedure_template",
|
"procedure_template",
|
||||||
@ -22,20 +23,18 @@
|
|||||||
"section_break_12",
|
"section_break_12",
|
||||||
"practitioner",
|
"practitioner",
|
||||||
"department",
|
"department",
|
||||||
|
"appointment_type",
|
||||||
"column_break_17",
|
"column_break_17",
|
||||||
"appointment_date",
|
"appointment_date",
|
||||||
"appointment_time",
|
"appointment_time",
|
||||||
"section_break_16",
|
|
||||||
"patient_name",
|
|
||||||
"patient_sex",
|
|
||||||
"column_break_21",
|
|
||||||
"patient_age",
|
|
||||||
"section_break_1",
|
|
||||||
"appointment_datetime",
|
"appointment_datetime",
|
||||||
|
"duration",
|
||||||
|
"section_break_16",
|
||||||
|
"invoiced",
|
||||||
|
"ref_sales_invoice",
|
||||||
|
"column_break_2",
|
||||||
"mode_of_payment",
|
"mode_of_payment",
|
||||||
"paid_amount",
|
"paid_amount",
|
||||||
"column_break_2",
|
|
||||||
"invoiced",
|
|
||||||
"company",
|
"company",
|
||||||
"section_break_3",
|
"section_break_3",
|
||||||
"notes",
|
"notes",
|
||||||
@ -73,11 +72,10 @@
|
|||||||
"set_only_once": 1
|
"set_only_once": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "In Minutes",
|
|
||||||
"fieldname": "duration",
|
"fieldname": "duration",
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Int",
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
"label": "Duration"
|
"label": "Duration (In Minutes)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_1",
|
"fieldname": "column_break_1",
|
||||||
@ -104,9 +102,10 @@
|
|||||||
"set_only_once": 1
|
"set_only_once": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"depends_on": "eval:doc.__islocal && doc.patient",
|
||||||
"fieldname": "get_procedure_from_encounter",
|
"fieldname": "get_procedure_from_encounter",
|
||||||
"fieldtype": "Button",
|
"fieldtype": "Button",
|
||||||
"label": "Get prescribed procedures"
|
"label": "Get Prescribed Clinical Procedures"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "procedure_prescription",
|
"fieldname": "procedure_prescription",
|
||||||
@ -194,21 +193,12 @@
|
|||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"report_hide": 1
|
"report_hide": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "column_break_21",
|
|
||||||
"fieldtype": "Column Break"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "patient_age",
|
"fieldname": "patient_age",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"label": "Patient Age",
|
"label": "Patient Age",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "section_break_1",
|
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"set_only_once": 1
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "appointment_datetime",
|
"fieldname": "appointment_datetime",
|
||||||
"fieldtype": "Datetime",
|
"fieldtype": "Datetime",
|
||||||
@ -279,10 +269,17 @@
|
|||||||
"label": "Reminded",
|
"label": "Reminded",
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"report_hide": 1
|
"report_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "ref_sales_invoice",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Reference Sales Invoice",
|
||||||
|
"options": "Sales Invoice",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2020-02-03 23:38:41.821141",
|
"modified": "2020-02-10 22:38:55.401247",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Healthcare",
|
"module": "Healthcare",
|
||||||
"name": "Patient Appointment",
|
"name": "Patient Appointment",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user