def put(self,id): """Update the appointment details by the appointment id""" appointment = request.get_json(force=True) pat_id = appointment['pat_id'] doc_id = appointment['doc_id'] conn.execute("UPDATE appointment SET pat_id=?,doc_id=? WHERE app_id=?", (pat_id, doc_id, id)) conn.commit() return appointment
def put(self, id): """Update the medicine by its id""" medicineInput = request.get_json(force=True) medicine_name = medicineInput['medicine_name'] desease = medicineInput['desease'] pat_name = medicineInput['pat_name'] conn.execute( "UPDATE medicine SET medicine_name=?,desease=?,pat_name=? WHERE med_id=?", (medicine_name, desease, pat_name, id)) conn.commit() return medicineInput
def put(self,id): """Update the doctor by its id""" doctorInput = request.get_json(force=True) doc_first_name=doctorInput['doc_first_name'] doc_last_name = doctorInput['doc_last_name'] doc_ph_no = doctorInput['doc_ph_no'] doc_address = doctorInput['doc_address'] conn.execute( "UPDATE doctor SET doc_first_name=?,doc_last_name=?,doc_ph_no=?,doc_address=? WHERE doc_id=?", (doc_first_name, doc_last_name, doc_ph_no, doc_address, id)) conn.commit() return doctorInput
def put(self, id): """Update the staff by its id""" staffInput = request.get_json(force=True) stf_first_name = staffInput['stf_first_name'] stf_last_name = staffInput['stf_last_name'] stf_ph_no = staffInput['stf_ph_no'] stf_address = staffInput['stf_address'] conn.execute( "UPDATE staff SET stf_first_name=?,stf_last_name=?,stf_ph_no=?,stf_address=? WHERE stf_id=?", (stf_first_name, stf_last_name, stf_ph_no, stf_address, id)) conn.commit() return staffInput
def put(self, id): """api to update the bill by it id""" billInput = request.get_json(force=True) pat_name = billInput['pat_name'] amount = billInput['amount'] bill_date = billInput['bill_date'] #bill_id = billInput['bill_id'] #pat_address = billInput['pat_address'] conn.execute("UPDATE bill SET pat_name=?,amount=? WHERE bill_id=?", (pat_name, amount, id)) conn.commit() return billInput
def get(self): """Retrive the patient,doctor and appointment count for the dashboard page""" getPatientCount=conn.execute("SELECT COUNT(*) AS patient FROM patient").fetchone() getDoctorCount = conn.execute("SELECT COUNT(*) AS doctor FROM doctor").fetchone() getAppointmentCount = conn.execute("SELECT COUNT(*) AS appointment FROM appointment").fetchone() getMedicineCount=conn.execute("select count(*) as medicine from medicine").fetchone() getbillCount=conn.execute("select count(*) as bill from bill").fetchone() getPatientCount.update(getDoctorCount) getPatientCount.update(getAppointmentCount) getPatientCount.update(getMedicineCount) getPatientCount.update(getbillCount) return getPatientCount
def import_yf_one_min_bars(ticker): ticker = ticker.upper() df = yf.Ticker(ticker).history(period="5d", interval="1m", prepost=True, actions=True, auto_adjust=True, back_adjust=False) df = df.reset_index() # change Datetime index to a column df['ticker'] = ticker df.rename(columns={ 'Datetime': 'bar_start', 'Open': 'open', 'High': 'high', 'Low': 'low', 'Close': 'close', 'Volume': 'volume', 'Dividends': 'dividends', 'Stock Splits': 'stock_splits' }, inplace=True) df['open'] = df['open'].round(4) df['high'] = df['high'].round(4) df['low'] = df['low'].round(4) df['close'] = df['close'].round(4) df['dividends'] = df['dividends'].round(4) df['stock_splits'] = df['stock_splits'].round(4) # some stock splits erroneously 1 for 0 (infinity), assume they are bugs, and replace them with 0s df["stock_splits"] = df["stock_splits"].replace(inf, 0) # assume its always EST timezone if df["bar_start"][0].tzname() != "EST": raise ValueError("Non EST timezone parsing yf_one_min_bars for", ticker) # rth set df['rth'] = pd.to_datetime(df['bar_start']).dt.time.between( datetime.time(9, 30), datetime.time(15, 59)).astype(int) # delete all conn.execute( text( """DELETE FROM yf_stock_intraday WHERE ticker = :ticker AND bar_start >= :bar_start""" ), { "ticker": ticker, "bar_start": df["bar_start"][0] }) # insert all df.to_sql('yf_stock_intraday', con=eng, if_exists='append', index=False)
def put(self, id): """api to update the patient by it id""" patientInput = request.get_json(force=True) pat_first_name = patientInput['pat_first_name'] pat_last_name = patientInput['pat_last_name'] pat_insurance_no = patientInput['pat_insurance_no'] pat_ph_no = patientInput['pat_ph_no'] pat_address = patientInput['pat_address'] conn.execute( "UPDATE patient SET pat_first_name=?,pat_last_name=?,pat_insurance_no=?,pat_ph_no=?,pat_address=? WHERE pat_id=?", (pat_first_name, pat_last_name, pat_insurance_no, pat_ph_no, pat_address, id)) conn.commit() return patientInput
def get(self): """Retrive the patient,doctor and appointment count for the dashboard page""" getPatientCount = conn.execute( "SELECT COUNT(*) AS patient FROM patient").fetchone() getDoctorCount = conn.execute( "SELECT COUNT(*) AS doctor FROM doctor").fetchone() getAppointmentCount = conn.execute( "SELECT COUNT(*) AS appointment FROM appointment").fetchone() getStaffCount = conn.execute( "SELECT COUNT(*) AS staff FROM staff").fetchone() getPatientCount.update(getDoctorCount) getPatientCount.update(getAppointmentCount) getPatientCount.update(getStaffCount) return getPatientCount
def get(self): """Retrive all the appointment and return in form of json""" appointment = conn.execute( "SELECT p.*,d.*,a.* from appointment a LEFT JOIN patient p ON a.pat_id = p.pat_id LEFT JOIN doctor d ON a.doc_id = d.doc_id ORDER BY appointment_date DESC" ).fetchall() return appointment
def get_sp500_tickers(): """ Get all the sp500 tickers in a list and return it """ # TODO add day parameter? tickers_tup = conn.execute( text( """SELECT tickers FROM ticker_group WHERE start_day = (SELECT start_day FROM ticker_group WHERE tag = 'sp500' ORDER BY start_day DESC LIMIT 1) AND tag = 'sp500';""" )).fetchone() if len(tickers_tup) > 0: return tickers_tup[0] else: return []
def get_top_tickers(n, skip=0): """ Get the top n tickers by marketcap """ # TODO add day parameter? tickers_tup = conn.execute( text( """SELECT ticker FROM fv_stock_daily WHERE day = (SELECT day FROM fv_stock_daily ORDER BY day DESC LIMIT 1) ORDER BY marketcap DESC NULLS LAST LIMIT :limit OFFSET :offset;""" ), { "limit": n, "offset": skip }).fetchall() return tuple_to_list(tickers_tup)
def post(self): """Create the appoitment by assiciating patient and docter with appointment date""" appointment = request.get_json(force=True) pat_id = appointment['pat_id'] doc_id = appointment['doc_id'] appointment_date = appointment['appointment_date'] appointment['app_id'] = conn.execute('''INSERT INTO appointment(pat_id,doc_id,appointment_date) VALUES(?,?,?)''', (pat_id, doc_id,appointment_date)).lastrowid conn.commit() return appointment
def post(self): """api to add the bill in the database""" billInput = request.get_json(force=True) pat_name = billInput['pat_name'] amount = billInput['amount'] bill_date = billInput['bill_date'] billInput['bill_id'] = conn.execute( '''INSERT INTO bill(pat_name,amount) VALUES(?,?)''', (pat_name, amount)).lastrowid conn.commit() return billInput
def post(self): """Add the new doctor""" doctorInput = request.get_json(force=True) doc_first_name=doctorInput['doc_first_name'] doc_last_name = doctorInput['doc_last_name'] doc_ph_no = doctorInput['doc_ph_no'] doc_address = doctorInput['doc_address'] doctorInput['doc_id']=conn.execute('''INSERT INTO doctor(doc_first_name,doc_last_name,doc_ph_no,doc_address) VALUES(?,?,?,?)''', (doc_first_name, doc_last_name,doc_ph_no,doc_address)).lastrowid conn.commit() return doctorInput
def post(self): """Add the new medicine""" medicineInput = request.get_json(force=True) #med_id=medicineInput['med_id'] medicine_name = medicineInput['medicine_name'] desease = medicineInput['desease'] pat_name = medicineInput['pat_name'] medicineInput['med_id'] = conn.execute( '''INSERT INTO medicine(medicine_name,desease,pat_name) VALUES(?,?,?)''', (medicine_name, desease, pat_name)).lastrowid conn.commit() return medicineInput
def import_yf_daily_history(ticker, period): ticker = ticker.upper() df = yf.Ticker(ticker).history(period=period, interval="1d", prepost=False, actions=True, auto_adjust=True, back_adjust=False) df['ticker'] = ticker df.rename(columns={ 'Open': 'open', 'High': 'high', 'Low': 'low', 'Close': 'close', 'Volume': 'volume', 'Dividends': 'dividends', 'Stock Splits': 'stock_splits' }, inplace=True) df.index.names = ['day'] df['open'] = df['open'].round(4) df['high'] = df['high'].round(4) df['low'] = df['low'].round(4) df['close'] = df['close'].round(4) df['dividends'] = df['dividends'].round(4) df['stock_splits'] = df['stock_splits'].round(4) # some stock splits erroneously 1 for 0 (infinity), assume they are bugs, and replace them with 0s df["stock_splits"] = df["stock_splits"].replace(inf, 0) # delete all conn.execute( text( """DELETE FROM yf_stock_daily WHERE ticker = :ticker AND day >= :day """ ), { "ticker": ticker, "day": df.index[0] }) # insert all df.to_sql('yf_stock_daily', con=eng, if_exists='append')
def post(self): """Add the new staff""" staffInput = request.get_json(force=True) stf_first_name = staffInput['stf_first_name'] stf_last_name = staffInput['stf_last_name'] stf_ph_no = staffInput['stf_ph_no'] stf_address = staffInput['stf_address'] staffInput['stf_id'] = conn.execute( '''INSERT INTO staff(stf_first_name,stf_last_name,stf_ph_no,stf_address) VALUES(?,?,?,?)''', (stf_first_name, stf_last_name, stf_ph_no, stf_address)).lastrowid conn.commit() return staffInput
def post(self): """api to add the patient in the database""" patientInput = request.get_json(force=True) pat_first_name = patientInput['pat_first_name'] pat_last_name = patientInput['pat_last_name'] pat_insurance_no = patientInput['pat_insurance_no'] pat_ph_no = patientInput['pat_ph_no'] pat_address = patientInput['pat_address'] patientInput['pat_id'] = conn.execute( '''INSERT INTO patient(pat_first_name,pat_last_name,pat_insurance_no,pat_ph_no,pat_address) VALUES(?,?,?,?,?)''', (pat_first_name, pat_last_name, pat_insurance_no, pat_ph_no, pat_address)).lastrowid conn.commit() return patientInput
def get(self): """Retrive list of all the staff""" staffs = conn.execute( "SELECT * FROM staff ORDER BY stf_date DESC").fetchall() return staffs
def delete(self, id): """Delete the staff by its id""" conn.execute("DELETE FROM staff WHERE stf_id=?", (id, )) conn.commit() return {'msg': 'sucessfully deleted'}
def get(self, id): """get the details of the stfktor by the staff id""" staff = conn.execute("SELECT * FROM staff WHERE stf_id=?", (id, )).fetchall() return staff
from flask_restful import Resource, Api, request from model import conn #billInput = request.get_json(force=True) pat_name = 'pat' #bill_date = bill['bill_date'] amount = 25000 conn.execute('''INSERT INTO bill(pat_name,amount) VALUES(?,?)''', (pat_name, amount)).lastrowid conn.commit()
def delete(self,id): """Delete teh appointment by its id""" conn.execute("DELETE FROM appointment WHERE app_id=?",(id,)) conn.commit() return {'msg': 'sucessfully deleted'}
def get(self, id): """api to retrive details of the patient by it id""" patient = conn.execute("SELECT * FROM patient WHERE pat_id=?", (id, )).fetchall() return patient
def get(self): """Retrive list of all the doctor""" doctors = conn.execute("SELECT * FROM doctor ORDER BY doc_date DESC").fetchall() return doctors
def delete(self, id): """api to delete the patiend by its id""" conn.execute("DELETE FROM patient WHERE pat_id=?", (id, )) conn.commit() return {'msg': 'sucessfully deleted'}
def delete(self, id): """Delete the doctor by its id""" conn.execute("DELETE FROM doctor WHERE doc_id=?", (id,)) conn.commit() return {'msg': 'sucessfully deleted'}
def get(self,id): """get the details of the docktor by the doctor id""" doctor = conn.execute("SELECT * FROM doctor WHERE doc_id=?",(id,)).fetchall() return doctor
def get(self): """Api to retive all the patient from the database""" patients = conn.execute( "SELECT * FROM patient ORDER BY pat_date DESC").fetchall() return patients