From 369ba85499d8454d99bf1a7cd70d942eb57992f8 Mon Sep 17 00:00:00 2001 From: Ranjith Kurungadam Date: Tue, 13 Mar 2018 14:50:24 +0530 Subject: [PATCH] Physician Schedule fixes (#13284) * move button add schedule to grid * Physician Schedule- add slots for multiple days * fix patient image view --- .../healthcare/doctype/patient/patient.json | 44 ++++++++++++++++++- .../physician_schedule/physician_schedule.js | 44 +++++++++++-------- 2 files changed, 67 insertions(+), 21 deletions(-) diff --git a/erpnext/healthcare/doctype/patient/patient.json b/erpnext/healthcare/doctype/patient/patient.json index 21bef3071c..10cc11abdc 100644 --- a/erpnext/healthcare/doctype/patient/patient.json +++ b/erpnext/healthcare/doctype/patient/patient.json @@ -44,6 +44,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -75,6 +76,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -106,6 +108,7 @@ "reqd": 1, "search_index": 1, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -137,6 +140,7 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -168,6 +172,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -198,6 +203,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -228,6 +234,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -260,6 +267,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -286,10 +294,11 @@ "print_hide_if_no_value": 0, "read_only": 0, "remember_last_selected_value": 0, - "report_hide": 1, + "report_hide": 0, "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0, "width": "50%" }, @@ -320,6 +329,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -351,6 +361,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 1, + "translatable": 0, "unique": 0 }, { @@ -382,6 +393,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -412,6 +424,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -443,6 +456,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -473,6 +487,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -504,6 +519,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -534,6 +550,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -565,6 +582,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -595,6 +613,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -625,6 +644,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -655,6 +675,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -684,6 +705,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -714,6 +736,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -744,6 +767,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -774,6 +798,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -804,6 +829,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -833,6 +859,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -864,6 +891,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -894,6 +922,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -924,6 +953,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -954,6 +984,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -984,6 +1015,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -1014,6 +1046,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -1043,6 +1076,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -1073,6 +1107,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -1103,6 +1138,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -1136,6 +1172,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -1167,6 +1204,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -1197,6 +1235,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 }, { @@ -1228,6 +1267,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, + "translatable": 0, "unique": 0 } ], @@ -1243,7 +1283,7 @@ "issingle": 0, "istable": 0, "max_attachments": 50, - "modified": "2017-11-24 12:39:33.061005", + "modified": "2018-03-13 11:20:31.338415", "modified_by": "Administrator", "module": "Healthcare", "name": "Patient", diff --git a/erpnext/healthcare/doctype/physician_schedule/physician_schedule.js b/erpnext/healthcare/doctype/physician_schedule/physician_schedule.js index 74ba66f81a..5b0b57f174 100644 --- a/erpnext/healthcare/doctype/physician_schedule/physician_schedule.js +++ b/erpnext/healthcare/doctype/physician_schedule/physician_schedule.js @@ -3,10 +3,11 @@ frappe.ui.form.on('Physician Schedule', { refresh: function(frm) { - frm.add_custom_button(__('Add Time Slots'), () => { + cur_frm.fields_dict["time_slots"].grid.wrapper.find('.grid-add-row').hide(); + cur_frm.fields_dict["time_slots"].grid.add_custom_button(__('Add Time Slots'), () => { var d = new frappe.ui.Dialog({ fields: [ - {fieldname: 'day', label: __('Day'), fieldtype:'Select', + {fieldname: 'days', label: __('Select Days'), fieldtype:'MultiSelect', options:[ {value:'Sunday', label:__('Sunday')}, {value:'Monday', label:__('Monday')}, @@ -15,7 +16,7 @@ frappe.ui.form.on('Physician Schedule', { {value:'Thursday', label:__('Thursday')}, {value:'Friday', label:__('Friday')}, {value:'Saturday', label:__('Saturday')}, - ], reqd: 1, 'default': 'Monday'}, + ], reqd: 1}, {fieldname: 'from_time', label:__('From'), fieldtype:'Time', 'default': '09:00:00', reqd: 1}, {fieldname: 'to_time', label:__('To'), fieldtype:'Time', @@ -27,24 +28,29 @@ frappe.ui.form.on('Physician Schedule', { primary_action: () => { var values = d.get_values(); if(values) { - let cur_time = moment(values.from_time, 'HH:mm:ss'); - let end_time = moment(values.to_time, 'HH:mm:ss'); - - - while(cur_time < end_time) { - let to_time = cur_time.clone().add(values.duration, 'minutes'); - if(to_time <= end_time) { - - // add a new timeslot - frm.add_child('time_slots', { - from_time: cur_time.format('HH:mm:ss'), - to_time: to_time.format('HH:mm:ss'), - day: values.day - }); + values.days.split(',').forEach(function(day){ + day = $.trim(day); + if(['Sunday', 'Monday', 'Tuesday', 'Wednesday', + 'Thursday', 'Friday', 'Saturday'].includes(day)){ + add_slots(day); + } + }); + function add_slots(week_day){ + let cur_time = moment(values.from_time, 'HH:mm:ss'); + let end_time = moment(values.to_time, 'HH:mm:ss'); + while(cur_time < end_time) { + let to_time = cur_time.clone().add(values.duration, 'minutes'); + if(to_time <= end_time) { + // add a new timeslot + frm.add_child('time_slots', { + from_time: cur_time.format('HH:mm:ss'), + to_time: to_time.format('HH:mm:ss'), + day: week_day + }); + } + cur_time = to_time; } - cur_time = to_time; } - frm.refresh_field('time_slots'); frappe.show_alert({ message:__('Time slots added'),