Расписание приёмов
This commit is contained in:
parent
0a5634bb59
commit
1b0f6bd6c9
75
app.py
75
app.py
|
@ -1,11 +1,17 @@
|
|||
import gi
|
||||
import os
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk, GObject
|
||||
from mods.db import Patient, store_patient_index, update_patient_index, search_patients, db
|
||||
from datetime import date
|
||||
from gi.repository import Gtk, GObject, Gdk
|
||||
from mods.db import Patient, Reception, store_patient_index, update_patient_index, search_patients, db
|
||||
from datetime import date, datetime, timedelta, time
|
||||
import peewee
|
||||
|
||||
# FIXME: временно
|
||||
DAY_START = time(8,0)
|
||||
DAY_END = time(13,0)
|
||||
TIME_INTERVAL = timedelta(minutes=30)
|
||||
#
|
||||
|
||||
gender_dict = {
|
||||
'male': 'Мужской',
|
||||
'female': 'Женский'
|
||||
|
@ -25,6 +31,9 @@ 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')
|
||||
male_patient_row_file = os.path.join(ui_dir, 'male_patient_row.glade')
|
||||
female_patient_row_file = os.path.join(ui_dir, 'female_patient_row.glade')
|
||||
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()
|
||||
gender_ui_str = {}
|
||||
with open(male_patient_row_file, 'r') as f:
|
||||
gender_ui_str['male'] = f.read()
|
||||
|
@ -34,6 +43,13 @@ with open(female_patient_row_file, 'r') as f:
|
|||
|
||||
builder = Gtk.Builder()
|
||||
|
||||
def get_reception_timelist(rec_date):
|
||||
dstart = datetime(rec_date.year, rec_date.month, rec_date.day, DAY_START.hour, DAY_START.minute)
|
||||
dend = datetime(rec_date.year, rec_date.month, rec_date.day, DAY_END.hour, DAY_END.minute)
|
||||
work_day_minutes_total = (dend.hour - dstart.hour) * 60 + dend.minute - dstart.minute
|
||||
shift_minutes_range = range(0, work_day_minutes_total, int(TIME_INTERVAL.seconds / 60))
|
||||
return [(dstart + timedelta(minutes=x)).time() for x in shift_minutes_range]
|
||||
|
||||
class PatientFilter:
|
||||
def __init__(self):
|
||||
self.reset()
|
||||
|
@ -67,6 +83,26 @@ class PatientRow(Gtk.ListBoxRow):
|
|||
def birth_date_setter(self, value):
|
||||
self._birth_date = value
|
||||
|
||||
class ReceptionRow(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 datetime(self):
|
||||
return self._datetime
|
||||
@datetime.setter
|
||||
def datetime_setter(self, value):
|
||||
self._datetime = value
|
||||
@GObject.Property
|
||||
def scheduled(self):
|
||||
return self._scheduled
|
||||
@scheduled.setter
|
||||
def scheduled_setter(self, value):
|
||||
self._scheduled = value
|
||||
|
||||
class MainWinHandler:
|
||||
def main_win_close(self, *args):
|
||||
Gtk.main_quit()
|
||||
|
@ -102,6 +138,30 @@ class MainWinHandler:
|
|||
pl.add(build_patient_row(p))
|
||||
pl.show_all()'''
|
||||
|
||||
def build_reception_row(reception_datetime):
|
||||
b = Gtk.Builder()
|
||||
b.add_from_string(reception_row_ui_str)
|
||||
win = b.get_object('win')
|
||||
box = b.get_object('reception_box')
|
||||
b.get_object('hour').set_text(reception_datetime.strftime('%H'))
|
||||
b.get_object('minute').set_text(reception_datetime.strftime('%M'))
|
||||
reception = Reception.select().where(Reception.time == reception_datetime)
|
||||
row = ReceptionRow()
|
||||
if len(reception):
|
||||
row.props.scheduled = True
|
||||
reception_cont = b.get_object('reception_cont')
|
||||
reception_cont.props.border_width = 2
|
||||
reception_cont.override_background_color(Gtk.StateFlags(0), Gdk.RGBA(red=0.5, green=0.7, blue=0.5, alpha=1.0))
|
||||
reception_patient = Gtk.Label()
|
||||
reception_patient.set_text(' '.join([reception.patient.last_name, reception.patient.first_name, reception.patient.middle_name]))
|
||||
reception_cont.add(reception_patient)
|
||||
else:
|
||||
row.props.scheduled = False
|
||||
win.remove(win.get_children()[0])
|
||||
row.props.datetime = reception_datetime
|
||||
row.add(box)
|
||||
return row
|
||||
|
||||
def build_patient_row(patient):
|
||||
b = Gtk.Builder()
|
||||
b.add_from_string(gender_ui_str[patient.gender])
|
||||
|
@ -131,8 +191,17 @@ def patient_filter_func(row):
|
|||
return True
|
||||
return row.props.db_id in patient_filter.filter(fstr)
|
||||
|
||||
def redraw_reception_list(selected_date):
|
||||
reception_timelist = get_reception_timelist(selected_date)
|
||||
reception_list = builder.get_object('reception_list')
|
||||
for d in reception_timelist:
|
||||
reception_list.add(build_reception_row(d))
|
||||
|
||||
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)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import os
|
||||
from peewee import Model, CharField, BigAutoField, DateTimeField, IntegerField, fn, Field, Expression, TextField, ForeignKeyField, DateField
|
||||
from peewee import Model, CharField, BigAutoField, DateTimeField, IntegerField, fn, Field, Expression, TextField, ForeignKeyField, DateField, TimeField
|
||||
from playhouse.sqlite_ext import CSqliteExtDatabase, FTS5Model, AutoIncrementField, SearchField, RowIDField
|
||||
|
||||
var_dir = os.path.join(os.path.abspath(os.environ['HOME']), '.eldoc')
|
||||
|
@ -99,5 +99,10 @@ def update_patient_index(pat):
|
|||
db.connect()
|
||||
db.create_tables([
|
||||
Patient,
|
||||
PatientIndex
|
||||
PatientIndex,
|
||||
Reception,
|
||||
Diagnosis,
|
||||
ReceptionDiagnosis,
|
||||
ReceptionAnamnesis,
|
||||
AnamnesisTemplate
|
||||
])
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="schedule_page">
|
||||
<object class="GtkBox" id="reception_page">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
|
@ -78,7 +78,7 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBox">
|
||||
<object class="GtkListBox" id="reception_list">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.1 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkWindow" id="win">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="decorated">False</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="reception_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="hour">
|
||||
<property name="width_request">35</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">3</property>
|
||||
<property name="margin_right">3</property>
|
||||
<property name="margin_top">3</property>
|
||||
<property name="margin_bottom">3</property>
|
||||
<property name="label" translatable="yes">00</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
<attribute name="scale" value="2"/>
|
||||
</attributes>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="minute">
|
||||
<property name="width_request">20</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">3</property>
|
||||
<property name="margin_right">3</property>
|
||||
<property name="margin_top">3</property>
|
||||
<property name="margin_bottom">3</property>
|
||||
<property name="label" translatable="yes">00</property>
|
||||
<property name="yalign">0</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
<attribute name="underline" value="True"/>
|
||||
</attributes>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</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_left">3</property>
|
||||
<property name="margin_right">3</property>
|
||||
<property name="margin_top">3</property>
|
||||
<property name="margin_bottom">3</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkEventBox" id="reception_cont">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
Loading…
Reference in New Issue