Рерганизация кода и начало нового приёма
This commit is contained in:
parent
318de06602
commit
ac0a237b19
190
app.py
190
app.py
|
@ -1,73 +1,17 @@
|
|||
import gi
|
||||
import os
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk, GObject, Gdk
|
||||
from mods.db import db, Patient, Reception, Catalog, List
|
||||
from mods.settings import s_get_reception_list, s_set_reception_list
|
||||
from mods.catalogs import add_catalog, search_catalogs
|
||||
from gi.repository import Gtk
|
||||
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.patients import build_patient_row, patient_sort_func, patient_filter_func_factory, create_new_patient_win, create_open_patient_win
|
||||
from mods.receptions import create_new_reception_win, build_reception_row
|
||||
from mods.lists import create_open_list_win
|
||||
from mods.files import list_row_ui_str
|
||||
from mods.utils import show_msg, ConditionalFilter, enable_widget, disable_widget
|
||||
from datetime import datetime, timedelta
|
||||
import peewee
|
||||
import re
|
||||
from mods.patients import search_patients
|
||||
from mods.receptions import create_new_reception_win, redraw_reception_list, create_reception_list_settings_win
|
||||
from mods.lists import create_open_list_win, build_list_row
|
||||
from mods.root import builder
|
||||
from mods.utils import enable_widget, disable_widget, ConditionalFilter
|
||||
from datetime import datetime
|
||||
|
||||
# Variables
|
||||
resource_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'res')
|
||||
ui_dir = os.path.join(resource_dir, 'ui')
|
||||
|
||||
main_win_file = os.path.join(ui_dir, 'main_win.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')
|
||||
|
||||
catalog_row_file = os.path.join(ui_dir, 'catalog_list_row.glade')
|
||||
with open(catalog_row_file, 'r') as f:
|
||||
catalog_row_ui_str = f.read()
|
||||
|
||||
############
|
||||
|
||||
builder = Gtk.Builder()
|
||||
|
||||
def get_reception_timelist(rec_date):
|
||||
s = s_get_reception_list()
|
||||
dstart = datetime(rec_date.year, rec_date.month, rec_date.day, s.day_start[0], s.day_start[1])
|
||||
dend = datetime(rec_date.year, rec_date.month, rec_date.day, s.day_end[0], s.day_end[1])
|
||||
work_day_minutes_total = (dend.hour - dstart.hour) * 60 + dend.minute - dstart.minute
|
||||
shift_minutes_range = range(0, work_day_minutes_total, s.interval)
|
||||
return [dstart + timedelta(minutes=x) for x in shift_minutes_range]
|
||||
|
||||
|
||||
catalog_filter = ConditionalFilter(search_catalogs)
|
||||
|
||||
class CatalogRow(Gtk.ListBoxRow):
|
||||
@GObject.Property
|
||||
def db_id(self):
|
||||
return self._db_id
|
||||
@db_id.setter
|
||||
def db_id_setter(self, value):
|
||||
self._db_id = value
|
||||
@GObject.Property
|
||||
def name(self):
|
||||
return self._name
|
||||
@name.setter
|
||||
def name_setter(self, value):
|
||||
self._name = value
|
||||
class ListRow(Gtk.ListBoxRow):
|
||||
@GObject.Property
|
||||
def db_id(self):
|
||||
return self._db_id
|
||||
@db_id.setter
|
||||
def db_id_setter(self, value):
|
||||
self._db_id = value
|
||||
@GObject.Property
|
||||
def name(self):
|
||||
return self._name
|
||||
@name.setter
|
||||
def name_setter(self, value):
|
||||
self._name = value
|
||||
patient_filter = ConditionalFilter(search_patients)
|
||||
|
||||
class MainWinHandler:
|
||||
def main_win_close(self, *args):
|
||||
|
@ -82,20 +26,23 @@ class MainWinHandler:
|
|||
cal = builder.get_object('reception_cal')
|
||||
cal_date = cal.get_date()
|
||||
d = datetime(cal_date.year, cal_date.month + 1, cal_date.day)
|
||||
rl = builder.get_object('reception_list')
|
||||
rl.unselect_all()
|
||||
self.reception_list_unselected()
|
||||
redraw_reception_list(d)
|
||||
def show_reception_list_settings_win(self, button):
|
||||
reception_list_settings_win = create_reception_list_settings_win()
|
||||
reception_list_settings_win.show_all()
|
||||
def show_new_reception_win(self, button):
|
||||
new_reception_win = create_new_reception_win(builder)
|
||||
new_reception_win = create_new_reception_win()
|
||||
new_reception_win.show_all()
|
||||
def show_new_patient_win(self, button):
|
||||
new_patient_win = create_new_patient_win(patient_list)
|
||||
new_patient_win = create_new_patient_win()
|
||||
new_patient_win.show_all()
|
||||
def show_open_patient_win(self, button):
|
||||
pl = builder.get_object('patient_list')
|
||||
row = pl.get_selected_row()
|
||||
open_patient_win = create_open_patient_win(row.props.db_id, patient_list)
|
||||
open_patient_win = create_open_patient_win(row.props.db_id)
|
||||
open_patient_win.show_all()
|
||||
def show_open_list_win(self, button):
|
||||
ll = builder.get_object('list_list')
|
||||
|
@ -103,19 +50,25 @@ class MainWinHandler:
|
|||
open_list_win = create_open_list_win(row.props.db_id)
|
||||
open_list_win.show_all()
|
||||
def show_new_catalog_win(self, button):
|
||||
new_catalog_win = create_new_catalog_win()
|
||||
new_catalog_win = create_new_catalog_win(catalog_list)
|
||||
new_catalog_win.show_all()
|
||||
def reception_list_selected(self, *a):
|
||||
rl = builder.get_object('reception_list')
|
||||
new_button = builder.get_object('new_reception_button')
|
||||
edit_button = builder.get_object('edit_reception_button')
|
||||
row = rl.get_selected_row()
|
||||
if not row:
|
||||
return
|
||||
if row.props.scheduled:
|
||||
enable_widget([edit_button])
|
||||
disable_widget([new_button])
|
||||
else:
|
||||
enable_widget([new_button])
|
||||
disable_widget([edit_button])
|
||||
def reception_list_unselected(self, *a):
|
||||
new_button = builder.get_object('new_reception_button')
|
||||
edit_button = builder.get_object('edit_reception_button')
|
||||
disable_widget([new_button, edit_button])
|
||||
def patient_list_selected(self, *a):
|
||||
button = builder.get_object('patient_open_button')
|
||||
enable_widget([button])
|
||||
|
@ -144,67 +97,20 @@ class MainWinHandler:
|
|||
self.catalog_list_unselected()
|
||||
cl.invalidate_filter()
|
||||
|
||||
def build_list_row(list_o):
|
||||
b = Gtk.Builder()
|
||||
b.add_from_string(list_row_ui_str)
|
||||
win = b.get_object('win')
|
||||
box = b.get_object('list_box')
|
||||
b.get_object('name').set_text(list_o.name)
|
||||
row = ListRow()
|
||||
row.props.db_id = list_o.id
|
||||
row.name = list_o.name
|
||||
win.remove(win.get_children()[0])
|
||||
row.add(box)
|
||||
return row
|
||||
|
||||
def build_catalog_row(catalog):
|
||||
b = Gtk.Builder()
|
||||
b.add_from_string(catalog_row_ui_str)
|
||||
win = b.get_object('win')
|
||||
box = b.get_object('catalog_box')
|
||||
b.get_object('name').set_text(catalog.name)
|
||||
row = CatalogRow()
|
||||
row.props.db_id = catalog.id
|
||||
row.name = catalog.name
|
||||
win.remove(win.get_children()[0])
|
||||
row.add(box)
|
||||
return row
|
||||
|
||||
|
||||
|
||||
|
||||
def list_sort_func(row1, row2, *a):
|
||||
text1 = row1.props.name
|
||||
text2 = row2.props.name
|
||||
return (text1 > text2) - (text1 < text2)
|
||||
def catalog_sort_func(row1, row2, *a):
|
||||
text1 = row1.props.name
|
||||
text2 = row2.props.name
|
||||
return (text1 > text2) - (text1 < text2)
|
||||
def catalog_filter_func(row):
|
||||
fstr = builder.get_object('catalog_filter').get_text().strip()
|
||||
if not fstr:
|
||||
catalog_filter.reset()
|
||||
return True
|
||||
return row.props.db_id in catalog_filter.filter(fstr)
|
||||
|
||||
def redraw_reception_list(selected_date):
|
||||
reception_timelist = get_reception_timelist(selected_date)
|
||||
reception_list = builder.get_object('reception_list')
|
||||
for c in reception_list.get_children():
|
||||
reception_list.remove(c)
|
||||
for d in reception_timelist:
|
||||
reception_list.add(build_reception_row(d))
|
||||
reception_list.show_all()
|
||||
|
||||
builder.add_from_file(main_win_file)
|
||||
builder.connect_signals(MainWinHandler())
|
||||
#####
|
||||
redraw_reception_list(datetime.now())
|
||||
#####
|
||||
patient_list = builder.get_object('patient_list')
|
||||
patient_list.set_sort_func(patient_sort_func)
|
||||
patient_list.set_filter_func(patient_filter_func_factory(builder))
|
||||
patient_list.set_filter_func(patient_filter_func_factory(patient_filter, builder))
|
||||
with db.atomic():
|
||||
for p in Patient.select():
|
||||
patient_list.add(build_patient_row(p))
|
||||
|
@ -222,54 +128,6 @@ with db.atomic():
|
|||
for c in Catalog.select():
|
||||
catalog_list.add(build_catalog_row(c))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def create_reception_list_settings_win():
|
||||
b = Gtk.Builder()
|
||||
class ReceptionListSettingsHandler:
|
||||
def save_settings(self, *a):
|
||||
start_hour = int(b.get_object('start_hour').get_value())
|
||||
start_minute = int(b.get_object('start_minute').get_value())
|
||||
end_hour = int(b.get_object('end_hour').get_value())
|
||||
end_minute = int(b.get_object('end_minute').get_value())
|
||||
interval = int(b.get_object('interval').get_value())
|
||||
s_set_reception_list([start_hour, start_minute], [end_hour, end_minute], interval)
|
||||
redraw_reception_list(datetime.now())
|
||||
b.get_object('reception_list_settings_win').close()
|
||||
b.add_from_file(reception_list_settings_win_file)
|
||||
b.connect_signals(ReceptionListSettingsHandler())
|
||||
s = s_get_reception_list()
|
||||
b.get_object('start_hour').set_value(s.day_start[0])
|
||||
b.get_object('start_minute').set_value(s.day_start[1])
|
||||
b.get_object('end_hour').set_value(s.day_end[0])
|
||||
b.get_object('end_minute').set_value(s.day_end[1])
|
||||
b.get_object('interval').set_value(s.interval)
|
||||
w = b.get_object('reception_list_settings_win')
|
||||
return w
|
||||
|
||||
def create_new_catalog_win():
|
||||
b = Gtk.Builder()
|
||||
class NewCatalogHandler:
|
||||
def save_catalog(self, *a):
|
||||
catname = re.sub(r'\s+', ' ', b.get_object('catalog_name').get_text()).strip()
|
||||
if not len(catname):
|
||||
return show_msg('Не указано имя справочника', 'Данное поле должно быть заполнено', level='warn')
|
||||
try:
|
||||
catalog = add_catalog(catname)
|
||||
except peewee.IntegrityError:
|
||||
return show_msg('Данный справочник уже существует', 'Справочник с указанным названием уже есть с базе данных', level='warn')
|
||||
row = build_catalog_row(catalog)
|
||||
catalog_list.add(row)
|
||||
catalog_list.select_row(row)
|
||||
catalog_list.show_all()
|
||||
b.get_object('new_catalog_window').close()
|
||||
b.add_from_file(new_catalog_win_file)
|
||||
b.connect_signals(NewCatalogHandler())
|
||||
w = b.get_object('new_catalog_window')
|
||||
return w
|
||||
|
||||
main_win = builder.get_object('main_window')
|
||||
main_win.show_all()
|
||||
Gtk.main()
|
||||
|
|
|
@ -1,5 +1,26 @@
|
|||
from mods.db import db, Catalog, CatalogIndex
|
||||
import re
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk, GObject
|
||||
from mods.utils import show_msg, ConditionalFilter
|
||||
from mods.files import catalog_row_ui_str, new_catalog_win_file
|
||||
from mods.root import builder
|
||||
import peewee
|
||||
|
||||
class CatalogRow(Gtk.ListBoxRow):
|
||||
@GObject.Property
|
||||
def db_id(self):
|
||||
return self._db_id
|
||||
@db_id.setter
|
||||
def db_id_setter(self, value):
|
||||
self._db_id = value
|
||||
@GObject.Property
|
||||
def name(self):
|
||||
return self._name
|
||||
@name.setter
|
||||
def name_setter(self, value):
|
||||
self._name = value
|
||||
|
||||
def add_catalog(name):
|
||||
with db.atomic():
|
||||
|
@ -23,3 +44,52 @@ def search_catalogs(q):
|
|||
.where(CatalogIndex.match(q))
|
||||
.order_by(CatalogIndex.bm25()))
|
||||
|
||||
catalog_filter = ConditionalFilter(search_catalogs)
|
||||
|
||||
###########################################################################
|
||||
|
||||
def build_catalog_row(catalog):
|
||||
b = Gtk.Builder()
|
||||
b.add_from_string(catalog_row_ui_str)
|
||||
win = b.get_object('win')
|
||||
box = b.get_object('catalog_box')
|
||||
b.get_object('name').set_text(catalog.name)
|
||||
row = CatalogRow()
|
||||
row.props.db_id = catalog.id
|
||||
row.name = catalog.name
|
||||
win.remove(win.get_children()[0])
|
||||
row.add(box)
|
||||
return row
|
||||
|
||||
def create_new_catalog_win(catalog_list):
|
||||
b = Gtk.Builder()
|
||||
class NewCatalogHandler:
|
||||
def save_catalog(self, *a):
|
||||
catname = re.sub(r'\s+', ' ', b.get_object('catalog_name').get_text()).strip()
|
||||
if not len(catname):
|
||||
return show_msg('Не указано имя справочника', 'Данное поле должно быть заполнено', level='warn')
|
||||
try:
|
||||
catalog = add_catalog(catname)
|
||||
except peewee.IntegrityError:
|
||||
return show_msg('Данный справочник уже существует', 'Справочник с указанным названием уже есть с базе данных', level='warn')
|
||||
row = build_catalog_row(catalog)
|
||||
catalog_list.add(row)
|
||||
catalog_list.select_row(row)
|
||||
catalog_list.show_all()
|
||||
b.get_object('new_catalog_window').close()
|
||||
b.add_from_file(new_catalog_win_file)
|
||||
b.connect_signals(NewCatalogHandler())
|
||||
w = b.get_object('new_catalog_window')
|
||||
return w
|
||||
|
||||
def catalog_sort_func(row1, row2, *a):
|
||||
text1 = row1.props.name
|
||||
text2 = row2.props.name
|
||||
return (text1 > text2) - (text1 < text2)
|
||||
def catalog_filter_func(row):
|
||||
fstr = builder.get_object('catalog_filter').get_text().strip()
|
||||
if not fstr:
|
||||
catalog_filter.reset()
|
||||
return True
|
||||
return row.props.db_id in catalog_filter.filter(fstr)
|
||||
|
||||
|
|
|
@ -22,8 +22,15 @@ with open(female_patient_row_file, 'r') as f:
|
|||
reception_row_file = os.path.join(ui_dir, 'reception_row.glade')
|
||||
with open(reception_row_file, 'r') as f:
|
||||
reception_row_ui_str = f.read()
|
||||
catalog_row_file = os.path.join(ui_dir, 'catalog_list_row.glade')
|
||||
with open(catalog_row_file, 'r') as f:
|
||||
catalog_row_ui_str = f.read()
|
||||
|
||||
main_win_file = os.path.join(ui_dir, 'main_win.glade')
|
||||
new_patient_win_file = os.path.join(ui_dir, 'new_patient_win.glade')
|
||||
open_patient_win_file = os.path.join(ui_dir, 'open_patient_win.glade')
|
||||
edit_patient_win_file = os.path.join(ui_dir, 'edit_patient_win.glade')
|
||||
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')
|
||||
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')
|
||||
|
|
|
@ -2,7 +2,7 @@ import gi
|
|||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk, GObject, Gdk
|
||||
from mods.db import db, List, ListRecord, ListRecordIndex
|
||||
from mods.files import open_list_win_file, listrecord_row_ui_str, editable_row_ui_str
|
||||
from mods.files import open_list_win_file, listrecord_row_ui_str, editable_row_ui_str, list_row_ui_str
|
||||
from mods.utils import show_msg, disable_widget, enable_widget, ConditionalFilter
|
||||
import re
|
||||
import peewee
|
||||
|
@ -27,6 +27,20 @@ class ListRecFilter(ConditionalFilter):
|
|||
self.ids = list(map(lambda x: x.id, self.search_func(list_id, query)))
|
||||
return self.ids
|
||||
|
||||
class ListRow(Gtk.ListBoxRow):
|
||||
@GObject.Property
|
||||
def db_id(self):
|
||||
return self._db_id
|
||||
@db_id.setter
|
||||
def db_id_setter(self, value):
|
||||
self._db_id = value
|
||||
@GObject.Property
|
||||
def name(self):
|
||||
return self._name
|
||||
@name.setter
|
||||
def name_setter(self, value):
|
||||
self._name = value
|
||||
|
||||
class ListRecordRow(Gtk.ListBoxRow):
|
||||
@GObject.Property
|
||||
def db_id(self):
|
||||
|
@ -87,6 +101,18 @@ def search_list_record(list_id, q):
|
|||
.where((ListRecord.list == list_o) & (ListRecordIndex.match(q)))
|
||||
.order_by(ListRecordIndex.bm25()))
|
||||
#####################################################################################################################
|
||||
def build_list_row(list_o):
|
||||
b = Gtk.Builder()
|
||||
b.add_from_string(list_row_ui_str)
|
||||
win = b.get_object('win')
|
||||
box = b.get_object('list_box')
|
||||
b.get_object('name').set_text(list_o.name)
|
||||
row = ListRow()
|
||||
row.props.db_id = list_o.id
|
||||
row.name = list_o.name
|
||||
win.remove(win.get_children()[0])
|
||||
row.add(box)
|
||||
return row
|
||||
def build_listrecord_row(listrec_o):
|
||||
b = Gtk.Builder()
|
||||
b.add_from_string(listrecord_row_ui_str)
|
||||
|
@ -124,6 +150,8 @@ def create_open_list_win(list_id):
|
|||
if ev.keyval == Gdk.KEY_Escape:
|
||||
lr_list.remove(row)
|
||||
row.destroy()
|
||||
lr_list.unselect_all()
|
||||
self.listrec_row_unselected()
|
||||
def row_edit_cancel(self, entry, ev, edit_row):
|
||||
if ev.keyval == Gdk.KEY_Escape:
|
||||
rec = get_listrecord(edit_row.props.db_id)
|
||||
|
|
|
@ -2,9 +2,10 @@ import gi
|
|||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk, GObject
|
||||
import os
|
||||
from mods.files import gender_ui_str, icon_dir, open_patient_win_file, new_patient_win_file, edit_patient_win_file
|
||||
from mods.utils import ConditionalFilter, show_msg, gender_dict, doc_type_dict
|
||||
from mods.files import gender_ui_str, icon_dir, open_patient_win_file, new_patient_win_file, edit_patient_win_file, choose_patient_win_file
|
||||
from mods.utils import ConditionalFilter, show_msg, gender_dict, doc_type_dict, enable_widget, disable_widget
|
||||
from mods.db import db, Patient, PatientIndex
|
||||
from mods.root import builder
|
||||
from datetime import date
|
||||
import re
|
||||
import peewee
|
||||
|
@ -39,8 +40,9 @@ def search_patients(q):
|
|||
on=(Patient.id == PatientIndex.rowid))
|
||||
.where(PatientIndex.match(q))
|
||||
.order_by(PatientIndex.bm25()))
|
||||
|
||||
patient_filter = ConditionalFilter(search_patients)
|
||||
def get_all_patients():
|
||||
with db.atomic():
|
||||
return Patient.select()
|
||||
|
||||
class PatientRow(Gtk.ListBoxRow):
|
||||
@GObject.Property
|
||||
|
@ -155,8 +157,9 @@ def set_patient_win_values(patient_id, b, edit=False):
|
|||
b.get_object('snils_number').set_text(pat.snils_number)
|
||||
b.get_object('notes_buffer').set_text(pat.notes)
|
||||
|
||||
def create_open_patient_win(patient_id, patient_list):
|
||||
def create_open_patient_win(patient_id):
|
||||
b = Gtk.Builder()
|
||||
patient_list = builder.get_object('patient_list')
|
||||
class OpenPatientWinHandler:
|
||||
def show_edit_patient_win(self, *a):
|
||||
edit_patient_win = create_edit_patient_win(patient_id, patient_list)
|
||||
|
@ -170,8 +173,9 @@ def create_open_patient_win(patient_id, patient_list):
|
|||
set_patient_win_values(patient_id, b)
|
||||
return w
|
||||
|
||||
def create_edit_patient_win(patient_id, patient_list):
|
||||
def create_edit_patient_win(patient_id):
|
||||
b = Gtk.Builder()
|
||||
patient_list = builder.get_object('patient_list')
|
||||
class EditPatientWinHandler:
|
||||
def edit_patient_win_close(self, *args):
|
||||
w.destroy()
|
||||
|
@ -205,9 +209,9 @@ def create_edit_patient_win(patient_id, patient_list):
|
|||
set_patient_win_values(patient_id, b, edit=True)
|
||||
return w
|
||||
|
||||
|
||||
def create_new_patient_win(patient_list):
|
||||
def create_new_patient_win():
|
||||
b = Gtk.Builder()
|
||||
patient_list = builder.get_object('patient_list')
|
||||
class NewPatienWinHandler:
|
||||
def only_digits(self, entry):
|
||||
text = entry.get_text()
|
||||
|
@ -232,11 +236,40 @@ def create_new_patient_win(patient_list):
|
|||
b.connect_signals(NewPatienWinHandler())
|
||||
w = b.get_object('new_patient_window')
|
||||
return w
|
||||
|
||||
def create_choose_patient_win(new_reception_b):
|
||||
b = Gtk.Builder()
|
||||
patient_cont = new_reception_b.get_object('patient')
|
||||
patient_filter = ConditionalFilter(search_patients)
|
||||
class ChoosePatientWinHandler:
|
||||
def patient_filter_changed(self, filter_widget):
|
||||
pl.unselect_all()
|
||||
self.patient_list_unselected()
|
||||
pl.invalidate_filter()
|
||||
def patient_list_selected(self, *a):
|
||||
accept_button = b.get_object('accept_button')
|
||||
enable_widget([accept_button])
|
||||
def patient_list_unselected(self, *a):
|
||||
accept_button = b.get_object('accept_button')
|
||||
disable_widget([accept_button])
|
||||
b.add_from_file(choose_patient_win_file)
|
||||
b.connect_signals(ChoosePatientWinHandler())
|
||||
pl = b.get_object('patient_list')
|
||||
pl.set_sort_func(patient_sort_func)
|
||||
pl.set_filter_func(patient_filter_func_factory(patient_filter, b))
|
||||
###
|
||||
for p in get_all_patients():
|
||||
pl.add(build_patient_row(p))
|
||||
###
|
||||
w = b.get_object('choose_patient_window')
|
||||
return w
|
||||
|
||||
def patient_sort_func(row1, row2, *a):
|
||||
text1 = row1.props.fio
|
||||
text2 = row2.props.fio
|
||||
return (text1 > text2) - (text1 < text2)
|
||||
def patient_filter_func_factory(b):
|
||||
|
||||
def patient_filter_func_factory(patient_filter, b):
|
||||
def patient_filter_func(row):
|
||||
fstr = b.get_object('patient_filter').get_text().strip()
|
||||
if not fstr:
|
||||
|
@ -244,3 +277,4 @@ def patient_filter_func_factory(b):
|
|||
return True
|
||||
return row.props.db_id in patient_filter.filter(fstr)
|
||||
return patient_filter_func
|
||||
|
||||
|
|
|
@ -2,7 +2,18 @@ import gi
|
|||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk, GObject, Gdk
|
||||
from mods.db import db, Reception
|
||||
from mods.files import new_reception_win_file, reception_row_ui_str
|
||||
from mods.files import new_reception_win_file, reception_row_ui_str, reception_list_settings_win_file
|
||||
from mods.settings import s_get_reception_list, s_set_reception_list
|
||||
from mods.root import builder
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
def get_reception_timelist(rec_date):
|
||||
s = s_get_reception_list()
|
||||
dstart = datetime(rec_date.year, rec_date.month, rec_date.day, s.day_start[0], s.day_start[1])
|
||||
dend = datetime(rec_date.year, rec_date.month, rec_date.day, s.day_end[0], s.day_end[1])
|
||||
work_day_minutes_total = (dend.hour - dstart.hour) * 60 + dend.minute - dstart.minute
|
||||
shift_minutes_range = range(0, work_day_minutes_total, s.interval)
|
||||
return [dstart + timedelta(minutes=x) for x in shift_minutes_range]
|
||||
|
||||
class ReceptionRow(Gtk.ListBoxRow):
|
||||
@GObject.Property
|
||||
|
@ -23,6 +34,13 @@ class ReceptionRow(Gtk.ListBoxRow):
|
|||
@scheduled.setter
|
||||
def scheduled_setter(self, value):
|
||||
self._scheduled = value
|
||||
class NewReceptionPatientLabel(Gtk.Label):
|
||||
@GObject.Property
|
||||
def patient_db_id(self):
|
||||
return self._patient_db_id
|
||||
@patient_db_id.setter
|
||||
def db_id_setter(self, value):
|
||||
self._patient_db_id = value
|
||||
|
||||
def build_reception_row(reception_datetime):
|
||||
b = Gtk.Builder()
|
||||
|
@ -50,11 +68,57 @@ def build_reception_row(reception_datetime):
|
|||
row.add(box)
|
||||
return row
|
||||
|
||||
def create_new_reception_win(root_builder):
|
||||
def create_new_reception_win():
|
||||
b = Gtk.Builder()
|
||||
reception_list = builder.get_object('reception_list')
|
||||
row = reception_list.get_selected_row()
|
||||
class NewReceptionWinHandler:
|
||||
pass
|
||||
def show_choose_patient_win(self, button):
|
||||
from mods.patients import create_choose_patient_win
|
||||
choose_patient_win = create_choose_patient_win(b)
|
||||
choose_patient_win.show_all()
|
||||
b.add_from_file(new_reception_win_file)
|
||||
b.connect_signals(NewReceptionWinHandler())
|
||||
#####
|
||||
patient_label = NewReceptionPatientLabel()
|
||||
patient_label.props.patient_db_id = -1
|
||||
#patient_label.set_markup('<span size="xx-large">test</span>')
|
||||
#####
|
||||
patient_cont = b.get_object('patient')
|
||||
patient_cont.pack_start(patient_label, True, True, 0)
|
||||
patient_cont.reorder_child(patient_label, 0)
|
||||
w = b.get_object('new_reception_window')
|
||||
dt_label = b.get_object('datetime')
|
||||
dt_label.set_text(row.props.datetime.strftime('%m.%d.%Y - %H:%M'))
|
||||
return w
|
||||
def create_reception_list_settings_win():
|
||||
b = Gtk.Builder()
|
||||
class ReceptionListSettingsHandler:
|
||||
def save_settings(self, *a):
|
||||
start_hour = int(b.get_object('start_hour').get_value())
|
||||
start_minute = int(b.get_object('start_minute').get_value())
|
||||
end_hour = int(b.get_object('end_hour').get_value())
|
||||
end_minute = int(b.get_object('end_minute').get_value())
|
||||
interval = int(b.get_object('interval').get_value())
|
||||
s_set_reception_list([start_hour, start_minute], [end_hour, end_minute], interval)
|
||||
redraw_reception_list(datetime.now())
|
||||
b.get_object('reception_list_settings_win').close()
|
||||
b.add_from_file(reception_list_settings_win_file)
|
||||
b.connect_signals(ReceptionListSettingsHandler())
|
||||
s = s_get_reception_list()
|
||||
b.get_object('start_hour').set_value(s.day_start[0])
|
||||
b.get_object('start_minute').set_value(s.day_start[1])
|
||||
b.get_object('end_hour').set_value(s.day_end[0])
|
||||
b.get_object('end_minute').set_value(s.day_end[1])
|
||||
b.get_object('interval').set_value(s.interval)
|
||||
w = b.get_object('reception_list_settings_win')
|
||||
return w
|
||||
def redraw_reception_list(selected_date):
|
||||
reception_timelist = get_reception_timelist(selected_date)
|
||||
reception_list = builder.get_object('reception_list')
|
||||
for c in reception_list.get_children():
|
||||
reception_list.remove(c)
|
||||
for d in reception_timelist:
|
||||
reception_list.add(build_reception_row(d))
|
||||
reception_list.show_all()
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
from mods.files import main_win_file
|
||||
|
||||
builder = Gtk.Builder()
|
||||
builder.add_from_file(main_win_file)
|
|
@ -2,7 +2,7 @@
|
|||
<!-- Generated with glade 3.22.1 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkWindow" id="choose_patioent_window">
|
||||
<object class="GtkWindow" id="choose_patient_window">
|
||||
<property name="width_request">600</property>
|
||||
<property name="height_request">500</property>
|
||||
<property name="can_focus">False</property>
|
||||
|
@ -32,10 +32,16 @@
|
|||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="patients_page">
|
||||
<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">
|
||||
|
@ -45,11 +51,70 @@
|
|||
<object class="GtkListBox" id="patient_list">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<signal name="row-selected" handler="patient_list_selected" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</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="patient_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>
|
||||
<signal name="changed" handler="patient_filter_changed" swapped="no"/>
|
||||
</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="pack_type">end</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkTextBuffer" id="notes_buffer"/>
|
||||
<object class="GtkWindow" id="edit_patient_window">
|
||||
<property name="width_request">500</property>
|
||||
<property name="height_request">290</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="window_position">center</property>
|
||||
|
|
|
@ -3,14 +3,19 @@
|
|||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkApplicationWindow" id="main_window">
|
||||
<property name="width_request">800</property>
|
||||
<property name="height_request">500</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title">ElDoc</property>
|
||||
<property name="default_width">800</property>
|
||||
<property name="default_height">500</property>
|
||||
<property name="window_position">center</property>
|
||||
<property name="icon_name">accessories-character-map</property>
|
||||
<signal name="destroy" handler="main_win_close" swapped="no"/>
|
||||
<child>
|
||||
<placeholder/>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">Электронный Доктор</property>
|
||||
<property name="show_close_button">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
|
@ -51,6 +56,7 @@
|
|||
<property name="label" translatable="yes">Создать</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="icon_name">list-add</property>
|
||||
<signal name="clicked" handler="show_new_reception_win" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -121,6 +127,7 @@
|
|||
<object class="GtkListBox" id="reception_list">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<signal name="row-selected" handler="reception_list_selected" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkTextBuffer" id="notes_buffer"/>
|
||||
<object class="GtkWindow" id="new_patient_window">
|
||||
<property name="width_request">500</property>
|
||||
<property name="height_request">290</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="window_position">center</property>
|
||||
|
|
|
@ -101,12 +101,13 @@
|
|||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="patient_fio">
|
||||
<object class="GtkBox" id="patient">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<attributes>
|
||||
<attribute name="scale" value="2"/>
|
||||
</attributes>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
|
@ -120,6 +121,7 @@
|
|||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="show_choose_patient_win" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkWindow" id="open_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>
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkTextBuffer" id="notes_buffer"/>
|
||||
<object class="GtkWindow" id="open_patient_window">
|
||||
<property name="width_request">500</property>
|
||||
<property name="height_request">400</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="window_position">center</property>
|
||||
|
@ -608,8 +610,6 @@
|
|||
<property name="left_padding">12</property>
|
||||
<child>
|
||||
<object class="GtkListBox" id="reception_list">
|
||||
<property name="width_request">400</property>
|
||||
<property name="height_request">150</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
|
|
Loading…
Reference in New Issue