|  | @ -77,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
 | 
	
	
		
			
				|  | @ -536,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);
 | 
	
	
		
			
				|  | @ -573,7 +573,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         prescriptionExpressageDao.save(expressageDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //3.创建候诊室
 | 
	
		
			
				|  |  |         createRoom(outpatient);
 | 
	
		
			
				|  |  |         createRoom(outpatient,chargeType);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return outpatient;
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -584,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();
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -614,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;
 | 
	
	
		
			
				|  | @ -2853,12 +2858,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);
 | 
	
	
		
			
				|  | @ -2888,7 +2893,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //3.创建候诊室
 | 
	
		
			
				|  |  |         createRoom(outpatient);
 | 
	
		
			
				|  |  |         createRoom(outpatient,chargeType);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return outpatient;
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -2920,10 +2925,13 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             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)){
 | 
	
		
			
				|  |  |                 com.alibaba.fastjson.JSONObject biz = json.getJSONObject("biz_content");
 | 
	
		
			
				|  |  |                 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");
 | 
	
	
		
			
				|  | @ -2983,4 +2991,161 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         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;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |