大家好,我是python222_小鋒老師,看到一個不錯的基于Python的Django醫院管理系統,分享下哈。
項目視頻演示
https://www.bilibili.com/video/BV1iPH8zmEut/
項目介紹
隨著人民生活水平日益增長,科技日益發達的今天,人們對身體健康的重視也越來越高。醫院的需求也隨之增加。中國有句古話稱“病從口入”,隨著生活水平的提高,人們在飲食方面也提出了更高的要求。然而,各種食品添加劑的使用使得人們的身體也出現了一些問題。因此,人們對醫院的需求迅速增長,而與之相應的是管理方面的挑戰。
為了提高醫院的經濟效益,使其在同行競爭中立于不敗之地,迫切需要一個科學的醫院信息管理系統來解決醫院面臨的各種困難。這個系統需要充分了解患者的基本情況,并集結眾多患者的管理經驗,融合先進的管理思想,同時考慮醫院的實際情況,將信息流作為主線,優化流程,為醫院管理層提供最佳的管理手段,幫助醫院實現資源充分共享,快捷簡便地查詢資源,全面提升醫院整體水平,從而增強醫院的競爭力[1]。因此,現代化醫院管理變得尤為重要。
系統展示
部分代碼
from django.contrib import admin# Register your models here.
from .models import *@admin.register(Department)
class DepartmentAdmin(admin.ModelAdmin):# 要顯示的字段list_display = ('id', 'name','doctor_name', 'create_time')# 需要搜索的字段search_fields = ('name',)# 分頁顯示,一頁的數量list_per_page = 10actions_on_top = True@admin.register(Doctor)
class DoctorAdmin(admin.ModelAdmin):#resource_class = ProxyResourcelist_display = ( 'name', 'gender', 'phone', 'stu_no','department', 'enable', 'create_time','idCard')# search_fields = ('name', 'enable', 'idCard', 'department')search_fields = ('name', 'phone')list_per_page = 20# raw_id_fields = ('department',)# list_filter = ('department', AgeListFilter, 'create_time')# list_filter = (AgeListFilter, 'department', 'create_time', 'birthday', 'time', 'enable', 'gender')list_display_links = ('name',)#fields = ('user_name', 'idCard', 'birthday') # 編輯界面只顯示No、Name和Age#exclude = ('pass_word','user_name') # 記得元祖需要在后面加個逗號,不然會報錯list_editable = ('department', 'phone', 'enable', 'gender','idCard','stu_no')date_hierarchy = 'create_time'@admin.register(House)
class HouseAdmin(admin.ModelAdmin):# 要顯示的字段list_display = ('no', 'name','level','amount', 'create_time')fields = ('no', 'name', 'level','amount' ) # 編輯界面只顯示No、Name和Age# 需要搜索的字段search_fields = ('no',)# 分頁顯示,一頁的數量list_per_page = 10actions_on_top = True# inlines = [# HealthLogInline,# MaintanceInline# ]import xlwt
from django.http import HttpResponse, JsonResponse
import datetime@admin.register(Medical)
class MedicalAdmin(admin.ModelAdmin):# 要顯示的字段list_display = ('id', 'name', 'price', 'qr_code', 'create_time', 'prescription')fields = ('name', 'qr_code', 'price', 'prescription') # 編輯界面只顯示No、Name和Ageactions = ['output']# 需要搜索的字段search_fields = ('name', 'qr_code', 'price', 'prescription')# 分頁顯示,一頁的數量list_per_page = 10actions_on_top = True# inlines = [# HealthLogInline,# MaintanceInline# ]def output(self, request, queryset):response = HttpResponse(content_type='application/vnd.ms-excel') # 指定返回格式為excel,excel文件MINETYPE為application/vnd.ms-excelresponse['Content-Disposition'] = 'attachment;filename=instorage.xls'wb = xlwt.Workbook(encoding='utf-8') # 創建一個工作簿sheet = wb.add_sheet('藥品單據') # 創建一個工作表# 創建一個居中對齊的樣式style = xlwt.XFStyle()alignment = xlwt.Alignment()alignment.horz = xlwt.Alignment.HORZ_CENTERstyle.alignment = alignmentfont = xlwt.Font()font.name = '宋體'font.bold = Truefont.height = 20 * 11 # 設置字體大小style.font = font# 將樣式應用于單元格sheet.write_merge(0, 0, 0, 5, '藥品單據', style)sheet.write(1, 0, 'id', style)sheet.write(1, 1, '名稱', style)sheet.write(1, 2, '描述', style)sheet.write(1, 3, '價格', style)sheet.write(1, 4, '數量', style)sheet.write(1, 5, '創建時間', style)data_row = 2for obj in queryset:# 創建一個居中對齊的樣式style = xlwt.XFStyle()alignment = xlwt.Alignment()alignment.horz = xlwt.Alignment.HORZ_CENTERstyle.alignment = alignmentsheet.write(data_row, 0, obj.id, style)sheet.write(data_row, 1, obj.name, style)sheet.write(data_row, 2, obj.prescription, style)sheet.write(data_row, 3, str(obj.price), style)sheet.write(data_row, 4, obj.qr_code, style)sheet.write(data_row, 5, obj.create_time.strftime('%Y-%m-%d'), style)data_row = data_row + 1wb.save(response)return responseoutput.short_description = '生成藥品單據'output.type = 'success'output.style = 'background-color: #00a65a; color: #fff; border-color: #008d4c;'@admin.register(Patient)
class PatientAdmin(admin.ModelAdmin):#resource_class = ProxyResourcelist_display = ( 'name', 'gender', 'phone', 'idCard','department', 'in_time','doctor_name', 'create_time','idCard')# search_fields = ('name', 'enable', 'idCard', 'department')search_fields = ('name', 'department__name')list_per_page = 20# raw_id_fields = ('department',)# list_filter = ('department', AgeListFilter, 'create_time')# list_filter = (AgeListFilter, 'department', 'create_time', 'birthday', 'time', 'enable', 'gender')list_display_links = ('name',)#fields = ('user_name', 'idCard', 'birthday') # 編輯界面只顯示No、Name和Age#exclude = ('pass_word','user_name') # 記得元祖需要在后面加個逗號,不然會報錯list_editable = ('department', 'phone', 'idCard', 'doctor_name', 'gender','idCard','in_time')date_hierarchy = 'create_time'
#!/usr/bin/env python
import os
import sysif __name__ == '__main__':os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'simpleui_demo.settings')try:from django.core.management import execute_from_command_lineexcept ImportError as exc:raise ImportError("Couldn't import Django. Are you sure it's installed and ""available on your PYTHONPATH environment variable? Did you ""forget to activate a virtual environment?") from excexecute_from_command_line(sys.argv)
源碼下載
鏈接:https://pan.baidu.com/s/167Mx6cYeKROqhKl2I2dLCQ
提取碼:1234