1 Star 0 Fork 0

似火/untitled2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
病历书写qt.py 16.00 KB
一键复制 编辑 原始数据 按行查看 历史
from PyQt5.Qt import *
import sys,os
from peewee import *
from datetime import datetime,date,timedelta
from 病历书写 import Ui_MainWindow
from 病历输入模板 import Ui_Dialog
from WordHelp.WordApp import WordApp
db=SqliteDatabase(os.getcwd()+r"/病历记录.db")
class Mywindow(Ui_MainWindow):
def __init__(self):
super().__init__()
super().setupUi(self)
self.LineEdit_ruyuanriqi.setText(datetime.now().strftime("%Y-%m-%d %H:%M"))
self.LineEdit_bingshicaijiriqi.setText((datetime.now()+timedelta(hours=4)).strftime("%Y-%m-%d %H:%M"))
self.lineEdit_zhusu.setText("腹痛、恶心、呕吐1天,加重2小时。")
self.textEdit_xianbingshi.setText(''' 患者1天前进食油腻食品后出现腹痛、恶心症状,腹痛以剑突下、脐周较为明显,为阵发性绞痛,并伴呕吐,呕吐物为胃内容物,患者自服用“多潘立酮”1片治疗,症状稍减轻,夜间呕吐2次,今晨晨起后患者腹痛症状加重,为求诊治来我院,门诊以“1、急性胆囊炎 2、后循环缺血 3、脑出血后遗症”为诊断收入我科;自发病来,饮食、睡眠差,二便正常,体重未明显减轻。
“高血压”病史9年余,服用“硝苯地平缓释片”20mg每天治疗,血压控制在140/90mmhg左右。
''')
self.textEdit_jiwangshi.setText('''否认“糖尿病、冠心病”等其他慢性病病史;否认有肝炎、结核等传染病病史;否认外伤史;否认输血、献血史;否认食物、药物过敏史;预防接种随当地社会进行。系统回顾无异常。
''')
self.textEdit_guominshi.setText('''否认药物过敏史,否认食物过敏史。''')
self.textEdit_gerenshi.setText('''出生并生长于原籍,无外地久居史;无疫区接触史;职业与工作条件无工业毒物、粉尘、放射性物质接触史;无冶游史;否认毒品及药物成瘾史;无烟、酒等其他不良嗜好。''')
self.lineEdit_hunyinshi.setText('''适龄结婚,爱人体健,夫妻关系和睦。2子,均体健。''')
self.lineEdit_yuejingshi.setPlaceholderText('''请不要填写''')
self.lineEdit_jiazushi.setText('''父母已故,死因不详。兄妹均体健。否认有家族遗传性疾病。''')
self.lineEdit_tiwen.setText('36.5')
self.lineEdit_maibo.setText('70')
self.lineEdit_huxi.setText('18')
self.lineEdit_xueya.setText('130/80')
self.textEdit_zhuankejiancha.setText('''双肺呼吸音清,未闻及干湿性啰音。心前区无隆起,心尖搏动正常。无震颤及心包摩擦感。心浊音界正常。心率62次/分,律齐,心音有力,各瓣膜听诊区未闻及病理性杂音,剑突下、脐周压痛明显,肝脏于右侧肋缘下未触及,墨菲氏征阳性,脾脏于左侧肋缘下未触及,麦氏点压痛阴性,双下肢无水肿。''')
self.textEdit_fuzhujiancha.setText('''心电图示:1、正常心电图。血常规示:白细胞计数6.88*109/l,中性粒细胞比率51.4%,血生化基本正常。''')
self.textEdit_chubuzhenduan.setText('''1、急性胃炎 2、后循环缺血 3、2型糖尿病''')
self.textEdit_jianbiezhenduan.setText('''本病应和1、化脓性胆囊炎 也可出现墨菲征阳性,右上腹疼痛等症状,但一般伴发热、黄疸等症状,腹部彩超可有特异性表现,本例暂不考虑。2、胆管结石并感染 也可出现剧烈腹痛,但一般为阵发性,可出现黄疸,彩超可鉴别,本例暂不考虑。''')
self.lineEdit_zhiliaojihua.setText('''给予头孢呋辛、替硝唑控制感染,维生素b6保护胃黏膜,并给予口服药物治疗''')
self.lineEdit_bianzheng.setText('''活血通络、补虚泄浊''')
self.lineEdit_fangzi.setText('定眩汤')
self.lineEdit_bingming.setText('胆囊炎')
self.textEdit_fangzineirong.setText('''茯苓15g 党参20g 泽泻12g 天麻10g
钩藤20g 北柴胡15g 清半夏10g 酸枣仁18g
檀香9g 陈皮12g 胎菊15g 三七粉6g
用法:水煎服每日1剂,分2次''')
self.horizontalLayout_2.setStretchFactor(self.verticalLayout_2,1)
self.horizontalLayout_2.setStretchFactor(self.verticalLayout_3,3)
self.treeWidget.setMinimumWidth(400)
self.treeWidget.setColumnCount(2)
self.verticalLayout_2.SetMaximumSize=True
self.btn_addBingmingmodel=QPushButton()
self.btn_addBingmingmodel.setText("添加到疾病模板")
self.LineEdit_addBingmingmodel=QLineEdit()
self.LineEdit_addBingmingmodel.setPlaceholderText("请输入病名模板名称")
self.btn_addZhongyaomodel=QPushButton()
self.btn_addZhongyaomodel.setText("添加到中药模板")
self.LineEdit_addZhongyaomodel=QLineEdit()
self.LineEdit_addZhongyaomodel.setPlaceholderText("请输入中药模板名称")
self.verticalLayout_2.addWidget(self.LineEdit_addBingmingmodel)
self.verticalLayout_2.addWidget(self.btn_addBingmingmodel)
self.verticalLayout_2.addWidget(self.LineEdit_addZhongyaomodel)
self.verticalLayout_2.addWidget(self.btn_addZhongyaomodel)
self.btn_addBingmingmodel.clicked.connect(self.addBingming)
self.btn_addZhongyaomodel.clicked.connect(self.addZhongyao)
self.treeWidget.setHeaderLabels(["模板类型","模板"])
self.treeWidget.clicked.connect(self.onTreeItemClicked)
self.root=QTreeWidgetItem(self.treeWidget)
self.root2=QTreeWidgetItem(self.treeWidget)
self.fullmod=["冠心病","急性支气管肺炎","胆囊炎","急性泌尿系感染"]
self.root.setText(0,"完整模板")
self.root2.setText(0,"中药模板")
QTreeWidgetItem(self.root2).setText(1,"瓜蒌薤白汤")
QTreeWidgetItem(self.root2).setText(1,"补阳怀五汤")
QTreeWidgetItem(self.root2).setText(1,"银翘散")
QTreeWidgetItem(self.root2).setText(1,"武大郎")
QTreeWidgetItem(self.root2).setText(1,"潘金莲")
self.pushButton.clicked.connect(self.saveToDocs)
self.pushButton_2.clicked.connect(self.saveShouci)
for i,k in enumerate(self.fullmod):
QTreeWidgetItem(self.root).setText(1,k)
def onTreeItemClicked(self,index:QModelIndex):
pass
def saveShouci(self):
pass
def saveToDocs(self):
self.bingli = Bingli()
self.bingli.姓名=self.LineEdit_name.text()
self.bingli.性别=self.LineEdit_sex.text()
self.bingli.年龄=self.LineEdit_age.text()
self.bingli.籍贯=self.LineEdit_jiguan.text()
self.bingli.职业=self.LineEdit_job.text()
self.bingli.婚姻=self.LineEdit_hunyin.text()
self.ruyuanriqi=datetime.strptime(self.LineEdit_ruyuanriqi.text(),"%Y-%m-%d %H:%M")
self.bingli.入院日期=self.ruyuanriqi
self.bingli.家庭住址=self.LineEdit_jiatingzhuzhi.text()
self.bingli.病史采集日期=self.ruyuanriqi+timedelta(hours=5)
self.bingli.联系人=self.LineEdit_lianxiren.text()
self.bingli.与患者关系=self.LineEdit_guanxi.text()
self.bingli.电话=self.LineEdit_dianhua.text()
self.bingli.家庭住址=self.lineEdit_jiatingzhuzhi.text()
self.bingli.主诉=self.lineEdit_zhusu.text()
self.bingli.现病史=self.textEdit_xianbingshi.toPlainText()
self.bingli.既往史=self.textEdit_jiwangshi.toPlainText()
self.bingli.过敏史=self.textEdit_guominshi.toPlainText()
self.bingli.个人史=self.textEdit_guominshi.toPlainText()
self.bingli.婚育史=self.lineEdit_hunyinshi.text()
self.bingli.月经史=self.lineEdit_yuejingshi.text()
self.bingli.家族史=self.lineEdit_jiazushi.text()
self.bingli.体温=self.lineEdit_tiwen.text()
self.bingli.脉搏=self.lineEdit_maibo.text()
self.bingli.呼吸=self.lineEdit_huxi.text()
self.bingli.血压=self.lineEdit_xueya.text()
self.bingli.专科检查=self.textEdit_zhuankejiancha.toPlainText()
self.bingli.辅助检查=self.textEdit_fuzhujiancha.toPlainText()
self.bingli.初步诊断=self.textEdit_chubuzhenduan.toPlainText()
self.bingli.病名=self.lineEdit_bingming.text()
self.bingli.辩证=self.lineEdit_bianzheng.text()
self.bingli.方子=self.lineEdit_fangzi.text()
self.bingli.方子内容=self.textEdit_fangzineirong.toPlainText()
self.bingli.鉴别诊断=self.textEdit_jianbiezhenduan.toPlainText()
self.bingli.治疗计划=self.lineEdit_zhiliaojihua.text()
self.name=self.LineEdit_name.text()
self.bingli.病历文件位置=self.name+self.ruyuanriqi.date().strftime("%Y-%m-%d")
self.bingli.首次病程位置=self.name+self.ruyuanriqi.date().strftime("%Y-%m-%d")
self.bingli.出院记录位置=self.name+self.ruyuanriqi.date().strftime("%Y-%m-%d")
# db.connect()
# self.bingli.save()
# db.close()
self.worddo()
def worddo(self):
app_bingli = WordApp()
app_bingli.setVisible(False)
app_bingli.open(os.getcwd() + "/" + "病历自动生成/病历书写模板.docx")
app_shouci=WordApp()
app_shouci.setVisible(False)
app_shouci.open(os.getcwd()+"/"+"病历自动生成/病程记录模板.docx")
app_chuyuan=WordApp()
app_chuyuan.setVisible(False)
app_chuyuan.open(os.getcwd()+"/"+"病历自动生成/出院记录模板.docx")
self.wordReplace(app_bingli)
self.wordReplace(app_shouci)
self.wordReplace(app_chuyuan)
self.shouciReplace(app_shouci)
if not os.path.exists(self.bingli.病历文件位置):
os.makedirs(self.bingli.病历文件位置)
app_bingli.saveAs(os.getcwd() + "/" + self.bingli.病历文件位置 + r"/大病历.docx")
app_shouci.saveAs(os.getcwd() + "/" + self.bingli.病历文件位置 + r"/首次.docx")
app_chuyuan.saveAs(os.getcwd() + "/" + self.bingli.病历文件位置 + r"/出院记录.docx")
app_bingli.quit()
app_shouci.quit()
app_chuyuan.quit()
db.connect()
self.bingli.save()
db.close()
QMessageBox.show("生成完成!")
def wordReplace(self,app_bingli):
app_bingli.replaceStr("$姓名$", self.LineEdit_name.text())
app_bingli.replaceStr("$性别$", self.LineEdit_sex.text())
app_bingli.replaceStr("$年龄$", self.LineEdit_age.text())
app_bingli.replaceStr("$籍贯$", self.LineEdit_jiguan.text())
app_bingli.replaceStr("$职业$", self.LineEdit_job.text())
app_bingli.replaceStr("$婚姻$", self.LineEdit_hunyin.text())
app_bingli.replaceStr("$入院日期$", self.LineEdit_ruyuanriqi.text())
app_bingli.replaceStr("$家庭住址$", self.lineEdit_jiatingzhuzhi.text())
app_bingli.replaceStr("$病史采集日期$", self.LineEdit_bingshicaijiriqi.text())
app_bingli.replaceStr("$联系人$", self.LineEdit_lianxiren.text())
app_bingli.replaceStr("$关系$", self.LineEdit_guanxi.text())
app_bingli.replaceStr("$电话$", self.LineEdit_dianhua.text())
app_bingli.replaceStr("$家庭住址$", self.lineEdit_jiatingzhuzhi.text())
app_bingli.replaceStr("$主诉$", self.lineEdit_zhusu.text())
app_bingli.replaceStr("$现病史$", self.textEdit_xianbingshi.toPlainText())
app_bingli.replaceStr("$既往史$", self.textEdit_jiwangshi.toPlainText())
app_bingli.replaceStr("$过敏史$", self.textEdit_guominshi.toPlainText())
app_bingli.replaceStr("$个人史$", self.textEdit_gerenshi.toPlainText())
app_bingli.replaceStr("$婚姻史$", self.lineEdit_hunyinshi.text())
app_bingli.replaceStr("$家族史$", self.lineEdit_jiazushi.text())
app_bingli.replaceStr("$体温$", self.lineEdit_tiwen.text())
app_bingli.replaceStr("$脉搏$", self.lineEdit_maibo.text())
app_bingli.replaceStr("$呼吸$", self.lineEdit_huxi.text())
app_bingli.replaceStr("$血压$", self.lineEdit_xueya.text())
app_bingli.replaceStr("$专科检查$", self.textEdit_zhuankejiancha.toPlainText())
app_bingli.replaceStr("$辅助检查$", self.textEdit_fuzhujiancha.toPlainText())
app_bingli.replaceStr("$初步诊断$", self.textEdit_chubuzhenduan.toPlainText())
app_bingli.replaceStr("$鉴别诊断$", self.textEdit_jianbiezhenduan.toPlainText())
app_bingli.replaceStr("$治疗计划$", self.lineEdit_zhiliaojihua.text())
app_bingli.replaceStr("$辩证$", self.lineEdit_bianzheng.text())
app_bingli.replaceStr("$方子$", self.lineEdit_fangzi.text())
app_bingli.replaceStr("$方子内容$", self.textEdit_fangzineirong.toPlainText())
def shouciReplace(self,app_shouci:WordApp):
app_shouci.replaceStr("$入院第一天$",self.ruyuanriqi.strftime("%Y-%m-%d")+" 8:00")
app_shouci.replaceStr("$入院第二天$",(self.ruyuanriqi+timedelta(days=1)).strftime("%Y-%m-%d")+" 8:00")
app_shouci.replaceStr("$入院第三天$",(self.ruyuanriqi+timedelta(days=2)).strftime("%Y-%m-%d")+" 8:00")
app_shouci.replaceStr("$入院第六天$",(self.ruyuanriqi+timedelta(days=5)).strftime("%Y-%m-%d")+" 8:00")
app_shouci.replaceStr("$入院第九天$",(self.ruyuanriqi+timedelta(days=8)).strftime("%Y-%m-%d")+" 8:00")
def addBingming(self):
pass
def addZhongyao(self):
pass
class Bingli(Model):
class Meta:
database=db
姓名=CharField(null=True)
性别=CharField(null=True)
年龄=CharField(null=True)
籍贯=CharField(null=True)
职业=CharField(null=True)
婚姻=CharField(null=True)
入院日期=DateTimeField(default=datetime.now())
家庭住址=CharField(max_length=50,null=True)
病史采集日期=DateTimeField(default=datetime.now()+timedelta(hours=5))
联系人=CharField(max_length=10,null=True)
与患者关系=CharField(max_length=10,null=True)
电话=CharField(max_length=20,null=True)
家庭住址=CharField(max_length=50,null=True)
主诉=CharField(null=True)
现病史=TextField(null=True)
既往史=TextField(null=True)
过敏史=CharField(null=True)
个人史=CharField(null=True)
婚育史=CharField(null=True)
月经史=CharField(null=True)
家族史=CharField(null=True)
体温=CharField(null=True)
脉搏=CharField(null=True)
呼吸=CharField(null=True)
血压=CharField(null=True)
专科检查=TextField(null=True)
辅助检查=TextField(null=True)
初步诊断=TextField(null=True)
病名 = CharField(null=True)
辩证 = CharField(default="益气养阴,活血化瘀")
方子 = TextField(null=True)
方子内容 = TextField(null=True)
鉴别诊断 = TextField(null=True)
治疗计划 = TextField(null=True)
添加日期=DateField(default=date.today(),null=True)
病历文件位置=CharField(default="",null=True)
首次病程位置=CharField(default="",null=True)
出院记录位置=CharField(default="",null=True)
class Zhongyao(Model):
class Meta:
database=db
病名=CharField(null=True)
辩证=CharField(default="益气养阴,活血化瘀")
方子=TextField(null=True)
方子内容=TextField(null=True)
添加日期 = DateField(default=date.today(),null=True)
class Jibing(Model):
class Meta:
database=db
病名=CharField(null=True)
辩证 = CharField(null=True)
方子 = TextField(null=True)
方子内容=TextField(null=True)
主诉 = CharField(null=True)
现病史 = TextField(null=True)
专科检查 = TextField(null=True)
辅助检查 = TextField(null=True)
初步诊断 = TextField(null=True)
鉴别诊断=TextField(null=True)
治疗计划=TextField(null=True)
添加日期 = DateField(default=date.today(),null=True)
病历文件位置 = CharField(default="",null=True)
首次病程位置 = CharField(default="",null=True)
出院记录位置 = CharField(default="",null=True)
if __name__ == '__main__':
app = QApplication(sys.argv)
mywin=Mywindow()
mywin.show()
sys.exit(app.exec_())
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/aslyr/untitled2.git
[email protected]:aslyr/untitled2.git
aslyr
untitled2
untitled2
master

搜索帮助