|  | @ -12,6 +12,7 @@ import com.yihu.jw.entity.base.dict.DictDeptDescDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.im.ConsultDo;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.im.ConsultTeamDo;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.org.BaseDoctorPatientFollowDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.org.BaseOrgDO;
 | 
	
	
		
			
				|  | @ -79,6 +80,7 @@ import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.GenerateUserSig;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.Pkis.PKIService_PortType;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.Pkis.PKIService_ServiceLocator;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.StringUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.WebserviceUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.hibernate.HibenateUtils;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.dao.BasePatientWechatDao;
 | 
	
	
		
			
				|  | @ -366,13 +368,13 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      * @param size
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public MixEnvelop findReOutpatientList(String patient, Integer status, String startTime, String endTime, Integer page, Integer size) {
 | 
	
		
			
				|  |  |     public MixEnvelop findReOutpatientList(String patient, Integer status, String startTime, String endTime,String outpatientType, Integer page, Integer size) {
 | 
	
		
			
				|  |  |         String totalSql = "SELECT " +
 | 
	
		
			
				|  |  |                 " COUNT(1) AS \"total\" " +
 | 
	
		
			
				|  |  |                 " FROM " +
 | 
	
		
			
				|  |  |                 " wlyy_outpatient o " +
 | 
	
		
			
				|  |  |                 " WHERE " +
 | 
	
		
			
				|  |  |                 " o.patient =:patient AND o.outpatient_type != '2' ";
 | 
	
		
			
				|  |  |                 " o.patient =:patient  ";
 | 
	
		
			
				|  |  |         Map<String, Object> totalParams = new HashedMap();
 | 
	
		
			
				|  |  |         totalParams.put("patient", patient);
 | 
	
		
			
				|  |  |         if (status != null) {
 | 
	
	
		
			
				|  | @ -388,6 +390,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             totalParams.put("endTime", DateUtil.strToDateLong(endTime + " 23:59:59"));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(outpatientType)){
 | 
	
		
			
				|  |  |             totalSql+=" AND o.outpatient_type = :outpatientType ";
 | 
	
		
			
				|  |  |             totalParams.put("outpatientType", outpatientType);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |        /* totalParams.add(patient);
 | 
	
		
			
				|  |  |         if(status!=null){
 | 
	
		
			
				|  |  |             totalSql +=  " AND o.status = ? ";
 | 
	
	
		
			
				|  | @ -428,6 +434,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 " o.hospital_name AS \"hospitalName\"," +
 | 
	
		
			
				|  |  |                 " o.win_no AS \"winNo\"," +
 | 
	
		
			
				|  |  |                 " o.type AS  \"type\"," +
 | 
	
		
			
				|  |  |                 " o.outpatient_type AS  \"outpatientType\"," +
 | 
	
		
			
				|  |  |                 " o.dept AS \"dept\", " +
 | 
	
		
			
				|  |  |                 " o.dept_name AS \"deptName\", " +
 | 
	
		
			
				|  |  |                 " o.patient AS \"patient\", " +
 | 
	
	
		
			
				|  | @ -480,7 +487,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             params.put("endTime", DateUtil.strToDateLong(endTime + " 23:59:59"));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         sql += " AND o.outpatient_type != '2' ORDER BY o.create_time DESC ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(outpatientType)){
 | 
	
		
			
				|  |  |             sql+=" AND o.outpatient_type = '"+outpatientType+"' ORDER BY o.create_time DESC ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         logger.info("sql="+sql);
 | 
	
		
			
				|  |  |         List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, params, page, size);
 | 
	
		
			
				|  |  |         for(Map<String, Object> map:list){
 | 
	
	
		
			
				|  | @ -523,6 +532,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         rs.put("operator",outpatientDO.getOperator());
 | 
	
		
			
				|  |  |         rs.put("status",outpatientDO.getStatus());
 | 
	
		
			
				|  |  |         rs.put("fee",outpatientDO.getFee());
 | 
	
		
			
				|  |  |         rs.put("icd10Name",outpatientDO.getIcd10Name());
 | 
	
		
			
				|  |  |         rs.put("createTime",DateUtil.dateToStrLong(outpatientDO.getCreateTime()));
 | 
	
		
			
				|  |  |         //居民详情
 | 
	
		
			
				|  |  |         BasePatientDO basePatientDO = basePatientDao.findById(outpatientDO.getPatient());
 | 
	
	
		
			
				|  | @ -850,51 +860,66 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         outpatientDO.setStatus("0");
 | 
	
		
			
				|  |  |         outpatientDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         outpatientDO.setIdcard(patientDO.getIdcard());
 | 
	
		
			
				|  |  |         outpatientDO.setOutpatientType("1");
 | 
	
		
			
				|  |  |         outpatientDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (outpatientDO.getRegisterDate() == null) {
 | 
	
		
			
				|  |  |             outpatientDO.setRegisterDate(new Date());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         WlyyPrescriptionExpressageDO previous = checkOutPatientPre(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |         //2.物流信息
 | 
	
		
			
				|  |  |         WlyyPrescriptionExpressageDO expressageDO = objectMapper.readValue(expressageJson, WlyyPrescriptionExpressageDO.class);
 | 
	
		
			
				|  |  |         if (null!=previous.getId()&&previous.getOneselfPickupFlg()!=expressageDO.getOneselfPickupFlg()){
 | 
	
		
			
				|  |  |             WlyyOutpatientDO wlyyOutpatientDO = new WlyyOutpatientDO();
 | 
	
		
			
				|  |  |             wlyyOutpatientDO.setRemindCount(previous.getOneselfPickupFlg());
 | 
	
		
			
				|  |  |             return wlyyOutpatientDO;
 | 
	
		
			
				|  |  |         WlyyPrescriptionExpressageDO expressageDO = new WlyyPrescriptionExpressageDO();
 | 
	
		
			
				|  |  |         if(!outpatientDO.getOutpatientType().equalsIgnoreCase("3")){
 | 
	
		
			
				|  |  |             WlyyPrescriptionExpressageDO previous = checkOutPatientPre(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |             //2.物流信息
 | 
	
		
			
				|  |  |             expressageDO = objectMapper.readValue(expressageJson, WlyyPrescriptionExpressageDO.class);
 | 
	
		
			
				|  |  |             if (null!=previous.getId()&&previous.getOneselfPickupFlg()!=expressageDO.getOneselfPickupFlg()){
 | 
	
		
			
				|  |  |                 WlyyOutpatientDO wlyyOutpatientDO = new WlyyOutpatientDO();
 | 
	
		
			
				|  |  |                 wlyyOutpatientDO.setOutpatientType(outpatientDO.getOutpatientType());
 | 
	
		
			
				|  |  |                 wlyyOutpatientDO.setRemindCount(previous.getOneselfPickupFlg());
 | 
	
		
			
				|  |  |                 return wlyyOutpatientDO;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         WlyyOutpatientDO outpatient = outpatientDao.save(outpatientDO);
 | 
	
		
			
				|  |  |         WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("WX_MONEY");
 | 
	
		
			
				|  |  |         Double price = 0.0;
 | 
	
		
			
				|  |  |         String chargeType1 = null;
 | 
	
		
			
				|  |  |         if (outpatient.getOutpatientType().equalsIgnoreCase("1")){
 | 
	
		
			
				|  |  |             if(outpatientDO.getType().equalsIgnoreCase("1")){
 | 
	
		
			
				|  |  |                 chargeType1 = doctorDO.getTwfzChargeType();
 | 
	
		
			
				|  |  |             }else if(outpatientDO.getType().equalsIgnoreCase("2")){
 | 
	
		
			
				|  |  |                 chargeType1 = doctorDO.getSpfzChargeType();
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }else if (outpatient.getOutpatientType().equalsIgnoreCase("3")){
 | 
	
		
			
				|  |  |             if(outpatientDO.getType().equalsIgnoreCase("1")){
 | 
	
		
			
				|  |  |                 chargeType1 = doctorDO.getTwzxChargeType();
 | 
	
		
			
				|  |  |             }else if(outpatientDO.getType().equalsIgnoreCase("2")){
 | 
	
		
			
				|  |  |                 chargeType1 = doctorDO.getSpzxChargeType();
 | 
	
		
			
				|  |  |         if (doctorDO!=null){
 | 
	
		
			
				|  |  |             if (outpatient.getOutpatientType().equalsIgnoreCase("1")){
 | 
	
		
			
				|  |  |                 if(outpatientDO.getType().equalsIgnoreCase("1")){
 | 
	
		
			
				|  |  |                     chargeType1 = doctorDO.getTwfzChargeType();
 | 
	
		
			
				|  |  |                 }else if(outpatientDO.getType().equalsIgnoreCase("2")){
 | 
	
		
			
				|  |  |                     chargeType1 = doctorDO.getSpfzChargeType();
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }else if (outpatient.getOutpatientType().equalsIgnoreCase("3")){
 | 
	
		
			
				|  |  |                 if(outpatientDO.getType().equalsIgnoreCase("1")){
 | 
	
		
			
				|  |  |                     chargeType1 = doctorDO.getTwzxChargeType();
 | 
	
		
			
				|  |  |                 }else if(outpatientDO.getType().equalsIgnoreCase("2")){
 | 
	
		
			
				|  |  |                     chargeType1 = doctorDO.getSpzxChargeType();
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }else if (outpatient.getOutpatientType().equalsIgnoreCase("2")){
 | 
	
		
			
				|  |  |                 chargeType1 = doctorDO.getXtfzChargeType();
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if(doctorDO!=null){
 | 
	
		
			
				|  |  |                 if (StringUtils.isNoneBlank(chargeType1)){
 | 
	
		
			
				|  |  |                     WlyyChargeDictDO chargeDictDO = wlyyChargeDictDao.findByChargeType(chargeType1);
 | 
	
		
			
				|  |  |                     if (chargeDictDO!=null){
 | 
	
		
			
				|  |  |                         price = chargeDictDO.getReqFee();
 | 
	
		
			
				|  |  |                     }else {
 | 
	
		
			
				|  |  |                         price = Double.parseDouble(hospitalSysDictDO.getDictValue());
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 price = Double.parseDouble(hospitalSysDictDO.getDictValue());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }else if (outpatient.getOutpatientType().equalsIgnoreCase("2")){
 | 
	
		
			
				|  |  |             chargeType1 = doctorDO.getXtfzChargeType();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(doctorDO!=null){
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(chargeType1)){
 | 
	
		
			
				|  |  |                 WlyyChargeDictDO chargeDictDO = wlyyChargeDictDao.findByChargeType(chargeType1);
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(chargeType)){
 | 
	
		
			
				|  |  |                 WlyyChargeDictDO chargeDictDO = wlyyChargeDictDao.findByChargeType(chargeType);
 | 
	
		
			
				|  |  |                 if (chargeDictDO!=null){
 | 
	
		
			
				|  |  |                     price = chargeDictDO.getReqFee();
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     price = Double.parseDouble(hospitalSysDictDO.getDictValue());
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             price = Double.parseDouble(hospitalSysDictDO.getDictValue());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         /*if (doctorDO != null && StringUtils.isNoneBlank(doctorDO.getFee())) {
 | 
	
		
			
				|  |  |             price = Double.parseDouble(doctorDO.getFee());
 | 
	
	
		
			
				|  | @ -915,6 +940,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }else if (outpatient.getOutpatientType().equalsIgnoreCase("2")){
 | 
	
		
			
				|  |  |             businessOrderService.recharge(outpatient.getId(), "协同复诊-诊查费", "5", "协同复诊-诊查费", outpatient.getConsumer(), outpatient.getConsumerName(), outpatient.getDoctor(), price);
 | 
	
		
			
				|  |  |         }else if ("3".equalsIgnoreCase(outpatient.getOutpatientType())){
 | 
	
		
			
				|  |  |             BusinessOrderDO businessOrderDO = businessOrderService.recharge(outpatient.getId(), "专家咨询费", "1", "专家咨询费", outpatient.getConsumer(), outpatient.getConsumerName(), outpatient.getDoctor(), price);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -931,36 +958,37 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             throw new RuntimeException("号源已经被预约,请选择其他号源");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (0==expressageDO.getOneselfPickupFlg()){
 | 
	
		
			
				|  |  |             if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
 | 
	
		
			
				|  |  |                 String drugCode= expressageDO.getHospitalCode()==null?"5550":expressageDO.getHospitalCode();
 | 
	
		
			
				|  |  |                 expressageDO.setHospitalCode(drugCode);
 | 
	
		
			
				|  |  |         if (!outpatientDO.getOutpatientType().equalsIgnoreCase("3")){
 | 
	
		
			
				|  |  |             if (0==expressageDO.getOneselfPickupFlg()){
 | 
	
		
			
				|  |  |                 if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
 | 
	
		
			
				|  |  |                     String drugCode= expressageDO.getHospitalCode()==null?"5550":expressageDO.getHospitalCode();
 | 
	
		
			
				|  |  |                     expressageDO.setHospitalCode(drugCode);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 System.out.println("进入物流信息");
 | 
	
		
			
				|  |  |                 expressageDO.setDel(1);
 | 
	
		
			
				|  |  |                 expressageDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                 expressageDO.setOutpatientId(outpatient.getId());
 | 
	
		
			
				|  |  |                 prescriptionExpressageDao.save(expressageDO);
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 System.out.println("写入自取信息");
 | 
	
		
			
				|  |  |                 String drugStoreCode = expressageDO.getHospitalCode();
 | 
	
		
			
				|  |  |                 BaseDrugStoreDO baseDrugStoreDO = baseDrugStoreDao.findDrugByid(drugStoreCode);
 | 
	
		
			
				|  |  |                 if (null!=baseDrugStoreDO){
 | 
	
		
			
				|  |  |                     expressageDO.setCityCode(baseDrugStoreDO.getCityCode());
 | 
	
		
			
				|  |  |                     expressageDO.setCityName(baseDrugStoreDO.getCityName());
 | 
	
		
			
				|  |  |                     expressageDO.setProvinceCode(baseDrugStoreDO.getProvinceCode());
 | 
	
		
			
				|  |  |                     expressageDO.setProvinceName(baseDrugStoreDO.getProvinceName());
 | 
	
		
			
				|  |  |                     expressageDO.setTownCode(baseDrugStoreDO.getTownCode());
 | 
	
		
			
				|  |  |                     expressageDO.setTownName(baseDrugStoreDO.getTownName());
 | 
	
		
			
				|  |  |                     expressageDO.setHospitalCode(baseDrugStoreDO.getDrugStoreCode());
 | 
	
		
			
				|  |  |                     expressageDO.setHospitalName(baseDrugStoreDO.getHospitalName());
 | 
	
		
			
				|  |  |                     expressageDO.setHospitalAddress(baseDrugStoreDO.getAddress());
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 expressageDO.setDel(1);
 | 
	
		
			
				|  |  |                 expressageDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                 expressageDO.setOutpatientId(outpatient.getId());
 | 
	
		
			
				|  |  |                 prescriptionExpressageDao.save(expressageDO);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             System.out.println("进入物流信息");
 | 
	
		
			
				|  |  |             expressageDO.setDel(1);
 | 
	
		
			
				|  |  |             expressageDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |             expressageDO.setOutpatientId(outpatient.getId());
 | 
	
		
			
				|  |  |             prescriptionExpressageDao.save(expressageDO);
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             System.out.println("写入自取信息");
 | 
	
		
			
				|  |  |             String drugStoreCode = expressageDO.getHospitalCode();
 | 
	
		
			
				|  |  |             BaseDrugStoreDO baseDrugStoreDO = baseDrugStoreDao.findDrugByid(drugStoreCode);
 | 
	
		
			
				|  |  |             if (null!=baseDrugStoreDO){
 | 
	
		
			
				|  |  |                 expressageDO.setCityCode(baseDrugStoreDO.getCityCode());
 | 
	
		
			
				|  |  |                 expressageDO.setCityName(baseDrugStoreDO.getCityName());
 | 
	
		
			
				|  |  |                 expressageDO.setProvinceCode(baseDrugStoreDO.getProvinceCode());
 | 
	
		
			
				|  |  |                 expressageDO.setProvinceName(baseDrugStoreDO.getProvinceName());
 | 
	
		
			
				|  |  |                 expressageDO.setTownCode(baseDrugStoreDO.getTownCode());
 | 
	
		
			
				|  |  |                 expressageDO.setTownName(baseDrugStoreDO.getTownName());
 | 
	
		
			
				|  |  |                 expressageDO.setHospitalCode(baseDrugStoreDO.getDrugStoreCode());
 | 
	
		
			
				|  |  |                 expressageDO.setHospitalName(baseDrugStoreDO.getHospitalName());
 | 
	
		
			
				|  |  |                 expressageDO.setHospitalAddress(baseDrugStoreDO.getAddress());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             expressageDO.setDel(1);
 | 
	
		
			
				|  |  |             expressageDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |             expressageDO.setOutpatientId(outpatient.getId());
 | 
	
		
			
				|  |  |             prescriptionExpressageDao.save(expressageDO);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (wechatId.equalsIgnoreCase("xm_xzzx_wx")){
 | 
	
		
			
				|  |  |             logger.info("心脏中心同步患者开始");
 | 
	
	
		
			
				|  | @ -1180,18 +1208,27 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         return rs;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Map<String, Object> checkOutpatient(String patient,String wxId,boolean flag) throws Exception {
 | 
	
		
			
				|  |  |     public Map<String, Object> checkOutpatient(String patient,String wxId,boolean flag,String outpatientType) throws Exception {
 | 
	
		
			
				|  |  |         //-1卡余额不足,,-2 存在未结束的诊断热 1成功
 | 
	
		
			
				|  |  |         Map<String, Object> rs = new HashedMap();
 | 
	
		
			
				|  |  |         //1.余额判断改到前端判断
 | 
	
		
			
				|  |  |         //net.sf.json.JSONObject json = entranceService.qutpatientBalance(cardNo,demoFlag);
 | 
	
		
			
				|  |  |         WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("consultAccount");
 | 
	
		
			
				|  |  |         String accountControl = "0";
 | 
	
		
			
				|  |  |         if (null!=wlyyHospitalSysDictDO){
 | 
	
		
			
				|  |  |             accountControl = wlyyHospitalSysDictDO.getDictValue();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //1.判断
 | 
	
		
			
				|  |  |         //net.sf.json.JS余额判断改到前端ONObject json = entranceService.qutpatientBalance(cardNo,demoFlag);
 | 
	
		
			
				|  |  |         if (flag){
 | 
	
		
			
				|  |  |             if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
 | 
	
		
			
				|  |  |                 List<WlyyOutpatientDO> outpatientDOS = outpatientDao.findByPatientListByStatus(patient);
 | 
	
		
			
				|  |  |                 List<WlyyOutpatientDO> outpatientDOS = new ArrayList<>();
 | 
	
		
			
				|  |  |                 if (StringUtils.isNotBlank(outpatientType)){
 | 
	
		
			
				|  |  |                     outpatientDOS = outpatientDao.findByPatientListByStatusAndType(patient,outpatientType);
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     outpatientDOS = outpatientDao.findByPatientListByStatus(patient);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 if (outpatientDOS!=null&&outpatientDOS.size()!=0){
 | 
	
		
			
				|  |  |                     WlyyOutpatientDO outpatientDO = outpatientDOS.get(0);
 | 
	
		
			
				|  |  |                     if (outpatientDO.getHisStatus()!=null){
 | 
	
		
			
				|  |  |                     if (outpatientDO.getHisStatus()!=null&&"0".equalsIgnoreCase(accountControl)){
 | 
	
		
			
				|  |  |                         logger.info("您上一次就诊进入"+outpatientDO.getHisStatus());
 | 
	
		
			
				|  |  |                         if(outpatientDO.getHisStatus()!=1&&outpatientDO.getHisStatus()!=-1){
 | 
	
		
			
				|  |  |                             logger.info("您上一次就诊进入======"+outpatientDO.getHisStatus());
 | 
	
	
		
			
				|  | @ -1209,7 +1246,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                             return rs;
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     }else if (outpatientDO.getHisStatus()==null){
 | 
	
		
			
				|  |  |                     }else if (outpatientDO.getHisStatus()==null&&"0".equalsIgnoreCase(accountControl)){
 | 
	
		
			
				|  |  |                         rs.put("outpatient", outpatientDO);
 | 
	
		
			
				|  |  |                         rs.put("code", -3);
 | 
	
		
			
				|  |  |                         rs.put("mes", "您上一次就诊未结算,请结算后才能发起复诊。");
 | 
	
	
		
			
				|  | @ -1227,16 +1264,26 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //2.判断是否有未结束的
 | 
	
		
			
				|  |  |         List<WlyyOutpatientDO> list = outpatientDao.findByPatientList(patient);
 | 
	
		
			
				|  |  |         List<WlyyOutpatientDO> list = new ArrayList<>();
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(outpatientType)&&outpatientType.equalsIgnoreCase("3")){
 | 
	
		
			
				|  |  |             list = outpatientDao.findByPatientAndDoctorList(patient);
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             list = outpatientDao.findByPatientList(patient);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (list != null && list.size() > 0) {
 | 
	
		
			
				|  |  |             rs.put("outpatient", list.get(0));
 | 
	
		
			
				|  |  |             rs.put("code", -2);
 | 
	
		
			
				|  |  |             rs.put("mes", "存在未结束的诊断");
 | 
	
		
			
				|  |  |             return rs;
 | 
	
		
			
				|  |  |             if(!list.get(0).getOutpatientType().equalsIgnoreCase("3")){
 | 
	
		
			
				|  |  |                 rs.put("outpatient", list.get(0));
 | 
	
		
			
				|  |  |                 rs.put("code", -2);
 | 
	
		
			
				|  |  |                 rs.put("mes", "存在未结束的诊断");
 | 
	
		
			
				|  |  |                 return rs;
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 rs.put("outpatient", list.get(0));
 | 
	
		
			
				|  |  |                 rs.put("code", -2);
 | 
	
		
			
				|  |  |                 rs.put("mes", "存在未结束的咨询");
 | 
	
		
			
				|  |  |                 return rs;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         rs.put("code", 1);
 | 
	
		
			
				|  |  |         rs.put("mes", "验证通过");
 | 
	
	
		
			
				|  | @ -1600,7 +1647,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                         chargeTypeList = chargeType.replace(",","','");
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     String sqlCharge = "select charge_type as \"chargeType\",charge_name as \"chargeName\"," +
 | 
	
		
			
				|  |  |                             "req_fee  as \"reqFee\",dept_type_code as \"deptTypeCode\" " +
 | 
	
		
			
				|  |  |                             "req_fee  as \"reqFee\",zj_fee  as \"zjFee\",xt_fee  as \"xtFee\",dept_type_code as \"deptTypeCode\" " +
 | 
	
		
			
				|  |  |                             " from wlyy_charge_dict where 1=1";
 | 
	
		
			
				|  |  |                     sqlCharge+=" and charge_type in ( '"+chargeTypeList+"')";
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -3517,7 +3564,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                     chargeType = chargeType.replace(",","','");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 String sqlCharge = "select charge_type as \"chargeType\",charge_name as \"chargeName\"," +
 | 
	
		
			
				|  |  |                         "req_fee  as \"reqFee\",dept_type_code as \"deptTypeCode\" " +
 | 
	
		
			
				|  |  |                         "req_fee  as \"reqFee\",zj_fee  as \"zjFee\",xt_fee  as \"xtFee\",dept_type_code as \"deptTypeCode\" " +
 | 
	
		
			
				|  |  |                         " from wlyy_charge_dict where 1=1";
 | 
	
		
			
				|  |  |                 sqlCharge+=" and charge_type in ( '"+chargeType+"')";
 | 
	
		
			
				|  |  |                 if (StringUtils.isNoneBlank(deptTyepCode)){
 | 
	
	
		
			
				|  | @ -3525,6 +3572,21 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 chargeDictDOLists =  hibenateUtils.createSQLQuery(sqlCharge);
 | 
	
		
			
				|  |  |             }*/
 | 
	
		
			
				|  |  |             String sqlCharge = "SELECT\n" +
 | 
	
		
			
				|  |  |                     "\tm.req_fee as \"twfzFee\",\n" +
 | 
	
		
			
				|  |  |                     "\ta.req_fee as \"spfzFee\",\n" +
 | 
	
		
			
				|  |  |                     "\tb.req_fee as \"spzxFee\",\n" +
 | 
	
		
			
				|  |  |                     "\tv.req_fee as \"twzxFee\",\n" +
 | 
	
		
			
				|  |  |                     "\td.req_fee as \"xtzxFee\"\n" +
 | 
	
		
			
				|  |  |                     "FROM\n" +
 | 
	
		
			
				|  |  |                     "\tbase_doctor t\n" +
 | 
	
		
			
				|  |  |                     "LEFT JOIN wlyy_charge_dict m ON t.twfz_charge_type = m.charge_type\n" +
 | 
	
		
			
				|  |  |                     "LEFT JOIN wlyy_charge_dict a ON t.spfz_charge_type = a.charge_type\n" +
 | 
	
		
			
				|  |  |                     "LEFT JOIN wlyy_charge_dict b ON t.spzx_charge_type = b.charge_type\n" +
 | 
	
		
			
				|  |  |                     "LEFT JOIN wlyy_charge_dict v ON t.twzx_charge_type = v.charge_type\n" +
 | 
	
		
			
				|  |  |                     "LEFT JOIN wlyy_charge_dict d ON t.xtfz_charge_type = d.charge_type\n" +
 | 
	
		
			
				|  |  |                     "WHERE t.id = '"+doctorDO.getId()+"' ";
 | 
	
		
			
				|  |  |             chargeDictDOLists =  hibenateUtils.createSQLQuery(sqlCharge);
 | 
	
		
			
				|  |  |             rs.put("chargeTypeList",chargeDictDOLists);
 | 
	
		
			
				|  |  |             //机构科室信息
 | 
	
		
			
				|  |  |             List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findByDoctorCode(doctorDO.getId());
 | 
	
	
		
			
				|  | @ -3784,7 +3846,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                     chargeType = chargeType.replace(",","','");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 String sqlCharge = "select charge_type as \"chargeType\",charge_name as \"chargeName\"," +
 | 
	
		
			
				|  |  |                         "req_fee  as \"reqFee\",dept_type_code as \"deptTypeCode\" " +
 | 
	
		
			
				|  |  |                         "req_fee  as \"reqFee\",zj_fee  as \"zjFee\",xt_fee  as \"xtFee\",dept_type_code as \"deptTypeCode\" " +
 | 
	
		
			
				|  |  |                         " from wlyy_charge_dict where 1=1";
 | 
	
		
			
				|  |  |                 sqlCharge+=" and charge_type in ( '"+chargeType+"')";
 | 
	
		
			
				|  |  |                 if(StringUtils.isNoneBlank(deptTyepCode)){
 | 
	
	
		
			
				|  | @ -3809,6 +3871,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                     "LEFT JOIN wlyy_charge_dict d ON t.xtfz_charge_type = d.charge_type\n" +
 | 
	
		
			
				|  |  |                     "WHERE t.id = '"+doctorDO.getId()+"' ";
 | 
	
		
			
				|  |  |             chargeDictDOLists =  hibenateUtils.createSQLQuery(sqlCharge);
 | 
	
		
			
				|  |  |             rs.put("chargeTypeList",chargeDictDOLists);
 | 
	
		
			
				|  |  |             //机构科室信息
 | 
	
		
			
				|  |  |             List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findByDoctorCode(doctorDO.getId());
 | 
	
		
			
				|  |  |             List<BaseDoctorHospitalDO> hospitalDOList = new ArrayList<>();
 | 
	
	
		
			
				|  | @ -3935,16 +3998,30 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
 | 
	
		
			
				|  |  |                 data.put("question", wlyyOutpatientDO.getIcd10Name());
 | 
	
		
			
				|  |  |                 String msg = "";
 | 
	
		
			
				|  |  |                 if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
 | 
	
		
			
				|  |  |                     data.put("type", "9");
 | 
	
		
			
				|  |  |                     msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被医生取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
 | 
	
		
			
				|  |  |                     sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "doctorRefuseRemind", cancelRemark);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
 | 
	
		
			
				|  |  |                     data.put("type", "16");
 | 
	
		
			
				|  |  |                     msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被医生取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
 | 
	
		
			
				|  |  |                     sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "doctorRefuseRemind", cancelRemark);
 | 
	
		
			
				|  |  |                 if ("1".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())||"2".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())){
 | 
	
		
			
				|  |  |                     if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
 | 
	
		
			
				|  |  |                         data.put("type", "9");
 | 
	
		
			
				|  |  |                         msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被医生取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
 | 
	
		
			
				|  |  |                         sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "doctorRefuseRemind", cancelRemark);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
 | 
	
		
			
				|  |  |                         data.put("type", "16");
 | 
	
		
			
				|  |  |                         msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被医生取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
 | 
	
		
			
				|  |  |                         sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "doctorRefuseRemind", cancelRemark);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
 | 
	
		
			
				|  |  |                         data.put("type", "1");
 | 
	
		
			
				|  |  |                         msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文咨询已被医生取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
 | 
	
		
			
				|  |  |                         sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "1", "doctorRefuseRemind", cancelRemark);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
 | 
	
		
			
				|  |  |                         data.put("type", "17");
 | 
	
		
			
				|  |  |                         msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频咨询已被医生取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
 | 
	
		
			
				|  |  |                         sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "17", "doctorRefuseRemind", cancelRemark);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 data.put("msg", msg);
 | 
	
		
			
				|  |  |                 messageDO.setData(data.toString());
 | 
	
		
			
				|  |  |                 systemMessageService.saveMessage(messageDO);
 | 
	
	
		
			
				|  | @ -4041,6 +4118,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
 | 
	
		
			
				|  |  |                 first = outpatientDO.getConsumerName() + ",您好!您的视频复诊已取消";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if ("1".equals(type)) {
 | 
	
		
			
				|  |  |                 contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
 | 
	
		
			
				|  |  |                 first = outpatientDO.getConsumerName() + ",您好!您的图文咨询已取消";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if ("17".equals(type)) {
 | 
	
		
			
				|  |  |                 contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
 | 
	
		
			
				|  |  |                 first = outpatientDO.getConsumerName() + ",您好!您的视频咨询已取消";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             logger.info("doctorRefuseRemind医生拒诊入参:outpatientId="+outpatientId);
 | 
	
		
			
				|  |  |             msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
 | 
	
		
			
				|  |  |         } else if("outPatientTimeOutRemind".equalsIgnoreCase(titelType)) {
 | 
	
	
		
			
				|  | @ -4074,13 +4159,23 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if ("1".equals(type)) {
 | 
	
		
			
				|  |  |                 contentMsg = "您有一个图文咨询订单待支付,点击完成支付,如您已支付请忽略本条信息";
 | 
	
		
			
				|  |  |                 first = consPatientDO.getName() + ",您好!您有一个图文咨询订单待支付,请及时支付。";
 | 
	
		
			
				|  |  |                 msgUrl="/ims-wx/index.html#/chatRoom?type=1&consultCode="+consultTeam.getConsult();
 | 
	
		
			
				|  |  |                 if (StringUtils.isNotBlank(outpatientId)){
 | 
	
		
			
				|  |  |                     msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
 | 
	
		
			
				|  |  |                     first = outpatientDO.getConsumerName() + ",您好!您有一个图文咨询订单待支付,请及时支付。";
 | 
	
		
			
				|  |  |                 }else{
 | 
	
		
			
				|  |  |                     msgUrl="/ims-wx/index.html#/chatRoom?type=1&consultCode="+consultTeam.getConsult();
 | 
	
		
			
				|  |  |                     first = consPatientDO.getName() + ",您好!您有一个图文咨询订单待支付,请及时支付。";
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 logger.info("图文咨询订单待支付微信消息模板推送开始");
 | 
	
		
			
				|  |  |             } else if ("17".equals(type)) {
 | 
	
		
			
				|  |  |                 contentMsg = "您有一个视频咨询订单待支付,点击完成支付,如您已支付请忽略本条信息";
 | 
	
		
			
				|  |  |                 first =  consPatientDO.getName() + ",您好!您有一个视频咨询订单待支付,请及时支付。";
 | 
	
		
			
				|  |  |                 msgUrl="/ims-wx/index.html#/chatRoom?type=1&consultCode="+consultTeam.getConsult();
 | 
	
		
			
				|  |  |                 if (StringUtils.isNotBlank(outpatientId)){
 | 
	
		
			
				|  |  |                     msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
 | 
	
		
			
				|  |  |                     first =  outpatientDO.getConsumerName() + ",您好!您有一个视频咨询订单待支付,请及时支付。";
 | 
	
		
			
				|  |  |                 }else{
 | 
	
		
			
				|  |  |                     msgUrl="/ims-wx/index.html#/chatRoom?type=1&consultCode="+consultTeam.getConsult();
 | 
	
		
			
				|  |  |                     first =  consPatientDO.getName() + ",您好!您有一个视频咨询订单待支付,请及时支付。";
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 logger.info("视频咨询订单待支付微信消息模板推送开始");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -4095,7 +4190,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             contentMsg = "" + remindMsg;
 | 
	
		
			
				|  |  |             remark = "请您尽快回复";
 | 
	
		
			
				|  |  |         } else if ("outpatientMsgRemind".equalsIgnoreCase(titelType)) {
 | 
	
		
			
				|  |  |           if (StringUtils.isNotEmpty(outpatientId)){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |               if ("16".equals(type)) {
 | 
	
		
			
				|  |  |                   first = doctorDO.getName() + doctorDO.getJobTitleName() + "医生已向您发起视频通话邀请,请点击详情进入视频诊室。";
 | 
	
		
			
				|  |  |                   contentMsg = "您的视频复诊已开始,错过将重新排队";
 | 
	
	
		
			
				|  | @ -4103,8 +4198,18 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                   msgUrl="/ims-wx/index.html#/returnVisit/preChat?type=16&outpatientId="+outpatientId;
 | 
	
		
			
				|  |  |                   logger.info("视频问诊已接诊提醒微信模板消息发送开始");
 | 
	
		
			
				|  |  |               }
 | 
	
		
			
				|  |  |           }
 | 
	
		
			
				|  |  |           if (consultTeam!=null){
 | 
	
		
			
				|  |  |               if ("17".equals(type)) {
 | 
	
		
			
				|  |  |                   first = doctorDO.getName() + doctorDO.getJobTitleName() + "医生已向您发起视频通话邀请,请点击详情进入视频诊室。";
 | 
	
		
			
				|  |  |                   contentMsg = "您的视频咨询已开始,错过将重新排队";
 | 
	
		
			
				|  |  |                   remark = "点击消息进入视频诊室接听视频通话,开始视频复诊。";
 | 
	
		
			
				|  |  |                   if (StringUtils.isNotEmpty(outpatientId)){
 | 
	
		
			
				|  |  |                       msgUrl="/ims-wx/index.html#/returnVisit/preChat?type=17&outpatientId="+outpatientId;
 | 
	
		
			
				|  |  |                   }else{
 | 
	
		
			
				|  |  |                       msgUrl="/ims-wx/index.html#/zx/prechat?consultCode="+consultTeam.getConsult();
 | 
	
		
			
				|  |  |                   }
 | 
	
		
			
				|  |  |                   logger.info("视频咨询已接诊提醒微信模板消息发送开始");
 | 
	
		
			
				|  |  |               }
 | 
	
		
			
				|  |  |           /*if (consultTeam!=null){
 | 
	
		
			
				|  |  |               if ("17".equals(type)) {
 | 
	
		
			
				|  |  |                   first = consDoctorDO.getName() + consDoctorDO.getJobTitleName() + "医生已向您发起视频通话邀请,请点击详情进入视频诊室。";
 | 
	
		
			
				|  |  |                   contentMsg = "您的视频咨询已开始,错过将重新排队";
 | 
	
	
		
			
				|  | @ -4112,19 +4217,37 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                   msgUrl="/ims-wx/index.html#/zx/prechat?consultCode="+consultTeam.getConsult();
 | 
	
		
			
				|  |  |                   logger.info("视频咨询已接诊提醒微信模板消息发送开始");
 | 
	
		
			
				|  |  |               }
 | 
	
		
			
				|  |  |           }
 | 
	
		
			
				|  |  |           }*/
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         } else if ("videoOrderRemind".equalsIgnoreCase(titelType)) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if ("16".equals(type)) {
 | 
	
		
			
				|  |  |                 first = "您的视频复诊已预约成功。";
 | 
	
		
			
				|  |  |                 contentMsg = "预计" + outpatientDO.getDoctorName() + "医生将于" + DateUtil.dateToStrLong(outpatientDO.getRegisterDate()) + " 与您进行视频复诊。请留意微信公众号消息。";
 | 
	
		
			
				|  |  |                 msgUrl="/ims-wx/index.html#/returnVisit/preChat?type=16&outpatientId="+outpatientId;
 | 
	
		
			
				|  |  |                 if (StringUtils.isNoneBlank(outpatientDO.getDoctorName())){
 | 
	
		
			
				|  |  |                     first = "您的视频复诊已预约成功。";
 | 
	
		
			
				|  |  |                     contentMsg = "预计" + outpatientDO.getDoctorName() + "医生将于" + DateUtil.dateToStrLong(outpatientDO.getRegisterDate()) + " 与您进行视频复诊。请留意微信公众号消息。";
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     first = outpatientDO.getPatientName()+"您好!您已成功发起快速视频复诊。";
 | 
	
		
			
				|  |  |                     contentMsg = "您已预约" + DateUtil.dateToStrLong(consultTeam.getCzrq()) +  "的视频复诊 与您进行视频复诊。请留意微信公众号消息。请耐心等待医生接单。如长时间无医生接单,建议选择医生发起视频复诊";
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 logger.info("视频复诊已预约成功微信消息模板推送开始");
 | 
	
		
			
				|  |  |             } else if ("17".equals(type)) {
 | 
	
		
			
				|  |  |                 first = "您的视频咨询已预约成功。";
 | 
	
		
			
				|  |  |                 contentMsg = "预计" + consDoctorDO.getName() + "医生将于" + DateUtil.dateToStrLong(consultTeam.getCzrq()) + " 与您进行视频咨询。请留意微信公众号消息。";
 | 
	
		
			
				|  |  |                 msgUrl="/ims-wx/index.html#/zx/prechat?consultCode="+consultTeam.getConsult();
 | 
	
		
			
				|  |  |                 if (StringUtils.isNotEmpty(outpatientId)){
 | 
	
		
			
				|  |  |                     msgUrl="/ims-wx/index.html#/returnVisit/preChat?type=17&outpatientId="+outpatientId;
 | 
	
		
			
				|  |  |                     if (StringUtils.isNoneBlank(outpatientDO.getDoctorName())){
 | 
	
		
			
				|  |  |                         first = "您的视频咨询已预约成功。";
 | 
	
		
			
				|  |  |                         contentMsg = "预计" + outpatientDO.getDoctorName() + "医生将于" + DateUtil.dateToStrLong(consultTeam.getCzrq()) + " 与您进行视频咨询。请留意微信公众号消息。";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     }else{
 | 
	
		
			
				|  |  |                         first = outpatientDO.getPatientName()+"您好!您已成功发起快速视频咨询。";
 | 
	
		
			
				|  |  |                         contentMsg = "您已预约" + DateUtil.dateToStrLong(consultTeam.getCzrq()) +  "的视频咨询 与您进行视频咨询。请留意微信公众号消息。请耐心等待医生接单。如长时间无医生接单,建议选择医生发起视频咨询";
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 }else{
 | 
	
		
			
				|  |  |                     msgUrl="/ims-wx/index.html#/zx/prechat?consultCode="+consultTeam.getConsult();
 | 
	
		
			
				|  |  |                     contentMsg = "预计" + consDoctorDO.getName() + "医生将于" + DateUtil.dateToStrLong(consultTeam.getCzrq()) + " 与您进行视频咨询。请留意微信公众号消息。";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 logger.info("视频咨询已预约成功微信消息模板推送开始");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             remark = "咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
 | 
	
	
		
			
				|  | @ -4202,17 +4325,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                         newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
 | 
	
		
			
				|  |  |                         newConfig.setKeyword1( "视频复诊支付");
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     newConfig.setKeyword2(outpatientDO.getHospitalName());
 | 
	
		
			
				|  |  |                     newConfig.setKeyword3(outpatientDO.getDoctorName());
 | 
	
		
			
				|  |  |                     //发起微信消息模板推送
 | 
	
		
			
				|  |  |                     newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
 | 
	
		
			
				|  |  |                     logger.info("眼科微信消息模板推送 就诊支付提醒开始");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 //咨询支付
 | 
	
		
			
				|  |  |                 if (consultTeam!=null){
 | 
	
		
			
				|  |  |                     WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_pay_notice_zx", scene, 1);
 | 
	
		
			
				|  |  |                     BeanUtils.copyProperties(config, newConfig);
 | 
	
		
			
				|  |  |                     newConfig.setFirst(config.getFirst().replace("key1", consPatientDO.getName()));
 | 
	
		
			
				|  |  |                     if ("1".equals(type)) {
 | 
	
		
			
				|  |  |                         newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
 | 
	
		
			
				|  |  |                         newConfig.setKeyword1("图文咨询支付");
 | 
	
	
		
			
				|  | @ -4220,13 +4332,31 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                         newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
 | 
	
		
			
				|  |  |                         newConfig.setKeyword1("视频咨询支付");
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     newConfig.setKeyword2( hospitalDO.getOrgName());
 | 
	
		
			
				|  |  |                     newConfig.setKeyword3( consDoctorDO.getName());
 | 
	
		
			
				|  |  |                     newConfig.setKeyword2(outpatientDO.getHospitalName());
 | 
	
		
			
				|  |  |                     newConfig.setKeyword3(outpatientDO.getDoctorName());
 | 
	
		
			
				|  |  |                     //发起微信消息模板推送
 | 
	
		
			
				|  |  |                     newConfig.setUrl(newConfig.getUrl() + "" + consultTeam.getConsult());
 | 
	
		
			
				|  |  |                     logger.info("眼科微信消息模板推送 咨询支付提醒开始");
 | 
	
		
			
				|  |  |                     newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
 | 
	
		
			
				|  |  |                     logger.info("眼科微信消息模板推送 就诊支付提醒开始");
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     //咨询支付
 | 
	
		
			
				|  |  |                     if (consultTeam!=null){
 | 
	
		
			
				|  |  |                         WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_pay_notice_zx", scene, 1);
 | 
	
		
			
				|  |  |                         BeanUtils.copyProperties(config, newConfig);
 | 
	
		
			
				|  |  |                         newConfig.setFirst(config.getFirst().replace("key1", consPatientDO.getName()));
 | 
	
		
			
				|  |  |                         if ("1".equals(type)) {
 | 
	
		
			
				|  |  |                             newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
 | 
	
		
			
				|  |  |                             newConfig.setKeyword1("图文咨询支付");
 | 
	
		
			
				|  |  |                         } else if ("17".equals(type)) {
 | 
	
		
			
				|  |  |                             newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
 | 
	
		
			
				|  |  |                             newConfig.setKeyword1("视频咨询支付");
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         newConfig.setKeyword2( hospitalDO.getOrgName());
 | 
	
		
			
				|  |  |                         newConfig.setKeyword3( consDoctorDO.getName());
 | 
	
		
			
				|  |  |                         //发起微信消息模板推送
 | 
	
		
			
				|  |  |                         newConfig.setUrl(newConfig.getUrl() + "" + consultTeam.getConsult());
 | 
	
		
			
				|  |  |                         logger.info("眼科微信消息模板推送 咨询支付提醒开始");
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             } else if ("prescriptionPayRemind".equalsIgnoreCase(titelType)) {
 | 
	
		
			
				|  |  |                 scene = "cfzfts";
 | 
	
		
			
				|  |  |                 WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_prescription_pay_notice", scene, 1);
 | 
	
	
		
			
				|  | @ -4255,49 +4385,53 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                     WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_outpatient_msg_notice_jz", scene, 1);
 | 
	
		
			
				|  |  |                     BeanUtils.copyProperties(config, newConfig);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getDoctorName()).replace("key2", doctorDO.getJobTitleName()));
 | 
	
		
			
				|  |  |                     newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getDoctorName()).replace("key2", StringUtils.isNoneBlank(doctorDO.getJobTitleName())?doctorDO.getJobTitleName():""));
 | 
	
		
			
				|  |  |                     newConfig.setKeyword1( outpatientDO.getDoctorName());
 | 
	
		
			
				|  |  |                     newConfig.setKeyword2(DateUtil.dateToStrLong(outpatientDO.getAdmDate()));
 | 
	
		
			
				|  |  |                     newConfig.setKeyword3(outpatientDO.getDeptName());
 | 
	
		
			
				|  |  |                     newConfig.setKeyword4( outpatientDO.getIcd10Name());
 | 
	
		
			
				|  |  |                     if ("16".equals(type)) {
 | 
	
		
			
				|  |  |                         newConfig.setRemark(config.getRemark().replace("key1", "视频复诊"));
 | 
	
		
			
				|  |  |                         newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
 | 
	
		
			
				|  |  |                     } else if ("17".equals(type)) {
 | 
	
		
			
				|  |  |                         newConfig.setRemark(config.getRemark().replace("key1", "视频咨询"));
 | 
	
		
			
				|  |  |                         newConfig.setUrl(newConfig.getUrl().replace("type=16","type=17") + "" + outpatientDO.getId());
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     //发起微信消息模板推送
 | 
	
		
			
				|  |  |                     newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
 | 
	
		
			
				|  |  |                     logger.info("眼科微信消息模板推送 视频问诊接诊提醒开始");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 if (consultTeam!=null){
 | 
	
		
			
				|  |  |                     WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_outpatient_msg_notice_zx", scene, 1);
 | 
	
		
			
				|  |  |                     BeanUtils.copyProperties(config, newConfig);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     newConfig.setFirst(config.getFirst().replace("key1", consPatientDO.getName()).replace("key2", consDoctorDO.getJobTitleName()));
 | 
	
		
			
				|  |  |                     newConfig.setKeyword1( consDoctorDO.getName());
 | 
	
		
			
				|  |  |                     newConfig.setKeyword2(DateUtil.dateToStrLong(consultTeam.getCzrq()));//咨询暂无挂号时间
 | 
	
		
			
				|  |  |                     newConfig.setKeyword3( hospitalDO.getDeptName());
 | 
	
		
			
				|  |  |                     newConfig.setKeyword4( consultTeam.getSymptoms());
 | 
	
		
			
				|  |  |                     if ("16".equals(type)) {
 | 
	
		
			
				|  |  |                         newConfig.setRemark(config.getRemark().replace("key1", "视频复诊"));
 | 
	
		
			
				|  |  |                     } else if ("17".equals(type)) {
 | 
	
		
			
				|  |  |                         newConfig.setRemark(config.getRemark().replace("key1", "视频咨询"));
 | 
	
		
			
				|  |  |                     logger.info("眼科微信消息模板推送 视频问诊接诊提醒开始");
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     if (consultTeam!=null){
 | 
	
		
			
				|  |  |                         WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_outpatient_msg_notice_zx", scene, 1);
 | 
	
		
			
				|  |  |                         BeanUtils.copyProperties(config, newConfig);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         newConfig.setFirst(config.getFirst().replace("key1", consPatientDO.getName()).replace("key2", consDoctorDO.getJobTitleName()));
 | 
	
		
			
				|  |  |                         newConfig.setKeyword1( consDoctorDO.getName());
 | 
	
		
			
				|  |  |                         newConfig.setKeyword2(DateUtil.dateToStrLong(consultTeam.getCzrq()));//咨询暂无挂号时间
 | 
	
		
			
				|  |  |                         newConfig.setKeyword3( hospitalDO.getDeptName());
 | 
	
		
			
				|  |  |                         newConfig.setKeyword4( consultTeam.getSymptoms());
 | 
	
		
			
				|  |  |                         if ("16".equals(type)) {
 | 
	
		
			
				|  |  |                             newConfig.setRemark(config.getRemark().replace("key1", "视频复诊"));
 | 
	
		
			
				|  |  |                         } else if ("17".equals(type)) {
 | 
	
		
			
				|  |  |                             newConfig.setRemark(config.getRemark().replace("key1", "视频咨询"));
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         //发起微信消息模板推送
 | 
	
		
			
				|  |  |                         newConfig.setUrl(newConfig.getUrl() + "" + consultTeam.getConsult());
 | 
	
		
			
				|  |  |                         logger.info("眼科微信消息模板推送 视频咨询接诊提醒开始");
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     //发起微信消息模板推送
 | 
	
		
			
				|  |  |                     newConfig.setUrl(newConfig.getUrl() + "" + consultTeam.getConsult());
 | 
	
		
			
				|  |  |                     logger.info("眼科微信消息模板推送 视频咨询接诊提醒开始");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             } else if ("videoOrderRemind".equalsIgnoreCase(titelType)) {
 | 
	
		
			
				|  |  |                 scene = "spwzyytx";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 if (StringUtils.isNotEmpty(outpatientId)){
 | 
	
		
			
				|  |  |                     WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_video_notice_fz", scene, 1);
 | 
	
		
			
				|  |  |                     WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_video_notice", scene, 1);
 | 
	
		
			
				|  |  |                     BeanUtils.copyProperties(config, newConfig);
 | 
	
		
			
				|  |  |                     if ("16".equals(type)) {
 | 
	
		
			
				|  |  |                         newConfig.setFirst(config.getFirst().replaceFirst("key1", "视频复诊"));
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     if ("17".equals(type)) {
 | 
	
		
			
				|  |  |                         newConfig.setFirst(config.getFirst().replaceFirst("key1", "视频咨询"));
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     newConfig.setKeyword1( outpatientDO.getConsumerName());
 | 
	
		
			
				|  |  |                     newConfig.setKeyword2( outpatientDO.getDeptName());
 | 
	
		
			
				|  |  |                     newConfig.setKeyword3( outpatientDO.getDoctorName());
 | 
	
	
		
			
				|  | @ -4306,24 +4440,23 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                     //发起微信消息模板推送
 | 
	
		
			
				|  |  |                     newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
 | 
	
		
			
				|  |  |                     logger.info("眼科微信消息模板推送 视频问诊预约提醒开始");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 if (consultTeam!=null){
 | 
	
		
			
				|  |  |                     WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_video_notice_zx", scene, 1);
 | 
	
		
			
				|  |  |                     BeanUtils.copyProperties(config, newConfig);
 | 
	
		
			
				|  |  |                     if ("17".equals(type)) {
 | 
	
		
			
				|  |  |                         newConfig.setFirst(config.getFirst().replaceFirst("key1", "视频咨询"));
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     if (consultTeam!=null){
 | 
	
		
			
				|  |  |                         WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_video_notice", scene, 1);
 | 
	
		
			
				|  |  |                         BeanUtils.copyProperties(config, newConfig);
 | 
	
		
			
				|  |  |                         if ("17".equals(type)) {
 | 
	
		
			
				|  |  |                             newConfig.setFirst(config.getFirst().replaceFirst("key1", "视频咨询"));
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         newConfig.setKeyword1(consPatientDO.getName());
 | 
	
		
			
				|  |  |                         newConfig.setKeyword2(hospitalDO.getDeptName());
 | 
	
		
			
				|  |  |                         newConfig.setKeyword3(consDoctorDO.getName());
 | 
	
		
			
				|  |  |                         newConfig.setKeyword4(DateUtil.dateToStrLong(consultTeam.getCzrq()));
 | 
	
		
			
				|  |  |                         newConfig.setKeyword5(generalDoctorWaitingNumber(consDoctorDO.getId(), wxId, outpatientId));
 | 
	
		
			
				|  |  |                         //发起微信消息模板推送
 | 
	
		
			
				|  |  |                         newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
 | 
	
		
			
				|  |  |                         logger.info("眼科微信消息模板推送 视频咨询预约提醒开始");
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     newConfig.setKeyword1(consPatientDO.getName());
 | 
	
		
			
				|  |  |                     newConfig.setKeyword2(hospitalDO.getDeptName());
 | 
	
		
			
				|  |  |                     newConfig.setKeyword3(consDoctorDO.getName());
 | 
	
		
			
				|  |  |                     newConfig.setKeyword4(DateUtil.dateToStrLong(consultTeam.getCzrq()));
 | 
	
		
			
				|  |  |                     newConfig.setKeyword5(generalDoctorWaitingNumber(consDoctorDO.getId(), wxId, outpatientId));
 | 
	
		
			
				|  |  |                     //发起微信消息模板推送
 | 
	
		
			
				|  |  |                     newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
 | 
	
		
			
				|  |  |                     logger.info("眼科微信消息模板推送 视频咨询预约提醒开始");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             } else if ("evaluateRemind".equalsIgnoreCase(titelType)) {
 | 
	
		
			
				|  |  |                 scene = "fwqjtx";
 | 
	
		
			
				|  |  |                 WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_evaluate_notice", scene, 1);
 | 
	
	
		
			
				|  | @ -4573,9 +4706,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         //协同门诊
 | 
	
		
			
				|  |  |         if (3 == type) {
 | 
	
		
			
				|  |  |             sql += " AND room.reservation_type=2 ";
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |         } else if (4==type){
 | 
	
		
			
				|  |  |             //专家咨询
 | 
	
		
			
				|  |  |             sql += " AND room.reservation_type=3 AND room.consult_type =1";
 | 
	
		
			
				|  |  |         } else if (1==type) {
 | 
	
		
			
				|  |  |             //在线复诊
 | 
	
		
			
				|  |  |             sql += " AND room.reservation_type=1 AND room.consult_type =1";
 | 
	
		
			
				|  |  |         }else if (2==type) {//视频复诊
 | 
	
		
			
				|  |  |             //在线复诊
 | 
	
		
			
				|  |  |             sql += " AND room.reservation_type=1 AND room.consult_type=" + type;
 | 
	
		
			
				|  |  |             sql += " AND room.reservation_type !=3 AND room.consult_type =2";
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(dept)) {
 | 
	
	
		
			
				|  | @ -4584,7 +4725,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         if(StringUtils.isNoneBlank(sex)){
 | 
	
		
			
				|  |  |             sql += " AND patient.sex=" + sex + " ";
 | 
	
		
			
				|  |  |         }if(StringUtils.isNoneBlank(keyword)){
 | 
	
		
			
				|  |  |             sql += " AND patient.name like '%" + keyword + "%' ";
 | 
	
		
			
				|  |  |             sql += " AND outpatient.patient_name like '%" + keyword + "%' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNoneBlank(ageGroup)){
 | 
	
		
			
				|  |  |             String[] age = ageGroup.split(",");
 | 
	
	
		
			
				|  | @ -4621,8 +4762,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                        if (StringUtils.isNotBlank(basePatientDO.getIdcard())){
 | 
	
		
			
				|  |  |                            patientAge = DateUtil.getAgeForIdcard(basePatientDO.getIdcard());
 | 
	
		
			
				|  |  |                            outpatient.put("patientAge", DateUtil.getAgeForIdcard(basePatientDO.getIdcard()));
 | 
	
		
			
				|  |  |                            patientSex =basePatientDO.getSex();
 | 
	
		
			
				|  |  |                        }
 | 
	
		
			
				|  |  |                        patientSex =basePatientDO.getSex();
 | 
	
		
			
				|  |  |                    }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 outpatient.put("patientAge", patientAge);
 | 
	
	
		
			
				|  | @ -5242,6 +5383,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 sql += " and d.del='1' order by d.consult_status DESC ,evaluate.score desc,a.total " + consutlSort;
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 sql += " and d.del='1' order by d.consult_status desc nulls last ,evaluate.score desc nulls last ,a.total " + consutlSort;
 | 
	
		
			
				|  |  |                 sql+=" NULLS LAST,\n" +
 | 
	
		
			
				|  |  |                         "\tD.id DESC";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             sql += " and d.del='1' order by d.consult_status DESC ,evaluate.score desc,a.total " + consutlSort;
 | 
	
	
		
			
				|  | @ -5284,7 +5427,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                     chargeType = chargeType.replace(",","','");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 String sqlCharge = "select charge_type as \"chargeType\",charge_name as \"chargeName\"," +
 | 
	
		
			
				|  |  |                         "req_fee  as \"reqFee\",dept_type_code as \"deptTypeCode\" " +
 | 
	
		
			
				|  |  |                         "req_fee  as \"reqFee\",zj_fee  as \"zjFee\",xt_fee  as \"xtFee\",dept_type_code as \"deptTypeCode\" " +
 | 
	
		
			
				|  |  |                         " from wlyy_charge_dict where 1=1";
 | 
	
		
			
				|  |  |                 sqlCharge+=" and charge_type in ( '"+chargeType+"')";
 | 
	
		
			
				|  |  |                 if (StringUtils.isNoneBlank(deptTyepCode)){
 | 
	
	
		
			
				|  | @ -5309,6 +5452,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                     "LEFT JOIN wlyy_charge_dict d ON t.xtfz_charge_type = d.charge_type\n" +
 | 
	
		
			
				|  |  |                     "WHERE t.id = '"+map.get("id")+"' ";
 | 
	
		
			
				|  |  |             chargeDictDOLists =  hibenateUtils.createSQLQuery(sqlCharge);
 | 
	
		
			
				|  |  |             map.put("chargeTypeList",chargeDictDOLists);
 | 
	
		
			
				|  |  |             //查询医生各项评价平均分
 | 
	
		
			
				|  |  |             String sqlscore = "SELECT " +
 | 
	
		
			
				|  |  |                     "AVG(a.score) AS \"score\"," +
 | 
	
	
		
			
				|  | @ -5896,6 +6040,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 "AND room.outpatient_id=outpatient.id " +
 | 
	
		
			
				|  |  |                 "AND consult.relation_code=outpatient.id " +
 | 
	
		
			
				|  |  |                 "AND outpatient.pay_status=1 " +
 | 
	
		
			
				|  |  |                 "AND outpatient.type =2 " +
 | 
	
		
			
				|  |  |                 "AND consult.status = 0 ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(doctor)) {
 | 
	
		
			
				|  |  |             sql = sql + "AND room.doctor='" + doctor + "' " +
 | 
	
	
		
			
				|  | @ -6000,7 +6145,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         return waitCount.toString();
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public com.alibaba.fastjson.JSONArray getWaitingForVisitVideoPrescriptionByDoctor(String doctor, String wxId) {
 | 
	
		
			
				|  |  |     public com.alibaba.fastjson.JSONArray getWaitingForVisitVideoPrescriptionByDoctor(String doctor, String wxId,String outpatientType,String keyWord) {
 | 
	
		
			
				|  |  |         String condition = "";
 | 
	
		
			
				|  |  |         if ("xm_ykyy_wx".equals(wxId)) {
 | 
	
		
			
				|  |  |             if(flag){
 | 
	
	
		
			
				|  | @ -6046,11 +6191,19 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 "AND outpatient.status = 0 " +
 | 
	
		
			
				|  |  |                 "AND outpatient.pay_status = 1 " +
 | 
	
		
			
				|  |  |                 "AND room.doctor='" + doctor + "' " +
 | 
	
		
			
				|  |  |                 "AND room.reservation_time is not null " +
 | 
	
		
			
				|  |  |                 "AND room.consult_type= 2 ";/* +
 | 
	
		
			
				|  |  |                 "AND room.reservation_time is not null ";/* +
 | 
	
		
			
				|  |  |                 "AND room.reservation_time >= '"+DateUtil.dateToStrShort(new Date())+" 00:00:00' order by room.reservation_time ASC ";
 | 
	
		
			
				|  |  | //                "AND room.reservation_time>='"+DateUtil.getStringDate("yyyy-MM-dd")+" 00:00:00"+"' ";*/
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(outpatientType)&&"1".equalsIgnoreCase(outpatientType)){
 | 
	
		
			
				|  |  |             sql+="  AND room.consult_type= 2 and room.reservation_type in (1,2)";
 | 
	
		
			
				|  |  |         } else if (StringUtils.isNotBlank(outpatientType)&&"4".equalsIgnoreCase(outpatientType)) {
 | 
	
		
			
				|  |  |             sql+="  AND room.consult_type= 2 and room.reservation_type = 3";
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             sql += " AND room.consult_type= 2 ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(keyWord)){
 | 
	
		
			
				|  |  |             sql += " AND outpatient.patient_name like '%"+keyWord+"%'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if ("xm_ykyy_wx".equals(wxId)) {
 | 
	
		
			
				|  |  |             if(flag){
 | 
	
		
			
				|  |  |                 sql += " AND room.reservation_time >= str_to_date('" + DateUtil.dateToStrShort(new Date()) + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
 | 
	
	
		
			
				|  | @ -6159,6 +6312,49 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         wlyyOutpatientDO.setDoctor(doctor);
 | 
	
		
			
				|  |  |         wlyyOutpatientDO.setDoctorName(baseDoctorDO.getName());
 | 
	
		
			
				|  |  |         outpatientDao.save(wlyyOutpatientDO);
 | 
	
		
			
				|  |  |         if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
 | 
	
		
			
				|  |  |             String doctorYktid ="";
 | 
	
		
			
				|  |  |             if (baseDoctorDO!=null){
 | 
	
		
			
				|  |  |                 if(StringUtils.isNoneBlank(baseDoctorDO.getYktDoctorId())){
 | 
	
		
			
				|  |  |                     doctorYktid = baseDoctorDO.getYktDoctorId();
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(baseDoctorDO.getId());
 | 
	
		
			
				|  |  |                     if (doctorMappingDO!=null){
 | 
	
		
			
				|  |  |                         String doctorResponse = ykyyService.getYktDoctor(doctorMappingDO.getMappingCode());
 | 
	
		
			
				|  |  |                         System.out.println("Continue");
 | 
	
		
			
				|  |  |                         com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(doctorResponse);
 | 
	
		
			
				|  |  |                         if (jsonObject.getInteger("code")==200){
 | 
	
		
			
				|  |  |                             com.alibaba.fastjson.JSONArray array = jsonObject.getJSONArray("data");
 | 
	
		
			
				|  |  |                             if (array!=null&&array.size()!=0){
 | 
	
		
			
				|  |  |                                 doctorYktid=array.getJSONObject(0).getString("DOCTORUSERID");
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String orderNo = "";
 | 
	
		
			
				|  |  |             BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatientCode);
 | 
	
		
			
				|  |  |             if (businessOrderDO!=null){
 | 
	
		
			
				|  |  |                 orderNo = businessOrderDO.getOrderNo();
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String res = ykyyService.updateDoctorIdByOrderId(doctorYktid,orderNo);
 | 
	
		
			
				|  |  |             WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(res)){
 | 
	
		
			
				|  |  |                 com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(res);
 | 
	
		
			
				|  |  |                 if (object!=null){
 | 
	
		
			
				|  |  |                     wlyyHttpLogDO.setCode(object.getString("code"));
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setName("抢单医生id写入眼科通");
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setCode("update_doctorid_by_orderno");
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setRequest("doctorId="+doctorYktid+";"+"orderNo="+orderNo);
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setDoctor(doctor);
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setResponse(res);
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |             wlyyHttpLogDao.save(wlyyHttpLogDO);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -6434,7 +6630,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 "AND outpatient.doctor='" + doctor + "' " +
 | 
	
		
			
				|  |  |                 "AND outpatient.pay_status = 1 " +
 | 
	
		
			
				|  |  |                 "AND outpatient.outpatient_type= '" + outpatient_type + "'  ";
 | 
	
		
			
				|  |  |         if ("1".equals(outpatient_type)) {//复诊
 | 
	
		
			
				|  |  |         if ("1".equals(outpatient_type)||"3".equals(outpatient_type)) {//复诊
 | 
	
		
			
				|  |  |             sql = sql + " AND outpatient.type= '" + type + "' ";
 | 
	
		
			
				|  |  |             if ("2".equals(type)) {//视频复诊才需要判断时间,
 | 
	
		
			
				|  |  |                 if ("xm_ykyy_wx".equals(wxId)) {
 | 
	
	
		
			
				|  | @ -6565,17 +6761,58 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      * @param outpatient
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public SystemMessageDO sendOutPatientMes(WlyyOutpatientDO outpatient,boolean payFlag) {
 | 
	
		
			
				|  |  |     public SystemMessageDO sendOutPatientMes(WlyyOutpatientDO outpatient,boolean payFlag)  {
 | 
	
		
			
				|  |  |         System.out.println("发送新增门诊信息");
 | 
	
		
			
				|  |  |         SystemMessageDO systemMessageDO = new SystemMessageDO();
 | 
	
		
			
				|  |  |         String msg = "";
 | 
	
		
			
				|  |  |         JSONObject data = new JSONObject();
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             JSONObject data = new JSONObject();
 | 
	
		
			
				|  |  |             //1.在线复诊2.协同门诊
 | 
	
		
			
				|  |  |             if ("2".equals(outpatient.getOutpatientType())) {
 | 
	
		
			
				|  |  |                 systemMessageDO.setTitle("协同门诊");
 | 
	
		
			
				|  |  |                 systemMessageDO.setType("3");
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |             } else if ("3".equals(outpatient.getOutpatientType())) {//专家咨询
 | 
	
		
			
				|  |  |                 //1.图文 2.视频 3家医
 | 
	
		
			
				|  |  |                 if ("1".equals(outpatient.getType())) {
 | 
	
		
			
				|  |  |                     systemMessageDO.setTitle("图文咨询");
 | 
	
		
			
				|  |  |                     systemMessageDO.setType("18");
 | 
	
		
			
				|  |  |                     if (payFlag){
 | 
	
		
			
				|  |  |                         saveInquirySystemMessage(outpatient,null);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     msg="图文咨询";
 | 
	
		
			
				|  |  |                 } else if("3".equals(outpatient.getType())){
 | 
	
		
			
				|  |  |                     systemMessageDO.setTitle("家医咨询");
 | 
	
		
			
				|  |  |                     systemMessageDO.setType("15");
 | 
	
		
			
				|  |  |                     msg="家医咨询";
 | 
	
		
			
				|  |  |                     if (payFlag){
 | 
	
		
			
				|  |  |                         saveInquirySystemMessage(outpatient,null);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     systemMessageDO.setTitle("视频咨询预约成功");
 | 
	
		
			
				|  |  |                     systemMessageDO.setType("17");
 | 
	
		
			
				|  |  |                     if (payFlag){
 | 
	
		
			
				|  |  |                         saveInquirySystemMessage(outpatient,null);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     msg = "您的视频咨询已预约成功。\n" +
 | 
	
		
			
				|  |  |                             "预计" + outpatient.getDoctorName() + "医生将于" + outpatient.getRegisterDate() + " 与您进行视频咨询。请留意系统消息或微信公众号消息。咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     sendWxTemplateMsg(wechatId, outpatient.getId(),null, "17", "videoOrderRemind", "");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 systemMessageDO.setReceiver(outpatient.getDoctor());
 | 
	
		
			
				|  |  |                 systemMessageDO.setReceiverName(outpatient.getDoctorName());
 | 
	
		
			
				|  |  |                 systemMessageDO.setRelationCode(outpatient.getId());
 | 
	
		
			
				|  |  |                 systemMessageDO.setSender(outpatient.getPatient());
 | 
	
		
			
				|  |  |                 systemMessageDO.setSenderName(outpatient.getPatientName());
 | 
	
		
			
				|  |  |                 systemMessageDO.setRelationCode(outpatient.getId());
 | 
	
		
			
				|  |  |                 data.put("name", outpatient.getPatientName());
 | 
	
		
			
				|  |  |                 data.put("age", IdCardUtil.getAgeForIdcard(outpatient.getIdcard()));
 | 
	
		
			
				|  |  |                 data.put("gender", IdCardUtil.getSexForIdcard_new(outpatient.getIdcard()));
 | 
	
		
			
				|  |  |                 data.put("question", outpatient.getDescription());
 | 
	
		
			
				|  |  |                 data.put("msg", msg);
 | 
	
		
			
				|  |  |                 systemMessageDO.setData(data.toString());
 | 
	
		
			
				|  |  |                 logger.info("添加模板消息4");
 | 
	
		
			
				|  |  |                 systemMessageService.saveMessage(systemMessageDO);
 | 
	
		
			
				|  |  |             } else if ("1".equals(outpatient.getOutpatientType()))  {//在线复诊
 | 
	
		
			
				|  |  |                 //1.图文 2.视频
 | 
	
		
			
				|  |  |                 if ("1".equals(outpatient.getType())) {
 | 
	
		
			
				|  |  |                     systemMessageDO.setTitle("图文复诊");
 | 
	
	
		
			
				|  | @ -6583,42 +6820,44 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                     if (payFlag){
 | 
	
		
			
				|  |  |                         saveInquirySystemMessage(outpatient,null);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     msg="图文复诊";
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     systemMessageDO.setTitle("视频复诊预约成功");
 | 
	
		
			
				|  |  |                     systemMessageDO.setType("2");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     if (payFlag){
 | 
	
		
			
				|  |  |                         saveInquirySystemMessage(outpatient,null);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     msg = "您的视频复诊已预约成功。\n" +
 | 
	
		
			
				|  |  |                             "预计" + outpatient.getDoctorName() + "医生将于" + outpatient.getRegisterDate() + " 与您进行视频咨询。请留意系统消息或微信公众号消息。咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
 | 
	
		
			
				|  |  |                     systemMessageDO.setReceiver(outpatient.getDoctor());
 | 
	
		
			
				|  |  |                     systemMessageDO.setReceiverName(outpatient.getDoctorName());
 | 
	
		
			
				|  |  |                     systemMessageDO.setRelationCode(outpatient.getId());
 | 
	
		
			
				|  |  |                     systemMessageDO.setSender(outpatient.getPatient());
 | 
	
		
			
				|  |  |                     systemMessageDO.setSenderName(outpatient.getPatientName());
 | 
	
		
			
				|  |  |                     systemMessageDO.setRelationCode(outpatient.getId());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     data.put("name", outpatient.getPatientName());
 | 
	
		
			
				|  |  |                     data.put("age", IdCardUtil.getAgeForIdcard(outpatient.getIdcard()));
 | 
	
		
			
				|  |  |                     data.put("gender", IdCardUtil.getSexForIdcard_new(outpatient.getIdcard()));
 | 
	
		
			
				|  |  |                     data.put("question", outpatient.getDescription());
 | 
	
		
			
				|  |  |                     data.put("msg", msg);
 | 
	
		
			
				|  |  |                     systemMessageDO.setData(data.toString());
 | 
	
		
			
				|  |  |                     systemMessageService.saveMessage(systemMessageDO);
 | 
	
		
			
				|  |  |                     sendWxTemplateMsg(wechatId, outpatient.getId(),null, "17", "videoOrderRemind", "");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     sendWxTemplateMsg(wechatId, outpatient.getId(),null, "16", "videoOrderRemind", "");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 systemMessageDO.setReceiver(outpatient.getDoctor());
 | 
	
		
			
				|  |  |                 systemMessageDO.setReceiverName(outpatient.getDoctorName());
 | 
	
		
			
				|  |  |                 systemMessageDO.setRelationCode(outpatient.getId());
 | 
	
		
			
				|  |  |                 systemMessageDO.setSender(outpatient.getPatient());
 | 
	
		
			
				|  |  |                 systemMessageDO.setSenderName(outpatient.getPatientName());
 | 
	
		
			
				|  |  |                 systemMessageDO.setRelationCode(outpatient.getId());
 | 
	
		
			
				|  |  |                 logger.info("添加模板消息5");
 | 
	
		
			
				|  |  |                 data.put("name", outpatient.getPatientName());
 | 
	
		
			
				|  |  |                 data.put("age", IdCardUtil.getAgeForIdcard(outpatient.getIdcard()));
 | 
	
		
			
				|  |  |                 data.put("gender", IdCardUtil.getSexForIdcard_new(outpatient.getIdcard()));
 | 
	
		
			
				|  |  |                 data.put("question", outpatient.getDescription());
 | 
	
		
			
				|  |  |                 data.put("msg", msg);
 | 
	
		
			
				|  |  |                 systemMessageDO.setData(data.toString());
 | 
	
		
			
				|  |  |                 systemMessageService.saveMessage(systemMessageDO);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             BasePatientDO patient = basePatientDao.findById(outpatient.getPatient());
 | 
	
		
			
				|  |  |             if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
 | 
	
		
			
				|  |  |                 ykyyService.pushNotificationToYktPatient(patient.getYktId(), systemMessageDO.getTitle(), data.get("msg").toString());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             logger.error("sendOutPatientMes :" + e.toString());
 | 
	
		
			
				|  |  |             return null;
 | 
	
		
			
				|  |  |             return systemMessageDO;
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |             logger.info("sendOutPatientMes"+e.getMessage());
 | 
	
		
			
				|  |  |             return  null;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return systemMessageDO;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public void saveInquirySystemMessage(WlyyOutpatientDO outpatient,ConsultTeamDo consultTeamDo) {
 | 
	
	
		
			
				|  | @ -6629,14 +6868,23 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         systemMessageDO.setType("11");
 | 
	
		
			
				|  |  |         JSONObject data = new JSONObject();
 | 
	
		
			
				|  |  |         if (outpatient!=null){
 | 
	
		
			
				|  |  |             if ("1".equals(outpatient.getType())) {
 | 
	
		
			
				|  |  |                 type = "9";
 | 
	
		
			
				|  |  |                 msg = outpatient.getPatientName() + ",您好!您有一个图文复诊订单待支付,请及时支付。点击完成支付,如您已支付请忽略本条信息。";
 | 
	
		
			
				|  |  |             } else if ("2".equals(outpatient.getType())){
 | 
	
		
			
				|  |  |                 type = "16";
 | 
	
		
			
				|  |  |                 msg = outpatient.getPatientName() + ",您好!您有一个视频复诊订单待支付,请及时支付。点击完成支付,如您已支付请忽略本条信息。";
 | 
	
		
			
				|  |  |             if("1".equalsIgnoreCase(outpatient.getOutpatientType())){
 | 
	
		
			
				|  |  |                 if ("1".equals(outpatient.getType())) {
 | 
	
		
			
				|  |  |                     type = "9";
 | 
	
		
			
				|  |  |                     msg = outpatient.getPatientName() + ",您好!您有一个图文复诊订单待支付,请及时支付。点击完成支付,如您已支付请忽略本条信息。";
 | 
	
		
			
				|  |  |                 } else if ("2".equals(outpatient.getType())){
 | 
	
		
			
				|  |  |                     type = "16";
 | 
	
		
			
				|  |  |                     msg = outpatient.getPatientName() + ",您好!您有一个视频复诊订单待支付,请及时支付。点击完成支付,如您已支付请忽略本条信息。";
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }else if ("3".equalsIgnoreCase(outpatient.getOutpatientType())){
 | 
	
		
			
				|  |  |                 if ("1".equals(outpatient.getType())) {
 | 
	
		
			
				|  |  |                     type = "1";
 | 
	
		
			
				|  |  |                     msg = outpatient.getPatientName() + ",您好!您有一个图文咨询订单待支付,请及时支付。点击完成支付,如您已支付请忽略本条信息。";
 | 
	
		
			
				|  |  |                 } else if ("2".equals(outpatient.getType())){
 | 
	
		
			
				|  |  |                     type = "17";
 | 
	
		
			
				|  |  |                     msg = outpatient.getPatientName() + ",您好!您有一个视频咨询订单待支付,请及时支付。点击完成支付,如您已支付请忽略本条信息。";
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             systemMessageDO.setSender(outpatient.getDoctor());
 | 
	
		
			
				|  |  |             systemMessageDO.setSenderName(outpatient.getDoctorName());
 | 
	
		
			
				|  |  |             systemMessageDO.setRelationCode(outpatient.getId());
 | 
	
	
		
			
				|  | @ -6725,6 +6973,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         one.setDept(outpatientDO.getDept());
 | 
	
		
			
				|  |  |         one.setDeptName(outpatientDO.getDeptName());
 | 
	
		
			
				|  |  |         one.setType(outpatientDO.getType());
 | 
	
		
			
				|  |  |         one.setOutpatientType(outpatientDO.getOutpatientType());
 | 
	
		
			
				|  |  |         WlyyOutpatientDO outpatient = outpatientDao.save(one);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         WlyyPatientRegisterTimeDO registerTimeDO = null;
 | 
	
	
		
			
				|  | @ -6742,6 +6991,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 registerTimeDO.setOutpatientId(outpatient.getId());
 | 
	
		
			
				|  |  |                 registerTimeDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                 patientRegisterTimeDao.save(registerTimeDO);
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 one.setRegisterDate(new Date());
 | 
	
		
			
				|  |  |                 outpatientDao.save(one);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             throw new RuntimeException("号源已经被预约,请选择其他号源");
 | 
	
	
		
			
				|  | @ -6761,6 +7013,49 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             hospitalWaitingRoomDao.save(roomDOs);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
 | 
	
		
			
				|  |  |             String doctorYktid = "";
 | 
	
		
			
				|  |  |             String orderNo = "";
 | 
	
		
			
				|  |  |             BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(outpatientDO.getDoctor());
 | 
	
		
			
				|  |  |             if (baseDoctorDO!=null){
 | 
	
		
			
				|  |  |                 if(StringUtils.isNoneBlank(baseDoctorDO.getYktDoctorId())){
 | 
	
		
			
				|  |  |                     doctorYktid = baseDoctorDO.getYktDoctorId();
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(baseDoctorDO.getId());
 | 
	
		
			
				|  |  |                     if (doctorMappingDO!=null){
 | 
	
		
			
				|  |  |                         String doctorResponse = ykyyService.getYktDoctor(doctorMappingDO.getMappingCode());
 | 
	
		
			
				|  |  |                         System.out.println("Continue");
 | 
	
		
			
				|  |  |                         com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(doctorResponse);
 | 
	
		
			
				|  |  |                         if (jsonObject.getInteger("code")==200){
 | 
	
		
			
				|  |  |                             com.alibaba.fastjson.JSONArray array = jsonObject.getJSONArray("data");
 | 
	
		
			
				|  |  |                             if (array!=null&&array.size()!=0){
 | 
	
		
			
				|  |  |                                 doctorYktid=array.getJSONObject(0).getString("DOCTORUSERID");
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatientDO.getId());
 | 
	
		
			
				|  |  |             if (businessOrderDO!=null){
 | 
	
		
			
				|  |  |                 orderNo = businessOrderDO.getOrderNo();
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String res = ykyyService.updateDoctorIdByOrderId(doctorYktid,orderNo);
 | 
	
		
			
				|  |  |             WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(res)){
 | 
	
		
			
				|  |  |                 com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(res);
 | 
	
		
			
				|  |  |                 if (object!=null){
 | 
	
		
			
				|  |  |                     wlyyHttpLogDO.setCode(object.getString("code"));
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setName("患者选择抢单医生id写入眼科通");
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setCode("update_doctorid_by_orderno");
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setRequest("doctorId="+doctorYktid+";"+"orderNo="+orderNo);
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setDoctor(outpatientDO.getDoctor());
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setPatient(outpatientDO.getConsumer());
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setResponse(res);
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |             wlyyHttpLogDao.save(wlyyHttpLogDO);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return outpatient;
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -6821,7 +7116,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                         patient.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                         patient.setUpdateTime(new Date());
 | 
	
		
			
				|  |  |                         patient.setBirthday(DateUtil.strToDate(biz.getString("birthday"), "yyyyMMdd"));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         basePatientDao.save(patient);
 | 
	
		
			
				|  |  |                         rsMap.put("sCode", auth_status);
 | 
	
		
			
				|  |  |                         rsMap.put("sMes", "success");
 | 
	
	
		
			
				|  | @ -8231,6 +8525,33 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Boolean sendOutPatientSuggest(String advicesJson) {
 | 
	
		
			
				|  |  |         List<WlyyConsultAdvice> advices = (List<WlyyConsultAdvice>) com.alibaba.fastjson.JSONArray.parseArray(advicesJson, WlyyConsultAdvice.class);
 | 
	
		
			
				|  |  |         if (advices!=null&&advices.size()>0){
 | 
	
		
			
				|  |  |             WlyyConsultAdvice advice = advices.get(0);
 | 
	
		
			
				|  |  |             String consult =  advice.getConsult();
 | 
	
		
			
				|  |  |             String sql = "select t.relation_code as \"relationCode\" from wlyy_consult t where t.id = '"+consult+"'";
 | 
	
		
			
				|  |  |             List<Map<String,Object>> map = hibenateUtils.createSQLQuery(sql);
 | 
	
		
			
				|  |  |             if(map!=null&&map.size()>0){
 | 
	
		
			
				|  |  |                 String outpatientId= map.get(0).get("relationCode").toString();
 | 
	
		
			
				|  |  |                WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId);
 | 
	
		
			
				|  |  |                if (wlyyOutpatientDO!=null){
 | 
	
		
			
				|  |  |                    StringBuffer content = new StringBuffer();
 | 
	
		
			
				|  |  |                    StringBuffer icd10Code = new StringBuffer();
 | 
	
		
			
				|  |  |                    for (WlyyConsultAdvice consultAdvice:advices){
 | 
	
		
			
				|  |  |                        content.append(consultAdvice.getAdviceValue()+",");
 | 
	
		
			
				|  |  |                        icd10Code.append(consultAdvice.getAdviceKey()+",");
 | 
	
		
			
				|  |  |                    }
 | 
	
		
			
				|  |  |                    if (content!=null&&content.length()>0){
 | 
	
		
			
				|  |  |                        System.out.println("content+====="+content);
 | 
	
		
			
				|  |  |                        content.deleteCharAt(content.length()-1);
 | 
	
		
			
				|  |  |                        icd10Code.deleteCharAt(icd10Code.length()-1);
 | 
	
		
			
				|  |  |                    }
 | 
	
		
			
				|  |  |                    wlyyOutpatientDO.setIcd10Name(content.toString());
 | 
	
		
			
				|  |  |                    wlyyOutpatientDO.setIcd10(icd10Code.toString());
 | 
	
		
			
				|  |  |                    outpatientDao.save(wlyyOutpatientDO);
 | 
	
		
			
				|  |  |                }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         wlyyConsultAdviceDao.save(advices);
 | 
	
		
			
				|  |  |         return true;
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -9186,8 +9507,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         return null;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public static void main(String[] args) {
 | 
	
		
			
				|  |  |         String ss = DateUtil.getStringDateShort();
 | 
	
		
			
				|  |  |         System.out.println(ss);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     public com.alibaba.fastjson.JSONObject selectHospitalInfo(String doctorId,String orgCode){
 | 
	
		
			
				|  |  |         /**
 | 
	
		
			
				|  |  |          * 1、今日待就诊:今日当前家庭医生在当前医院的未完成的协同门诊书
 | 
	
	
		
			
				|  | @ -9202,8 +9525,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |          6、累计就诊:当前医院累计协同门诊的已接诊数量
 | 
	
		
			
				|  |  |          */
 | 
	
		
			
				|  |  |         Date startTime  = DateUtil.strToDateLong(DateUtil.getStringDateShort()+" 00:00:00");
 | 
	
		
			
				|  |  |         Date endTime  = DateUtil.strToDateLong(DateUtil.getStringDateShort()+" 23:59:59");
 | 
	
		
			
				|  |  |         String nowDate = DateUtil.getStringDateShort();
 | 
	
		
			
				|  |  |         Date startTime  = DateUtil.strToDateLong(nowDate+" 00:00:00");
 | 
	
		
			
				|  |  |         Date endTime  = DateUtil.strToDateLong(nowDate+" 23:59:59");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
 | 
	
		
			
				|  |  |         // 1、今日待就诊:今日当前家庭医生在当前医院的未完成的协同门诊书
 | 
	
		
			
				|  |  |         List<WlyyOutpatientDO> outpatientDOS =  outpatientDao.findByGeneralDoctorAndStatusAndDate(doctorId,startTime,endTime,"0,1,2");
 | 
	
	
		
			
				|  | @ -9216,12 +9541,22 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             jsonObject.put("nextTime",null);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //3、服务评分:当前医院的综合服务评分
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //在线医生:当前医院在班的专科医生数
 | 
	
		
			
				|  |  |         String sql ="SELECT d.id as \"id\",d.name as \"name\" FROM base_doctor d WHERE (EXISTS (SELECT 1 FROM wlyy_doctor_work_time t WHERE t.doctor = d.id AND t.start_time >=:startTime AND t.end_time <=:endTime ) OR  d.consult_status = '1')";
 | 
	
		
			
				|  |  |         Map<String, Object> params = new HashedMap();
 | 
	
		
			
				|  |  |         params.put("startTime",startTime);
 | 
	
		
			
				|  |  |         params.put("endTime",endTime);
 | 
	
		
			
				|  |  |         String timeCondition="";
 | 
	
		
			
				|  |  |         if("xm_ykyy_wx".equals(wechatId)){
 | 
	
		
			
				|  |  |             if (flag){
 | 
	
		
			
				|  |  |                 timeCondition+="AND t.start_time >= '"+nowDate+" 00:00:00'";
 | 
	
		
			
				|  |  |                 timeCondition+="AND t.start_time <= '"+nowDate+" 23:59:59'";
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 timeCondition+="AND t.start_time >= to_date('"+nowDate+" 00:00:00','yyyy-mm-dd hh24:mi:ss')";
 | 
	
		
			
				|  |  |                 timeCondition+="AND t.start_time <= to_date('"+nowDate+" 23:59:59','yyyy-mm-dd hh24:mi:ss')";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             timeCondition+="AND t.start_time >= '"+nowDate+" 00:00:00'";
 | 
	
		
			
				|  |  |             timeCondition+="AND t.start_time <= '"+nowDate+" 23:59:59'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String sql ="SELECT d.id as \"id\",d.name as \"name\" FROM base_doctor d WHERE (EXISTS (SELECT 1 FROM wlyy_doctor_work_time t WHERE t.doctor = d.id "+timeCondition+"  ) OR  d.consult_status = '1')";
 | 
	
		
			
				|  |  |         List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, params);
 | 
	
		
			
				|  |  |         jsonObject.put("onlineDoctors",list.size());
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -9434,5 +9769,47 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             return "ok";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> findOutpatientAndPatient(String startTime,String endTime){
 | 
	
		
			
				|  |  |         String sql  = "SELECT\n" +
 | 
	
		
			
				|  |  |                 "\tt.status as \"status\",\n" +
 | 
	
		
			
				|  |  |                 "\tt.source as \"source\",\n" +
 | 
	
		
			
				|  |  |                 "\tt.outpatient_type as \"outpatientType\",\n" +
 | 
	
		
			
				|  |  |                 "\tt.create_time as \"createTime\",\n" +
 | 
	
		
			
				|  |  |                 "\tb.idcard as \"idCard\" \n" +
 | 
	
		
			
				|  |  |                 "FROM\n" +
 | 
	
		
			
				|  |  |                 "\twlyy_outpatient t\n" +
 | 
	
		
			
				|  |  |                 "\tLEFT JOIN base_patient b ON t.patient = b.id where 1=1 ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(startTime)){
 | 
	
		
			
				|  |  |             if("xm_ykyy_wx".equals(wechatId)){
 | 
	
		
			
				|  |  |                 if (flag){
 | 
	
		
			
				|  |  |                     sql+=" and t.create_time >= '" + startTime + " ' ";
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     sql+=" and t.create_time >= to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss') ";
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 sql+=" and t.create_time >= '" + startTime + "' ";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(endTime)){
 | 
	
		
			
				|  |  |             if("xm_ykyy_wx".equals(wechatId)){
 | 
	
		
			
				|  |  |                 if (flag){
 | 
	
		
			
				|  |  |                     sql+=" and t.create_time <= '" + endTime + "' ";
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     sql+=" and t.create_time <= to_date('" + endTime + "', 'yyyy-mm-dd hh24:mi:ss') ";
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 sql+=" and t.create_time <= '" + endTime + "'";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
 | 
	
		
			
				|  |  |         for (Map<String,Object> map:list){
 | 
	
		
			
				|  |  |             if (map.get("createTime")!=null){
 | 
	
		
			
				|  |  |                 map.put("createTime",DateUtil.dateToStrLong(DateUtil.strToDateLong(map.get("createTime").toString())));
 | 
	
		
			
				|  |  |                 map.put("orgCode",wechatId);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return list;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |