from django.shortcuts import render
from django.shortcuts import HttpResponse
from django.utils import timezone
import json
import traceback
from hoimsystem.models.roleUser import *
from hoimsystem.models.adminOp import *
from hoimsystem.models.doctorOp import *
from hoimsystem.models.roleUser import *
from hoimsystem.models.patientOp import *
# Create your views here.
# 测试api
def test(request):
response = {"code": 200, "msg": 'success'}
return HttpResponse(json.dumps(response))
# 医生注册
def add_doctor(request):
received_data = json.loads(request.body.decode())
username = received_data.get('username')
if users.objects.filter(username=username).exists():
response = {"code": 500, "msg": '已存在相同用户'}
return HttpResponse(json.dumps(response))
password = received_data.get('password')
name = received_data.get('name')
title = received_data.get('title')
if received_data.get('sex') == '女':
sex = 0
else:
sex = 1
phone = received_data.get('phone')
department_in = department.objects.get(department_id=received_data.get('department'))
permission = received_data.get('permission')
education = received_data.get('education')
try:
# 判断是否为科室主任
if permission == 'director':
users.objects.create(username=username, password=password, user_role="director")
else:
users.objects.create(username=username, password=password, user_role="doctor")
user_id = users.objects.get(username=username)
# 在医生表中插入记录
doctor.objects.create(name=name, sex=sex, title=title, education=education, phone=phone, permission=permission, department_id=department_in, user_id=user_id)
response = {"code": 200, "msg": 'success'}
except:
traceback.print_exc()
response = {"code": 500, "msg": '医生注册失败'}
return HttpResponse(json.dumps(response))
# 医生排班
def doctor_schedule_register(request):
received_data = json.loads(request.body.decode())
schedule_list = received_data.get('schedule')
specialist = received_data.get('specialist')
number = received_data.get('number')
doctor_obj = doctor.objects.get(doctor_id=received_data.get('doctor'))
for i in schedule_list:
week = i[0:3]
time = i[3:5]
if doctor_schedule.objects.filter(week=week, time=time, doctor_id=doctor_obj).exists():
doctor_schedule_obj = doctor_schedule.objects.get(week=week, time=time, doctor_id=doctor_obj)
doctor_schedule_obj.number = number
doctor_schedule_obj.specialist = specialist
doctor_schedule_obj.save()
else:
doctor_schedule.objects.create(week=week, time=time, number=number, specialist=specialist, doctor_id=doctor_obj)
response = {"code": 200, "msg": 'success'}
return HttpResponse(json.dumps(response))
# 医生排班信息查看
def doctor_schedule_getlist(request):
token = users.objects.get(username=request.META.get('HTTP_ACCESSTOKEN')).user_role
data = []
if token == 'admin' or token == 'patient':
schedule_list = doctor_schedule.objects.all()
doctor_list = doctor.objects.all()
for i in doctor_list:
schedule_list = doctor_schedule.objects.filter(doctor_id=i.doctor_id)
schedule = []
for j in schedule_list:
schedule.append(j.week[2] + j.time[0])
data.append({
'id': i.doctor_id,
'name': i.name,
'schedule': schedule,
'number': j.number,
'specialist': j.specialist
})
elif token == 'doctor' or token == 'director':
token = users.objects.get(username=request.META.get('HTTP_ACCESSTOKEN')).user_role
doctor_obj = doctor.objects.get(user_id=users.objects.get(username=request.META.get('HTTP_ACCESSTOKEN')))
schedule_list = doctor_schedule.objects.filter(doctor_id=doctor_obj.doctor_id)
schedule = []
for i in schedule_list:
schedule.append(i.week[2] + i.time[0])
data.append({
'id': doctor_obj.doctor_id,
'name': doctor_obj.name,
'schedule': schedule
})
response = {"code": 200, "msg": 'success', 'data': data}
return HttpResponse(json.dumps(response))
# 药品注册
def pharmaceutical_register(request):
received_data = json.loads(request.body.decode())
name = received_data.get('name')
stock = received_data.get('stock')
price = float(received_data.get('price'))
expireddate = received_data.get('expireddate')
purchasing_time = timezone.now()
supplier = received_data.get('supplier')
remark = received_data.get('remark')
pharmaceutical.objects.create(name=name, stock=stock, price=price, expireddate=expireddate, purchasing_time=purchasing_time, supplier=supplier, remark=remark)
response = {"code": 200, "msg": 'success'}
return HttpResponse(json.dumps(response))
# 药品信息
def get_pharmaceutical_list(request):
pharmaceutical_list = pharmaceutical.objects.all()
data = []
for item in pharmaceutical_list:
data.append({
'id': item.pharmaceutical_id,
'name': item.name,
'stock': item.stock,
'price': item.price,
'expireddate': str(item.expireddate),
'purchasing_time': str(item.purchasing_time),
'supplier': item.supplier,
'remark': item.remark
})
response = {"code": 200, "msg": 'success', "data": data}
return HttpResponse(json.dumps(response))
# 药品处方查询
def pharmaceutical_stock_query(request):
received_data = json.loads(request.body.decode())
pharmaceutical_id = received_data.get('id')
stock_status = pharmaceutical.objects.get(pharmaceutical_id=pharmaceutical_id).stock
data = {"stock": stock_status}
response = {"code": 200, "msg": 'success', "data": data}
return HttpResponse(json.dumps(response))
# 处方注册
def prescription_register(request):
received_data = json.loads(request.body.decode())
doctor_uid = users.objects.get(username=request.META.get('HTTP_ACCESSTOKEN')).user_id
doctor_obj = doctor.objects.get(user_id=doctor_uid)
patient_id = received_data.get('patient')
patient_obj = patient.objects.get(patient_id=patient_id)
pre = prescription.objects.create(patient_id=patient_obj, doctor_id=doctor_obj)
prescription_obj = prescription.objects.get(prescription_id=pre.prescription_id)
phas = received_data.get('phas')
amount = 0
for item in phas:
pharmaceutical_obj = pharmaceutical.objects.get(pharmaceutical_id=item['id'])
pharmaceutical_obj.stock -= int(item['number'])
pharmaceutical_obj.save()
pre_pha.objects.create(prescription_id=pre.prescription_id, pharmaceutical_id=pharmaceutical_obj, number=item['number'])
price = pharmaceutical.objects.get(pharmaceutical_id=item['id']).price
amount = amount + float(price) * int(item['number'])
print(amount)
charge.objects.create(charge_time=timezone.now(), time="1970-1-1", prescription_id=prescription_obj, amount=amount, status=0)
response = {"code": 200, "msg": 'success'}
return HttpResponse(json.dumps(response))
# 获取处方信息
def get_prescription_list(request):
role = users.objects.get(username=request.META.get('HTTP_ACCESSTOKEN')).user_role
username = users.objects.get(username=request.META.get('HTTP_ACCESSTOKEN')).username
data = []
if role == 'admin':
prescriptions = prescription.objects.all()
for item in prescriptions:
doctor_id = item.doctor_id.doctor_id
doctor_name = item.doctor_id.name
patient_id = item.patient_id.patient_id
patient_name = item.patient_id.name
phas = []
phas_raw = p
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【资源说明】 基于Vue+Django的前后端分离医院信息管理系统源码+运行说明(毕业设计).zip 如何运行 - 运行前端 ``` bash cd vue-ui npm i npm run serve ``` - 运行后端(以Windows系统为例) ``` bash cd django_be pip install -r requirement.txt python manage.py makemigration python manage.py migrate python manage.py runserver ``` ## 架构 - 前端 - Vue2.x - Element-ui - 后端 - Django ## 开发环境 - Windows 11 22H2 - Python 3.7.3 - Node.js v16.18.1 - MySQL 8.0.31 【备注】 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用!有问题请及时沟通交流。 2、适用人群:计算机相关专业(如计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网、自动化、电子信息等)在校学生、专业老师或者企业员工下载使用。 3、用途:项目具有较高的学习借鉴价值,不仅适用于小白学习入门进阶。也可作为毕设项目、课程设计、大作业、初期项目立项演示等。 4、如果基础还行,或热爱钻研,亦可在此项目代码基础上进行修改添加,实现其他不同功能。 欢迎下载,沟通交流,互相学习,共同进步!
资源推荐
资源详情
资源评论
收起资源包目录
基于Vue+Django的前后端分离医院信息管理系统源码+运行说明(毕业设计).zip (315个子文件)
.browserslistrc 55B
plus.css 9KB
dots.css 2KB
loading.css 2KB
gauge.css 1KB
inner-circles.css 998B
.editorconfig 207B
.gitattributes 275B
.gitignore 355B
.gitignore 176B
.gitignore 17B
index.html 1KB
favicon_backup.ico 4KB
favicon.ico 4KB
django_be.iml 1KB
background.jpg 1.94MB
zfb_kf.jpg 121KB
zfb_699.jpg 105KB
zfb_100.jpg 102KB
zfb_799.jpg 102KB
right.jpg 95KB
left.jpg 73KB
remixIcon.js 45KB
index.js 22KB
icon.js 15KB
router.js 7KB
changeLog.js 6KB
index.js 6KB
colorfulIcon.js 5KB
vue.config.js 5KB
vab.js 4KB
tabsBar.js 3KB
request.js 3KB
user.js 3KB
user.js 3KB
index.js 3KB
setting.config.js 3KB
permission.js 2KB
table.js 2KB
notice.js 2KB
encrypt.js 2KB
settings.js 2KB
handleRoutes.js 2KB
accessToken.js 2KB
userManagement.js 2KB
routes.js 1KB
tree.js 1KB
static.js 1KB
index.js 1KB
roleManagement.js 1KB
goodsList.js 1001B
menuManagement.js 949B
validate.js 934B
support.js 867B
export.js 867B
net.config.js 815B
.eslintrc.js 726B
personalCenter.js 697B
user.js 673B
errorLog.js 651B
clipboard.js 628B
registrationManagement.js 609B
appointmentManagement.js 609B
plopfile.js 600B
errorLog.js 548B
index.js 513B
pharmaceuticalManagement.js 490B
main.js 486B
permission.js 444B
index.js 436B
patientManagement.js 429B
personalCenter.js 413B
userManagement.js 413B
roleManagement.js 413B
menuManagement.js 413B
github.js 412B
index.js 404B
index.js 404B
table.js 398B
table.js 386B
prettier.config.js 362B
ad.js 355B
doctorScheduleManagement.js 338B
prescriptionManagement.js 328B
theme.config.js 322B
departmentManagement.js 318B
doctorManagement.js 306B
adviceManagement.js 306B
chargesManagement.js 296B
notice.js 284B
index.js 269B
pageTitle.js 232B
settings.js 204B
element.js 189B
markdown.js 186B
vabMarkdownEditor.js 183B
colorfulIcon.js 165B
remixIcon.js 162B
router.js 160B
goodsList.js 158B
共 315 条
- 1
- 2
- 3
- 4
资源评论
onnx
- 粉丝: 9378
- 资源: 5588
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- js-leetcode题解之169-majority-element.js
- js-leetcode题解之168-excel-sheet-column-title.js
- js-leetcode题解之167-two-sum-II-input-array-is-sorted.js
- js-leetcode题解之166-fraction-to-recurring-decimal.js
- js-leetcode题解之165-compare-version-numbers.js
- js-leetcode题解之164-maximum-gap.js
- js-leetcode题解之163-missing-ranges.js
- js-leetcode题解之162-find-peak-element.js
- js-leetcode题解之161-one-edit-distance.js
- js-leetcode题解之160-intersection-of-two-linked-lists.js
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功