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

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

trick9191 7 роки тому
батько
коміт
661e9228f6

+ 244 - 13
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwSmjkService.java

@ -2,29 +2,23 @@ package com.yihu.wlyy.service.third.jw;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientReservation;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientReservationDao;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.service.third.ehr.EhrService;
import com.yihu.wlyy.service.third.guahao.GuahaoDoctor;
import com.yihu.wlyy.service.third.guahao.IGuahaoService;
import com.yihu.wlyy.util.*;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionContext;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by hzp on 2016/11/14.
@ -351,15 +345,252 @@ public class JwSmjkService {
        return re;
    }
    public String responseStr(String response) throws Exception{
        String re = "";
        if (!StringUtils.isEmpty(response)) {
            JSONObject jsonObject = new JSONObject(response);
            int status = jsonObject.getInt("status");
            if (status == 200) {
                re = jsonObject.getString("data");
            } else {
                String msg = "处理失败,请联系管理员";
                if(!jsonObject.isNull("msg")){
                    msg = jsonObject.getString("msg");
                }
                throw new Exception(msg);
            }
        } else {
            throw new Exception("null response.");
        }
        return re;
    }
    public Boolean responseBool(String response) throws Exception{
        boolean re = false;
        if (!StringUtils.isEmpty(response)) {
            JSONObject jsonObject = new JSONObject(response);
            int status = jsonObject.getInt("status");
            if (status == 200) {
                re = jsonObject.getBoolean("data");
            } else {
                String msg = "处理失败,请联系管理员";
                if(!jsonObject.isNull("msg")){
                    msg = jsonObject.getString("msg");
                }
                throw new Exception(msg);
            }
        } else {
            throw new Exception("null response.");
        }
        return re;
    }
    /**
     * 获取医院列表
     * @param type
     * @return
     * @throws Exception
     */
    public String GetOrgList(String type) throws Exception{
        String url = jwUrl + "/third/guahao/GetOrgList";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("type", type));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        return responseStr(response);
    }
    /**
     * 获取科室接口
     * @param hospitalId
     * @return
     * @throws Exception
     */
    public String GetOrgDepList(String hospitalId) throws Exception{
        String url = jwUrl + "/third/guahao/GetOrgDepList";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("hospitalId", hospitalId));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        return responseStr(response);
    }
    /**
     * 获取医生列表接口
     * @param hospitalId
     * @return
     * @throws Exception
     */
    public String GetDoctorList(String hospitalId,String hosDeptId) throws Exception{
        String url = jwUrl + "/third/guahao/GetDoctorList";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("hospitalId", hospitalId));
        params.add(new BasicNameValuePair("hosDeptId", hosDeptId));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        return responseStr(response);
    }
    /**
     * 获取医生排班接口(包含排班详细)
     * @param hospitalId
     * @return
     * @throws Exception
     */
    public String GetDoctorArrange(String hospitalId,String hosDeptId,String doctorId) throws Exception{
        String url = jwUrl + "/third/guahao/GetDoctorArrange";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("hospitalId", hospitalId));
        params.add(new BasicNameValuePair("hosDeptId", hosDeptId));
        params.add(new BasicNameValuePair("doctorId", doctorId));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        return responseStr(response);
    }
    /**
     * 获取医生排班接口(一级)
     * @param hospitalId
     * @return
     * @throws Exception
     */
    public String GetDoctorArrangeSimple(String hospitalId,String hosDeptId,String doctorId) throws Exception{
        String url = jwUrl + "/third/guahao/GetDoctorArrangeSimple";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("hospitalId", hospitalId));
        params.add(new BasicNameValuePair("hosDeptId", hosDeptId));
        params.add(new BasicNameValuePair("doctorId", doctorId));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        return responseStr(response);
    }
    /**
     * 创建挂号单
     * @param hospitalId
     * @return
     * @throws Exception
     */
    public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,
                               String doctorId,String doctorName,String arrangeDate,String patient,
                               String patientName,String cardNo,String clinicCard,String patientPhone) throws Exception{
        String url = jwUrl + "/third/guahao/CreateOrder";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("hospitalName", hospitalName));
        params.add(new BasicNameValuePair("hospitalId", hospitalId));
        params.add(new BasicNameValuePair("hosDeptId", hosDeptId));
        params.add(new BasicNameValuePair("hosDeptName", hosDeptName));
        params.add(new BasicNameValuePair("doctorId", doctorId));
        params.add(new BasicNameValuePair("doctorName", doctorName));
        params.add(new BasicNameValuePair("arrangeDate", arrangeDate));
        params.add(new BasicNameValuePair("patient", patient));
        params.add(new BasicNameValuePair("patientName", patientName));
        params.add(new BasicNameValuePair("cardNo", cardNo));
        params.add(new BasicNameValuePair("clinicCard", clinicCard));
        params.add(new BasicNameValuePair("patientPhone", patientPhone));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        return responseStr(response);
    }
    /**
     * 取消挂号单
     * @param orderId
     * @return
     * @throws Exception
     */
    public boolean CancelOrder(String orderId,String clinicCard) throws Exception{
        String url = jwUrl + "/third/guahao/CancelOrder";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("orderId", orderId));
        params.add(new BasicNameValuePair("clinicCard", clinicCard));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        return responseBool(response);
    }
    /**
     * 获取医生信息
     * @param hospitalId
     * @return
     * @throws Exception
     */
    public String GetDoctorInfo(String hospitalId,String hosDeptId,String doctorId) throws Exception{
        String url = jwUrl + "/third/guahao/GetDoctorInfo";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("hospitalId", hospitalId));
        params.add(new BasicNameValuePair("hosDeptId", hosDeptId));
        params.add(new BasicNameValuePair("doctorId", doctorId));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        return responseStr(response);
    }
    /**
     * 获取预约状态(0 撤销 1 确认 2 已诊  3停诊)
     * @param hospitalId
     * @return
     * @throws Exception
     */
    public Integer GetOrderStatus(String hospitalId,String hosDeptId,String doctorId) throws Exception{
        Integer re = null;
        String url = jwUrl + "/third/guahao/GetOrderStatus";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("hospitalId", hospitalId));
        params.add(new BasicNameValuePair("hosDeptId", hosDeptId));
        params.add(new BasicNameValuePair("doctorId", doctorId));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if (!StringUtils.isEmpty(response)) {
            JSONObject jsonObject = new JSONObject(response);
            int status = jsonObject.getInt("status");
            if (status == 200) {
                re = jsonObject.getInt("data");
            } else {
                throw new Exception(jsonObject.getString("msg"));
            }
        } else {
            throw new Exception("null response.");
        }
        return re;
    }
    /**
     * 根据患者医保卡获取近三个月的预约记录
     * @param patient
     * @return
     * @throws Exception
     */
    public String GetRegList(String patient) throws Exception{
        String url = jwUrl + "/third/guahao/GetRegList";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("patient", patient));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        return responseStr(response);
    }
    /**
     * 根据患者,预约编号,机构编号获取单条记录预约记录
     * @param patient
     * @return
     * @throws Exception
     */
    public String GetRegDetail(String patient,String orgCode,String regCode) throws Exception{
        String url = jwUrl + "/third/guahao/GetRegDetail";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("patient", patient));
        params.add(new BasicNameValuePair("orgCode", orgCode));
        params.add(new BasicNameValuePair("regCode", regCode));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        return responseStr(response);
    }
    /*************************************** 旧版本函数 *************************************************************************/

+ 14 - 12
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/booking/DoctorBookingController.java

@ -6,6 +6,7 @@ import com.yihu.wlyy.repository.patient.PatientReservationDao;
import com.yihu.wlyy.service.app.reservation.PatientReservationService;
import com.yihu.wlyy.service.third.guahao.GuahaoXMService;
import com.yihu.wlyy.service.third.guahao.GuahaoYihuService;
import com.yihu.wlyy.service.third.jw.JwSmjkService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
@ -29,7 +30,8 @@ public class DoctorBookingController extends BaseController{
    @Autowired
    private GuahaoXMService guahaoXM;
    @Autowired
    private JwSmjkService jwSmjkService;
    @Autowired
    private GuahaoYihuService guahaoYihu;
@ -70,17 +72,17 @@ public class DoctorBookingController extends BaseController{
        try {
            //获取订单信息
            PatientReservation obj = patientReservationService.findById(orderId);
            boolean re = false;
            if (obj != null) {
                String type = obj.getType();
                String code = obj.getCode();
                if (type.equals("0")) {  //医护网接口
                    re = guahaoYihu.CancelOrder(code);
                } else if (type.equals("1"))   //厦门市民健康预约接口
                {
                    re = guahaoXM.CancelOrder(code, obj.getSsc());
                }
            }
            boolean re = jwSmjkService.CancelOrder(obj.getCode(),obj.getSsc());
//            if (obj != null) {
//                String type = obj.getType();
//                String code = obj.getCode();
//                if (type.equals("0")) {  //医护网接口
//                    re = guahaoYihu.CancelOrder(code);
//                } else if (type.equals("1"))   //厦门市民健康预约接口
//                {
//                    re = guahaoXM.CancelOrder(code, obj.getSsc());
//                }
//            }
            if (re) {
                //更新状态

+ 14 - 11
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/booking/PatientBookingController.java

@ -6,6 +6,7 @@ import com.yihu.wlyy.service.app.reservation.PatientReservationService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.guahao.GuahaoXMService;
import com.yihu.wlyy.service.third.guahao.GuahaoYihuService;
import com.yihu.wlyy.service.third.jw.JwSmjkService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
@ -40,6 +41,8 @@ public class PatientBookingController extends WeixinBaseController{
    private PatientService patientService;
    @Autowired
    WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private JwSmjkService jwSmjkService;
    @RequestMapping(value = "CancelOrder", method = RequestMethod.POST)
@ -50,17 +53,17 @@ public class PatientBookingController extends WeixinBaseController{
        try {
            //获取订单信息
            PatientReservation obj = patientReservationService.findByCode(orderId);
            boolean re = false;
            if (obj != null) {
                String type = obj.getType();
                String code = obj.getCode();
                if (type.equals("0")) {  //医护网接口
                    re = guahaoYihu.CancelOrder(code);
                } else if (type.equals("1"))   //厦门市民健康预约接口
                {
                    re = guahaoXM.CancelOrder(code, obj.getSsc());
                }
            }
            boolean re = jwSmjkService.CancelOrder(obj.getCode(),obj.getSsc());
//            if (obj != null) {
//                String type = obj.getType();
//                String code = obj.getCode();
//                if (type.equals("0")) {  //医护网接口
//                    re = guahaoYihu.CancelOrder(code);
//                } else if (type.equals("1"))   //厦门市民健康预约接口
//                {
//                    re = guahaoXM.CancelOrder(code, obj.getSsc());
//                }
//            }
            if (re) {
                //更新状态

+ 35 - 18
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java

@ -5,13 +5,14 @@ import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientReservation;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.message.SMSDao;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.app.reservation.PatientReservationService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.guahao.GuahaoDoctor;
import com.yihu.wlyy.service.third.guahao.GuahaoXMService;
import com.yihu.wlyy.service.third.guahao.GuahaoYihuService;
import com.yihu.wlyy.service.third.guahao.IGuahaoService;
import com.yihu.wlyy.service.third.jw.JwSmjkService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
@ -34,7 +35,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -66,6 +66,10 @@ public class BookingController extends WeixinBaseController {
    @Autowired
    WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private ConsultService consultService;
    @Autowired
    private JwSmjkService jwSmjkService;
    /**
     * 根据城市编码获取相应挂号服务
@ -138,8 +142,9 @@ public class BookingController extends WeixinBaseController {
                             @ApiParam(name = "pageSize", value = "每页记录数", defaultValue = "")
                             @RequestParam(value = "pageSize", required = false) Integer pageSize) {
        try {
            List<Map<String, String>> list = getService(city).GetOrgList(city, filter, type, pageIndex, pageSize);
            return write(200, "获取机构列表成功!", "data", list);
//            List<Map<String, String>> list = getService(city).GetOrgList(city, filter, type, pageIndex, pageSize);
            String re = jwSmjkService.GetOrgList(type);
            return write(200, "获取机构列表成功!", "data", re);
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
@ -160,7 +165,8 @@ public class BookingController extends WeixinBaseController {
                                @ApiParam(name = "pageSize", value = "每页记录数", defaultValue = "")
                                @RequestParam(value = "pageSize", required = false) Integer pageSize) {
        try {
            List<Map<String, String>> list = getService(city).GetOrgDepList(hospitalId, filter, pageIndex, pageSize);
//            List<Map<String, String>> list = getService(city).GetOrgDepList(hospitalId, filter, pageIndex, pageSize);
            String list = jwSmjkService.GetOrgDepList(hospitalId);
            return write(200, "获取科室列表成功!", "data", list);
        } catch (Exception e) {
            return error(-1, e.getMessage());
@ -183,7 +189,8 @@ public class BookingController extends WeixinBaseController {
                                @ApiParam(name = "pageSize", value = "每页记录数", defaultValue = "")
                                @RequestParam(value = "pageSize", required = false) Integer pageSize) {
        try {
            List<GuahaoDoctor> list = getService(city).GetDoctorList(hospitalId, hosDeptId, filter, pageIndex, pageSize);
//            List<GuahaoDoctor> list = getService(city).GetDoctorList(hospitalId, hosDeptId, filter, pageIndex, pageSize);
            String list = jwSmjkService.GetDoctorList(hospitalId,hosDeptId);
            return write(200, "获取医生列表成功!", "data", list);
        } catch (Exception e) {
            return error(-1, e.getMessage());
@ -202,7 +209,8 @@ public class BookingController extends WeixinBaseController {
                                   @ApiParam(name = "doctorId", value = "医生ID", defaultValue = "AA2")
                                   @RequestParam(value = "doctorId", required = true) String doctorId) {
        try {
            List<Map<String, Object>> list = getService(city).GetDoctorArrange(hospitalId, hosDeptId, doctorId);
//            List<Map<String, Object>> list = getService(city).GetDoctorArrange(hospitalId, hosDeptId, doctorId);
            String list = jwSmjkService.GetDoctorArrange(hospitalId,hosDeptId,doctorId);
            return write(200, "获取医生排班成功!", "data", list);
        } catch (Exception e) {
            return error(-1, e.getMessage());
@ -221,7 +229,8 @@ public class BookingController extends WeixinBaseController {
                                         @ApiParam(name = "doctorId", value = "医生ID", defaultValue = "03101")
                                         @RequestParam(value = "doctorId", required = true) String doctorId) {
        try {
            List<Map<String, String>> list = getService(city).GetDoctorArrangeSimple(hospitalId, hosDeptId, doctorId);
//            List<Map<String, String>> list = getService(city).GetDoctorArrangeSimple(hospitalId, hosDeptId, doctorId);
            String list = jwSmjkService.GetDoctorArrangeSimple(hospitalId,hosDeptId,doctorId);
            return write(200, "获取医生排班成功!", "data", list);
        } catch (Exception e) {
            return error(-1, e.getMessage());
@ -240,7 +249,8 @@ public class BookingController extends WeixinBaseController {
                                @ApiParam(name = "hosDeptId", value = "科室id", defaultValue = "1040610")
                                @RequestParam(value = "hosDeptId", required = true) String hosDeptId) {
        try {
            GuahaoDoctor doctor = getService(city).GetDoctorInfo(doctorId, hospitalId, hosDeptId);
//            GuahaoDoctor doctor = getService(city).GetDoctorInfo(doctorId, hospitalId, hosDeptId);
            String doctor = jwSmjkService.GetDoctorInfo(hospitalId,hosDeptId,doctorId);
            return write(200, "获取医生信息成功!", "data", doctor);
        } catch (Exception e) {
            return error(-1, e.getMessage());
@ -289,12 +299,17 @@ public class BookingController extends WeixinBaseController {
            if (StringUtils.isEmpty(patientPhone)) {
                return error(-1, "未设置手机号码!");
            }
            String orderCode = getService(city).CreateOrder(hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, arrangeDate, patient, patientName, cardNo, clinicCard, patientPhone);
            //String orderCode = getService(city).CreateOrder(hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, arrangeDate, patient, patientName, cardNo, clinicCard, patientPhone);
            String orderCode = jwSmjkService.CreateOrder(hospitalId,hospitalName,hosDeptId,hosDeptName,doctorId,doctorName,arrangeDate,patient,patientName,cardNo,clinicCard,patientPhone);
            //预约发送微信消息
            PatientReservation obj = patientReservationService.findByCode(orderCode);
            if (obj != null) {
                Patient p = patientService.findByCode(obj.getPatient());
                if(StringUtils.isNotBlank(obj.getDoctor())){
                    consultService.sendMucMessageBySingnType(obj.getDoctor(),obj.getDoctorName(),patient,"我已成功为您预约:" + DateUtil.dateToStrLong(obj.getStartTime()) + "," + hospitalName + hosDeptName + doctorName + "医生的号源。您可直接前往医院就诊</br><a name='guahao' href='javascript:void(0)' data-id='" + obj.getId() + "'>点击查看详情</a>","1",p.getName());
                }
                String msg = "您成功预约了 " + obj.getOrgName() + " " + obj.getDoctorName() + " " + obj.getStartTime() + " 的号源!";
                // 推送消息给微信端
                JSONObject json = new JSONObject();
@ -367,7 +382,7 @@ public class BookingController extends WeixinBaseController {
    @RequestMapping(value = "CancelOrder", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("取消挂号单")
    @ApiOperation("取消挂号单(已废弃)")
    public String CancelOrder(@ApiParam(name = "orderId", value = "订单id", defaultValue = "9")
                              @RequestParam(value = "orderId", required = true) Long orderId) {
        try {
@ -691,11 +706,12 @@ public class BookingController extends WeixinBaseController {
    public String GetRegList(@ApiParam(name = "patient", value = "患者编号", defaultValue = "0cc6e4562de2437ab2dbbf51a9fc3b49")
                             @RequestParam(value = "patient", required = false) String patient) {
        try {
            SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd");
            Date nowDate = new Date();
            Date oneMonthAfter = getMonthBefore(nowDate, -1);
            Date threeMonthBefore = getMonthBefore(nowDate, 3);        //三个月历史记录
            List<PatientReservation> list = guahaoXM.GetRegList(patient, sm.format(threeMonthBefore), sm.format(oneMonthAfter), threeMonthBefore, oneMonthAfter);
//            SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd");
//            Date nowDate = new Date();
//            Date oneMonthAfter = getMonthBefore(nowDate, -1);
//            Date threeMonthBefore = getMonthBefore(nowDate, 3);        //三个月历史记录
//            List<PatientReservation> list = guahaoXM.GetRegList(patient, sm.format(threeMonthBefore), sm.format(oneMonthAfter), threeMonthBefore, oneMonthAfter);
            String list = jwSmjkService.GetRegList(patient);
            return write(200, "获取患者预约信息列表成功!", "data", list);
        } catch (Exception e) {
            return error(-1, e.getMessage());
@ -712,7 +728,8 @@ public class BookingController extends WeixinBaseController {
                                          @ApiParam(name = "regCode", value = "挂号单号",defaultValue = "9c34e255-5984-43f0-8ecf-3bbf160e3c58")
                                          @RequestParam(value = "regCode", required = true) String regCode) {
        try {
            PatientReservation obj = guahaoXM.getRegDetail(patientCode, orgCode, regCode);
//            PatientReservation obj = guahaoXM.getRegDetail(patientCode, orgCode, regCode);
            String obj = jwSmjkService.GetRegDetail(patientCode,orgCode,regCode);
            return write(200, "获取患者预约信息成功!", "data", obj);
        } catch (Exception e) {
            return error(-1, e.getMessage());