def add_new_doctor(doctor):
    conn = None
    try:
        conn = create_connection(DATABASE_LOCATION)
        cur = conn.cursor()

        cur.execute(SQL_INSERT_DOCTOR, (doctor.name,
                                         doctor.firstname,
                                         doctor.adheli,
                                         doctor.login,
                                         doctor.password,
                                         doctor.token,
                                         doctor.email,
                                         doctor.speciality,
                                         doctor.is_valid,
                                         doctor.register_date,
                                         doctor.fid_user,))
        conn.commit()
    except Error:
        raise PatientException(jsonify({
            'status': 'error',
            'message': 'Technical error'
        }))
    finally:
        if conn:
            conn.close()
def admin_exist():
    conn = None
    try:
        conn = create_connection(DATABASE_LOCATION)
        cur = conn.cursor()
        cur.execute(SQL_SELECT_ADMIN_EXIST)
        number = int(cur.fetchone()[0])
        return number > 0
    except Error:
        raise PatientException(jsonify({
            'status': 'error',
            'message': 'Technical error'
        }))
    finally:
        if conn:
            conn.close()
def create_admin_user():
    hash_object = hashlib.sha384("toor".encode("utf-8"))
    pwd = hash_object.hexdigest()
    if not admin_exist():
        conn = None
        try:
            conn = create_connection(DATABASE_LOCATION)
            cur = conn.cursor()
            cur.execute(SQL_INSERT_ADMIN_USER, ("admin", "admin", "*****@*****.**", "root", pwd, "1234", 1, datetime.datetime.now(),))
            conn.commit()
        except Error:
            raise PatientException(jsonify({
                'status': 'error',
                'message': 'Technical error'
            }))
        finally:
            if conn:
                conn.close()
def add_new_alert(alert):
    conn = None
    try:
        conn = create_connection(DATABASE_LOCATION)
        cur = conn.cursor()
        cur.execute(SQL_INSERT_ALERT, (alert.fid_patient,
                                         alert.date_contact,
                                         alert.is_booked,))
        alert_id = cur.lastrowid
        conn.commit()
        return alert_id
    except Error:
        raise PatientException(jsonify({
            'status': 'error',
            'message': 'Technical error'
        }))
    finally:
        if conn:
            conn.close()
def add_new_patient(patient):
    conn = None
    try:
        conn = create_connection(DATABASE_LOCATION)
        cur = conn.cursor()
        cur.execute(SQL_INSERT_PATIENT, (patient.name,
                                         patient.first_name,
                                         patient.email,
                                         patient.phone,
                                         patient.comment,
                                         datetime.datetime.now(),))
        patient_id = cur.lastrowid
        conn.commit()
        return patient_id
    except Error:
        raise PatientException(jsonify({
            'status': 'error',
            'message': 'Technical error'
        }))
    finally:
        if conn:
            conn.close()
示例#6
0
 def __valid_phone(self):
     if not self.phone or "":
         raise PatientException("Your phone is not valid")
示例#7
0
 def __valid_email(self):
     regex = '^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$'
     if not re.search(regex, self.email):
         raise PatientException("Your email is null")