From 4359ab54db5d5288f0abf75c1e1b4b63f29af75d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D1=80=D0=BE=D0=B4=D0=B8=D0=BD=20=D0=A0=D0=BE?= =?UTF-8?q?=D0=BC=D0=B0=D0=BD?= Date: Thu, 12 Dec 2019 20:48:46 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=B3=D0=BE=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=D1=91=D0=BC=D0=B0=20=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mods/patients.py | 22 ++++++++++++++++++---- mods/receptions.py | 29 +++++++++++++++++++++-------- res/ui/choose_patient_win.glade | 1 + res/ui/new_reception_win.glade | 4 +++- 4 files changed, 43 insertions(+), 13 deletions(-) diff --git a/mods/patients.py b/mods/patients.py index b489910..6ef1169 100644 --- a/mods/patients.py +++ b/mods/patients.py @@ -162,7 +162,7 @@ def create_open_patient_win(patient_id): 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) + edit_patient_win = create_edit_patient_win(patient_id) w.destroy() edit_patient_win.show_all() b.add_from_file(open_patient_win_file) @@ -179,7 +179,7 @@ def create_edit_patient_win(patient_id): class EditPatientWinHandler: def edit_patient_win_close(self, *args): w.destroy() - open_patient_win = create_open_patient_win(patient_id, patient_list) + open_patient_win = create_open_patient_win(patient_id) open_patient_win.show_all() def only_digits(self, entry): text = entry.get_text() @@ -240,6 +240,7 @@ def create_new_patient_win(): def create_choose_patient_win(new_reception_b): b = Gtk.Builder() patient_cont = new_reception_b.get_object('patient') + save_button = new_reception_b.get_object('save_button') patient_filter = ConditionalFilter(search_patients) class ChoosePatientWinHandler: def patient_filter_changed(self, filter_widget): @@ -247,13 +248,26 @@ def create_choose_patient_win(new_reception_b): 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]) + def submit(self, button): + from mods.receptions import NewReceptionPatientLabel + row = pl.get_selected_row() + for c in patient_cont.get_children(): + patient_cont.remove(c) + patient_label = NewReceptionPatientLabel() + patient_label.props.db_id = row.props.db_id + patient_label.set_markup(f'{row.props.fio}') + patient_cont.pack_start(patient_label, True, True, 0) + patient_cont.reorder_child(patient_label, 0) + patient_cont.show_all() + enable_widget([save_button]) + w.destroy() + b.add_from_file(choose_patient_win_file) b.connect_signals(ChoosePatientWinHandler()) + accept_button = b.get_object('accept_button') pl = b.get_object('patient_list') pl.set_sort_func(patient_sort_func) pl.set_filter_func(patient_filter_func_factory(patient_filter, b)) diff --git a/mods/receptions.py b/mods/receptions.py index 46dcb7b..9bdceb0 100644 --- a/mods/receptions.py +++ b/mods/receptions.py @@ -1,12 +1,17 @@ import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk, GObject, Gdk -from mods.db import db, Reception +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.settings import s_get_reception_list, s_set_reception_list from mods.root import builder from datetime import datetime, timedelta +def add_reception(patient_id, reception_dt): + with db.atomic(): + patient = Patient.get_by_id(patient_id) + return Reception.create(patient=patient, time=reception_dt) + 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]) @@ -36,11 +41,11 @@ class ReceptionRow(Gtk.ListBoxRow): 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(self): + return self._db_id + @db_id.setter def db_id_setter(self, value): - self._patient_db_id = value + self._db_id = value def build_reception_row(reception_datetime): b = Gtk.Builder() @@ -50,9 +55,10 @@ def build_reception_row(reception_datetime): b.get_object('hour').set_text(reception_datetime.strftime('%H')) b.get_object('minute').set_text(reception_datetime.strftime('%M')) with db.atomic(): - reception = Reception.select().where(Reception.time == reception_datetime) + q = Reception.select().where(Reception.time == reception_datetime) row = ReceptionRow() - if len(reception): + if len(q): + reception = q.get() row.props.scheduled = True row.props.db_id = reception.id reception_cont = b.get_object('reception_cont') @@ -77,11 +83,18 @@ def create_new_reception_win(): from mods.patients import create_choose_patient_win choose_patient_win = create_choose_patient_win(b) choose_patient_win.show_all() + def save_reception(self, button): + pat_label = patient_cont.get_children()[0] + if pat_label.props.db_id < 0: + return + rec = add_reception(pat_label.props.db_id, row.props.datetime) + w.destroy() + redraw_reception_list(row.props.datetime) b.add_from_file(new_reception_win_file) b.connect_signals(NewReceptionWinHandler()) ##### patient_label = NewReceptionPatientLabel() - patient_label.props.patient_db_id = -1 + patient_label.props.db_id = -1 #patient_label.set_markup('test') ##### patient_cont = b.get_object('patient') diff --git a/res/ui/choose_patient_win.glade b/res/ui/choose_patient_win.glade index b15fc34..38d40f8 100644 --- a/res/ui/choose_patient_win.glade +++ b/res/ui/choose_patient_win.glade @@ -21,6 +21,7 @@ False True True + True diff --git a/res/ui/new_reception_win.glade b/res/ui/new_reception_win.glade index fcdd1dc..6366ccc 100644 --- a/res/ui/new_reception_win.glade +++ b/res/ui/new_reception_win.glade @@ -15,10 +15,12 @@ Новый приём True - + True + False True True + True