Esempio n. 1
0
    def get_patient_with_id(self, id):
        cursor = self.connection.cursor()

        try:
            str_patient_id = str(id)
            cursor.execute(" SELECT * FROM public.patient WHERE id = '" +
                           str_patient_id + "'")

            record = cursor.fetchone()

            result = PatientInfoTable(
                patient_id=record[0],
                doctor_id=record[1],
                name=record[2],
                surname=record[3],
                email=record[4],
                password=record[5],
                age=record[6],
                gender=record[7],
                city=record[8],
                body_height=record[9],
                body_mass_index=record[10],
                body_weight=record[11],
                confirmed=record[12],
                blood_pressure_risk=record[14],
                cholesterol_risk=record[15],
                id=record[13],
                hemoglobin_a1c=record[16],
                high_density_lipoprotein_cholesterol=record[17],
                low_density_lipoprotein_cholesterol=record[18],
                total_cholesterol=record[19],
                triglycerides=record[20],
                calcium=record[21],
                carbon_dioxide=record[22],
                chloride=record[23],
                creatinine=record[24],
                glucose=record[25],
                potassium=record[26],
                sodium=record[27],
                urea_nitrogen=record[28],
                glomerular_filtration=record[29],
                microalbumin=record[30],
                fev1_fvc=record[31])

        except (Exception, psycopg2.Error) as error:
            self.connection.rollback()
            print("\n\nFailed to get the user\n", error)
            result = None
        finally:
            cursor.close()
            return result
Esempio n. 2
0
 def get_patient_info(self, patient_id):
     cursor = self.connection.cursor()
     try:
         cursor.execute(
             '''SELECT * FROM public.patient_info, public.user
                         WHERE public.user.id = patient_id
                             AND patient_id = %s''', (patient_id, ))
     except (Exception, psycopg2.ProgrammingError) as error:
         print("\n\nFailed to execute patient info query\n", error)
         return
     result = cursor.fetchall()
     cursor.close()
     return [
         PatientInfoTable(patient_id=record[0],
                          doctor_id=record[1],
                          name=record[2],
                          surname=record[3],
                          email=record[4],
                          password=record[5],
                          age=record[6],
                          gender=record[7],
                          city=record[8],
                          body_height=record[9],
                          body_mass_index=record[10],
                          body_weight=record[11],
                          blood_pressure_risk=record[12],
                          cholesterol_risk=record[13],
                          confirmed=record[14],
                          id=record[15],
                          hemoglobin_a1c=record[18],
                          high_density_lipoprotein_cholesterol=record[19],
                          low_density_lipoprotein_cholesterol=record[20],
                          total_cholesterol=record[21],
                          triglycerides=record[22],
                          calcium=record[23],
                          carbon_dioxide=record[24],
                          chloride=record[25],
                          creatinine=record[26],
                          glucose=record[27],
                          potassium=record[28],
                          sodium=record[29],
                          urea_nitrogen=record[30],
                          glomerular_filtration=record[31],
                          microalbumin=record[32],
                          fev1_fvc=record[33]) for record in result
     ]
Esempio n. 3
0
    def get_doctors_patients(self, doctorid):
        cursor = self.connection.cursor()
        cursor.execute(
            '''SELECT id,patient_id, name,email,surname FROM public.patient 
                            WHERE doctor_id = %s''', (doctorid, ))
        results = cursor.fetchall()
        patients = []
        for res in results:
            patients.append(
                PatientInfoTable(id=res[0],
                                 patient_id=res[1],
                                 doctor_id=None,
                                 name=res[2],
                                 surname=res[4],
                                 email=res[3],
                                 password=None,
                                 age=None))

        cursor.close()
        return patients
Esempio n. 4
0
 def get_one_patient_info(self, patient_id):
     cursor = self.connection.cursor()
     try:
         cursor.execute(
             '''SELECT * FROM public.patient, public.user
                         WHERE public.user.id = patient_id
                             AND patient_id = %s''', (patient_id, ))
     except (Exception, psycopg2.ProgrammingError) as error:
         print("\n\nFailed to execute patient info query\n", error)
         return
     record = cursor.fetchone()
     cursor.close()
     return PatientInfoTable(
         patient_id=record[0],
         doctor_id=record[1],
         blood_type=record[2],
         blood_pressure=record[3],
         diagnosis=record[4],
         patient_info_id=record[6],
         email=record[8],
         age=record[9],
         name=record[10],
         surname=record[11],
     )
Esempio n. 5
0
def insert_patient():
    session['is_in_home'] = False
    msg = ''
    if request.method == 'POST':

        # doctorid current session kulanılarak doktorun id si alınarak verilecek

        doctorid = session['id']
        patient_id = request.form['id']
        name = request.form['name']
        surname = request.form['surname']
        email = request.form['email']
        age = int(request.form['age'])
        password = patient_id + surname

        user = User(name=name,
                    surname=surname,
                    email=email,
                    password=password,
                    age=age,
                    user_type=2)

        #patient info ekle
        db = current_app.config['db']
        #insert user table
        #insert patient table

        answer = db.insert_user(user)

        if answer[0]:
            msg = 'You have successfully registered '
            userID = db.get_user_info(email)
            print(userID)
            user1 = PatientInfoTable(patient_id=patient_id,
                                     doctor_id=doctorid,
                                     name=name,
                                     surname=surname,
                                     email=email,
                                     password=password,
                                     age=age,
                                     id=userID.id)
            flash(msg)
            answer = db.insert_patient(user1)
            print
            if answer:
                msg = 'Patient is added, successfuly '
                flash(msg)
                # TODO:  "notificationsa değil patient profile gidecek"
                return render_template('update_patient_profile.html',
                                       info=user1,
                                       notification_id=None)
            else:
                msg = "Something went wrong"
                flash(msg)
                return redirect(url_for('insert_patient'))
                # return render_template('register.html')

        else:
            print(answer[1])
            idx = str(answer[1]).find("DETAIL")
            if idx != -1:
                msg = str(answer[1])[:idx].capitalize()
            else:
                msg = "Something went wrong"
            flash(msg)
            return redirect(url_for('insert_patient'))
            # return render_template('register.html')

    return render_template('add_patient.html')
Esempio n. 6
0
def update_patient_medical_data():
    session['is_in_home'] = False
    print(request.method)
    if session['loggedin'] and request.method == 'POST':
        patient = PatientInfoTable(
            request.form["patient_id"], request.form["doctor_id"],
            request.form["name"], request.form["surname"],
            request.form["email"], None, request.form["age"],
            request.form["gender"], request.form["city"],
            request.form["body_height"], request.form["body_mass_index"],
            request.form["body_weight"], None, None, None, None,
            request.form["hemoglobin_a1c"],
            request.form["high_density_lipoprotein_cholesterol"],
            request.form["low_density_lipoprotein_cholesterol"],
            request.form["total_cholesterol"], request.form["triglycerides"],
            request.form["calcium"], request.form["carbon_dioxide"],
            request.form["chloride"], request.form["creatinine"],
            request.form["glucose"], request.form["potassium"],
            request.form["sodium"], request.form["urea_nitrogen"],
            request.form["glomerular_filtration"],
            request.form["microalbumin"], request.form["fev1_fvc"])

        checker = current_app.config['db'].update_medical_data(patient)
        print("updatedd ya")
        print((checker))
        print(session['id'])
        print(patient.doctor_id)
        db = current_app.config['db']

        p = db.get_patient(patient.patient_id)
        print("yaptımmm", patient.patient_id)
        notif = db.get_specific_notification(patient.doctor_id, p.id)

        if notif != None:
            print(notif)
            db.update_notification_status(notif.id, False)
        else:
            print(patient.doctor_id)
            print(p.id)

            db.insert_notification(p.id, patient.doctor_id)

        if checker:
            msg = "Updated Succesfully"
            flash(msg)
        else:
            msg = "something went wrong"
            flash(msg)

        if session['isDoctor'] == False:
            return render_template('update_patient_profile.html',
                                   info=patient,
                                   notification_id=None,
                                   isNotif=False)

        elif session['isDoctor']:
            print("buraya mi")
            db = current_app.config['db']
            # BURADA NOTIFICATIONI ALIP OKUNDU BILGISI VERILECEK
            #notif = db.get_notification(patient.doctor_id, patient.patient_id)
            #update_notification_status(notif.id)
            notif = 0
            return render_template('update_patient_profile.html',
                                   info=patient,
                                   notification_id=notif)
        else:
            print("else mi")

    #elif session['loggedin'] and request.method == 'GET':
    #print("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")
        """