def change_appointment(self, appointmentID, appointmenttime): connection = Dbconnect.get_connection() try: with connection.cursor() as cursor: # Create a new record sql = queries["Change Appointment"] cursor.execute(sql, (appointmenttime, appointmentID)) # connection is not autocommit by default. So you must commit to save # your changes. connection.commit() finally: connection.close() return "change appointment success"
def make_appointment(self, doctorid, patientid, appointmenttime): connection = Dbconnect.get_connection() try: with connection.cursor() as cursor: # Create a new record sql = queries["Create Appointment"] cursor.execute(sql, (None, doctorid, patientid, appointmenttime)) # connection is not autocommit by default. So you must commit to save # your changes. connection.commit() finally: connection.close() return "add appointment success"
def get_prescription_info_list(self, limit=1000, offset=0): ''' method to get list of prescriptions ''' connection = Dbconnect.get_connection() try: with connection.cursor() as cursor: # get all patients within defined limit and offset sql = queries["Get Prescription List"] cursor.execute(sql, (limit, offset)) result = cursor.fetchall() finally: connection.close() return result
def get_patient_info_by_id(self, ID): ''' method to get patient information from the database ''' connection = Dbconnect.get_connection() try: with connection.cursor() as cursor: # get all patients with passed ID sql = queries["Get Patient Info"] cursor.execute(sql, (ID)) result = cursor.fetchall() finally: connection.close() return result
def get_appointments_by_patient_id(self, patientID): connection = Dbconnect.get_connection() try: with connection.cursor() as cursor: # Create a new record sql = queries["Get Appointments by patientID"] cursor.execute(sql, (patientID)) # connection is not autocommit by default. So you must commit to save # your changes. connection.commit() result = cursor.fetchone() finally: connection.close() return result
def get_prescription_by_id(self, prescriptionID): ''' method to get prescription by id ''' connection = Dbconnect.get_connection() try: with connection.cursor() as cursor: # get all prescriptions assigned to a patient sql = queries["Get Prescription by ID"] cursor.execute(sql, (prescriptionID)) # get result of prescriptions query result = cursor.fetchone() finally: connection.close() return result
def get_prescriptions_for_patient(self, patientID): ''' method to get all precriptions for a certain patient ''' connection = Dbconnect.get_connection() try: with connection.cursor() as cursor: # get all prescriptions assigned to a patient sql = queries["Get Patient Prescriptions"] cursor.execute(sql, (patientID)) # get result of prescriptions query result = cursor.fetchall() finally: connection.close() return result
def get_last_entry(self): ''' method to get last entry stored on database ''' connection = Dbconnect.get_connection() try: with connection.cursor() as cursor: # confirm account credentials sql = queries["Get Last User"] cursor.execute(sql) # get result of confirming credentials result = cursor.fetchone() finally: connection.close() return result
def confirm_credentials(self, username, password): ''' method to confirm inputted credentials against those stored on database ''' connection = Dbconnect.get_connection() try: with connection.cursor() as cursor: # confirm account credentials sql = queries["Confirm Credentials"] cursor.execute(sql, (username, password)) # get result of confirming credentials result = cursor.fetchone() finally: connection.close() return result
def remove_patient(self, ID): ''' method to remove a patient index from the database ''' connection = Dbconnect.get_connection() try: with connection.cursor() as cursor: # Create a new record sql = queries["Remove Patient"] cursor.execute(sql, (ID)) # connection is not autocommit by default. So you must commit to save # your changes. connection.commit() finally: connection.close() return "remove patient success"
def add_prescription(self, doctorID, patientID, prescription): ''' method to add a new prescription index to database ''' connection = Dbconnect.get_connection() try: with connection.cursor() as cursor: # create a new user index sql = queries["Add Prescription"] cursor.execute(sql, (None, doctorID, patientID, prescription)) # connection is not autocommit by default. So you must commit to save # your changes. connection.commit() finally: connection.close() return "add prescription success"
def remove_prescription(self, prescriptionID): ''' method to remove a prescription from the database ''' connection = Dbconnect.get_connection() try: with connection.cursor() as cursor: # cremove prescription from database sql = queries["Remove Prescription"] cursor.execute(sql, (prescriptionID)) # connection is not autocommit by default. So you must commit to save # your changes. connection.commit() finally: connection.close() return "edit prescription success"
def change_prescription(self, prescriptionID, prescription): ''' method to change an existing prescription index in the database ''' connection = Dbconnect.get_connection() try: with connection.cursor() as cursor: # change prescription information sql = queries["Change Prescription"] cursor.execute(sql, (prescription, prescriptionID)) # connection is not autocommit by default. So you must commit to save # your changes. connection.commit() finally: connection.close() return "edit prescription success"
def change_patient_info(self, name, weight, address, phone, insurance, height, medicalhistory, ID): ''' method to change patient information on database ''' connection = Dbconnect.get_connection() try: with connection.cursor() as cursor: # get all patients with passed name sql = queries["Change Patient Info"] cursor.execute(sql, (name, weight, address, phone, insurance, height, medicalhistory, ID)) connection.commit() finally: connection.close() return "successfully altered patient info"
def change_username(self, newUsername, username, password): ''' method to change username of user ''' connection = Dbconnect.get_connection() try: with connection.cursor() as cursor: # modify user's username with inputted credentials sql = queries["Change Username"] cursor.execute(sql, (newUsername, username, password)) # connection is not autocommit by default. So you must commit to save # your changes. connection.commit() finally: connection.close() return "username changed success"
def remove_user(self, id): ''' method to remove user from system ''' connection = Dbconnect.get_connection() try: with connection.cursor() as cursor: # remove user from database sql = queries["Remove User"] cursor.execute(sql, (id)) # connection is not autocommit by default. So you must commit to save # your changes. connection.commit() # remove patient pertaining to user PatientModel().remove_patient(id) finally: connection.close() return "remove user success"
def add_user(self, id, username, password, userType, permissionLevel): ''' method to add a user to the system ''' connection = Dbconnect.get_connection() try: with connection.cursor() as cursor: # create a new user index sql = queries["Add User"] cursor.execute( sql, (id, username, password, userType, int(permissionLevel))) # connection is not autocommit by default. So you must commit to save # your changes. connection.commit() finally: connection.close() return "add user success"
def add_patient(self, ID, name, age, weight, gender, height, address, phone, medicalhistory, insurance, DOB): ''' method to add a patient index to the database ''' connection = Dbconnect.get_connection() try: with connection.cursor() as cursor: # Create a new record sql = queries["Add Patient"] cursor.execute(sql, (ID, name, age, weight, gender, height, address, phone, medicalhistory, insurance, DOB)) # connection is not autocommit by default. So you must commit to save # your changes. connection.commit() finally: connection.close() return "add patient success"
def test_init(self): config = Config.__annotations__ Dbconnect.set_db_info(config) con = Dbconnect.get_connection() con.close()