示例#1
0
 def additional_out(self, header_titles: list, query: str):
     self.thread = QueryThread(query, self.connection)
     self.thread.done.connect(
         lambda: self.out(header_titles,
                          self.thread.cursor,
                          table=self._userWindow.desc_table))
     self.thread.start()
示例#2
0
 def additional_out(self, header_titles: list, query: str, callback=None):
     self.thread = QueryThread(query, self.connection)
     self.thread.done.connect(
         lambda: self.out(header_titles,
                          self.thread.cursor,
                          table=self._docWindow.desc_table,
                          callback=callback))
     self.thread.start()
示例#3
0
class DoctorController:
    currentState = 0
    SELECT_STATE: dict = {
        'none': 0,
        'disease': 1,
        'drag': 2,
        'examination': 3,
        'stat': 4
    }

    HEADERS = {
        'stat': [
            "Имя заболевания", "Январь", "Февраль", "Март", "Апрель", "Май",
            "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь",
            "Декабрь"
        ],
        'param':
        ["Имя заболеввания", "Название параметра", "Значение параметра"],
        'examination': [
            "Id",
            "Дата обследования",
            "Название обследования",
        ],
        'disease': [
            "Id", "Имя заболевания", "Дата начала", "Дата конца",
            "Описание болезни"
        ],
        'drag': [
            "Id", "Название лекарства", "Цена", "Срок годности", "Описание",
            "Масса", "Поставшик", "Надо ли рецепт"
        ]
    }

    selected_row = -1
    selected_column = -1
    selected_id = -1

    _doctor: Doctor
    _id_drag: int = 1
    _name_drag: str = ""
    _get_time_zip: str = ""
    _get_time_fio: str = ""

    _add_login: str = ""
    _add_name_disease: str = ""
    _add_date_being: str = "2000-01-01"
    _add_is_end: bool = True
    _add_date_end: str = "2000-01-01"
    _add_decs_disease: str = ""

    _change_login: str = ""
    _change_id_disease: int = 1
    _change_date_end: str = "2100-12-31"

    _see_login: str = ""

    _see_exm_login: str = ""
    _see_exm_date_begin: str = "2000-01-01"
    _see_exm_date_end: str = "2000-01-01"

    _appoint_id_disease: int = 1
    _appoint_name_drag: str = ""

    _exm_login: str = ""
    _exm_name: str = ""
    _exm_date: str = '2000-01-01'

    _param_name: str = ""
    _param_val: str = ""

    _get_stat_date: str = "2000-01-01"
    _get_stat_index: int = "220000"

    @property
    def cursor(self):
        # noinspection PyProtectedMember
        return self._doctor._user.conn.cursor()

    @property
    def connection(self):
        # noinspection PyProtectedMember
        return self._doctor._user.conn

    @property
    def login(self):
        # noinspection PyProtectedMember
        return self._doctor._user.login

    @property
    def password(self):
        # noinspection PyProtectedMember
        return self._doctor._user.password

    def set_see_exm_login(self, value):
        self._see_exm_login = value

    def set_emx_login(self, value):
        self._exm_login = value

    def set_emx_name(self, value):
        self._exm_name = value

    def set_param_name(self, value):
        self._param_name = value

    def set_param_val(self, value):
        self._param_val = value

    def set_see_login(self, value):
        self._see_login = value

    def set_add_login(self, value):
        self._add_login = value

    def set_add_name_disease(self, value):
        self._add_name_disease = value

    def set_add_date_being(self, value):
        self._add_date_being = value.toString('yyyy-MM-dd')

    def set_add_is_end(self, value):
        self._add_is_end = value
        self._docWindow.add_date_end_disease.setEnabled(value)

    def set_add_decs_disease(self, value):
        self._add_decs_disease = value

    def set_add_date_end(self, value):
        self._add_date_end = value.toString('yyyy-MM-dd')

    def set_change_date_end(self, value):
        self._change_date_end = value.toString('yyyy-MM-dd')

    def set_appoint_name_drag(self, value):
        self._appoint_name_drag = value

    def set_see_exm_date_begin(self, value):
        self._see_exm_date_begin = value.toString('yyyy-MM-dd')

    def set_see_exm_date_end(self, value):
        self._see_exm_date_end = value.toString('yyyy-MM-dd')

    def set_exm_date(self, value):
        self._exm_date = value.toString('yyyy-MM-dd')

    def set_get_stat_index(self, value):
        self._get_stat_index = value

    def set_get_stat_date(self, value):
        self._get_stat_date = value.toString('yyyy-MM-dd')

    def select_disease_patient(self):
        self.currentState = self.SELECT_STATE['disease']
        self.standard_out(
            self.HEADERS['disease'],
            "EXEC select_disease '{0}', '{1}', '{2}'".format(
                self._see_login, self.login, self.password))

    def select_add_disease_patient(self):
        self._docWindow.see_login_text_box.setText(self._add_login)
        self.standard_out(
            self.HEADERS['disease'],
            "EXEC add_disease '{0}', '{1}', '{2}', '{3}', '{4}', {5}, '{6}'".
            format(
                self._add_login, self.login, self.password,
                self._add_name_disease, self._add_date_being,
                "'{0}'".format(self._add_date_end)
                if self._add_is_end else 'NULL', self._add_decs_disease),
            callback=self.select_disease_patient)
        self.currentState = self.SELECT_STATE['disease']

    def select_change_disease_patient(self):
        if self.currentState == self.SELECT_STATE[
                'disease'] and self.selected_row != -1:
            self.standard_out(self.HEADERS['disease'],
                              "EXEC [change_disease] {0}, '{1}'".format(
                                  self.selected_id, self._change_date_end),
                              callback=self.select_disease_patient)

    def select_add_drag(self):
        if self.currentState == self.SELECT_STATE[
                'disease'] and self.selected_row != -1:
            self.additional_out(self.HEADERS['drag'],
                                "EXEC [appoint_drag] {0}, '{1}'".format(
                                    self.selected_id, self._appoint_name_drag),
                                callback=self.select_drag)

    def select_add_emx(self):
        self._docWindow.see_exm_login_text_box.setText(self._exm_login)
        self._docWindow.see_exm_date_begin.setDate(QDate(1800, 1, 1))
        self._docWindow.see_exm_date_end.setDate(QDate(3000, 1, 1))
        self.standard_out(
            self.HEADERS['examination'],
            "EXEC [add_examination] '{0}', '{1}', '{2}', '{3}', '{4}'".format(
                self.login, self.password, self._exm_login, self._exm_name,
                self._exm_date),
            callback=self.select_see_emx)

    def select_add_param(self):
        if self.currentState == self.SELECT_STATE[
                'examination'] and self.selected_row != -1:
            self.standard_out(
                self.HEADERS['disease'],
                "EXEC [add_param] '{0}', '{1}', '{2}', '{3}', '{4}'".format(
                    self.selected_id, self.login, self.password,
                    self._param_name, self._param_val),
                callback=self.select_get_param)
        else:
            QueryMessage(300)

    def select_get_param(self):
        self.additional_out(
            self.HEADERS['param'],
            "EXEC [get_doctor_examination_param] '{0}', '{1}', {2}".format(
                self.login, self.password, self.selected_id))

    def select_see_emx(self):
        self.currentState = self.SELECT_STATE['examination']
        self.standard_out(
            self.HEADERS['examination'],
            "EXEC [get_doctor_examinations] '{0}', '{1}', '{2}', '{3}', '{4}'".
            format(self._see_exm_login, self.login, self.password,
                   self._see_exm_date_begin, self._see_exm_date_end))

    def select_see_exclude_emx(self):
        self.currentState = self.SELECT_STATE['examination']
        self.standard_out(
            self.HEADERS['examination'],
            "EXEC [get_exclude_doctor_examinations] '{0}', '{1}', '{2}', '{3}', '{4}'"
            .format(self._see_exm_login, self.login, self.password,
                    self._see_exm_date_begin, self._see_exm_date_end))

    def select_drag(self):
        self.additional_out(
            self.HEADERS['drag'],
            "EXEC [get_drags_by_disease_doctor] '{0}', '{1}', {2};".format(
                self.login, self.password,
                int(self._docWindow.table.item(self.selected_row, 0).text())))

    def select_stat_by_all_time(self):
        self.currentState = self.SELECT_STATE['stat']
        self.standard_out(self.HEADERS['stat'],
                          "EXEC get_statistic_by_all_time")

    def select_stat_by_index(self):
        self.currentState = self.SELECT_STATE['stat']
        self.standard_out(
            self.HEADERS['stat'],
            "EXEC get_statistic_by_index {0}".format(self._get_stat_index))

    def select_stat_by_year(self):
        self.currentState = self.SELECT_STATE['stat']
        self.standard_out(
            self.HEADERS['stat'],
            "EXEC get_statistic_by_year '{0}'".format(self._get_stat_date))

    def select_stat_by_index_year(self):
        self.currentState = self.SELECT_STATE['stat']
        self.standard_out(
            self.HEADERS['stat'],
            "EXEC get_statistic_by_index_year {0}, '{1}'".format(
                self._get_stat_index, self._get_stat_date))

    def __init__(self, _mainController, doctor: Doctor):
        self._mainController = _mainController
        self._connection = self._mainController.conn
        self._docWindow = DoctorWindow(self)
        self._doctor = doctor

    def out(self,
            header_titles: list,
            cursor,
            table: QTableWidget = None,
            callback=None):
        if not table:
            table: QTableWidget = self._docWindow.table

        table.clearContents()
        table.setColumnCount(len(header_titles))
        table.setHorizontalHeaderLabels(header_titles)
        row = cursor.fetchone()
        table.setRowCount(0)
        table.resizeColumnsToContents()

        if not row:
            QueryMessage(399)
            return
        elif row[0] == 0 and callback is not None:
            callback()
        elif len(row) == 1:
            QueryMessage(row[0])
        else:
            row_count = 0
            while row:
                table.setRowCount(row_count + 1)
                for x in range(len(header_titles)):
                    if str(row[x]) == 'True' or str(row[x]) == 'False':
                        table.setItem(
                            row_count, x,
                            QTableWidgetItem("Да" if row[7] else "Нет"))
                    elif str(row[x]) == 'None':
                        table.setItem(row_count, x, QTableWidgetItem("-"))
                    else:
                        table.setItem(row_count, x,
                                      QTableWidgetItem(str(row[x])))
                row_count += 1
                row = cursor.fetchone()

            table.resizeColumnsToContents()

            if table == self._docWindow.table:
                self.selected_row = -1
                self.selected_column = -1
                self._docWindow.desc_table.clearContents()
                self._docWindow.desc_table.setRowCount(0)

    def standard_out(self, header_titles: list, query: str, callback=None):
        self.thread = QueryThread(query, self.connection)
        self.thread.done.connect(lambda: self.out(
            header_titles, self.thread.cursor, callback=callback))
        self.thread.start()

    def additional_out(self, header_titles: list, query: str, callback=None):
        self.thread = QueryThread(query, self.connection)
        self.thread.done.connect(
            lambda: self.out(header_titles,
                             self.thread.cursor,
                             table=self._docWindow.desc_table,
                             callback=callback))
        self.thread.start()

    def change_additional(self, row_number: int, column_number: int):
        self.selected_row = row_number
        self.selected_column = column_number
        self.selected_id = int(
            self._docWindow.table.item(row_number, 0).text())
        if self.currentState == self.SELECT_STATE['examination']:
            self.select_get_param()
        elif self.currentState == self.SELECT_STATE['disease']:
            self.select_drag()
示例#4
0
 def standard_out(self, header_titles: list, query: str, callback=None):
     self.thread = QueryThread(query, self.connection)
     self.thread.done.connect(lambda: self.out(
         header_titles, self.thread.cursor, callback=callback))
     self.thread.start()
示例#5
0
class InfoController:
    _id_drag: int = 1
    _name_drag: str = ""
    _get_time_zip: str = ""
    _get_time_fio: str = ""

    HEADERS = {
        'work_time': [
            "ФИО врача", "Время начала работы", "Время конца работы",
            "Индекс больницы"
        ],
        'drag': [
            "Id", "Название лекарства", "Цена", "Срок годности", "Описание",
            "Масса", "Поставшик", "Надо ли рецепт"
        ]
    }

    def __init__(self, _mainController):
        self._mainController = _mainController
        self._connection = self._mainController.conn
        self._infoWindow = InfoWindow(self)

    @property
    def connection(self):
        return self._connection

    def set_id_drag(self, value):
        self._id_drag = value

    def set_name_drag(self, value):
        self._name_drag = value

    def set_get_time_zip(self, value):
        self._get_time_zip = value

    def set_get_time_fio(self, value):
        self._get_time_fio = value

    def select_time_work_by_zip(self):
        self.standard_out(
            self.HEADERS['work_time'],
            "EXEC [get_time_work_by_zip] {0};".format(self._get_time_zip))

    def select_time_work_by_fio(self):
        self.standard_out(
            self.HEADERS['work_time'],
            "EXEC [get_time_work_by_fio] '{0}';".format(self._get_time_fio))

    def select_time_work(self):
        self.standard_out(
            self.HEADERS['work_time'],
            "EXEC [get_time_work_by_zip_fio] {0}, '{1}';".format(
                self._get_time_zip, self._get_time_fio))

    def select_drag_by_id(self):
        self.standard_out(self.HEADERS['drag'],
                          "EXEC [get_drag_by_id] {0};".format(self._id_drag))

    def select_drag_by_name(self):
        self.standard_out(
            self.HEADERS['drag'],
            "EXEC [get_drag_by_name] '{0}';".format(self._name_drag))

    def standard_out(self, header_titles: list, query: str):
        self.thread = QueryThread(query, self.connection)
        self.thread.done.connect(
            lambda: self.out(header_titles, self.thread.cursor))
        self.thread.start()

    def out(self, header_titles: list, cursor):
        table: QTableWidget = self._infoWindow.table

        table.clearContents()
        table.setColumnCount(len(header_titles))
        table.setHorizontalHeaderLabels(header_titles)
        row = cursor.fetchone()
        table.setRowCount(0)

        if not row:
            QueryMessage(399)
            return
        else:
            row_count = 0
            while row:
                table.setRowCount(row_count + 1)
                for x in range(len(header_titles)):
                    if str(row[x]) == 'True' or str(row[x]) == 'False':
                        table.setItem(
                            row_count, x,
                            QTableWidgetItem("Да" if row[7] else "Нет"))
                    elif str(row[x]) == 'None':
                        table.setItem(row_count, x, QTableWidgetItem("-"))
                    else:
                        table.setItem(row_count, x,
                                      QTableWidgetItem(str(row[x])))
                row_count += 1
                row = cursor.fetchone()

            table.resizeColumnsToContents()
示例#6
0
class UserController:
    currentState = 0
    SELECT_STATE: dict = {'none': 0, 'disease': 1, 'drag': 2, 'examination': 3}

    _userWindow: UserWindow
    _patient: Patient
    _date_begin_disease: date = '2000-01-01'
    _date_end_disease: date = '2000-01-01'
    _id_disease: int = 1

    _date_begin_examination = '2000-01-01'
    _date_end_examination = '2000-01-01'
    _id_examination = 1

    PARAM_HEADER = [
        "Название обследования", "Название характеристики",
        "Значение характеристики"
    ]
    DISEASE_HEADER = ["Id", "Имя болезни", "Дата начала", "Дата конца"]
    DRAG_HEADER = [
        "Id", "Название лекарства", "Цена", "Срок годности", "Описание",
        "Масса", "Поставшик", "Надо ли рецепт"
    ]
    EXAMINATION_HEADER = [
        "Id", "Название обследования", "Дата обследования", "Имя врача"
    ]

    @property
    def cursor(self):
        # noinspection PyProtectedMember
        return self._patient._user.conn.cursor()

    @property
    def connection(self):
        # noinspection PyProtectedMember
        return self._patient._user.conn

    @property
    def login(self):
        # noinspection PyProtectedMember
        return self._patient._user.login

    @property
    def password(self):
        # noinspection PyProtectedMember
        return self._patient._user.password

    def __init__(self, _mainController, user: User):
        self._mainController = _mainController
        self._patient = Patient()
        self._patient.get(user.conn, login=user.login, password=user.password)

        self._userWindow = UserWindow(self, self._patient)

    def set_date_begin_disease(self, value: date):
        self._date_begin_disease = value.toString('yyyy-MM-dd')

    def set_date_end_disease(self, value: date):
        self._date_end_disease = value.toString('yyyy-MM-dd')

    def set_date_begin_examination(self, value: date):
        self._date_begin_examination = value.toString('yyyy-MM-dd')

    def set_date_end_examination(self, value: date):
        self._date_end_examination = value.toString('yyyy-MM-dd')

    def set_id_disease(self, value: str):
        self._id_disease = value

    def set_id_examination(self, value):
        self._id_examination = value

    def select_include_disease(self):
        self.currentState = self.SELECT_STATE['disease']
        self.standard_out(
            self.DISEASE_HEADER,
            "EXEC [get_patient_diseases] '{0}', '{1}', '{2}', '{3}';".format(
                self.login, self.password, self._date_begin_disease,
                self._date_end_disease))

    def select_exclude_disease(self):
        self.currentState = self.SELECT_STATE['disease']
        self.standard_out(
            self.DISEASE_HEADER,
            "EXEC [get_inverse_patient_diseases] '{0}', '{1}', '{2}', '{3}';".
            format(self.login, self.password, self._date_begin_disease,
                   self._date_end_disease))

    def select_list_drags_by_id(self, id_):
        self.additional_out(
            self.DRAG_HEADER,
            "EXEC [get_drags_by_disease] '{0}', '{1}', {2};".format(
                self.login, self.password, id_))

    def select_examination(self):
        self.currentState = self.SELECT_STATE['examination']
        self.standard_out(
            self.EXAMINATION_HEADER,
            "EXEC [get_patient_examinations] '{0}', '{1}', '{2}', '{3}'".
            format(self.login, self.password, self._date_begin_examination,
                   self._date_end_examination))

    def select_inverse_examination(self):
        self.currentState = self.SELECT_STATE['examination']
        self.standard_out(
            self.EXAMINATION_HEADER,
            "EXEC [get_inverse_patient_examinations] '{0}', '{1}', '{2}', '{3}'"
            .format(self.login, self.password, self._date_begin_examination,
                    self._date_end_examination))

    def select_examination_param(self, id_):
        self.additional_out(
            self.PARAM_HEADER,
            "EXEC get_param_examination '{0}', '{1}', {2}".format(
                self.login, self.password, id_))

    def select_current_health_state(self):
        self.currentState = self.SELECT_STATE['none']
        self.standard_out(
            self.PARAM_HEADER + ["Дата проверки"],
            "EXEC [get_current_state_health] '{0}', '{1}'".format(
                self.login, self.password))

    def out(self, header_titles: list, cursor, table: QTableWidget = None):
        if not table:
            table: QTableWidget = self._userWindow.table

        table.clearContents()
        table.setColumnCount(len(header_titles))
        table.setHorizontalHeaderLabels(header_titles)
        row = cursor.fetchone()

        if row is None or not row:
            QueryMessage(399)
            return
        else:
            row_count = 0
            table.setRowCount(row_count)
            while row:
                table.setRowCount(row_count + 1)
                for x in range(len(header_titles)):
                    if str(row[x]) == 'True' or str(row[x]) == 'False':
                        table.setItem(
                            row_count, x,
                            QTableWidgetItem("Да" if row[7] else "Нет"))
                    elif str(row[x]) == 'None':
                        table.setItem(row_count, x, QTableWidgetItem("-"))
                    else:
                        table.setItem(row_count, x,
                                      QTableWidgetItem(str(row[x])))
                row_count += 1
                row = cursor.fetchone()

            table.resizeColumnsToContents()

            if table == self._userWindow.table:
                self.selected_row = -1
                self.selected_column = -1
                self._userWindow.desc_table.clearContents()
                self._userWindow.desc_table.setRowCount(0)

    def standard_out(self, header_titles: list, query: str):
        self.thread = QueryThread(query, self.connection)
        self.thread.done.connect(
            lambda: self.out(header_titles, self.thread.cursor))
        self.thread.start()

    def additional_out(self, header_titles: list, query: str):
        self.thread = QueryThread(query, self.connection)
        self.thread.done.connect(
            lambda: self.out(header_titles,
                             self.thread.cursor,
                             table=self._userWindow.desc_table))
        self.thread.start()

    def change_additional(self, row_number: int):
        if self.currentState == self.SELECT_STATE['examination']:
            self.select_examination_param(
                int(self._userWindow.table.item(row_number, 0).text()))
        elif self.currentState == self.SELECT_STATE['disease']:
            self.select_list_drags_by_id(
                int(self._userWindow.table.item(row_number, 0).text()))