Procházet zdrojové kódy

Merge branch 'dev' of zd_123/patient-co-management into dev

trick9191 před 7 roky
rodič
revize
83f6cfd89d

+ 43 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/common/dao/DoctorDao.java

@ -0,0 +1,43 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.hos.device.common.dao;
import com.yihu.hos.device.model.Doctor;
import com.yihu.hos.device.model.Patient;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface DoctorDao extends PagingAndSortingRepository<Doctor, Long> {
    Doctor findByName(String name);
    // 按医生标识查询医生信息
    @Query("select p from Doctor p where p.code = ?1")
    Doctor findByCode(String code);
    Doctor findByCodeAndDel(String code, Integer del);
    @Query("select d from Doctor d where d.del = 1")
    List<Doctor> findAllDoctors();
    @Query("select d from Doctor d where d.del = 1 and d.name like ?1")
    List<Doctor> findDoctorsByName(String name);
    @Query("select d from Doctor d where d.del = 1 and d.hospital = ?1")
    Iterable<Doctor> findHospitalDoctors(String hospital);
    // 手机号查询医生信息
    @Query("select p from Doctor p where p.mobile = ?1 and p.status = 1")
    Doctor findByMobile(String mobile);
}

+ 6 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/common/dao/MessageDao.java

@ -13,6 +13,8 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface MessageDao extends PagingAndSortingRepository<Message, Long>, JpaSpecificationExecutor<Message> {
    @Query("select count(a) from Message a where a.type =1 and a.read= 1 and a.receiver=?1 ")
@ -42,4 +44,8 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @Query("select count(a) from Message a where a.read = 0 and over ='0'  and a.receiver=?1 and a.type=?2 ")
    int findMessageNum(String doctor, Integer type);
    //查询医生下的签约居民未读体征异常消息
    @Query("SELECT a FROM Message a WHERE a.sender=?1 AND a.receiver = ?2 AND a.type = 2 and a.del = '1' and a.read=1 ORDER BY czrq DESC")
    List<Message> findUnreadHealthIndex(String sender, String receiver);
}

+ 463 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/model/Doctor.java

@ -0,0 +1,463 @@
package com.yihu.hos.device.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;
/**
 * 医生信息
 *
 * @author George
 */
@Entity
@Table(name = "wlyy_doctor",schema="wlyy",catalog="wlyy")
public class Doctor extends IdEntity implements Serializable {
    private static final long serialVersionUID = -6585552029939285364L;
    private String code;        // 业务主键
    private String name;        //姓名
    private Integer sex;        // 性别(1男,2女)
    private Date birthday;      //生日
    private String photo;       //头像http地址
    private String mobile;      //手机号
    private String password;    //密码
    private String salt;        // 密码标识
    private Integer status;     // 状态(1正常,0禁用)
    private String province;    //省code
    private String city;         //市code
    private String town;         //区县code
    private String provinceName;//省名称
    private String cityName;    //市名称
    private String townName;    //区县名称
    private String hospital;        // 医院代码
    private String hospitalName;    //医院名称
    private String dept;            // 科室代码
    private String deptName;        //可是名称
    private String job;             // 职称代码
    private String jobName;         // 职称名
    private String expertise;       // 医生专长
    private String introduce;       // 医生介绍
    private Integer level;          // 类型:1专科医生,2全科医生,3健康管理师
    private Integer iscertified;   // 资格是否认证通过,1是,0否
    private String qrcode;          // 二维码
    private Date czrq;              // 更新时间
    private Integer del;            // 状态(1正常,0删除)
    private String idcard;          //身份证号
    private Integer isFamous;       //是否是名医 1是  0或者空不是
    private String isPasswordPrompt;// 是否提示密码信息 1是 0或者空是否
    private String isHelp;          //是否求助  1已经求助 0未求助
    private Double evaluateScore;//评分
    private String checkPassword;   //审方密码
    private String checkSalt;       //审方密码的盐
    private Date certifiedOvertime; //CA证书过期时间
    private String certificateNum;     //CA证书编号
    private String openid; //医生微信openID
    //=====================非hibernate字段=========================
    private String concernCode;//关注code
    private String activityPath;//活动路径
    public Double getEvaluateScore() {
        return evaluateScore;
    }
    public void setEvaluateScore(Double evaluateScore) {
        this.evaluateScore = evaluateScore;
    }
    public Doctor() {
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public Doctor(Long id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Integer getSex() {
        return sex;
    }
    public void setSex(Integer sex) {
        this.sex = sex;
    }
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
    public Date getBirthday() {
        return birthday;
    }
    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }
    public String getPhoto() {
        return photo;
    }
    public void setPhoto(String photo) {
        this.photo = photo;
    }
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getSalt() {
        return salt;
    }
    public void setSalt(String salt) {
        this.salt = salt;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getProvince() {
        return province;
    }
    public void setProvince(String province) {
        this.province = province;
    }
    public String getCity() {
        return city;
    }
    public void setCity(String city) {
        this.city = city;
    }
    public String getTown() {
        return town;
    }
    public void setTown(String town) {
        this.town = town;
    }
    @Column(name = "province_name")
    public String getProvinceName() {
        return provinceName;
    }
    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }
    @Column(name = "city_name")
    public String getCityName() {
        return cityName;
    }
    public void setCityName(String cityName) {
        this.cityName = cityName;
    }
    @Column(name = "town_name")
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    @Column(name = "dept_name")
    public String getDeptName() {
        return deptName;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
    @Column(name = "job_name")
    public String getJobName() {
        return jobName;
    }
    public void setJobName(String jobName) {
        this.jobName = jobName;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getDept() {
        return dept;
    }
    public void setDept(String dept) {
        this.dept = dept;
    }
    public String getJob() {
        return job;
    }
    public void setJob(String job) {
        this.job = job;
    }
    public String getExpertise() {
        return expertise;
    }
    public void setExpertise(String expertise) {
        this.expertise = expertise;
    }
    public String getIntroduce() {
        return introduce;
    }
    public void setIntroduce(String introduce) {
        this.introduce = introduce;
    }
    public Integer getLevel() {
        return level;
    }
    public void setLevel(Integer level) {
        this.level = level;
    }
    @Column(name = "iscertified")
    public Integer getIscertified() {
        return iscertified;
    }
    public void setIscertified(Integer isCertified) {
        this.iscertified = isCertified;
    }
    public String getQrcode() {
        return qrcode;
    }
    public void setQrcode(String qrcode) {
        this.qrcode = qrcode;
    }
    // 设定JSON序列化时的日期格式
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
    @Column(name = "del")
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    @Column(name = "is_famous")
    public Integer getIsFamous() {
        return isFamous;
    }
    public void setIsFamous(Integer isFamous) {
        this.isFamous = isFamous;
    }
    /**
     * 是否为专科医生。
     *
     * @return
     */
    @Transient
    public boolean isProfessionalDoctor() {
        if (level != null && level == 1) {
            return true;
        } else {
            return false;
        }
    }
    /**
     * 是否为全科医生。
     *
     * @return
     */
    @Transient
    public boolean isGeneralDoctor() {
        if (level != null && level == 2) {
            return true;
        } else {
            return false;
        }
    }
    /**
     * 是否为健康管理师。
     *
     * @return
     */
    @Transient
    public boolean isHealthDoctor() {
        if (level != null && level == 3) {
            return true;
        } else {
            return false;
        }
    }
    @Transient
    public String getIsHelp() {
        return isHelp;
    }
    public void setIsHelp(String isHelp) {
        this.isHelp = isHelp;
    }
    @Column(name = "is_password_prompt")
    public String getIsPasswordPrompt() {
        return isPasswordPrompt;
    }
    public void setIsPasswordPrompt(String isPasswordPrompt) {
        this.isPasswordPrompt = isPasswordPrompt;
    }
    public String getCheckPassword() {
        return checkPassword;
    }
    public void setCheckPassword(String checkPassword) {
        this.checkPassword = checkPassword;
    }
    public String getCheckSalt() {
        return checkSalt;
    }
    public void setCheckSalt(String checkSalt) {
        this.checkSalt = checkSalt;
    }
    public Date getCertifiedOvertime() {
        return certifiedOvertime;
    }
    public void setCertifiedOvertime(Date certifiedOvertime) {
        this.certifiedOvertime = certifiedOvertime;
    }
    public String getCertificateNum() {
        return certificateNum;
    }
    public void setCertificateNum(String certificateNum) {
        this.certificateNum = certificateNum;
    }
    public String getOpenid() {
        return openid;
    }
    public void setOpenid(String openid) {
        this.openid = openid;
    }
    @Transient
    public String getConcernCode() {
        return concernCode;
    }
    public void setConcernCode(String concernCode) {
        this.concernCode = concernCode;
    }
    public static long getSerialVersionUID() {
        return serialVersionUID;
    }
    public String getActivityPath() {
        return activityPath;
    }
    public void setActivityPath(String activityPath) {
        this.activityPath = activityPath;
    }
}

+ 49 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/AsyncService.java

@ -27,6 +27,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -44,6 +45,7 @@ public class AsyncService extends BaseService{
    private SignFamilyDao signFamilyDao;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Value("${systemConfig.server_url}")
    private String wlyyService;
    @Autowired
@ -78,6 +80,14 @@ public class AsyncService extends BaseService{
    private MessageDao messageDao;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private DoctorDao doctorDao;
    @Value("${doctorAssistant.api}")
    private String doctorAssistant;
    @Value("${doctorAssistant.target_url}")
    private String targetUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    /**
     * 校验指标是否超标,发送消息
@ -223,6 +233,7 @@ public class AsyncService extends BaseService{
    private void sendMessage(String content, Patient patient, PatientHealthIndex model) {
        logger.info("======start sendMessage======");
        String patientCode = patient.getCode();
        String patientName = patient.getName();
        // 消息接收者
        List<String> receivers = new ArrayList<String>();
        // 查询病人家庭签约的健康管理师
@ -230,6 +241,8 @@ public class AsyncService extends BaseService{
        logger.info("签约对象--全科医生code===="+signFamily.getDoctor());
        String healthDoctorFamily = "";
        String doctorFamily = "";
        String doctorName = "";
        String doctorOpenID = "";
        if (signFamily != null) {
            healthDoctorFamily = signFamily.getDoctorHealth();
            doctorFamily = signFamily.getDoctor();
@ -237,10 +250,16 @@ public class AsyncService extends BaseService{
            if (StringUtils.isNotEmpty(healthDoctorFamily)) {
                // 添加到消息接收人列表
                receivers.add(healthDoctorFamily);
                Doctor doctor = doctorDao.findByCode(healthDoctorFamily);
                doctorName = doctor.getName();
                doctorOpenID = doctor.getOpenid();
            }
            if (StringUtils.isNotEmpty(doctorFamily)){
                // 添加到消息接收人列表
                receivers.add(doctorFamily);
                Doctor doctor = doctorDao.findByCode(signFamily.getDoctor());
                doctorName = doctor.getName();
                doctorOpenID = doctor.getOpenid();
            }
        }
        // 查询病人三师签约中的健康管理师
@ -286,6 +305,9 @@ public class AsyncService extends BaseService{
            if(messageService.getMessageNoticeSettingByMessageType(receiver,"1",MessageNoticeSetting.MessageTypeEnum.healthSignSwitch.getValue())){
                // 异常通知
                if (receiver.equals(doctorFamily)){
                    logger.info("全科添加发送消息");
                }
                JSONObject json = new JSONObject();
                json.put("receiver", receiver);
                json.put("type", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.D_HI_01.name());
@ -298,6 +320,33 @@ public class AsyncService extends BaseService{
        // 批量保存消息
        logger.info("消息数量---"+messages.size());
        messageDao.save(messages);
        for (String receiver : receivers) {
            if (StringUtils.isEmpty(receiver)) {
                continue;
            }
            if(messageService.getMessageNoticeSettingByMessageType(receiver,"1", MessageNoticeSetting.MessageTypeEnum.healthSignSwitch.getValue())){
                //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                if (StringUtils.isNotEmpty(doctorOpenID)) {
                    List<Message> messagesList = messageDao.findUnreadHealthIndex(patientCode, receiver);
                    if (messagesList != null && messagesList.size()>0){
                        String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                        List<NameValuePair> params = new ArrayList<>();
                        params.add(new BasicNameValuePair("type", "3"));
                        params.add(new BasicNameValuePair("openId", doctorOpenID));
                        params.add(new BasicNameValuePair("url", targetUrl));
                        params.add(new BasicNameValuePair("first", doctorName + "医生,您的签约居民" + patientName +
                                "有" + messagesList.size() + "条未读的体征异常消息"));
                        params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                        SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                        String date = format.format(new Date());
                        String keywords = date + "," + patientName;
                        params.add(new BasicNameValuePair("keywords", keywords));
                        httpClientUtil.post(url, params, "UTF-8");
                    }
                }
            }
        }
        // 推送消息给医生
        pushMsgTask.put(array);
    }

+ 13 - 1
patient-co-service/wlyy_device/src/main/resources/application.yml

@ -61,6 +61,10 @@ systemConfig:
  socket_server: http://192.168.131.102:3008
  server_url: http://192.168.131.24:8080/
# Specify the DBMS
#医生助手服务器地址及模板跳转链接(医生未读消息统计页)
doctorAssistant:
  api: http://ehr.yihu.com/wlyy/
  target_url: home/html/unreadMessageStatistic.html
---
spring:
@ -99,6 +103,10 @@ systemConfig:
  jw_server: http://172.19.103.88:8011/wlyy_service-1.0-SNAPSHOT
  socket_server: http://172.19.103.88:3000
  server_url: http://ehr.yihu.com/wlyy/
#医生助手服务器地址及模板跳转链接(医生未读消息统计页)
doctorAssistant:
  api: http://ehr.yihu.com/wlyy/
  target_url: home/html/unreadMessageStatistic.html
---
spring:
  profiles: production
@ -134,4 +142,8 @@ systemConfig:
  msg_push_server: http://127.0.0.1:3000/system/sendmsg.im
  jw_server: http://59.61.92.90:8072/wlyy_service
  socket_server: http://27.155.101.77:3000
  server_url: http://www.xmtyw.cn/wlyy/
  server_url: http://www.xmtyw.cn/wlyy/
#医生助手服务器地址及模板跳转链接(医生未读消息统计页)
doctorAssistant:
  api: http://www.xmtyw.cn/assistant/
  target_url: home/html/unreadMessageStatistic.html

+ 8 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java

@ -307,17 +307,20 @@ public class PatientHealthIndexService extends BaseService {
        // 查询病人家庭签约的健康管理师
        SignFamily signFamily = signFamilyDao.findByjiatingPatientYes(patientCode);
        String healthDoctorFamily = "";
        String doctotFamily = "";
        String doctorName = "";
        String doctorOpenID = "";
        if (signFamily != null) {
            healthDoctorFamily = signFamily.getDoctorHealth();
            doctotFamily = signFamily.getDoctor();
            if (StringUtils.isNotEmpty(healthDoctorFamily)) {
                // 添加到消息接收人列表
                receivers.add(healthDoctorFamily);
                Doctor doctor = doctorDao.findByCode(healthDoctorFamily);
                doctorName = doctor.getName();
                doctorOpenID = doctor.getOpenid();
            } else {
            }
            if (StringUtils.isNotEmpty(doctotFamily)){
                // 添加到消息接收人列表
                receivers.add(signFamily.getDoctor());
                Doctor doctor = doctorDao.findByCode(signFamily.getDoctor());
@ -335,6 +338,10 @@ public class PatientHealthIndexService extends BaseService {
                // 添加到消息接收人列表
                receivers.add(healthDoctorTeam);
            }
            if (StringUtils.isNotEmpty(signFamilySS.getDoctor()) && !StringUtils.equals(doctotFamily, signFamilySS.getDoctor())) {
                // 添加到消息接收人列表
                receivers.add(doctotFamily);
            }
        }
        List<Message> messages = new ArrayList<Message>();
        JSONArray array = new JSONArray();

+ 45 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/RedisController.java

@ -0,0 +1,45 @@
package com.yihu.wlyy.web.common.util;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
 * Created by zhangdan-pc on 2018/07/30
 */
@RestController
@RequestMapping(value = "/common/redis")
@Api("查询正式库reids值")
public class RedisController extends BaseController {
    @Autowired
    private StringRedisTemplate redisTemplate;
    /**
     * 查询增删改路径
     *
     * @return
     */
    @RequestMapping(value = "/getByKey",method = RequestMethod.POST)
    @ApiOperation(value = "根据key值查询结果")
    public String getByKey(@RequestParam(value = "key")String key) {
        try {
            String response = redisTemplate.opsForValue().get(key);
            return write(200,"查询成功","data",response);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
}