refactor: Patient Appointment status
This commit is contained in:
parent
7c66975040
commit
41bd317e25
@ -108,15 +108,6 @@ frappe.ui.form.on('Patient Appointment', {
|
||||
}, __('Create'));
|
||||
}
|
||||
|
||||
if (frm.doc.status == 'Pending') {
|
||||
frm.add_custom_button(__('Set Open'), function() {
|
||||
update_status(frm, 'Open');
|
||||
});
|
||||
frm.add_custom_button(__('Cancel'), function() {
|
||||
update_status(frm, 'Cancelled');
|
||||
});
|
||||
}
|
||||
|
||||
frappe.db.get_value('Healthcare Settings', {name: 'Healthcare Settings'}, 'automate_appointment_invoicing', (settings) => {
|
||||
if (settings.automate_appointment_invoicing) {
|
||||
frm.set_df_property('mode_of_payment', 'hidden', 0);
|
||||
|
@ -89,7 +89,7 @@
|
||||
"in_filter": 1,
|
||||
"in_list_view": 1,
|
||||
"label": "Status",
|
||||
"options": "\nScheduled\nOpen\nClosed\nPending\nCancelled",
|
||||
"options": "\nScheduled\nOpen\nClosed\nCancelled",
|
||||
"read_only": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
@ -257,8 +257,7 @@
|
||||
"fieldtype": "Link",
|
||||
"ignore_user_permissions": 1,
|
||||
"label": "Referring Practitioner",
|
||||
"options": "Healthcare Practitioner",
|
||||
"set_only_once": 1
|
||||
"options": "Healthcare Practitioner"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
@ -278,7 +277,7 @@
|
||||
}
|
||||
],
|
||||
"links": [],
|
||||
"modified": "2020-02-25 11:29:26.988952",
|
||||
"modified": "2020-02-25 13:09:50.055119",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Healthcare",
|
||||
"name": "Patient Appointment",
|
||||
|
@ -20,6 +20,7 @@ class PatientAppointment(Document):
|
||||
self.validate_overlaps()
|
||||
self.set_appointment_datetime()
|
||||
self.validate_customer_created()
|
||||
self.set_status()
|
||||
|
||||
def after_insert(self):
|
||||
invoice_appointment(self)
|
||||
@ -27,14 +28,17 @@ class PatientAppointment(Document):
|
||||
self.check_fee_validity()
|
||||
send_confirmation_msg(self)
|
||||
|
||||
def on_update(self):
|
||||
def set_status(self):
|
||||
today = getdate()
|
||||
appointment_date = getdate(self.appointment_date)
|
||||
|
||||
# If appointment is created for today set status as Open
|
||||
if today == appointment_date:
|
||||
frappe.db.set_value('Patient Appointment', self.name, 'status', 'Open')
|
||||
self.reload()
|
||||
# If appointment is created for today set status as Open else Scheduled
|
||||
if appointment_date == today:
|
||||
self.status = 'Open'
|
||||
elif appointment_date > today:
|
||||
self.status = 'Scheduled'
|
||||
elif appointment_date < today:
|
||||
self.status = 'Expired'
|
||||
|
||||
def validate_overlaps(self):
|
||||
end_time = datetime.datetime.combine(getdate(self.appointment_date), get_time(self.appointment_time)) \
|
||||
@ -427,3 +431,12 @@ def get_procedure_prescribed(patient):
|
||||
from `tabPatient Encounter` ct, `tabProcedure Prescription` pp
|
||||
where ct.patient='{0}' and pp.parent=ct.name and pp.appointment_booked=0
|
||||
order by ct.creation desc""".format(patient))
|
||||
|
||||
def update_appointment_status():
|
||||
# update the status of appointments daily
|
||||
|
||||
frappe.db.sql("""update `tabPatient Appointment` set status = 'Open'
|
||||
where appointment_date = CURDATE() and status = 'Scheduled'""")
|
||||
|
||||
frappe.db.sql("""update `tabPatient Appointment` set status = 'Expired'
|
||||
where appointment_date < CURDATE() and status NOT IN ('Closed', 'Cancelled')""")
|
@ -3,4 +3,14 @@
|
||||
*/
|
||||
frappe.listview_settings['Patient Appointment'] = {
|
||||
filters: [["status", "=", "Open"]],
|
||||
get_indicator: function(doc) {
|
||||
var colors = {
|
||||
"Open": "orange",
|
||||
"Scheduled": "yellow",
|
||||
"Closed": "green",
|
||||
"Cancelled": "red",
|
||||
"Expired": "grey"
|
||||
};
|
||||
return [__(doc.status), colors[doc.status], "status,=," + doc.status];
|
||||
}
|
||||
};
|
||||
|
@ -309,7 +309,8 @@ scheduler_events = {
|
||||
"erpnext.support.doctype.service_level_agreement.service_level_agreement.check_agreement_status",
|
||||
"erpnext.crm.doctype.email_campaign.email_campaign.send_email_to_leads_or_contacts",
|
||||
"erpnext.crm.doctype.email_campaign.email_campaign.set_email_campaign_status",
|
||||
"erpnext.selling.doctype.quotation.quotation.set_expired_status"
|
||||
"erpnext.selling.doctype.quotation.quotation.set_expired_status",
|
||||
"erpnext.healthcare_healthcare.doctype.patient_appointment.patient_appointment.update_appointment_status"
|
||||
],
|
||||
"daily_long": [
|
||||
"erpnext.setup.doctype.email_digest.email_digest.send",
|
||||
|
Loading…
Reference in New Issue
Block a user