基于SpringBoot的中医诊疗平台的设计与实现(二)

简介: 基于SpringBoot的中医诊疗平台的设计与实现

基于SpringBoot的中医诊疗平台的设计与实现(一)https://developer.aliyun.com/article/1423382


四,核心代码展示

MeRecordServiceImpl 诊疗记录功能代码

package com.medicalsys.platform.service.impl;
import com.google.gson.Gson;
import com.medicalsys.platform.bean.MeRecord;
import com.medicalsys.platform.bean.User;
import com.medicalsys.platform.dao.MeRecordDao;
import com.medicalsys.platform.service.MeRecordService;
import com.medicalsys.platform.util.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpSession;
import javax.sound.midi.Soundbank;
import java.util.ArrayList;
import java.util.List;
/*
诊疗记录服务层
 */
@Service
public class MeRecordServiceImpl implements MeRecordService {
    @Autowired
    private MeRecordDao meRecordDao;
    @Autowired
    private PageUtil pageUtil;
    @Autowired
    private Gson gson;
    //检索记录
    @Override
    public String findAllMeRecord(String page, String limit, String name, String time) {
        int count=0;
        List<MeRecord> meRecordList=new ArrayList<>();
        //调用脚标算法
        Integer[] pageindex=pageUtil.pageindex(page, limit);
        //检索方式判断
        if((name==null || StringUtils.isEmpty(name)) && (time==null || StringUtils.isEmpty(time))){
            count=meRecordDao.meRecordCount();
            meRecordList=meRecordDao.findAllMeRecord(pageindex[0],pageindex[1]);
        }else{
            if(name!=null && !StringUtils.isEmpty(name)) name="%"+name+"%";
            else {name=new String(); name="%";}
            if(time!=null && !StringUtils.isEmpty(time)) time="%"+time.split("\\s+")[0]+"%";
            else {time=new String();time="%";}
            count=meRecordDao.meRecordSearchCount(name, time);
            meRecordList=meRecordDao.findAllSearch(pageindex[0],pageindex[1],name,time);
        }
        String meRecordjson = gson.toJson(meRecordList);
        return "{\n" +
                "  \"code\": 0,\n" +
                "  \"count\": " + String.valueOf(count) + ",\n" +
                "  \"data\": " +meRecordjson + "}";
    }
    //今日诊疗记录
    @Override
    public String findAllMeRecordID(String page, String limit, String name, String time, HttpSession session) {
        List<MeRecord> meRecordList=new ArrayList<>();
        //调用脚标算法
        Integer[] pageindex=pageUtil.pageindex(page, limit);
        //检索方式判断
        if((name==null || StringUtils.isEmpty(name)) && (time==null || StringUtils.isEmpty(time))){
            meRecordList=meRecordDao.findAllMeRecord(pageindex[0],pageindex[1]);
        }else{
            if(name!=null && !StringUtils.isEmpty(name)) name="%"+name+"%";
            else {name=new String(); name="%";}
            if(time!=null && !StringUtils.isEmpty(time)) time="%"+time.split("\\s+")[0]+"%";
            else {time=new String();time="%";}
            meRecordList=meRecordDao.findAllSearch(pageindex[0],pageindex[1],name,time);
        }
        User user = (User) session.getAttribute("user");
        List<MeRecord> meRecordListID=new ArrayList<>();
        //过滤其它医生记录
        for (MeRecord meRecord : meRecordList) {
            if(user.getId()==meRecord.getUserid()){
                meRecordListID.add(meRecord);
            }
        }
        String meRecordjson = gson.toJson(meRecordListID);
        return "{\n" +
                "  \"code\": 0,\n" +
                "  \"count\": " + String.valueOf(meRecordListID.size()) + ",\n" +
                "  \"data\": " +meRecordjson + "}";
    }
    //返回指定记录
    @Override
    public MeRecord findMeRecordById(String id) {
        return meRecordDao.findMeRecordById(Integer.valueOf(id));
    }
    //添加诊疗记录
    @Override
    public String addMeRecord(MeRecord meRecord,HttpSession session) {
        User user= (User) session.getAttribute("user");
        meRecord.setUserid(user.getId());
        int addflag=meRecordDao.addMeRecord(meRecord);
        if(addflag==1){
            return "{\n" +
                    "  \"code\": 200,\n" +
                    "  \"msg\": \"添加记录成功\",\n" +
                    "  \"data\": {\n" +
                    "  }\n" +
                    "}";
        }else {
            return "{\n" +
                    "  \"code\": 1,\n" +
                    "  \"msg\": \"添加失败\",\n" +
                    "  \"data\": {\n" +
                    "  }\n" +
                    "}";
        }
    }
    //更新诊疗记录
    @Override
    public String updateMeRecord(MeRecord meRecord) {
        int addflag=meRecordDao.updateMeRecord(meRecord);
        if(addflag==1){
            return "{\n" +
                    "  \"code\": 200,\n" +
                    "  \"msg\": \"更新记录成功\",\n" +
                    "  \"data\": {\n" +
                    "  }\n" +
                    "}";
        }else {
            return "{\n" +
                    "  \"code\": 1,\n" +
                    "  \"msg\": \"更新失败\",\n" +
                    "  \"data\": {\n" +
                    "  }\n" +
                    "}";
        }
    }
    //删除诊疗记录
    @Override
    public String deleteMeRecord(String[] idsStr) {
        int count=0;
        String notdelet="";
        int length=0;
        for (String s : idsStr) {
            if(StringUtils.isEmpty(s)==false&&s!=null){
                int deleteflag=meRecordDao.deleteMeRecord(Integer.valueOf(s));
                count=count+deleteflag;
                length++;
                if(deleteflag==0) notdelet=notdelet+s;
            }
        }
        if(count==length){
            return  "{\n" +
                    "  \"code\": 0,\n" +
                    "  \"msg\": \"删除成功\",\n" +
                    "  \"data\": {\n" +
                    "  }\n" +
                    "}";
        }else {
            return  "{\n" +
                    "  \"code\": 1,\n" +
                    "  \"msg\": \"删除"+notdelet+"失败\",\n" +
                    "  \"data\": {\n" +
                    "  }\n" +
                    "}";
        }
    }
}

FamRecordServiceImpl医案服务功能代码

package com.medicalsys.platform.service.impl;
import com.google.gson.Gson;
import com.medicalsys.platform.bean.FamRecord;
import com.medicalsys.platform.bean.MeRecord;
import com.medicalsys.platform.dao.FamRecordDao;
import com.medicalsys.platform.service.FamRecordService;
import com.medicalsys.platform.util.MdFileCompare;
import com.medicalsys.platform.util.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceUtils;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
/*
医案服务层
 */
@Service
public class FamRecordServiceImpl implements FamRecordService {
    @Autowired
    private FamRecordDao famRecordDao;
    @Autowired
    private PageUtil pageUtil;
    @Autowired
    private MdFileCompare mdFileCompare;
    @Autowired
    private Gson gson;
    //检索医案
    @Override
    public String findAllFamRecord(String page, String limit, String zdiagnosis, String dialetype) {
        int count=0;
        List<FamRecord> famRecordList=new ArrayList<>();
        //调用脚标算法
        Integer[] pageindex=pageUtil.pageindex(page, limit);
        //检索方式判断
        if((zdiagnosis==null || StringUtils.isEmpty(zdiagnosis)) && (dialetype==null || StringUtils.isEmpty(dialetype))){
            count=famRecordDao.famRecordCount();
            famRecordList=famRecordDao.findAllFamRecord(pageindex[0],pageindex[1]);
        }else{
            if(zdiagnosis!=null && !StringUtils.isEmpty(zdiagnosis)) zdiagnosis="%"+zdiagnosis+"%";
            else {zdiagnosis=new String(); zdiagnosis="%";}
            if(dialetype!=null && !StringUtils.isEmpty(dialetype)) dialetype="%"+dialetype+"%";
            else {dialetype=new String();dialetype="%";}
            count=famRecordDao.famRecordSearchCount(zdiagnosis,dialetype);
            famRecordList=famRecordDao.findAllSearch(pageindex[0],pageindex[1],zdiagnosis,dialetype);
        }
        String famRecordjson = gson.toJson(famRecordList);
        return "{\n" +
                "  \"code\": 0,\n" +
                "  \"count\": " + String.valueOf(count) + ",\n" +
                "  \"data\": " +famRecordjson + "}";
    }
    @Override
    public FamRecord findFamRecordById(String id) {
        return famRecordDao.findFamRecordById(Integer.valueOf(id));
    }
    //添加医案
    @Override
    public String addFamRecord(FamRecord famRecord) {
        int addflag=famRecordDao.addFamRecord(famRecord);
        if(addflag==1){
           return "{\n" +
                "  \"code\": 200,\n" +
                "  \"msg\": \"添加医案成功\",\n" +
                "  \"data\": {\n" +
                "  }\n" +
                "}";
        }else {
            return "{\n" +
                    "  \"code\": 1,\n" +
                    "  \"msg\": \"添加医案失败\",\n" +
                    "  \"data\": {\n" +
                    "  }\n" +
                    "}";
        }
    }
    //更新医案
    @Override
    public String updateFamRecord(FamRecord famRecord) {
        int addflag=famRecordDao.updateFamRecord(famRecord);
        if(addflag==1){
            return "{\n" +
                    "  \"code\": 200,\n" +
                    "  \"msg\": \"更新医案成功\",\n" +
                    "  \"data\": {\n" +
                    "  }\n" +
                    "}";
        }else {
            return "{\n" +
                    "  \"code\": 1,\n" +
                    "  \"msg\": \"更新失败\",\n" +
                    "  \"data\": {\n" +
                    "  }\n" +
                    "}";
        }
    }
    //删除医案
    @Override
    public String deleteFamRecord(String[] idsStr) {
        int count=0;
        String notdelet="";
        int length=0;
        for (String s : idsStr) {
            if(StringUtils.isEmpty(s)==false&&s!=null){
                int deleteflag=famRecordDao.deleteFamRecord(Integer.valueOf(s));
                count=count+deleteflag;
                length++;
                if(deleteflag==0) notdelet=notdelet+s;
            }
        }
        if(count==length){
            return  "{\n" +
                    "  \"code\": 0,\n" +
                    "  \"msg\": \"删除成功\",\n" +
                    "  \"data\": {\n" +
                    "  }\n" +
                    "}";
        }else {
            return  "{\n" +
                    "  \"code\": 1,\n" +
                    "  \"msg\": \"删除"+notdelet+"失败\",\n" +
                    "  \"data\": {\n" +
                    "  }\n" +
                    "}";
        }
    }
    //处方比对
    @Override
    public FamRecord findCompare(String zdiagnosis, String dialetype, String drugs, String page, Model model) {
        int count=0;
        List<FamRecord> famRecordList=new ArrayList<>();
        //调用脚标算法
        Integer[] pageindex=pageUtil.pageindex(page, "1");
        //检索方式判断
        if((zdiagnosis==null || StringUtils.isEmpty(zdiagnosis)) && (dialetype==null || StringUtils.isEmpty(dialetype))){
            count=famRecordDao.famRecordCount();
            famRecordList=famRecordDao.findAllFamRecord(pageindex[0],pageindex[1]);
        }else{
            if(zdiagnosis!=null && !StringUtils.isEmpty(zdiagnosis)) zdiagnosis="%"+zdiagnosis+"%";
            else {zdiagnosis=new String(); zdiagnosis="%";}
            if(dialetype!=null && !StringUtils.isEmpty(dialetype)) dialetype="%"+dialetype+"%";
            else {dialetype=new String();dialetype="%";}
            count=famRecordDao.famRecordSearchCount(zdiagnosis,dialetype);
            famRecordList=famRecordDao.findAllSearch(pageindex[0],pageindex[1],zdiagnosis,dialetype);
        }
        //处方比对
        if(famRecordList.size()==0){
            model.addAttribute("countnum", "0");
            model.addAttribute("pagenum", "0");
            model.addAttribute("drugs", drugs);
           return null;
        }else {
            String[] strings=mdFileCompare.compare(famRecordList.get(0), drugs);
            famRecordList.get(0).setDrugs(strings[0]);
            model.addAttribute("countnum", count);
            model.addAttribute("pagenum", pageindex[0]+1);
            model.addAttribute("drugs", strings[1]);
            return famRecordList.get(0);
        }
    }
}

五,项目总结

相关文章
|
3月前
|
SQL 安全 前端开发
毕设答辩问题讲解说明:基于SpringBoot+Vue的汉服文化交流社区平台设计与开发
这篇文章是关于一个基于SpringBoot+Vue的汉服文化交流社区平台的毕业设计答辩问题讲解,涵盖了系统功能、亮点创新、数据库设计、积分领取机制、数据库安全和个人密码修改功能等方面的答辩问题和回答要点。
|
3月前
|
JavaScript Java Maven
毕设项目&课程设计&毕设项目:springboot+vue实现的在线求职管理平台(含教程&源码&数据库数据)
本文介绍了一款基于Spring Boot和Vue.js实现的在线求职平台。该平台采用了前后端分离的架构,使用Spring Boot作为后端服务
毕设项目&课程设计&毕设项目:springboot+vue实现的在线求职管理平台(含教程&源码&数据库数据)
|
3月前
|
监控 Java Serverless
美团 Flink 大作业部署问题之想在Serverless平台上实时查看Spring Boot应用的日志要怎么操作
美团 Flink 大作业部署问题之想在Serverless平台上实时查看Spring Boot应用的日志要怎么操作
|
4月前
|
JavaScript Java 测试技术
基于SpringBoot+Vue+uniapp的在线招聘平台的详细设计和实现(源码+lw+部署文档+讲解等)
基于SpringBoot+Vue+uniapp的在线招聘平台的详细设计和实现(源码+lw+部署文档+讲解等)
|
4月前
|
JavaScript Java 测试技术
基于SpringBoot+Vue+uniapp的大学生国学自主学习平台的详细设计和实现(源码+lw+部署文档+讲解等)
基于SpringBoot+Vue+uniapp的大学生国学自主学习平台的详细设计和实现(源码+lw+部署文档+讲解等)
|
4月前
|
JavaScript Java 测试技术
基于SpringBoot+Vue的洛川县苹果销售管理平台的详细设计和实现(源码+lw+部署文档+讲解等)
基于SpringBoot+Vue的洛川县苹果销售管理平台的详细设计和实现(源码+lw+部署文档+讲解等)
44 0
|
4月前
|
JavaScript Java 测试技术
基于SpringBoot+Vue的求职招聘平台的详细设计和实现(源码+lw+部署文档+讲解等)
基于SpringBoot+Vue的求职招聘平台的详细设计和实现(源码+lw+部署文档+讲解等)
62 0
|
4月前
|
JavaScript Java 测试技术
基于SpringBoot+Vue+uniapp的中医学习服务管理系统的详细设计和实现(源码+lw+部署文档+讲解等)
基于SpringBoot+Vue+uniapp的中医学习服务管理系统的详细设计和实现(源码+lw+部署文档+讲解等)
|
4月前
|
JavaScript Java 测试技术
基于SpringBoot+Vue+uniapp的租房平台的详细设计和实现(源码+lw+部署文档+讲解等)
基于SpringBoot+Vue+uniapp的租房平台的详细设计和实现(源码+lw+部署文档+讲解等)