Exemplo n.º 1
0
    def find_doctor_id(self, permit_number):
        database = db.get_instance()
        query = "SELECT id FROM doctor WHERE permit_number=" + permit_number
        queryexecute = database.execute_query(query)
        data = queryexecute.fetchall()

        return str(data[0][0])
Exemplo n.º 2
0
 def doctorgetclinic(self, doctor_id):
     database = db.get_instance()
     query = "SELECT clinic_name FROM doctor WHERE permit_number=" + doctor_id
     queryexecute = database.execute_query(query)
     data = queryexecute.fetchall()
     print(data)
     return data
Exemplo n.º 3
0
 def deleteappointment(self, doctor_id, clinic_name):
     database = db.get_instance()
     print(doctor_id)
     doctor_id = str(doctor_id)
     query = "DELETE FROM doctoravailability WHERE id =" + doctor_id + " AND clinic_name=" + "'" + clinic_name + "'"
     database.execute_query(query)
     database.commit_db()
     message = "Availability Deleted"
     return message
Exemplo n.º 4
0
    def get_doctor_by_id(self, doctor_id):

        database = db.get_instance()
        query = "SELECT * FROM doctor WHERE id= " "'" + str(doctor_id) + "'" ""

        cur = database.execute_query(query)
        data = cur.fetchall()
        d = tuple()
        for row in data:
            d = tuple((row["first_name"], row["last_name"], row["speciality"],
                       row["city"], row["permit_number"], row["password"]))
        # returns a list of users
        return d
Exemplo n.º 5
0
    def __init__(self):
        if ClientController._instance is not None:
            raise Exception("This class is a singleton!")

        else:
            ClientController._instance = self
            Controller.__init__(self, DatabaseContainer.get_instance())

            self._db_loaded = False
            self._client_catalog = app.classes.catalogs.UserCatalog()
            self._catalog_controller = app.controllers.catalog_controller.CatalogController.get_instance(
            )
            self._loan_catalog = app.classes.catalogs.LoanCatalog.get_instance(
            )
Exemplo n.º 6
0
    def find_doctor_by_full_name(self, first_name, last_name):
        '''
             Finding the particular doctor according to their first and last name
        '''
        database = db.get_instance()
        query = "SELECT * FROM doctor WHERE first_name= " "'" + first_name + "'" " AND last_name= " "'" + last_name + "'" ""

        cur = database.execute_query(query)
        data = cur.fetchall()
        d = tuple()
        for row in data:
            d = tuple((row["first_name"], row["last_name"], row["speciality"],
                       row["city"], row["permit_number"], row["password"]))
        # returns a list of users
        return d
Exemplo n.º 7
0
 def register_doctor(self, first_name, last_name, speciality, city,
                     password, permit_number, clinic_name):
     try:
         database = db.get_instance()
         database.execute_query(
             "insert into doctor(first_name, last_name, speciality, city, password, permit_number,clinic_name) VALUES (?,?,?,?,?,?,?)",
             (first_name, last_name, speciality, city, password,
              permit_number, clinic_name))
         database.commit_db()
         message = "Record Successfully added"
     except:
         message = "Error!!! Registration failed."
     finally:
         return message
         database.close_connection()
Exemplo n.º 8
0
 def patient_register(self, first_name, last_name, birthday, gender,
                      phone_number, email, address, age, health_card):
     try:
         database = db.get_instance()
         #cur = con.cursor()
         database.execute_query(
             "insert into patient(first_name, last_name,birthday,gender,phone_number,email,address,age,health_card) VALUES (?,?,?,?,?,?,?,?,?)",
             (first_name, last_name, birthday, gender, phone_number, email,
              address, age, health_card))
         database.commit_db()
         message = "Record Successfully added"
     except:
         message = "Error!!! Registration failed."
     finally:
         return message
         database.close_connection()
Exemplo n.º 9
0
    def get_distinct_speciality(self):
        database = db.get_instance()
        query = "SELECT DISTINCT speciality FROM doctor"

        cur = database.execute_query(query)

        data = cur.fetchall()
        specialties = []
        d = tuple()
        for row in data:
            print(row["speciality"])
            specialties.append(row["speciality"])
            #d = tuple((row["speciality"]))
        d = tuple(specialties)
        # returns a list of users
        return d
Exemplo n.º 10
0
    def __init__(self):
        if AdminController._instance is not None:
            raise Exception("This class is a singleton!")
        else:
            AdminController._instance = self
            Controller.__init__(self, DatabaseContainer.get_instance())

            # Admin Controller should have an instance of catalog controller
            self._catalog_controller = CatalogController.get_instance()

            # Admin Controller contains a catalog of admin users
            self._admin_catalog = UserCatalog()

            # Admin Controller contains a catalog of loans
            self._loan_catalog = app.classes.catalogs.LoanCatalog.get_instance(
            )
            self._db_loaded = False
Exemplo n.º 11
0
    def nurse_find_patient_by_clinic(self, healthcard_number):
        '''
             Nurse finds the particular patient according to the clinic the patient belongs to
        '''
        database = db.get_instance()

        query = "SELECT * FROM patient WHERE health_card=" + "'" + healthcard_number + "'"
        print(query)

        cur = database.execute_query(query)
        data = cur.fetchall()
        d = tuple()
        for row in data:
            d = tuple((row["first_name"], row["last_name"], row["birthday"],
                       row["gender"], row["phone_number"], row["email"],
                       row["address"], row["age"], row["health_card"]))
        # returns a list of users
        return d
Exemplo n.º 12
0
    def nurse_find_doctor_by_clinic(self, permit_number, clinic_name):
        '''
            Nurse finds the particular doctor according to the clinic the doctor belongs to
        '''
        database = db.get_instance()

        query = "SELECT * FROM doctor WHERE permit_number=" + permit_number + " AND clinic_name=" + "'" + clinic_name + "'"
        print(query)

        cur = database.execute_query(query)
        data = cur.fetchall()
        d = tuple()
        for row in data:
            d = tuple((row["first_name"], row["last_name"], row["speciality"],
                       row["city"], row["permit_number"], row["clinic_name"]))
        # returns a list of users
        print(d)
        return d
Exemplo n.º 13
0
    def get_doctor_by_clinic_name(self, doctor_clinic_name):
        database = db.get_instance()

        # Get all the doctor specialities information for the clinic
        query = "SELECT * FROM doctor WHERE clinic_name = " "'" + str(
            doctor_clinic_name) + "'" ""

        cur = database.execute_query(query)
        data = cur.fetchall()
        ids = []
        last_names = []
        first_names = []
        specialties = []
        clinic_names = []
        cities = []
        passwords = []
        permit_numbers = []

        d = tuple()
        for row in data:
            ids.append(row["id"])
            last_names.append(row["last_name"])
            first_names.append(row["first_name"])
            specialties.append(row["speciality"])
            clinic_names.append(row["clinic_name"])
            cities.append(row["city"])
            passwords.append(row["password"])
            permit_numbers.append(row["permit_number"])

        values_from_db = tuple(
            list(
                zip(ids, last_names, first_names, specialties, clinic_names,
                    cities, passwords, passwords, permit_numbers)))
        print(values_from_db)
        print()
        '''doctors_list.append(row["first_name"], row["last_name"], row["speciality"], row["clinic_name"], row["city"], row["permit_number"],
                    row["password"])'''

        #d = tuple((row["first_name"], row["last_name"], row["speciality"], row["clinic_name"], row["city"], row["permit_number"],
        #row["password"]))
        d = values_from_db

        # returns a list of doctors
        return d
Exemplo n.º 14
0
    def get_doctor_name_from_id(self, patient_id):
        database = db.get_instance()
        query = "SELECT doctor.first_name, doctor.last_name FROM doctor INNER JOIN appointment ON doctor.id = appointment.doctor_id WHERE appointment.patient_id = " "'" + str(
            patient_id) + "'" ""

        cur = database.execute_query(query)

        data = cur.fetchall()
        firstnames = []
        lastnames = []
        d = tuple()

        for row in data:
            #print(doctor.first_name)
            firstnames.append(row["first_name"])
            lastnames.append(row["last_name"])
            #d = tuple((row["speciality"]))
        d = tuple(list(zip(firstnames, lastnames)))

        # returns a list of users
        return d
Exemplo n.º 15
0
 def __init__(self):
     if CatalogController._instance is not None:
         raise Exception("This class is a singleton!")
     else:
         CatalogController._instance = self
         Controller.__init__(self, DatabaseContainer.get_instance())
         self._inventory = {
             CatalogController.BOOK_TYPE: BookCatalog.get_instance(),
             CatalogController.MOVIE_TYPE: MovieCatalog.get_instance(),
             CatalogController.MAGAZINE_TYPE:
             MagazineCatalog.get_instance(),
             CatalogController.ALBUM_TYPE: AlbumCatalog.get_instance()
         }
         #CatalogController.LOAN_TYPE: LoanCatalog.get_instance()}
         self._constructors = {
             CatalogController.BOOK_TYPE: Book,
             CatalogController.MOVIE_TYPE: Movie,
             CatalogController.MAGAZINE_TYPE: Magazine,
             CatalogController.ALBUM_TYPE: Album
         }
         #CatalogController.LOAN_TYPE: Loan}
         self._db_loaded = False
Exemplo n.º 16
0
    def find_a_patient(self, healthcare_number):
        '''
            Finding the particular patient according to the healthcare # from the find nurse page
        '''
        database = db.get_instance()
        query = ""
        try:
            query = "SELECT * FROM patient WHERE health_card=" + "'" + healthcare_number + "'"
        except ValueError:
            query = ""

        cur = database.execute_query(query)
        data = cur.fetchall()
        d = tuple()
        for row in data:
            d = tuple(
                (row["id"], row["first_name"], row["last_name"],
                 row["birthday"], row["gender"], row["phone_number"],
                 row["email"], row["address"], row["age"], row["health_card"]))
        print(d)
        # returns a list of users
        return d
Exemplo n.º 17
0
    def find_doctor_by_permit_number(self, permit_number):
        '''
             Finding the particular doctor according to the permit # from the find nurse page
        '''
        database = db.get_instance()
        try:
            val = int(permit_number)
            if (val > 0):
                query = "SELECT * FROM doctor WHERE permit_number=" + permit_number
            else:
                query = ""
        except ValueError:
            query = ""

        cur = database.execute_query(query)
        data = cur.fetchall()
        d = tuple()
        for row in data:
            d = tuple((row["first_name"], row["last_name"], row["speciality"],
                       row["city"], row["permit_number"], row["password"]))
        # returns a list of users
        return d
Exemplo n.º 18
0
    def get_doctor_by_specialty(self, doctor_specialty):
        database = db.get_instance()
        query = "SELECT * FROM doctor WHERE speciality= " "'" + str(
            doctor_specialty) + "'" ""

        cur = database.execute_query(query)
        data = cur.fetchall()
        ids = []
        last_names = []
        first_names = []
        specialties = []
        cities = []
        passwords = []
        permit_numbers = []

        d = tuple()
        for row in data:
            ids.append(row["id"])
            last_names.append(row["last_name"])
            first_names.append(row["first_name"])
            specialties.append(row["speciality"])
            cities.append(row["city"])
            passwords.append(row["password"])
            permit_numbers.append(row["permit_number"])

        values_from_db = tuple(
            list(
                zip(ids, last_names, first_names, specialties, cities,
                    passwords, passwords, permit_numbers)))
        '''doctors_list.append(row["first_name"], row["last_name"], row["speciality"], row["city"], row["permit_number"],
                       row["password"])'''
        #d = tuple((row["first_name"], row["last_name"], row["speciality"], row["city"], row["permit_number"],
        #row["password"]))
        d = values_from_db
        # returns a list of users
        return d
Exemplo n.º 19
0
import logging

from flask import Flask, request as req

from app.controllers import pages

from app.classes.database_container import DatabaseContainer
from app.common_definitions.common_paths import PATH_TO_DATABASE
from app.database import sqlite_script

# Create and fill database with values - closes connection to
# Database was filled, objects are in memory if function call returns True
objects_in_memory = sqlite_script.initializeAndFillDatabase()

# Connect to the database through an abstracted object - this object must be imported into route files for use
databaseObject = DatabaseContainer.get_instance()


def create_app(config_filename):
    app = Flask(__name__)
    app.config.from_object(config_filename)

    app.register_blueprint(pages.blueprint)

    app.logger.setLevel(logging.NOTSET)

    @app.after_request
    def log_response(resp):
        app.logger.info("{} {} {}\n{}".format(req.method, req.url, req.data,
                                              resp))
        return resp
Exemplo n.º 20
0
 def doctorgetallappointments(self, doctor_id, clinic_name):
     database = db.get_instance()
     query = "SELECT * FROM doctoravailability WHERE doctor_id=" + doctor_id + " AND clinic_name=" + "'" + clinic_name + "'"
     queryexecute = database.execute_query(query)
     data = queryexecute.fetchall()
     return data
Exemplo n.º 21
0
    def doctorappointmentbook(self, day, start_time_hour, start_time_minute,
                              end_time_hour, end_time_minute, doctor_id,
                              clinic_name):
        message = "Availabilities loaded"
        database = db.get_instance()
        _start_time_hour = int(start_time_hour)
        _start_time_minute = int(start_time_minute)

        _end_time_hour = int(end_time_hour)
        _end_time_minute = int(end_time_minute)
        start_time = str(start_time_hour) + ':' + str(start_time_minute)
        end_time = str(end_time_hour) + ':' + str(end_time_minute)
        doctor_id = str(doctor_id)

        if (_start_time_hour <= _end_time_hour and _start_time_minute <
                _end_time_minute) or (_start_time_hour < _end_time_hour):
            start_time = str(start_time_hour) + ':' + str(start_time_minute)
            end_time = str(end_time_hour) + ':' + str(end_time_minute)
            query3 = "SELECT COUNT(*) FROM doctoravailability WHERE date_day= '" + day + "' AND doctor_id=" + doctor_id + " AND clinic_name=" + "'" + clinic_name + "'"
            cur = database.execute_query(query3)
            data1 = cur.fetchall()
            data1 = int(data1[0][0])
            print(data1)
            if data1 == 0:
                doctor_id = int(doctor_id)
                start_time = start_time + ":00"
                end_time = end_time + ":00"
                query2 = "insert into doctoravailability(date_day, start_time, end_time, doctor_id,clinic_name) VALUES (?,?,?,?,?)"
                database.execute_query(
                    query2,
                    (day, start_time, end_time, doctor_id, clinic_name))
                database.commit_db()
                print("hello")
                return "Availability Added"
            else:
                query = "SELECT * FROM doctoravailability WHERE date_day= '" + day + "' AND doctor_id=" + doctor_id + " AND clinic_name=" + "'" + clinic_name + "'"
                cur = database.execute_query(query)
                data = cur.fetchall()
                count = 0

                for row in data:
                    start = row[2]
                    end = row[3]
                    if int(start[0:1]) == 8 or int(start[0:1]) == 9:
                        start = '0' + start
                    if int(end[0:1]) == 8 or int(end[0:1]) == 9:
                        end = '0' + end
                    print(start)
                    print(end)
                    if (_start_time_hour > int(end[0:2]) and _end_time_hour > int(end[0:2])) or \
                        (_start_time_hour < int(start[0:2]) and _end_time_hour < int(start[0:2])) or \
                        (_start_time_hour < int(start[0:2]) and _end_time_hour <= int(start[0:2]) and _end_time_minute <= int(start[3:5])) or \
                        (_start_time_hour >= int(end[0:2]) and _end_time_hour > int(end[0:2]) and _start_time_minute >= int(end[3:5])) or \
                        (_start_time_hour <= int(start[0:2]) and _end_time_hour <= int(start[0:2]) and _start_time_minute < int(start[3:5]) and _end_time_minute <= int(start[3:5])):
                        count += 1
                        print(count)
                        if count == data1:
                            start_time = start_time + ":00"
                            end_time = end_time + ":00"
                            query2 = "insert into doctoravailability(date_day, start_time, end_time, doctor_id,clinic_name) VALUES (?,?,?,?,?)"
                            database.execute_query(query2,
                                                   (day, start_time, end_time,
                                                    doctor_id, clinic_name))
                            database.commit_db()
                            message = "Availability Added"
                            return message

                return "Enter proper values"
        else:
            message = "Enter proper values!!!"
        #query2 = "insert into doctoravailability(date_day, start_time, end_time, doctor_id) VALUES (?,?,?,?)"
        #database.execute_query(query2, (day, start_time, end_time,doctor_id ))
        #database.commit_db()
        return message