毕设无从下手?《口腔诊所系统》Python+Django开发教程帮你解决从设计到实现全过程

61 阅读5分钟

一、个人简介

💖💖作者:计算机编程果茶熊

💙💙个人简介:曾长期从事计算机专业培训教学,担任过编程老师,同时本人也热爱上课教学,擅长Java、微信小程序、Python、Golang、安卓Android等多个IT方向。会做一些项目定制化开发、代码讲解、答辩教学、文档编写、也懂一些降重方面的技巧。平常喜欢分享一些自己开发中遇到的问题的解决办法,也喜欢交流技术,大家有技术代码这一块的问题可以问我!

💛💛想说的话:感谢大家的关注与支持!

💕💕文末获取源码联系计算机编程果茶熊

二、系统介绍

开发语言:Java+Python

数据库:MySQL

系统架构:B/S

后端框架:SpringBoot(Spring+SpringMVC+Mybatis)+Django

前端:Vue+HTML+CSS+JavaScript+jQuery

《口腔诊所系统》是一款基于B/S架构的现代化牙科诊所管理平台,采用Java/Python双语言支持,分别基于Spring Boot(Spring+SpringMVC+Mybatis)和Django框架开发,前端使用Vue+ElementUI+HTML技术栈,数据库采用MySQL。系统功能全面,包括个人中心、患者管理、医生管理、牙科项目管理、坐诊医生管理、预约挂号管理、挂号取消管理、就诊记录管理、开药记录管理、药品类型管理、药品信息管理、医生评分管理以及系统管理等13个核心模块。该系统实现了口腔诊所日常运营的数字化管理,使医患信息、预约挂号、就诊记录和药品管理等业务流程更加规范高效,通过直观的界面展示和便捷的操作方式,大幅提升了诊所的管理效率和服务质量。系统架构清晰,代码结构合理,既满足了口腔诊所的实际业务需求,也体现了现代软件工程的设计理念,是计算机专业学生毕业设计的理想选择,能够全面锻炼和展示学生的软件开发综合能力。

三、口腔诊所系统-视频解说

毕设无从下手?《口腔诊所系统》Python+Django开发教程帮你解决从设计到实现全过程

四、口腔诊所系统-功能展示

后台管理员首页

后台管理员药品管理

前台个人中心

后台管理员预约账号管理

支付

后台医生账号首页

前台公告

前台首页

前台问诊医生信息

五、口腔诊所系统-代码展示



```
// 核心功能1: 预约挂号管理
@Service
public class AppointmentServiceImpl implements AppointmentService {
    
    @Autowired
    private AppointmentMapper appointmentMapper;
    
    @Autowired
    private DoctorScheduleMapper doctorScheduleMapper;
    
    @Autowired
    private PatientMapper patientMapper;
    
    @Override
    @Transactional
    public ResponseResult createAppointment(AppointmentDTO appointmentDTO) {
        // 验证患者信息是否存在
        Patient patient = patientMapper.selectById(appointmentDTO.getPatientId());
        if (patient == null) {
            return ResponseResult.error("患者信息不存在");
        }
        
        // 验证医生排班是否存在且可预约
        DoctorSchedule schedule = doctorScheduleMapper.selectById(appointmentDTO.getScheduleId());
        if (schedule == null) {
            return ResponseResult.error("医生排班信息不存在");
        }
        
        // 检查预约时间段是否已满
        int appointmentCount = appointmentMapper.countByScheduleIdAndTimeSlot(
                appointmentDTO.getScheduleId(), 
                appointmentDTO.getAppointmentTime());
        
        if (appointmentCount >= schedule.getMaxAppointments()) {
            return ResponseResult.error("该时间段预约已满,请选择其他时间");
        }
        
        // 检查患者是否已有同一天的预约
        List<Appointment> existingAppointments = appointmentMapper.findByPatientIdAndDate(
                appointmentDTO.getPatientId(),
                DateUtil.formatDate(appointmentDTO.getAppointmentTime()));
        
        if (!existingAppointments.isEmpty()) {
            return ResponseResult.error("您在同一天已有预约,请勿重复预约");
        }
        
        // 创建预约记录
        Appointment appointment = new Appointment();
        BeanUtils.copyProperties(appointmentDTO, appointment);
        appointment.setStatus(AppointmentStatusEnum.WAITING.getCode());
        appointment.setCreateTime(new Date());
        appointment.setAppointmentNumber(generateAppointmentNumber());
        
        appointmentMapper.insert(appointment);
        
        // 更新医生排班的已预约数量
        schedule.setBookedCount(schedule.getBookedCount() + 1);
        doctorScheduleMapper.updateById(schedule);
        
        return ResponseResult.success("预约成功", appointment);
    }
    
    // 生成预约编号
    private String generateAppointmentNumber() {
        return "APT" + System.currentTimeMillis() + RandomUtil.randomNumbers(4);
    }
}


// 核心功能2: 就诊记录管理
@Service
public class MedicalRecordServiceImpl implements MedicalRecordService {


    @Autowired
    private MedicalRecordMapper medicalRecordMapper;
    
    @Autowired
    private AppointmentMapper appointmentMapper;
    
    @Autowired
    private PatientMapper patientMapper;
    
    @Autowired
    private DentalProjectMapper dentalProjectMapper;
    
    @Override
    @Transactional
    public ResponseResult createMedicalRecord(MedicalRecordDTO recordDTO) {
        // 验证预约信息
        Appointment appointment = appointmentMapper.selectById(recordDTO.getAppointmentId());
        if (appointment == null) {
            return ResponseResult.error("预约信息不存在");
        }
        
        // 验证预约状态是否为已到诊
        if (!AppointmentStatusEnum.ARRIVED.getCode().equals(appointment.getStatus())) {
            return ResponseResult.error("患者未到诊,无法创建就诊记录");
        }
        
        // 验证患者信息
        Patient patient = patientMapper.selectById(appointment.getPatientId());
        if (patient == null) {
            return ResponseResult.error("患者信息不存在");
        }
        
        // 验证牙科项目
        if (recordDTO.getProjectIds() != null && !recordDTO.getProjectIds().isEmpty()) {
            List<DentalProject> projects = dentalProjectMapper.selectBatchIds(recordDTO.getProjectIds());
            if (projects.size() != recordDTO.getProjectIds().size()) {
                return ResponseResult.error("部分牙科项目不存在");
            }
        }
        
        // 创建就诊记录
        MedicalRecord medicalRecord = new MedicalRecord();
        BeanUtils.copyProperties(recordDTO, medicalRecord);
        medicalRecord.setRecordNumber(generateRecordNumber());
        medicalRecord.setPatientId(appointment.getPatientId());
        medicalRecord.setDoctorId(appointment.getDoctorId());
        medicalRecord.setDepartmentId(appointment.getDepartmentId());
        medicalRecord.setTreatmentDate(new Date());
        medicalRecord.setCreateTime(new Date());
        
        // 处理诊断结果和治疗方案
        medicalRecord.setDiagnosis(recordDTO.getDiagnosis());
        medicalRecord.setTreatmentPlan(recordDTO.getTreatmentPlan());
        
        // 处理牙位信息
        if (StringUtils.isNotEmpty(recordDTO.getToothPositions())) {
            medicalRecord.setToothPositions(recordDTO.getToothPositions());
        }
        
        // 保存就诊记录
        medicalRecordMapper.insert(medicalRecord);
        
        // 关联牙科项目
        if (recordDTO.getProjectIds() != null && !recordDTO.getProjectIds().isEmpty()) {
            for (Long projectId : recordDTO.getProjectIds()) {
                medicalRecordMapper.insertMedicalRecordProject(medicalRecord.getId(), projectId);
            }
        }
        
        // 更新预约状态为已完成
        appointment.setStatus(AppointmentStatusEnum.COMPLETED.getCode());
        appointmentMapper.updateById(appointment);
        
        // 更新患者最后就诊时间
        patient.setLastVisitTime(new Date());
        patientMapper.updateById(patient);
        
        return ResponseResult.success("就诊记录创建成功", medicalRecord);
    }
    
    // 生成就诊记录编号
    private String generateRecordNumber() {
        return "MR" + DateUtil.format(new Date(), "yyyyMMdd") + RandomUtil.randomNumbers(6);
    }
}


// 核心功能3: 药品信息管理
@Service
public class MedicineServiceImpl implements MedicineService {


    @Autowired
    private MedicineMapper medicineMapper;
    
    @Autowired
    private MedicineTypeMapper medicineTypeMapper;
    
    @Autowired
    private PrescriptionMapper prescriptionMapper;
    
    @Override
    @Transactional
    public ResponseResult addMedicine(MedicineDTO medicineDTO) {
        // 验证药品类型是否存在
        MedicineType medicineType = medicineTypeMapper.selectById(medicineDTO.getTypeId());
        if (medicineType == null) {
            return ResponseResult.error("药品类型不存在");
        }
        
        // 检查药品名称是否重复
        Medicine existingMedicine = medicineMapper.selectByName(medicineDTO.getName());
        if (existingMedicine != null) {
            return ResponseResult.error("药品名称已存在");
        }
        
        // 检查药品编码是否重复
        if (StringUtils.isNotEmpty(medicineDTO.getCode())) {
            Medicine medicineByCode = medicineMapper.selectByCode(medicineDTO.getCode());
            if (medicineByCode != null) {
                return ResponseResult.error("药品编码已存在");
            }
        }
        
        // 创建药品信息
        Medicine medicine = new Medicine();
        BeanUtils.copyProperties(medicineDTO, medicine);
        
        // 设置默认值
        if (medicine.getStatus() == null) {
            medicine.setStatus(1); // 默认启用状态
        }
        
        medicine.setCreateTime(new Date());
        
        // 生成药品编码(如果未提供)
        if (StringUtils.isEmpty(medicine.getCode())) {
            medicine.setCode(generateMedicineCode(medicineDTO.getTypeId()));
        }
        
        // 计算预警阈值(如果未提供)
        if (medicine.getWarnStock() == null && medicine.getTotalStock() != null) {
            medicine.setWarnStock(medicine.getTotalStock() / 5); // 默认为总库存的20%
        }
        
        // 保存药品信息
        medicineMapper.insert(medicine);
        
        // 记录库存变动日志
        MedicineStockLog stockLog = new MedicineStockLog();
        stockLog.setMedicineId(medicine.getId());
        stockLog.setOperationType(1); // 1-入库
        stockLog.setQuantity(medicine.getTotalStock());
        stockLog.setOperator(medicineDTO.getCreator());
        stockLog.setOperateTime(new Date());
        stockLog.setRemark("初始入库");
        
        medicineMapper.insertStockLog(stockLog);
        
        // 更新药品类型的药品数量
        medicineType.setMedicineCount(medicineType.getMedicineCount() + 1);
        medicineTypeMapper.updateById(medicineType);
        
        return ResponseResult.success("药品添加成功", medicine);
    }
    
    @Override
    @Transactional
    public ResponseResult updateMedicineStock(MedicineStockDTO stockDTO) {
        // 验证药品是否存在
        Medicine medicine = medicineMapper.selectById(stockDTO.getMedicineId());
        if (medicine == null) {
            return ResponseResult.error("药品不存在");
        }
        
        // 验证操作类型
        if (stockDTO.getOperationType() != 1 && stockDTO.getOperationType() != 2) {
            return ResponseResult.error("操作类型不正确,1-入库,2-出库");
        }
        
        // 验证数量
        if (stockDTO.getQuantity() <= 0) {
            return ResponseResult.error("操作数量必须大于0");
        }
        
        // 出库操作需要验证库存是否足够
        if (stockDTO.getOperationType() == 2) {
            if (medicine.getTotalStock() < stockDTO.getQuantity()) {
                return ResponseResult.error("库存不足,当前库存: " + medicine.getTotalStock());
            }
        }
        
        // 更新库存
        int newStock;
        if (stockDTO.getOperationType() == 1) {
            // 入库
            newStock = medicine.getTotalStock() + stockDTO.getQuantity();
        } else {
            // 出库
            newStock = medicine.getTotalStock() - stockDTO.getQuantity();
        }
        
        medicine.setTotalStock(newStock);
        medicine.setUpdateTime(new Date());
        medicineMapper.updateById(medicine);
        
        // 记录库存变动日志
        MedicineStockLog stockLog = new MedicineStockLog();
        stockLog.setMedicineId(medicine.getId());
        stockLog.setOperationType(stockDTO.getOperationType());
        stockLog.setQuantity(stockDTO.getQuantity());
        stockLog.setOperator(stockDTO.getOperator());
        stockLog.setOperateTime(new Date());
        stockLog.setRemark(stockDTO.getRemark());
        
        medicineMapper.insertStockLog(stockLog);
        
        // 检查是否需要发出库存预警
        if (medicine.getWarnStock() != null && medicine.getTotalStock() <= medicine.getWarnStock()) {
            // 发送库存预警通知
            sendStockWarningNotification(medicine);
        }
        
        return ResponseResult.success("库存更新成功", medicine);
    }
    
    // 生成药品编码
    private String generateMedicineCode(Long typeId) {
        MedicineType type = medicineTypeMapper.selectById(typeId);
        String typeCode = type != null ? type.getCode() : "MED";
        return typeCode + DateUtil.format(new Date(), "yyyyMMdd") + RandomUtil.randomNumbers(4);
    }
    
    // 发送库存预警通知
    private void sendStockWarningNotification(Medicine medicine) {
        // 实际项目中可以发送邮件、短信或系统内部消息
        log.warn("药品库存预警: 药品[{}], 编码[{}], 当前库存[{}], 预警阈值[{}]", 
                medicine.getName(), medicine.getCode(), 
                medicine.getTotalStock(), medicine.getWarnStock());
    }
}


```

六、口腔诊所系统-文档展示

七、END

💕💕文末获取源码联系计算机编程果茶熊