Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

DESKTOP-G6NQ3SI\dante 7 years ago
parent
commit
01a0a681a3

+ 1 - 1
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/common/dao/PatientHealthIndexDao.java

@ -55,7 +55,7 @@ public interface PatientHealthIndexDao
	@Query("select a from PatientHealthIndex a where a.user = ?1 and a.type =?2  order by recordDate desc ")
    List<PatientHealthIndex> findByPatientAndType(String patientCode, int type, Pageable pageable);
	@Query("select count(a) from DevicePatientHealthIndex a where a.recordDate >= ?1 and a.recordDate <= ?2 and a.type in (1,2) and a.status = ?3 and a.del = '1' and user = ?4")
	@Query("select count(a) from PatientHealthIndex a where a.recordDate >= ?1 and a.recordDate <= ?2 and a.type in (1,2) and a.status = ?3 and a.del = '1' and user = ?4")
	int getCountByTimeAndStatus(Date start, Date end, int status, String patientCode);
	@Query(value="select * from device.wlyy_patient_health_index where user = ?1 and type = ?2 ORDER BY record_date desc limit 0 ,5",nativeQuery = true)

+ 10 - 161
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/service/template/DoctorFeldsherTemplateService.java

@ -9,6 +9,7 @@ import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.ImUtill;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import com.yihu.wlyy.wechat.util.WeiXinTempMsgSendUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
@ -42,6 +43,11 @@ public class DoctorFeldsherTemplateService extends BaseService {
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private ImUtill imUtill;
    @Autowired
    private WeiXinTempMsgSendUtils weiXinTempMsgSendUtils;
    @Value("${wechat.message.template_consult_notice}")
    private String templateId;
    @Value("${server.server_url}")
    private String server_url;
@ -91,159 +97,6 @@ public class DoctorFeldsherTemplateService extends BaseService {
        logger.info("sendJson: " + sendJson);
    }
    /**
     * 发送给医生的模板消息提醒
     *
     * @param patientCode 居民code
     * @param doctorCode  医生code
     * @throws Exception
     */
    public void sendDoctorTemplate(String patientCode, String doctorCode, int type) throws Exception {
        int num = 0;
        int num1 = 0;
        int num2 = 0;
        int num3 = 0;
        int num4 = 0;
        int num5 = 0;
        int num6 = 0;
        Date date = new Date();
        Date date1 = new Date();
        String content1 = "";
        String contetn2 = "";
        Patient people = patientDao.findByCode(patientCode);
        String patientOpenId = people.getOpenid();
        String patientName = people.getName();
        int patientSex = people.getSex();
        Doctor doctor = doctorDao.findByCode(doctorCode);
        String doctorName = doctor.getName();
        String doctorOpenId = doctor.getOpenid();
        //使用微信应用宝跳转APP的功能。点击后跳转APP消息页。
        String url = "";
        String first = "";
        String remark = "请进入手机APP查看,如尚未安装APP请点击详情下载安装";
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
        JSONObject sendJson = new JSONObject();
        switch (type) {
            case 1:
                first = doctorName + "医生您好,你有一条新的签约申请待处理";
                sendJson.put("keyword1", patientName);
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 2:
                first = doctorName + "医生,您的签约居民" + patientName + "有" + num + "条未读的体征异常消息";
                sendJson.put("keyword1", patientName);
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 3:
                first = doctorName + "医生您好。" + date + "新增1个签约居民待分配健管师,截至目前共有 " + num1 + " 人待处理";
                sendJson.put("keyword1", "分配健管师");
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 4:
                first = "您今日有" + num3 + "个随访计划待处理";
                sendJson.put("keyword1", patientName);
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 5:
                first = doctorName + "医生您好,有患者向您发起咨询";
                sendJson.put("keyword1", patientName);
                sendJson.put("keyword2", patientSex == 1 ? "男" : "女");
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 6:
                first = "居民" + patientName + "的健康咨询有新的回复";
                sendJson.put("keyword1", content1);
                sendJson.put("keyword2", contetn2);
                sendJson.put("keyword3", doctorName);
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 7:
                first = doctorName + "医生您好。您的签约居民" + patientName + "申请线上续方,请尽快审核";
                sendJson.put("keyword1", "续方审核");
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 8:
                first = doctorName + "医生您好。" + date1 +
                        "新增1个续方订单待分配配送员,目前共" + num4 +
                        "人待分配,一个尽快分配";
                sendJson.put("keyword1", "分配配送员");
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 9:
                first = doctorName + "医生您好。您有一个您有1个续方申请处方开立失败";
                sendJson.put("keyword1", doctorName);
                sendJson.put("keyword2", patientName);
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 10:
                first = doctorName + "医生您好。您有1个续方申请已在线下调整完成,请尽快进行CA认证";
                sendJson.put("keyword1", "续方审核CA认证");
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 11:
                first = doctorName + "医生您好,你有一条新的续签申请待处理";
                sendJson.put("keyword1", patientName);
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
        }
    }
    /**
     * 拼装医生助手 医生类模板消息并发送
     *
@ -260,19 +113,15 @@ public class DoctorFeldsherTemplateService extends BaseService {
            String remark = "请进入手机APP查看,如尚未安装APP请点击详情下载安装";
            String url = server_url + "wx_doctor/html/home/html/jumpApp.html";
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
            JSONObject sendJson = new JSONObject();
            Doctor doctor = doctorDao.findByCode(doctorCode);
            String doctorName = doctor.getName();
            String doctorOpenId = doctor.getOpenid();
            String first = businessType;
            sendJson.put("keyword1", content);
            sendJson.put("keyword2", dateFormat.format(new Date()));
            sendJson.put("first", first);
            sendJson.put("remark", remark);
            sendJson.put("url", url);//带参数的模板跳转链接
            pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 11, doctorOpenId, doctorName, sendJson);
            JSONObject sendJson = weiXinTempMsgSendUtils.packageTemplate(businessType, remark, content, dateFormat.format(new Date()));
            Boolean flag = weiXinTempMsgSendUtils.sendTemplateMessage(templateId, doctorOpenId, url, sendJson);
            logger.info("send wechat message param : " + doctorOpenId+" =======> "+content);
            logger.info("send wechat message retuen : " + flag+" =======> "+flag);
            logger.info("sendJson: " + sendJson);
            return true;
        } catch (Exception e) {

+ 60 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/web/doctor/template/DoctorFeldsherTemplateController.java

@ -0,0 +1,60 @@
package com.yihu.wlyy.web.doctor.template;
import com.yihu.wlyy.repository.template.DoctorGuidanceTempDao;
import com.yihu.wlyy.service.template.DoctorFeldsherTemplateService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
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;
/**
 * 医生健康指导模板
 * <p>
 * Created by Reece on 2017/9/14.
 */
@RestController
@RequestMapping(value = "/doctor/feldsher")
@Api(description = "医生健康指导模板")
public class DoctorFeldsherTemplateController extends BaseController {
    @Autowired
    private DoctorFeldsherTemplateService feldsherTemplateService;
    @Autowired
    DoctorGuidanceTempDao guidanceTempDao;
    /**
     * @param doctorCode   医生code
     * @param sessionId    会话Id
     * @param sessionType  会话类型
     * @param businessType 消息类型
     * @param from         发送者
     * @param content      消息内容
     * @return
     */
    @RequestMapping(value = "/sendDoctorTemplate", method = RequestMethod.GET)
    @ApiOperation(value = "医生助手给医生发送模板消息")
    public String sendDoctorTemplate(@RequestParam @ApiParam(value = "医生code") String doctorCode,
                                     @RequestParam @ApiParam(value = "会话Id", required = false) String sessionId,
                                     @RequestParam @ApiParam(value = "会话类型", required = false) String sessionType,
                                     @RequestParam @ApiParam(value = "消息类型") String businessType,
                                     @RequestParam @ApiParam(value = "发送者", required = false) String from,
                                     @RequestParam @ApiParam(value = "消息内容") String content) {
        try {
            Boolean flag = feldsherTemplateService.sendDoctorTemplate(doctorCode, sessionId, sessionType, businessType, from, content);
            if (flag){
                return write(200, "发送成功!");
            }else {
                return write( -1, "发送失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return invalidUserException(e, -1, "发送失败!");
        }
    }
}

+ 5 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -860,6 +860,11 @@ public class PatientService extends TokenService {
                "   f.patient = p.code ";
        //判断是否是慢病管理
        if(isSlowDisease){
            fousGSql = fousGSql + " AND p.disease >0 AND p.status > 0 ";
        }
        if(StringUtils.isNotBlank(diseaseCondition)){
            fousGSql = fousGSql +"   AND p.disease_condition = "+diseaseCondition;
        }