def ignore_time(self, time): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() try: with connection.cursor() as cursor: sql = 'update `time_table` set `accepted` = %s where id = %s' cursor.execute(sql, (False, time)) connection.commit() finally: connection.close()
def save(self): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() sql = 'INSERT INTO `mail` (`sender_id`,`receive_id`,`title`,`body`) VALUES (%s,%s,%s,%s)' try: with connection.cursor() as cursor: cursor.execute(sql, (self.sender_id,self.receiver_id,self.title,self.body)) connection.commit() finally: connection.close()
def make_pres(self, pid): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() try: with connection.cursor() as cursor: sql = 'insert into `prescription` ( `dr_id`, `p_id`) VALUES (%s,%s) ' cursor.execute(sql, (self.id, pid)) connection.commit() finally: connection.close() return "done"
def find_all_filter(time): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() sql = 'select * from `medicine` WHERE `expiration_date` > %s' try: with connection.cursor() as cursor: cursor.execute(sql,(time,)) result = cursor.fetchall() finally: connection.close() return result
def add_item(pres_id, item_id): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() try: with connection.cursor() as cursor: sql = 'insert into `prescription_item` ( `pr_id`, `item_id`) VALUES (%s,%s) ' cursor.execute(sql, (pres_id, item_id)) connection.commit() finally: connection.close() return "done"
def take_test(self, lab_prescription): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() sql = 'update `lab_prescription` set `isDone` = %s where id = %s' try: with connection.cursor() as cursor: cursor.execute(sql, (True, lab_prescription)) connection.commit() finally: connection.close() return
def get_all(p): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() sql = 'select * from `item` WHERE p_id =%s ' try: with connection.cursor() as cursor: cursor.execute(sql,(p,)) result = cursor.fetchall() finally: connection.close() return result
def lab_prescription(self, p, name): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() sql = 'INSERT INTO `lab_prescription`(`doctor_id`, `patient_id`, `name`) VALUES (%s,%s,%s)' try: with connection.cursor() as cursor: cursor.execute(sql, (self.id, p, name)) connection.commit() finally: connection.close()
def find_all(): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() sql = 'select * from `medicine` ' try: with connection.cursor() as cursor: cursor.execute(sql) result = cursor.fetchall() finally: connection.close() return result
def see_time_table(self): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() sql = 'select * from `time_table` where `dr_id` = %s ' try: with connection.cursor() as cursor: cursor.execute(sql, (self.id, )) result = cursor.fetchall() return result finally: connection.close()
def see_doctor_time(self,user): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() try: with connection.cursor() as cursor: sql = "SELECT * FROM `time` WHERE `user_id`=%s" cursor.execute(sql, (user.id,)) result = cursor.fetchall() finally: connection.close() return result
def see_messages(self): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() try: with connection.cursor() as cursor: sql = 'select * from `mail` where `receive_id` = %s ' cursor.execute(sql, (self.id, )) result = cursor.fetchall() return result finally: connection.close()
def set_doctors_time_table(doctor, days, hour): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() sql = 'INSERT INTO `time` (`dr_id`,`week_day`,`hours`) VALUES (%s,%s,%s)' try: with connection.cursor() as cursor: cursor.execute(sql, (doctor, days, hour)) connection.commit() finally: connection.close() return
def sign_up(user): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() sql = 'INSERT INTO `users` (`name`,`family`,`mobile_no`,`email`, `password`,`user_type`) VALUES (%s,%s,%s,%s,%s,%s)' try: with connection.cursor() as cursor: cursor.execute(sql, (user.name, user.family, user.mobile_no, user.email, user.password, user.user_type)) connection.commit() finally: connection.close()
def add_time(self): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() sql = 'INSERT INTO `time` (`user_id`,`week_day`,`hours`) VALUES (%s,%s,%s)' try: with connection.cursor() as cursor: cursor.execute(sql, (self.user.id, self.week_day,self.hour)) connection.commit() finally: connection.close() return
def add_item(self): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() sql = 'INSERT INTO `item` (`name`,`p_id`,`cost`) VALUES (%s,%s,%s)' try: with connection.cursor() as cursor: cursor.execute(sql, (self.name, self.p,self.cost)) connection.commit() finally: connection.close() return
def set_appoinetment(self,dr_id,p_id,weekday,hour): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() try: with connection.cursor() as cursor: sql = 'INSERT INTO `time_table` (`dr_id`,`p_id`,`week_day`,`hours`) VALUES (%s,%s,%s,%s)' cursor.execute(sql, (dr_id,p_id,weekday,hour)) connection.commit() finally: connection.close() return
def save_me(self, name, family, mobile_no, email, password): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() try: sql = "UPDATE `users` SET `name`=%s,`family`=%s,`mobile_no`=%s,`email`=%s,`password`=%s WHERE `email`=%s " with connection.cursor() as cursor: cursor.execute( sql, (name, family, mobile_no, email, password, self.email)) connection.commit() finally: connection.close()
def get_bed_data(self): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() try: with connection.cursor() as cursor: sql = "select * from `bed` as b " \ "inner join `patient_bed` pb on b.id = pb.bed_id " \ "where pb.patient_id = %s " cursor.execute(sql, (self.id, )) result = cursor.fetchone() return result finally: connection.close()
def see_prescription_history(pid): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() sql = 'select p.p_id,p.dr_id,i.name from `prescription` as p ' \ 'inner join `prescription_item` as pi on p.id = pi.pr_id ' \ 'inner join `item` as i on i.id = pi.item_id ' \ 'WHERE p.p_id = %s' try: with connection.cursor() as cursor: cursor.execute(sql, (pid, )) result = cursor.fetchall() return result finally: connection.close()
def get_bed(self): db = DB('localhost', 'root', 'db') connection = db.data_base_connection() try: with connection.cursor() as cursor: sql = "SELECT * FROM `bed` WHERE `isEmpty`=%s" cursor.execute(sql, (True, )) result = cursor.fetchone() sql = 'INSERT INTO `patient_bed` (`patient_id`,`bed_id`) VALUES (%s,%s)' cursor.execute(sql, (self.id, result['id'])) connection.commit() sql = 'update `bed` set `isEmpty` = %s where id = %s' cursor.execute(sql, (False, result['id'])) connection.commit() finally: connection.close() return "done"