Переглянути джерело

续方咨询,随访相关接口

huangwenjie 7 роки тому
батько
коміт
7d51bc6c4e

+ 55 - 28
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -20,20 +20,25 @@ import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.system.Icd10DictServcie;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.util.ImUtill;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -100,6 +105,12 @@ public class PrescriptionInfoService extends BaseService {
    private PrescriptionAdjustReasonDao prescriptionAdjustReasonDao;
    @Autowired
    private FollowUpDao followUpDao;
	@Value("${doctorAssistant.api}")
	private String doctorAssistant;
	@Value("${doctorAssistant.target_url}")
	private String targetUrl;
	@Autowired
	private HttpClientUtil httpClientUtil;
    private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
@ -551,10 +562,6 @@ public class PrescriptionInfoService extends BaseService {
            if (s > 86400) {
                prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.pay_outtime.getValue());
                prescriptionDao.save(prescription);
    
                //取消长处方关联的随访记录
                canclePrescriptionFollowup(code);
            }
        } else {
            //rs.put("time","");
@ -619,9 +626,6 @@ public class PrescriptionInfoService extends BaseService {
        //同步智业接口
        jwPrescriptionService.fadeRecipe(code);
    
        //取消长处方关联的随访记录
        canclePrescriptionFollowup(code);
        return 1;
    }
@ -919,9 +923,32 @@ public class PrescriptionInfoService extends BaseService {
                //审核不通过模板消息
                sendRMess(p.getCode(), 0);
    
                //取消长处方关联的随访记录
                canclePrescriptionFollowup(code);
	
	            //取消长处方关联的随访记录
	            canclePrescriptionFollowup(code);
	
	            try {
		            //            新增发送医生助手模板消息 v1.4.0 by wujunjie
		            Doctor doctor = doctorDao.findByCode(p.getDoctor());
		            String doctorOpenID = doctor.getOpenid();
		            if (StringUtils.isNotEmpty(doctorOpenID)) {
			            String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
			            List<NameValuePair> params = new ArrayList<>();
			            params.add(new BasicNameValuePair("type", "1"));
			            params.add(new BasicNameValuePair("openId", doctorOpenID));
			            params.add(new BasicNameValuePair("url", targetUrl));
			            params.add(new BasicNameValuePair("first", doctor.getName() + "医生您好。您有一个您有1个续方申请处方开立失败。"));
			            params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
			            SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
			            String date = format.format(new Date());
			            String keywords = doctor.getName() +","+ p.getPatientName() +"," + date;
			            params.add(new BasicNameValuePair("keywords", keywords));
			
			            httpClientUtil.post(url, params, "UTF-8");
		            }
	            } catch (Exception e) {
		            e.printStackTrace();
	            }
            }
            prescriptionReviewedDao.save(reviewed);
            prescriptionDao.save(p);
@ -1864,22 +1891,22 @@ public class PrescriptionInfoService extends BaseService {
        }
        return jsonObject;
    }
    
    /**
     * 根据长处方CODE,取消关联的随访记录
     * @param prescriptionCode
     */
    private void canclePrescriptionFollowup(String prescriptionCode){
        try {
            //续方取消,随访记录也取消,这里如果出错则直接捕获,记录日志,不往外抛,避免影响长处方逻辑
            Followup followup = followUpDao.getFollowupByPrescriptionCode(prescriptionCode);
            if(followup !=null){
                followup.setStatus("0");
                followUpDao.save(followup);
            }
        }catch (Exception e){
            logger.info("续方取消,随访记录同步取消失败:"+e.getMessage());
        }
    }
	
	
	/**
	 * 根据长处方CODE,取消关联的随访记录
	 * @param prescriptionCode
	 */
	private void canclePrescriptionFollowup(String prescriptionCode){
		try {
			//续方取消,随访记录也取消,这里如果出错则直接捕获,记录日志,不往外抛,避免影响长处方逻辑
			Followup followup = followUpDao.getFollowupByPrescriptionCode(prescriptionCode);
			if(followup !=null){
				followup.setStatus("0");
				followUpDao.save(followup);
			}
		}catch (Exception e){
			logger.info("续方取消,随访记录同步取消失败:"+e.getMessage());
		}
	}
}

+ 43 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionAdjustController.java

@ -2,17 +2,29 @@ package com.yihu.wlyy.web.doctor.prescription;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.service.app.prescription.PrescriptionAdjustService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * Created by yeshijie on 2017/8/17.
 */
@ -27,6 +39,14 @@ public class PrescriptionAdjustController extends BaseController {
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PrescriptionAdjustService prescriptionAdjustService;
    @Autowired
    private DoctorDao doctorDao;
    @Value("${doctorAssistant.api}")
    private String doctorAssistant;
    @Value("${doctorAssistant.target_url}")
    private String targetUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @RequestMapping(value = "adjustPrescription",method = RequestMethod.POST)
    @ObserverRequired
@ -44,6 +64,29 @@ public class PrescriptionAdjustController extends BaseController {
            if(json.getInteger("status")==-1){
                return error(-1,json.getString("msg"));
            }
            try {
                //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                Prescription prescription = prescriptionDao.findByCode(code);
                Doctor doctor = doctorDao.findByCode(prescription.getDoctor());
                String doctorOpenID = doctor.getOpenid();
                if (StringUtils.isNotEmpty(doctorOpenID)) {
                    String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                    List<NameValuePair> params = new ArrayList<>();
                    params.add(new BasicNameValuePair("type", "9"));
                    params.add(new BasicNameValuePair("openId", doctorOpenID));
                    params.add(new BasicNameValuePair("url", targetUrl));
                    params.add(new BasicNameValuePair("first", doctor.getName() + "医生您好。您有1个续方申请已在线下调整完成,请尽快进行CA认证."));
                    params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                    SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                    String date = format.format(new Date());
                    String keywords = "续方审核CA认证" +"," + date;
                    params.add(new BasicNameValuePair("keywords", keywords));
                    httpClientUtil.post(url, params, "UTF-8");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            return write(200,"请求调整成功");
        }catch (Exception e){
            error(e);

+ 55 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -803,6 +803,38 @@ public class ConsultController extends WeixinBaseController {
                        return invalidUserException(new RuntimeException(resObj.getString("message")), -1, "追问失败!" + resObj.getString("message"));
                    }
                    failed.add(String.valueOf(resObj.get("data")));
                    try {
                        //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                        Doctor doctor = doctorDao.findByCode(log.getDoctor());
                        String doctorOpenID = doctor.getOpenid();
                        if (StringUtils.isNotEmpty(doctorOpenID)) {
                                String title = "";
                                Consult consultSingle = consultDao.findByCode(log.getConsult());
                                if (consultSingle!=null){
                                    Integer singleType = consultSingle .getType();
                                    if (singleType != null && singleType ==8 ){
                                        title = consultSingle.getTitle();
                                    }else if(singleType != null && singleType !=8 ){
                                        title = consultSingle.getSymptoms();
                                    }
                                    String first = "居民" +patient.getName()+"的健康咨询有新的回复。";
                                    String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                                    List<NameValuePair> params = new ArrayList<>();
                                    params.add(new BasicNameValuePair("type", "8"));
                                    params.add(new BasicNameValuePair("openId", doctorOpenID));
                                    params.add(new BasicNameValuePair("url", targetUrl));
                                    params.add(new BasicNameValuePair("first",  first));
                                    params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                                    String keywords = title + "," + content +","+ log.getDoctorName();
                                    params.add(new BasicNameValuePair("keywords", keywords));
                                    httpClientUtil.post(url, params, "UTF-8");
                                }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
            return write(200, "追问成功!", "data", failed);
@ -1067,6 +1099,29 @@ public class ConsultController extends WeixinBaseController {
            // 推送消息给医生
            pushMsgTask.put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.D_CT_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_PRESCRIPTION.续方咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_PRESCRIPTION.您有新的续方咨询.name(), consult.getConsult());
            try {
                //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                Doctor doctor1 = doctorDao.findByCode(doctor);
                Patient patient = patientDao.findByCode(getRepUID());
                String doctorOpenID = doctor1.getOpenid();
                if (StringUtils.isNotEmpty(doctorOpenID)) {
                        String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                        List<NameValuePair> params = new ArrayList<>();
                        params.add(new BasicNameValuePair("type", "9"));
                        params.add(new BasicNameValuePair("openId", doctorOpenID));
                        params.add(new BasicNameValuePair("url", targetUrl));
                        params.add(new BasicNameValuePair("first", doctor1.getName() + "医生您好。您的签约居民"+patient.getName()+"申请线上续方,请尽快审核。"));
                        params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                        SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                        String date = format.format(new Date());
                        String keywords = "续方审核" + "," + date;
                        params.add(new BasicNameValuePair("keywords", keywords));
                        httpClientUtil.post(url, params, "UTF-8");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            BusinessLogs.info(BusinessLogs.BusinessType.consult, getRepUID(), getUID(), new JSONObject(consult));
            return write(200, "提交成功", "data", consult);