def adding_account(): if request.method == 'POST': ssn = request.form['patient_ssn'] first_name = request.form['patient_first_name'] last_name = request.form['patient_last_name'] age = request.form['patient_age'] email = request.form['patient_email'] address = request.form['patient_address'] city = request.form['patient_city'] state = request.form['patient_state'] zipcode = request.form['patient_zipcode'] phone = request.form['patient_phone_number'] date_of_birth = request.form['patient_date_of_birth'] cursor = db.cursor() cursor.execute("""INSERT INTO User VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, null)""", (str(ssn) , str(first_name), str(last_name), str(age), str(email), str(address) , str(city), str(state), str(zipcode), str(phone), str(date_of_birth))) cursor.execute("""INSERT INTO Patient VALUES (%s)""", (str(ssn), )) db.commit() return render_template('new_account.html', data_return=[ssn , first_name, last_name, age, email, address, city, state, zipcode, phone, date_of_birth]) else: return render_template('adding_new_patient.html')
def add_appointment_to_database(cursor, patient_ssn, symptoms): # finding min appointment number cursor.execute("SELECT max(appointment_sn) from Appointment") max_appointment_number = cursor.fetchone() current_appointment_number = int(max_appointment_number[0]) + 1 today = datetime.datetime.now() cursor.execute("""INSERT INTO Appointment VALUES (%s, null, %s, %s, %s, null )""" ,(str(current_appointment_number), patient_ssn, symptoms, today.strftime("%m-%d-%Y"))) db.commit() return current_appointment_number
def delete_appointment(): if request.method == 'GET': return render_template('delete_appointment.html') elif request.method == 'POST': cursor = db.cursor() appointment_number = request.form['appointment_number'] cursor.execute("SELECT * from Appointment where appointment_sn=(%s)", (appointment_number, )) data = cursor.fetchone() if data == None: return render_template('delete_appointment.html', data='Appointment did not exist') elif data[1] != None: return render_template('delete_appointment.html', data='You can not delete this appointment') else: cursor.execute("DELETE FROM Appointment Where appointment_sn=(%s)" , (appointment_number, )) db.commit() return render_template('delete_appointment.html', data="We apologizes when we could not help you. Hope you will get well sone!!!")
def test_insertion(self): conn = engine.connect() insertion = Activity( date='20160704', steps=10000, user_id='1', total_sleep=8, resting_hr=60, step_week_slope=1, sleep_week_slope=1, hr_week_slope=1, curr_health_score=60, health_score_in_week=65 ) db.session.add(insertion) db.commit() s = db.select() result = conn.execute(s) for row in result: print row self.assertEqual(result, 200)
def update_appointment(appointment): if request.method == "POST": cursor = db.cursor() symptoms = request.form['symptoms'] notes = request.form['notes'] if len(request.form) <= 3: # update appointment info cursor.execute("UPDATE Appointment set symptoms=%s, notes=%s where appointment_sn=%s", (symptoms, notes, appointment)) db.commit() else: cursor.execute("UPDATE Appointment set symptoms=%s, notes=%s where appointment_sn=%s", (symptoms, notes, appointment)) db.commit() medicine_name = request.form['medicine_name'] medicine_shape = request.form['medicine_shape'] medicine_producer = request.form['medicine_producer'] medicine_unit_per_time = request.form['medicine_unit_per_time'] medicine_total = request.form['medicine_total'] # checking existing medicine cursor.execute("SELECT * from Medicine where medicine_name=%s and shape=%s and producer=%s" , (medicine_name, medicine_shape, medicine_producer)) medicine_info = cursor.fetchone() if medicine_info == None: return redirect(url_for('showing_appointment_update_info', appointment=appointment, set_value=1)) else: cursor.execute("UPDATE Appointment_medicine set medicine_name=%s, shape=%s, producer=%s where appointment_sn=%s" , (medicine_name, medicine_shape, medicine_producer, appointment)) db.commit() checking, return_data = getting_all_appointment_info(appointment) return render_template('showing_appointment.html', data=return_data)
def db_create(): db.create_all() db.commit() print('create db tables')