Создание нового приёма готово

This commit is contained in:
Бородин Роман 2019-12-12 20:48:46 +03:00
parent ac0a237b19
commit 4359ab54db
4 changed files with 43 additions and 13 deletions

View File

@ -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'<span size="xx-large">{row.props.fio}</span>')
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))

View File

@ -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('<span size="xx-large">test</span>')
#####
patient_cont = b.get_object('patient')

View File

@ -21,6 +21,7 @@
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="submit" swapped="no"/>
<child>
<object class="GtkImage">
<property name="visible">True</property>

View File

@ -15,10 +15,12 @@
<property name="title" translatable="yes">Новый приём</property>
<property name="show_close_button">True</property>
<child>
<object class="GtkButton">
<object class="GtkButton" id="save_button">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="save_reception" swapped="no"/>
<child>
<object class="GtkImage">
<property name="visible">True</property>