def unpack(request): code = int(request.POST.get("code")) log.info( str(request.session["username"]) + str(request.session["auth"]) + "访问了数据库") back_dic = "" id = int(request.session["id"]) if code == 1: print("go f**k yourself") elif code == 2: back_dic = getAllPatient(id) elif code == 3: back_dic = getAllNurse(id) elif code == 4: choose = request.POST.get("choose") back_dic = getExPatient(id, choose) elif code == 5: back_dic = patientOut() elif code == 6: back_dic = moreOperation() elif code == 7: nurse = request.POST.get("nurse") back_dic = getPatientByNurse(nurse) elif code == 8: nurse = request.POST.get("nurse") back_dic = nurseDelete(id, nurse) elif code == 9: back_dic = getAllWard(id) elif code == 10: name = request.POST.get("name") username = request.POST.get("username") password = request.POST.get("password") back_dic = addNurse(id, name, username, password) return HttpResponse(json.dumps(back_dic))
def getAllWard(id): log.info("获取所有病床") back_list = nurse_master_query_sickbed_and_patient(id) back_dic = {"code": "1", "msg": "success", "data": []} for (a, b, c, d, e) in back_list: item = {"sid": a, "sstatus": b, "pid": c, "pname": d, "pinfo": e} back_dic["data"].append(item) return json.dumps(back_dic)
def addNat(id, result, life, date): log.info("添加核酸检测单给" + str(id)) il_level = ["轻症", "重症", "危重症"] result_level = ["阴性", "阳性"] add_nat_report(result_level[int(result)], date, il_level[int(life) - 1], int(id)) back_dic = {"code": "1", "msg": "success", "data": []} return json.dumps(back_dic)
def getPatientByNurse(nurse): log.info("获取" + str(nurse) + "负责的病人") back_list = doctor_query_nurse_patient(int(nurse)) back_dic = {"code": "1", "msg": "success", "data": []} for (a, b, c) in back_list: if c is None: c = "暂无" item = {"id": a, "name": b, "status": c} back_dic["data"].append(item) return json.dumps(back_dic)
def getAllNurse(id): log.info("获取所有护士和护士长") result = doctor_query_nurses(int(id)) back_dic = {"code": "1", "msg": "success", "data": []} for (a, b, c, d, e) in result: auth = 0 if e == "nurse_master": auth = 1 item = {"id": a, "name": c, "auth": auth} back_dic["data"].append(item) return json.dumps(back_dic)
def getAllPatient(id): log.info("获取当前治疗区域的病人信息") back_list = nurse_master_query_patient(id, -1) back_dic = {"code": "1", "msg": "success", "data": []} status = ["可出院", "治疗中", "待转移"] for (a, b, c, d) in back_list: if c is None: c = "暂无" item = {"id": a, "name": b, "status": c + status[d + 1]} back_dic["data"].append(item) return json.dumps(back_dic)
def patientOut(): log.info("获取所有可以出院的病人") back_dic = { "code": "1", "msg": "success", "data": [{ "id": "1", "name": "sb", "status": "可出院" }] } return json.dumps(back_dic)
def moreOperation(): log.info("修改该区域病房护士信息") back_dic = { "code": "1", "msg": "success", "data": [{ "id": "1", "name": "sb", "status": "可出院" }] } return json.dumps(back_dic)
def moreOperation(id, life): life_str = "" if life == 1: life_str = "轻症" if life == 2: life_str = "重症" if life == 3: life_str = "危重症" log.info("修改" + str(id) + "评级为" + str(life_str)) update_nat_illness_level(life_str, id) back_dic = { "code": "1", "msg": "success", } return json.dumps(back_dic)
def getNat(pid): log.info("获取病人" + pid + "核酸检测结果") (a, b, c, d) = ward_nurse_query_nat_report(int(pid)) item = { "id": a, "time": str(c), "live": d, "result": b } back_dic = { "code": "1", "msg": "success", "data": item } return back_dic
def getPatientOut(id): log.info("获取所有可以出院的病人") back_list = doctor_query_patient(int(id), 3) back_dic = {"code": "1", "msg": "success", "data": []} status = ["可出院", "治疗中", "待转移"] for (a, b, c, d) in back_list: life = 0 if c == "病亡": life = 1 item = { "id": a, "name": b, "status": c + "," + status[d + 1], "life": life } back_dic["data"].append(item) return json.dumps(back_dic)
def getExPatient(choose, id): log.info("按照筛选条件搜索病人的病人") back_list = doctor_query_patient(id, int(choose)) back_dic = {"code": "1", "msg": "success", "data": []} status = ["可出院", "治疗中", "待转移"] for (a, b, c, d) in back_list: life = 0 if c == "病亡": life = 1 if c is None: c = "暂无" item = { "id": a, "name": b, "status": c + "," + status[d + 1], "life": life } back_dic["data"].append(item) return json.dumps(back_dic)
def updateNat(pid, temp, sympton, liveStatus, cur_id): log.info("更新" + pid + "核酸检测单") status = [ "在院治疗", "病亡" ] back_dic = { "code": "1", "msg": "success", "data": [] } year = time.localtime().tm_year month = time.localtime().tm_mon day = time.localtime().tm_mday hour = time.localtime().tm_hour minute = time.localtime().tm_min second = time.localtime().tm_sec time_str = str(year) + "-" + str(month) + "-" + str(day) + " " + str(hour) + ":" + str(minute) + ":" + str(second) record_patient_status(time_str, float(temp), sympton, status[int(liveStatus)], int(cur_id), int(pid)) return json.dumps(back_dic)
def unpack(request): code = int(request.POST.get("code")) log.info(str(request.session["username"]) + str(request.session["auth"]) + "访问了数据库") back_dic = "" id = int(request.session["id"]) if code == 1: print("go f**k yourself") elif code == 2: back_dic = getAllPatient(id) elif code == 3: pid = request.POST.get("pid") back_dic = getNat(pid) elif code == 4: choose = request.POST.get("choose") back_dic = getExPatient(id, choose) elif code == 5: pid = request.POST.get("pid") temp = request.POST.get("temp") sympton = request.POST.get("sympton") liveStatus = request.POST.get("liveStatus") cur_id = request.POST.get("currentID") back_dic = updateNat(pid, temp, sympton, liveStatus, cur_id) return HttpResponse(json.dumps(back_dic))
def unpack(request): code = int(request.POST.get("code")) id = request.session["id"] log.info( str(request.session["username"]) + str(request.session["auth"]) + "访问了数据库") back_dic = "" if code == 1: back_dic = getPatientOut(id) elif code == 2: back_dic = getAllPatient(id) elif code == 3: back_dic = getAllNurse(id) elif code == 4: choose = int(request.POST.get("choose")) back_dic = getExPatient(choose, id) elif code == 5: pid = int(request.POST.get("pid")) back_dic = patientOut(pid) elif code == 6: pid = int(request.POST.get("pid")) life = int(request.POST.get("life")) back_dic = moreOperation(pid, life) elif code == 7: nurse = int(request.POST.get("param[nurse]")) back_dic = getPatientByNurse(nurse) elif code == 8: die = int(request.POST.get("pid")) back_dic = patientDie(die, id) elif code == 10: result = request.POST.get("result") date = request.POST.get("date") life = request.POST.get("life") pid = request.POST.get("pid") back_dic = addNat(pid, result, life, date) return HttpResponse(json.dumps(back_dic))
def nurseDelete(id, nurse): log.info("删除护士" + str(nurse)) delete_ward_nurse(id, int(nurse)) return {"code": "1", "msg": "success", "data": []}
def addNurse(id, name, username, password): log.info("添加护士" + name) add_ward_nurse(id, username, password, name) return {"code": "1", "msg": "success", "data": []}
def patientDie(die, id): log.info("使" + str(die) + "病人死亡") back_dic = {"code": "1", "msg": "success", "data": []} update_patient_life_status("病亡", die) return json.dumps(back_dic)
def patientOut(pid): log.info("使" + str(pid) + "病人出院") update_patient_life_status("康复出院", pid) back_dic = {"code": "1", "msg": "success", "data": []} return json.dumps(back_dic)
from connector.connectMysql import db from Service.BaseService import insert_user from util import config from util import logger import pymysql treatment_area = ['轻症治疗区域', '重症治疗区域', '危重症治疗区域'] init_ward_number = [5, 5, 3] init_ward_nurse_per_area = [3, 2, 2] sickbed_per_ward = [4, 2, 1] from util.logger import logggg as log log.info("----------------------------") log.info("start initializing.") database = pymysql.connect(config.IP, config.DB_USER, config.DB_PASSWORD) cursor = database.cursor() cursor.execute("drop database if exists %s" % config.DB_NAME) cursor.execute("create database %s" % config.DB_NAME) database.commit() database.close() log.info("read sql") cursor = db.cursor() sql_file = open("../static/Hospital.sql", "r+", encoding="utf-8") all_sql = sql_file.read().split(";") sql_file.close() for sql in all_sql: if sql.strip() != '': cursor.execute(sql) db.commit()