From cd525299ee62247768b93bdbabc5b8f838fac08b Mon Sep 17 00:00:00 2001 From: Tom Price Date: Tue, 20 Mar 2018 06:38:44 +0000 Subject: [PATCH] [Feature] Add default duration and color to appointment type (#13296) * Add default duration and color to appointment type When creating a Patient Appointment, the Duration field will be populated when the Appointment Type is set. This is preserved when checking availability and booking an appointment. `Appointment Type.color` is used in the calendar display. * Remove accidental fixed date from git * Update modified timestamp to ensure migrations. Set to the timestamp of dd506a0961437540872c01d3487b8e37806c0bb0 --- .../appointment_type/appointment_type.json | 63 ++++++++++++++++++- .../patient_appointment.js | 21 ++++++- .../patient_appointment.json | 9 ++- .../patient_appointment.py | 11 ++-- .../patient_appointment_calendar.js | 3 +- 5 files changed, 93 insertions(+), 14 deletions(-) diff --git a/erpnext/healthcare/doctype/appointment_type/appointment_type.json b/erpnext/healthcare/doctype/appointment_type/appointment_type.json index 9d331fa74b..46ca5d9114 100644 --- a/erpnext/healthcare/doctype/appointment_type/appointment_type.json +++ b/erpnext/healthcare/doctype/appointment_type/appointment_type.json @@ -71,6 +71,67 @@ "search_index": 0, "set_only_once": 0, "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 1, + "collapsible": 0, + "columns": 0, + "description": "In Minutes", + "fieldname": "default_duration", + "fieldtype": "Int", + "hidden": 1, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 1, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Default Duration", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "color", + "fieldtype": "Color", + "hidden": 1, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Color", + "length": 0, + "no_copy": 1, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 1, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 } ], "has_web_view": 0, @@ -83,7 +144,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-10-05 11:07:26.369657", + "modified": "2018-03-13 12:10:00.123456", "modified_by": "Administrator", "module": "Healthcare", "name": "Appointment Type", diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js index f34f7cfe1a..41974a6976 100644 --- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js +++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js @@ -137,6 +137,7 @@ frappe.ui.form.on('Patient Appointment', { var slot_details = data.slot_details; var slot_html = ""; + var duration = frm.doc.duration | 0; $.each(slot_details, function(i, slot_detail){ slot_html = slot_html + ``; slot_html = slot_html + `
` + slot_detail['avail_slot'].map(slot => { @@ -155,7 +156,7 @@ frappe.ui.form.on('Patient Appointment', { } start_time = booked_moment; let end_time = booked_moment.add(booked.duration, 'minutes'); - if(end_time.isSameOrAfter(to_time)){ + if(end_time.isSameOrAfter(to_time) || end_time.add(duration).isAfter(to_time)){ disabled = 'disabled="disabled"'; return false; }else{ @@ -163,9 +164,10 @@ frappe.ui.form.on('Patient Appointment', { } } }); + return `