Browse Source

咨询记录

hxm 3 years ago
parent
commit
54ad2b2c5b

+ 47 - 29
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -3312,22 +3312,42 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        } else {
            sql = sql + "date_format(p.pay_time,'%Y-%m-%d %H:%i:%S' )  AS \"payTime\",";
        }
        sql = sql + " e.name as \"name\", " +
                " e.oneself_pickup_flg AS \"oneselfPickupFlg\", " +
                " o.id AS \"outpatientId\", " +
                " o.icd10_name AS \"icd10Name\", " +
                " p.status as \"status\", " +
                " p.id AS \"prescriptionId\" ," +
                " e.id AS \"expressageId\" ,"+
                " p.real_order AS \"realOrder\" ,"+
                " p.origin_real_order AS \"originRealOrder\"," +
                " o.patient_name as \"patientName\" "+
                " FROM " +
                " wlyy_outpatient o " +
                " JOIN wlyy_prescription p ON p.outpatient_id = o.id " +
                " JOIN wlyy_prescription_expressage e ON e.outpatient_id = o.id " +
                " WHERE" +
                " 1=1";
        sql = sql + "IFNULL(p.create_time,' ') as time,\n" +
                "IFNULL(e.name,' ') as \"name\", \n" +
                "IFNULL(p.pay_time,' ') AS \"pay_time\" ,\n" +
                "IFNULL(p.real_order,' ') AS \"realOrder\" ,\n" +
                "IFNULL(o.patient_name,' ') as \"patientName\",\n" +
                "IFNULL(i.drug_name,' ') as \"infoName\",\n" +
                "IF(p.create_time = NULL,'否','是') as \"create_time\" ,\n" +
                "case e.oneself_pickup_flg\n" +
                "when 1 then '自取'\n" +
                "when 2 then '快递配送'\n" +
                "else ' ' end oneself_pickup_flg,\n" +
                "CASE p.status\n" +
                "when -4 then '已作废'\n" +
                "when -3 then '支付过期取消'\n" +
                "when -2 then '患者自己取消'\n" +
                "when -1 then '医生取消'\n" +
                "when 0 then '候诊中'\n" +
                "when 10 then '诊断中'\n" +
                "when 11 then '药师审核失败 / 调整中'\n" +
                "when 12 then '药师审核完成'\n" +
                "when 13 then '开方失败/调整中'\n" +
                "when 20 then '诊断完成/开方成功/待支付'\n" +
                "when 21 then '支付失败/待支付中'\n" +
                "when 30 then '支付成功/等待配药'\n" +
                "when 31 then '配药成功/等待取药'\n" +
                "when 32 then '配送中'\n" +
                "when 100 then '已完成/未评价'\n" +
                "when 101 then '已完成/已经评价'\n" +
                "else ' ' END status\n" +
                "FROM \n" +
                "wlyy_outpatient o\n" +
                "left JOIN wlyy_prescription p ON p.outpatient_id = o.id\n" +
                "left JOIN wlyy_prescription_expressage e ON e.outpatient_id = o.id \n" +
                "left JOIN wlyy_prescription_info i on i.prescription_id = p.id\n" +
                "WHERE\n" +
                "1=1 ";
        if (StringUtils.isNotBlank(status)) {
            sql += " AND p.status in(" + status + ") ";
        }
@ -3368,16 +3388,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        }
        sql +=" order by p.create_time desc ";
        /*       sql += " LIMIT " + (page - 1) * size + "," + size + "";*/
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, page, size);
        for (Map<String, Object> map : list) {
        List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(sql);
        for (Map<String, Object> map : mapList) {
            if (map.get("prescriptionId") != null) {
                List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(map.get("prescriptionId").toString(), 1);
                map.put("info", wlyyPrescriptionInfoDOS);
            }
        }
        return MixEnvelop.getSuccessListWithPage(BaseHospitalRequestMapping.Prescription.api_success, list, page, size, count);
        return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success, mapList);
    }
    public Boolean setMailno(String mailno, String expressageId) {
@ -3403,15 +3421,15 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            int i = 1;
            for (Map<String, Object> m : ls) {
                addCell(ws, i, 0, m.get("createTime").toString());
                addCell(ws, i, 1, m.get("origin_real_order").toString());
                addCell(ws, i, 2, m.get("patient_name").toString());
                addCell(ws, i, 3, m.get(" ").toString());
                addCell(ws, i, 4, m.get(" ").toString());
                addCell(ws, i, 5, m.get("dispensary_type").toString());
                addCell(ws, i, 0, m.get("time").toString());
                addCell(ws, i, 1, m.get("realOrder").toString());
                addCell(ws, i, 2, m.get("patientName").toString());
                addCell(ws, i, 3, m.get("name").toString());
                addCell(ws, i, 4, m.get("infoName").toString());
                addCell(ws, i, 5, (String) m.get("oneself_pickup_flg"));
                addCell(ws, i, 6, m.get("pay_time").toString());
                addCell(ws, i, 7, m.get("deal_status").toString());
                addCell(ws, i, 8, m.get("pay_status").toString());
                addCell(ws, i, 7, m.get("create_time").toString());
                addCell(ws, i, 8, (String) m.get("status"));
                /*addCell(ws, i, 0, m.get("createTime").toString());
                addCell(ws, i, 1, (String) m.get("name"), "");
                addCell(ws, i, 2, (String) m.get("icd10Name"), "");

+ 8 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/MixEnvelop.java

@ -137,6 +137,14 @@ public class MixEnvelop<T, J> extends Envelop {
        return envelop;
    }
    public static MixEnvelop getPushList(String message, List list) {
        MixEnvelop envelop = new MixEnvelop();
        envelop.setMessage(message);
        envelop.setDetailModelList(list);
        envelop.setStatus(200);
        return envelop;
    }
    public static MixEnvelop getSuccessListWithPage2(String message, List mapList) {
        MixEnvelop envelop = new MixEnvelop();
        envelop.setMessage(message);

+ 1214 - 1140
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -77,30 +77,30 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    private static final Logger logger = LoggerFactory.getLogger(PrescriptionEndpoint.class);
    @Autowired
    private PrescriptionService prescriptionService;
    
    @Autowired
    private WlyyBusinessService wlyyBusinessService;
    
    @Autowired
    private PrescriptionLogService prescriptionLogService;
    
    @Autowired
    private InspectionService inspectionService;
    
    @Autowired
    private DoctorPreSignService doctorPreSignService;
    
    @Autowired
    private WorkTimeService workTimeService;
    
    @Autowired
    private ImService imService;
    
    @Autowired
    private OutpatientDao outpatientDao;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    
    @Autowired
    private BusinessOrderService businessOrderService;
    @Autowired
@ -143,7 +143,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @Value("${demo.flag}")
    private boolean demoFlag;
    
    @Value("${wechat.id}")
    private String wxId;
@ -162,322 +162,322 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = "updPrescriptionExpressage")
    @ApiOperation(value = "修改续方收货信息")
    public ObjEnvelop updPrescriptionExpressage(@ApiParam(name = "id", value = "收获信息id")
                                         @RequestParam(value = "id",required = true) String id,
                                         @ApiParam(name = "oneselfPickupFlg", value = "是否自取 1是 0否")
                                         @RequestParam(value = "oneselfPickupFlg",required = true) Integer oneselfPickupFlg,
                                         @ApiParam(name = "name", value = "收货人姓名")
                                         @RequestParam(value = "name",required = false) String name,
                                         @ApiParam(name = "mobile", value = "收货人电话")
                                             @RequestParam(value = "mobile",required = false) String mobile,
                                         @ApiParam(name = "address", value = "详细地址")
                                             @RequestParam(value = "address",required = false) String address,
                                         @ApiParam(name = "provinceCode", value = "省code")
                                             @RequestParam(value = "provinceCode",required = false) String provinceCode,
                                         @ApiParam(name = "provinceName", value = "省名称")
                                             @RequestParam(value = "provinceName",required = false) String provinceName,
                                         @ApiParam(name = "cityCode", value = "市code")
                                             @RequestParam(value = "cityCode",required = false) String cityCode,
                                         @ApiParam(name = "cityName", value = "市名称")
                                             @RequestParam(value = "cityName",required = false) String cityName,
                                         @ApiParam(name = "townCode", value = "区code")
                                             @RequestParam(value = "townCode",required = false) String townCode,
                                         @ApiParam(name = "townName", value = "区名称")
                                             @RequestParam(value = "townName",required = false) String townName,
                                         @ApiParam(name = "streetCode", value = "街道code")
                                             @RequestParam(value = "streetCode",required = false) String streetCode,
                                         @ApiParam(name = "streetName", value = "街道名称")
                                             @RequestParam(value = "streetName",required = false) String streetName){
                                                @RequestParam(value = "id", required = true) String id,
                                                @ApiParam(name = "oneselfPickupFlg", value = "是否自取 1是 0否")
                                                @RequestParam(value = "oneselfPickupFlg", required = true) Integer oneselfPickupFlg,
                                                @ApiParam(name = "name", value = "收货人姓名")
                                                @RequestParam(value = "name", required = false) String name,
                                                @ApiParam(name = "mobile", value = "收货人电话")
                                                @RequestParam(value = "mobile", required = false) String mobile,
                                                @ApiParam(name = "address", value = "详细地址")
                                                @RequestParam(value = "address", required = false) String address,
                                                @ApiParam(name = "provinceCode", value = "省code")
                                                @RequestParam(value = "provinceCode", required = false) String provinceCode,
                                                @ApiParam(name = "provinceName", value = "省名称")
                                                @RequestParam(value = "provinceName", required = false) String provinceName,
                                                @ApiParam(name = "cityCode", value = "市code")
                                                @RequestParam(value = "cityCode", required = false) String cityCode,
                                                @ApiParam(name = "cityName", value = "市名称")
                                                @RequestParam(value = "cityName", required = false) String cityName,
                                                @ApiParam(name = "townCode", value = "区code")
                                                @RequestParam(value = "townCode", required = false) String townCode,
                                                @ApiParam(name = "townName", value = "区名称")
                                                @RequestParam(value = "townName", required = false) String townName,
                                                @ApiParam(name = "streetCode", value = "街道code")
                                                @RequestParam(value = "streetCode", required = false) String streetCode,
                                                @ApiParam(name = "streetName", value = "街道名称")
                                                @RequestParam(value = "streetName", required = false) String streetName) {
        try {
            WlyyPrescriptionExpressageDO obj = prescriptionService.updPrescriptionExpressage(id, oneselfPickupFlg, name, mobile, address, provinceCode
                    , provinceName, cityCode, cityName, townCode, townName, streetCode, streetName);
            return success(obj);
        }catch (Exception e) {
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findOutpatientList)
    @ApiOperation(value = " 查询某个时间段的患者门诊就诊记录")
    public ListEnvelop findOutpatientList(@ApiParam(name = "patient", value = "居民id")
                                          @RequestParam(value = "patient",required = false) String patient,
                                          @RequestParam(value = "patient", required = false) String patient,
                                          @ApiParam(name = "startTime", value = "开始时间")
                                          @RequestParam(value = "startTime",required = false) String startTime,
                                          @RequestParam(value = "startTime", required = false) String startTime,
                                          @ApiParam(name = "endTime", value = "结束时间")
                                          @RequestParam(value = "endTime",required = false) String endTime,
                                          @RequestParam(value = "endTime", required = false) String endTime,
                                          @ApiParam(name = "ksdm", value = "科室代码")
                                              @RequestParam(value = "ksdm",required = false) String ksdm,
                                          @RequestParam(value = "ksdm", required = false) String ksdm,
                                          @ApiParam(name = "cardNo", value = "就诊卡", required = false)
                                              @RequestParam(value = "cardNo",required = false)String cardNo,
                                          @RequestParam(value = "cardNo", required = false) String cardNo,
                                          @ApiParam(name = "flag", value = "标识", required = false)
                                              @RequestParam(value = "flag",required = false)String flag) throws Exception {
                                          @RequestParam(value = "flag", required = false) String flag) throws Exception {
        try {
            if(StringUtils.isNoneBlank(startTime)){
                startTime = startTime+" 00:00:00";
            if (StringUtils.isNoneBlank(startTime)) {
                startTime = startTime + " 00:00:00";
            }
            if(StringUtils.isNoneBlank(endTime)){
                endTime =endTime+" 23:59:59";
            if (StringUtils.isNoneBlank(endTime)) {
                endTime = endTime + " 23:59:59";
            }
            List<WlyyOutpatientVO> vos = new ArrayList<>();
            if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                vos = prescriptionService.findOutpatientList(patient, startTime, endTime, demoFlag,ksdm,cardNo);
            }else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")){
                vos = tnPrescriptionService.findOutpatientList(patient, cardNo,startTime, endTime, demoFlag,ksdm,flag);
            }else if (wxId.equalsIgnoreCase("xm_hcyy_wx")){
            if (wxId.equalsIgnoreCase("xm_zsyy_wx")) {
                vos = prescriptionService.findOutpatientList(patient, startTime, endTime, demoFlag, ksdm, cardNo);
            } else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")) {
                vos = tnPrescriptionService.findOutpatientList(patient, cardNo, startTime, endTime, demoFlag, ksdm, flag);
            } else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
            }else {
            } else {
                return ListEnvelop.getError("尚未开发!");
            }
            return success(vos);
        }catch (Exception e) {
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findOutpatientInfo)
    @ApiOperation(value = " 查询单条门诊就诊记录")
    public ObjEnvelop findOutpatientInfo(@ApiParam(name = "patient", value = "居民id")
                                         @RequestParam(value = "patient",required = false) String patient,
                                         @RequestParam(value = "patient", required = false) String patient,
                                         @ApiParam(name = "conNo", value = "就诊次数")
                                         @RequestParam(value = "conNo",required = false) String conNo)throws Exception{
                                         @RequestParam(value = "conNo", required = false) String conNo) throws Exception {
        try {
            WlyyOutpatientVO obj = new WlyyOutpatientVO();
            if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                obj = prescriptionService.findOutpatientInfo(patient,conNo);
            }else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")){
                obj = tnPrescriptionService.findOutpatientInfo(patient,conNo,demoFlag,null);
            }else if (wxId.equalsIgnoreCase("xm_hcyy_wx")){
            if (wxId.equalsIgnoreCase("xm_zsyy_wx")) {
                obj = prescriptionService.findOutpatientInfo(patient, conNo);
            } else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")) {
                obj = tnPrescriptionService.findOutpatientInfo(patient, conNo, demoFlag, null);
            } else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
            }else {
            } else {
                return ObjEnvelop.getError("尚未开发!");
            }
            return success(obj);
        }catch (Exception e) {
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findOriginPrescriptionList)
    @ApiOperation(value = "门诊下所有处方信息")
    public ListEnvelop findOriginPrescriptionList(
            @ApiParam(name = "registerSn", value = "流水号")
            @RequestParam(value = "registerSn",required = false) String registerSn,
            @RequestParam(value = "registerSn", required = false) String registerSn,
            @ApiParam(name = "patNo", value = "病人id")
            @RequestParam(value = "patNo",required = false) String patNo,
            @RequestParam(value = "patNo", required = false) String patNo,
            @ApiParam(name = "admNo", value = "住院唯一号")
            @RequestParam(value = "admNo",required = false) String admNo,
            @RequestParam(value = "admNo", required = false) String admNo,
            @ApiParam(name = "realOrder", value = "处方号")
            @RequestParam(value = "realOrder",required = false) String realOrder) throws Exception {
            @RequestParam(value = "realOrder", required = false) String realOrder) throws Exception {
        try {
            List<WlyyPrescriptionVO> obj = new ArrayList<>();
            if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                obj= prescriptionService.findOriginPrescriptionList(registerSn, patNo, realOrder, admNo,demoFlag);
            }else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")){
                obj= tnPrescriptionService.findOriginPrescriptionList(registerSn, patNo, realOrder, admNo,demoFlag);
            }else if (wxId.equalsIgnoreCase("xm_hcyy_wx")){
            if (wxId.equalsIgnoreCase("xm_zsyy_wx")) {
                obj = prescriptionService.findOriginPrescriptionList(registerSn, patNo, realOrder, admNo, demoFlag);
            } else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")) {
                obj = tnPrescriptionService.findOriginPrescriptionList(registerSn, patNo, realOrder, admNo, demoFlag);
            } else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
            }else {
            } else {
                return ListEnvelop.getError("尚未开发!");
            }
            return success(obj);
        }catch (Exception e) {
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findOriginPrescription)
    @ApiOperation(value = "历史处方信息(单条)")
    public ObjEnvelop findOriginPrescription(
            @ApiParam(name = "registerSn", value = "流水号", required = false)
            @RequestParam(value = "registerSn",required = false) String registerSn,
            @RequestParam(value = "registerSn", required = false) String registerSn,
            @ApiParam(name = "patNo", value = "病人id", required = false)
            @RequestParam(value = "patNo",required = false) String patNo,
            @RequestParam(value = "patNo", required = false) String patNo,
            @ApiParam(name = "admNo", value = "住院唯一号", required = false)
            @RequestParam(value = "admNo",required = false) String admNo,
            @RequestParam(value = "admNo", required = false) String admNo,
            @ApiParam(name = "realOrder", value = "处方号", required = false)
            @RequestParam(value = "realOrder",required = false) String realOrder) throws Exception {
            @RequestParam(value = "realOrder", required = false) String realOrder) throws Exception {
        try{
            WlyyPrescriptionVO obj = prescriptionService.findOriginPrescription(registerSn, patNo, admNo,realOrder, demoFlag);
        try {
            WlyyPrescriptionVO obj = prescriptionService.findOriginPrescription(registerSn, patNo, admNo, realOrder, demoFlag);
            return success(obj);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findPrescriptionList)
    @ApiOperation(value = "获取续方记录列表", notes = "获取续方记录列表")
    public MixEnvelop<WlyyPrescriptionVO,WlyyPrescriptionVO> findPrescriptionList(@ApiParam(name = "patient", value = "居民code")
                                                                                  @RequestParam(value = "patient", required = false) String patient,
                                                                                  @ApiParam(name = "status", value = "状态,多状态‘,’分割,例如‘1,2’,‘1,2,3’")
                                                                                  @RequestParam(value = "status", required = false)String status,
                                                                                  @ApiParam(name = "startTime", value = "开始时间,‘yyyy-MM-dd’")
                                                                                  @RequestParam(value = "startTime", required = false)String startTime,
                                                                                  @ApiParam(name = "endTime", value = "结束时间,yyyy-MM-dd’")
                                                                                  @RequestParam(value = "endTime", required = false)String endTime,
                                                                                  @ApiParam(name = "page", value = "第几页,1开始’")
                                                                                  @RequestParam(value = "page", required = false)Integer page,
                                                                                  @ApiParam(name = "size", value = "每页大小")
                                                                                  @RequestParam(value = "size", required = true) Integer size) {
        try {
            return prescriptionService.findPrescriptionList(patient,status,startTime,endTime,page,size,wxId);
    public MixEnvelop<WlyyPrescriptionVO, WlyyPrescriptionVO> findPrescriptionList(@ApiParam(name = "patient", value = "居民code")
                                                                                   @RequestParam(value = "patient", required = false) String patient,
                                                                                   @ApiParam(name = "status", value = "状态,多状态‘,’分割,例如‘1,2’,‘1,2,3’")
                                                                                   @RequestParam(value = "status", required = false) String status,
                                                                                   @ApiParam(name = "startTime", value = "开始时间,‘yyyy-MM-dd’")
                                                                                   @RequestParam(value = "startTime", required = false) String startTime,
                                                                                   @ApiParam(name = "endTime", value = "结束时间,yyyy-MM-dd’")
                                                                                   @RequestParam(value = "endTime", required = false) String endTime,
                                                                                   @ApiParam(name = "page", value = "第几页,1开始’")
                                                                                   @RequestParam(value = "page", required = false) Integer page,
                                                                                   @ApiParam(name = "size", value = "每页大小")
                                                                                   @RequestParam(value = "size", required = true) Integer size) {
        try {
            return prescriptionService.findPrescriptionList(patient, status, startTime, endTime, page, size, wxId);
        } catch (Exception e) {
            return failedMixEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findReOutpatientList)
    @ApiOperation(value = "查询复诊记录列表", notes = "查询复诊记录列表")
    public MixEnvelop<WlyyOutpatientVO,WlyyOutpatientVO> findReOutpatientList(@ApiParam(name = "patient", value = "居民code")
                                                                              @RequestParam(value = "patient", required = true) String patient,
                                                                              @ApiParam(name = "status", value = "状态:-1取消,0候诊中,1就诊中,2已完成")
                                                                              @RequestParam(value = "status", required = false) Integer status,
                                                                              @ApiParam(name = "startTime", value = "开始时间,‘yyyy-MM-dd’")
                                                                              @RequestParam(value = "startTime", required = false)String startTime,
                                                                              @ApiParam(name = "endTime", value = "结束时间,yyyy-MM-dd’")
                                                                              @RequestParam(value = "endTime", required = false)String endTime,
                                                                              @ApiParam(name = "outpatientType", value = "1复诊2协同3咨询")
                                                                                  @RequestParam(value = "outpatientType", required = false)String outpatientType,
                                                                              @ApiParam(name = "page", value = "第几页,1开始’")
                                                                              @RequestParam(value = "page", required = false)Integer page,
                                                                              @ApiParam(name = "size", value = "每页大小")
                                                                              @RequestParam(value = "size", required = true) Integer size) {
        try {
            return prescriptionService.findReOutpatientList(patient,status,startTime,endTime,outpatientType,page,size);
        }catch (Exception e) {
    public MixEnvelop<WlyyOutpatientVO, WlyyOutpatientVO> findReOutpatientList(@ApiParam(name = "patient", value = "居民code")
                                                                               @RequestParam(value = "patient", required = true) String patient,
                                                                               @ApiParam(name = "status", value = "状态:-1取消,0候诊中,1就诊中,2已完成")
                                                                               @RequestParam(value = "status", required = false) Integer status,
                                                                               @ApiParam(name = "startTime", value = "开始时间,‘yyyy-MM-dd’")
                                                                               @RequestParam(value = "startTime", required = false) String startTime,
                                                                               @ApiParam(name = "endTime", value = "结束时间,yyyy-MM-dd’")
                                                                               @RequestParam(value = "endTime", required = false) String endTime,
                                                                               @ApiParam(name = "outpatientType", value = "1复诊2协同3咨询")
                                                                               @RequestParam(value = "outpatientType", required = false) String outpatientType,
                                                                               @ApiParam(name = "page", value = "第几页,1开始’")
                                                                               @RequestParam(value = "page", required = false) Integer page,
                                                                               @ApiParam(name = "size", value = "每页大小")
                                                                               @RequestParam(value = "size", required = true) Integer size) {
        try {
            return prescriptionService.findReOutpatientList(patient, status, startTime, endTime, outpatientType, page, size);
        } catch (Exception e) {
            return failedMixEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findReOutpatientInfo)
    @ApiOperation(value = "查询复诊记录,处方,居民信息,物流(单条)", notes = "查询复诊记录,处方,居民信息,物流(单条)")
    public ObjEnvelop findReOutpatientInfo(@ApiParam(name = "outpatientId", value = "复诊ID")
                                           @RequestParam(value = "outpatientId", required = true) String outpatientId,
                                           @ApiParam(name = "prescriptionId", value = "处方ID")
                                           @RequestParam(value = "prescriptionId", required = false) String prescriptionId)throws Exception{
                                           @RequestParam(value = "prescriptionId", required = false) String prescriptionId) throws Exception {
        try {
            com.alibaba.fastjson.JSONObject obj =  prescriptionService.findReOutpatientInfo(outpatientId,prescriptionId,wxId);
            com.alibaba.fastjson.JSONObject obj = prescriptionService.findReOutpatientInfo(outpatientId, prescriptionId, wxId);
            return success(obj);
        }catch (Exception e) {
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findPrescriptionInfo)
    @ApiOperation(value = "获取所有居民相关信息,续方信息,物流信息,药品信息(单条)", notes = "获取所有居民相关信息,续方信息,物流信息,药品信息(单条)")
    public ObjEnvelop<Map<String,Object>> findPrescriptionInfo(@ApiParam(name = "prescriptionId", value = "续方明细")
                                                               @RequestParam(value = "prescriptionId", required = false) String prescriptionId) {
    public ObjEnvelop<Map<String, Object>> findPrescriptionInfo(@ApiParam(name = "prescriptionId", value = "续方明细")
                                                                @RequestParam(value = "prescriptionId", required = false) String prescriptionId) {
        try {
            return success(BaseHospitalRequestMapping.Prescription.api_success,prescriptionService.findPrescriptionInfo(prescriptionId));
        }catch (Exception e) {
            return success(BaseHospitalRequestMapping.Prescription.api_success, prescriptionService.findPrescriptionInfo(prescriptionId));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.checkPrescription)
    @ApiOperation(value = "判断是否可续方,true 可以,false不可以", notes = "判断是否可续方,true 可以,false不可以")
    public ObjEnvelop<Boolean> checkPrescription(@ApiParam(name = "patient", value = "续方明细")
                                                 @RequestParam(value = "patient", required = false) String patient) {
        
        try {
            return success(BaseHospitalRequestMapping.Prescription.api_success,prescriptionService.checkPrescription(patient));
        }catch (Exception e) {
            return success(BaseHospitalRequestMapping.Prescription.api_success, prescriptionService.checkPrescription(patient));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.cancelPrescription)
    @ApiOperation(value = "居民取消续方", notes = "居民取消续方")
    public ObjEnvelop<Boolean> cancelPrescription(@ApiParam(name = "prescriptionId", value = "续方ID")
                                                  @RequestParam(value = "prescriptionId", required = false) String prescriptionId) {
        
        try {
            return success(BaseHospitalRequestMapping.Prescription.api_success,prescriptionService.cancelPrescription(prescriptionId));
        }catch (Exception e) {
            return success(BaseHospitalRequestMapping.Prescription.api_success, prescriptionService.cancelPrescription(prescriptionId));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findPatientCard)
    @ApiOperation(value = "查询患者就诊卡", notes = "查询患者就诊卡")
    public ListEnvelop findPatientCard(@ApiParam(name = "patient", value = "居民Code")
                                       @RequestParam(value = "patient", required = true)String patient)throws Exception {
                                       @RequestParam(value = "patient", required = true) String patient) throws Exception {
        try {
            if ("xm_zsyy_wx".equalsIgnoreCase(wxId)){
            if ("xm_zsyy_wx".equalsIgnoreCase(wxId)) {
                return success(prescriptionService.findPatientCard(patient));
            }else if ("xm_hcyy_wx".equalsIgnoreCase(wxId)){
            } else if ("xm_hcyy_wx".equalsIgnoreCase(wxId)) {
                String result = hcyyEntranceService.findPatientCard(patient);
                JSONArray jsonArray = new JSONArray();
                if (result!=null&&result!=""){
                if (result != null && result != "") {
                    JSONArray array = JSONArray.parseArray(result);
                    if (array!=null&&array.size()!=0){
                    if (array != null && array.size() != 0) {
                        jsonArray = array.getJSONArray(0);
                    }
                }
                return success(jsonArray);
            }else if ("xm_tasy_wx".equalsIgnoreCase(wxId)){
            } else if ("xm_tasy_wx".equalsIgnoreCase(wxId)) {
                return success(tasyNatService.findPatientCard(patient));
            }else {
            } else {
                return ListEnvelop.getError("暂未开放");
            }
        }catch (Exception e) {
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.checkOutpatient)
    @ApiOperation(value = "判断是否可用发起门诊", notes = "判断是否可用发起门诊")
    public ObjEnvelop checkOutpatient(@ApiParam(name = "patient", value = "续方明细")
                                      @RequestParam(value = "patient", required = true)String patient,
                                      @RequestParam(value = "patient", required = true) String patient,
                                      @ApiParam(name = "flag", value = "标识是否开启结算")
                                      @RequestParam(value = "flag", required = false)boolean flag,
                                      @RequestParam(value = "flag", required = false) boolean flag,
                                      @ApiParam(name = "outpatientType", value = "1在线复诊 2 协同 3 专家咨询")
                                          @RequestParam(value = "outpatientType", required = false)String outpatientType)throws Exception{
                                      @RequestParam(value = "outpatientType", required = false) String outpatientType) throws Exception {
        try {
            return success(prescriptionService.checkOutpatient(patient,wxId,flag,outpatientType));
        }catch (Exception e) {
            return success(prescriptionService.checkOutpatient(patient, wxId, flag, outpatientType));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findAllHospital)
    @ApiOperation(value = "查询所有机构", notes = "查询所有机构")
    public ListEnvelop findAllHospital(@ApiParam(name = "level", value = "医院等级")
                                       @RequestParam(value = "level", required = false)Integer level,
                                       @RequestParam(value = "level", required = false) Integer level,
                                       @ApiParam(name = "keyWord", value = "名字关键字")
                                       @RequestParam(value = "keyWord", required = false)String keyWord) {
                                       @RequestParam(value = "keyWord", required = false) String keyWord) {
        try {
            return success(prescriptionService.findAllHospital(level,keyWord));
        }catch (Exception e) {
            return success(prescriptionService.findAllHospital(level, keyWord));
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDeptByHospital)
    @ApiOperation(value = "查询机构底下部门", notes = "查询机构底下部门")
    public ListEnvelop findDeptByHospital(@ApiParam(name = "orgCode", value = "机构code")
                                          @RequestParam(value = "orgCode", required = true)String orgCode,
                                          @RequestParam(value = "orgCode", required = true) String orgCode,
                                          @ApiParam(name = "dept", value = "需要置顶部门")
                                          @RequestParam(value = "dept", required = false)String dept,
                                          @RequestParam(value = "dept", required = false) String dept,
                                          @ApiParam(name = "consultDeptFlag", value = "1为查询开通服务部门")
                                          @RequestParam(value = "consultDeptFlag", required = false)String consultDeptFlag) {
                                          @RequestParam(value = "consultDeptFlag", required = false) String consultDeptFlag) {
        try {
            return success(prescriptionService.findDeptByHospital(orgCode,dept,consultDeptFlag));
        }catch (Exception e) {
            return success(prescriptionService.findDeptByHospital(orgCode, dept, consultDeptFlag));
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
@ -486,13 +486,13 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDeptDescByDeptCodeAndOrgCode)
    @ApiOperation(value = "查询科室介绍", notes = "查询科室介绍")
    public MixEnvelop findDeptDesc(@ApiParam(name = "orgCode", value = "机构code")
                                          @RequestParam(value = "orgCode", required = true)String orgCode,
                                          @ApiParam(name = "deptCode", value = "部门code")
                                          @RequestParam(value = "deptCode", required = true)String deptCode) {
                                   @RequestParam(value = "orgCode", required = true) String orgCode,
                                   @ApiParam(name = "deptCode", value = "部门code")
                                   @RequestParam(value = "deptCode", required = true) String deptCode) {
        try {
            return prescriptionService.findDeptDesc(orgCode,deptCode);
        }catch (Exception e) {
            return prescriptionService.findDeptDesc(orgCode, deptCode);
        } catch (Exception e) {
            return failedMixEnvelopException(e);
        }
    }
@ -501,200 +501,200 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDeptByOrgCode)
    @ApiOperation(value = "查询机构下所有科室", notes = "查询机构下所有科室")
    public MixEnvelop findDeptByOrgCode(@ApiParam(name = "orgCode", value = "机构code")
                                   @RequestParam(value = "orgCode", required = true)String orgCode,
                                        @RequestParam(value = "orgCode", required = true) String orgCode,
                                        @ApiParam(name = "keyName", value = "关键字")
                                        @RequestParam(value = "keyName", required = false)String keyName) {
                                        @RequestParam(value = "keyName", required = false) String keyName) {
        try {
            return prescriptionService.findDeptByOrgCode(orgCode,keyName);
        }catch (Exception e) {
            return prescriptionService.findDeptByOrgCode(orgCode, keyName);
        } catch (Exception e) {
            return failedMixEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDeptByKeyWord)
    @ApiOperation(value = "查询有所有已开放的科室", notes = "查询有所有已开放的科室")
    public ListEnvelop findDeptByKeyWord(@ApiParam(name = "keyWord", value = "关键字")
                                         @RequestParam(value = "keyWord", required = false)String keyWord,
                                         @RequestParam(value = "keyWord", required = false) String keyWord,
                                         @ApiParam(name = "page", value = "第几页")
                                         @RequestParam(value = "page",required = true) Integer page,
                                         @RequestParam(value = "page", required = true) Integer page,
                                         @ApiParam(name = "pagesize", value = "分页大小")
                                         @RequestParam(value = "pagesize",required = true) Integer pagesize) {
                                         @RequestParam(value = "pagesize", required = true) Integer pagesize) {
        try {
            return success(prescriptionService.findDeptByKeyWord(keyWord,page,pagesize));
        }catch (Exception e) {
            return success(prescriptionService.findDeptByKeyWord(keyWord, page, pagesize));
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDoctorByHospitalAndDept)
    @ApiOperation(value = "查询部门下医生", notes = "查询部门下医生")
    public ListEnvelop findDoctorByHospitalAndDept(@ApiParam(name = "orgCode", value = "机构code")
                                                   @RequestParam(value = "orgCode", required = false)String orgCode,
                                                   @RequestParam(value = "orgCode", required = false) String orgCode,
                                                   @ApiParam(name = "dept", value = "部门code")
                                                   @RequestParam(value = "dept", required = false)String dept,
                                                   @RequestParam(value = "dept", required = false) String dept,
                                                   @ApiParam(name = "chargeType", value = "号别")
                                                   @RequestParam(value = "chargeType", required = false)String chargeType,
                                                   @RequestParam(value = "chargeType", required = false) String chargeType,
                                                   @ApiParam(name = "doctorCode", value = "需要置顶医生")
                                                   @RequestParam(value = "doctorCode", required = false)String doctorCode,
                                                   @RequestParam(value = "doctorCode", required = false) String doctorCode,
                                                   @ApiParam(name = "outpatientType", value = "1图文,2视频")
                                                   @RequestParam(value = "outpatientType", required = false)String outpatientType,
                                                   @RequestParam(value = "outpatientType", required = false) String outpatientType,
                                                   @ApiParam(name = "startDate", value = "开始时间,yyyy-MM-dd HH:mm:ss")
                                                   @RequestParam(value = "startDate", required = false)String startDate,
                                                   @RequestParam(value = "startDate", required = false) String startDate,
                                                   @ApiParam(name = "endDate", value = "结束时间,yyyy-MM-dd HH:mm:ss")
                                                   @RequestParam(value = "endDate", required = false)String endDate,
                                                   @RequestParam(value = "endDate", required = false) String endDate,
                                                   @ApiParam(name = "key", value = "关键字搜索,医生名字/科室名称/专长")
                                                   @RequestParam(value = "key", required = false)String key,
                                                   @RequestParam(value = "key", required = false) String key,
                                                   @ApiParam(name = "consultStatus", value = "是否在线")
                                                   @RequestParam(value = "consultStatus", required = false)String consultStatus) {
                                                   @RequestParam(value = "consultStatus", required = false) String consultStatus) {
        try {
            return success(prescriptionService.findDoctorByHospitalAndDept(orgCode,dept,chargeType,doctorCode,outpatientType,startDate,endDate,key,consultStatus));
        }catch (Exception e) {
            return success(prescriptionService.findDoctorByHospitalAndDept(orgCode, dept, chargeType, doctorCode, outpatientType, startDate, endDate, key, consultStatus));
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.appointmentRevisit)
    @ApiOperation(value = "居民发起复诊", notes = "居民发起复诊")
    public ObjEnvelop appointmentRevisit(@ApiParam(name = "outpatientJson", value = "居民门诊json")
                                         @RequestParam(value = "outpatientJson", required = false)String outpatientJson,
                                         @RequestParam(value = "outpatientJson", required = false) String outpatientJson,
                                         @ApiParam(name = "expressageJson", value = "居民物流json")
                                         @RequestParam(value = "expressageJson", required = false)String expressageJson,
                                         @RequestParam(value = "expressageJson", required = false) String expressageJson,
                                         @ApiParam(name = "registerJson", value = "预约时间")
                                         @RequestParam(value = "registerJson", required = false)String registerJson,
                                         @RequestParam(value = "registerJson", required = false) String registerJson,
                                         @ApiParam(name = "chargeType", value = "预约实体json")
                                         @RequestParam(value = "chargeType", required = false)String chargeType)throws Exception {
        
                                         @RequestParam(value = "chargeType", required = false) String chargeType) throws Exception {
        try {
            WlyyOutpatientDO wlyyOutpatientDO = prescriptionService.appointmentRevisit(outpatientJson,expressageJson,registerJson,chargeType);
            if (wlyyOutpatientDO!=null&&null==wlyyOutpatientDO.getId()&&!wlyyOutpatientDO.getOutpatientType().equalsIgnoreCase("3")){
                ObjEnvelop objEnvelop =new ObjEnvelop();
            WlyyOutpatientDO wlyyOutpatientDO = prescriptionService.appointmentRevisit(outpatientJson, expressageJson, registerJson, chargeType);
            if (wlyyOutpatientDO != null && null == wlyyOutpatientDO.getId() && !wlyyOutpatientDO.getOutpatientType().equalsIgnoreCase("3")) {
                ObjEnvelop objEnvelop = new ObjEnvelop();
                String msg = "";
                if (1==wlyyOutpatientDO.getRemindCount()){
                if (1 == wlyyOutpatientDO.getRemindCount()) {
                    msg = "自取";
                }else {
                } else {
                    msg = "快递配送";
                }
                objEnvelop.setMessage("您已经选择过"+msg+"方式,请勿修改");
                objEnvelop.setMessage("您已经选择过" + msg + "方式,请勿修改");
                objEnvelop.setStatus(300);
                return objEnvelop;
            }else {
            } else {
                BaseDoctorDO doctorDO = baseDoctorDao.findById(wlyyOutpatientDO.getDoctor());
                if (wlyyOutpatientDO.getPayStatus()!=null&&wlyyOutpatientDO.getPayStatus()==1){
                if (wlyyOutpatientDO.getPayStatus() != null && wlyyOutpatientDO.getPayStatus() == 1) {
                    //发送系统消息
                    SystemMessageDO systemMessageDO = prescriptionService.sendOutPatientMes(wlyyOutpatientDO,payFlag);
                    SystemMessageDO systemMessageDO = prescriptionService.sendOutPatientMes(wlyyOutpatientDO, payFlag);
                    //发送IM消息
                    hospitalSystemMessageService.sendImMessage(systemMessageDO);
                }
                //发送医生抢单消息
                if(StringUtils.isBlank(wlyyOutpatientDO.getDoctor())){
                if (StringUtils.isBlank(wlyyOutpatientDO.getDoctor())) {
                    hospitalSystemMessageService.sendImPichCheckMessage(wlyyOutpatientDO);
                }
                if(!"zsyy".equals(qywxId) && !"xm_xzzx_wx".equals(qywxId)){
                if (!"zsyy".equals(qywxId) && !"xm_xzzx_wx".equals(qywxId)) {
                    //发送厦门i健康智能推送
                    try{
                        if (doctorDO!=null&&"3".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())){
                            String wxurl = wlyyUrl+"/im/common/message/sendDoctorTemplateByDoctorIdcard?sessionId=1_1&sessionType=1&from=1&content=1&businessType=new&doctor_idcard="+doctorDO.getIdcard()+"&patientName="+URLEncoder.encode(wlyyOutpatientDO.getPatientName())+"&url=1";
                            logger.info("发送厦门i健康智能推送url:"+wxurl);
                    try {
                        if (doctorDO != null && "3".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())) {
                            String wxurl = wlyyUrl + "/im/common/message/sendDoctorTemplateByDoctorIdcard?sessionId=1_1&sessionType=1&from=1&content=1&businessType=new&doctor_idcard=" + doctorDO.getIdcard() + "&patientName=" + URLEncoder.encode(wlyyOutpatientDO.getPatientName()) + "&url=1";
                            logger.info("发送厦门i健康智能推送url:" + wxurl);
                            wlyyBusinessService.sendDoctorTemplateByDoctorIdcard(wxurl);
                        }
                    }catch (Exception e){
                        logger.info("发送厦门i健康智能失败"+e.toString());
                    } catch (Exception e) {
                        logger.info("发送厦门i健康智能失败" + e.toString());
                    }
                }
                return success(BaseHospitalRequestMapping.Prescription.api_success,wlyyOutpatientDO);
                return success(BaseHospitalRequestMapping.Prescription.api_success, wlyyOutpatientDO);
            }
        }catch (Exception e) {
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getICD10)
    @ApiOperation(value = "获取ICD10诊断编码", notes = "获取ICD10诊断编码")
    public ListEnvelop getICD10(@ApiParam(name = "pyKey", value = "拼音关键字")
                                @RequestParam(value = "pyKey", required = false)String pyKey)throws Exception {
        if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                                @RequestParam(value = "pyKey", required = false) String pyKey) throws Exception {
        if (wxId.equalsIgnoreCase("xm_zsyy_wx")) {
            return success(prescriptionService.getICD10(pyKey));
        }else if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
        } else if (wxId.equalsIgnoreCase("xm_xzzx_wx")) {
            return success(xzzxEntranceService.selectIcd10Dict(pyKey));
        }else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")){
            return success(tnPrescriptionService.getICD10(pyKey,false));
        }else if (wxId.equalsIgnoreCase("xm_hcyy_wx")){
        } else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")) {
            return success(tnPrescriptionService.getICD10(pyKey, false));
        } else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
            ListEnvelop listEnvelop = new ListEnvelop();
            return listEnvelop;
        }else {
        } else {
            return ListEnvelop.getError("尚未开发!");
        }
        
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getDrugDictionary)
    @ApiOperation(value = "获取药品字典", notes = "获取药品字典")
    public ListEnvelop getDrugDictionary(@ApiParam(name = "drugNo", value = "药品编码")
                                         @RequestParam(value = "drugNo", required = false)String drugNo,
                                         @RequestParam(value = "drugNo", required = false) String drugNo,
                                         @ApiParam(name = "pyKey", value = "拼音关键字")
                                         @RequestParam(value = "pyKey", required = false)String pyKey,
                                         @RequestParam(value = "pyKey", required = false) String pyKey,
                                         @ApiParam(name = "winNo", value = "分部编码")
                                         @RequestParam(value = "winNo", required = false)String winNo,
                                         @RequestParam(value = "winNo", required = false) String winNo,
                                         @ApiParam(name = "groupNo", value = "药房编码")
                                         @RequestParam(value = "groupNo", required = false)String groupNo)throws Exception {
        if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
            return success(prescriptionService.getDrugDictionary(drugNo,pyKey,winNo,groupNo));
        }else if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
            return success(xzzxEntranceService.selectDrugDict(pyKey,drugNo));
        }else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")){
            return success(tnPrescriptionService.getDrugDictionary(drugNo,pyKey,null,groupNo,null));
        }else if (wxId.equalsIgnoreCase("xm_hcyy_wx")){
                                         @RequestParam(value = "groupNo", required = false) String groupNo) throws Exception {
        if (wxId.equalsIgnoreCase("xm_zsyy_wx")) {
            return success(prescriptionService.getDrugDictionary(drugNo, pyKey, winNo, groupNo));
        } else if (wxId.equalsIgnoreCase("xm_xzzx_wx")) {
            return success(xzzxEntranceService.selectDrugDict(pyKey, drugNo));
        } else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")) {
            return success(tnPrescriptionService.getDrugDictionary(drugNo, pyKey, null, groupNo, null));
        } else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
            ListEnvelop listEnvelop = new ListEnvelop();
            return listEnvelop;
        }else {
        } else {
            return ListEnvelop.getError("尚未开发!");
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getDrugUse)
    @ApiOperation(value = "获取用法", notes = "获取用法")
    public ListEnvelop getDrugUse(@ApiParam(name = "pyKey", value = "拼音关键字")
                                  @RequestParam(value = "pyKey", required = false)String pyKey,
                                  @RequestParam(value = "pyKey", required = false) String pyKey,
                                  @ApiParam(name = "drugNo", value = "药品编码")
                                  @RequestParam(value = "drugNo", required = false)String drugNo)throws Exception {
                                  @RequestParam(value = "drugNo", required = false) String drugNo) throws Exception {
        if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
            return success(prescriptionService.getDrugUse(drugNo,pyKey));
        }else if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
        if (wxId.equalsIgnoreCase("xm_zsyy_wx")) {
            return success(prescriptionService.getDrugUse(drugNo, pyKey));
        } else if (wxId.equalsIgnoreCase("xm_xzzx_wx")) {
            return success(xzzxEntranceService.selectMedicineUsed(pyKey));
        }else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")){
            return success(tnPrescriptionService.getDrugUse(pyKey,demoFlag));
        }else if (wxId.equalsIgnoreCase("xm_hcyy_wx")){
        } else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")) {
            return success(tnPrescriptionService.getDrugUse(pyKey, demoFlag));
        } else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
            ListEnvelop listEnvelop = new ListEnvelop();
            return listEnvelop;
        }else {
        } else {
            return ListEnvelop.getError("尚未开发!");
        }
        
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getDrugFrequency)
    @ApiOperation(value = "获取用药频次", notes = "获取用药频次")
    public ListEnvelop getDrugFrequency()throws Exception {
    public ListEnvelop getDrugFrequency() throws Exception {
        if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
        if (wxId.equalsIgnoreCase("xm_zsyy_wx")) {
            return success(prescriptionService.getDrugFrequency());
        }else if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
        } else if (wxId.equalsIgnoreCase("xm_xzzx_wx")) {
            return success(xzzxEntranceService.selectFrequencyDict());
        }else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")){
        } else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")) {
            return success(tnPrescriptionService.getDrugFrequency(demoFlag));
        }else if (wxId.equalsIgnoreCase("xm_hcyy_wx")){
        } else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
            ListEnvelop listEnvelop = new ListEnvelop();
            return listEnvelop;
        }else {
        } else {
            return ListEnvelop.getError("尚未开发!");
        }
    }
@ -702,39 +702,39 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.deletePrescriptionByid)
    @ApiOperation(value = "删除处方草稿", notes = "删除处方草稿")
    public Envelop deletePrescription(@ApiParam(name = "id", value = "处方id")
                                              @RequestParam(value = "id", required = true)String id)throws Exception {
                                      @RequestParam(value = "id", required = true) String id) throws Exception {
        try{
        try {
            return success(prescriptionService.deletePrescription(id));
        }catch (Exception e) {
        } catch (Exception e) {
            return failedException(e);
        }
    }
    
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.makeDiagnosis)
    @ApiOperation(value = "下诊断", notes = "下诊断接口")
    public ObjEnvelop makeDiagnosis(@ApiParam(name = "outPatientId", value = "门诊编号")
                                    @RequestParam(value = "outPatientId", required = true)String outPatientId,
                                    @RequestParam(value = "outPatientId", required = true) String outPatientId,
                                    @ApiParam(name = "advice", value = "医嘱")
                                    @RequestParam(value = "advice", required = false)String advice,
                                    @RequestParam(value = "advice", required = false) String advice,
                                    @ApiParam(name = "type", value = "1需要提交his,2不提交只下诊断")
                                    @RequestParam(value = "type", required = true)String type,
                                    @RequestParam(value = "type", required = true) String type,
                                    @ApiParam(name = "infoJsons", value = "药品json")
                                    @RequestParam(value = "infoJsons", required = false)String infoJsons,
                                    @RequestParam(value = "infoJsons", required = false) String infoJsons,
                                    @ApiParam(name = "diagnosisJson", value = "诊断json")
                                    @RequestParam(value = "diagnosisJson", required = true)String diagnosisJson,
                                    @RequestParam(value = "diagnosisJson", required = true) String diagnosisJson,
                                    @ApiParam(name = "inspectionJson", value = "检查检验")
                                    @RequestParam(value = "inspectionJson", required = false)String inspectionJson,
                                    @RequestParam(value = "inspectionJson", required = false) String inspectionJson,
                                    @ApiParam(name = "emrJson", value = "电子病历")
                                        @RequestParam(value = "emrJson", required = false)String emrJson,
                                    @RequestParam(value = "emrJson", required = false) String emrJson,
                                    @ApiParam(name = "prescriptionId", value = "处方id")
                                        @RequestParam(value = "prescriptionId", required = false)String prescriptionId,
                                    @RequestParam(value = "prescriptionId", required = false) String prescriptionId,
                                    @ApiParam(name = "hisId", value = "审方唯一标识")
                                        @RequestParam(value = "hisId", required = false)String hisId,
                                    @RequestParam(value = "hisId", required = false) String hisId,
                                    @ApiParam(name = "orderId", value = "上门服务订单号")
                                        @RequestParam(value = "orderId", required = false)String orderId)throws Exception {
        Map<String,Object> result = prescriptionService.makeDiagnosis(outPatientId,prescriptionId,advice,type,infoJsons,diagnosisJson,inspectionJson,emrJson,hisId);
                                    @RequestParam(value = "orderId", required = false) String orderId) throws Exception {
        Map<String, Object> result = prescriptionService.makeDiagnosis(outPatientId, prescriptionId, advice, type, infoJsons, diagnosisJson, inspectionJson, emrJson, hisId);
        try {
            com.alibaba.fastjson.JSONObject msgObj = new com.alibaba.fastjson.JSONObject();
@ -742,198 +742,234 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            List<WlyyPrescriptionDiagnosisDO> diagnosisDOs = (List<WlyyPrescriptionDiagnosisDO>) com.alibaba.fastjson.JSONArray.parseArray(diagnosisJson, WlyyPrescriptionDiagnosisDO.class);
            String zd_str = "";
            String jl_str = advice;
            for(WlyyPrescriptionDiagnosisDO diagnosisDO:diagnosisDOs){
                if("1".equals(diagnosisDO.getType())){
                    zd_str+=diagnosisDO.getName()+","+zd_str;
                }else {
                    zd_str+=diagnosisDO.getName()+",";
            for (WlyyPrescriptionDiagnosisDO diagnosisDO : diagnosisDOs) {
                if ("1".equals(diagnosisDO.getType())) {
                    zd_str += diagnosisDO.getName() + "," + zd_str;
                } else {
                    zd_str += diagnosisDO.getName() + ",";
                }
            }
            zd_str = zd_str.substring(0,zd_str.length()-1);
            msgObj.put("zd",zd_str);
            msgObj.put("jl",jl_str);
            msgObj.put("outpatientid",outPatientId);
            zd_str = zd_str.substring(0, zd_str.length() - 1);
            msgObj.put("zd", zd_str);
            msgObj.put("jl", jl_str);
            msgObj.put("outpatientid", outPatientId);
            WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findOne(outPatientId);
            String immsg = imService.pushHuiZhenMsg(msgObj,wlyyOutpatientDO.getDoctor(),wlyyOutpatientDO.getDoctorName(),outPatientId,wlyyOutpatientDO.getPatient(),wlyyOutpatientDO.getOutpatientType());
            System.out.println("发送诊断消息成功:"+immsg);
            if (result.get("prescriptionId")!=null&&StringUtils.isNoneBlank(orderId)){
              prescriptionService.savePrescriptionToDoorService(orderId,result.get("prescriptionId").toString());
            String immsg = imService.pushHuiZhenMsg(msgObj, wlyyOutpatientDO.getDoctor(), wlyyOutpatientDO.getDoctorName(), outPatientId, wlyyOutpatientDO.getPatient(), wlyyOutpatientDO.getOutpatientType());
            System.out.println("发送诊断消息成功:" + immsg);
            if (result.get("prescriptionId") != null && StringUtils.isNoneBlank(orderId)) {
                prescriptionService.savePrescriptionToDoorService(orderId, result.get("prescriptionId").toString());
            }
        }catch (Exception e){
            System.out.println("发送诊断消息失败:"+e.getMessage());
        } catch (Exception e) {
            System.out.println("发送诊断消息失败:" + e.getMessage());
//            e.printStackTrace();
        }
        return success(result);
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findExpressageList)
    @ApiOperation(value = "获取订单列表", notes = "获取订单列表")
    public MixEnvelop findExpressageList(@ApiParam(name = "status", value = "流程状态,多状态用‘,’分割")
                                         @RequestParam(value = "status", required = false)String status,
                                         @RequestParam(value = "status", required = false) String status,
                                         @ApiParam(name = "oneselfPickupFlg", value = "是否自取 1是 0否")
                                         @RequestParam(value = "oneselfPickupFlg", required = false)String oneselfPickupFlg,
                                         @RequestParam(value = "oneselfPickupFlg", required = false) String oneselfPickupFlg,
                                         @ApiParam(name = "nameKey", value = "配送员名称")
                                         @RequestParam(value = "nameKey", required = false)String nameKey,
                                         @RequestParam(value = "nameKey", required = false) String nameKey,
                                         @ApiParam(name = "patientName", value = "就诊人")
                                             @RequestParam(value = "patientName", required = false)String patientName,
                                         @RequestParam(value = "patientName", required = false) String patientName,
                                         @ApiParam(name = "startTime", value = "开始时间,yyyy-MM-dd")
                                         @RequestParam(value = "startTime", required = false)String startTime,
                                         @RequestParam(value = "startTime", required = false) String startTime,
                                         @ApiParam(name = "endTime", value = "结束时间,yyyy-MM-dd")
                                         @RequestParam(value = "endTime", required = false)String endTime,
                                         @RequestParam(value = "endTime", required = false) String endTime,
                                         @ApiParam(name = "page", value = "第几页,1开始")
                                         @RequestParam(value = "page", required = false)Integer page,
                                         @RequestParam(value = "page", required = false) Integer page,
                                         @ApiParam(name = "size", value = "每页大小")
                                         @RequestParam(value = "size", required = false)Integer size) {
                                         @RequestParam(value = "size", required = false) Integer size) {
        try {
            return prescriptionService.findExpressageList(status,oneselfPickupFlg,nameKey,startTime,endTime,page,size,wxId,patientName);
        }catch (Exception e) {
            return prescriptionService.findExpressageList(status, oneselfPickupFlg, nameKey, startTime, endTime, page, size, wxId, patientName);
        } catch (Exception e) {
            return failedMixEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.setMailno)
    @ApiOperation(value = "设置订单编号", notes = "设置订单编号")
    public ObjEnvelop setMailno(@ApiParam(name = "mailno", value = "订单号")
                                @RequestParam(value = "mailno", required = false)String mailno,
                                @RequestParam(value = "mailno", required = false) String mailno,
                                @ApiParam(name = "expressageId", value = "订单id")
                                @RequestParam(value = "expressageId", required = false)String expressageId) {
                                @RequestParam(value = "expressageId", required = false) String expressageId) {
        try{
            return success(prescriptionService.setMailno(mailno,expressageId));
        }catch (Exception e) {
        try {
            return success(prescriptionService.setMailno(mailno, expressageId));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.pushListWrite)
    @ApiOperation(value = "订单导出", notes = "订单导出")
    public void pushListWrite(@ApiParam(name = "status", value = "流程状态,多状态用‘,’分割")
                              @RequestParam(value = "status", required = false)String status,
                              @RequestParam(value = "status", required = false) String status,
                              @ApiParam(name = "oneselfPickupFlg", value = "是否自取 1是 0否")
                              @RequestParam(value = "oneselfPickupFlg", required = false)String oneselfPickupFlg,
                              @RequestParam(value = "oneselfPickupFlg", required = false) String oneselfPickupFlg,
                              @ApiParam(name = "nameKey", value = "配送员名称")
                              @RequestParam(value = "nameKey", required = false)String nameKey,
                              @RequestParam(value = "nameKey", required = false) String nameKey,
                              @ApiParam(name = "patientName", value = "就诊人姓名")
                              @RequestParam(value = "patientName", required = false)String patientName,
                              @RequestParam(value = "patientName", required = false) String patientName,
                              @ApiParam(name = "startTime", value = "开始时间,yyyy-MM-dd")
                              @RequestParam(value = "startTime", required = false)String startTime,
                              @RequestParam(value = "startTime", required = false) String startTime,
                              @ApiParam(name = "endTime", value = "结束时间,yyyy-MM-dd")
                              @RequestParam(value = "endTime", required = false)String endTime,
                              HttpServletResponse response) throws Exception{
        MixEnvelop expressages = prescriptionService.findExpressageList(status,oneselfPickupFlg,nameKey,startTime,endTime,1,10000,wxId,patientName);
        List<Map<String,Object>> list = expressages.getDetailModelList();
                              @RequestParam(value = "endTime", required = false) String endTime,
                              HttpServletResponse response) throws Exception {
        MixEnvelop expressages = prescriptionService.findExpressageList(status, oneselfPickupFlg, nameKey, startTime, endTime, 1, 10000, wxId, patientName);
        List<Map<String, Object>> list = expressages.getDetailModelList();
        response.setContentType("octets/stream");
        response.setHeader("Content-Disposition", "attachment; filename="+ new String( "pushDataList.xls"));
        response.setHeader("Content-Disposition", "attachment; filename=" + new String("pushDataList.xls"));
        OutputStream os = response.getOutputStream();
        prescriptionService.pushListWrite(os,list);
        prescriptionService.pushListWrite(os, list);
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.searchRecordWrite)
    @ApiOperation(value = "咨询记录导出", notes = "咨询记录导出")
    public Envelop searchRecordWrite(/*@ApiParam(name = "doctor", value = "医生id")
                                         @RequestParam(value = "doctor",required = false) String doctor,
                                     @ApiParam(name = "title", value = "咨询标题关键字")
                                         @RequestParam(value = "title",required = false) String title,
                                     @ApiParam(name = "patient", value = "患者id")
                                         @RequestParam(value = "patient",required = false) String patient,
                                     @ApiParam(name = "id", value = "咨询ID")
                                         @RequestParam(value = "id",required = false) String id,
                                     @ApiParam(name = "type", value = "咨询类型")
                                         @RequestParam(value = "type",required = true) String type,
                                     @ApiParam(name = "status", value = "咨询状态:0全部,1候诊中,2就诊中,3结束")
                                         @RequestParam(value = "status",required = true) Integer status,
                                     @ApiParam(name = "start_time", value = "开始时间 YYYY-MM-DD HH:MM:SS")
                                         @RequestParam(value = "start_time",required = false) String start_time,
                                     @ApiParam(name = "end_time", value = "结束时间 YYYY-MM-DD HH:MM:SS")
                                         @RequestParam(value = "end_time",required = false) String end_time,*/
            HttpServletResponse response) throws Exception {
        try {
            MixEnvelop expressages = imService.recordByDoctor();//doctor, id, type, status, title, start_time, end_time, patient
            List<Map<String, Object>> list = expressages.getDetailModelList();
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("searchRecordWrite.xls"));
            OutputStream os = response.getOutputStream();
            prescriptionService.searchRecordWrite(os, list);
            return success(expressages);
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findByDeptTypeCode)
    @ApiOperation(value = "就诊费用查询", notes = "就诊费用查询")
    public ListEnvelop findByDeptTypeCode(@ApiParam(name = "deptTypeCode", value = "6总部7金榜8夏禾")
                                          @RequestParam(value = "deptTypeCode", required = false)String deptTypeCode) throws Exception{
                                          @RequestParam(value = "deptTypeCode", required = false) String deptTypeCode) throws Exception {
        try {
            return success(prescriptionService.findByDeptTypeCode(deptTypeCode));
        }catch (Exception e) {
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getCardInfo)
    @ApiOperation(value = "获取卡信息", notes = "获取卡信息")
    public ObjEnvelop getCardInfo(@ApiParam(name = "cardNo", value = "卡号")
                                  @RequestParam(value = "cardNo", required = false)String cardNo) throws Exception {
        return success(prescriptionService.getCardInfo(cardNo,demoFlag));
                                  @RequestParam(value = "cardNo", required = false) String cardNo) throws Exception {
        return success(prescriptionService.getCardInfo(cardNo, demoFlag));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDoctorWithWork)
    @ApiOperation(value = "查询医生带排班", notes = "查询医生带排班")
    public ObjEnvelop findDoctorWithWork(@ApiParam(name = "orgCode", value = "机构code")
                                         @RequestParam(value = "orgCode", required = false)String orgCode,
                                         @RequestParam(value = "orgCode", required = false) String orgCode,
                                         @ApiParam(name = "dept", value = "部门code")
                                         @RequestParam(value = "dept", required = false)String dept,
                                         @RequestParam(value = "dept", required = false) String dept,
                                         @ApiParam(name = "doctorCode", value = "需要置顶医生code")
                                         @RequestParam(value = "doctorCode", required = false)String doctorCode,
                                         @RequestParam(value = "doctorCode", required = false) String doctorCode,
                                         @ApiParam(name = "chargeType", value = "号别")
                                         @RequestParam(value = "chargeType", required = false)String chargeType,
                                         @RequestParam(value = "chargeType", required = false) String chargeType,
                                         @ApiParam(name = "outpatientType", value = "1图文,2视频")
                                         @RequestParam(value = "outpatientType", required = false)String outpatientType,
                                         @RequestParam(value = "outpatientType", required = false) String outpatientType,
                                         @ApiParam(name = "startDate", value = "开始时间,yyyy-MM-dd HH:mm:ss")
                                         @RequestParam(value = "startDate", required = false)String startDate,
                                         @RequestParam(value = "startDate", required = false) String startDate,
                                         @ApiParam(name = "endDate", value = "结束时间,yyyy-MM-dd HH:mm:ss")
                                         @RequestParam(value = "endDate", required = false)String endDate,
                                         @RequestParam(value = "endDate", required = false) String endDate,
                                         @ApiParam(name = "key", value = "关键字搜索,医生名字/科室名称/专长")
                                         @RequestParam(value = "key", required = false)String key,
                                         @RequestParam(value = "key", required = false) String key,
                                         @ApiParam(name = "consultStatus", value = "是否在线")
                                         @RequestParam(value = "consultStatus", required = false)String consultStatus,
                                         @RequestParam(value = "consultStatus", required = false) String consultStatus,
                                         @ApiParam(name = "ywCode", value = "业务Code")
                                             @RequestParam(value = "ywCode", required = false)String ywCode,
                                         @RequestParam(value = "ywCode", required = false) String ywCode,
                                         @ApiParam(name = "page", value = "第几页")
                                         @RequestParam(value = "page", required = true)Integer page,
                                         @RequestParam(value = "page", required = true) Integer page,
                                         @ApiParam(name = "size", value = "每页大小")
                                         @RequestParam(value = "size", required = true)Integer size) {
        
                                         @RequestParam(value = "size", required = true) Integer size) {
        try {
            return success(prescriptionService.findDoctorWithWork(orgCode,dept,chargeType,doctorCode,outpatientType,startDate,endDate,key,consultStatus,page,size,ywCode));
            return success(prescriptionService.findDoctorWithWork(orgCode, dept, chargeType, doctorCode, outpatientType, startDate, endDate, key, consultStatus, page, size, ywCode));
        }catch (Exception e) {
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDoctorWithMouthWork)
    @ApiOperation(value = "查询医生列表带月份排班状态", notes = "查询医生列表带月份排班状态")
    public ObjEnvelop findDoctorWithMouthWork(@ApiParam(name = "orgCode", value = "机构code")
                                              @RequestParam(value = "orgCode", required = true)String orgCode,
                                              @RequestParam(value = "orgCode", required = true) String orgCode,
                                              @ApiParam(name = "dept", value = "部门code")
                                              @RequestParam(value = "dept", required = false)String dept,
                                              @RequestParam(value = "dept", required = false) String dept,
                                              @ApiParam(name = "date", value = "yyyy-MM")
                                              @RequestParam(value = "date", required = true)String date,
                                              @RequestParam(value = "date", required = true) String date,
                                              @ApiParam(name = "chargeType", value = "号别")
                                              @RequestParam(value = "chargeType", required = false)String chargeType,
                                              @RequestParam(value = "chargeType", required = false) String chargeType,
                                              @ApiParam(name = "nameKey", value = "名字关键字")
                                              @RequestParam(value = "nameKey", required = false)String nameKey,
                                              @RequestParam(value = "nameKey", required = false) String nameKey,
                                              @ApiParam(name = "iswork", value = "不传全部,1.当月已经排班,2.当月未排班")
                                              @RequestParam(value = "iswork", required = false)String iswork,
                                              @RequestParam(value = "iswork", required = false) String iswork,
                                              @ApiParam(name = "page", value = "第几页")
                                              @RequestParam(value = "page", required = true)Integer page,
                                              @RequestParam(value = "page", required = true) Integer page,
                                              @ApiParam(name = "size", value = "每页大小")
                                              @RequestParam(value = "size", required = true)Integer size) {
        
                                              @RequestParam(value = "size", required = true) Integer size) {
        try {
            return success(prescriptionService.findDoctorWithMouthWork(orgCode,dept,chargeType,date,nameKey,iswork,page,size));
        }catch (Exception e) {
            return success(prescriptionService.findDoctorWithMouthWork(orgCode, dept, chargeType, date, nameKey, iswork, page, size));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findWorkTimeInfo)
    @ApiOperation(value = "获取具体号源", notes = "获取具体号源")
    public ListEnvelop findWorkTimeInfo(@ApiParam(name = "id", value = "排班id")
                                        @RequestParam(value = "id", required = false)String id) {
                                        @RequestParam(value = "id", required = false) String id) {
        try {
            return success(prescriptionService.findWorkTimeInfo(id));
        }catch (Exception e) {
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDoctorInfo)
    @ApiOperation(value = "获取医生信息", notes = "获取医生信息")
    public ObjEnvelop findDoctorInfo(@ApiParam(name = "doctor", value = "医生code")
                                     @RequestParam(value = "doctor", required = true)String doctor,
                                     @RequestParam(value = "doctor", required = true) String doctor,
                                     @ApiParam(name = "withWork", value = "传1带排班,其他不带")
                                     @RequestParam(value = "withWork", required = false)String withWork,
                                     @RequestParam(value = "withWork", required = false) String withWork,
                                     @ApiParam(name = "patient", value = "患者code")
                                         @RequestParam(value = "patient", required = false)String patient){
                                     @RequestParam(value = "patient", required = false) String patient) {
        try {
            return success(prescriptionService.findDoctorInfo(doctor,withWork,patient));
        }catch (Exception e) {
            return success(prescriptionService.findDoctorInfo(doctor, withWork, patient));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
@ -941,64 +977,64 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.updateDoctorInfo)
    @ApiOperation(value = "更新医生信息", notes = "更新医生信息")
    public ObjEnvelop updateDoctorInfo(@ApiParam(name = "id", value = "医生id")
                                     @RequestParam(value = "id", required = true)String id,
                                       @RequestParam(value = "id", required = true) String id,
                                       @ApiParam(name = "img", value = "风采图")
                                       @RequestParam(value = "img", required = false)String img,
                                       @RequestParam(value = "img", required = false) String img,
                                       @ApiParam(name = "photo", value = "头像")
                                           @RequestParam(value = "photo", required = false)String photo,
                                       @RequestParam(value = "photo", required = false) String photo,
                                       @ApiParam(name = "background", value = "医生id")
                                           @RequestParam(value = "background", required = false)String background,
                                       @RequestParam(value = "background", required = false) String background,
                                       @ApiParam(name = "expertise", value = "医生特长")
                                           @RequestParam(value = "expertise", required = false)String expertise,
                                       @RequestParam(value = "expertise", required = false) String expertise,
                                       @ApiParam(name = "visitHospital", value = "出诊医院code")
                                           @RequestParam(value = "visitHospital", required = false)String visitHospital,
                                       @RequestParam(value = "visitHospital", required = false) String visitHospital,
                                       @ApiParam(name = "visitHospitalName", value = "出诊医院名称")
                                           @RequestParam(value = "visitHospitalName", required = false)String visitHospitalName,
                                       @RequestParam(value = "visitHospitalName", required = false) String visitHospitalName,
                                       @ApiParam(name = "visitDept", value = "出诊科室code")
                                           @RequestParam(value = "visitDept", required = false)String visitDept,
                                       @RequestParam(value = "visitDept", required = false) String visitDept,
                                       @ApiParam(name = "visitDeptName", value = "出诊科室名称")
                                           @RequestParam(value = "visitDeptName", required = false)String visitDeptName,
                                       @RequestParam(value = "visitDeptName", required = false) String visitDeptName,
                                       @ApiParam(name = "backgroundId", value = "背景id")
                                           @RequestParam(value = "backgroundId", required = false)String backgroundId,
                                       @RequestParam(value = "backgroundId", required = false) String backgroundId,
                                       @ApiParam(name = "name", value = "姓名")
                                           @RequestParam(value = "name", required = false)String name,
                                       @RequestParam(value = "name", required = false) String name,
                                       @ApiParam(name = "sex", value = "性别")
                                           @RequestParam(value = "sex", required = false)Integer sex,
                                       @RequestParam(value = "sex", required = false) Integer sex,
                                       @ApiParam(name = "learning", value = "学术背景")
                                           @RequestParam(value = "learning", required = false)String learning,
                                       @RequestParam(value = "learning", required = false) String learning,
                                       @ApiParam(name = "introduce", value = "简介")
                                           @RequestParam(value = "introduce", required = false)String introduce){
                                       @RequestParam(value = "introduce", required = false) String introduce) {
        try {
            return success(prescriptionService.updateDoctorInfo(id, img,background,expertise, visitHospital, visitHospitalName, visitDept, visitDeptName, backgroundId,name,sex,learning,introduce,photo));
            return success(prescriptionService.updateDoctorInfo(id, img, background, expertise, visitHospital, visitHospitalName, visitDept, visitDeptName, backgroundId, name, sex, learning, introduce, photo));
        } catch (Exception e) {
            e.printStackTrace();
            return failedObjEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDoctorBaseInfo)
    @ApiOperation(value = "获取医生基本信息信息", notes = "获取医生基本信息信息")
    public ObjEnvelop findDoctorBaseInfo(@ApiParam(name = "doctor", value = "医生code")
                                         @RequestParam(value = "doctor", required = true)String doctor){
                                         @RequestParam(value = "doctor", required = true) String doctor) {
        try {
            return success(prescriptionService.findDoctorBaseInfo(doctor));
        }catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failedObjEnvelopException(e);
        }
    }
    
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.cancelOutPatient)
    @ApiOperation(value = "取消复诊", notes = "取消复诊")
    public ObjEnvelop cancelOutPatient(@ApiParam(name = "outPatientId", value = "门诊记录")
                                       @RequestParam(value = "outPatientId", required = false)String outPatientId,
                                       @RequestParam(value = "outPatientId", required = false) String outPatientId,
                                       @ApiParam(name = "cancelType", value = "取消原因类型")
                                       @RequestParam(value = "cancelType", required = false)String cancelType,
                                       @RequestParam(value = "cancelType", required = false) String cancelType,
                                       @ApiParam(name = "cancelValue", value = "取消原因名称")
                                       @RequestParam(value = "cancelValue", required = false)String cancelValue,
                                       @RequestParam(value = "cancelValue", required = false) String cancelValue,
                                       @ApiParam(name = "cancelRemark", value = "取消原因详细说明")
                                       @RequestParam(value = "cancelRemark", required = false)String cancelRemark) {
                                       @RequestParam(value = "cancelRemark", required = false) String cancelRemark) {
        //修改consult门诊状态
        //修改consult门诊状态
@ -1011,129 +1047,129 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            }
        }*/
        try{
        try {
            try {
                String consultCode = imService.getConsultCodeByOutpatientId(outPatientId);
                System.out.println("consultCode"+consultCode);
                if(StringUtils.isNoneBlank(consultCode)) {
                System.out.println("consultCode" + consultCode);
                if (StringUtils.isNoneBlank(consultCode)) {
                    ConsultDo consultDo = consultDao.findByRelationCode(outPatientId);
                    if(null!=consultDo){
                    if (null != consultDo) {
                        imService.cancelRevisit(consultCode, consultDo.getPatient(), 1);
                    }
                }
                if ("xm_zsyy_wx".equalsIgnoreCase(wxId)){
                    String msgUrl="https://hlwyy.xmzsh.com/ims-wx/index.html#/returnVisit/record?outpatientId="+outPatientId;
                    prescriptionService.sendZsMsgFlow("OL_WZ_CANCEL",outPatientId,"",msgUrl,"取消问诊(用户)");
                if ("xm_zsyy_wx".equalsIgnoreCase(wxId)) {
                    String msgUrl = "https://hlwyy.xmzsh.com/ims-wx/index.html#/returnVisit/record?outpatientId=" + outPatientId;
                    prescriptionService.sendZsMsgFlow("OL_WZ_CANCEL", outPatientId, "", msgUrl, "取消问诊(用户)");
                }
            }catch (Exception e){
            } catch (Exception e) {
                System.out.println("居民取消复诊失败");
                e.printStackTrace();
            }
            return success(prescriptionService.cancelOutPatient(outPatientId,cancelType,cancelValue,cancelRemark,1,wxId));
        }catch (Exception e) {
            return success(prescriptionService.cancelOutPatient(outPatientId, cancelType, cancelValue, cancelRemark, 1, wxId));
        } catch (Exception e) {
            e.printStackTrace();
            return failedObjEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findCancelReasonList)
    @ApiOperation(value = "获取居民取消原因字典", notes = "获取居民取消原因字典")
    public ListEnvelop findCancelReasonList(){
    public ListEnvelop findCancelReasonList() {
        try {
            return success(prescriptionService.findCancelReasonList());
        }catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findFastRegisterDate)
    @ApiOperation(value = "獲取快速咨詢時間", notes = "獲取快速咨詢時間")
    public ListEnvelop findFastRegisterDate(){
    public ListEnvelop findFastRegisterDate() {
        try {
            return success(prescriptionService.findFastRegisterDate());
        }catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findByTimeSlot)
    @ApiOperation(value = "获取快速咨询时间分段", notes = "获取快速咨询时间分段")
    public ListEnvelop findByTimeSlot(@ApiParam(name = "startTime", value = "开始时间")
                                      @RequestParam(value = "startTime", required = false)String startTime,
                                      @RequestParam(value = "startTime", required = false) String startTime,
                                      @ApiParam(name = "endTime", value = "结束时间")
                                      @RequestParam(value = "endTime", required = false)String endTime) {
                                      @RequestParam(value = "endTime", required = false) String endTime) {
        try {
            return success(prescriptionService.findByTimeSlot(startTime,endTime));
        }catch (Exception e) {
            return success(prescriptionService.findByTimeSlot(startTime, endTime));
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException(e);
        }
    }
    
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDoctorWorkTimeByMonth)
    @ApiOperation(value = "查询某个医生某个月份排班记录", notes = "查询某个医生某个月份排班记录")
    public ListEnvelop findDoctorWorkTimeByMonth(@ApiParam(name = "doctor", value = "医生code")
                                                 @RequestParam(value = "doctor", required = true)String doctor,
                                                 @RequestParam(value = "doctor", required = true) String doctor,
                                                 @ApiParam(name = "date", value = "年份和月份,yyyy-MM")
                                                 @RequestParam(value = "date", required = false)String date,
                                                 @RequestParam(value = "date", required = false) String date,
                                                 @ApiParam(name = "startDate", value = "yyyy-MM-dd")
                                                 @RequestParam(value = "startDate", required = false)String startDate,
                                                 @RequestParam(value = "startDate", required = false) String startDate,
                                                 @ApiParam(name = "endDate", value = "yyyy-MM-dd")
                                                 @RequestParam(value = "endDate", required = false)String endDate) {
                                                 @RequestParam(value = "endDate", required = false) String endDate) {
        try {
            return success(prescriptionService.findDoctorWorkTimeByMonth(doctor,date,startDate,endDate));
        }catch (Exception e) {
            return success(prescriptionService.findDoctorWorkTimeByMonth(doctor, date, startDate, endDate));
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findWorkRule)
    @ApiOperation(value = "查询排班规则", notes = "查询排班规则")
    public ListEnvelop findWorkRule(@ApiParam(name = "hospital", value = "医生code")
                                    @RequestParam(value = "hospital", required = true)String hospital) {
                                    @RequestParam(value = "hospital", required = true) String hospital) {
        try {
            return success(prescriptionService.findWorkRule("Scheduling",hospital));
        }catch (Exception e) {
            return success(prescriptionService.findWorkRule("Scheduling", hospital));
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException(e);
        }
    }
    
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.updateWorkRule)
    @ApiOperation(value = "保存排班规则", notes = "保存排班规则")
    public ObjEnvelop updateWorkRule(@ApiParam(name = "workRoleJsons", value = "排班规则json")
                                     @RequestParam(value = "workRoleJsons", required = true)String workRoleJsons) {
                                     @RequestParam(value = "workRoleJsons", required = true) String workRoleJsons) {
        try {
            return success(prescriptionService.updateWorkRule(workRoleJsons));
        }catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failedObjEnvelopException(e);
        }
    }
    
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.saveDoctorWorkTimeJson)
    @ApiOperation(value = "排班批量保存接口", notes = "排班批量保存接口")
    public ObjEnvelop saveDoctorWorkTimeJson(@ApiParam(name = "type", value = "1.全医院,2.科室,3.医生")
                                             @RequestParam(value = "type", required = true)String type,
                                             @RequestParam(value = "type", required = true) String type,
                                             @ApiParam(name = "codes", value = "1.医院code,2.科室code,‘,’分割,3.医生code,‘,’分割")
                                             @RequestParam(value = "codes", required = true)String codes,
                                             @RequestParam(value = "codes", required = true) String codes,
                                             @ApiParam(name = "workTimeJson", value = "排班列表json")
                                             @RequestParam(value = "workTimeJson", required = true)String workTimeJson,
                                             @RequestParam(value = "workTimeJson", required = true) String workTimeJson,
                                             @ApiParam(name = "date", value = "yyyy-MM,支持‘,’分割")
                                             @RequestParam(value = "date", required = false)String date)throws Exception {
                                             @RequestParam(value = "date", required = false) String date) throws Exception {
        try {
            return success(prescriptionService.saveDoctorWorkTimeJson(type,codes,workTimeJson,date));
        }catch (Exception e) {
            return success(prescriptionService.saveDoctorWorkTimeJson(type, codes, workTimeJson, date));
        } catch (Exception e) {
            e.printStackTrace();
            return failedObjEnvelopException(e);
        }
@ -1143,13 +1179,13 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.doctorSaveWorkTimeJson)
    @ApiOperation(value = "医生自主排班保存接口", notes = "医生自主排班保存接口")
    public ObjEnvelop doctorSaveWorkTimeJson(@ApiParam(name = "codes", value = "医生code,‘,’分割")
                                             @RequestParam(value = "codes", required = true)String codes,
                                             @RequestParam(value = "codes", required = true) String codes,
                                             @ApiParam(name = "workTimeJson", value = "排班列表json")
                                             @RequestParam(value = "workTimeJson", required = true)String workTimeJson,
                                             @RequestParam(value = "workTimeJson", required = true) String workTimeJson,
                                             @ApiParam(name = "date", value = "yyyy-MM,支持‘,’分割")
                                             @RequestParam(value = "date", required = false)String date)throws Exception {
                                             @RequestParam(value = "date", required = false) String date) throws Exception {
        try {
            return success(prescriptionService.doctorSaveWorkTimeJson(codes,workTimeJson,date));
            return success(prescriptionService.doctorSaveWorkTimeJson(codes, workTimeJson, date));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
@ -1159,19 +1195,20 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.updateWorkTime)
    @ApiOperation(value = "医生自主排班编辑接口", notes = "医生自主排班编辑接口")
    public ObjEnvelop doctorUpdateWorkTimeJson(@ApiParam(name = "workTimeJson", value = "排班列表json")
                                             @RequestParam(value = "workTimeJson", required = true)String workTimeJson,
                                             @ApiParam(name = "codes", value = "医生code,‘,’分割")
                                             @RequestParam(value = "codes", required = true)String codes)throws Exception {
                                               @RequestParam(value = "workTimeJson", required = true) String workTimeJson,
                                               @ApiParam(name = "codes", value = "医生code,‘,’分割")
                                               @RequestParam(value = "codes", required = true) String codes) throws Exception {
        try {
            return success(prescriptionService.doctorUpdateWorkTimeJson(workTimeJson,codes));
            return success(prescriptionService.doctorUpdateWorkTimeJson(workTimeJson, codes));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.deleteWorkTime)
    @ApiOperation(value = "医生自主排班删除接口", notes = "医生自主排班删除接口")
    public ObjEnvelop deleteWorkTime(@ApiParam(name = "code", value = "排班id")
                                             @RequestParam(value = "code", required = true)String code)throws Exception {
                                     @RequestParam(value = "code", required = true) String code) throws Exception {
        try {
            return success(prescriptionService.deleteWorkTime(code));
        } catch (Exception e) {
@ -1184,56 +1221,57 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    public Envelop test()throws Exception {
        return success(prescriptionService.test());
    }*/
    
    @PostMapping(value = "test2")
    @ApiOperation(value = "test2", notes = "test2")
    public Envelop test(String no)throws Exception {
    public Envelop test(String no) throws Exception {
        try {
            return success(prescriptionService.test2(no));
        } catch (Exception e) {
            return failedException(e);
        }
    }
    
    @PostMapping(value = "/sendMes")
    @ApiOperation(value = "心脏模板消息推送", notes = "心脏模板消息推送")
    public Envelop sendMes(@ApiParam(name = "wxId", value = "wxId")
                           @RequestParam(value = "wxId", required = true)String wxId,
                           @RequestParam(value = "wxId", required = true) String wxId,
                           @ApiParam(name = "patient", value = "居民ID")
                           @RequestParam(value = "patient", required = false)String patient,
                           @RequestParam(value = "patient", required = false) String patient,
                           @ApiParam(name = "cardNo", value = "卡号")
                           @RequestParam(value = "cardNo", required = false)String cardNo,
                           @RequestParam(value = "cardNo", required = false) String cardNo,
                           @ApiParam(name = "first", value = "头部")
                           @RequestParam(value = "first", required = true)String first,
                           @RequestParam(value = "first", required = true) String first,
                           @ApiParam(name = "noticeContent", value = "内容")
                           @RequestParam(value = "noticeContent", required = true)String noticeContent,
                           @RequestParam(value = "noticeContent", required = true) String noticeContent,
                           @ApiParam(name = "remark", value = "备注")
                           @RequestParam(value = "remark", required = true)String remark,
                           @RequestParam(value = "remark", required = true) String remark,
                           @ApiParam(name = "redirectUrl", value = "跳转链接")
                           @RequestParam(value = "redirectUrl", required = true)String redirectUrl) {
        return success(xzzxEntranceService.sendMes(wxId,patient,cardNo,first,noticeContent,remark,redirectUrl));
                           @RequestParam(value = "redirectUrl", required = true) String redirectUrl) {
        return success(xzzxEntranceService.sendMes(wxId, patient, cardNo, first, noticeContent, remark, redirectUrl));
    }
    @PostMapping(value = "/sendXCXMes")
    @ApiOperation(value = "心脏模板消息推送小程序跳转", notes = "心脏模板消息推送小程序跳转")
    public Envelop sendXCXMes(@ApiParam(name = "wxId", value = "wxId")
                              @RequestParam(value = "wxId", required = true)String wxId,
                              @RequestParam(value = "wxId", required = true) String wxId,
                              @ApiParam(name = "patient", value = "居民ID")
                              @RequestParam(value = "patient", required = false)String patient,
                              @RequestParam(value = "patient", required = false) String patient,
                              @ApiParam(name = "cardNo", value = "卡号")
                              @RequestParam(value = "cardNo", required = false)String cardNo,
                              @RequestParam(value = "cardNo", required = false) String cardNo,
                              @ApiParam(name = "first", value = "头部")
                              @RequestParam(value = "first", required = true)String first,
                              @RequestParam(value = "first", required = true) String first,
                              @ApiParam(name = "noticeContent", value = "内容")
                              @RequestParam(value = "noticeContent", required = true)String noticeContent,
                              @RequestParam(value = "noticeContent", required = true) String noticeContent,
                              @ApiParam(name = "remark", value = "备注")
                              @RequestParam(value = "remark", required = true)String remark,
                              @RequestParam(value = "remark", required = true) String remark,
                              @ApiParam(name = "redirectUrl", value = "跳转链接")
                              @RequestParam(value = "redirectUrl", required = true)String miniProgramPagepath,
                              @RequestParam(value = "redirectUrl", required = true) String miniProgramPagepath,
                              @ApiParam(name = "miniProgramAppId", value = "APPID")
                              @RequestParam(value = "miniProgramAppId", required = true)String miniProgramAppId  ) {
        return success(xzzxEntranceService.sendXCXMes( wxId, patient, cardNo, first, noticeContent, remark, miniProgramPagepath, miniProgramAppId));
                              @RequestParam(value = "miniProgramAppId", required = true) String miniProgramAppId) {
        return success(xzzxEntranceService.sendXCXMes(wxId, patient, cardNo, first, noticeContent, remark, miniProgramPagepath, miniProgramAppId));
    }
    
    @PostMapping(value = "/sendXZMes")
    @ApiOperation(value = "心脏模板消息推送小程序跳转", notes = "心脏模板消息推送小程序跳转")
    public Envelop ehospitalNotice(
@ -1252,62 +1290,62 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "contentString", value = "内容明细串")
            @RequestParam(value = "contentString", required = false) String contentString) throws Exception {
        String rs = xzzxEntranceService.ehospitalNotice(userName, idCard, phone, title, url, content, contentString);
        if("1".equals(rs)){
        if ("1".equals(rs)) {
            return success("推送成功");
        }
        return failed("推送失败");
    }
    
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findPatientInfo)
    @ApiOperation(value = "获取居民信息接口", notes = "获取居民信息接口")
    public ObjEnvelop findPatientInfo(@ApiParam(name = "patient", value = "居民ID")
                                      @RequestParam(value = "patient", required = true)String patient){
                                      @RequestParam(value = "patient", required = true) String patient) {
        try {
            return success(prescriptionService.findPatientInfo(patient));
        }catch (Exception e) {
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
        
    }
        @PostMapping(value = BaseHospitalRequestMapping.Prescription.updatePatientInfo)
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.updatePatientInfo)
    @ApiOperation(value = "修改居民信息", notes = "修改居民信息")
    public ObjEnvelop findPatientInfo(@ApiParam(name = "patient", value = "居民ID")
                                      @RequestParam(value = "patient", required = true)String patient,
                                      @RequestParam(value = "patient", required = true) String patient,
                                      @ApiParam(name = "name", value = "居民名称")
                                      @RequestParam(value = "name", required = true)String name,
                                      @RequestParam(value = "name", required = true) String name,
                                      @ApiParam(name = "ssc", value = "社保卡")
                                      @RequestParam(value = "ssc", required = true)String ssc,
                                      @RequestParam(value = "ssc", required = true) String ssc,
                                      @ApiParam(name = "idcard", value = "居民身份证")
                                       @RequestParam(value = "idcard", required = true)String idcard,
                                      @RequestParam(value = "idcard", required = true) String idcard,
                                      @ApiParam(name = "sex", value = "性别")
                                          @RequestParam(value = "sex", required = false)Integer sex,
                                      @RequestParam(value = "sex", required = false) Integer sex,
                                      @ApiParam(name = "town", value = "所在区code")
                                          @RequestParam(value = "town", required = false)String town,
                                      @RequestParam(value = "town", required = false) String town,
                                      @ApiParam(name = "townName", value = "所在区名称")
                                          @RequestParam(value = "townName", required = false)String townName,
                                      @RequestParam(value = "townName", required = false) String townName,
                                      @ApiParam(name = "committeeCode", value = "居委会code")
                                          @RequestParam(value = "committeeCode", required = false)String committeeCode,
                                      @RequestParam(value = "committeeCode", required = false) String committeeCode,
                                      @ApiParam(name = "committeeName", value = "居委会code")
                                          @RequestParam(value = "committeeName", required = false)String committeeName,
                                      @RequestParam(value = "committeeName", required = false) String committeeName,
                                      @ApiParam(name = "address", value = "常驻地址")
                                          @RequestParam(value = "address", required = false)String address,
                                      @RequestParam(value = "address", required = false) String address,
                                      @ApiParam(name = "photo", value = "头像")
                                          @RequestParam(value = "photo", required = false)String photo,
                                      @RequestParam(value = "photo", required = false) String photo,
                                      @ApiParam(name = "mobile", value = "手机号")
                                          @RequestParam(value = "mobile", required = false)String mobile,
                                      @RequestParam(value = "mobile", required = false) String mobile,
                                      @ApiParam(name = "province", value = "所在省code")
                                          @RequestParam(value = "province", required = false)String province,
                                      @RequestParam(value = "province", required = false) String province,
                                      @ApiParam(name = "provinceName", value = "所在省名称")
                                          @RequestParam(value = "provinceName", required = false)String provinceName,
                                      @RequestParam(value = "provinceName", required = false) String provinceName,
                                      @ApiParam(name = "city", value = "市code")
                                          @RequestParam(value = "city", required = false)String city,
                                      @RequestParam(value = "city", required = false) String city,
                                      @ApiParam(name = "cityName", value = "市名称")
                                          @RequestParam(value = "cityName", required = false)String cityName){
                                      @RequestParam(value = "cityName", required = false) String cityName) {
        try {
            return success(prescriptionService.updatePatientInfo(patient,name,idcard,ssc,sex,town,townName,committeeCode,committeeName,address,photo,mobile,province,provinceName,city,cityName));
        }catch (Exception e) {
            return success(prescriptionService.updatePatientInfo(patient, name, idcard, ssc, sex, town, townName, committeeCode, committeeName, address, photo, mobile, province, provinceName, city, cityName));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
@ -1315,515 +1353,519 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.saveDoctorOnlineWork)
    @ApiOperation(value = "保存在线排班", notes = "保存在线排班")
    public Envelop saveDoctorOnlineWork(@ApiParam(name = "onlineWorkJson", value = "保存在线排班json")
                                        @RequestParam(value = "onlineWorkJson", required = true)String onlineWorkJson)throws Exception {
                                        @RequestParam(value = "onlineWorkJson", required = true) String onlineWorkJson) throws Exception {
        try {
            return prescriptionService.saveDoctorOnlineWork(onlineWorkJson);
        }catch (Exception e) {
        } catch (Exception e) {
            return failedException(e);
        }
    }
    
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.delDoctorOnlineWork)
    @ApiOperation(value = "删除在线排班", notes = "删除在线排班")
    public Envelop delDoctorOnlineWork(@ApiParam(name = "id", value = "保存在线排班ID")
                                       @RequestParam(value = "id", required = true)String id)throws Exception {
                                       @RequestParam(value = "id", required = true) String id) throws Exception {
        try {
            return prescriptionService.delDoctorOnlineWork(id);
        }catch (Exception e) {
        } catch (Exception e) {
            return failedException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDoctorOnlineWorkList)
    @ApiOperation(value = "查询医生在线排班", notes = "查询医生在线排班")
    public ListEnvelop findDoctorOnlineWorkList(@ApiParam(name = "doctor", value = "医生code")
                                                @RequestParam(value = "doctor", required = true)String doctor,
                                                @RequestParam(value = "doctor", required = true) String doctor,
                                                @ApiParam(name = "startDate", value = "开始时间,YYYY-MM-dd")
                                                @RequestParam(value = "startDate", required = true)String startDate,
                                                @RequestParam(value = "startDate", required = true) String startDate,
                                                @ApiParam(name = "endDate", value = "结束时间,YYYY-MM-dd")
                                                @RequestParam(value = "endDate", required = true)String endDate)throws Exception {
                                                @RequestParam(value = "endDate", required = true) String endDate) throws Exception {
        try {
            return success(prescriptionService.findDoctorOnlineWorkList(doctor,startDate,endDate));
            return success(prescriptionService.findDoctorOnlineWorkList(doctor, startDate, endDate));
        }catch (Exception e) {
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.cooperativeOutpatient)
    @ApiOperation(value = "发起协同门诊", notes = "发起协同门诊")
    public ObjEnvelop cooperativeOutpatient(@ApiParam(name = "outpatientJson", value = "复诊实体json")
                                            @RequestParam(value = "outpatientJson", required = true)String outpatientJson,
                                            @RequestParam(value = "outpatientJson", required = true) String outpatientJson,
                                            @ApiParam(name = "registerJson", value = "预约实体json")
                                            @RequestParam(value = "registerJson", required = false)String registerJson,
                                            @RequestParam(value = "registerJson", required = false) String registerJson,
                                            @ApiParam(name = "chargeType", value = "号别")
                                            @RequestParam(value = "chargeType", required = false)String chargeType)throws Exception {
                                            @RequestParam(value = "chargeType", required = false) String chargeType) throws Exception {
        try {
            WlyyOutpatientDO wlyyOutpatientDO = prescriptionService.cooperativeOutpatient(outpatientJson,registerJson,chargeType);
            WlyyOutpatientDO wlyyOutpatientDO = prescriptionService.cooperativeOutpatient(outpatientJson, registerJson, chargeType);
            if (wlyyOutpatientDO.getPayStatus()!=null&&wlyyOutpatientDO.getPayStatus()==1){
            if (wlyyOutpatientDO.getPayStatus() != null && wlyyOutpatientDO.getPayStatus() == 1) {
                //构建系统消息
                SystemMessageDO systemMessageDO = prescriptionService.sendOutPatientMes(wlyyOutpatientDO,payFlag);
                SystemMessageDO systemMessageDO = prescriptionService.sendOutPatientMes(wlyyOutpatientDO, payFlag);
                //发送系统消息
                hospitalSystemMessageService.sendImMessage(systemMessageDO);
            }
            //发送医生抢单消息
            if(StringUtils.isBlank(wlyyOutpatientDO.getDoctor())){
            if (StringUtils.isBlank(wlyyOutpatientDO.getDoctor())) {
                hospitalSystemMessageService.sendImPichCheckMessage(wlyyOutpatientDO);
            }
            return success(wlyyOutpatientDO);
        }catch (Exception e) {
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.saveOutpatientDoctor)
    @ApiOperation(value = "设置门诊医生", notes = "设置门诊医生")
    public ObjEnvelop saveOutpatientDoctor(@ApiParam(name = "outpatientJson", value = "复诊实体json")
                                           @RequestParam(value = "outpatientJson", required = true)String outpatientJson,
                                           @RequestParam(value = "outpatientJson", required = true) String outpatientJson,
                                           @ApiParam(name = "registerJson", value = "预约实体json")
                                           @RequestParam(value = "registerJson", required = false)String registerJson,
                                           @RequestParam(value = "registerJson", required = false) String registerJson,
                                           @ApiParam(name = "chargeType", value = "号别")
                                           @RequestParam(value = "chargeType", required = false)String chargeType)throws Exception {
                                           @RequestParam(value = "chargeType", required = false) String chargeType) throws Exception {
        try {
            return success(prescriptionService.saveOutpatientDoctor(outpatientJson,registerJson,chargeType));
        }catch (Exception e) {
            return success(prescriptionService.saveOutpatientDoctor(outpatientJson, registerJson, chargeType));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.checkOauthQRCode)
    @ApiOperation(value = "验证授权", notes = "验证授权")
    public ObjEnvelop checkOauthQRCode(@ApiParam(name = "authorizeNo", value = "流水编号")
                                       @RequestParam(value = "authorizeNo", required = true)String authorizeNo)throws Exception {
                                       @RequestParam(value = "authorizeNo", required = true) String authorizeNo) throws Exception {
        return success(prescriptionService.checkOauthQRCode(authorizeNo));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findByGeneralDoctor)
    @ApiOperation(value = "全科医生协同门诊列表", notes = "全科医生协同门诊列表")
    public Envelop findByGeneralDoctor(@ApiParam(name = "generalDoctor", value = "全科医生")
                                       @RequestParam(value = "generalDoctor", required = true)String generalDoctor,
                                       @RequestParam(value = "generalDoctor", required = true) String generalDoctor,
                                       @ApiParam(name = "startDate", value = "开始时间")
                                       @RequestParam(value = "startDate", required = false)String startDate,
                                       @RequestParam(value = "startDate", required = false) String startDate,
                                       @ApiParam(name = "endDate", value = "结束时间")
                                       @RequestParam(value = "endDate", required = false)String endDate,
                                       @RequestParam(value = "endDate", required = false) String endDate,
                                       @ApiParam(name = "status", value = "状态")
                                       @RequestParam(value = "status", required = false)String status,
                                       @RequestParam(value = "status", required = false) String status,
                                       @ApiParam(name = "sort", value = "排序")
                                       @RequestParam(value = "sort", required = false)String sort,
                                       @RequestParam(value = "sort", required = false) String sort,
                                       @ApiParam(name = "page", value = "第几页")
                                       @RequestParam(value = "page", required = true)Integer page,
                                       @RequestParam(value = "page", required = true) Integer page,
                                       @ApiParam(name = "size", value = "每页大小")
                                       @RequestParam(value = "size", required = true)Integer size) {
                                       @RequestParam(value = "size", required = true) Integer size) {
        try {
            return prescriptionService.findByGeneralDoctor(generalDoctor,startDate,endDate,status,sort,page,size,wxId);
        }catch (Exception e) {
            return prescriptionService.findByGeneralDoctor(generalDoctor, startDate, endDate, status, sort, page, size, wxId);
        } catch (Exception e) {
            return failedException(e);
        }
    }
    
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findGeneralDoctorInfo)
    @ApiOperation(value = "全科医生首页统计信息", notes = "全科医生首页统计信息")
    public ObjEnvelop findGeneralDoctorInfo(@ApiParam(name = "generalDoctor", value = "全科医生")
                                            @RequestParam(value = "generalDoctor", required = true)String generalDoctor) {
                                            @RequestParam(value = "generalDoctor", required = true) String generalDoctor) {
        try {
            return success(prescriptionService.findGeneralDoctorInfo(generalDoctor));
        }catch (Exception e) {
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.sendWlyyOutpatientMes)
    @ApiOperation(value = "发送i健康系统消息", notes = "发送i健康系统消息")
    public ObjEnvelop sendWlyyOutpatientMes(@ApiParam(name = "doctor", value = "全科医生Id")
                                            @RequestParam(value = "doctor", required = true)String doctor,
                                            @RequestParam(value = "doctor", required = true) String doctor,
                                            @ApiParam(name = "outPatientId", value = "门诊id")
                                            @RequestParam(value = "outPatientId", required = true)String outPatientId) {
        return success(wlyyBusinessService.sendWlyyOutpatientMes(doctor,outPatientId));
                                            @RequestParam(value = "outPatientId", required = true) String outPatientId) {
        return success(wlyyBusinessService.sendWlyyOutpatientMes(doctor, outPatientId));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.readWlyyOutpatientMes)
    @ApiOperation(value = "设置I健康消息已读", notes = "设置I健康消息已读")
    public ObjEnvelop readWlyyOutpatientMes(@ApiParam(name = "outPatientId", value = "门诊id")
                                            @RequestParam(value = "outPatientId", required = true)String outPatientId){
                                            @RequestParam(value = "outPatientId", required = true) String outPatientId) {
        return success(wlyyBusinessService.readWlyyOutpatientMes(outPatientId));
    }
    //===========
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getTodayOutpatinetList)
    @ApiOperation(value = "居民获取当日就诊列表", notes = "居民获取当日就诊列表")
    public ListEnvelop getTodayOutpatinetList(@ApiParam(name = "patient", value = "居民ID")
                                              @RequestParam(value = "patient", required = true) String patient){
        try{
            return success(prescriptionService.getTodayOutpatinetList(patient,wxId));
        }catch (Exception e) {
                                              @RequestParam(value = "patient", required = true) String patient) {
        try {
            return success(prescriptionService.getTodayOutpatinetList(patient, wxId));
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getDoctorMapping)
    @ApiOperation(value = "获取医生mappingcode", notes = "获取医生mappingcode")
    public ObjEnvelop getDoctorMapping(@ApiParam(name = "doctor", value = "医生code")
                                       @RequestParam(value = "doctor", required = true)String doctor,
                                       @RequestParam(value = "doctor", required = true) String doctor,
                                       @ApiParam(name = "orgCode", value = "机构code")
                                       @RequestParam(value = "orgCode", required = true)String orgCode){
                                       @RequestParam(value = "orgCode", required = true) String orgCode) {
        try {
            return success(prescriptionService.getDoctorMapping(doctor,orgCode));
            return success(prescriptionService.getDoctorMapping(doctor, orgCode));
        }catch (Exception e) {
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
        
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getInspectionDictionary)
    @ApiOperation(value = "获取检查检验", notes = "获取检查检验")
    public ListEnvelop getInspectionDictionary(@ApiParam(name = "pyKey", value = "拼音码")
                                               @RequestParam(value = "pyKey", required = false)String pyKey,
                                               @RequestParam(value = "pyKey", required = false) String pyKey,
                                               @ApiParam(name = "winNo", value = "6总部7金榜8夏禾10检查11检验")
                                               @RequestParam(value = "winNo", required = true)String winNo,
                                               @RequestParam(value = "winNo", required = true) String winNo,
                                               @ApiParam(name = "codes", value = "检查检验收费码codes,用逗号分割")
                                               @RequestParam(value = "codes", required = false)String codes)throws Exception{
        if("xm_xzzx_wx".equalsIgnoreCase(wxId)){
            if ("10".equalsIgnoreCase(winNo)){
                                               @RequestParam(value = "codes", required = false) String codes) throws Exception {
        if ("xm_xzzx_wx".equalsIgnoreCase(wxId)) {
            if ("10".equalsIgnoreCase(winNo)) {
                //检查
                return success(xzzxEntranceService.selectExamApply(pyKey));
            }else {
            } else {
                //检验
                return success(xzzxEntranceService.selectLisApply(pyKey));
            }
        }if("sd_tnzyy_wx".equalsIgnoreCase(wxId)){
            return  success(tnyyEntranceService.findVpacsBw(pyKey));
        }else {
            return success(prescriptionService.getInspectionDictionary(pyKey,codes,winNo));
        }
        if ("sd_tnzyy_wx".equalsIgnoreCase(wxId)) {
            return success(tnyyEntranceService.findVpacsBw(pyKey));
        } else {
            return success(prescriptionService.getInspectionDictionary(pyKey, codes, winNo));
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findPrescriptionLogByPreId)
    @ApiOperation(value = "查询处方日志", notes = "查询处方日志")
    public ListEnvelop findPrescriptionLogByPreId(@ApiParam(name = "prescriptionCode", value = "处方code")
                                                  @RequestParam(value = "prescriptionCode", required = true)String prescriptionCode)throws Exception{
        try{
                                                  @RequestParam(value = "prescriptionCode", required = true) String prescriptionCode) throws Exception {
        try {
            return success(prescriptionLogService.findPrescriptionLogByPreId(prescriptionCode));
        }catch (Exception e) {
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findByPrescriptionCodeByStatus)
    @ApiOperation(value = "查询处方流程", notes = "查询处方流程")
    public ListEnvelop findByPrescriptionCodeByStatus(@ApiParam(name = "prescriptionCode", value = "处方code")
                                                      @RequestParam(value = "prescriptionCode", required = true)String prescriptionCode)throws Exception{
                                                      @RequestParam(value = "prescriptionCode", required = true) String prescriptionCode) throws Exception {
        try {
            return success(prescriptionLogService.findByPrescriptionCodeByStatus(prescriptionCode));
        }catch (Exception e) {
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.xzzxFindByPartsCode)
    @ApiOperation(value = "心脏查询部位字典", notes = "心脏查询部位字典")
    public ListEnvelop xzzxFindByPartsCode(@ApiParam(name = "spellCode", value = "拼音首字母")
                                       @RequestParam(value = "spellCode", required = false)String spellCode)throws Exception{
                                           @RequestParam(value = "spellCode", required = false) String spellCode) throws Exception {
        return success(xzzxEntranceService.selectCheckBody(spellCode));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findByPartsCode)
    @ApiOperation(value = "查询部位字典", notes = "查询部位字典")
    public ListEnvelop findByPartsCode(@ApiParam(name = "parentCode", value = "父节点ID,第一层为0")
                                       @RequestParam(value = "parentCode", required = false)String parentCode)throws Exception{
                                       @RequestParam(value = "parentCode", required = false) String parentCode) throws Exception {
        return success(inspectionService.findByPartsCode(parentCode));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDictByName)
    @ApiOperation(value = "查询检查检验字典", notes = "查询检查检验字典")
    public ListEnvelop findDictByName(@ApiParam(name = "hospital", value = "医院")
                                      @RequestParam(value = "hospital", required = true)String hospital,
                                      @RequestParam(value = "hospital", required = true) String hospital,
                                      @ApiParam(name = "name", value = "字典名称,类型:InspectionType;固定液体 :InspectionFixativeType")
                                      @RequestParam(value = "name", required = true)String name)throws Exception{
        return success(inspectionService.findDictByName(hospital,name));
                                      @RequestParam(value = "name", required = true) String name) throws Exception {
        return success(inspectionService.findDictByName(hospital, name));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getJymb)
    @ApiOperation(value = "检验模板接口")
    public ListEnvelop getJymb(@ApiParam(name = "bz_code", value = "入参条件为第一节点代码")
                               @RequestParam(value = "bz_code",defaultValue = "") String bz_code,
                               @RequestParam(value = "bz_code", defaultValue = "") String bz_code,
                               @ApiParam(name = "tc_no", value = "二级节点代码")
                               @RequestParam(value = "tc_no",defaultValue = "") String tc_no,
                               @RequestParam(value = "tc_no", defaultValue = "") String tc_no,
                               @ApiParam(name = "flag", value = "入参条件为第一节点代码")
                               @RequestParam(value = "flag",defaultValue = "1") String flag) throws Exception {
        return success(prescriptionService.getJymb(bz_code,tc_no,flag));
                               @RequestParam(value = "flag", defaultValue = "1") String flag) throws Exception {
        return success(prescriptionService.getJymb(bz_code, tc_no, flag));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getJcmb)
    @ApiOperation(value = "检查模板接口")
    public ListEnvelop getJcmb(
            @ApiParam(name = "bz_code", value = "入参条件为第一节点代码")
            @RequestParam(value = "bz_code",defaultValue = "") String bz_code,
            @RequestParam(value = "bz_code", defaultValue = "") String bz_code,
            @ApiParam(name = "tc_no", value = "二级节点代码")
            @RequestParam(value = "tc_no",defaultValue = "") String tc_no,
            @RequestParam(value = "tc_no", defaultValue = "") String tc_no,
            @ApiParam(name = "flag", value = "入参条件为第一节点代码")
            @RequestParam(value = "flag",defaultValue = "1") String flag) throws Exception {
        return success(prescriptionService.getJcmb(bz_code,tc_no,flag));
            @RequestParam(value = "flag", defaultValue = "1") String flag) throws Exception {
        return success(prescriptionService.getJcmb(bz_code, tc_no, flag));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getTcChild)
    @ApiOperation(value = "套餐子项目字典接口")
    public ListEnvelop getTcChild(
            @ApiParam(name = "parent_code", value = "入参条件为子项目编码")
            @RequestParam(value = "parent_code",defaultValue = "") String parent_code) throws Exception {
            @RequestParam(value = "parent_code", defaultValue = "") String parent_code) throws Exception {
        return success(prescriptionService.getTcChild(parent_code));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getInsChild)
    @ApiOperation(value = "主项目绑定子项目字典接口")
    public ListEnvelop getInsChild(
            @ApiParam(name = "zd_charge_code", value = "入参条件为项目代码")
            @RequestParam(value = "zd_charge_code",defaultValue = "") String zd_charge_code) throws Exception {
            @RequestParam(value = "zd_charge_code", defaultValue = "") String zd_charge_code) throws Exception {
        return success(prescriptionService.getInsChild(zd_charge_code));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getTcxz)
    @ApiOperation(value = "套餐选择接口")
    public ListEnvelop getTcxz(
            @ApiParam(name = "bz_code", value = "入参条件为收费项目代码")
            @RequestParam(value = "bz_code",defaultValue = "") String charge_code,
            @RequestParam(value = "bz_code", defaultValue = "") String charge_code,
            @ApiParam(name = "tc_no", value = "二级节点代码")
            @RequestParam(value = "tc_no",defaultValue = "") String tc_no,
            @RequestParam(value = "tc_no", defaultValue = "") String tc_no,
            @ApiParam(name = "flag", value = "入参条件为第一节点代码")
            @RequestParam(value = "flag",defaultValue = "1") String flag) throws Exception {
        return success(prescriptionService.getTcxz(charge_code,tc_no,flag));
            @RequestParam(value = "flag", defaultValue = "1") String flag) throws Exception {
        return success(prescriptionService.getTcxz(charge_code, tc_no, flag));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getDoctorPreSign)
    @ApiOperation(value = "获取医生签名")
    public ObjEnvelop getDoctorPreSign(@ApiParam(name = "doctor", value = "医生编码")
                                       @RequestParam(value = "doctor",required = false) String doctor)throws Exception{
                                       @RequestParam(value = "doctor", required = false) String doctor) throws Exception {
        return success(doctorPreSignService.getDoctorSign(doctor));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getDoctorIntroduction)
    @ApiOperation(value = "获取医生简介")
    public ObjEnvelop getDoctorIntroduction(@ApiParam(name = "doctor", value = "医生编码")
                                            @RequestParam(value = "doctor",required = false) String doctor)throws Exception{
                                            @RequestParam(value = "doctor", required = false) String doctor) throws Exception {
        try {
            return success(prescriptionService.getDoctorIntroduction(doctor));
        }catch (Exception e) {
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findByDict)
    @ApiOperation(value = "查询医院字典", notes = "查询医院字典")
    public ListEnvelop findByDict(@ApiParam(name = "name", value = "字典名称")
                                  @RequestParam(value = "name", required = true)String name,
                                  @RequestParam(value = "name", required = true) String name,
                                  @ApiParam(name = "hospital", value = "医生code")
                                  @RequestParam(value = "hospital", required = true)String hospital) {
                                  @RequestParam(value = "hospital", required = true) String hospital) {
        try {
            return success(prescriptionService.findByDict(name,hospital));
            return success(prescriptionService.findByDict(name, hospital));
        }catch (Exception e) {
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getPatientAccetokenByIdcard)
    @ApiOperation(value = "根据居民CODE换取居民请求秘钥")
    public Envelop getPatientAccetokenByIdcard(@ApiParam(name = "patientCode", value = "居民CODE")
                                               @RequestParam(value = "patientCode",required = true) String patientCode,
                                               @RequestParam(value = "patientCode", required = true) String patientCode,
                                               @ApiParam(name = "wxid", value = "wxid")
                                               @RequestParam(value = "wxid",required = false) String wxid)throws Exception{
        if (StringUtils.isNoneBlank(wxid)){
                                               @RequestParam(value = "wxid", required = false) String wxid) throws Exception {
        if (StringUtils.isNoneBlank(wxid)) {
            wxId = wxid;
        }
        String doctorId=getUID();
        return success(wlyyBusinessService.wlyyGetPatientAccetokenByIdcard(patientCode,wxId,doctorId));
        String doctorId = getUID();
        return success(wlyyBusinessService.wlyyGetPatientAccetokenByIdcard(patientCode, wxId, doctorId));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findWlyyPatient)
    @ApiOperation(value = "获取居民信息")
    public Envelop findWlyyPatient(@ApiParam(name = "idcard", value = "idcard")
                                   @RequestParam(value = "idcard",required = true) String idcard)throws Exception{
                                   @RequestParam(value = "idcard", required = true) String idcard) throws Exception {
        return success(wlyyBusinessService.findWlyyPatient(idcard));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findPatientListBySscOrIdCard)
    @ApiOperation(value = "获取居民身份证信息")
    public Envelop findPatientListBySscOrIdCard(@ApiParam(name = "idcard", value = "idcard")
                                                @RequestParam(value = "idcard",required = false) String idcard,
                                                @RequestParam(value = "idcard", required = false) String idcard,
                                                @ApiParam(name = "ssc", value = "社保卡")
                                                @RequestParam(value = "ssc",required = false) String ssc)throws Exception{
        if(StringUtils.isNotBlank(idcard)&&idcard.length()>=6){
            return success(wlyyBusinessService.findPatientListBySscOrIdCard(idcard,null));
                                                @RequestParam(value = "ssc", required = false) String ssc) throws Exception {
        if (StringUtils.isNotBlank(idcard) && idcard.length() >= 6) {
            return success(wlyyBusinessService.findPatientListBySscOrIdCard(idcard, null));
        }
        if(StringUtils.isNotBlank(ssc)&&ssc.length()>=6){
            return success(wlyyBusinessService.findPatientListBySscOrIdCard(null,ssc));
        if (StringUtils.isNotBlank(ssc) && ssc.length() >= 6) {
            return success(wlyyBusinessService.findPatientListBySscOrIdCard(null, ssc));
        }
        return failed("身份证或医保卡格式有误");
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.makeBase64Qrcode)
    @ApiOperation(value = "获取医生二维码")
    public ObjEnvelop makeBase64Qrcode(@ApiParam(name = "doctor", value = "医生ID")
                                       @RequestParam(value = "doctor",required = true) String doctor)throws Exception{
        return success("获取医生二维码成功",wlyyBusinessService.makeBase64Qrcode(doctor));
                                       @RequestParam(value = "doctor", required = true) String doctor) throws Exception {
        return success("获取医生二维码成功", wlyyBusinessService.makeBase64Qrcode(doctor));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.doctorUpcomingList)
    @ApiOperation(value = "医生待办事项列表")
    public Envelop doctorUpcomingList(@ApiParam(name = "doctorCode", value = "医生CODE")
                                      @RequestParam(value = "doctorCode",required = true) String doctorCode,
                                      @RequestParam(value = "doctorCode", required = true) String doctorCode,
                                      @ApiParam(name = "type", value = "类型:1.视频复诊(16)、2.专科协同(12)、3.图文复诊(9)、4.专家咨询(1,15)")
                                      @RequestParam(value = "type",required = true) String type)throws Exception{
                                      @RequestParam(value = "type", required = true) String type) throws Exception {
        com.alibaba.fastjson.JSONArray array = new com.alibaba.fastjson.JSONArray();
        List<Map<String,Object>>  data = imService.doctorUpcomingList(doctorCode, type);
        List<Map<String, Object>> data = imService.doctorUpcomingList(doctorCode, type);
        if (data != null) {
            for (Map<String,Object> consult : data) {
                if("1,15,17".equals(type)){//专家咨询
                    Integer consultType =  Integer.parseInt(consult.get("type").toString());
                    if(1 == consultType){//专家咨询
                        consult.put("session_id", consult.get("consumer").toString()+"_"+ consult.get("outpatientId").toString()+"_1");
                    }else if(15 == consultType){//家医求助
                        consult.put("session_id", consult.get("consumer").toString()+"_"+ consult.get("outpatientId").toString()+"_"+ consult.get("doctorCode").toString()+"_15");
                    }else if (17==consultType){//视频咨询
                        consult.put("session_id", consult.get("consumer").toString()+"_"+ consult.get("outpatientId").toString()+"_17");
            for (Map<String, Object> consult : data) {
                if ("1,15,17".equals(type)) {//专家咨询
                    Integer consultType = Integer.parseInt(consult.get("type").toString());
                    if (1 == consultType) {//专家咨询
                        consult.put("session_id", consult.get("consumer").toString() + "_" + consult.get("outpatientId").toString() + "_1");
                    } else if (15 == consultType) {//家医求助
                        consult.put("session_id", consult.get("consumer").toString() + "_" + consult.get("outpatientId").toString() + "_" + consult.get("doctorCode").toString() + "_15");
                    } else if (17 == consultType) {//视频咨询
                        consult.put("session_id", consult.get("consumer").toString() + "_" + consult.get("outpatientId").toString() + "_17");
                    }
                }else if("9".equals(type)){//图文复诊
                    consult.put("session_id", consult.get("consumer").toString()+"_"+consult.get("outpatientId").toString()+"_9");
                    consult.put("type",type);
                }else if("16".equals(type)){//视频复诊
                    consult.put("session_id", consult.get("consumer").toString()+"_"+consult.get("outpatientId").toString()+"_16");
                    consult.put("type",type);
                }else if("12".equals(type)){//协同门诊
                    consult.put("session_id", consult.get("consumer").toString()+"_"+consult.get("outpatientId").toString()+"_12");
                    consult.put("type",type);
                }else{}
                
                } else if ("9".equals(type)) {//图文复诊
                    consult.put("session_id", consult.get("consumer").toString() + "_" + consult.get("outpatientId").toString() + "_9");
                    consult.put("type", type);
                } else if ("16".equals(type)) {//视频复诊
                    consult.put("session_id", consult.get("consumer").toString() + "_" + consult.get("outpatientId").toString() + "_16");
                    consult.put("type", type);
                } else if ("12".equals(type)) {//协同门诊
                    consult.put("session_id", consult.get("consumer").toString() + "_" + consult.get("outpatientId").toString() + "_12");
                    consult.put("type", type);
                } else {
                }
                array.add(consult);
            }
        }
        return success(array);
    }
    
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.setRecord)
    @ApiOperation(value = "his建立档案与互联网医院账户同步")
    public Envelop setRecord(@ApiParam(name = "json", value = "档案实体json")
                             @RequestParam(value = "json",required = true) String json,
                             @RequestParam(value = "json", required = true) String json,
                             @ApiParam(name = "type", value = "1.需要his建档,2.仅同步互联网医院账户")
                             @RequestParam(value = "type",required = true)String type)throws Exception{
        return success(prescriptionService.setRecord(json,type));
                             @RequestParam(value = "type", required = true) String type) throws Exception {
        return success(prescriptionService.setRecord(json, type));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findPatientRecord)
    @ApiOperation(value = "获取HIIS居民档案信息")
    public Envelop findPatientRecord(@ApiParam(name = "idcard", value = "居民身份证")
                                     @RequestParam(value = "idcard",required = false) String idcard,
                                     @RequestParam(value = "idcard", required = false) String idcard,
                                     @ApiParam(name = "patient", value = "居民code")
                                     @RequestParam(value = "patient",required = false)String patient,
                                     @RequestParam(value = "patient", required = false) String patient,
                                     @ApiParam(name = "admitNum", value = "就诊次数")
                                     @RequestParam(value = "admitNum",required = false)String admitNum,
                                     @RequestParam(value = "admitNum", required = false) String admitNum,
                                     @ApiParam(name = "ybcard", value = "医保卡")
                                     @RequestParam(value = "ybcard",required = false)String ybcard)throws Exception{
        return success(prescriptionService.findPatientRecord(idcard,patient,admitNum,ybcard));
                                     @RequestParam(value = "ybcard", required = false) String ybcard) throws Exception {
        return success(prescriptionService.findPatientRecord(idcard, patient, admitNum, ybcard));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDoctorByName)
    @ApiOperation(value = "获取医生信息")
    public ListEnvelop findDoctorByName(@ApiParam(name = "hospital", value = "医院code")
                                        @RequestParam(value = "hospital",required = false)String hospital,
                                        @RequestParam(value = "hospital", required = false) String hospital,
                                        @ApiParam(name = "name", value = "医生名称")
                                        @RequestParam(value = "name",required = false)String name,
                                        @RequestParam(value = "name", required = false) String name,
                                        @ApiParam(name = "chargeType", value = "号别")
                                        @RequestParam(value = "chargeType",required = false)String chargeType,
                                        @RequestParam(value = "chargeType", required = false) String chargeType,
                                        @ApiParam(name = "dept", value = "科室")
                                            @RequestParam(value = "dept",required = false)String dept) {
                                        @RequestParam(value = "dept", required = false) String dept) {
        try {
            return success(prescriptionService.findDoctorByName(hospital,name,chargeType,dept));
        }catch (Exception e) {
            return success(prescriptionService.findDoctorByName(hospital, name, chargeType, dept));
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDeptWithDoctorWorkTime)
    @ApiOperation(value = "获取带排班部门")
    public ListEnvelop findDeptWithDoctorWorkTime(@ApiParam(name = "hospital", value = "医院code")
                                                  @RequestParam(value = "hospital",required = false)String hospital,
                                                  @RequestParam(value = "hospital", required = false) String hospital,
                                                  @ApiParam(name = "keyWord", value = "科室关键字")
                                                  @RequestParam(value = "keyWord",required = false)String keyWord,
                                                  @RequestParam(value = "keyWord", required = false) String keyWord,
                                                  @ApiParam(name = "page", value = "第几页")
                                                  @RequestParam(value = "page",required = false)Integer page,
                                                  @RequestParam(value = "page", required = false) Integer page,
                                                  @ApiParam(name = "pagesize", value = "每页大小")
                                                  @RequestParam(value = "pagesize",required = false)Integer pagesize) {
                                                  @RequestParam(value = "pagesize", required = false) Integer pagesize) {
        try {
            return success(prescriptionService.findDeptWithDoctorWorkTime(hospital,keyWord,page,pagesize));
        }catch (Exception e) {
            return success(prescriptionService.findDeptWithDoctorWorkTime(hospital, keyWord, page, pagesize));
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.findWorkTimeRule)
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.findWorkTimeRule)
    @ApiOperation(value = "查询排班规则")
    public ObjEnvelop findWorkTimeRule(@ApiParam(name = "hospital", value = "医院code")
                                       @RequestParam(value = "hospital",required = true)String hospital) {
                                       @RequestParam(value = "hospital", required = true) String hospital) {
        try {
            return success(workTimeService.findWorkTimeRule(hospital));
        }catch (Exception e) {
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.saveWorkTimeRule)
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.saveWorkTimeRule)
    @ApiOperation(value = "保存排班规则")
    public ObjEnvelop saveWorkTimeRule(@ApiParam(name = "workTimeRuleJson", value = "保存排班规则")
                                       @RequestParam(value = "workTimeRuleJson",required = true)String workTimeRuleJson,
                                       @RequestParam(value = "workTimeRuleJson", required = true) String workTimeRuleJson,
                                       @ApiParam(name = "isDoctorWorkJson", value = "判断是否排班json数据")
                                       @RequestParam(value = "isDoctorWorkJson",required = false)String isDoctorWorkJson) throws Exception{
                                       @RequestParam(value = "isDoctorWorkJson", required = false) String isDoctorWorkJson) throws Exception {
        try {
            return success(workTimeService.saveWorkTimeRule(workTimeRuleJson,isDoctorWorkJson));
            return success(workTimeService.saveWorkTimeRule(workTimeRuleJson, isDoctorWorkJson));
        }catch (Exception e) {
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.checkDoctorWork)
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.checkDoctorWork)
    @ApiOperation(value = "判断医生是否在班")
    public ObjEnvelop checkDoctorWork(@ApiParam(name = "doctor", value = "判断医生是否在班")
                                      @RequestParam(value = "doctor",required = true)String doctor,
                                      @RequestParam(value = "doctor", required = true) String doctor,
                                      @ApiParam(name = "ywCode", value = "业务code")
                                      @RequestParam(value = "ywCode",required = false) String ywCode) throws Exception{
                                      @RequestParam(value = "ywCode", required = false) String ywCode) throws Exception {
        try {
            return success(workTimeService.checkDoctorWork(doctor,ywCode));
        }catch (Exception e) {
            return success(workTimeService.checkDoctorWork(doctor, ywCode));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.importDoctorWork)
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.importDoctorWork)
    @ApiOperation(value = "导入排班信息")
    public ListEnvelop importDoctorWork(@ApiParam(name = "file", value = "文件", required = true)
                                        @RequestPart(value = "file") MultipartFile file,
                                        @ApiParam(name = "hospital", value = "医院编码")
                                        @RequestParam(value = "hospital",required = true)String hospital,
                                        @RequestParam(value = "hospital", required = true) String hospital,
                                        @ApiParam(name = "dateMoth", value = "年-月,格式:2020-03")
                                        @RequestParam(value = "dateMoth",required = true)String dateMoth,
                                        HttpServletRequest request)throws Exception{
                                        @RequestParam(value = "dateMoth", required = true) String dateMoth,
                                        HttpServletRequest request) throws Exception {
        try {
            request.setCharacterEncoding("UTF-8");
            DoctorWorkTimeExcelReader reader = new DoctorWorkTimeExcelReader();
            reader.read(file);
            if("-1".equals(reader.getCode())) {
            if ("-1".equals(reader.getCode())) {
                ListEnvelop envelop = new ListEnvelop();
                envelop.setStatus(-1);
                envelop.setMessage("目前仅支持200位医生同时导入!");
@ -1832,7 +1874,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            List<DoctorWorkTimeMainExcelDO> errorLs = reader.getErrorLs();
            List<DoctorWorkTimeMainExcelDO> correctLs = reader.getCorrectLs();
            if(errorLs!=null&&errorLs.size()>0){
            if (errorLs != null && errorLs.size() > 0) {
                ListEnvelop envelop = new ListEnvelop();
                envelop.setStatus(-1);
                envelop.setMessage("格式错误!");
@ -1840,45 +1882,46 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                return envelop;
            }
            Map<String,Object> rs = workTimeService.getExcelWorkInfo(correctLs,dateMoth,hospital);
            List<DoctorWorkTimeMainExcelDO> error = (List<DoctorWorkTimeMainExcelDO>)rs.get("error");
            Map<String, Object> rs = workTimeService.getExcelWorkInfo(correctLs, dateMoth, hospital);
            List<DoctorWorkTimeMainExcelDO> error = (List<DoctorWorkTimeMainExcelDO>) rs.get("error");
            Integer errorTotal = (Integer) rs.get("errorTotal");
            Integer succTotal = (Integer) rs.get("succTotal");
            if(error!=null&&error.size()>0){
            if (error != null && error.size() > 0) {
                ListEnvelop envelop = new ListEnvelop();
                envelop.setStatus(-1);
                envelop.setMessage(succTotal+"位医生,更新成功!"+","+errorTotal+"位医生,身份信息错误!更新失败!");
                envelop.setMessage(succTotal + "位医生,更新成功!" + "," + errorTotal + "位医生,身份信息错误!更新失败!");
                envelop.setDetailModelList(error);
                return envelop;
            }
            ListEnvelop envelop = new ListEnvelop();
            envelop.setStatus(200);
            envelop.setMessage("导入成功!"+succTotal+"位医生排班数据!");
            envelop.setMessage("导入成功!" + succTotal + "位医生排班数据!");
            envelop.setDetailModelList(error);
            return envelop;
        }catch (Exception e) {
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    
    
    /**
     * 易联众统一支付
     *
     * @param relationCode
     * @return
     * @throws Exception
     */
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.selectOrderByRelationCode)
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.selectOrderByRelationCode)
    @ApiOperation("统一支付")
    public ObjEnvelop selectOrderByRelationCode(
            @ApiParam(name = "relationCode", value = "relationCode", required = true)
            @RequestParam(required = true)String relationCode,
            @RequestParam(required = true) String relationCode,
            @ApiParam(name = "depositType", value = "depositType", required = true)
            @RequestParam(required = true)String depositType) throws Exception {
            @RequestParam(required = true) String depositType) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",businessOrderService.reChargeJSON(relationCode,depositType,wxId));
            return ObjEnvelop.getSuccess("ok", businessOrderService.reChargeJSON(relationCode, depositType, wxId));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
@ -1886,23 +1929,24 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    /**
     * 易联众统一支付
     *
     * @param relationCode
     * @return
     * @throws Exception
     */
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.ylzRechargeJson)
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.ylzRechargeJson)
    @ApiOperation("统一支付--预交金支付")
    public ObjEnvelop ylzRechargeJson(
            @ApiParam(name = "relationCode", value = "relationCode", required = true)
            @RequestParam(required = true)String relationCode,
            @RequestParam(required = true) String relationCode,
            @ApiParam(name = "depositType", value = "depositType", required = true)
            @RequestParam(required = true)String depositType,
            @RequestParam(required = true) String depositType,
            @ApiParam(name = "cardType", value = "cardType", required = true)
            @RequestParam(required = true)String cardType,
            @RequestParam(required = true) String cardType,
            @ApiParam(name = "cardNo", value = "cardNo", required = true)
            @RequestParam(required = true)String cardNo) throws Exception {
            @RequestParam(required = true) String cardNo) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",businessOrderService.ylzRechargeJson(relationCode,depositType,wxId,cardType,cardNo,demoFlag));
            return ObjEnvelop.getSuccess("ok", businessOrderService.ylzRechargeJson(relationCode, depositType, wxId, cardType, cardNo, demoFlag));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
@ -1911,6 +1955,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    /**
     * 充值卡一支付
     *
     * @param mzhm
     * @param jkje
     * @param type
@ -1919,75 +1964,78 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
     * @return
     * @throws Exception
     */
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.yktMedicalCardTopUp)
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.yktMedicalCardTopUp)
    @ApiOperation("眼科--充值卡支付")
    public ObjEnvelop yktMedicalCardTopUp(
            @ApiParam(name = "mzhm", value = "卡号", required = true)
            @RequestParam(required = true)String mzhm,
            @RequestParam(required = true) String mzhm,
            @ApiParam(name = "jkje", value = "充值金额", required = true)
            @RequestParam(required = true)Double jkje,
            @RequestParam(required = true) Double jkje,
            @ApiParam(name = "type", value = "类型0 就诊卡号 1 门诊卡号", required = true)
            @RequestParam(required = true)Integer type,
            @RequestParam(required = true) Integer type,
            @ApiParam(name = "paymentType", value = "1支付宝 2微信", required = true)
            @RequestParam(required = true)Integer paymentType,
            @RequestParam(required = true) Integer paymentType,
            @ApiParam(name = "patientId", value = "居民code", required = true)
            @RequestParam(required = true)String patientId,
            @RequestParam(required = true) String patientId,
            @ApiParam(name = "hospitalId", value = "医院Ccode", required = true)
            @RequestParam(required = true)String hospitalId,
            @RequestParam(required = true) String hospitalId,
            @ApiParam(name = "wxPayType", value = "微信交易类型 公众号支付:JSAPI  原生扫码支付:NATIVE", required = true)
            @RequestParam(required = true)String wxPayType,
            @RequestParam(required = true) String wxPayType,
            @ApiParam(name = "geetestChallenge", value = "geetestChallenge")
            @RequestParam(value = "geetestChallenge", required = false)String geetestChallenge,
            @RequestParam(value = "geetestChallenge", required = false) String geetestChallenge,
            @ApiParam(name = "geetestValidate", value = "geetestValidate")
            @RequestParam(value = "geetestValidate", required = false)String geetestValidate,
            @RequestParam(value = "geetestValidate", required = false) String geetestValidate,
            @ApiParam(name = "geetestSeccode", value = "geetestSeccode")
            @RequestParam(value = "geetestSeccode", required = false)String geetestSeccode,
            @RequestParam(value = "geetestSeccode", required = false) String geetestSeccode,
            @ApiParam(name = "appletCode", value = "appletCode", required = false)
            @RequestParam(required = false)String appletCode) throws Exception {
            @RequestParam(required = false) String appletCode) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",businessOrderService.yktMedicalCardTopUp(mzhm,jkje,type,paymentType,patientId,wxId,hospitalId,wxPayType,appletCode,geetestChallenge,geetestValidate,geetestSeccode));
            return ObjEnvelop.getSuccess("ok", businessOrderService.yktMedicalCardTopUp(mzhm, jkje, type, paymentType, patientId, wxId, hospitalId, wxPayType, appletCode, geetestChallenge, geetestValidate, geetestSeccode));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    
    /**
     * 查询支付状态
     *
     * @param relationCode
     * @return
     * @throws Exception
     */
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.selectOrderStatus)
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.selectOrderStatus)
    @ApiOperation("查询支付状态")
    public ObjEnvelop selectOrderStatus(
            @ApiParam(name = "relationCode", value = "relationCode", required = true)
            @RequestParam(required = true)String relationCode,
            @RequestParam(required = true) String relationCode,
            @ApiParam(name = "flag", value = "flag", required = false)
            @RequestParam(required = false)String flag) throws Exception {
            @RequestParam(required = false) String flag) throws Exception {
        try {
            if (StringUtils.isNoneBlank(flag)){
            if (StringUtils.isNoneBlank(flag)) {
                Integer id = Integer.parseInt(relationCode);
                return ObjEnvelop.getSuccess("ok",businessOrderService.selectById(id));
                return ObjEnvelop.getSuccess("ok", businessOrderService.selectById(id));
            }
            return ObjEnvelop.getSuccess("ok",businessOrderService.selectStatus(relationCode));
            return ObjEnvelop.getSuccess("ok", businessOrderService.selectStatus(relationCode));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    /**
     * 查询支付状态
     *
     * @param id
     * @return
     * @throws Exception
     */
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.selectOrderStatusById)
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.selectOrderStatusById)
    @ApiOperation("查询支付状态")
    public ObjEnvelop selectOrderStatusById(
            @ApiParam(name = "id", value = "订单id", required = true)
            @RequestParam(required = true)Integer id) throws Exception {
            @RequestParam(required = true) Integer id) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",businessOrderService.selectStatusById(id));
            return ObjEnvelop.getSuccess("ok", businessOrderService.selectStatusById(id));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
@ -1995,47 +2043,47 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    /**
     * 查询支付info
     *
     * @param relationCode
     * @return
     * @throws Exception
     */
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.selectOrderListStatus)
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.selectOrderListStatus)
    @ApiOperation("查询支付info")
    public ObjEnvelop selectOrderListStatus(
            @ApiParam(name = "relationCode", value = "relationCode", required = true)
            @RequestParam(required = true)String relationCode) throws Exception {
            @RequestParam(required = true) String relationCode) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",businessOrderService.selectListStatus(relationCode));
            return ObjEnvelop.getSuccess("ok", businessOrderService.selectListStatus(relationCode));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    /**
     * 易联众统一退款
     *
     *
     * @throws Exception
     */
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.ylzRefund)
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.ylzRefund)
    @ApiOperation("易联众统一退款")
    public ObjEnvelop ylzRefund(
            @ApiParam(name = "patient", value = "patient", required = true)
            @RequestParam(required = true)String patient,
            @RequestParam(required = true) String patient,
            @ApiParam(name = "orderNo", value = "orderNo", required = true)
            @RequestParam(required = true)String orderNo,
            @RequestParam(required = true) String orderNo,
            @ApiParam(name = "refundPrice", value = "refundPrice", required = true)
            @RequestParam(required = true)Double refundPrice,
            @RequestParam(required = true) Double refundPrice,
            @ApiParam(name = "description", value = "description", required = true)
            @RequestParam(required = true)String description) throws Exception {
            @RequestParam(required = true) String description) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",businessOrderService.ylzOrderRefund(wxId,patient,orderNo,refundPrice,description));
            return ObjEnvelop.getSuccess("ok", businessOrderService.ylzOrderRefund(wxId, patient, orderNo, refundPrice, description));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    
    
    /**
     * 易联众统一订单查询
     *
@ -2044,83 +2092,84 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
     * @return
     * @throws Exception
     */
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.tradeQuery)
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.tradeQuery)
    @ApiOperation("易联众统一订单查询")
    public ObjEnvelop tradeQuery(
            @ApiParam(name = "tradeType", value = "tradeType", required = true)
            @RequestParam(required = true)String tradeType,
            @RequestParam(required = true) String tradeType,
            @ApiParam(name = "orderNo", value = "orderNo", required = true)
            @RequestParam(required = true)String orderNo) throws Exception {
            @RequestParam(required = true) String orderNo) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",businessOrderService.tradeQuery(orderNo,tradeType));
            return ObjEnvelop.getSuccess("ok", businessOrderService.tradeQuery(orderNo, tradeType));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.selectPrescriptionList)
    @ApiOperation(value = "查询处方列表")
    public ListEnvelop findPrescriptionList(@ApiParam(name = "hospital", value = "医院code")
                                            @RequestParam(value = "hospital",required = false)String hospital,
                                            @RequestParam(value = "hospital", required = false) String hospital,
                                            @ApiParam(name = "dept", value = "科室code")
                                            @RequestParam(value = "dept",required = false)String dept,
                                            @RequestParam(value = "dept", required = false) String dept,
                                            @ApiParam(name = "status", value = "状态")
                                            @RequestParam(value = "status",required = false)String status,
                                            @RequestParam(value = "status", required = false) String status,
                                            @ApiParam(name = "startTime", value = "开始时间")
                                            @RequestParam(value = "startTime",required = false)String startTime,
                                            @RequestParam(value = "startTime", required = false) String startTime,
                                            @ApiParam(name = "endTime", value = "结束时间")
                                            @RequestParam(value = "endTime",required = false)String endTime,
                                            @RequestParam(value = "endTime", required = false) String endTime,
                                            @ApiParam(name = "nameinfo", value = "医生名字/患者名字")
                                            @RequestParam(value = "nameinfo",required = false)String nameinfo,
                                            @RequestParam(value = "nameinfo", required = false) String nameinfo,
                                            @ApiParam(name = "page", value = "第几页")
                                            @RequestParam(value = "page",required = false)Integer page,
                                            @RequestParam(value = "page", required = false) Integer page,
                                            @ApiParam(name = "pagesize", value = "每页大小")
                                            @RequestParam(value = "pagesize",required = false)Integer pagesize) {
                                            @RequestParam(value = "pagesize", required = false) Integer pagesize) {
        try {
            return success(prescriptionService.selectByCondition(hospital,dept,status,startTime,endTime,nameinfo,page,pagesize,wxId));
        }catch (Exception e) {
            return success(prescriptionService.selectByCondition(hospital, dept, status, startTime, endTime, nameinfo, page, pagesize, wxId));
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.updateStatus)
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.updateStatus)
    @ApiOperation("完成自取")
    public ObjEnvelop updateStatus(
            @ApiParam(name = "prescriptionId", value = "prescriptionId", required = true)
            @RequestParam(required = true)String prescriptionId,
            @RequestParam(required = true) String prescriptionId,
            @ApiParam(name = "status", value = "status", required = true)
            @RequestParam(required = true)Integer status) throws Exception {
            @RequestParam(required = true) Integer status) throws Exception {
        try {
            prescriptionService.updateStatus(prescriptionId,status);
            return ObjEnvelop.getSuccess("ok",null);
            prescriptionService.updateStatus(prescriptionId, status);
            return ObjEnvelop.getSuccess("ok", null);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    /**
     * 更改单号
     *
     * @param id
     * @param mailNo
     * @return
     * @throws Exception
     */
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.updateMailNoById)
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.updateMailNoById)
    @ApiOperation("更改单号")
    public ObjEnvelop updateMailNoById(
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(required = true)String id,
            @RequestParam(required = true) String id,
            @ApiParam(name = "mailNo", value = "mailNo", required = true)
            @RequestParam(required = true)String mailNo) throws Exception {
            @RequestParam(required = true) String mailNo) throws Exception {
        try {
            prescriptionService.updateMailNoById(id,mailNo);
            return ObjEnvelop.getSuccess("ok",null);
            prescriptionService.updateMailNoById(id, mailNo);
            return ObjEnvelop.getSuccess("ok", null);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    /**
     * 处方-- 审方
     *
@ -2132,65 +2181,65 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
     * @return
     * @throws Exception
     */
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.prescriptionCheck)
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.prescriptionCheck)
    @ApiOperation("处方-审方")
    public ObjEnvelop prescriptionCheck(
            @ApiParam(name = "operate", value = "审核人", required = true)
            @RequestParam(required = true)String operate,
            @RequestParam(required = true) String operate,
            @ApiParam(name = "operateName", value = "审核人名字", required = true)
            @RequestParam(required = true)String operateName,
            @RequestParam(required = true) String operateName,
            @ApiParam(name = "reason", value = "审核原因", required = true)
            @RequestParam(required = true)String reason,
            @RequestParam(required = true) String reason,
            @ApiParam(name = "status", value = "0未审核1审核退回2审核通过", required = true)
            @RequestParam(required = true)Integer status,
            @RequestParam(required = true) Integer status,
            @ApiParam(name = "prescriptionId", value = "prescriptionId", required = true)
            @RequestParam(required = true)String prescriptionId) throws Exception {
    
        WlyyPrescriptionCheckDO wlyyPrescriptionCheckDO = prescriptionService.saveCheck(operate,operateName,reason,status,prescriptionId,wxId);
            @RequestParam(required = true) String prescriptionId) throws Exception {
        WlyyPrescriptionCheckDO wlyyPrescriptionCheckDO = prescriptionService.saveCheck(operate, operateName, reason, status, prescriptionId, wxId);
        try {
            WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionService.findPrescriptionDo(prescriptionId);
            WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findOne(wlyyPrescriptionDO.getOutpatientId());
            if (status==1){
            if (status == 1) {
                com.alibaba.fastjson.JSONObject msgObj = new com.alibaba.fastjson.JSONObject();
                msgObj.put("outpatientid",wlyyPrescriptionDO.getOutpatientId());
                msgObj.put("prescriptionId",prescriptionId);
                msgObj.put("reason",reason);
                String immsg = imService.pushPrescriptionBackMsg(msgObj,operate,operateName,wlyyPrescriptionDO.getOutpatientId(),wlyyOutpatientDO.getConsumer(),wlyyOutpatientDO.getOutpatientType(),wlyyOutpatientDO.getType());
                System.out.println("发送诊断消息成功:"+immsg);
            }else if (status==2){
                msgObj.put("outpatientid", wlyyPrescriptionDO.getOutpatientId());
                msgObj.put("prescriptionId", prescriptionId);
                msgObj.put("reason", reason);
                String immsg = imService.pushPrescriptionBackMsg(msgObj, operate, operateName, wlyyPrescriptionDO.getOutpatientId(), wlyyOutpatientDO.getConsumer(), wlyyOutpatientDO.getOutpatientType(), wlyyOutpatientDO.getType());
                System.out.println("发送诊断消息成功:" + immsg);
            } else if (status == 2) {
                JSONObject object = (JSONObject) JSONObject.toJSON(wlyyPrescriptionDO);
                System.out.println("wlyyPrescriptionDO参数入参"+object.toJSONString());
                WlyyPrescriptionVO prescriptionVO = JSONObject.toJavaObject(object,WlyyPrescriptionVO.class);
                List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(wlyyPrescriptionDO.getId(),1);
                System.out.println("wlyyPrescriptionDO参数入参" + object.toJSONString());
                WlyyPrescriptionVO prescriptionVO = JSONObject.toJavaObject(object, WlyyPrescriptionVO.class);
                List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(wlyyPrescriptionDO.getId(), 1);
                List<WlyyPrescriptionInfoVO> wlyyPrescriptionInfoVOS = new ArrayList<>();
                for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO:wlyyPrescriptionInfoDOS){
                for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO : wlyyPrescriptionInfoDOS) {
                    JSONObject jsonObject = (JSONObject) JSONObject.toJSON(wlyyPrescriptionInfoDO);
                    System.out.println("wlyyPrescriptionInfoDO参数入参"+jsonObject.toJSONString());
                    WlyyPrescriptionInfoVO prescriptionInfoVO = JSONObject.toJavaObject(jsonObject,WlyyPrescriptionInfoVO.class);
                    System.out.println("wlyyPrescriptionInfoDO参数入参" + jsonObject.toJSONString());
                    WlyyPrescriptionInfoVO prescriptionInfoVO = JSONObject.toJavaObject(jsonObject, WlyyPrescriptionInfoVO.class);
                    wlyyPrescriptionInfoVOS.add(prescriptionInfoVO);
                }
                prescriptionVO.setInfoVOs(wlyyPrescriptionInfoVOS);
                List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOS = prescriptionDiagnosisDao.findByPrescriptionId(wlyyPrescriptionDO.getId(),1);
                List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOS = prescriptionDiagnosisDao.findByPrescriptionId(wlyyPrescriptionDO.getId(), 1);
                List<WlyyPrescriptionDiagnosisVO> wlyyPrescriptionDiagnosisVOS = new ArrayList<>();
                for (WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO:wlyyPrescriptionDiagnosisDOS){
                for (WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO : wlyyPrescriptionDiagnosisDOS) {
                    JSONObject jsonObject = (JSONObject) JSONObject.toJSON(wlyyPrescriptionDiagnosisDO);
                    System.out.println("wlyyPrescriptionDiagnosisDO参数入参"+jsonObject.toJSONString());
                    WlyyPrescriptionDiagnosisVO prescriptionDiagnosisVO = JSONObject.toJavaObject(jsonObject,WlyyPrescriptionDiagnosisVO.class);
                    System.out.println("wlyyPrescriptionDiagnosisDO参数入参" + jsonObject.toJSONString());
                    WlyyPrescriptionDiagnosisVO prescriptionDiagnosisVO = JSONObject.toJavaObject(jsonObject, WlyyPrescriptionDiagnosisVO.class);
                    wlyyPrescriptionDiagnosisVOS.add(prescriptionDiagnosisVO);
                }
                prescriptionVO.setDiagnosisVOs(wlyyPrescriptionDiagnosisVOS);
                imService.pushPrescriptionImMessage(prescriptionVO);
            }
        }catch (Exception e){
            System.out.println("发送诊断消息失败:"+e.getMessage());
        } catch (Exception e) {
            System.out.println("发送诊断消息失败:" + e.getMessage());
//            e.printStackTrace();
        }
    
        return ObjEnvelop.getSuccess("ok",wlyyPrescriptionCheckDO);
        return ObjEnvelop.getSuccess("ok", wlyyPrescriptionCheckDO);
    }
    
    
    /**
     * 医生端-处方处理
     *
@ -2201,26 +2250,26 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
     * @return
     * @throws Exception
     */
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.savePrescriptionCheck)
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.savePrescriptionCheck)
    @ApiOperation("医生端-处方处理")
    public ObjEnvelop savePrescriptionCheck(
            @ApiParam(name = "operate", value = "操作人code", required = true)
            @RequestParam(required = true)String operate,
            @RequestParam(required = true) String operate,
            @ApiParam(name = "reason", value = "处理原因", required = true)
            @RequestParam(required = true)String reason,
            @RequestParam(required = true) String reason,
            @ApiParam(name = "status", value = "3处方修改4执行处方", required = true)
            @RequestParam(required = true)Integer status,
            @RequestParam(required = true) Integer status,
            @ApiParam(name = "prescriptionId", value = "处方id", required = true)
            @RequestParam(required = true)String prescriptionId) throws Exception {
            @RequestParam(required = true) String prescriptionId) throws Exception {
        try {
            //String operate,String operateName,String reason,Integer status,String prescriptionId
            return ObjEnvelop.getSuccess("ok",prescriptionService.savePrescriptionCheck(operate,reason,status,prescriptionId));
            return ObjEnvelop.getSuccess("ok", prescriptionService.savePrescriptionCheck(operate, reason, status, prescriptionId));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    
    /**
     * 查询审核历史记录
     *
@ -2228,64 +2277,65 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
     * @return
     * @throws Exception
     */
    @GetMapping(value= BaseHospitalRequestMapping.Prescription.prescriptionCheckList)
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.prescriptionCheckList)
    @ApiOperation("查询审核历史记录")
    public ObjEnvelop prescriptionCheckList(
            @ApiParam(name = "prescriptionId", value = "prescriptionId", required = true)
            @RequestParam(required = true)String prescriptionId) throws Exception {
            @RequestParam(required = true) String prescriptionId) throws Exception {
        try {
            
            return ObjEnvelop.getSuccess("ok",prescriptionService.findPrescriptionCheck(prescriptionId));
            return ObjEnvelop.getSuccess("ok", prescriptionService.findPrescriptionCheck(prescriptionId));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    
    /**
     * 查询单条处方记录
     *
     * @param prescriptionId
     * @return
     * @throws Exception
     */
    @GetMapping(value= BaseHospitalRequestMapping.Prescription.selectByPrescriptionId)
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.selectByPrescriptionId)
    @ApiOperation("查询单条处方记录")
    public ObjEnvelop selectByPrescriptionId(
            @ApiParam(name = "prescriptionId", value = "prescriptionId", required = true)
            @RequestParam(required = true)String prescriptionId) throws Exception {
            @RequestParam(required = true) String prescriptionId) throws Exception {
        try {
            
            return ObjEnvelop.getSuccess("ok",prescriptionService.selectByPrescriptionId(prescriptionId));
            return ObjEnvelop.getSuccess("ok", prescriptionService.selectByPrescriptionId(prescriptionId));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    
    
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.deleteById)
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.deleteById)
    @ApiOperation("医生端-逻辑删除业务数据")
    public ObjEnvelop deleteById(
            @ApiParam(name = "flag", value = "1药品2诊断3检查", required = true)
            @RequestParam(required = true)Integer flag,
            @RequestParam(required = true) Integer flag,
            @ApiParam(name = "id", value = "业务id", required = true)
            @RequestParam(required = true)String id) throws Exception {
            @RequestParam(required = true) String id) throws Exception {
        try {
            prescriptionService.deleteById(flag,id);
            return ObjEnvelop.getSuccess("ok",null);
            prescriptionService.deleteById(flag, id);
            return ObjEnvelop.getSuccess("ok", null);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value= BaseHospitalRequestMapping.Prescription.selectExpireTime)
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.selectExpireTime)
    @ApiOperation("查询过期时间")
    public ObjEnvelop selectExpireTime(
            @ApiParam(name = "relationCode", value = "relationCode", required = true)
            @RequestParam(required = true)String relationCode) throws Exception {
            @RequestParam(required = true) String relationCode) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",businessOrderService.selectOrderTime(relationCode));
            return ObjEnvelop.getSuccess("ok", businessOrderService.selectOrderTime(relationCode));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
@ -2314,17 +2364,18 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    /**
     * 查询电子病历
     *
     * @param prescriptionId
     * @return
     * @throws Exception
     */
    @GetMapping(value= BaseHospitalRequestMapping.Prescription.findEmrByPrescriptionId)
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findEmrByPrescriptionId)
    @ApiOperation("查询电子病历")
    public ObjEnvelop findByPrescriptionId(
            @ApiParam(name = "prescriptionId", value = "prescriptionId", required = true)
            @RequestParam(required = true)String prescriptionId) throws Exception {
            @RequestParam(required = true) String prescriptionId) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",prescriptionService.findByPrescriptionId(prescriptionId));
            return ObjEnvelop.getSuccess("ok", prescriptionService.findByPrescriptionId(prescriptionId));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
@ -2364,17 +2415,18 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    /**
     * 查询his电子病历
     *
     * @param registerSn
     * @return
     * @throws Exception
     */
    @GetMapping(value= BaseHospitalRequestMapping.Prescription.findHisEmr)
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findHisEmr)
    @ApiOperation("查询电子病历")
    public ObjEnvelop findHisEmr(
            @ApiParam(name = "registerSn", value = "registerSn", required = true)
            @RequestParam(required = true)String registerSn) throws Exception {
            @RequestParam(required = true) String registerSn) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",prescriptionService.readOutPatient(registerSn));
            return ObjEnvelop.getSuccess("ok", prescriptionService.readOutPatient(registerSn));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
@ -2382,33 +2434,34 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    /**
     * 查询his电子病历
     *
     * @param registerSn
     * @return
     * @throws Exception
     */
    @GetMapping(value= BaseHospitalRequestMapping.Prescription.findHisEmrXml)
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findHisEmrXml)
    @ApiOperation("查询电子病历")
    public ObjEnvelop findHisEmrXml(
            @ApiParam(name = "registerSn", value = "registerSn", required = true)
            @RequestParam(required = true)String registerSn) throws Exception {
            @RequestParam(required = true) String registerSn) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",prescriptionService.readOutPatientXml(registerSn));
            return ObjEnvelop.getSuccess("ok", prescriptionService.readOutPatientXml(registerSn));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value= BaseHospitalRequestMapping.Prescription.outpatient)
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.outpatient)
    @ApiOperation("门诊病历列表信息")
    public ObjEnvelop outpatient(
            @ApiParam(name = "patient", value = "patient", required = true)
            @RequestParam(required = true)String patient) throws Exception {
            @RequestParam(required = true) String patient) throws Exception {
        try {
            String doctorId=getUID();
            if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
                return ObjEnvelop.getSuccess("ok",xzzxEntranceService.selectHistoryEmrFromEntrance(patient,null));
            }else {
                return ObjEnvelop.getSuccess("ok",prescriptionService.outpatient(patient,doctorId));
            String doctorId = getUID();
            if (wxId.equalsIgnoreCase("xm_xzzx_wx")) {
                return ObjEnvelop.getSuccess("ok", xzzxEntranceService.selectHistoryEmrFromEntrance(patient, null));
            } else {
                return ObjEnvelop.getSuccess("ok", prescriptionService.outpatient(patient, doctorId));
            }
        } catch (Exception e) {
@ -2417,86 +2470,85 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value= BaseHospitalRequestMapping.Prescription.outpmedicaldoc)
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.outpmedicaldoc)
    @ApiOperation("医疗文书列表信息")
    public ObjEnvelop outpmedicaldoc(
            @ApiParam(name = "patient", value = "patient", required = true)
            @RequestParam(required = true)String patient) throws Exception {
            @RequestParam(required = true) String patient) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",prescriptionService.outpmedicaldoc(patient));
            return ObjEnvelop.getSuccess("ok", prescriptionService.outpmedicaldoc(patient));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value= BaseHospitalRequestMapping.Prescription.getPatInfoDataXml)
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getPatInfoDataXml)
    @ApiOperation("获取病历的PDF流")
    public ObjEnvelop getPatInfoDataXml(
            @ApiParam(name = "opid", value = "门诊病历", required = false)
            @RequestParam(required = false)String opid,
            @RequestParam(required = false) String opid,
            @ApiParam(name = "recSn", value = "医疗文书", required = false)
            @RequestParam(required = false)String recSn) throws Exception {
            @RequestParam(required = false) String recSn) throws Exception {
        try {
            if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
                return ObjEnvelop.getSuccess("ok",xzzxEntranceService.selectBrowseSingleEMR(opid));
            }else {
                return ObjEnvelop.getSuccess("ok",prescriptionService.getPatInfoDataXml(opid,recSn));
            if (wxId.equalsIgnoreCase("xm_xzzx_wx")) {
                return ObjEnvelop.getSuccess("ok", xzzxEntranceService.selectBrowseSingleEMR(opid));
            } else {
                return ObjEnvelop.getSuccess("ok", prescriptionService.getPatInfoDataXml(opid, recSn));
            }
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.saveEmr)
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.saveEmr)
    @ApiOperation("写入his电子病历")
    public ObjEnvelop findHisEmr(
            @ApiParam(name = "registerSn", value = "registerSn", required = true)
            @RequestParam(required = true)String registerSn,
            @RequestParam(required = true) String registerSn,
            @ApiParam(name = "chiefComplaint", value = "chiefComplaint", required = true)
            @RequestParam(required = true)String chiefComplaint,
            @RequestParam(required = true) String chiefComplaint,
            @ApiParam(name = "hpi", value = "hpi", required = true)
            @RequestParam(required = true)String hpi,
            @RequestParam(required = true) String hpi,
            @ApiParam(name = "elapsemhis", value = "elapsemhis", required = true)
            @RequestParam(required = true)String elapsemhis,
            @RequestParam(required = true) String elapsemhis,
            @ApiParam(name = "bodycheck", value = "bodycheck", required = true)
            @RequestParam(required = true)String bodycheck,
            @RequestParam(required = true) String bodycheck,
            @ApiParam(name = "assistanTcheck", value = "assistanTcheck", required = true)
            @RequestParam(required = true)String assistanTcheck,
            @RequestParam(required = true) String assistanTcheck,
            @ApiParam(name = "doctor", value = "doctor", required = true)
            @RequestParam(required = true)String doctor,
            @RequestParam(required = true) String doctor,
            @ApiParam(name = "doctorName", value = "doctorName", required = true)
            @RequestParam(required = true)String doctorName) throws Exception {
            @RequestParam(required = true) String doctorName) throws Exception {
        //String registerSn,String chiefComplaint,String hpi,String elapsemhis,String bodycheck,String assistanTcheck
        try {
            return ObjEnvelop.getSuccess("ok",prescriptionService.writeOutPatient(registerSn,chiefComplaint,hpi,elapsemhis,bodycheck,assistanTcheck,doctor,doctorName));
            return ObjEnvelop.getSuccess("ok", prescriptionService.writeOutPatient(registerSn, chiefComplaint, hpi, elapsemhis, bodycheck, assistanTcheck, doctor, doctorName));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findPatientAllPrescription)
    @ApiOperation(value = "查询患者所有处方信息", notes = "查询患者所有处方信息")
    public PageEnvelop findPatientAllPrescription(@ApiParam(name = "keyName", value = "搜索关键字")
                                                  @RequestParam(value = "keyName", required = false)String keyName,
                                                  @RequestParam(value = "keyName", required = false) String keyName,
                                                  @ApiParam(name = "status[]", value = "状态")
                                                  @RequestParam(value = "status[]", required = false)String status,
                                                  @RequestParam(value = "status[]", required = false) String status,
                                                  @ApiParam(name = "isSelectDrug", value = "1查询处方药品1是0查询检查")
                                                      @RequestParam(value = "isSelectDrug", required = false)String isSelectDrug,
                                                  @RequestParam(value = "isSelectDrug", required = false) String isSelectDrug,
                                                  @ApiParam(name = "patient", value = "患者id")
                                                      @RequestParam(value = "patient", required = false)String patient,
                                                  @RequestParam(value = "patient", required = false) String patient,
                                                  @ApiParam(name = "page", value = "第几页")
                                                  @RequestParam(value = "page",required = false,defaultValue = "1") Integer page,
                                                  @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
                                                  @ApiParam(name = "size", value = "页面大小")
                                                  @RequestParam(value = "size",required = false,defaultValue = "10") Integer size)throws Exception {
                                                  @RequestParam(value = "size", required = false, defaultValue = "10") Integer size) throws Exception {
        try {
            boolean consumerflag = false ;
            if (!StringUtils.isNoneBlank(patient)){
                patient=getUID();
                consumerflag=true;
            boolean consumerflag = false;
            if (!StringUtils.isNoneBlank(patient)) {
                patient = getUID();
                consumerflag = true;
            }
            return prescriptionService.findPatientAllPrescription(keyName,status,page,size,patient,isSelectDrug,consumerflag);
            return prescriptionService.findPatientAllPrescription(keyName, status, page, size, patient, isSelectDrug, consumerflag);
        } catch (Exception e) {
            return failedPageEnvelopException(e);
        }
@ -2505,13 +2557,13 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDrugAddress)
    @ApiOperation(value = "查看取药地址", notes = "查看取药地址")
    public MixEnvelop findDrugAddress(@ApiParam(name = "outpatientId", value = "关联门诊code")
                                      @RequestParam(value = "outpatientId", required = true)String outpatientId,
                                      @RequestParam(value = "outpatientId", required = true) String outpatientId,
                                      @ApiParam(name = "longitude", value = "经度")
                                      @RequestParam(value = "longitude",required = true) String longitude,
                                      @RequestParam(value = "longitude", required = true) String longitude,
                                      @ApiParam(name = "dimension", value = "维度")
                                      @RequestParam(value = "dimension",required = true) String dimension)throws Exception {
                                      @RequestParam(value = "dimension", required = true) String dimension) throws Exception {
        try {
            return prescriptionService.findDrugAddress(outpatientId,longitude,dimension);
            return prescriptionService.findDrugAddress(outpatientId, longitude, dimension);
        } catch (Exception e) {
            return failedMixEnvelopException(e);
        }
@ -2520,7 +2572,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findCommity)
    @ApiOperation(value = "获取居委会列表")
    public ListEnvelop<BaseCommitteeVO> findCommity (
    public ListEnvelop<BaseCommitteeVO> findCommity(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
@ -2531,7 +2583,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        try {
            List<BaseCommitteeDO> baseProvinces = baseCommitteeService.search(fields, filters, sorts);
            return success(baseProvinces, BaseCommitteeVO.class);
        }catch (Exception e) {
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
@ -2539,7 +2591,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findTown)
    @ApiOperation(value = "获取区列表")
    public ListEnvelop<BaseTownVO> list (
    public ListEnvelop<BaseTownVO> list(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
@ -2547,10 +2599,10 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        try{
        try {
            List<BaseTownDO> baseTowns = baseTownService.search(fields, filters, sorts);
            return success(baseTowns, BaseTownVO.class);
        }catch (Exception e) {
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
@ -2558,7 +2610,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findProvince)
    @ApiOperation(value = "获取省列表")
    public ListEnvelop<BaseProvinceVO> findProvince (
    public ListEnvelop<BaseProvinceVO> findProvince(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
@ -2569,14 +2621,14 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        try {
            List<BaseProvinceDO> baseProvinces = baseProvinceService.search(fields, filters, sorts);
            return success(baseProvinces, BaseProvinceVO.class);
        }catch (Exception e) {
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findCity)
    @ApiOperation(value = "获取市列表")
    public ListEnvelop<BaseCityVO> findCity (
    public ListEnvelop<BaseCityVO> findCity(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
@ -2587,33 +2639,35 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        try {
            List<BaseCityDO> baseCitys = baseCityService.search(fields, filters, sorts);
            return success(baseCitys, BaseCityVO.class);
        }catch (Exception e) {
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    /**
     * 获取诊间支付url
     *
     * @param prescriptionId
     * @return
     * @throws Exception
     */
    @GetMapping(value= BaseHospitalRequestMapping.Prescription.selectByUrl)
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.selectByUrl)
    @ApiOperation("获取诊间支付url")
    public ObjEnvelop selectByUrl(
            @ApiParam(name = "prescriptionId", value = "prescriptionId", required = false)
            @RequestParam(required = false)String prescriptionId,
            @RequestParam(required = false) String prescriptionId,
            @ApiParam(name = "oupatientId", value = "oupatientId", required = false)
            @RequestParam(required = false)String oupatientId,
            @RequestParam(required = false) String oupatientId,
            @ApiParam(name = "flag", value = "flag", required = false)
            @RequestParam(required = false)String flag,
            @RequestParam(required = false) String flag,
            @ApiParam(name = "channel", value = "WX、ALI", required = false)
            @RequestParam(required = false)String channel) throws Exception {
            @RequestParam(required = false) String channel) throws Exception {
        try {
            if (StringUtils.isNoneBlank(flag)){
            if (StringUtils.isNoneBlank(flag)) {
                Integer id = Integer.parseInt(oupatientId);
                return ObjEnvelop.getSuccess("ok",prescriptionService.selectByUrlHsjc(id,wxId,channel));
            }else {
                return ObjEnvelop.getSuccess("ok",prescriptionService.selectByUrl(oupatientId,prescriptionId,wxId));
                return ObjEnvelop.getSuccess("ok", prescriptionService.selectByUrlHsjc(id, wxId, channel));
            } else {
                return ObjEnvelop.getSuccess("ok", prescriptionService.selectByUrl(oupatientId, prescriptionId, wxId));
            }
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
@ -2622,32 +2676,32 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findPatientOpenId)
    @ApiOperation(value = "获取居民OpenId")
    public MixEnvelop findCity (
    public MixEnvelop findCity(
            @ApiParam(name = "patientCode", value = "居民code")
            @RequestParam(value = "patientCode", required = false) String patientCode) throws Exception {
      try {
          return   prescriptionService.findPatientOpenId(patientCode);
      } catch (Exception e) {
          return failedMixEnvelopException(e);
      }
        try {
            return prescriptionService.findPatientOpenId(patientCode);
        } catch (Exception e) {
            return failedMixEnvelopException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.updatePayStatus)
    @ApiOperation(value = "无需支付时调用")
    public ObjEnvelop updatePayStatus (
    public ObjEnvelop updatePayStatus(
            @ApiParam(name = "relationCode", value = "业务code")
            @RequestParam(value = "relationCode", required = false) String relationCode) throws Exception {
        try {
            BusinessOrderDO businessOrderDO = businessOrderService.updatePayStatusByRelation(relationCode,wxId);
            if (businessOrderDO.getOrderCategory().equalsIgnoreCase("2")){
            BusinessOrderDO businessOrderDO = businessOrderService.updatePayStatusByRelation(relationCode, wxId);
            if (businessOrderDO.getOrderCategory().equalsIgnoreCase("2")) {
                SystemMessageDO systemMessageDO = new SystemMessageDO();
                systemMessageDO.setType("1");
                systemMessageDO.setReceiver(businessOrderDO.getDoctor());
                systemMessageDO.setSender(businessOrderDO.getPatient());
                //发送IM消息
                hospitalSystemMessageService.sendImMessage(systemMessageDO);
            }else if (businessOrderDO.getOrderCategory().equalsIgnoreCase("3")){
            } else if (businessOrderDO.getOrderCategory().equalsIgnoreCase("3")) {
                SystemMessageDO systemMessageDO = new SystemMessageDO();
                systemMessageDO.setType("2");
                systemMessageDO.setReceiver(businessOrderDO.getDoctor());
@ -2655,7 +2709,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                //发送IM消息
                hospitalSystemMessageService.sendImMessage(systemMessageDO);
            }
            return ObjEnvelop.getSuccess("ok",businessOrderDO);
            return ObjEnvelop.getSuccess("ok", businessOrderDO);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
@ -2664,40 +2718,43 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findPatNoByPatient)
    @ApiOperation(value = "patient映射信息")
    public ObjEnvelop findPatNoByPatient (
    public ObjEnvelop findPatNoByPatient(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = false) String code) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",patientMappingService.findPatientNoByPatientCode(code));
            return ObjEnvelop.getSuccess("ok", patientMappingService.findPatientNoByPatientCode(code));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.popularityIncrease)
    @ApiOperation(value = "医生人气值增长")
    public Envelop popularityIncrease (
    public Envelop popularityIncrease(
            @ApiParam(name = "doctor", value = "医生id")
            @RequestParam(value = "doctor", required = false) String doctor) throws Exception {
        try {
            BaseDoctorDO baseDoctorDO=baseDoctorInfoService.popularityIncrease(doctor);
            return  success("操作成功",baseDoctorDO);
        }catch (Exception e) {
            BaseDoctorDO baseDoctorDO = baseDoctorInfoService.popularityIncrease(doctor);
            return success("操作成功", baseDoctorDO);
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.xzzxSelectExamApply)
    @ApiOperation(value = "检查项目查询接口")
    public ListEnvelop selectExamApply(
            @ApiParam(name = "spellCode", value = "拼音首字母")
            @RequestParam(value = "spellCode",defaultValue = "") String spellCode) throws Exception {
            @RequestParam(value = "spellCode", defaultValue = "") String spellCode) throws Exception {
        return success(xzzxEntranceService.selectExamApply(spellCode));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.xzzxSelectLisApply)
    @ApiOperation(value = "检验项目查询接口")
    public ListEnvelop selectLisApply(
            @ApiParam(name = "spellCode", value = "拼音首字母")
            @RequestParam(value = "spellCode",defaultValue = "") String spellCode) throws Exception {
            @RequestParam(value = "spellCode", defaultValue = "") String spellCode) throws Exception {
        return success(xzzxEntranceService.selectLisApply(spellCode));
    }
@ -2705,150 +2762,156 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "合理用药审核接口")
    public Envelop xzzxCheckInfo(
            @ApiParam(name = "prescriptionOnly", value = "处方唯一标识")
            @RequestParam(value = "prescriptionOnly",defaultValue = "") String prescriptionOnly,
            @RequestParam(value = "prescriptionOnly", defaultValue = "") String prescriptionOnly,
            @ApiParam(name = "payType", value = "付款方式0自费;1医保")
            @RequestParam(value = "payType",defaultValue = "") String payType,
            @RequestParam(value = "payType", defaultValue = "") String payType,
            @ApiParam(name = "doctor", value = "医生id")
            @RequestParam(value = "doctor",defaultValue = "") String doctor,
            @RequestParam(value = "doctor", defaultValue = "") String doctor,
            @ApiParam(name = "patient", value = "病人id")
            @RequestParam(value = "patient",defaultValue = "") String patient,
            @RequestParam(value = "patient", defaultValue = "") String patient,
            @ApiParam(name = "diagnosisDOS", value = "诊断json")
            @RequestParam(value = "diagnosisDOS",defaultValue = "") String diagnosisDOS,
            @RequestParam(value = "diagnosisDOS", defaultValue = "") String diagnosisDOS,
            @ApiParam(name = "infos", value = "药品json")
            @RequestParam(value = "infos",defaultValue = "") String infos) throws Exception {
            @RequestParam(value = "infos", defaultValue = "") String infos) throws Exception {
        JSONArray druginfos = JSONArray.parseArray(infos);
        List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = new ArrayList<>();
        for (int i=0;i<druginfos.size();i++){
            WlyyPrescriptionInfoDO wlyyPrescriptionInfo = toEntity(druginfos.get(i).toString(),WlyyPrescriptionInfoDO.class);
        for (int i = 0; i < druginfos.size(); i++) {
            WlyyPrescriptionInfoDO wlyyPrescriptionInfo = toEntity(druginfos.get(i).toString(), WlyyPrescriptionInfoDO.class);
            wlyyPrescriptionInfoDOS.add(wlyyPrescriptionInfo);
        }
        JSONArray diagnosis = JSONArray.parseArray(diagnosisDOS);
        List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOS = new ArrayList<>();
        for (int i=0;i<diagnosis.size();i++){
            WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO = toEntity(diagnosis.get(i).toString(),WlyyPrescriptionDiagnosisDO.class);
        for (int i = 0; i < diagnosis.size(); i++) {
            WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO = toEntity(diagnosis.get(i).toString(), WlyyPrescriptionDiagnosisDO.class);
            wlyyPrescriptionDiagnosisDOS.add(wlyyPrescriptionDiagnosisDO);
        }
        return success(xzzxEntranceService.checkInputInfo(prescriptionOnly,payType,doctor,patient,wlyyPrescriptionDiagnosisDOS,wlyyPrescriptionInfoDOS));
        return success(xzzxEntranceService.checkInputInfo(prescriptionOnly, payType, doctor, patient, wlyyPrescriptionDiagnosisDOS, wlyyPrescriptionInfoDOS));
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.xzzxSaveCheckInfo)
    @ApiOperation(value = "合理用药审核通过后保存接口")
    public Envelop xzzxSaveCheckInfo(
            @ApiParam(name = "prescriptionOnly", value = "处方唯一标识")
            @RequestParam(value = "prescriptionOnly",defaultValue = "") String prescriptionOnly,
            @RequestParam(value = "prescriptionOnly", defaultValue = "") String prescriptionOnly,
            @ApiParam(name = "payType", value = "付款方式0自费;1医保")
            @RequestParam(value = "payType",defaultValue = "") String payType,
            @RequestParam(value = "payType", defaultValue = "") String payType,
            @ApiParam(name = "doctor", value = "医生id")
            @RequestParam(value = "doctor",defaultValue = "") String doctor,
            @RequestParam(value = "doctor", defaultValue = "") String doctor,
            @ApiParam(name = "patient", value = "病人id")
            @RequestParam(value = "patient",defaultValue = "") String patient,
            @RequestParam(value = "patient", defaultValue = "") String patient,
            @ApiParam(name = "diagnosisDOS", value = "诊断json")
            @RequestParam(value = "diagnosisDOS",defaultValue = "") String diagnosisDOS,
            @RequestParam(value = "diagnosisDOS", defaultValue = "") String diagnosisDOS,
            @ApiParam(name = "infos", value = "药品json")
            @RequestParam(value = "infos",defaultValue = "") String infos) throws Exception {
            @RequestParam(value = "infos", defaultValue = "") String infos) throws Exception {
        JSONArray druginfos = JSONArray.parseArray(infos);
        List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = new ArrayList<>();
        for (int i=0;i<druginfos.size();i++){
            WlyyPrescriptionInfoDO wlyyPrescriptionInfo = toEntity(druginfos.get(i).toString(),WlyyPrescriptionInfoDO.class);
        for (int i = 0; i < druginfos.size(); i++) {
            WlyyPrescriptionInfoDO wlyyPrescriptionInfo = toEntity(druginfos.get(i).toString(), WlyyPrescriptionInfoDO.class);
            wlyyPrescriptionInfoDOS.add(wlyyPrescriptionInfo);
        }
        JSONArray diagnosis = JSONArray.parseArray(diagnosisDOS);
        List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOS = new ArrayList<>();
        for (int i=0;i<diagnosis.size();i++){
            WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO = toEntity(diagnosis.get(i).toString(),WlyyPrescriptionDiagnosisDO.class);
        for (int i = 0; i < diagnosis.size(); i++) {
            WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO = toEntity(diagnosis.get(i).toString(), WlyyPrescriptionDiagnosisDO.class);
            wlyyPrescriptionDiagnosisDOS.add(wlyyPrescriptionDiagnosisDO);
        }
        return success(xzzxEntranceService.saveCheckInputInfo(prescriptionOnly,payType,doctor,patient,wlyyPrescriptionDiagnosisDOS,wlyyPrescriptionInfoDOS));
        return success(xzzxEntranceService.saveCheckInputInfo(prescriptionOnly, payType, doctor, patient, wlyyPrescriptionDiagnosisDOS, wlyyPrescriptionInfoDOS));
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.xzzxDeleteCheckInfo)
    @ApiOperation(value = "合理用药作废处方接口")
    public Envelop deleteCheckInputInfo(
            @ApiParam(name = "prescriptionOnly", value = "处方唯一标识")
            @RequestParam(value = "prescriptionOnly",defaultValue = "") String prescriptionOnly,
            @RequestParam(value = "prescriptionOnly", defaultValue = "") String prescriptionOnly,
            @ApiParam(name = "payType", value = "付款方式0自费;1医保")
            @RequestParam(value = "payType",defaultValue = "") String payType,
            @RequestParam(value = "payType", defaultValue = "") String payType,
            @ApiParam(name = "doctor", value = "医生id")
            @RequestParam(value = "doctor",defaultValue = "") String doctor,
            @RequestParam(value = "doctor", defaultValue = "") String doctor,
            @ApiParam(name = "patient", value = "病人id")
            @RequestParam(value = "patient",defaultValue = "") String patient,
            @RequestParam(value = "patient", defaultValue = "") String patient,
            @ApiParam(name = "diagnosisDOS", value = "诊断json")
            @RequestParam(value = "diagnosisDOS",defaultValue = "") String diagnosisDOS) throws Exception {
            @RequestParam(value = "diagnosisDOS", defaultValue = "") String diagnosisDOS) throws Exception {
        JSONArray diagnosis = JSONArray.parseArray(diagnosisDOS);
        List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOS = new ArrayList<>();
        for (int i=0;i<diagnosis.size();i++){
            WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO = toEntity(diagnosis.get(i).toString(),WlyyPrescriptionDiagnosisDO.class);
        for (int i = 0; i < diagnosis.size(); i++) {
            WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO = toEntity(diagnosis.get(i).toString(), WlyyPrescriptionDiagnosisDO.class);
            wlyyPrescriptionDiagnosisDOS.add(wlyyPrescriptionDiagnosisDO);
        }
        return success(xzzxEntranceService.deleteCheckInputInfo(prescriptionOnly,payType,doctor,patient,wlyyPrescriptionDiagnosisDOS));
        return success(xzzxEntranceService.deleteCheckInputInfo(prescriptionOnly, payType, doctor, patient, wlyyPrescriptionDiagnosisDOS));
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.updatePatientDiagnosis)
    @ApiOperation(value = "更新患者诊断记录")
    public Envelop updatePatientDiagnosis(
            @ApiParam(name = "outpatientId", value = "outpatientId")
            @RequestParam(value = "outpatientId",defaultValue = "",required = true) String outpatientId,
            @RequestParam(value = "outpatientId", defaultValue = "", required = true) String outpatientId,
            @ApiParam(name = "icd10", value = "诊断码")
            @RequestParam(value = "icd10",defaultValue = "") String icd10,
            @RequestParam(value = "icd10", defaultValue = "") String icd10,
            @ApiParam(name = "icd10Name", value = "诊断名称")
            @RequestParam(value = "icd10Name",defaultValue = "") String icd10Name) throws Exception {
            @RequestParam(value = "icd10Name", defaultValue = "") String icd10Name) throws Exception {
        try {
            return prescriptionService.updatePatientDiagnosis(outpatientId,icd10,icd10Name);
        }catch (Exception e) {
            return prescriptionService.updatePatientDiagnosis(outpatientId, icd10, icd10Name);
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.delHisPrescriptionByHisNo)
    @ApiOperation(value = "删除his处方信息")
    public ObjEnvelop delHisPrescriptionByHisNo(
            @ApiParam(name = "realOrder", value = "realOrder")
            @RequestParam(value = "realOrder",defaultValue = "",required = true) String realOrder) throws Exception {
            @RequestParam(value = "realOrder", defaultValue = "", required = true) String realOrder) throws Exception {
        ObjEnvelop objEnvelop = new ObjEnvelop();
        objEnvelop.setObj(xzzxEntranceService.deletePrescriptionToEntrance(realOrder));
        return objEnvelop;
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.saveEmrToEntrance)
    @ApiOperation(value = "保存电子病历")
    public ObjEnvelop saveEmr(
            @ApiParam(name = "prescriptionId", value = "prescriptionId")
            @RequestParam(value = "prescriptionId",defaultValue = "",required = true) String prescriptionId,
            @RequestParam(value = "prescriptionId", defaultValue = "", required = true) String prescriptionId,
            @ApiParam(name = "baseSign", value = "baseSign")
            @RequestParam(value = "baseSign",defaultValue = "",required = false) String baseSign) throws Exception {
            @RequestParam(value = "baseSign", defaultValue = "", required = false) String baseSign) throws Exception {
        ObjEnvelop objEnvelop = new ObjEnvelop();
        objEnvelop.setObj(xzzxEntranceService.saveEmrToEntrance(prescriptionId,baseSign));
        objEnvelop.setObj(xzzxEntranceService.saveEmrToEntrance(prescriptionId, baseSign));
        return objEnvelop;
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.prescriptionManage)
    @ApiOperation(value = "处方管理")
    public MixEnvelop prescriptionManage(
            @ApiParam(name = "keyWord", value = "患者姓名或证件号或就诊卡")
            @RequestParam(value = "keyWord",defaultValue = "",required = false) String keyWord,
            @RequestParam(value = "keyWord", defaultValue = "", required = false) String keyWord,
            @ApiParam(name = "doctorId", value = "医生id")
            @RequestParam(value = "doctorId",defaultValue = "",required = false) String doctorId,
            @RequestParam(value = "doctorId", defaultValue = "", required = false) String doctorId,
            @ApiParam(name = "startTime", value = "开始时间")
            @RequestParam(value = "startTime",defaultValue = "",required = false) String startTime,
            @RequestParam(value = "startTime", defaultValue = "", required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间")
            @RequestParam(value = "endTime",defaultValue = "",required = false) String endTime,
            @RequestParam(value = "endTime", defaultValue = "", required = false) String endTime,
            @ApiParam(name = "checkStatus", value = "处方审核状态")
            @RequestParam(value = "checkStatus",defaultValue = "",required = false) String checkStatus,
            @RequestParam(value = "checkStatus", defaultValue = "", required = false) String checkStatus,
            @ApiParam(name = "status", value = "处方状态")
            @RequestParam(value = "status",defaultValue = "",required = false) String status,
            @RequestParam(value = "status", defaultValue = "", required = false) String status,
            @ApiParam(name = "page", value = "页数")
            @RequestParam(value = "page",defaultValue = "",required = false) Integer page,
            @ApiParam(name = "pageSize",value = "页大小")
            @RequestParam(value = "pageSize",defaultValue = "",required = false) Integer pageSize) throws Exception {
            @RequestParam(value = "page", defaultValue = "", required = false) Integer page,
            @ApiParam(name = "pageSize", value = "页大小")
            @RequestParam(value = "pageSize", defaultValue = "", required = false) Integer pageSize) throws Exception {
        try {
            return prescriptionService.prescriptionManage(keyWord,doctorId,startTime,endTime,checkStatus,status,page,pageSize);
        }catch (Exception e) {
            return prescriptionService.prescriptionManage(keyWord, doctorId, startTime, endTime, checkStatus, status, page, pageSize);
        } catch (Exception e) {
            return failedMixEnvelopException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.disablePrescription)
    @ApiOperation(value = "作废处方")
    public Envelop disablePrescription(
            @ApiParam(name = "prescriptionId", value = "prescriptionId")
            @RequestParam(value = "prescriptionId",defaultValue = "",required = true) String prescriptionId) throws Exception {
            @RequestParam(value = "prescriptionId", defaultValue = "", required = true) String prescriptionId) throws Exception {
        return success(prescriptionService.disablePrescription(prescriptionId));
    }
@ -2858,47 +2921,50 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "生成小程序秘钥")
    public Envelop appletSign(
            @ApiParam(name = "userId", value = "userId")
            @RequestParam(value = "userId",defaultValue = "",required = true) String userId,
            @RequestParam(value = "userId", defaultValue = "", required = true) String userId,
            @ApiParam(name = "channelName", value = "channelName")
            @RequestParam(value = "channelName",defaultValue = "",required = false) String channelName,
            @RequestParam(value = "channelName", defaultValue = "", required = false) String channelName,
            @ApiParam(name = "flag", value = "flag")
            @RequestParam(value = "flag",defaultValue = "",required = false) String flag) throws Exception {
        if (StringUtils.isNoneBlank(flag)&&flag.equalsIgnoreCase("yx")){
            return success(prescriptionService.yxToken2(userId,channelName));
        }else {
            @RequestParam(value = "flag", defaultValue = "", required = false) String flag) throws Exception {
        if (StringUtils.isNoneBlank(flag) && flag.equalsIgnoreCase("yx")) {
            return success(prescriptionService.yxToken2(userId, channelName));
        } else {
            return success(prescriptionService.appletSign(userId));
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.yxToken20)
    @ApiOperation(value = "云信token2.0")
    public Envelop yxToken20(
            @ApiParam(name = "userId", value = "userId")
            @RequestParam(value = "userId",defaultValue = "",required = true) String userId,
            @RequestParam(value = "userId", defaultValue = "", required = true) String userId,
            @ApiParam(name = "channelName", value = "channelName")
            @RequestParam(value = "channelName",defaultValue = "",required = false) String channelName) throws Exception {
            @RequestParam(value = "channelName", defaultValue = "", required = false) String channelName) throws Exception {
        return success(prescriptionService.yxToken(userId,channelName));
        return success(prescriptionService.yxToken(userId, channelName));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.doorServiceTest)
    @ApiOperation(value = "测试上门复诊数据同步")
    public Envelop doorServiceTest(
            @ApiParam(name = "orderId", value = "orderId")
            @RequestParam(value = "orderId",defaultValue = "",required = false) String orderId,
            @RequestParam(value = "orderId", defaultValue = "", required = false) String orderId,
            @ApiParam(name = "prId", value = "prId")
            @RequestParam(value = "prId",defaultValue = "",required = false) String prId) throws Exception {
            @RequestParam(value = "prId", defaultValue = "", required = false) String prId) throws Exception {
        return success(prescriptionService.savePrescriptionToDoorService(orderId,prId));
        return success(prescriptionService.savePrescriptionToDoorService(orderId, prId));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.selectMzRecord)
    @ApiOperation(value = "查询门诊记录下的患者列表")
    public Envelop selectMzRecord(
            @ApiParam(name = "doctor", value = "doctor")
            @RequestParam(value = "doctor",defaultValue = "",required = true) String doctor,
            @RequestParam(value = "doctor", defaultValue = "", required = true) String doctor,
            @ApiParam(name = "patientName", value = "patientName")
            @RequestParam(value = "patientName",defaultValue = "",required = false) String patientName) throws Exception {
            @RequestParam(value = "patientName", defaultValue = "", required = false) String patientName) throws Exception {
        return success(tnyyEntranceService.selectMzRecord(doctor,patientName));
        return success(tnyyEntranceService.selectMzRecord(doctor, patientName));
    }
@ -2906,11 +2972,11 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "查询住院记录下的患者列表")
    public Envelop selectZyRecord(
            @ApiParam(name = "doctor", value = "doctor")
            @RequestParam(value = "doctor",defaultValue = "",required = true) String doctor,
            @RequestParam(value = "doctor", defaultValue = "", required = true) String doctor,
            @ApiParam(name = "patientName", value = "patientName")
            @RequestParam(value = "patientName",defaultValue = "",required = false) String patientName) throws Exception {
            @RequestParam(value = "patientName", defaultValue = "", required = false) String patientName) throws Exception {
        return success(tnyyEntranceService.selectZyRecord(doctor,patientName));
        return success(tnyyEntranceService.selectZyRecord(doctor, patientName));
    }
@ -2918,7 +2984,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "查询某个患者的住院记录")
    public Envelop findJKTA_V_ZKSG_HZCX_HIS(
            @ApiParam(name = "brid", value = "患者id")
            @RequestParam(value = "brid",defaultValue = "",required = true) String brid) throws Exception {
            @RequestParam(value = "brid", defaultValue = "", required = true) String brid) throws Exception {
        return success(tnyyEntranceService.findJKTA_V_ZKSG_HZCX_HIS(brid));
    }
@ -2928,40 +2994,42 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "查询某个患者的住院记录")
    public Envelop findJKTA_ZY_RECORD(
            @ApiParam(name = "brid", value = "患者id")
            @RequestParam(value = "brid",defaultValue = "",required = true) String brid) throws Exception {
            @RequestParam(value = "brid", defaultValue = "", required = true) String brid) throws Exception {
        return success(tnyyEntranceService.findJKTA_ZY_RECORD(brid));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.doctorUpcomingList2)
    @ApiOperation(value = "医生待办事项列表")
    public Envelop doctorUpcomingList2(@ApiParam(name = "doctorCode", value = "医生CODE")
                                      @RequestParam(value = "doctorCode",required = true) String doctorCode,
                                      @ApiParam(name = "type", value = "类型:1.视频复诊(16)、2.专科协同(12)、3.图文复诊(9)、4.专家咨询(1,15)")
                                      @RequestParam(value = "type",required = true) String type)throws Exception{
                                       @RequestParam(value = "doctorCode", required = true) String doctorCode,
                                       @ApiParam(name = "type", value = "类型:1.视频复诊(16)、2.专科协同(12)、3.图文复诊(9)、4.专家咨询(1,15)")
                                       @RequestParam(value = "type", required = true) String type) throws Exception {
        com.alibaba.fastjson.JSONArray array = new com.alibaba.fastjson.JSONArray();
        List<Map<String,Object>>  data = imService.doctorUpcomingList2(doctorCode, type);
        List<Map<String, Object>> data = imService.doctorUpcomingList2(doctorCode, type);
        if (data != null) {
            for (Map<String,Object> consult : data) {
                if("1,15,17".equals(type)){//专家咨询
                    Integer consultType =  Integer.parseInt(consult.get("type").toString());
                    if(1 == consultType){//专家咨询
                        consult.put("session_id", consult.get("consumer").toString()+"_"+ consult.get("outpatientId").toString()+"_1");
                    }else if(15 == consultType){//家医求助
                        consult.put("session_id", consult.get("consumer").toString()+"_"+ consult.get("outpatientId").toString()+"_"+ consult.get("doctorCode").toString()+"_15");
                    }else if (17==consultType){//视频咨询
                        consult.put("session_id", consult.get("consumer").toString()+"_"+ consult.get("outpatientId").toString()+"_17");
            for (Map<String, Object> consult : data) {
                if ("1,15,17".equals(type)) {//专家咨询
                    Integer consultType = Integer.parseInt(consult.get("type").toString());
                    if (1 == consultType) {//专家咨询
                        consult.put("session_id", consult.get("consumer").toString() + "_" + consult.get("outpatientId").toString() + "_1");
                    } else if (15 == consultType) {//家医求助
                        consult.put("session_id", consult.get("consumer").toString() + "_" + consult.get("outpatientId").toString() + "_" + consult.get("doctorCode").toString() + "_15");
                    } else if (17 == consultType) {//视频咨询
                        consult.put("session_id", consult.get("consumer").toString() + "_" + consult.get("outpatientId").toString() + "_17");
                    }
                }else if("9".equals(type)){//图文复诊
                    consult.put("session_id", consult.get("consumer").toString()+"_"+consult.get("outpatientId").toString()+"_9");
                    consult.put("type",type);
                }else if("16".equals(type)){//视频复诊
                    consult.put("session_id", consult.get("consumer").toString()+"_"+consult.get("outpatientId").toString()+"_16");
                    consult.put("type",type);
                }else if("12".equals(type)){//协同门诊
                    consult.put("session_id", consult.get("consumer").toString()+"_"+consult.get("outpatientId").toString()+"_12");
                    consult.put("type",type);
                }else{}
                } else if ("9".equals(type)) {//图文复诊
                    consult.put("session_id", consult.get("consumer").toString() + "_" + consult.get("outpatientId").toString() + "_9");
                    consult.put("type", type);
                } else if ("16".equals(type)) {//视频复诊
                    consult.put("session_id", consult.get("consumer").toString() + "_" + consult.get("outpatientId").toString() + "_16");
                    consult.put("type", type);
                } else if ("12".equals(type)) {//协同门诊
                    consult.put("session_id", consult.get("consumer").toString() + "_" + consult.get("outpatientId").toString() + "_12");
                    consult.put("type", type);
                } else {
                }
                array.add(consult);
            }
@ -2972,23 +3040,23 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @GetMapping("/BS10142")
    public ListEnvelop BS10142(
            @ApiParam(name = "deptCode", value = "deptCode")
            @RequestParam(value = "deptCode",required = false)String deptCode,
            @RequestParam(value = "deptCode", required = false) String deptCode,
            @ApiParam(name = "docCode", value = "docCode")
            @RequestParam(value = "docCode",required = false)String docCode,
            @RequestParam(value = "docCode", required = false) String docCode,
            @ApiParam(name = "chargeType", value = "chargeType")
            @RequestParam(value = "chargeType",required = false)String chargeType) throws Exception {
        if("xm_zsyy_wx".equalsIgnoreCase(wxId)){
            return success(entranceService.BS10142(deptCode,docCode,chargeType,demoFlag));
        }else if ("xm_tasy_wx".equalsIgnoreCase(wxId)){
            String res=tasyNatService.departMent(deptCode);
            String dept="";
            @RequestParam(value = "chargeType", required = false) String chargeType) throws Exception {
        if ("xm_zsyy_wx".equalsIgnoreCase(wxId)) {
            return success(entranceService.BS10142(deptCode, docCode, chargeType, demoFlag));
        } else if ("xm_tasy_wx".equalsIgnoreCase(wxId)) {
            String res = tasyNatService.departMent(deptCode);
            String dept = "";
            WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("tasyNatDept");
            if (wlyyHospitalSysDictDO!=null){
                dept=wlyyHospitalSysDictDO.getDictValue();
            if (wlyyHospitalSysDictDO != null) {
                dept = wlyyHospitalSysDictDO.getDictValue();
            }
            JSONObject deptres = JSON.parseObject(res);
            if (deptres!=null){
                if (deptres.getString("success").equalsIgnoreCase("true")){
            if (deptres != null) {
                if (deptres.getString("success").equalsIgnoreCase("true")) {
                    /*JSONObject data = JSON.parseObject(deptres.getString("data"));
                    String depts=data.getString("Dept");
                    JSONArray jsonArray1 = JSON.parseArray(depts);
@ -3003,44 +3071,45 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                        }
                    }*/
                    String json=tasyNatService.GetDoctorWorkDate("3",dept);
                    String json = tasyNatService.GetDoctorWorkDate("3", dept);
                    JSONObject jsonObject = JSON.parseObject(json);
                    jsonObject.put("dept",dept);
                    jsonObject.put("dept", dept);
                    com.alibaba.fastjson.JSONArray jsonArray = new com.alibaba.fastjson.JSONArray();
                    jsonArray.add(jsonObject);
                    return success(jsonArray);
                }else {
                } else {
                    return ListEnvelop.getError("获取部门编码失败");
                }
            }else {
            } else {
                return ListEnvelop.getError("无效部门");
            }
        }else {
        } else {
            return ListEnvelop.getError("未开放");
        }
    }
    @GetMapping("/BS10143")
    public ListEnvelop BS10143(@ApiParam(name = "day", value = "day")
                               @RequestParam(value = "day",required = false)String day,
                               @RequestParam(value = "day", required = false) String day,
                               @ApiParam(name = "dept", value = "dept")
                               @RequestParam(value = "dept",required = false)String dept,
                               @RequestParam(value = "dept", required = false) String dept,
                               @ApiParam(name = "doctor", value = "doctor")
                                   @RequestParam(value = "doctor",required = false)String doctor,
                               @RequestParam(value = "doctor", required = false) String doctor,
                               @ApiParam(name = "IsAll", value = "IsAll")
                                   @RequestParam(value = "IsAll",required = false)String IsAll,
                               @RequestParam(value = "IsAll", required = false) String IsAll,
                               @ApiParam(name = "pm", value = "pm")
                               @RequestParam(value = "pm",required = false)String pm) throws Exception {
        if("xm_zsyy_wx".equalsIgnoreCase(wxId)){
            return success(entranceService.BS10143(day,pm,false));
        }else if ("xm_tasy_wx".equalsIgnoreCase(wxId)){
            String res=tasyNatService.GetOrderSource(dept,doctor,day,"3",IsAll,pm);
            String xml="";
            if (!org.apache.axis.utils.StringUtils.isEmpty(res)){
                               @RequestParam(value = "pm", required = false) String pm) throws Exception {
        if ("xm_zsyy_wx".equalsIgnoreCase(wxId)) {
            return success(entranceService.BS10143(day, pm, false));
        } else if ("xm_tasy_wx".equalsIgnoreCase(wxId)) {
            String res = tasyNatService.GetOrderSource(dept, doctor, day, "3", IsAll, pm);
            String xml = "";
            if (!org.apache.axis.utils.StringUtils.isEmpty(res)) {
                JSONObject jsonObject = JSON.parseObject(res);
                System.out.println("====="+jsonObject.getString("success"));
                if (jsonObject!=null&&jsonObject.getString("success").equalsIgnoreCase("true")){
                    xml=jsonObject.getString("data");
                System.out.println("=====" + jsonObject.getString("success"));
                if (jsonObject != null && jsonObject.getString("success").equalsIgnoreCase("true")) {
                    xml = jsonObject.getString("data");
                    XMLSerializer xmlSerializer = new XMLSerializer();
                    String json = xmlSerializer.read(xml).toString();
                    JSONObject jsonObjectRes = JSON.parseObject(json);
@ -3050,98 +3119,101 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                }
            }
            return ListEnvelop.getError("查询失败");
        }else {
        } else {
            return ListEnvelop.getError("未开放");
        }
    }
    @GetMapping("/BS10144")
    public Envelop BS10144(@ApiParam(name = "deptCode", value = "deptCode")
                               @RequestParam(value = "deptCode",required = false)String deptCode,
                           @RequestParam(value = "deptCode", required = false) String deptCode,
                           @ApiParam(name = "docCode", value = "docCode")
                           @RequestParam(value = "docCode",required = false)String docCode,
                           @RequestParam(value = "docCode", required = false) String docCode,
                           @ApiParam(name = "startTime", value = "startTime")
                               @RequestParam(value = "startTime",required = false)String startTime,
                           @RequestParam(value = "startTime", required = false) String startTime,
                           @ApiParam(name = "sSID", value = "sSID")
                               @RequestParam(value = "sSID",required = false)String sSID,
                           @RequestParam(value = "sSID", required = false) String sSID,
                           @ApiParam(name = "patientName", value = "patientName")
                               @RequestParam(value = "patientName",required = false)String patientName,
                           @RequestParam(value = "patientName", required = false) String patientName,
                           @ApiParam(name = "patientID", value = "patientID")
                               @RequestParam(value = "patientID",required = false)String patientID,
                           @RequestParam(value = "patientID", required = false) String patientID,
                           @ApiParam(name = "patientPhone", value = "patientPhone")
                               @RequestParam(value = "patientPhone",required = false)String patientPhone,
                           @RequestParam(value = "patientPhone", required = false) String patientPhone,
                           @ApiParam(name = "pm", value = "pm")
                               @RequestParam(value = "pm",required = false)String pm) throws Exception {
        return success(entranceService.BS10144(deptCode,docCode,startTime,sSID,patientName,patientID,patientPhone,pm,demoFlag));
                           @RequestParam(value = "pm", required = false) String pm) throws Exception {
        return success(entranceService.BS10144(deptCode, docCode, startTime, sSID, patientName, patientID, patientPhone, pm, demoFlag));
    }
    @GetMapping("/BS10145")
    public Envelop BS10145(@ApiParam(name = "id", value = "id")
                               @RequestParam(value = "id",required = false)Integer id,
                           @RequestParam(value = "id", required = false) Integer id,
                           @ApiParam(name = "patientId", value = "patientId")
                               @RequestParam(value = "patientId",required = false)String patientId) throws Exception {
                           @RequestParam(value = "patientId", required = false) String patientId) throws Exception {
        try {
            return success(prescriptionService.cancelNatAppointment(id,patientId));
            return success(prescriptionService.cancelNatAppointment(id, patientId));
        } catch (Exception e) {
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping("/saveNatAppointment")
    @ApiOperation(value = "核酸检测预约接口")
    public Envelop saveNatAppointment(@ApiParam(name = "chargeAmount", value = "chargeAmount")
                                          @RequestParam(value = "chargeAmount",required = false)String chargeAmount,
                                      @RequestParam(value = "chargeAmount", required = false) String chargeAmount,
                                      @ApiParam(name = "inspectionName", value = "inspectionName")
                                          @RequestParam(value = "inspectionName",required = false)String inspectionName,
            @ApiParam(name = "mediaCard", value = "mediaCard")
                                          @RequestParam(value = "mediaCard",required = false)String mediaCard,
                                      @RequestParam(value = "inspectionName", required = false) String inspectionName,
                                      @ApiParam(name = "mediaCard", value = "mediaCard")
                                      @RequestParam(value = "mediaCard", required = false) String mediaCard,
                                      @ApiParam(name = "patientId", value = "patientId")
                                          @RequestParam(value = "patientId",required = false)String patientId,
                                      @RequestParam(value = "patientId", required = false) String patientId,
                                      @ApiParam(name = "name", value = "name")
                                          @RequestParam(value = "name",required = false)String name,
                                      @RequestParam(value = "name", required = false) String name,
                                      @ApiParam(name = "cardNo", value = "cardNo")
                                          @RequestParam(value = "cardNo",required = false)String cardNo,
                                      @RequestParam(value = "cardNo", required = false) String cardNo,
                                      @ApiParam(name = "cardType", value = "cardType")
                                          @RequestParam(value = "cardType",required = false)String cardType,
                                      @RequestParam(value = "cardType", required = false) String cardType,
                                      @ApiParam(name = "mobile", value = "mobile")
                                          @RequestParam(value = "mobile",required = false)String mobile,
                                      @RequestParam(value = "mobile", required = false) String mobile,
                                      @ApiParam(name = "firstJobCode", value = "firstJobCode")
                                          @RequestParam(value = "firstJobCode",required = false)String firstJobCode,
                                      @RequestParam(value = "firstJobCode", required = false) String firstJobCode,
                                      @ApiParam(name = "firstJobName", value = "firstJobName")
                                          @RequestParam(value = "firstJobName",required = false)String firstJobName,
                                      @RequestParam(value = "firstJobName", required = false) String firstJobName,
                                      @ApiParam(name = "secondJobCode", value = "secondJobCode")
                                          @RequestParam(value = "secondJobCode",required = false)String secondJobCode,
                                      @RequestParam(value = "secondJobCode", required = false) String secondJobCode,
                                      @ApiParam(name = "secondJobName", value = "secondJobName")
                                          @RequestParam(value = "secondJobName",required = false)String secondJobName,
                                      @RequestParam(value = "secondJobName", required = false) String secondJobName,
                                      @ApiParam(name = "natTime", value = "natTime")
                                          @RequestParam(value = "natTime",required = false)String natTime,
                                      @RequestParam(value = "natTime", required = false) String natTime,
                                      @ApiParam(name = "address", value = "address")
                                          @RequestParam(value = "address",required = false)String address,
                                      @RequestParam(value = "address", required = false) String address,
                                      @ApiParam(name = "provinceName", value = "provinceName")
                                          @RequestParam(value = "provinceName",required = false)String provinceName,
                                      @RequestParam(value = "provinceName", required = false) String provinceName,
                                      @ApiParam(name = "cityName", value = "cityName")
                                          @RequestParam(value = "cityName",required = false)String cityName,
                                      @RequestParam(value = "cityName", required = false) String cityName,
                                      @ApiParam(name = "townName", value = "townName")
                                          @RequestParam(value = "townName",required = false)String townName,
                                      @RequestParam(value = "townName", required = false) String townName,
                                      @ApiParam(name = "streetName", value = "streetName")
                                          @RequestParam(value = "streetName",required = false)String streetName,
                                      @RequestParam(value = "streetName", required = false) String streetName,
                                      @ApiParam(name = "pm", value = "pm")
                                          @RequestParam(value = "pm",required = false)String pm,
                                      @RequestParam(value = "pm", required = false) String pm,
                                      @ApiParam(name = "checkPart", value = "checkPart")
                                          @RequestParam(value = "checkPart",required = false)String checkPart,
                                      @RequestParam(value = "checkPart", required = false) String checkPart,
                                      @ApiParam(name = "pushFlag", value = "pushFlag")
                                          @RequestParam(value = "pushFlag",required = false)String pushFlag,
                                      @RequestParam(value = "pushFlag", required = false) String pushFlag,
                                      @ApiParam(name = "cardNoType", value = "cardNoType")
                                          @RequestParam(value = "cardNoType",required = false)String cardNoType,
                                      @RequestParam(value = "cardNoType", required = false) String cardNoType,
                                      @ApiParam(name = "chargeFlag", value = "chargeFlag")
                                          @RequestParam(value = "chargeFlag",required = false)String chargeFlag,
                                      @RequestParam(value = "chargeFlag", required = false) String chargeFlag,
                                      @ApiParam(name = "chargeCode", value = "chargeCode")
                                          @RequestParam(value = "chargeCode",required = false)String chargeCode,
                                      @RequestParam(value = "chargeCode", required = false) String chargeCode,
                                      @ApiParam(name = "icdCode", value = "icdCode")
                                          @RequestParam(value = "icdCode",required = false)String icdCode,
                                      @RequestParam(value = "icdCode", required = false) String icdCode,
                                      @ApiParam(name = "preNo", value = "preNo")
                                          @RequestParam(value = "preNo",required = false)String preNo){
                                      @RequestParam(value = "preNo", required = false) String preNo) {
        try {
            return success(prescriptionService.saveNatAppointment(chargeAmount,inspectionName,mediaCard,patientId,name,cardNo,cardType,mobile,firstJobCode,firstJobName,secondJobCode,secondJobName,natTime,address,provinceName,
                    cityName,townName,streetName,pm,pushFlag,cardNoType,getUID(),checkPart,chargeFlag,chargeCode,icdCode,preNo));
            return success(prescriptionService.saveNatAppointment(chargeAmount, inspectionName, mediaCard, patientId, name, cardNo, cardType, mobile, firstJobCode, firstJobName, secondJobCode, secondJobName, natTime, address, provinceName,
                    cityName, townName, streetName, pm, pushFlag, cardNoType, getUID(), checkPart, chargeFlag, chargeCode, icdCode, preNo));
        } catch (Exception e) {
            return Envelop.getError(e.getMessage());
        }
@ -3150,14 +3222,14 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @GetMapping("/sendMessage")
    @ApiOperation(value = "预约成功发送模板消息")
    public Envelop sendMessage( @ApiParam(name = "pushChannel", value = "pushChannel")
                                          @RequestParam(value = "pushChannel",required = false)String pushChannel,
                                      @ApiParam(name = "pushFlag", value = "pushFlag")
                                          @RequestParam(value = "pushFlag",required = false)String pushFlag,
                                      @ApiParam(name = "id", value = "id")
                                          @RequestParam(value = "id",required = false)Integer id) throws Exception {
        try {
            return success(prescriptionService.sendMessage(id,pushChannel,pushFlag));
    public Envelop sendMessage(@ApiParam(name = "pushChannel", value = "pushChannel")
                               @RequestParam(value = "pushChannel", required = false) String pushChannel,
                               @ApiParam(name = "pushFlag", value = "pushFlag")
                               @RequestParam(value = "pushFlag", required = false) String pushFlag,
                               @ApiParam(name = "id", value = "id")
                               @RequestParam(value = "id", required = false) Integer id) throws Exception {
        try {
            return success(prescriptionService.sendMessage(id, pushChannel, pushFlag));
        } catch (Exception e) {
            return Envelop.getError(e.getMessage());
        }
@ -3165,19 +3237,19 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @GetMapping("/sendAlipayMessage")
    public Envelop sendAlipayMessage(@ApiParam(name = "code", value = "code")
                           @RequestParam(value = "code",required = false)String code,
                           @ApiParam(name = "patientId", value = "patientId")
                           @RequestParam(value = "patientId",required = false)String patientId,
                           @ApiParam(name = "fee", value = "fee")
                           @RequestParam(value = "fee",required = false)String fee,
                           @ApiParam(name = "redirdctUrl", value = "redirdctUrl")
                           @RequestParam(value = "redirdctUrl",required = false)String redirdctUrl,
                          @ApiParam(name = "realorder", value = "realorder")
                          @RequestParam(value = "realorder",required = false)String realorder,
                          @ApiParam(name = "reserverTime", value = "reserverTime")
                          @RequestParam(value = "reserverTime",required = false)String reserverTime) throws Exception {
        try {
            return success(prescriptionService.sendAlipayMessage(patientId,code,fee,redirdctUrl,reserverTime,realorder));
                                     @RequestParam(value = "code", required = false) String code,
                                     @ApiParam(name = "patientId", value = "patientId")
                                     @RequestParam(value = "patientId", required = false) String patientId,
                                     @ApiParam(name = "fee", value = "fee")
                                     @RequestParam(value = "fee", required = false) String fee,
                                     @ApiParam(name = "redirdctUrl", value = "redirdctUrl")
                                     @RequestParam(value = "redirdctUrl", required = false) String redirdctUrl,
                                     @ApiParam(name = "realorder", value = "realorder")
                                     @RequestParam(value = "realorder", required = false) String realorder,
                                     @ApiParam(name = "reserverTime", value = "reserverTime")
                                     @RequestParam(value = "reserverTime", required = false) String reserverTime) throws Exception {
        try {
            return success(prescriptionService.sendAlipayMessage(patientId, code, fee, redirdctUrl, reserverTime, realorder));
        } catch (Exception e) {
            return Envelop.getError(e.getMessage());
        }
@ -3211,24 +3283,24 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "isSuccess", value = "1成功  0失败")
            @RequestParam(value = "isSuccess", required = false) Integer isSuccess,
            @ApiParam(name = "orderNo", value = "订单号")
            @RequestParam(value = "orderNo", required = false) String  orderNo,
            @RequestParam(value = "orderNo", required = false) String orderNo,
            @ApiParam(name = "page", value = "页数")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "pageSize", value = "每页大小")
            @RequestParam(value = "pageSize", required = false) Integer pageSize) throws Exception {
        try {
            return prescriptionService.getNatAppointmentList(realOrder, name, hospitalFlag, mobile, idcard, payStatus, medicare, createTimeStart, createTimeEnd, appointmentTimeStart,appointmentTimeEnd,isSuccess, page, pageSize,orderNo);
        }catch (Exception e) {
            return prescriptionService.getNatAppointmentList(realOrder, name, hospitalFlag, mobile, idcard, payStatus, medicare, createTimeStart, createTimeEnd, appointmentTimeStart, appointmentTimeEnd, isSuccess, page, pageSize, orderNo);
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @GetMapping("/syncPrescription")
    @ApiOperation(value = "同步泰安处方")
    public Envelop syncPrescription( @ApiParam(name = "code", value = "code")
                                @RequestParam(value = "code",required = false)String code) throws Exception {
    public Envelop syncPrescription(@ApiParam(name = "code", value = "code")
                                    @RequestParam(value = "code", required = false) String code) throws Exception {
        try {
            return success(tnyyEntranceService.findByRealOrder(code,demoFlag));
            return success(tnyyEntranceService.findByRealOrder(code, demoFlag));
        } catch (Exception e) {
            return Envelop.getError(e.getMessage());
        }
@ -3236,41 +3308,42 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @GetMapping("/findOperateLogs")
    @ApiOperation(value = "查询操作日志")
    public Envelop findOperateLogs( @ApiParam(name = "code", value = "code")
                                     @RequestParam(value = "code",required = false)String code,
                                    @ApiParam(name = "name", value = "name")
                                    @RequestParam(value = "name",required = false)String name,
                                    @ApiParam(name = "patientName", value = "patientName")
                                        @RequestParam(value = "patientName",required = false)String patientName,
                                    @ApiParam(name = "doctorName", value = "doctorName")
                                        @RequestParam(value = "doctorName",required = false)String doctorName,
                                    @ApiParam(name = "startTime", value = "startTime")
                                        @RequestParam(value = "startTime",required = false)String startTime,
                                    @ApiParam(name = "endTime", value = "endTime")
                                        @RequestParam(value = "endTime",required = false)String endTime,
                                    @ApiParam(name = "page", value = "page")
                                        @RequestParam(value = "page",required = false)Integer page,
                                    @ApiParam(name = "pageSize", value = "pageSize")
                                        @RequestParam(value = "pageSize",required = false)Integer pageSize) throws Exception {
        try {
            return success(baseOperateLogService.findOperateLogList(code,name,patientName,doctorName,startTime,endTime,page,pageSize));
    public Envelop findOperateLogs(@ApiParam(name = "code", value = "code")
                                   @RequestParam(value = "code", required = false) String code,
                                   @ApiParam(name = "name", value = "name")
                                   @RequestParam(value = "name", required = false) String name,
                                   @ApiParam(name = "patientName", value = "patientName")
                                   @RequestParam(value = "patientName", required = false) String patientName,
                                   @ApiParam(name = "doctorName", value = "doctorName")
                                   @RequestParam(value = "doctorName", required = false) String doctorName,
                                   @ApiParam(name = "startTime", value = "startTime")
                                   @RequestParam(value = "startTime", required = false) String startTime,
                                   @ApiParam(name = "endTime", value = "endTime")
                                   @RequestParam(value = "endTime", required = false) String endTime,
                                   @ApiParam(name = "page", value = "page")
                                   @RequestParam(value = "page", required = false) Integer page,
                                   @ApiParam(name = "pageSize", value = "pageSize")
                                   @RequestParam(value = "pageSize", required = false) Integer pageSize) throws Exception {
        try {
            return success(baseOperateLogService.findOperateLogList(code, name, patientName, doctorName, startTime, endTime, page, pageSize));
        } catch (Exception e) {
            return Envelop.getError(e.getMessage());
        }
    }
    @PostMapping("/treatment")
    @ApiOperation(value = "下诊断", notes = "下诊断接口")
    public Envelop treatment(
                                    @ApiParam(name = "infoJsons", value = "药品json")
                                    @RequestParam(value = "infoJsons", required = false)String infoJsons,
                                    @ApiParam(name = "treatmentJson", value = "治疗方案json")
                                    @RequestParam(value = "treatmentJson", required = false)String treatmentJson)throws Exception {
       try {
           BaseAdviceTreatmentDO baseAdviceTreatmentDO = inspectionService.saveTreatment(infoJsons,treatmentJson);
           return success("操作成功");
       }catch (Exception e){
           return Envelop.getError(e.getMessage());
       }
            @ApiParam(name = "infoJsons", value = "药品json")
            @RequestParam(value = "infoJsons", required = false) String infoJsons,
            @ApiParam(name = "treatmentJson", value = "治疗方案json")
            @RequestParam(value = "treatmentJson", required = false) String treatmentJson) throws Exception {
        try {
            BaseAdviceTreatmentDO baseAdviceTreatmentDO = inspectionService.saveTreatment(infoJsons, treatmentJson);
            return success("操作成功");
        } catch (Exception e) {
            return Envelop.getError(e.getMessage());
        }
    }
    /*@GetMapping("/findDoctorChargeType")
@ -3325,11 +3398,11 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "获取患者待结算信息页面", notes = "获取患者待结算信息页面")
    public Envelop getSettlementInfo(
            @ApiParam(name = "outpatientId", value = "outpatientId")
            @RequestParam(value = "outpatientId", required = false)String outpatientId)throws Exception {
            @RequestParam(value = "outpatientId", required = false) String outpatientId) throws Exception {
        try {
            return success("操作成功",prescriptionService.getSettlementInfo(outpatientId));
        }catch (Exception e){
            return success("操作成功", prescriptionService.getSettlementInfo(outpatientId));
        } catch (Exception e) {
            return Envelop.getError(e.getMessage());
        }
    }
@ -3338,13 +3411,14 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "确认医保结算", notes = "确认医保结算")
    public Envelop getSettlementInfo(
            @ApiParam(name = "outpatientId", value = "outpatientId")
            @RequestParam(value = "outpatientId", required = false)String outpatientId,
            @RequestParam(value = "outpatientId", required = false) String outpatientId,
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = false)String code)throws Exception {
            @RequestParam(value = "code", required = false) String code) throws Exception {
        try {
            return success("操作成功",prescriptionService.confirmSettlementInfo(outpatientId,code));
        }catch (Exception e){
            return success("操作成功", prescriptionService.confirmSettlementInfo(outpatientId, code));
        } catch (Exception e) {
            return Envelop.getError(e.getMessage());
        }
    }
}