前言
- 💖💖作者:计算机程序员小杨
- 💙💙个人简介:我是一名计算机相关专业的从业者,擅长Java、微信小程序、Python、Golang、安卓Android等多个IT方向。会做一些项目定制化开发、代码讲解、答辩教学、文档编写、也懂一些降重方面的技巧。热爱技术,喜欢钻研新工具和框架,也乐于通过代码解决实际问题,大家有技术代码这一块的问题可以问我!
- 💛💛想说的话:感谢大家的关注与支持!
- 💕💕文末获取源码联系 计算机程序员小杨
- 💜💜
- 网站实战项目
- 安卓/小程序实战项目
- 大数据实战项目
- 深度学习实战项目
- 计算机毕业设计选题
- 💜💜
一.开发工具简介
- 开发语言:Java
- 后端框架:Spring Boot(Spring+SpringMVC+Mybatis)
- 前端:Vue
- 数据库:MySQL
- 系统架构:B/S
- 开发工具:IDEA
二.系统内容简介
《医院患者就诊数据可视化分析系统》是一款基于Java语言开发的医院信息化管理平台,采用Spring Boot框架构建后端服务体系,结合Vue前端技术实现用户交互界面,通过MySQL数据库存储医疗数据信息。该系统遵循B/S架构模式,为医院提供全面的患者就诊流程管理和数据分析服务。系统涵盖患者基础信息管理、医生资源配置、预约挂号流程控制、诊断治疗记录跟踪、药品库存管理、处方开具管理、费用结算处理等核心业务模块,同时具备数据可视化分析能力,能够对医院运营数据进行统计分析和图表展示。通过集成化的管理方式,系统实现了从患者入院到出院全流程的数字化管控,提升医院工作效率,优化患者就医体验,为医院管理层提供决策支持数据,推动医院信息化建设向智能化方向发展。
三.系统功能演示
四.系统界面展示
五.系统源码展示
import org.apache.spark.sql.SparkSession;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
@Service
public class PatientManagementService {
@Autowired
private PatientMapper patientMapper;
private SparkSession spark = SparkSession.builder().appName("HospitalDataAnalysis").master("local").getOrCreate();
public Result addPatient(Patient patient) {
if (patient.getName() == null || patient.getName().trim().isEmpty()) {
return Result.error("患者姓名不能为空");
}
if (patient.getPhone() == null || !patient.getPhone().matches("^1[3-9]\\d{9}$")) {
return Result.error("手机号格式不正确");
}
if (patient.getIdCard() == null || !patient.getIdCard().matches("^[1-9]\\d{17}$")) {
return Result.error("身份证号格式不正确");
}
Patient existPatient = patientMapper.findByIdCard(patient.getIdCard());
if (existPatient != null) {
return Result.error("该身份证号已注册");
}
patient.setCreateTime(new Date());
patient.setStatus(1);
patient.setPatientNo(generatePatientNo());
patientMapper.insert(patient);
Dataset<Row> patientData = spark.read().format("jdbc").option("url", "jdbc:mysql://localhost:3306/hospital").option("dbtable", "patient").option("user", "root").option("password", "123456").load();
long totalPatients = patientData.count();
return Result.success("患者添加成功,当前患者总数:" + totalPatients);
}
public Result updatePatientInfo(Patient patient) {
if (patient.getId() == null) {
return Result.error("患者ID不能为空");
}
Patient existPatient = patientMapper.findById(patient.getId());
if (existPatient == null) {
return Result.error("患者信息不存在");
}
if (patient.getPhone() != null && !patient.getPhone().matches("^1[3-9]\\d{9}$")) {
return Result.error("手机号格式不正确");
}
patient.setUpdateTime(new Date());
patientMapper.updateById(patient);
return Result.success("患者信息更新成功");
}
private String generatePatientNo() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
String dateStr = sdf.format(new Date());
String sequence = String.format("%04d", new Random().nextInt(9999));
return "P" + dateStr + sequence;
}
}
@Service
public class AppointmentService {
@Autowired
private AppointmentMapper appointmentMapper;
@Autowired
private DoctorMapper doctorMapper;
private SparkSession spark = SparkSession.builder().appName("AppointmentAnalysis").master("local").getOrCreate();
public Result createAppointment(Appointment appointment) {
if (appointment.getPatientId() == null) {
return Result.error("患者ID不能为空");
}
if (appointment.getDoctorId() == null) {
return Result.error("医生ID不能为空");
}
if (appointment.getAppointmentDate() == null) {
return Result.error("预约日期不能为空");
}
if (appointment.getAppointmentDate().before(new Date())) {
return Result.error("预约日期不能早于当前日期");
}
Doctor doctor = doctorMapper.findById(appointment.getDoctorId());
if (doctor == null || doctor.getStatus() != 1) {
return Result.error("医生信息无效或不可用");
}
List<Appointment> existAppointments = appointmentMapper.findByDoctorAndDate(appointment.getDoctorId(), appointment.getAppointmentDate(), appointment.getTimeSlot());
if (existAppointments.size() >= doctor.getMaxAppointments()) {
return Result.error("该时段预约已满");
}
appointment.setCreateTime(new Date());
appointment.setStatus(0);
appointment.setAppointmentNo(generateAppointmentNo());
appointmentMapper.insert(appointment);
Dataset<Row> appointmentData = spark.read().format("jdbc").option("url", "jdbc:mysql://localhost:3306/hospital").option("dbtable", "appointment").option("user", "root").option("password", "123456").load();
Dataset<Row> todayAppointments = appointmentData.filter("appointment_date = current_date()");
long todayCount = todayAppointments.count();
return Result.success("预约成功,预约号:" + appointment.getAppointmentNo() + ",今日预约总数:" + todayCount);
}
public Result cancelAppointment(Long appointmentId, String reason) {
if (appointmentId == null) {
return Result.error("预约ID不能为空");
}
Appointment appointment = appointmentMapper.findById(appointmentId);
if (appointment == null) {
return Result.error("预约信息不存在");
}
if (appointment.getStatus() == 2) {
return Result.error("预约已取消,无法重复取消");
}
if (appointment.getStatus() == 1) {
return Result.error("预约已完成,无法取消");
}
long hoursDiff = (appointment.getAppointmentDate().getTime() - System.currentTimeMillis()) / (1000 * 60 * 60);
if (hoursDiff < 2) {
return Result.error("距离预约时间不足2小时,无法取消");
}
appointment.setStatus(2);
appointment.setCancelReason(reason);
appointment.setCancelTime(new Date());
appointmentMapper.updateById(appointment);
return Result.success("预约取消成功");
}
private String generateAppointmentNo() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String timeStr = sdf.format(new Date());
return "A" + timeStr + String.format("%03d", new Random().nextInt(999));
}
}
@Service
public class PrescriptionService {
@Autowired
private PrescriptionMapper prescriptionMapper;
@Autowired
private DrugMapper drugMapper;
private SparkSession spark = SparkSession.builder().appName("PrescriptionAnalysis").master("local").getOrCreate();
public Result createPrescription(Prescription prescription) {
if (prescription.getPatientId() == null) {
return Result.error("患者ID不能为空");
}
if (prescription.getDoctorId() == null) {
return Result.error("医生ID不能为空");
}
if (prescription.getDrugList() == null || prescription.getDrugList().isEmpty()) {
return Result.error("处方药品信息不能为空");
}
BigDecimal totalAmount = BigDecimal.ZERO;
for (PrescriptionDrug drug : prescription.getDrugList()) {
if (drug.getDrugId() == null || drug.getQuantity() <= 0) {
return Result.error("药品信息或数量无效");
}
Drug drugInfo = drugMapper.findById(drug.getDrugId());
if (drugInfo == null || drugInfo.getStock() < drug.getQuantity()) {
return Result.error("药品库存不足:" + (drugInfo != null ? drugInfo.getName() : "未知药品"));
}
BigDecimal drugAmount = drugInfo.getPrice().multiply(new BigDecimal(drug.getQuantity()));
totalAmount = totalAmount.add(drugAmount);
drug.setPrice(drugInfo.getPrice());
drug.setAmount(drugAmount);
}
prescription.setTotalAmount(totalAmount);
prescription.setCreateTime(new Date());
prescription.setStatus(0);
prescription.setPrescriptionNo(generatePrescriptionNo());
prescriptionMapper.insert(prescription);
for (PrescriptionDrug drug : prescription.getDrugList()) {
drug.setPrescriptionId(prescription.getId());
prescriptionMapper.insertPrescriptionDrug(drug);
}
Dataset<Row> prescriptionData = spark.read().format("jdbc").option("url", "jdbc:mysql://localhost:3306/hospital").option("dbtable", "prescription").option("user", "root").option("password", "123456").load();
Dataset<Row> monthlyPrescriptions = prescriptionData.filter("create_time >= date_sub(current_date(), 30)");
long monthlyCount = monthlyPrescriptions.count();
return Result.success("处方开具成功,处方号:" + prescription.getPrescriptionNo() + ",本月处方总数:" + monthlyCount);
}
public Result dispensePrescription(Long prescriptionId) {
if (prescriptionId == null) {
return Result.error("处方ID不能为空");
}
Prescription prescription = prescriptionMapper.findById(prescriptionId);
if (prescription == null) {
return Result.error("处方信息不存在");
}
if (prescription.getStatus() != 1) {
return Result.error("处方状态异常,无法发药");
}
List<PrescriptionDrug> drugList = prescriptionMapper.findDrugsByPrescriptionId(prescriptionId);
for (PrescriptionDrug prescriptionDrug : drugList) {
Drug drug = drugMapper.findById(prescriptionDrug.getDrugId());
if (drug.getStock() < prescriptionDrug.getQuantity()) {
return Result.error("药品库存不足:" + drug.getName());
}
drug.setStock(drug.getStock() - prescriptionDrug.getQuantity());
drugMapper.updateStock(drug.getId(), drug.getStock());
}
prescription.setStatus(2);
prescription.setDispenseTime(new Date());
prescriptionMapper.updateById(prescription);
return Result.success("发药成功");
}
private String generatePrescriptionNo() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
String dateStr = sdf.format(new Date());
String sequence = String.format("%06d", new Random().nextInt(999999));
return "R" + dateStr + sequence;
}
}
六.系统文档展示
结束
💕💕文末获取源码联系 计算机程序员小杨