|  | @ -21,6 +21,7 @@ import com.yihu.jw.entity.hospital.doctor.WlyyPatientRegisterTimeDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.prescription.*;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.file_upload.FileUploadService;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.dict.WlyyChargeDictDao;
 | 
	
	
		
			
				|  | @ -49,6 +50,7 @@ import com.yihu.jw.util.common.IdCardUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.common.QrcodeUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.date.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.mysql.query.BaseJpaService;
 | 
	
		
			
				|  |  | import com.yihu.utils.security.MD5;
 | 
	
		
			
				|  |  | import com.ylzinfo.ehc.EhcHandler;
 | 
	
		
			
				|  |  | import com.ylzinfo.ehc.common.utils.DateUtils;
 | 
	
		
			
				|  |  | import com.ylzinfo.ehc.trans.TransRequest;
 | 
	
	
		
			
				|  | @ -75,7 +77,7 @@ import java.lang.Boolean;
 | 
	
		
			
				|  |  | import java.util.*;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * Created by Trick on 2019/5/17.
 | 
	
		
			
				|  |  |  * Created by Trick on 2019/5/17
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  | @Service
 | 
	
		
			
				|  |  | @Transactional
 | 
	
	
		
			
				|  | @ -135,7 +137,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |     private PrescriptionExpressageService sfexpressService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private WlyyDoctorOnlineTimeDao wlyyDoctorOnlineTimeDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private OauthYlzConfigDao oauthYlzConfigDao;
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Value("${demo.flag}")
 | 
	
	
		
			
				|  | @ -533,7 +536,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public WlyyOutpatientDO appointmentRevisit(String outpatientJson,String expressageJson,String registerJson)throws Exception{
 | 
	
		
			
				|  |  |     public WlyyOutpatientDO appointmentRevisit(String outpatientJson,String expressageJson,String registerJson,String chargeType)throws Exception{
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //1.保存就诊实体
 | 
	
		
			
				|  |  |         WlyyOutpatientDO outpatientDO = objectMapper.readValue(outpatientJson,WlyyOutpatientDO.class);
 | 
	
	
		
			
				|  | @ -570,7 +573,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         prescriptionExpressageDao.save(expressageDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //3.创建候诊室
 | 
	
		
			
				|  |  |         createRoom(outpatient);
 | 
	
		
			
				|  |  |         createRoom(outpatient,chargeType);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return outpatient;
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -581,7 +584,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      * @param outpatientDO
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Boolean createRoom(WlyyOutpatientDO outpatientDO){
 | 
	
		
			
				|  |  |     public Boolean createRoom(WlyyOutpatientDO outpatientDO,String chargeType){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         WlyyHospitalWaitingRoomDO waitingRoom = new WlyyHospitalWaitingRoomDO();
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -611,6 +614,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         waitingRoom.setOutpatientId(outpatientDO.getId());
 | 
	
		
			
				|  |  |         waitingRoom.setCreateTime(new Date());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(chargeType)){
 | 
	
		
			
				|  |  |             waitingRoom.setChargeType(chargeType);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         hospitalWaitingRoomDao.save(waitingRoom);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return true;
 | 
	
	
		
			
				|  | @ -1008,16 +1016,26 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             throw new RuntimeException("未找到医生映射信息");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //判断是否已经挂号,如果已经挂号
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(outpatientDO.getConNo())&&StringUtils.isNotBlank(outpatientDO.getRegisterNo())){
 | 
	
		
			
				|  |  |             net.sf.json.JSONObject res = new JSONObject();
 | 
	
		
			
				|  |  |             res.put("@RESULT","0");
 | 
	
		
			
				|  |  |             return res;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         net.sf.json.JSONObject rs = entranceService.BS10111(outpatientDO.getCardNo(),doctorMappingDO.getMappingCode(),outpatientDO.getDept(),null,outpatientDO.getWinNo(),demoFlag);
 | 
	
		
			
				|  |  |         String rsCode = (String)rs.get("@RESULT");
 | 
	
		
			
				|  |  |         net.sf.json.JSONObject res = rs.getJSONObject("resquest");
 | 
	
		
			
				|  |  |         logger.info("res: " +res.toString());
 | 
	
		
			
				|  |  |         String rsCode = res.getString("@RESULT");
 | 
	
		
			
				|  |  |         if("0".equals(rsCode)){
 | 
	
		
			
				|  |  |             //存储挂号号
 | 
	
		
			
				|  |  |             String serialNo = (String)rs.get("serial_no");
 | 
	
		
			
				|  |  |             outpatientDO.setRegisterNo(serialNo);
 | 
	
		
			
				|  |  |             String conNo = (String)rs.get("@times");
 | 
	
		
			
				|  |  |             outpatientDO.setConNo(conNo);
 | 
	
		
			
				|  |  |             outpatientDao.save(outpatientDO);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //保存日志
 | 
	
		
			
				|  |  |             //保存日志
 | 
	
		
			
				|  |  |         WlyyHttpLogDO log = new WlyyHttpLogDO();
 | 
	
		
			
				|  |  |         log.setCode("registerOutPatient");
 | 
	
		
			
				|  |  |         log.setName("挂号");
 | 
	
	
		
			
				|  | @ -1028,7 +1046,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         log.setStatus(rsCode);
 | 
	
		
			
				|  |  |         log.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         wlyyHttpLogDao.save(log);
 | 
	
		
			
				|  |  |         return rs;
 | 
	
		
			
				|  |  |         return res;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -1183,13 +1201,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                     json.put("days",info.getDays());
 | 
	
		
			
				|  |  |                     json.put("frequency",info.getFrequency());
 | 
	
		
			
				|  |  |                     jsonData.add(json);
 | 
	
		
			
				|  |  |                     logger.info("json:" +json.toString());
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 //保存处方
 | 
	
		
			
				|  |  |                 prescriptionInfoDao.save(infoDOs);
 | 
	
		
			
				|  |  |                 
 | 
	
		
			
				|  |  |                 //调用his开方接口
 | 
	
		
			
				|  |  |                 net.sf.json.JSONObject jsonObject = entranceService.BS10112(jsonData.toJSONString(),demoFlag);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 logger.info("调用his开方接口: "+jsonObject.toString());
 | 
	
		
			
				|  |  |                 //判断返回结果
 | 
	
		
			
				|  |  |                 String rs = jsonObject.getString("@RESULT");
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -1547,7 +1566,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public net.sf.json.JSONObject getCardInfo(String cardNo, boolean demoFlag) throws Exception {
 | 
	
		
			
				|  |  |         return entranceService.qutpatientBalance(cardNo,true);
 | 
	
		
			
				|  |  |         return entranceService.qutpatientBalance(cardNo,demoFlag);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> findWorkTimeInfo(String id){
 | 
	
	
		
			
				|  | @ -2204,6 +2223,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 " d.job_title_name AS jobTitleName," +
 | 
	
		
			
				|  |  |                 " d.charge_type AS chargeType," +
 | 
	
		
			
				|  |  |                 " h.dept_name AS deptName," +
 | 
	
		
			
				|  |  |                 " d.consult_status AS consultStatus," +
 | 
	
		
			
				|  |  |                 " a.total as consultTotal" +
 | 
	
		
			
				|  |  |                 " FROM " +
 | 
	
		
			
				|  |  |                 " base_doctor d " +
 | 
	
	
		
			
				|  | @ -2461,6 +2481,23 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         return rs;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Map<String,Object> getPatientInfoMap(BasePatientDO basePatientDO){
 | 
	
		
			
				|  |  |         Map<String,Object> rs = new HashedMap();
 | 
	
		
			
				|  |  |         rs.put("id",basePatientDO.getId());
 | 
	
		
			
				|  |  |         rs.put("name",basePatientDO.getName());
 | 
	
		
			
				|  |  |         rs.put("sex",basePatientDO.getSex());
 | 
	
		
			
				|  |  |         rs.put("provinceCode",basePatientDO.getProvinceCode());
 | 
	
		
			
				|  |  |         rs.put("provinceName",basePatientDO.getProvinceName());
 | 
	
		
			
				|  |  |         rs.put("cityCode",basePatientDO.getCityCode());
 | 
	
		
			
				|  |  |         rs.put("cityName",basePatientDO.getCityName());
 | 
	
		
			
				|  |  |         rs.put("townCode",basePatientDO.getTownCode());
 | 
	
		
			
				|  |  |         rs.put("townName",basePatientDO.getTownName());
 | 
	
		
			
				|  |  |         rs.put("idcard",basePatientDO.getIdcard());
 | 
	
		
			
				|  |  |         rs.put("age",IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard()));
 | 
	
		
			
				|  |  |         rs.put("mobile",basePatientDO.getMobile());
 | 
	
		
			
				|  |  |         return rs;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private FileUploadService fileUploadService;
 | 
	
	
		
			
				|  | @ -2833,12 +2870,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 发起图文和视频复诊
 | 
	
		
			
				|  |  |      * 发起图文和视频协同门诊复诊
 | 
	
		
			
				|  |  |      * @param outpatientJson
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public WlyyOutpatientDO cooperativeOutpatient(String outpatientJson,String registerJson)throws Exception{
 | 
	
		
			
				|  |  |     public WlyyOutpatientDO cooperativeOutpatient(String outpatientJson,String registerJson,String chargeType)throws Exception{
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //1.保存就诊实体
 | 
	
		
			
				|  |  |         WlyyOutpatientDO outpatientDO = objectMapper.readValue(outpatientJson,WlyyOutpatientDO.class);
 | 
	
	
		
			
				|  | @ -2868,8 +2905,259 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //3.创建候诊室
 | 
	
		
			
				|  |  |         createRoom(outpatient);
 | 
	
		
			
				|  |  |         createRoom(outpatient,chargeType);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return outpatient;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 验证电子健康卡授权
 | 
	
		
			
				|  |  |      * @param authorizeNo
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Map<String,Object> checkOauthQRCode(String authorizeNo){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Map<String,Object> rsMap = new HashedMap();
 | 
	
		
			
				|  |  |         OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findOne("ylz_config");
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             TransRequest e = new TransRequest();
 | 
	
		
			
				|  |  |             e.setMethod("ehc.ehealthcard.auth.query");
 | 
	
		
			
				|  |  |             e.setApp_id(oauthYlzConfigDO.getAppId());
 | 
	
		
			
				|  |  |             e.setTerm_id(oauthYlzConfigDO.getTermId());
 | 
	
		
			
				|  |  |             e.setVersion(oauthYlzConfigDO.getVersion());
 | 
	
		
			
				|  |  |             e.setTimestamp(DateUtil.dateToStr(new Date(),"yyyyMMddHHmmss"));
 | 
	
		
			
				|  |  |             e.setSign_type(oauthYlzConfigDO.getSignType());
 | 
	
		
			
				|  |  |             e.setEnc_type(oauthYlzConfigDO.getEncType());
 | 
	
		
			
				|  |  |             com.alibaba.fastjson.JSONObject bizContent = new com.alibaba.fastjson.JSONObject();
 | 
	
		
			
				|  |  |             bizContent.put("out_authorize_no", authorizeNo);
 | 
	
		
			
				|  |  |             e.setBiz_content(JSON.toJSONString(bizContent));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             EhcHandler ehcHandler = new EhcHandler(oauthYlzConfigDO.getUrl(), oauthYlzConfigDO.getAppId(), oauthYlzConfigDO.getTermId(), oauthYlzConfigDO.getAppKey());
 | 
	
		
			
				|  |  |             TransResponse re = ehcHandler.execute(e);
 | 
	
		
			
				|  |  |             String rs = com.alibaba.fastjson.JSONObject.toJSONString(re);
 | 
	
		
			
				|  |  |             com.alibaba.fastjson.JSONObject json = (com.alibaba.fastjson.JSONObject) com.alibaba.fastjson.JSONObject.parse(rs);
 | 
	
		
			
				|  |  |             logger.info("checkOauthQRCode:"+rs);
 | 
	
		
			
				|  |  |             String ret_code = json.getString("ret_code");
 | 
	
		
			
				|  |  |             if("0000".equals(ret_code)){
 | 
	
		
			
				|  |  |                 logger.info("biz_content: "+json.getString("biz_content"));
 | 
	
		
			
				|  |  |                 String strBiz = json.getString("biz_content");
 | 
	
		
			
				|  |  |                 com.alibaba.fastjson.JSONObject biz = (com.alibaba.fastjson.JSONObject) com.alibaba.fastjson.JSONObject.parse(strBiz);
 | 
	
		
			
				|  |  | //                com.alibaba.fastjson.JSONObject biz = json.getJSONObject("biz_content");
 | 
	
		
			
				|  |  |                 String  auth_status = biz.getString("auth_status");
 | 
	
		
			
				|  |  |                 if("succ".equals(auth_status)){
 | 
	
		
			
				|  |  |                     String idcard = biz.getString("id_no");
 | 
	
		
			
				|  |  |                     BasePatientDO patientDO =  basePatientDao.findByIdcardAndDel(idcard,"1");
 | 
	
		
			
				|  |  |                     if(patientDO == null){
 | 
	
		
			
				|  |  |                         BasePatientDO patient = new BasePatientDO();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         String salt = UUID.randomUUID().toString().substring(0,5);
 | 
	
		
			
				|  |  |                         String mobile = biz.getString("mobile_phone");
 | 
	
		
			
				|  |  |                         String pw = idcard.substring(mobile.length()-6);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         patient.setIdcard(idcard);
 | 
	
		
			
				|  |  |                         patient.setName(biz.getString("user_name"));
 | 
	
		
			
				|  |  |                         patient.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
 | 
	
		
			
				|  |  |                         patient.setSalt(salt);
 | 
	
		
			
				|  |  |                         patient.setMobile(mobile);
 | 
	
		
			
				|  |  |                         patient.setDel("1");
 | 
	
		
			
				|  |  |                         patient.setEnabled(1);
 | 
	
		
			
				|  |  |                         patient.setLocked(0);
 | 
	
		
			
				|  |  |                         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");
 | 
	
		
			
				|  |  |                         rsMap.put("patient",getPatientInfoMap(patient));
 | 
	
		
			
				|  |  |                         return rsMap;
 | 
	
		
			
				|  |  |                     }else{
 | 
	
		
			
				|  |  |                         rsMap.put("sCode",auth_status);
 | 
	
		
			
				|  |  |                         rsMap.put("sMes","success");
 | 
	
		
			
				|  |  |                         rsMap.put("patient",getPatientInfoMap(patientDO));
 | 
	
		
			
				|  |  |                         return rsMap;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }else if("ing".equals(auth_status)){
 | 
	
		
			
				|  |  |                     rsMap.put("sCode",auth_status);
 | 
	
		
			
				|  |  |                     rsMap.put("sMes","正在授权");
 | 
	
		
			
				|  |  |                     return rsMap;
 | 
	
		
			
				|  |  |                 }else if("fail".equals(auth_status)){
 | 
	
		
			
				|  |  |                     rsMap.put("sCode",auth_status);
 | 
	
		
			
				|  |  |                     rsMap.put("sMes","授权失败");
 | 
	
		
			
				|  |  |                     return rsMap;
 | 
	
		
			
				|  |  |                 }else if("cancel".equals(auth_status)){
 | 
	
		
			
				|  |  |                     rsMap.put("sCode",auth_status);
 | 
	
		
			
				|  |  |                     rsMap.put("sMes","取消授权");
 | 
	
		
			
				|  |  |                     return rsMap;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             rsMap.put("sCode","err");
 | 
	
		
			
				|  |  |             rsMap.put("sMes","请求失败");
 | 
	
		
			
				|  |  |             return rsMap;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         rsMap.put("sCode","err");
 | 
	
		
			
				|  |  |         rsMap.put("sMes","请求失败");
 | 
	
		
			
				|  |  |         return rsMap;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 查询协同门诊记录
 | 
	
		
			
				|  |  |      * @param generalDoctor
 | 
	
		
			
				|  |  |      * @param startDate
 | 
	
		
			
				|  |  |      * @param endDate
 | 
	
		
			
				|  |  |      * @param status
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Envelop findByGeneralDoctor(String generalDoctor,String startDate,String endDate,String status,Integer page,Integer size){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String sqlTotal ="SELECT " +
 | 
	
		
			
				|  |  |                 " count(1) AS total "+
 | 
	
		
			
				|  |  |                 " FROM " +
 | 
	
		
			
				|  |  |                 " wlyy_outpatient o " +
 | 
	
		
			
				|  |  |                 " WHERE " +
 | 
	
		
			
				|  |  |                 " o.general_doctor = '"+generalDoctor+"'";
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(startDate)){
 | 
	
		
			
				|  |  |             sqlTotal += " AND o.register_date >='"+startDate+" 00:00:00' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(endDate)){
 | 
	
		
			
				|  |  |             sqlTotal += " AND o.register_date <='"+endDate+" 23:59:59' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(status)){
 | 
	
		
			
				|  |  |             sqlTotal += " AND o.status ='"+status+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sqlTotal);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         logger.info("findByGeneralDoctor:  "+sqlTotal);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Long total = 0l;
 | 
	
		
			
				|  |  |         if (rstotal != null && rstotal.size() > 0) {
 | 
	
		
			
				|  |  |             total = (Long) rstotal.get(0).get("total");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String sql ="SELECT " +
 | 
	
		
			
				|  |  |                 " o.id AS id, " +
 | 
	
		
			
				|  |  |                 " o.adm_no AS admNo, " +
 | 
	
		
			
				|  |  |                 " o.origin_adm_no AS originAdmNo, " +
 | 
	
		
			
				|  |  |                 " o.register_no AS registerNo, " +
 | 
	
		
			
				|  |  |                 " o.origin_register_no AS originRegisterNo, " +
 | 
	
		
			
				|  |  |                 " o.origin_con_no AS originConNo, " +
 | 
	
		
			
				|  |  |                 " o.con_no AS conNo, " +
 | 
	
		
			
				|  |  |                 " o.outpatient_type AS outpatientType, " +
 | 
	
		
			
				|  |  |                 " o.type AS type, " +
 | 
	
		
			
				|  |  |                 " o.hospital AS hospital, " +
 | 
	
		
			
				|  |  |                 " o.hospital_name AS hospitalName, " +
 | 
	
		
			
				|  |  |                 " o.win_no AS winNo, " +
 | 
	
		
			
				|  |  |                 " o.dept AS dept, " +
 | 
	
		
			
				|  |  |                 " o.dept_name AS deptName, " +
 | 
	
		
			
				|  |  |                 " o.patient AS patient, " +
 | 
	
		
			
				|  |  |                 " o.patient_name AS patientName, " +
 | 
	
		
			
				|  |  |                 " o.doctor AS doctor, " +
 | 
	
		
			
				|  |  |                 " o.doctor_name AS doctorName, " +
 | 
	
		
			
				|  |  |                 " o.general_doctor AS generalDoctor, " +
 | 
	
		
			
				|  |  |                 " o.general_doctor_name AS generalDoctorName, " +
 | 
	
		
			
				|  |  |                 " o.idcard AS idcard, " +
 | 
	
		
			
				|  |  |                 " o.card_no AS cardNo, " +
 | 
	
		
			
				|  |  |                 " o.mjz AS mjz, " +
 | 
	
		
			
				|  |  |                 " o.icd10 AS icd10, "+
 | 
	
		
			
				|  |  |                 " o.icd10_name AS icd10Name, " +
 | 
	
		
			
				|  |  |                 " o.advice AS advice, " +
 | 
	
		
			
				|  |  |                 " o.adm_date AS admDate, " +
 | 
	
		
			
				|  |  |                 " o.description AS description, " +
 | 
	
		
			
				|  |  |                 " o.disease_img AS diseaseImg, " +
 | 
	
		
			
				|  |  |                 " o.create_time AS createTime, " +
 | 
	
		
			
				|  |  |                 " o.con_date AS conDate, " +
 | 
	
		
			
				|  |  |                 " o.patient_cancel_type AS patientCancelType, " +
 | 
	
		
			
				|  |  |                 " o.patient_cancel_value AS patientCancelValue, " +
 | 
	
		
			
				|  |  |                 " o.patient_cancel_remark AS patientCancelRemark, " +
 | 
	
		
			
				|  |  |                 " o.register_date AS registerDate, " +
 | 
	
		
			
				|  |  |                 " o.`status` AS STATUS, " +
 | 
	
		
			
				|  |  |                 " o.evaluate_status AS evaluateStatus " +
 | 
	
		
			
				|  |  |                 " FROM " +
 | 
	
		
			
				|  |  |                 " wlyy_outpatient o " +
 | 
	
		
			
				|  |  |                 " WHERE " +
 | 
	
		
			
				|  |  |                 " o.general_doctor = '"+generalDoctor+"'";
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(startDate)){
 | 
	
		
			
				|  |  |             sql+=" AND o.register_date >='"+startDate+" 00:00:00'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(endDate)){
 | 
	
		
			
				|  |  |             sql+=" AND o.register_date <='"+endDate+" 23:59:59'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(status)){
 | 
	
		
			
				|  |  |             sql+=" AND o.status ='"+status+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         sql += " ORDER BY o.register_date ASC LIMIT " + (page - 1) * size + "," + size + "";
 | 
	
		
			
				|  |  |         logger.info("findByGeneralDoctor:  "+sql);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         //List<WlyyOutpatientDO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyyOutpatientDO.class));
 | 
	
		
			
				|  |  |         return MixEnvelop.getSuccessListWithPage(BaseHospitalRequestMapping.Prescription.api_success, list, page, size, total);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 全科医生首页协同门诊统计列表
 | 
	
		
			
				|  |  |      * @param generalDoctor
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Map<String,Object> findGeneralDoctorInfo(String generalDoctor){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Map<String,Object> rs = new HashedMap();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Calendar endTime = Calendar.getInstance();
 | 
	
		
			
				|  |  |         endTime.setTime(new Date());
 | 
	
		
			
				|  |  |         endTime.set(endTime.get(Calendar.YEAR),endTime.get(Calendar.MONTH),endTime.get(Calendar.DAY_OF_MONTH),23,59,59);
 | 
	
		
			
				|  |  |         //今天协同门诊列表
 | 
	
		
			
				|  |  |         List<WlyyOutpatientDO> todayList = outpatientDao.findByGeneralDoctor(generalDoctor,new Date(),endTime.getTime());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         rs.put("todayList",todayList);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Calendar tomorrowTime = Calendar.getInstance();
 | 
	
		
			
				|  |  |         tomorrowTime.setTime(new Date());
 | 
	
		
			
				|  |  |         tomorrowTime.add(Calendar.DAY_OF_MONTH,1);
 | 
	
		
			
				|  |  |         tomorrowTime.set(endTime.get(tomorrowTime.YEAR),endTime.get(tomorrowTime.MONTH),endTime.get(tomorrowTime.DAY_OF_MONTH),00,00,00);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         endTime.add(Calendar.DAY_OF_MONTH,1);
 | 
	
		
			
				|  |  |         //明天协同门诊列表
 | 
	
		
			
				|  |  |         List<WlyyOutpatientDO> tomorrowList = outpatientDao.findByGeneralDoctor(generalDoctor,tomorrowTime.getTime(),endTime.getTime());
 | 
	
		
			
				|  |  |         rs.put("tomorrowList",tomorrowList);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //统计科预约医生
 | 
	
		
			
				|  |  |         String sql = "SELECT " +
 | 
	
		
			
				|  |  |                 " COUNT(1) AS total " +
 | 
	
		
			
				|  |  |                 " FROM " +
 | 
	
		
			
				|  |  |                 " base_doctor d " +
 | 
	
		
			
				|  |  |                 " JOIN base_doctor_role r ON d.id = r.doctor_code " +
 | 
	
		
			
				|  |  |                 " WHERE " +
 | 
	
		
			
				|  |  |                 " r.role_code ='specialist'";
 | 
	
		
			
				|  |  |         List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Long doctorTotal = 0l;
 | 
	
		
			
				|  |  |         if (rstotal != null && rstotal.size() > 0) {
 | 
	
		
			
				|  |  |             doctorTotal = (Long) rstotal.get(0).get("total");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         rs.put("doctorTotal",doctorTotal);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //统计在线医生
 | 
	
		
			
				|  |  |         String onlineSql="SELECT " +
 | 
	
		
			
				|  |  |                 " COUNT(1) AS total " +
 | 
	
		
			
				|  |  |                 " FROM " +
 | 
	
		
			
				|  |  |                 " base_doctor d " +
 | 
	
		
			
				|  |  |                 " JOIN base_doctor_role r ON d.id = r.doctor_code " +
 | 
	
		
			
				|  |  |                 " WHERE " +
 | 
	
		
			
				|  |  |                 " r.role_code ='specialist' " +
 | 
	
		
			
				|  |  |                 " AND d.consult_status ='1'";
 | 
	
		
			
				|  |  |         List<Map<String, Object>> oltotal = jdbcTemplate.queryForList(onlineSql);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Long onlineTotal = 0l;
 | 
	
		
			
				|  |  |         if (oltotal != null && oltotal.size() > 0) {
 | 
	
		
			
				|  |  |             onlineTotal = (Long) oltotal.get(0).get("total");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         rs.put("onlineTotal",onlineTotal);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return rs;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |