...ведение приёма...

This commit is contained in:
Бородин Роман 2019-12-13 23:42:46 +03:00
parent e8f4add6b9
commit 9dba62b751
8 changed files with 331 additions and 18 deletions

15
app.py
View File

@ -5,7 +5,7 @@ from mods.db import db, Patient, Catalog, List
from mods.catalogs import create_new_catalog_win, build_catalog_row, catalog_sort_func, catalog_filter_func from mods.catalogs import create_new_catalog_win, build_catalog_row, catalog_sort_func, catalog_filter_func
from mods.patients import build_patient_row, patient_sort_func, patient_filter_func_factory, create_new_patient_win, create_open_patient_win from mods.patients import build_patient_row, patient_sort_func, patient_filter_func_factory, create_new_patient_win, create_open_patient_win
from mods.patients import search_patients from mods.patients import search_patients
from mods.receptions import create_new_reception_win, redraw_reception_list, create_reception_list_settings_win from mods.receptions import create_new_reception_win, redraw_reception_list, create_reception_list_settings_win, create_open_reception_win
from mods.lists import create_open_list_win, build_list_row from mods.lists import create_open_list_win, build_list_row
from mods.root import builder from mods.root import builder
from mods.utils import enable_widget, disable_widget, ConditionalFilter from mods.utils import enable_widget, disable_widget, ConditionalFilter
@ -36,6 +36,9 @@ class MainWinHandler:
def show_new_reception_win(self, button): def show_new_reception_win(self, button):
new_reception_win = create_new_reception_win() new_reception_win = create_new_reception_win()
new_reception_win.show_all() new_reception_win.show_all()
def show_open_reception_win(self, button):
open_reception_win = create_open_reception_win()
open_reception_win.show_all()
def show_new_patient_win(self, button): def show_new_patient_win(self, button):
new_patient_win = create_new_patient_win() new_patient_win = create_new_patient_win()
new_patient_win.show_all() new_patient_win.show_all()
@ -56,19 +59,21 @@ class MainWinHandler:
rl = builder.get_object('reception_list') rl = builder.get_object('reception_list')
new_button = builder.get_object('new_reception_button') new_button = builder.get_object('new_reception_button')
edit_button = builder.get_object('edit_reception_button') edit_button = builder.get_object('edit_reception_button')
remove_button = builder.get_object('remove_reception_button')
row = rl.get_selected_row() row = rl.get_selected_row()
if not row: if not row:
return return True
if row.props.scheduled: if row.props.scheduled:
enable_widget([edit_button]) enable_widget([edit_button, remove_button])
disable_widget([new_button]) disable_widget([new_button])
else: else:
enable_widget([new_button]) enable_widget([new_button])
disable_widget([edit_button]) disable_widget([edit_button, remove_button])
def reception_list_unselected(self, *a): def reception_list_unselected(self, *a):
new_button = builder.get_object('new_reception_button') new_button = builder.get_object('new_reception_button')
edit_button = builder.get_object('edit_reception_button') edit_button = builder.get_object('edit_reception_button')
disable_widget([new_button, edit_button]) remove_button = builder.get_object('remove_reception_button')
disable_widget([new_button, edit_button, remove_button])
def patient_list_selected(self, *a): def patient_list_selected(self, *a):
button = builder.get_object('patient_open_button') button = builder.get_object('patient_open_button')
enable_widget([button]) enable_widget([button])

View File

@ -34,3 +34,4 @@ new_reception_win_file = os.path.join(ui_dir, 'new_reception_win.glade')
reception_list_settings_win_file = os.path.join(ui_dir, 'reception_list_settings.glade') reception_list_settings_win_file = os.path.join(ui_dir, 'reception_list_settings.glade')
new_catalog_win_file = os.path.join(ui_dir, 'new_catalog_win.glade') new_catalog_win_file = os.path.join(ui_dir, 'new_catalog_win.glade')
choose_patient_win_file = os.path.join(ui_dir, 'choose_patient_win.glade') choose_patient_win_file = os.path.join(ui_dir, 'choose_patient_win.glade')
open_reception_win_file = os.path.join(ui_dir, 'open_reception_win.glade')

View File

@ -11,7 +11,8 @@ lists_map = {
'diagnoz': 'Диагноз', 'diagnoz': 'Диагноз',
'anamnez': 'Анамнез', 'anamnez': 'Анамнез',
'observ': 'Осмотр', 'observ': 'Осмотр',
'druggs': 'Медикаменты' 'medicines': 'Медикаменты',
'procedures': 'Процедуры'
} }
for s_id in lists_map: for s_id in lists_map:

View File

@ -43,6 +43,9 @@ def search_patients(q):
def get_all_patients(): def get_all_patients():
with db.atomic(): with db.atomic():
return Patient.select() return Patient.select()
def get_patient(patient_id):
with db.atomic():
return Patient.get_by_id(patient_id)
class PatientRow(Gtk.ListBoxRow): class PatientRow(Gtk.ListBoxRow):
@GObject.Property @GObject.Property

View File

@ -2,7 +2,7 @@ import gi
gi.require_version('Gtk', '3.0') gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GObject, Gdk from gi.repository import Gtk, GObject, Gdk
from mods.db import db, Reception, Patient from mods.db import db, Reception, Patient
from mods.files import new_reception_win_file, reception_row_ui_str, reception_list_settings_win_file from mods.files import new_reception_win_file, reception_row_ui_str, reception_list_settings_win_file, open_reception_win_file
from mods.settings import s_get_reception_list, s_set_reception_list from mods.settings import s_get_reception_list, s_set_reception_list
from mods.root import builder from mods.root import builder
from datetime import datetime, timedelta from datetime import datetime, timedelta
@ -47,6 +47,10 @@ class NewReceptionPatientLabel(Gtk.Label):
def db_id_setter(self, value): def db_id_setter(self, value):
self._db_id = value self._db_id = value
def get_reception(reception_id):
with db.atomic():
return Reception.get_by_id(reception_id)
def build_reception_row(reception_datetime): def build_reception_row(reception_datetime):
b = Gtk.Builder() b = Gtk.Builder()
b.add_from_string(reception_row_ui_str) b.add_from_string(reception_row_ui_str)
@ -75,6 +79,23 @@ def build_reception_row(reception_datetime):
row.add(box) row.add(box)
return row return row
def create_open_reception_win():
b = Gtk.Builder()
reception_list = builder.get_object('reception_list')
reception_row = reception_list.get_selected_row()
reception = get_reception(reception_row.props.db_id)
class OpenReceptionWinHandler:
pass
b.add_from_file(open_reception_win_file)
b.connect_signals(OpenReceptionWinHandler())
#
patient_fio = b.get_object('patient_fio')
patient_fio.set_markup(f'<span size="x-large">{" ".join([reception.patient.last_name, reception.patient.first_name, reception.patient.middle_name])}</span>')
reception_dt = b.get_object('reception_datetime')
reception_dt.set_markup(f'<span size="x-large">{reception_row.props.datetime.strftime("%d.%m.%Y - %H:%M")}</span>')
#
w = b.get_object('open_reception_window')
return w
def create_new_reception_win(): def create_new_reception_win():
b = Gtk.Builder() b = Gtk.Builder()
reception_list = builder.get_object('reception_list') reception_list = builder.get_object('reception_list')
@ -88,7 +109,7 @@ def create_new_reception_win():
pat_label = patient_cont.get_children()[0] pat_label = patient_cont.get_children()[0]
if pat_label.props.db_id < 0: if pat_label.props.db_id < 0:
return return
rec = add_reception(pat_label.props.db_id, row.props.datetime) _ = add_reception(pat_label.props.db_id, row.props.datetime)
w.destroy() w.destroy()
redraw_reception_list(row.props.datetime) redraw_reception_list(row.props.datetime)
b.add_from_file(new_reception_win_file) b.add_from_file(new_reception_win_file)
@ -103,7 +124,7 @@ def create_new_reception_win():
patient_cont.reorder_child(patient_label, 0) patient_cont.reorder_child(patient_label, 0)
w = b.get_object('new_reception_window') w = b.get_object('new_reception_window')
dt_label = b.get_object('datetime') dt_label = b.get_object('datetime')
dt_label.set_text(row.props.datetime.strftime('%m.%d.%Y - %H:%M')) dt_label.set_text(row.props.datetime.strftime('%d.%m.%Y - %H:%M'))
return w return w
def create_reception_list_settings_win(): def create_reception_list_settings_win():
b = Gtk.Builder() b = Gtk.Builder()

View File

@ -0,0 +1,169 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkWindow" id="choose_list_window">
<property name="width_request">600</property>
<property name="height_request">500</property>
<property name="can_focus">False</property>
<property name="modal">True</property>
<property name="window_position">center</property>
<property name="default_width">800</property>
<property name="default_height">500</property>
<property name="type_hint">dialog</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="list_win_header">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="show_close_button">True</property>
<child>
<object class="GtkButton" id="accept_button">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">object-select-symbolic</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="add_button">
<property name="label">gtk-add</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<property name="always_show_image">True</property>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="edit_button">
<property name="label">gtk-edit</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<property name="always_show_image">True</property>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkButton" id="remove_button">
<property name="label">gtk-remove</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<property name="always_show_image">True</property>
</object>
<packing>
<property name="position">4</property>
</packing>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkListBox" id="listrecord_list">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">3</property>
<property name="margin_bottom">3</property>
<child>
<object class="GtkFixed">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSearchEntry" id="listrecord_filter">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_name">edit-find-symbolic</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkFixed">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@ -69,9 +69,24 @@
<property name="sensitive">False</property> <property name="sensitive">False</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Изменить</property> <property name="tooltip_text" translatable="yes">Изменить</property>
<property name="label" translatable="yes">Изменить</property> <property name="label" translatable="yes">Открыть</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="stock_id">gtk-edit</property> <property name="stock_id">gtk-open</property>
<signal name="clicked" handler="show_open_reception_win" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="remove_reception_button">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Удалить</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-no</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>

View File

@ -64,7 +64,6 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin_left">5</property> <property name="margin_left">5</property>
<property name="margin_right">5</property> <property name="margin_right">5</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property> <property name="margin_bottom">5</property>
<property name="left_padding">12</property> <property name="left_padding">12</property>
<child> <child>
@ -104,7 +103,6 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin_left">5</property> <property name="margin_left">5</property>
<property name="margin_right">5</property> <property name="margin_right">5</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property> <property name="margin_bottom">5</property>
<property name="left_padding">12</property> <property name="left_padding">12</property>
<child> <child>
@ -222,6 +220,26 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-delete</property>
<property name="icon_size">3</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child> <child>
<object class="GtkFixed"> <object class="GtkFixed">
<property name="visible">True</property> <property name="visible">True</property>
@ -230,7 +248,7 @@
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</object> </object>
@ -340,6 +358,26 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-delete</property>
<property name="icon_size">3</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child> <child>
<object class="GtkFixed"> <object class="GtkFixed">
<property name="visible">True</property> <property name="visible">True</property>
@ -348,7 +386,7 @@
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</object> </object>
@ -469,6 +507,26 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-delete</property>
<property name="icon_size">3</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child> <child>
<object class="GtkFixed"> <object class="GtkFixed">
<property name="visible">True</property> <property name="visible">True</property>
@ -477,7 +535,7 @@
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</object> </object>
@ -587,6 +645,26 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-delete</property>
<property name="icon_size">3</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child> <child>
<object class="GtkFixed"> <object class="GtkFixed">
<property name="visible">True</property> <property name="visible">True</property>
@ -595,7 +673,7 @@
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</object> </object>
@ -716,6 +794,26 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-delete</property>
<property name="icon_size">3</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child> <child>
<object class="GtkFixed"> <object class="GtkFixed">
<property name="visible">True</property> <property name="visible">True</property>
@ -724,7 +822,7 @@
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</object> </object>