Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vision-macula.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added database.db
Binary file not shown.
Binary file added database_schema.sql
Binary file not shown.
Binary file added src/bsmu/macula/app/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/bsmu/macula/app/database.db
Binary file not shown.
Binary file added src/bsmu/macula/app/edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added src/bsmu/macula/app/example.db
Empty file.
Binary file added src/bsmu/macula/app/images/icons/edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ plugins:

- bsmu.vision.plugins.task_storage_view.TaskStorageViewPlugin

- bsmu.macula.plugins.db.BD.BD
- bsmu.macula.plugins.gui.ensemble_segmenter_gui.EnsembleSegmenterGuiPlugin
- bsmu.macula.plugins.db.database_manager.DatabaseManager
Empty file.
52 changes: 52 additions & 0 deletions src/bsmu/macula/plugins/db/BD.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from PySide6.QtCore import Qt
from bsmu.vision.core.plugins import Plugin
from bsmu.vision.plugins.doc_interfaces.mdi import MdiPlugin
from bsmu.vision.plugins.windows.main import AlgorithmsMenu, MainWindowPlugin, MainWindow

from bsmu.macula.plugins.db.SQLiteTableViewer import TableWidgetExample
from bsmu.macula.plugins.ensemble_segmenter import BinaryEnsemblePlugin

if TYPE_CHECKING:
pass
class BD(Plugin):
_DEFAULT_DEPENDENCY_PLUGIN_FULL_NAME_BY_KEY = {
'main_window_plugin': 'bsmu.vision.plugins.windows.main.MainWindowPlugin',
'mdi_plugin': 'bsmu.vision.plugins.doc_interfaces.mdi.MdiPlugin'
}

def __init__(
self,
main_window_plugin: MainWindowPlugin,
mdi_plugin: MdiPlugin
):
super().__init__()
self._main_window_plugin = main_window_plugin
self._mdi_plugin = mdi_plugin

self._ensemble_segmenter_gui: BinaryEnsemblePlugin | None = None
self._main_window: MainWindow | None = None

@property
def ensemble_segmenter_gui(self) -> BinaryEnsemblePlugin | None:
return self._ensemble_segmenter_gui

def _enable_gui(self):
self._main_window = self._main_window_plugin.main_window

self._main_window.add_menu_action(
AlgorithmsMenu,
self.tr('BD'),
self._re
)
def _re(self):
self.window = TableWidgetExample()
self.window.setWindowModality(Qt.ApplicationModal)
self.window.show()

def _disable(self):
self._ensemble_segmenter_gui = None
self._main_window = None
494 changes: 494 additions & 0 deletions src/bsmu/macula/plugins/db/SQLiteTableViewer.py

Large diffs are not rendered by default.

Empty file.
72 changes: 72 additions & 0 deletions src/bsmu/macula/plugins/db/add_appointment_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from functools import partial

from PySide6.QtSql import QSqlQuery
from PySide6.QtWidgets import QDialog, QLineEdit, QPushButton, QVBoxLayout, QLabel

from bsmu.macula.plugins.db.database_manager import DatabaseManager


class AddApponitmentDialog(QDialog):
def __init__(self, appotintment_id):
super().__init__()
self.db_manager = DatabaseManager()
self.is_new_appointment = appotintment_id == 0
self.setWindowTitle("Добавить прием" if self.is_new_appointment else "Изменить данные приема")

self.name_input = QLineEdit()
self.sex_input = QLineEdit()
self.age_input = QLineEdit()
self.save_button = QPushButton("Сохранить" if self.is_new_appointment else "Редактировать")
if (self.is_new_appointment):
self.save_button.clicked.connect(self.save_data)
else:
self.save_button.clicked.connect(partial(self.edit_data, appotintment_id))

layout = QVBoxLayout()
layout.addWidget(QLabel("Имя:"))
layout.addWidget(self.name_input)
layout.addWidget(QLabel("Пол:"))
layout.addWidget(self.sex_input)
layout.addWidget(QLabel("Год рождения:"))
layout.addWidget(self.age_input)
layout.addWidget(self.save_button)

if (not self.is_new_appointment):
record = self.db_manager.fetch_record_by_id("pacients", appotintment_id)
# query = QSqlQuery(self.db)
# query.prepare("SELECT id, name, sex, year_of_birthday FROM pacients WHERE id = :pacient_id")
# query.bindValue(":pacient_id", patient_id)
# query.exec_()
# self.appointments_model = QSqlQueryModel()
# self.appointments_model.setQuery(query)
self.name_input.setText(record[0][1])
self.sex_input.setText(record[0][2])
self.age_input.setText(str(record[0][3]))
self.setLayout(layout)

def save_data(self):
name = self.name_input.text()
sex = self.sex_input.text()
age = self.age_input.text()

if name and age.isdigit():
query = QSqlQuery(self.db)
query.prepare("INSERT INTO pacients (name, sex, year_of_birthday) VALUES (?, ?, ?)")
query.addBindValue(name)
query.addBindValue(sex)
query.addBindValue(int(age))
query.exec_()
self.close()
else:
print("Ошибка: введите корректные данные")

def edit_data(self, patient_id):
name = self.name_input.text()
sex = self.sex_input.text()
age = self.age_input.text()

if name and sex and age.isdigit():
self.db_manager.update_pacient(name, sex, int(age), patient_id)
self.close()
else:
print("Ошибка: введите корректные данные")
80 changes: 80 additions & 0 deletions src/bsmu/macula/plugins/db/add_patient_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
from functools import partial

from PySide6.QtSql import QSqlQuery
from PySide6.QtWidgets import QDialog, QLineEdit, QPushButton, QVBoxLayout, QLabel

from bsmu.macula.plugins.db.database_manager import DatabaseManager


class AddRecordDialog(QDialog):
def __init__(self, db, patient_id):
super().__init__()
self.db = db
self.db_manager = DatabaseManager()
self.is_new_user = patient_id == 0
self.setWindowTitle("Добавить пациента" if self.is_new_user else "Изменить данные пациента")

self.name_input = QLineEdit()
self.sex_input = QLineEdit()
self.age_input = QLineEdit()
self.save_button = QPushButton("Сохранить" if self.is_new_user else "Редактировать")
if (self.is_new_user):
self.save_button.clicked.connect(self.save_data)
else:
self.save_button.clicked.connect(partial(self.edit_data, patient_id))

layout = QVBoxLayout()
layout.addWidget(QLabel("Имя:"))
layout.addWidget(self.name_input)
layout.addWidget(QLabel("Пол:"))
layout.addWidget(self.sex_input)
layout.addWidget(QLabel("Год рождения:"))
layout.addWidget(self.age_input)
layout.addWidget(self.save_button)

if (not self.is_new_user):
record = self.db_manager.fetch_record_by_id("pacients", patient_id)
# query = QSqlQuery(self.db)
# query.prepare("SELECT id, name, sex, year_of_birthday FROM pacients WHERE id = :pacient_id")
# query.bindValue(":pacient_id", patient_id)
# query.exec_()
# self.appointments_model = QSqlQueryModel()
# self.appointments_model.setQuery(query)
self.name_input.setText(record[0][1])
self.sex_input.setText(record[0][2])
self.age_input.setText(str(record[0][3]))
self.setLayout(layout)

def save_data(self):
name = self.name_input.text()
sex = self.sex_input.text()
age = self.age_input.text()

if name and age.isdigit():
query = QSqlQuery(self.db)
query.prepare("INSERT INTO pacients (name, sex, year_of_birthday) VALUES (?, ?, ?)")
query.addBindValue(name)
query.addBindValue(sex)
query.addBindValue(int(age))
query.exec_()
self.close()
else:
print("Ошибка: введите корректные данные")

def edit_data(self, patient_id):
name = self.name_input.text()
sex = self.sex_input.text()
age = self.age_input.text()

if name and sex and age.isdigit():
self.db_manager.update_pacient(name, sex, int(age), patient_id)
# query = QSqlQuery(self.db)
# query.prepare("UPDATE pacients SET name = ? WHERE id = ?")
# query.addBindValue(name)
# query.addBindValue(sex)
# query.addBindValue(int(age))
# query.addBindValue(patient_id)
# bol = query.exec_()
self.close()
else:
print("Ошибка: введите корректные данные")
Loading