def setInitialValues(self): teacher_id = user_info.current_userID self.db.cursor.execute("SELECT name From people where user_id= '" + str(teacher_id) + "'") teacher_name_list = self.db.cursor.fetchone() self.ui.name_label.setText(str(teacher_name_list[0])) # self.db.cursor.execute("SELECT name from groups") # filler.fillComboBox(self.ui.groupComboBox, self.db.cursor) self.db.cursor.execute( "SELECT name From people where type = 'S' order by name") filler.fillComboBox(self.ui.studentNameComboBox, self.db.cursor) self.db.cursor.execute( "SELECT name From people where type = 'P' order by name") filler.fillComboBox(self.ui.teacherNameComboBox, self.db.cursor) self.db.cursor.execute( "SELECT G.name, round(avg(COALESCE(value, 0)), 2) FROM people p " "FULL JOIN marks m on p.id = m.student_id " "RIGHT JOIN GROUPS G ON G.ID = P.GROUP_ID " "GROUP BY G.id ;") filler.fillTable(self.ui.groupTableWidget, self.db.cursor, 2) filler.fillMultipleComboBox([ self.ui.subjectNameComboBox, self.ui.SubjectComboBox, self.ui.subjectComboBox1, self.ui.subjectComboBox2 ], self.db.cursor, 'SELECT name from subject order by name') self.set_default_marks_table() self.ui.typeComboBox.clear() self.ui.typeComboBox.addItem("Student") self.ui.typeComboBox.addItem("Teacher") self.db.cursor.execute("SELECT p.name, s.name FROM MARKS M " "FULL JOIN PEOPLE P ON P.ID = M.STUDENT_ID " "LEFT JOIN GROUPS G ON G.ID = P.GROUP_ID " "FULL Join subject s on M.subject_id = s.id") filler.fillTable(self.ui.studentSubjectTableWidget, self.db.cursor, 2) self.db.cursor.execute("select * from avgMarkByTeacher") filler.fillTable(self.ui.avgMarkByTeacherTableWidget, self.db.cursor, 3) self.db.cursor.execute("select * from avgMarkByYears") filler.fillTable(self.ui.yearMarksTableWidget, self.db.cursor, 2) self.ui.yearComboBox.clear() self.ui.yearComboBox.addItem("") for i in range(2015, datetime.date.today().year): self.ui.yearComboBox.addItem(str(i)) filler.fillMultipleComboBox([ self.ui.groupComboBox, self.ui.groupNumComboBox, self.ui.groupPointerComboBox2, self.ui.groupPointerComboBox_2, self.ui.groupComboBox1 ], self.db.cursor, 'SELECT name from groups')
def date_change(self): global selected_date selected_date = str(self.ui.date_comboBox.currentText()) if len(selected_date) != 0 : self.db.cursor.execute("SELECT id from physicians where name = '" + str(self.ui.physician_comboBox.currentText()) + "'") global selected_doctor selected_doctor = self.db.cursor.fetchone() self.db.cursor.execute("SELECT x FROM (SELECT x::time, CASE WHEN Q.time = x IS NULL " "THEN false ELSE true END flag " "FROM generate_series(date %s + time '08:00', date %s + time '18:00', interval '30 min' ) t(x) " "left JOIN (SELECT * FROM Queue WHERE physician_id = %s and time::date = %s " "and time::time between time '08:00' and '18:00') AS Q on time = x) as foo where flag = false", (selected_date, selected_date, selected_doctor[0], selected_date)) filler.fillComboBox(self.ui.time_comboBox, self.db.cursor)
def changeNameOfGroupClicked(self): old_name = str(self.ui.groupPointerComboBox_2.currentText()) name = str(self.ui.changeNameOfGroupLineEdit.text()) try: self.db.cursor.execute("UPDATE groups SET name = '{}'" " WHERE id = (SELECT id from groups " "where name = '{}')".format(name, old_name)) self.db.cnxn.commit() except (Exception, sql.psycopg2.Error) as error: error_message = QtWidgets.QErrorMessage(self) error_message.setWindowTitle("Ошибка") error_message.showMessage("Такая группа уже есть") self.db.cursor.execute("SELECT name from groups") filler.fillComboBox(self.ui.groupPointerComboBox_2, self.db.cursor) self.ui.groupPointerComboBox_2.clear()
def setInitialValues(self): self.ui.date_label.setText( str(datetime.datetime.now().strftime("%Y-%m-%d %H:%M"))) doc_id = user_info.current_userID self.db.cursor.execute("SELECT name from Physicians where user_id= '" + str(doc_id) + "'") doc_name = self.db.cursor.fetchone() self.ui.name_label.setText(doc_name[0]) self.db.cursor.execute( "SELECT S.name, S.id from Physicians Ph LEFT JOIN Specialization S on Ph.specialization_id = S.id WHERE Ph.user_id=" + str(doc_id)) spec_name = self.db.cursor.fetchone() self.ui.spezialization_label.setText(spec_name[0]) self.db.cursor.execute( "SELECT passport from Physicians where user_id=" + str(doc_id)) pas_name = self.db.cursor.fetchone() self.ui.passport_label.setText(str(pas_name[0])) self.db.cursor.execute( "SELECT date_of_birth from Physicians where user_id=" + str(doc_id)) date_of_birth = self.db.cursor.fetchone() self.ui.date_of_birth_label.setText(str(date_of_birth[0])) self.db.cursor.execute( "SELECT phone from authentication_data WHERE id= %s", str(user_info.current_userID)) phone = self.db.cursor.fetchone() self.ui.phone_number_box.setText(str(phone[0])) self.db.cursor.execute("SELECT name from Patients") filler.fillComboBox(self.ui.patients_comboBox, self.db.cursor) self.db.cursor.execute( "SELECT name from Services where specialization_id = %s", str(spec_name[1])) filler.fillComboBox(self.ui.service_comboBox, self.db.cursor) self.form_queue_button_clicked() self.show_all_med_records()
def setInitialValues(self): user_id = user_info.current_userID self.db.cursor.execute("SELECT name From people where user_id= '" + str(user_id) + "'") student_name_list = self.db.cursor.fetchone() self.ui.name_label.setText(str(student_name_list[0])) # self.db.cursor.execute("SELECT name from groups") # filler.fillComboBox(self.ui.groupComboBox, self.db.cursor) self.db.cursor.execute("SELECT name From people where type = 'P' ") filler.fillComboBox(self.ui.teacherNameComboBox, self.db.cursor) filler.fillMultipleComboBox([self.ui.SubjectComboBox], self.db.cursor, 'SELECT name from subject') self.db.cursor.execute("SELECT s.name, t.name, value, date from marks " "left join people st on MARKS.STUDENT_ID = st.ID" " left join people t on MARKS.TEACHER_ID = t.id " "left join subject s on MARKS.SUBJECT_ID = s.id where student_id = {}".format(self.student_id)) filler.fillTable(self.ui.marksTableWidget, self.db.cursor, 4)
def setInitialValues(self): self.db.cursor.execute("SELECT name from patients where user_id=" + str(user_info.current_userID)) pat_name = self.db.cursor.fetchone() self.ui.name_label.setText(pat_name[0]) self.db.cursor.execute("SELECT passport from patients where user_id=" + str(user_info.current_userID)) pas_name = self.db.cursor.fetchone() self.ui.passport_label.setText(str(pas_name[0])) self.db.cursor.execute("SELECT date_of_birth from patients where user_id=" + str(user_info.current_userID)) date_of_birth = self.db.cursor.fetchone() self.ui.date_of_birth_label.setText(str(date_of_birth[0])) self.db.cursor.execute("SELECT phone from authentication_data WHERE id= '" + str(user_info.current_userID) + "'") phone = self.db.cursor.fetchone() self.ui.phone_number_box.setText(str(phone[0])) self.db.cursor.execute("SELECT insurance_policy from patients where user_id=" + str(user_info.current_userID)) policy = self.db.cursor.fetchone() self.ui.insurance_policy_label.setText(str(policy[0])) self.db.cursor.execute("SELECT snils from patients where user_id=" + str(user_info.current_userID)) snils = self.db.cursor.fetchone() self.ui.snils_label.setText(str(snils[0])) self.db.cursor.execute("SELECT name from specialization") filler.fillComboBox(self.ui.specialization_comboBox, self.db.cursor) self.queue_change() self.db.cursor.execute("SELECT Mr.date, Ph.name, Mr.diagnosis, S.name as Service FROM Medical_records Mr " "LEFT JOIN Physicians Ph on Ph.id = Mr.physician_id " "LEFT JOIN Services S on S.id = Mr.service_id " "WHERE Mr.patient_id = %s ORDER BY date desc" %str(patient_id[0])) filler.fillTable(self.ui.med_record_tableWIdget, self.db.cursor, 4) self.db.cursor.execute("SELECT SUM(cost) FROM (SELECT S.cost FROM Medical_records Mr " "LEFT JOIN Services S on S.id = Mr.service_id " "WHERE Mr.patient_id = %s and Mr.date > (select cast(date_trunc('month', current_date) as date)) " "ORDER BY date desc) as foo" %str(patient_id[0])) cost = self.db.cursor.fetchone() self.ui.cost_label.setText(str(cost[0]))
def specialization_change(self) : current_spec = str(self.ui.specialization_comboBox.currentText()) self.db.cursor.execute("SELECT name from physicians where specialization_id = (Select id from specialization where name = '" + current_spec + "')") filler.fillComboBox(self.ui.physician_comboBox, self.db.cursor)
def initialValues(self): self.db.cursor.execute( "SELECT name, date_of_birth, ad.phone, passport, snils, insurance_policy, contract_num " "FROM patients " "LEFT JOIN authentication_data ad on ad.id = user_id") filler.fillTable(self.ui.patients_tableWidget, self.db.cursor, 7) self.queue_button_clicked() self.show_all_physicians() self.ui.finance_info_label.setVisible(False) self.db.cursor.execute("SELECT name from specialization") filler.fillComboBox(self.ui.choose_spec_comboBox, self.db.cursor) self.db.cursor.execute("SELECT name from specialization") filler.fillComboBox(self.ui.spec_comboBox, self.db.cursor) self.db.cursor.execute("SELECT name from physicians") filler.fillComboBox(self.ui.physicians_finance_comboBox, self.db.cursor) self.show_all_med_card() self.db.cursor.execute( "SELECT Distinct Ph.name from medical_record_audit " "LEFT JOIN medical_records mr on medical_record_audit.mr_id = mr.id " "Left Join physicians ph on mr.physician_id = ph.id") filler.fillComboBox(self.ui.spec_who_change_med_card_comboBox, self.db.cursor) self.db.cursor.execute( "SELECT Ph.name from medical_records mr " "Left Join physicians ph on mr.physician_id = ph.id") filler.fillComboBox(self.ui.physician_med_card_comboBox, self.db.cursor) self.db.cursor.execute("SELECT P.name from medical_records mr " "Left Join patients p on mr.patient_id = p.id") filler.fillComboBox(self.ui.patients_med_card_comboBox, self.db.cursor) self.show_all_changes_med_card() self.db.cursor.execute("Select name from specialization") filler.fillComboBox(self.ui.specialization_comboBox, self.db.cursor) self.show_services() self.show_specializations()