Реализация работы с лекарствами в приёме. Часть...
This commit is contained in:
parent
2012391d08
commit
c67e4fb479
36
mods/db.py
36
mods/db.py
|
@ -100,6 +100,9 @@ class Patient(BaseModel):
|
||||||
policy_company = TextField(null=True)
|
policy_company = TextField(null=True)
|
||||||
snils_number = TextField(null=True)
|
snils_number = TextField(null=True)
|
||||||
notes = TextField(null=True)
|
notes = TextField(null=True)
|
||||||
|
class PatientIndex(BaseFTSModel):
|
||||||
|
rowid = RowIDField()
|
||||||
|
fio = SearchField()
|
||||||
class List(BaseModel):
|
class List(BaseModel):
|
||||||
id = AutoIncrementField()
|
id = AutoIncrementField()
|
||||||
name = TextField()
|
name = TextField()
|
||||||
|
@ -142,21 +145,6 @@ class DiagnosisIndex(BaseFTSModel):
|
||||||
rowid = RowIDField()
|
rowid = RowIDField()
|
||||||
code = SearchField()
|
code = SearchField()
|
||||||
title = SearchField()
|
title = SearchField()
|
||||||
class ReceptionDiagnosis(BaseModel):
|
|
||||||
id = AutoIncrementField()
|
|
||||||
reception = ForeignKeyField(Reception, backref='reception_diagnosisses', on_delete='CASCADE')
|
|
||||||
diagnosis = ForeignKeyField(Diagnosis, backref='reception_diagnosisses', on_delete='CASCADE')
|
|
||||||
class ReceptionAnamnesis(BaseModel):
|
|
||||||
id = AutoIncrementField()
|
|
||||||
reception = ForeignKeyField(Reception, backref='reception_anamnesisses', on_delete='CASCADE')
|
|
||||||
anamnesis = ForeignKeyField(ListRecord, backref='reception_anamnesisses', on_delete='CASCADE')
|
|
||||||
class ReceptionObserve(BaseModel):
|
|
||||||
id = AutoIncrementField()
|
|
||||||
reception = ForeignKeyField(Reception, backref='reception_symptoms', on_delete='CASCADE')
|
|
||||||
symptom = ForeignKeyField(ListRecord, backref='reception_symptoms', on_delete='CASCADE')
|
|
||||||
class PatientIndex(BaseFTSModel):
|
|
||||||
rowid = RowIDField()
|
|
||||||
fio = SearchField()
|
|
||||||
class RlsPharmacoTherapeuticGroup(BaseModel):
|
class RlsPharmacoTherapeuticGroup(BaseModel):
|
||||||
id = AutoIncrementField()
|
id = AutoIncrementField()
|
||||||
title = TextField(null=True)
|
title = TextField(null=True)
|
||||||
|
@ -182,6 +170,23 @@ class RlsIndex(BaseFTSModel):
|
||||||
rowid = RowIDField()
|
rowid = RowIDField()
|
||||||
tradename = SearchField()
|
tradename = SearchField()
|
||||||
internationalname = SearchField()
|
internationalname = SearchField()
|
||||||
|
class ReceptionDiagnosis(BaseModel):
|
||||||
|
id = AutoIncrementField()
|
||||||
|
reception = ForeignKeyField(Reception, backref='reception_diagnosisses', on_delete='CASCADE')
|
||||||
|
diagnosis = ForeignKeyField(Diagnosis, backref='reception_diagnosisses', on_delete='CASCADE')
|
||||||
|
class ReceptionAnamnesis(BaseModel):
|
||||||
|
id = AutoIncrementField()
|
||||||
|
reception = ForeignKeyField(Reception, backref='reception_anamnesisses', on_delete='CASCADE')
|
||||||
|
anamnesis = ForeignKeyField(ListRecord, backref='reception_anamnesisses', on_delete='CASCADE')
|
||||||
|
class ReceptionObserve(BaseModel):
|
||||||
|
id = AutoIncrementField()
|
||||||
|
reception = ForeignKeyField(Reception, backref='reception_symptoms', on_delete='CASCADE')
|
||||||
|
symptom = ForeignKeyField(ListRecord, backref='reception_symptoms', on_delete='CASCADE')
|
||||||
|
class ReceptionMedicine(BaseModel):
|
||||||
|
id = AutoIncrementField()
|
||||||
|
reception = ForeignKeyField(Reception, backref='reception_medicine', on_delete='CASCADE')
|
||||||
|
medicine = ForeignKeyField(Rls, backref='reception_medicine', on_delete='CASCADE')
|
||||||
|
|
||||||
### Настройки
|
### Настройки
|
||||||
class Settings(BaseModel):
|
class Settings(BaseModel):
|
||||||
key = TextField()
|
key = TextField()
|
||||||
|
@ -213,6 +218,7 @@ db.create_tables([
|
||||||
ReceptionDiagnosis,
|
ReceptionDiagnosis,
|
||||||
ReceptionAnamnesis,
|
ReceptionAnamnesis,
|
||||||
ReceptionObserve,
|
ReceptionObserve,
|
||||||
|
ReceptionMedicine,
|
||||||
RlsPharmacoTherapeuticGroup,
|
RlsPharmacoTherapeuticGroup,
|
||||||
RlsCountry,
|
RlsCountry,
|
||||||
Rls,
|
Rls,
|
||||||
|
|
|
@ -38,6 +38,9 @@ with open(observe_row_file, 'r') as f:
|
||||||
medicine_row_file = os.path.join(ui_dir, 'medicine_row.glade')
|
medicine_row_file = os.path.join(ui_dir, 'medicine_row.glade')
|
||||||
with open(medicine_row_file, 'r') as f:
|
with open(medicine_row_file, 'r') as f:
|
||||||
medicine_row_ui_str = f.read()
|
medicine_row_ui_str = f.read()
|
||||||
|
reception_midicine_row_file = os.path.join(ui_dir, 'reception_medicine_row.glade')
|
||||||
|
with open(reception_midicine_row_file, 'r') as f:
|
||||||
|
reception_midicine_row_ui_str = f.read()
|
||||||
|
|
||||||
main_win_file = os.path.join(ui_dir, 'main_win.glade')
|
main_win_file = os.path.join(ui_dir, 'main_win.glade')
|
||||||
new_patient_win_file = os.path.join(ui_dir, 'new_patient_win.glade')
|
new_patient_win_file = os.path.join(ui_dir, 'new_patient_win.glade')
|
||||||
|
|
|
@ -22,6 +22,9 @@ def search_medicines(q):
|
||||||
def get_all_medicines():
|
def get_all_medicines():
|
||||||
with db.atomic():
|
with db.atomic():
|
||||||
return Rls.select()
|
return Rls.select()
|
||||||
|
def get_medicine(med_id):
|
||||||
|
with db.atomic():
|
||||||
|
return Rls.get_by_id(med_id)
|
||||||
########################################################
|
########################################################
|
||||||
|
|
||||||
class MedicineRow(Gtk.ListBoxRow):
|
class MedicineRow(Gtk.ListBoxRow):
|
||||||
|
@ -72,6 +75,15 @@ def create_choose_medicine_win(reception_b):
|
||||||
enable_widget([accept_button])
|
enable_widget([accept_button])
|
||||||
def medicine_list_unselected(self, *a):
|
def medicine_list_unselected(self, *a):
|
||||||
disable_widget([accept_button])
|
disable_widget([accept_button])
|
||||||
|
def submit(self, button):
|
||||||
|
from mods.receptions import build_reception_medicine_row
|
||||||
|
exist_rows = list(map(lambda x: x.props.db_id, rm_list.get_children()))
|
||||||
|
row = ml.get_selected_row()
|
||||||
|
if row.props.db_id not in exist_rows:
|
||||||
|
medicine = get_medicine(row.props.db_id)
|
||||||
|
rm_list.add(build_reception_medicine_row(medicine))
|
||||||
|
rm_list.show_all()
|
||||||
|
w.destroy()
|
||||||
b.add_from_file(choose_medicine_win_file)
|
b.add_from_file(choose_medicine_win_file)
|
||||||
b.connect_signals(ChooseMedicineWinHandler())
|
b.connect_signals(ChooseMedicineWinHandler())
|
||||||
accept_button = b.get_object('accept_button')
|
accept_button = b.get_object('accept_button')
|
||||||
|
|
|
@ -2,12 +2,12 @@ import gi
|
||||||
from mods.utils import disable_widget, enable_widget
|
from mods.utils import disable_widget, enable_widget
|
||||||
gi.require_version('Gtk', '3.0')
|
gi.require_version('Gtk', '3.0')
|
||||||
from gi.repository import Gtk, GObject, Gdk
|
from gi.repository import Gtk, GObject, Gdk
|
||||||
from mods.db import db, Reception, Patient, ReceptionDiagnosis, ReceptionAnamnesis, ReceptionObserve
|
from mods.db import db, Reception, Patient, ReceptionDiagnosis, ReceptionAnamnesis, ReceptionObserve, ReceptionMedicine
|
||||||
from mods.files import new_reception_win_file, reception_row_ui_str, reception_list_settings_win_file, open_reception_win_file, diagnosis_row_ui_str
|
from mods.files import new_reception_win_file, reception_row_ui_str, reception_list_settings_win_file, open_reception_win_file, diagnosis_row_ui_str
|
||||||
from mods.files import anamnesis_row_ui_str, observe_row_ui_str
|
from mods.files import anamnesis_row_ui_str, observe_row_ui_str, reception_midicine_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.medicines import create_choose_medicine_win
|
from mods.medicines import create_choose_medicine_win, get_medicine
|
||||||
from mods.lists import get_listrecord, get_list_by_system_id, create_open_list_win, ANAMNEZ_LIST, OBSERVE_LIST
|
from mods.lists import get_listrecord, get_list_by_system_id, create_open_list_win, ANAMNEZ_LIST, OBSERVE_LIST
|
||||||
from mods.root import builder
|
from mods.root import builder
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
@ -72,6 +72,13 @@ class ReceptionObserveRow(Gtk.ListBoxRow):
|
||||||
@db_id.setter
|
@db_id.setter
|
||||||
def db_id_setter(self, value):
|
def db_id_setter(self, value):
|
||||||
self._db_id = value
|
self._db_id = value
|
||||||
|
class ReceptionMedicineRow(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
|
||||||
|
|
||||||
def get_reception(reception_id):
|
def get_reception(reception_id):
|
||||||
with db.atomic():
|
with db.atomic():
|
||||||
|
@ -85,6 +92,9 @@ def get_reception_anamnesis_items(reception):
|
||||||
def get_reception_observe_items(reception):
|
def get_reception_observe_items(reception):
|
||||||
with db.atomic():
|
with db.atomic():
|
||||||
return ReceptionObserve.select().where(ReceptionObserve.reception == reception)
|
return ReceptionObserve.select().where(ReceptionObserve.reception == reception)
|
||||||
|
def get_reception_medicine_items(reception):
|
||||||
|
with db.atomic():
|
||||||
|
return ReceptionMedicine.select().where(ReceptionMedicine.reception == reception)
|
||||||
def delete_reception_diagnosisses(reception, diag_id_list):
|
def delete_reception_diagnosisses(reception, diag_id_list):
|
||||||
if not len(diag_id_list): return
|
if not len(diag_id_list): return
|
||||||
with db.atomic():
|
with db.atomic():
|
||||||
|
@ -97,6 +107,10 @@ def delete_reception_observe_symptoms(reception, observe_id_list):
|
||||||
if not len(observe_id_list): return
|
if not len(observe_id_list): return
|
||||||
with db.atomic():
|
with db.atomic():
|
||||||
ReceptionObserve.delete().where((ReceptionObserve.reception == reception) & (ReceptionObserve.symptom.in_(observe_id_list))).execute()
|
ReceptionObserve.delete().where((ReceptionObserve.reception == reception) & (ReceptionObserve.symptom.in_(observe_id_list))).execute()
|
||||||
|
def delete_reception_medicines(reception, medicine_id_list):
|
||||||
|
if not len(medicine_id_list): return
|
||||||
|
with db.atomic():
|
||||||
|
ReceptionMedicine.delete().where((ReceptionMedicine.reception == reception) & (ReceptionMedicine.medicine.in_(medicine_id_list))).execute()
|
||||||
def add_reception_diagnosisses(reception, diag_id_list):
|
def add_reception_diagnosisses(reception, diag_id_list):
|
||||||
if not len(diag_id_list): return
|
if not len(diag_id_list): return
|
||||||
with db.atomic():
|
with db.atomic():
|
||||||
|
@ -112,6 +126,11 @@ def add_reception_observe_symptoms(reception, observe_id_list):
|
||||||
with db.atomic():
|
with db.atomic():
|
||||||
inserts = list(map(lambda x: {'reception': reception, 'symptom': get_listrecord(x)}, observe_id_list))
|
inserts = list(map(lambda x: {'reception': reception, 'symptom': get_listrecord(x)}, observe_id_list))
|
||||||
_ = ReceptionObserve.insert_many(inserts).execute()
|
_ = ReceptionObserve.insert_many(inserts).execute()
|
||||||
|
def add_reception_medicines(reception, medicine_id_list):
|
||||||
|
if not len(medicine_id_list): return
|
||||||
|
with db.atomic():
|
||||||
|
inserts = list(map(lambda x: {'reception': reception, 'medicine': get_medicine(x)}, medicine_id_list))
|
||||||
|
_ = ReceptionMedicine.insert_many(inserts).execute()
|
||||||
def save_reception_diagnosisses(reception, diag_id_list):
|
def save_reception_diagnosisses(reception, diag_id_list):
|
||||||
exist_diags = set(map(lambda x: x.diagnosis.id, get_reception_diagnosis_items(reception)))
|
exist_diags = set(map(lambda x: x.diagnosis.id, get_reception_diagnosis_items(reception)))
|
||||||
new_diags = set(diag_id_list)
|
new_diags = set(diag_id_list)
|
||||||
|
@ -195,6 +214,17 @@ def build_reception_observe_row(observe):
|
||||||
row.props.db_id = observe.id
|
row.props.db_id = observe.id
|
||||||
row.add(box)
|
row.add(box)
|
||||||
return row
|
return row
|
||||||
|
def build_reception_medicine_row(medicine):
|
||||||
|
b = Gtk.Builder()
|
||||||
|
b.add_from_string(reception_midicine_row_ui_str)
|
||||||
|
win = b.get_object('win')
|
||||||
|
box = b.get_object('reception_medicine_box')
|
||||||
|
b.get_object('title').set_text(f'{medicine.tradename}')
|
||||||
|
win.remove(win.get_children()[0])
|
||||||
|
row = ReceptionMedicineRow()
|
||||||
|
row.props.db_id = medicine.id
|
||||||
|
row.add(box)
|
||||||
|
return row
|
||||||
def create_open_reception_win():
|
def create_open_reception_win():
|
||||||
b = Gtk.Builder()
|
b = Gtk.Builder()
|
||||||
reception_list = builder.get_object('reception_list')
|
reception_list = builder.get_object('reception_list')
|
||||||
|
|
|
@ -23,6 +23,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="submit" swapped="no"/>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!-- Generated with glade 3.22.1 -->
|
<!-- Generated with glade 3.22.2 -->
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.20"/>
|
<requires lib="gtk+" version="3.20"/>
|
||||||
<object class="GtkWindow" id="win">
|
<object class="GtkWindow" id="win">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="decorated">False</property>
|
<property name="decorated">False</property>
|
||||||
<child>
|
<child type="titlebar">
|
||||||
<placeholder/>
|
<placeholder/>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Generated with glade 3.22.2 -->
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk+" version="3.20"/>
|
||||||
|
<object class="GtkWindow" id="win">
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="decorated">False</property>
|
||||||
|
<child type="titlebar">
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox" id="reception_medicine_box">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="title">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">label</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</interface>
|
Loading…
Reference in New Issue