Merge branch 'hotfix'
This commit is contained in:
commit
5235aa833c
@ -4,7 +4,7 @@ import inspect
|
|||||||
import frappe
|
import frappe
|
||||||
from erpnext.hooks import regional_overrides
|
from erpnext.hooks import regional_overrides
|
||||||
|
|
||||||
__version__ = '9.2.0'
|
__version__ = '9.2.1'
|
||||||
|
|
||||||
def get_default_company(user=None):
|
def get_default_company(user=None):
|
||||||
'''Get default company for user'''
|
'''Get default company for user'''
|
||||||
|
@ -200,7 +200,7 @@ def update_doc(new_document, reference_doc, args, schedule_date):
|
|||||||
new_document.run_method("on_recurring", reference_doc=reference_doc, subscription_doc=args)
|
new_document.run_method("on_recurring", reference_doc=reference_doc, subscription_doc=args)
|
||||||
|
|
||||||
def set_subscription_period(args, mcount, new_document):
|
def set_subscription_period(args, mcount, new_document):
|
||||||
if new_document.meta.get_field('from_date') and new_document.meta.get_field('to_date'):
|
if mcount and new_document.meta.get_field('from_date') and new_document.meta.get_field('to_date'):
|
||||||
last_ref_doc = frappe.db.sql("""
|
last_ref_doc = frappe.db.sql("""
|
||||||
select name, from_date, to_date
|
select name, from_date, to_date
|
||||||
from `tab{0}`
|
from `tab{0}`
|
||||||
|
@ -19,13 +19,13 @@ class TestFeeValidity(unittest.TestCase):
|
|||||||
patient = frappe.new_doc("Patient")
|
patient = frappe.new_doc("Patient")
|
||||||
patient.patient_name = "Test Patient"
|
patient.patient_name = "Test Patient"
|
||||||
patient.sex = "Male"
|
patient.sex = "Male"
|
||||||
patient.save(ignore_permissions = True)
|
patient.save(ignore_permissions=True)
|
||||||
patient = patient.name
|
patient = patient.name
|
||||||
|
|
||||||
if not physician:
|
if not physician:
|
||||||
physician = frappe.new_doc("Physician")
|
physician = frappe.new_doc("Physician")
|
||||||
physician.first_name= "Amit Jain"
|
physician.first_name = "Amit Jain"
|
||||||
physician.save(ignore_permissions = True)
|
physician.save(ignore_permissions=True)
|
||||||
physician = physician.name
|
physician = physician.name
|
||||||
|
|
||||||
frappe.db.set_value("Healthcare Settings", None, "max_visit", 2)
|
frappe.db.set_value("Healthcare Settings", None, "max_visit", 2)
|
||||||
@ -50,5 +50,5 @@ def create_appointment(patient, physician, appointment_date):
|
|||||||
appointment.patient = patient
|
appointment.patient = patient
|
||||||
appointment.physician = physician
|
appointment.physician = physician
|
||||||
appointment.appointment_date = appointment_date
|
appointment.appointment_date = appointment_date
|
||||||
appointment.save(ignore_permissions = True)
|
appointment.save(ignore_permissions=True)
|
||||||
return appointment
|
return appointment
|
||||||
|
@ -30,6 +30,14 @@ frappe.ui.form.on('Patient Appointment', {
|
|||||||
frm.add_custom_button(__('Cancel'), function() {
|
frm.add_custom_button(__('Cancel'), function() {
|
||||||
btn_update_status(frm, "Cancelled");
|
btn_update_status(frm, "Cancelled");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
frm.add_custom_button(__("Consultation"),function(){
|
||||||
|
btn_create_consultation(frm);
|
||||||
|
},"Create");
|
||||||
|
|
||||||
|
frm.add_custom_button(__('Vital Signs'), function() {
|
||||||
|
btn_create_vital_signs(frm);
|
||||||
|
},"Create");
|
||||||
}
|
}
|
||||||
if(frm.doc.status == "Pending"){
|
if(frm.doc.status == "Pending"){
|
||||||
frm.add_custom_button(__('Set Open'), function() {
|
frm.add_custom_button(__('Set Open'), function() {
|
||||||
@ -40,14 +48,6 @@ frappe.ui.form.on('Patient Appointment', {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
frm.add_custom_button(__("Consultation"),function(){
|
|
||||||
btn_create_consultation(frm);
|
|
||||||
},"Create");
|
|
||||||
|
|
||||||
frm.add_custom_button(__('Vital Signs'), function() {
|
|
||||||
btn_create_vital_signs(frm);
|
|
||||||
},"Create");
|
|
||||||
|
|
||||||
if(!frm.doc.__islocal){
|
if(!frm.doc.__islocal){
|
||||||
if(frm.doc.sales_invoice && frappe.user.has_role("Accounts User")){
|
if(frm.doc.sales_invoice && frappe.user.has_role("Accounts User")){
|
||||||
frm.add_custom_button(__('Invoice'), function() {
|
frm.add_custom_button(__('Invoice'), function() {
|
||||||
@ -188,7 +188,7 @@ var btn_update_status = function(frm, status){
|
|||||||
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: {appointmentId: 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();
|
||||||
|
@ -234,6 +234,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"depends_on": "eval:!doc.__islocal",
|
||||||
"fieldname": "section_break_1",
|
"fieldname": "section_break_1",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -755,7 +756,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2017-10-05 12:13:03.204936",
|
"modified": "2017-10-25 23:33:36.060803",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Healthcare",
|
"module": "Healthcare",
|
||||||
"name": "Patient Appointment",
|
"name": "Patient Appointment",
|
||||||
|
@ -6,66 +6,100 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
import json
|
import json
|
||||||
from frappe.utils import getdate
|
from frappe.utils import getdate, cint
|
||||||
from frappe import _
|
from frappe import _
|
||||||
import datetime
|
import datetime
|
||||||
from frappe.core.doctype.sms_settings.sms_settings import send_sms
|
from frappe.core.doctype.sms_settings.sms_settings import send_sms
|
||||||
from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account,get_income_account
|
from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account,get_income_account
|
||||||
|
|
||||||
|
|
||||||
class PatientAppointment(Document):
|
class PatientAppointment(Document):
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
today = datetime.date.today()
|
today = datetime.date.today()
|
||||||
appointment_date = getdate(self.appointment_date)
|
appointment_date = getdate(self.appointment_date)
|
||||||
#If appointment created for today set as open
|
|
||||||
if(today == appointment_date):
|
# If appointment created for today set as open
|
||||||
frappe.db.set_value("Patient Appointment",self.name,"status","Open")
|
if today == appointment_date:
|
||||||
|
frappe.db.set_value("Patient Appointment", self.name, "status", "Open")
|
||||||
self.reload()
|
self.reload()
|
||||||
|
|
||||||
def after_insert(self):
|
def after_insert(self):
|
||||||
#Check fee validity exists
|
# Check fee validity exists
|
||||||
appointment = self
|
appointment = self
|
||||||
validity_exist = validity_exists(appointment.physician, appointment.patient)
|
validity_exist = validity_exists(appointment.physician, appointment.patient)
|
||||||
if validity_exist :
|
if validity_exist:
|
||||||
fee_validity = frappe.get_doc("Fee Validity",validity_exist[0][0])
|
fee_validity = frappe.get_doc("Fee Validity", validity_exist[0][0])
|
||||||
#Check if the validity is valid
|
|
||||||
|
# Check if the validity is valid
|
||||||
appointment_date = getdate(appointment.appointment_date)
|
appointment_date = getdate(appointment.appointment_date)
|
||||||
if((fee_validity.valid_till >= appointment_date) and (fee_validity.visited < fee_validity.max_visit)):
|
if (fee_validity.valid_till >= appointment_date) and (fee_validity.visited < fee_validity.max_visit):
|
||||||
visited = fee_validity.visited + 1
|
visited = fee_validity.visited + 1
|
||||||
frappe.db.set_value("Fee Validity",fee_validity.name,"visited",visited)
|
frappe.db.set_value("Fee Validity", fee_validity.name, "visited", visited)
|
||||||
if(fee_validity.ref_invoice):
|
if fee_validity.ref_invoice:
|
||||||
frappe.db.set_value("Patient Appointment",appointment.name,"sales_invoice",fee_validity.ref_invoice)
|
frappe.db.set_value("Patient Appointment", appointment.name, "sales_invoice", fee_validity.ref_invoice)
|
||||||
frappe.msgprint(_("{0} has fee validity till {1}").format(appointment.patient, fee_validity.valid_till))
|
frappe.msgprint(_("{0} has fee validity till {1}").format(appointment.patient, fee_validity.valid_till))
|
||||||
confirm_sms(self)
|
confirm_sms(self)
|
||||||
|
|
||||||
def appointment_cancel(appointmentId):
|
def save(self, *args, **kwargs):
|
||||||
appointment = frappe.get_doc("Patient Appointment",appointmentId)
|
# duration is the only changeable field in the document
|
||||||
#If invoice --> fee_validity update with -1 visit
|
if not self.is_new():
|
||||||
if (appointment.sales_invoice):
|
self.db_set('duration', cint(self.duration))
|
||||||
validity = frappe.db.exists({"doctype": "Fee Validity","ref_invoice": appointment.sales_invoice})
|
else:
|
||||||
if(validity):
|
super(PatientAppointment, self).save(*args, **kwargs)
|
||||||
fee_validity = frappe.get_doc("Fee Validity",validity[0][0])
|
|
||||||
visited = fee_validity.visited - 1
|
|
||||||
frappe.db.set_value("Fee Validity",fee_validity.name,"visited",visited)
|
def appointment_cancel(appointment_id):
|
||||||
if visited <= 0:
|
appointment = frappe.get_doc("Patient Appointment", appointment_id)
|
||||||
frappe.msgprint(_("Appointment cancelled, Please review and cancel the invoice {0}".format(appointment.sales_invoice)))
|
|
||||||
else:
|
# If invoice --> fee_validity update with -1 visit
|
||||||
frappe.msgprint(_("Appointment cancelled"))
|
if appointment.sales_invoice:
|
||||||
|
validity = frappe.db.exists({"doctype": "Fee Validity", "ref_invoice": appointment.sales_invoice})
|
||||||
|
if validity:
|
||||||
|
fee_validity = frappe.get_doc("Fee Validity", validity[0][0])
|
||||||
|
visited = fee_validity.visited - 1
|
||||||
|
frappe.db.set_value("Fee Validity", fee_validity.name, "visited", visited)
|
||||||
|
if visited <= 0:
|
||||||
|
frappe.msgprint(
|
||||||
|
_("Appointment cancelled, Please review and cancel the invoice {0}".format(appointment.sales_invoice))
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
frappe.msgprint(_("Appointment cancelled"))
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_availability_data(date, physician):
|
def get_availability_data(date, physician):
|
||||||
# get availability data of 'physician' on 'date'
|
"""
|
||||||
|
Get availability data of 'physician' on 'date'
|
||||||
|
:param date: Date to check in schedule
|
||||||
|
:param physician: Name of the physician
|
||||||
|
:return: dict containing a list of available slots, list of appointments and time of appointments
|
||||||
|
"""
|
||||||
|
|
||||||
date = getdate(date)
|
date = getdate(date)
|
||||||
weekday = date.strftime("%A")
|
weekday = date.strftime("%A")
|
||||||
|
|
||||||
available_slots = []
|
available_slots = []
|
||||||
|
physician_schedule_name = None
|
||||||
|
physician_schedule = None
|
||||||
|
time_per_appointment = None
|
||||||
|
|
||||||
# get physicians schedule
|
# get physicians schedule
|
||||||
physician_schedule_name = frappe.db.get_value("Physician", physician, "physician_schedule")
|
physician_schedule_name = frappe.db.get_value("Physician", physician, "physician_schedule")
|
||||||
physician_schedule = frappe.get_doc("Physician Schedule", physician_schedule_name)
|
if physician_schedule_name:
|
||||||
time_per_appointment = frappe.db.get_value("Physician", physician, "time_per_appointment")
|
physician_schedule = frappe.get_doc("Physician Schedule", physician_schedule_name)
|
||||||
|
time_per_appointment = frappe.db.get_value("Physician", physician, "time_per_appointment")
|
||||||
|
else:
|
||||||
|
frappe.throw(_("Dr {0} does not have a Physician Schedule. Add it in Physician master".format(physician)))
|
||||||
|
|
||||||
for t in physician_schedule.time_slots:
|
if physician_schedule:
|
||||||
if weekday == t.day:
|
for t in physician_schedule.time_slots:
|
||||||
available_slots.append(t)
|
if weekday == t.day:
|
||||||
|
available_slots.append(t)
|
||||||
|
|
||||||
|
# `time_per_appointment` should never be None since validation in `Patient` is supposed to prevent
|
||||||
|
# that. However, it isn't impossible so we'll prepare for that.
|
||||||
|
if not time_per_appointment:
|
||||||
|
frappe.throw(_('"Time Per Appointment" hasn"t been set for Dr {0}. Add it in Physician master.').format(physician))
|
||||||
|
|
||||||
# if physician not available return
|
# if physician not available return
|
||||||
if not available_slots:
|
if not available_slots:
|
||||||
@ -89,27 +123,36 @@ def get_availability_data(date, physician):
|
|||||||
"time_per_appointment": time_per_appointment
|
"time_per_appointment": time_per_appointment
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def update_status(appointmentId, status):
|
def update_status(appointment_id, status):
|
||||||
frappe.db.set_value("Patient Appointment",appointmentId,"status",status)
|
frappe.db.set_value("Patient Appointment", appointment_id, "status", status)
|
||||||
if(status=="Cancelled"):
|
if status == "Cancelled":
|
||||||
appointment_cancel(appointmentId)
|
appointment_cancel(appointment_id)
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def set_open_appointments():
|
def set_open_appointments():
|
||||||
today = getdate()
|
today = getdate()
|
||||||
frappe.db.sql("""update `tabPatient Appointment` set status='Open' where status = 'Scheduled' and appointment_date = %s""",(today))
|
frappe.db.sql(
|
||||||
|
"update `tabPatient Appointment` set status='Open' where status = 'Scheduled'"
|
||||||
|
" and appointment_date = %s", today)
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def set_pending_appointments():
|
def set_pending_appointments():
|
||||||
today = getdate()
|
today = getdate()
|
||||||
frappe.db.sql("""update `tabPatient Appointment` set status='Pending' where status in ('Scheduled','Open') and appointment_date < %s""",(today))
|
frappe.db.sql(
|
||||||
|
"update `tabPatient Appointment` set status='Pending' where status in "
|
||||||
|
"('Scheduled','Open') and appointment_date < %s", today)
|
||||||
|
|
||||||
|
|
||||||
def confirm_sms(doc):
|
def confirm_sms(doc):
|
||||||
if (frappe.db.get_value("Healthcare Settings", None, "app_con")=='1'):
|
if frappe.db.get_value("Healthcare Settings", None, "app_con") == '1':
|
||||||
message = frappe.db.get_value("Healthcare Settings", None, "app_con_msg")
|
message = frappe.db.get_value("Healthcare Settings", None, "app_con_msg")
|
||||||
send_message(doc, message)
|
send_message(doc, message)
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def create_invoice(company, physician, patient, appointment_id, appointment_date):
|
def create_invoice(company, physician, patient, appointment_id, appointment_date):
|
||||||
if not appointment_id:
|
if not appointment_id:
|
||||||
@ -134,21 +177,24 @@ def create_invoice(company, physician, patient, appointment_id, appointment_date
|
|||||||
frappe.db.set_value("Consultation", consultation[0][0], "invoice", sales_invoice.name)
|
frappe.db.set_value("Consultation", consultation[0][0], "invoice", sales_invoice.name)
|
||||||
return sales_invoice.name
|
return sales_invoice.name
|
||||||
|
|
||||||
|
|
||||||
def get_fee_validity(physician, patient, date):
|
def get_fee_validity(physician, patient, date):
|
||||||
validity_exist = validity_exists(physician, patient)
|
validity_exist = validity_exists(physician, patient)
|
||||||
if validity_exist :
|
if validity_exist:
|
||||||
fee_validity = frappe.get_doc("Fee Validity",validity_exist[0][0])
|
fee_validity = frappe.get_doc("Fee Validity", validity_exist[0][0])
|
||||||
fee_validity = update_fee_validity(fee_validity, date)
|
fee_validity = update_fee_validity(fee_validity, date)
|
||||||
else:
|
else:
|
||||||
fee_validity = create_fee_validity(physician, patient, date)
|
fee_validity = create_fee_validity(physician, patient, date)
|
||||||
return fee_validity
|
return fee_validity
|
||||||
|
|
||||||
|
|
||||||
def validity_exists(physician, patient):
|
def validity_exists(physician, patient):
|
||||||
return frappe.db.exists({
|
return frappe.db.exists({
|
||||||
"doctype": "Fee Validity",
|
"doctype": "Fee Validity",
|
||||||
"physician": physician,
|
"physician": physician,
|
||||||
"patient": patient})
|
"patient": patient})
|
||||||
|
|
||||||
|
|
||||||
def update_fee_validity(fee_validity, date):
|
def update_fee_validity(fee_validity, date):
|
||||||
max_visit = frappe.db.get_value("Healthcare Settings", None, "max_visit")
|
max_visit = frappe.db.get_value("Healthcare Settings", None, "max_visit")
|
||||||
valid_days = frappe.db.get_value("Healthcare Settings", None, "valid_days")
|
valid_days = frappe.db.get_value("Healthcare Settings", None, "valid_days")
|
||||||
@ -164,6 +210,7 @@ def update_fee_validity(fee_validity, date):
|
|||||||
fee_validity.save(ignore_permissions=True)
|
fee_validity.save(ignore_permissions=True)
|
||||||
return fee_validity
|
return fee_validity
|
||||||
|
|
||||||
|
|
||||||
def create_fee_validity(physician, patient, date):
|
def create_fee_validity(physician, patient, date):
|
||||||
fee_validity = frappe.new_doc("Fee Validity")
|
fee_validity = frappe.new_doc("Fee Validity")
|
||||||
fee_validity.physician = physician
|
fee_validity.physician = physician
|
||||||
@ -171,6 +218,7 @@ def create_fee_validity(physician, patient, date):
|
|||||||
fee_validity = update_fee_validity(fee_validity, date)
|
fee_validity = update_fee_validity(fee_validity, date)
|
||||||
return fee_validity
|
return fee_validity
|
||||||
|
|
||||||
|
|
||||||
def create_invoice_items(appointment_id, physician, company, invoice):
|
def create_invoice_items(appointment_id, physician, company, invoice):
|
||||||
item_line = invoice.append("items")
|
item_line = invoice.append("items")
|
||||||
item_line.item_name = "Consulting Charges"
|
item_line.item_name = "Consulting Charges"
|
||||||
@ -178,16 +226,17 @@ def create_invoice_items(appointment_id, physician, company, invoice):
|
|||||||
item_line.qty = 1
|
item_line.qty = 1
|
||||||
item_line.uom = "Nos"
|
item_line.uom = "Nos"
|
||||||
item_line.conversion_factor = 1
|
item_line.conversion_factor = 1
|
||||||
item_line.income_account = get_income_account(physician,company)
|
item_line.income_account = get_income_account(physician, company)
|
||||||
op_consulting_charge = frappe.db.get_value("Physician", physician, "op_consulting_charge")
|
op_consulting_charge = frappe.db.get_value("Physician", physician, "op_consulting_charge")
|
||||||
if op_consulting_charge:
|
if op_consulting_charge:
|
||||||
item_line.rate = op_consulting_charge
|
item_line.rate = op_consulting_charge
|
||||||
item_line.amount = op_consulting_charge
|
item_line.amount = op_consulting_charge
|
||||||
return invoice
|
return invoice
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def create_consultation(appointment):
|
def create_consultation(appointment):
|
||||||
appointment = frappe.get_doc("Patient Appointment",appointment)
|
appointment = frappe.get_doc("Patient Appointment", appointment)
|
||||||
consultation = frappe.new_doc("Consultation")
|
consultation = frappe.new_doc("Consultation")
|
||||||
consultation.appointment = appointment.name
|
consultation.appointment = appointment.name
|
||||||
consultation.patient = appointment.patient
|
consultation.patient = appointment.patient
|
||||||
@ -199,29 +248,37 @@ def create_consultation(appointment):
|
|||||||
consultation.invoice = appointment.sales_invoice
|
consultation.invoice = appointment.sales_invoice
|
||||||
return consultation.as_dict()
|
return consultation.as_dict()
|
||||||
|
|
||||||
|
|
||||||
def remind_appointment():
|
def remind_appointment():
|
||||||
if (frappe.db.get_value("Healthcare Settings", None, "app_rem")=='1'):
|
if frappe.db.get_value("Healthcare Settings", None, "app_rem") == '1':
|
||||||
rem_before = datetime.datetime.strptime(frappe.get_value("Healthcare Settings", None, "rem_before"), "%H:%M:%S")
|
rem_before = datetime.datetime.strptime(frappe.get_value("Healthcare Settings", None, "rem_before"), "%H:%M:%S")
|
||||||
rem_dt = datetime.datetime.now() + datetime.timedelta(hours = rem_before.hour, minutes=rem_before.minute, seconds= rem_before.second)
|
rem_dt = datetime.datetime.now() + datetime.timedelta(
|
||||||
|
hours=rem_before.hour, minutes=rem_before.minute, seconds=rem_before.second)
|
||||||
|
|
||||||
appointment_list = frappe.db.sql("select name from `tabPatient Appointment` where start_dt between %s and %s and reminded = 0 ", (datetime.datetime.now(), rem_dt))
|
appointment_list = frappe.db.sql(
|
||||||
|
"select name from `tabPatient Appointment` where start_dt between %s and %s and reminded = 0 ",
|
||||||
|
(datetime.datetime.now(), rem_dt)
|
||||||
|
)
|
||||||
|
|
||||||
for i in range (0,len(appointment_list)):
|
for i in range(0, len(appointment_list)):
|
||||||
doc = frappe.get_doc("Patient Appointment", appointment_list[i][0])
|
doc = frappe.get_doc("Patient Appointment", appointment_list[i][0])
|
||||||
message = frappe.db.get_value("Healthcare Settings", None, "app_rem_msg")
|
message = frappe.db.get_value("Healthcare Settings", None, "app_rem_msg")
|
||||||
send_message(doc, message)
|
send_message(doc, message)
|
||||||
frappe.db.set_value("Patient Appointment",doc.name,"reminded",1)
|
frappe.db.set_value("Patient Appointment", doc.name, "reminded",1)
|
||||||
|
|
||||||
|
|
||||||
def send_message(doc, message):
|
def send_message(doc, message):
|
||||||
patient = frappe.get_doc("Patient",doc.patient)
|
patient = frappe.get_doc("Patient", doc.patient)
|
||||||
if(patient.mobile):
|
if patient.mobile:
|
||||||
context = {"doc": doc, "alert": doc, "comments": None}
|
context = {"doc": doc, "alert": doc, "comments": None}
|
||||||
if doc.get("_comments"):
|
if doc.get("_comments"):
|
||||||
context["comments"] = json.loads(doc.get("_comments"))
|
context["comments"] = json.loads(doc.get("_comments"))
|
||||||
#jinja to string convertion happens here
|
|
||||||
|
# jinja to string convertion happens here
|
||||||
message = frappe.render_template(message, context)
|
message = frappe.render_template(message, context)
|
||||||
number = [patient.mobile]
|
number = [patient.mobile]
|
||||||
send_sms(number,message)
|
send_sms(number, message)
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_events(start, end, filters=None):
|
def get_events(start, end, filters=None):
|
||||||
|
@ -501,6 +501,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"description": "In minutes",
|
||||||
"fieldname": "time_per_appointment",
|
"fieldname": "time_per_appointment",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -809,7 +810,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2017-10-04 17:35:44.363742",
|
"modified": "2017-10-05 16:08:24.624644",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Healthcare",
|
"module": "Healthcare",
|
||||||
"name": "Physician",
|
"name": "Physician",
|
||||||
|
@ -20,22 +20,32 @@ class Physician(Document):
|
|||||||
[cstr(self.get(f)).strip() for f in ["first_name","middle_name","last_name"]]))
|
[cstr(self.get(f)).strip() for f in ["first_name","middle_name","last_name"]]))
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
|
self.validate_schedule_and_time()
|
||||||
validate_party_accounts(self)
|
validate_party_accounts(self)
|
||||||
|
|
||||||
if self.user_id:
|
if self.user_id:
|
||||||
self.validate_for_enabled_user_id()
|
self.validate_for_enabled_user_id()
|
||||||
self.validate_duplicate_user_id()
|
self.validate_duplicate_user_id()
|
||||||
existing_user_id = frappe.db.get_value("Physician", self.name, "user_id")
|
existing_user_id = frappe.db.get_value("Physician", self.name, "user_id")
|
||||||
if(self.user_id != existing_user_id):
|
if self.user_id != existing_user_id:
|
||||||
frappe.permissions.remove_user_permission(
|
frappe.permissions.remove_user_permission(
|
||||||
"Physician", self.name, existing_user_id)
|
"Physician", self.name, existing_user_id)
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
existing_user_id = frappe.db.get_value("Physician", self.name, "user_id")
|
existing_user_id = frappe.db.get_value("Physician", self.name, "user_id")
|
||||||
if existing_user_id:
|
if existing_user_id:
|
||||||
frappe.permissions.remove_user_permission(
|
frappe.permissions.remove_user_permission(
|
||||||
"Physician", self.name, existing_user_id)
|
"Physician", self.name, existing_user_id)
|
||||||
|
|
||||||
|
def validate_schedule_and_time(self):
|
||||||
|
if (self.physician_schedule or self.time_per_appointment) and \
|
||||||
|
not (self.physician_schedule and self.time_per_appointment):
|
||||||
|
frappe.msgprint(
|
||||||
|
_('Both "Physician Schedule" and Time Per Appointment" must be set for Dr {0}').format(
|
||||||
|
self.first_name),
|
||||||
|
title='Error', raise_exception=1, indicator='red'
|
||||||
|
)
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
if self.user_id:
|
if self.user_id:
|
||||||
frappe.permissions.add_user_permission("Physician", self.name, self.user_id)
|
frappe.permissions.add_user_permission("Physician", self.name, self.user_id)
|
||||||
|
@ -3,8 +3,35 @@
|
|||||||
# See license.txt
|
# See license.txt
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import unittest
|
import unittest
|
||||||
|
import frappe
|
||||||
|
|
||||||
|
test_dependencies = ['Physician Schedule']
|
||||||
|
|
||||||
# test_records = frappe.get_test_records('Physician')
|
|
||||||
|
|
||||||
class TestPhysician(unittest.TestCase):
|
class TestPhysician(unittest.TestCase):
|
||||||
pass
|
def tearDown(self):
|
||||||
|
frappe.delete_doc_if_exists('Physician', '_Testdoctor2', force=1)
|
||||||
|
|
||||||
|
def test_schedule_and_time(self):
|
||||||
|
physician = frappe.new_doc('Physician')
|
||||||
|
physician.first_name = '_Testdoctor2'
|
||||||
|
physician.physician_schedule = '_Test Testdoctor Schedule'
|
||||||
|
|
||||||
|
self.assertRaises(frappe.ValidationError, physician.insert)
|
||||||
|
|
||||||
|
physician.physician_schedule = ''
|
||||||
|
physician.time_per_appointment = 15
|
||||||
|
|
||||||
|
self.assertRaises(frappe.ValidationError, physician.insert)
|
||||||
|
|
||||||
|
physician.physician_schedule = '_Test Testdoctor Schedule'
|
||||||
|
physician.time_per_appointment = 15
|
||||||
|
|
||||||
|
physician.insert()
|
||||||
|
|
||||||
|
def test_new_physician_without_schedule(self):
|
||||||
|
physician = frappe.new_doc('Physician')
|
||||||
|
physician.first_name = '_Testdoctor2'
|
||||||
|
|
||||||
|
physician.insert()
|
||||||
|
self.assertEqual(frappe.get_value('Physician', '_Testdoctor2', 'first_name'), '_Testdoctor2')
|
||||||
|
@ -5,5 +5,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
|
||||||
class PhysicianSchedule(Document):
|
class PhysicianSchedule(Document):
|
||||||
pass
|
def autoname(self):
|
||||||
|
self.name = self.schedule_name
|
||||||
|
@ -569,7 +569,7 @@ def get_events(start, end, filters=None):
|
|||||||
where ((ifnull(planned_start_date, '0000-00-00')!= '0000-00-00') \
|
where ((ifnull(planned_start_date, '0000-00-00')!= '0000-00-00') \
|
||||||
and (planned_start_date <= %(end)s) \
|
and (planned_start_date <= %(end)s) \
|
||||||
and ((ifnull(planned_start_date, '0000-00-00')!= '0000-00-00') \
|
and ((ifnull(planned_start_date, '0000-00-00')!= '0000-00-00') \
|
||||||
and planned_end_date >= %(start)s)) {conditions}
|
and ifnull(planned_end_date, '2199-12-31 00:00:00') >= %(start)s)) {conditions}
|
||||||
""".format(conditions=conditions), {
|
""".format(conditions=conditions), {
|
||||||
"start": start,
|
"start": start,
|
||||||
"end": end
|
"end": end
|
||||||
|
@ -17,6 +17,8 @@ def execute():
|
|||||||
doc = frappe.get_doc(doctype, record)
|
doc = frappe.get_doc(doctype, record)
|
||||||
if doc.items:
|
if doc.items:
|
||||||
if not doc.schedule_date:
|
if not doc.schedule_date:
|
||||||
min_schedule_date = min([d.schedule_date for d in doc.items])
|
schedule_dates = [d.schedule_date for d in doc.items if d.schedule_date]
|
||||||
frappe.db.set_value(doctype, record,
|
if len(schedule_dates) > 0:
|
||||||
"schedule_date", min_schedule_date, update_modified=False)
|
min_schedule_date = min(schedule_dates)
|
||||||
|
frappe.db.set_value(doctype, record,
|
||||||
|
"schedule_date", min_schedule_date, update_modified=False)
|
@ -71,9 +71,9 @@ def get_items(start, page_length, price_list, item_group, search_value=""):
|
|||||||
|
|
||||||
def get_conditions(item_code, serial_no, batch_no, barcode):
|
def get_conditions(item_code, serial_no, batch_no, barcode):
|
||||||
if serial_no or batch_no or barcode:
|
if serial_no or batch_no or barcode:
|
||||||
return frappe.db.escape(item_code), "i.item_code = %(item_code)s"
|
return frappe.db.escape(item_code), "i.name = %(item_code)s"
|
||||||
|
|
||||||
condition = """(i.item_code like %(item_code)s
|
condition = """(i.name like %(item_code)s
|
||||||
or i.item_name like %(item_code)s)"""
|
or i.item_name like %(item_code)s)"""
|
||||||
|
|
||||||
return '%%%s%%'%(frappe.db.escape(item_code)), condition
|
return '%%%s%%'%(frappe.db.escape(item_code)), condition
|
||||||
|
@ -40,7 +40,7 @@ def setup_complete(args=None):
|
|||||||
|
|
||||||
frappe.local.message_log = []
|
frappe.local.message_log = []
|
||||||
domain_settings = frappe.get_single('Domain Settings')
|
domain_settings = frappe.get_single('Domain Settings')
|
||||||
domain_settings.set_active_domains([args.get('domain')])
|
domain_settings.set_active_domains([_(args.get('domain'))])
|
||||||
|
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
login_as_first_user(args)
|
login_as_first_user(args)
|
||||||
|
@ -4,12 +4,12 @@ frappe.listview_settings['Item'] = {
|
|||||||
filters: [["disabled", "=", "0"]],
|
filters: [["disabled", "=", "0"]],
|
||||||
|
|
||||||
get_indicator: function(doc) {
|
get_indicator: function(doc) {
|
||||||
if(doc.total_projected_qty < 0) {
|
if (doc.disabled) {
|
||||||
return [__("Shortage"), "red", "total_projected_qty,<,0"];
|
|
||||||
} else if (doc.disabled) {
|
|
||||||
return [__("Disabled"), "grey", "disabled,=,Yes"];
|
return [__("Disabled"), "grey", "disabled,=,Yes"];
|
||||||
} else if (doc.end_of_life && doc.end_of_life < frappe.datetime.get_today()) {
|
} else if (doc.end_of_life && doc.end_of_life < frappe.datetime.get_today()) {
|
||||||
return [__("Expired"), "grey", "end_of_life,<,Today"];
|
return [__("Expired"), "grey", "end_of_life,<,Today"];
|
||||||
|
} else if(doc.total_projected_qty < 0) {
|
||||||
|
return [__("Shortage"), "red", "total_projected_qty,<,0"];
|
||||||
} else if (doc.has_variants) {
|
} else if (doc.has_variants) {
|
||||||
return [__("Template"), "orange", "has_variants,=,Yes"];
|
return [__("Template"), "orange", "has_variants,=,Yes"];
|
||||||
} else if (doc.variant_of) {
|
} else if (doc.variant_of) {
|
||||||
|
Loading…
Reference in New Issue
Block a user