Esempio n. 1
0
def notify_about_linked_phrs(profile_id,
                             email_msg=None,
                             text_msg=None,
                             entity=None,
                             user_name=None):
    linked_phr = frappe.db.sql("""select profile_id from 
		`tabNotification Configuration` 
		where linked_phr=1 and profile_id='%s'""" % (profile_id))
    if linked_phr:
        user = frappe.get_doc(
            'User',
            frappe.db.get_value("User", {"profile_id": profile_id}, "name"))
        if user:
            send_phrs_mail(user.name,
                           "HealthSnapp Updates:" + entity + " Updated",
                           "templates/emails/linked_phrs_updates.html", {
                               "user_name": user_name,
                               "entity": entity
                           })
            if frappe.db.get_value("Mobile Verification", {
                    "mobile_no": user.contact,
                    "mflag": 1
            }, "name"):
                rec_list = []
                rec_list.append(user.contact)
                send_sms(rec_list, msg=text_msg)
        else:
            from phr.templates.pages.dashboard import search_profile_data_from_solr
            search_profile_data_from_solr(profile_id)
Esempio n. 2
0
def notify_about_linked_phrs(profile_id,email_msg=None,text_msg=None,entity=None,user_name=None):
	linked_phr = frappe.db.sql("""select profile_id from 
		`tabNotification Configuration` 
		where linked_phr=1 and profile_id='%s'"""%(profile_id))
	if linked_phr:
		user = frappe.get_doc('User',frappe.db.get_value("User",{"profile_id":profile_id},"name"))
		if user:
			send_phrs_mail(user.name,"HealthSnapp Updates:"+entity+" Updated","templates/emails/linked_phrs_updates.html",{"user_name":user_name,"entity":entity})
			if frappe.db.get_value("Mobile Verification",{"mobile_no":user.contact,"mflag":1},"name"):
				rec_list = []
				rec_list.append(user.contact)
				send_sms(rec_list,msg=text_msg)
		else:
			from phr.templates.pages.dashboard import search_profile_data_from_solr
			search_profile_data_from_solr(profile_id)
Esempio n. 3
0
def send_notification(profile_list):
    print "##########Appointments#############"
    print profile_list
    msg = {}
    for profile in profile_list:
        user = frappe.db.get_value("User",
                                   {"profile_id": profile['profile_id']},
                                   "name")
        msgg = get_sms_template(
            "appointments", {
                "doctor_name": profile['provider_name'],
                "appointment_time": profile['time']
            })
        if user:
            pobj = frappe.get_doc('User', user)
            send_phr_sms(pobj.contact, msg=msgg)
        else:
            data = search_profile_data_from_solr(profile['profile_id'])
            if data:
                child = data['childProfile']
                parent = data['parentProfile']
                if child['mobile'] and frappe.db.get_value(
                        "Mobile Verification", {
                            "mobile_no": child['mobile'],
                            "mflag": 1
                        }, "name"):
                    send_phr_sms(child['mobile'], msg=msgg)
                else:
                    send_phr_sms(parent['mobile'], msg=msgg)
Esempio n. 4
0
def notify_to_do():
	profile_ids = get_profile_ids()
	print "########## TODO #############"
	print profile_ids
	if profile_ids:
		msg={}
		email_msg={}
		for profile in profile_ids:
			user = frappe.db.get_value("User",{"profile_id":profile['profile_id']},"name")
			todoobj = frappe.get_doc('ToDo',profile['name'])
			msgg = get_sms_template("todo",{"to_do":todoobj.description})
			if user:
				pobj = frappe.get_doc('User',user)
				send_phr_sms(pobj.contact,msg=msgg)
				send_phrs_mail(pobj.name,"PHR:To Do Alert","templates/emails/todo.html",{"todo":todoobj.description,"name":pobj.first_name})
			else:
				data = search_profile_data_from_solr(profile['profile_id'])
				
				if data:
					child = data['childProfile']
					
					if child['mobile'] and frappe.db.get_value("Mobile Verification",{"mobile_no":child['mobile'],"mflag":1},"name"):
						send_phr_sms(child['mobile'],msg=msgg)
					else:
						parent = data['parentProfile']
						send_phr_sms(parent['mobile'],msg=msgg)
					
					if child['email']:
						send_phrs_mail(child['email'],"PHR:To Do Alert","templates/emails/todo.html",{"todo":todoobj.description,"name":data["person_firstname"]})
					else:
						send_phrs_mail(parent['email'],"PHR:To Do Alert","templates/emails/todo.html",{"todo":todoobj.description,"name":data["person_firstname"]})	
Esempio n. 5
0
def notify_to_do():
    profile_ids = get_profile_ids()
    print "########## TODO #############"
    print profile_ids
    if profile_ids:
        msg = {}
        email_msg = {}
        for profile in profile_ids:
            user = frappe.db.get_value("User",
                                       {"profile_id": profile['profile_id']},
                                       "name")
            todoobj = frappe.get_doc('ToDo', profile['name'])
            msgg = get_sms_template("todo", {"to_do": todoobj.description})
            if user:
                pobj = frappe.get_doc('User', user)
                send_phr_sms(pobj.contact, msg=msgg)
                send_phrs_mail(pobj.name, "PHR:To Do Alert",
                               "templates/emails/todo.html", {
                                   "todo": todoobj.description,
                                   "name": pobj.first_name
                               })
            else:
                data = search_profile_data_from_solr(profile['profile_id'])

                if data:
                    child = data['childProfile']

                    if child['mobile'] and frappe.db.get_value(
                            "Mobile Verification", {
                                "mobile_no": child['mobile'],
                                "mflag": 1
                            }, "name"):
                        send_phr_sms(child['mobile'], msg=msgg)
                    else:
                        parent = data['parentProfile']
                        send_phr_sms(parent['mobile'], msg=msgg)

                    if child['email']:
                        send_phrs_mail(
                            child['email'], "PHR:To Do Alert",
                            "templates/emails/todo.html", {
                                "todo": todoobj.description,
                                "name": data["person_firstname"]
                            })
                    else:
                        send_phrs_mail(
                            parent['email'], "PHR:To Do Alert",
                            "templates/emails/todo.html", {
                                "todo": todoobj.description,
                                "name": data["person_firstname"]
                            })
Esempio n. 6
0
def send_notification(profile_list):
	print "##########Appointments#############"
	print profile_list
	msg={}
	for profile in profile_list:
		user = frappe.db.get_value("User",{"profile_id":profile['profile_id']},"name")
		msgg = get_sms_template("appointments",{"doctor_name":profile['provider_name'],"appointment_time":profile['time']})
		if user:
			pobj = frappe.get_doc('User',user)
			send_phr_sms(pobj.contact,msg=msgg)
		else:
			data = search_profile_data_from_solr(profile['profile_id'])
			if data:
				child = data['childProfile']
				parent = data['parentProfile']
				if child['mobile'] and frappe.db.get_value("Mobile Verification",{"mobile_no":child['mobile'],"mflag":1},"name"):
					send_phr_sms(child['mobile'],msg=msgg)
				else:
					send_phr_sms(parent['mobile'],msg=msgg)		
Esempio n. 7
0
def fetch_data_from_medications(med_list, recipient_list):
    if med_list:
        msg = {}
        for md in med_list:
            sms_send = True
            mobj = frappe.get_doc("Medication", md)
            week = [
                'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday',
                'Saturday', 'Sunday'
            ]
            import datetime
            now_day = datetime.datetime.today().weekday()
            fobj = frappe.get_doc("Dosage", mobj.dosage)
            options = json.loads(mobj.options)

            if mobj.dosage == "Weekly":
                if options['day'] != week[now_day]:
                    sms_send = False

            if sms_send:
                for d in fobj.get('dosage_fields'):
                    time_diff = 0
                    if d.fieldtype == "time":
                        time_now = datetime.datetime.strftime(
                            datetime.datetime.now(), '%H:%M')
                        if options.get(d.fieldname):
                            med_time = datetime.datetime.strptime(
                                options[d.fieldname],
                                '%I:%M %p').strftime('%H:%M')
                            time_diff = cint(
                                (datetime.datetime.strptime(time_now, '%H:%M')
                                 - datetime.datetime.strptime(
                                     med_time, '%H:%M')).total_seconds() / 60)

                    elif d.fieldname == "datetime":
                        now_time = datetime.datetime.strftime(
                            datetime.datetime.now(), '%Y-%m-%d %H:%M:%S.%f')
                        now_time_str = datetime.datetime.strptime(
                            now_time, '%Y-%m-%d %H:%M:%S.%f')
                        if options.get(d.fieldname):
                            med_time = datetime.datetime.strptime(
                                options[d.fieldname], '%Y-%m-%d %H:%M:%S.%f')
                            time_diff = cint(
                                (now_time - med_time).total_seconds() / 60)

                    if time_diff and (time_diff >= 0 and time_diff <= 5):
                        uexists = frappe.db.get_value(
                            "User", {"profile_id": mobj.profile_id}, "name")
                        msgg = get_sms_template(
                            "medication",
                            {"medication": mobj.get('medicine_name')})
                        if uexists:
                            user = frappe.get_doc("User", uexists)
                            send_phr_sms(user.contact, msg=msgg)
                        else:
                            data = search_profile_data_from_solr(
                                mobj.profile_id)
                            if data:
                                child = data['childProfile']
                                if child['mobile'] and frappe.db.get_value(
                                        "Mobile Verification", {
                                            "mobile_no": child['mobile'],
                                            "mflag": 1
                                        }, "name"):
                                    send_phr_sms(child['mobile'], msg=msgg)
                                else:
                                    parent = data['parentProfile']
                                    send_phr_sms(parent['mobile'], msg=msgg)
        return "done"