Анамнез в приёме

This commit is contained in:
Роман Бородин 2020-01-23 13:23:27 +03:00
parent eaf76e6428
commit 3910f9cb24
5 changed files with 72 additions and 174 deletions

View File

@ -59,6 +59,9 @@ class ListRecordRow(Gtk.ListBoxRow):
def get_list(list_id): def get_list(list_id):
with db.atomic(): with db.atomic():
return List.get_by_id(list_id) return List.get_by_id(list_id)
def get_list_by_system_id(s_id):
with db.atomic():
return List.select().where(List.system_id == s_id).get()
def get_listrecord(listrec_id): def get_listrecord(listrec_id):
with db.atomic(): with db.atomic():
return ListRecord.get_by_id(listrec_id) return ListRecord.get_by_id(listrec_id)
@ -142,7 +145,7 @@ def build_listrec_editable_row(listrec_o=None):
row.add(box) row.add(box)
return (row, text_input) return (row, text_input)
def create_open_list_win(list_id): def create_open_list_win(list_id, choose=False, parent_list=None):
list_o = get_list(list_id) list_o = get_list(list_id)
b = Gtk.Builder() b = Gtk.Builder()
listrecord_filter = ListRecFilter(search_list_record) listrecord_filter = ListRecFilter(search_list_record)
@ -159,6 +162,7 @@ def create_open_list_win(list_id):
row = build_listrecord_row(rec) row = build_listrecord_row(rec)
lr_list.remove(edit_row) lr_list.remove(edit_row)
edit_row.destroy() edit_row.destroy()
lr_list.unselect_all()
lr_list.add(row) lr_list.add(row)
lr_list.show_all() lr_list.show_all()
def enable_buttons_on_add_edit(self, *a): def enable_buttons_on_add_edit(self, *a):
@ -168,6 +172,7 @@ def create_open_list_win(list_id):
delete_list_record(row.props.db_id) delete_list_record(row.props.db_id)
lr_list.remove(row) lr_list.remove(row)
row.destroy() row.destroy()
lr_list.unselect_all()
lr_list.show_all() lr_list.show_all()
self.listrec_row_unselected() self.listrec_row_unselected()
def edit_row(self, button): def edit_row(self, button):
@ -181,6 +186,7 @@ def create_open_list_win(list_id):
inp.connect('key-release-event', self.row_edit_cancel, edit_row) inp.connect('key-release-event', self.row_edit_cancel, edit_row)
inp.connect('activate', self.update_row, edit_row) inp.connect('activate', self.update_row, edit_row)
inp.connect('destroy', self.enable_buttons_on_add_edit) inp.connect('destroy', self.enable_buttons_on_add_edit)
lr_list.unselect_all()
disable_widget([add_button, edit_button, remove_button, lr_filter]) disable_widget([add_button, edit_button, remove_button, lr_filter])
lr_list.show_all() lr_list.show_all()
def add_new_row(self, button): def add_new_row(self, button):
@ -190,6 +196,7 @@ def create_open_list_win(list_id):
text_input.connect('key-release-event', self.row_add_cancel, row) text_input.connect('key-release-event', self.row_add_cancel, row)
text_input.connect('activate', self.save_new_row, row) text_input.connect('activate', self.save_new_row, row)
text_input.connect('destroy', self.enable_buttons_on_add_edit) text_input.connect('destroy', self.enable_buttons_on_add_edit)
lr_list.unselect_all()
disable_widget([add_button, edit_button, remove_button, lr_filter]) disable_widget([add_button, edit_button, remove_button, lr_filter])
lr_list.show_all() lr_list.show_all()
def update_row(self, inp, edit_row): def update_row(self, inp, edit_row):
@ -222,14 +229,29 @@ def create_open_list_win(list_id):
row.destroy() row.destroy()
def listrec_row_selected(self, *a): def listrec_row_selected(self, *a):
enable_widget([edit_button, remove_button]) enable_widget([edit_button, remove_button])
if choose:
enable_widget([accept_button])
def listrec_row_unselected(self, *a): def listrec_row_unselected(self, *a):
disable_widget([edit_button, remove_button]) disable_widget([edit_button, remove_button])
if choose:
disable_widget([accept_button])
def listrec_filter_changed(self, filter_widget): def listrec_filter_changed(self, filter_widget):
lr_list.unselect_all() lr_list.unselect_all()
self.listrec_row_unselected() self.listrec_row_unselected()
lr_list.invalidate_filter() lr_list.invalidate_filter()
def submit(self, button):
from mods.receptions import build_reception_anamnesis_row
exist_rows = list(map(lambda x: x.props.db_id, parent_list.get_children()))
rows = lr_list.get_selected_rows()
for row in rows:
if row.props.db_id not in exist_rows:
anamnesis = get_listrecord(row.props.db_id)
parent_list.add(build_reception_anamnesis_row(anamnesis))
parent_list.show_all()
w.destroy()
b.add_from_file(open_list_win_file) b.add_from_file(open_list_win_file)
b.connect_signals(OpenListHandler()) olh = OpenListHandler()
b.connect_signals(olh)
# Gtk objects # Gtk objects
w = b.get_object('open_list_window') w = b.get_object('open_list_window')
lr_list = b.get_object('listrecord_list') lr_list = b.get_object('listrecord_list')
@ -238,6 +260,16 @@ def create_open_list_win(list_id):
edit_button = b.get_object('edit_button') edit_button = b.get_object('edit_button')
remove_button = b.get_object('remove_button') remove_button = b.get_object('remove_button')
list_header = b.get_object('list_win_header') list_header = b.get_object('list_win_header')
accept_place_box = b.get_object('accept_place')
sep_place_box = b.get_object('sep_place')
if choose:
sep_place_box.pack_start(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL), True, True, 0)
accept_button_img = Gtk.Image()
accept_button_img.set_from_icon_name('object-select-symbolic', Gtk.IconSize.BUTTON)
accept_button = Gtk.Button()
accept_button.set_image(accept_button_img)
accept_place_box.pack_start(accept_button, True, True, 0)
accept_button.connect('clicked', olh.submit)
############# #############
###### ######
def listrecord_sort_func(row1, row2, *a): def listrecord_sort_func(row1, row2, *a):

View File

@ -7,7 +7,7 @@ from mods.files import new_reception_win_file, reception_row_ui_str, reception_l
from mods.files import anamnesis_row_ui_str from mods.files import anamnesis_row_ui_str
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.diagnosis import create_choose_diagnosis_win, get_giagnosis from mods.diagnosis import create_choose_diagnosis_win, get_giagnosis
from mods.lists import get_listrecord from mods.lists import get_listrecord, get_list_by_system_id, create_open_list_win, ANAMNEZ_LIST
from mods.root import builder from mods.root import builder
from datetime import datetime, timedelta from datetime import datetime, timedelta
@ -166,6 +166,10 @@ def create_open_reception_win():
def show_choose_diagnosis_win(self, button): def show_choose_diagnosis_win(self, button):
choose_diagnosis_win = create_choose_diagnosis_win(b) choose_diagnosis_win = create_choose_diagnosis_win(b)
choose_diagnosis_win.show_all() choose_diagnosis_win.show_all()
def show_choose_anamnesis_win(self, button):
anam_db_list = get_list_by_system_id(ANAMNEZ_LIST)
choose_anamnesis_win = create_open_list_win(anam_db_list.id, choose=True, parent_list=reception_anam_list)
choose_anamnesis_win.show_all()
def remove_diagnosis(self, button): def remove_diagnosis(self, button):
row = reception_diag_list.get_selected_row() row = reception_diag_list.get_selected_row()
reception_diag_list.remove(row) reception_diag_list.remove(row)

View File

@ -1,169 +0,0 @@
<?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

@ -16,6 +16,29 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="show_close_button">True</property> <property name="show_close_button">True</property>
<child>
<object class="GtkBox" id="accept_place">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="sep_place">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child> <child>
<object class="GtkButton" id="add_button"> <object class="GtkButton" id="add_button">
<property name="label">gtk-add</property> <property name="label">gtk-add</property>
@ -26,6 +49,9 @@
<property name="always_show_image">True</property> <property name="always_show_image">True</property>
<signal name="clicked" handler="add_new_row" swapped="no"/> <signal name="clicked" handler="add_new_row" swapped="no"/>
</object> </object>
<packing>
<property name="position">2</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="edit_button"> <object class="GtkButton" id="edit_button">
@ -39,7 +65,7 @@
<signal name="clicked" handler="edit_row" swapped="no"/> <signal name="clicked" handler="edit_row" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="position">1</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -54,7 +80,7 @@
<signal name="clicked" handler="remove_row" swapped="no"/> <signal name="clicked" handler="remove_row" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="position">2</property> <property name="position">4</property>
</packing> </packing>
</child> </child>
</object> </object>
@ -78,6 +104,8 @@
<object class="GtkListBox" id="listrecord_list"> <object class="GtkListBox" id="listrecord_list">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="selection_mode">multiple</property>
<property name="activate_on_single_click">False</property>
<signal name="row-selected" handler="listrec_row_selected" swapped="no"/> <signal name="row-selected" handler="listrec_row_selected" swapped="no"/>
</object> </object>
</child> </child>

View File

@ -174,6 +174,7 @@
<object class="GtkListBox" id="anamnesis_list"> <object class="GtkListBox" id="anamnesis_list">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<signal name="row-selected" handler="anamnesis_selected" swapped="no"/>
</object> </object>
</child> </child>
</object> </object>
@ -206,6 +207,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
<signal name="clicked" handler="show_choose_anamnesis_win" swapped="no"/>
<child> <child>
<object class="GtkImage"> <object class="GtkImage">
<property name="visible">True</property> <property name="visible">True</property>
@ -227,6 +229,7 @@
<property name="sensitive">False</property> <property name="sensitive">False</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
<signal name="clicked" handler="remove_anamnesis" swapped="no"/>
<child> <child>
<object class="GtkImage"> <object class="GtkImage">
<property name="visible">True</property> <property name="visible">True</property>