| 
					
				 | 
			
			
				@ -427,28 +427,41 @@ public class RehabilitationInfoService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject noDownCount(String doctorCode, JSONObject object) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //未下转所有 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String notTurnedDownCountSql = "select count(*) from wlyy_patient_discharge d,wlyy_patient p where d.create_user ='" + doctorCode + "' and ( ISNULL(d.type) or d.type=2) AND p. CODE = d.patient AND d.patient NOT IN (   \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "SELECT i.patient FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i,wlyy_patient p WHERE i.create_user = '" + doctorCode + "' AND i. STATUS != 0 AND p. CODE = i.patient GROUP BY i.patient ORDER BY i.create_time desc)\n"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer allCount = jdbcTemplate.queryForObject(notTurnedDownCountSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String notTurnedDownCountSql = "select count(*) \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "from wlyy_rehabilitation_patient_info d INNER JOIN base_patient p ON p.id = d.patient \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  where d.create_user ='" + doctorCode + "' and ( ISNULL(d.type) or d.type=2)  AND d.patient NOT IN (   \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "		SELECT i.patient FROM wlyy_patient_rehabilitation_plan i,base_patient p \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "		WHERE i.create_user = '" + doctorCode + "' AND i. STATUS != 0 AND p.id = i.patient ) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //未家签 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String notSignedAtHomeSql = "SELECT count(*) FROM (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "select '' id, p.idcard,p.code,p.NAME patientName,p.sex,NULL age,p.address  from wlyy_patient_discharge d,wlyy_patient p\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "where d.create_user ='" + doctorCode + "' and ( ISNULL(d.type) or d.type=2) AND p. CODE = d.patient AND d.patient NOT IN (SELECT patient FROM wlyy_sign_family WHERE sign_year='" + DateUtil.getSignYear() + "' AND `status`=1) AND d.patient NOT IN \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "(   SELECT i.patient FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i,wlyy_patient p   WHERE i.create_user = '" + doctorCode + "' \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "AND i. STATUS != 0 AND p. CODE = i.patient GROUP BY i.patient ORDER BY i.create_time desc)GROUP BY d.patient ORDER BY d.create_time DESC\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ")aa\n"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer notSignedAtHome = jdbcTemplate.queryForObject(notSignedAtHomeSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "select '' id, p.idcard,p.id 'patientId',p.`name` patientName,p.sex,NULL age,p.address  \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " from wlyy_rehabilitation_patient_info d INNER JOIN base_patient p ON  p.id = d.patient\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " where d.create_user ='" + doctorCode + "' and ( ISNULL(d.type) or d.type=2) AND d.sign_status='0' \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND d.patient NOT IN ( \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	SELECT i.patient FROM wlyy_patient_rehabilitation_plan i INNER JOIN base_patient p  ON p.id = i.patient \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	WHERE i.create_user = '" + doctorCode + "' AND i. STATUS != 0 \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	GROUP BY i.patient \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  )GROUP BY d.patient \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ")aa"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String notSignedAtHome1Sql = "SELECT count(*) FROM (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "select '' id, p.idcard,p.code,p.NAME patientName,p.sex,NULL age,p.address,f.status signStatus,f.czrq  from wlyy_patient_discharge d,wlyy_patient p,wlyy_sign_family f\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "where d.create_user = '" + doctorCode + "' and ( ISNULL(d.type) or d.type=2) AND p. CODE = d.patient AND d.patient=f.patient AND f.`status`=1 AND f.sign_year='" + DateUtil.getSignYear() + "' AND d.patient NOT IN \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "(   SELECT i.patient FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i,wlyy_patient p   WHERE i.create_user = '" + doctorCode + "' \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "AND i. STATUS != 0 AND p. CODE = i.patient GROUP BY i.patient ORDER BY i.create_time desc)GROUP BY d.patient ORDER BY d.create_time DESC\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ")aa\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE aa.signStatus = 1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	select '' id, p.idcard,p.id 'patientId',p.`name` patientName,p.sex,NULL age,p.address\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	from wlyy_rehabilitation_patient_info d \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	INNER JOIN base_patient p ON  p.id= d.patient \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	where d.create_user = '" + doctorCode + "' and ( ISNULL(d.type) or d.type=2)  AND d.sign_status='1'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	AND d.patient NOT IN (  \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  	SELECT DISTINCT i.patient FROM wlyy_patient_rehabilitation_plan i,base_patient p   \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	  WHERE i.create_user = '" + doctorCode + "'  AND i. STATUS != 0 AND p.id = i.patient  \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	)\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	GROUP BY d.patient\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ")aa"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer allCount = jdbcTemplate.queryForObject(notTurnedDownCountSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer notSignedAtHome = jdbcTemplate.queryForObject(notSignedAtHomeSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer notSignedAtHome1 = jdbcTemplate.queryForObject(notSignedAtHome1Sql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        object.put("allCount", allCount);//全部 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        object.put("notTurnedDownCount", notSignedAtHome1);// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        object.put("notTurnedDownCount", notSignedAtHome1);//签约的 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        object.put("notSignedAtHome", notSignedAtHome);//未家签 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return object; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -457,16 +470,28 @@ public class RehabilitationInfoService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 未下转已家签 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject noDownAndSign(String idcard, String doctorCode, Integer page, Integer pagesize, JSONObject object) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String aa = " d.create_user ='" + doctorCode + "'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String filterSql = " and  d.create_user ='" + doctorCode + "'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(idcard)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            aa += " and  p.idcard like '%" + idcard + "%' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            filterSql += " and  p.idcard like '%" + idcard + "%' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "select '' id, p.idcard,p.code patient,p.NAME patientName,p.sex,NULL age,p.address,f.status signStatus," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "f.czrq,f.doctor_name doctorName,f.doctor_health_name doctorHealthName,f.hospital_name hospitalName,f.admin_team_code teamCode " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " from wlyy_patient_discharge d,wlyy_patient p,wlyy_sign_family f\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "where " + aa + " and ( ISNULL(d.type) or d.type=2) AND p. CODE = d.patient AND d.patient=f.patient AND f.`status`=1 AND f.sign_year='" + DateUtil.getSignYear() + "' AND d.patient NOT IN \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "(   SELECT i.patient FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i,wlyy_patient p   WHERE i.create_user = '" + doctorCode + "' \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "AND i. STATUS != 0 AND p. CODE = i.patient GROUP BY i.patient ORDER BY i.create_time desc)GROUP BY d.patient ORDER BY d.create_time DESC "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        String sql = "select '' id, p.idcard,p.code patient,p.NAME patientName,p.sex,NULL age,p.address,f.status signStatus," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "f.czrq,f.doctor_name doctorName,f.doctor_health_name doctorHealthName,f.hospital_name hospitalName,f.admin_team_code teamCode " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                " from wlyy_patient_discharge d,wlyy_patient p,wlyy_sign_family f\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "where 1=1 " + filterSql + " and ( ISNULL(d.type) or d.type=2) AND p. CODE = d.patient AND d.patient=f.patient AND f.`status`=1 AND f.sign_year='" + DateUtil.getSignYear() + "' AND d.patient NOT IN \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "(   SELECT i.patient FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i,wlyy_patient p   WHERE i.create_user = '" + doctorCode + "' \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "AND i. STATUS != 0 AND p. CODE = i.patient GROUP BY i.patient ORDER BY i.create_time desc)GROUP BY d.patient ORDER BY d.create_time DESC "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT  \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.idcard,p.id patient,p.`name` 'patientName',p.sex,NULL age,p.address,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " d.`dept`,d.`dept_name`\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM wlyy_rehabilitation_patient_info d INNER JOIN base_patient p ON  p.id = d.patient \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE  1=1 \n" + filterSql + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND ( ISNULL(d.type) or d.type=2)  AND d.sign_status='1' \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND d.patient NOT IN (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "		SELECT DISTINCT i.patient FROM wlyy_patient_rehabilitation_plan i,base_patient p  \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "		WHERE i.create_user = '" + doctorCode + "' AND i. STATUS != 0 AND p.id = i.patient\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ")\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "GROUP BY d.patient ORDER BY d.create_time DESC "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql += " LIMIT " + (page - 1) * pagesize + "," + pagesize; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -488,18 +513,29 @@ public class RehabilitationInfoService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject noDown(String idcard, String doctorCode, Integer page, Integer pagesize, JSONObject object) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String aa = " d.create_user ='" + doctorCode + "'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String filterSql = " and  d.create_user ='" + doctorCode + "'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(idcard)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            aa += " and  p.idcard like '%" + idcard + "%' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "select '' id, p.idcard,p.code patient,p.NAME patientName,p.sex,NULL age,p.address,f.status signStatus," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "f.czrq,f.doctor_name doctorName,f.doctor_health_name doctorHealthName,f.hospital_name hospitalName,f.admin_team_code teamCode," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " if(f.id is null,-2,-1) as isTurnDown " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " from wlyy_patient p,wlyy_patient_discharge d " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " left JOIN wlyy_sign_family f on d.patient=f.patient AND f.`status`=1 AND f.sign_year='" + DateUtil.getSignYear() + "'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "where " + aa + " and ( ISNULL(d.type) or d.type=2) AND p. CODE = d.patient  AND d.patient NOT IN \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "(   SELECT DISTINCT i.patient FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i,wlyy_patient p   WHERE i.create_user = '" + doctorCode + "' \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "AND i. STATUS != 0 AND p. CODE = i.patient )GROUP BY d.patient ORDER BY d.create_time DESC "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            filterSql += " and  p.idcard like '%" + idcard + "%' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        String sql = "select '' id, p.idcard,p.code patient,p.NAME patientName,p.sex,NULL age,p.address," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "f.status signStatus,f.czrq,f.doctor_name doctorName,f.doctor_health_name doctorHealthName,f.hospital_name hospitalName,f.admin_team_code teamCode," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                " if(f.id is null,-2,-1) as isTurnDown " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                " from wlyy_patient p,wlyy_patient_discharge d " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                " left JOIN wlyy_sign_family f on d.patient=f.patient AND f.`status`=1 AND f.sign_year='" + DateUtil.getSignYear() + "'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "where 1=1 " + filterSql + " and ( ISNULL(d.type) or d.type=2) AND p. CODE = d.patient  AND d.patient NOT IN \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "(   SELECT DISTINCT i.patient FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i,wlyy_patient p   WHERE i.create_user = '" + doctorCode + "' \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "AND i. STATUS != 0 AND p. CODE = i.patient )GROUP BY d.patient ORDER BY d.create_time DESC "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT '' id, p.idcard,p.id 'patient',p.`name` patientName,p.sex,NULL age,p.address,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " if(p.sign_status=0,-2,-1) as isTurnDown  \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM base_patient p \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " INNER JOIN wlyy_rehabilitation_patient_info d  ON p.id = d.patient and d.sign_status='1'  \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE 1=1  " + filterSql + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	 and d.create_user ='" + doctorCode + "'  AND ( ISNULL(d.type) or d.type=2) AND  d.patient NOT IN( \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	 SELECT DISTINCT i.patient FROM wlyy_patient_rehabilitation_plan i,base_patient p   \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	 WHERE i.create_user = '" + doctorCode + "' AND i.`status` != 0 AND p.id = i.patient \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	)\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "GROUP BY d.patient ORDER BY d.create_time DESC "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql += " LIMIT " + (page - 1) * pagesize + "," + pagesize; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        list.stream().forEach(one -> { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -515,15 +551,31 @@ public class RehabilitationInfoService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 已下转未接收 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject downAndNoSign(String idcard, String doctorCode, Integer page, Integer pagesize, JSONObject object) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql2 = "SELECT i.disease_name diseaseName,s.doctor,s.idcard,p.sex, s.patient,CAST(IFNULL(p.birthday,'') AS char ) birthday," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i. STATUS, p. NAME patientName, p.address, CONCAT(s.doctor_name,'(全科医生)' ) AS doctorName, \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "IFNULL(CONCAT(s.doctor_health_name,'(健管师)'), s.doctor_health_name ) doctorHealthName, s.hospital_name hospitalName, \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "s.admin_team_code teamCode ,pr.is_manage isManage \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "wlyy_specialist.wlyy_specialist_patient_relation pr \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE i.create_user = '" + doctorCode + "' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient AND s.status = 1 \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "AND s.expenses_status = 1 AND pr.patient=p.code and pr.team_code = i.team_code and pr.`status`>=0 and pr.sign_status=1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " and  (pr.is_manage != 1 OR isnull(pr.is_manage)) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        String sql2 = "SELECT i.disease_name diseaseName,s.doctor,s.idcard,p.sex, s.patient,CAST(IFNULL(p.birthday,'') AS char ) birthday," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                " i. STATUS, p. NAME patientName, p.address, CONCAT(s.doctor_name,'(全科医生)' ) AS doctorName, \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "IFNULL(CONCAT(s.doctor_health_name,'(健管师)'), s.doctor_health_name ) doctorHealthName, s.hospital_name hospitalName, \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "s.admin_team_code teamCode ,pr.is_manage isManage \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "wlyy_specialist.wlyy_specialist_patient_relation pr \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "WHERE i.create_user = '" + doctorCode + "' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient AND s.status = 1 \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "AND s.expenses_status = 1 AND pr.patient=p.code and pr.team_code = i.team_code and pr.`status`>=0 and pr.sign_status=1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                " and  (pr.is_manage != 1 OR isnull(pr.is_manage)) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql2 = "SELECT \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.disease_name diseaseName,i.create_user,p.idcard,p.sex,p.id 'patient',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.`status`, p.`name` 'patientName', p.address, \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " CAST(IFNULL(p.birthday,'') AS char ) birthday,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " pr.is_manage isManage \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM wlyy_patient_rehabilitation_plan i \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "INNER JOIN wlyy_rehabilitation_patient_info q ON q.patient=i.id AND q.sign_status='1' AND i.patient_info_code=q.`code` \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "INNER JOIN base_patient p ON  p.id = i.patient\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "INNER JOIN  wlyy_specialist_patient_relation pr ON  pr.patient=p.id\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE i.create_user = '" + doctorCode + "' AND i.status != 0 \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	 and pr.`status`>=0 and pr.sign_status=1  \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	AND  (pr.is_manage != 1 OR isnull(pr.is_manage))  \n"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(idcard)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql2 += " and  p.idcard like '%" + idcard + "%' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -555,32 +607,45 @@ public class RehabilitationInfoService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 已经下转统计 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject downCount(String doctorCode, JSONObject object) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql1 = "SELECT COUNT(distinct i.patient) \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "wlyy_specialist.wlyy_specialist_patient_relation pr \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE i.create_user = '" + doctorCode + "' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient AND s.status = 1 \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "AND s.expenses_status = 1 AND pr.patient=p.code and pr.team_code = i.team_code and pr.`status`>=0 and pr.sign_status=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        String sql1 = "SELECT COUNT(distinct i.patient) \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "wlyy_specialist.wlyy_specialist_patient_relation pr \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "WHERE i.create_user = '" + doctorCode + "' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient AND s.status = 1 \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "AND s.expenses_status = 1 AND pr.patient=p.code and pr.team_code = i.team_code and pr.`status`>=0 and pr.sign_status=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql1 = "SELECT \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(distinct i.patient) \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM wlyy_patient_rehabilitation_plan i \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "INNER JOIN  base_patient p ON  p.id = i.patient  \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "INNER JOIN wlyy_rehabilitation_patient_info q ON q.patient=i.id  AND i.patient_info_code=q.`code`  AND q.sign_status='1'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "INNER JOIN wlyy_specialist_patient_relation pr ON  pr.patient=p.id\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE i.create_user = '" + doctorCode + "' AND i.status != 0   and pr.`status`>=0 and pr.sign_status=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer list1 = jdbcTemplate.queryForObject(sql1, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //康复计划数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        String sql2 = "SELECT COUNT(distinct i.id) \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "WHERE i.create_user = '" + doctorCode + "' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                "AND s.status = 1 AND s.expenses_status = 1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql2 = "SELECT COUNT(distinct i.id) \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE i.create_user = '" + doctorCode + "' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "AND s.status = 1 AND s.expenses_status = 1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM wlyy_patient_rehabilitation_plan i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " inner join  base_patient p on  p.id = i.patient \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " inner join  wlyy_rehabilitation_patient_info q on  q.patient = i.patient AND i.patient_info_code=q.`code` AND q.sign_status='1' \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE i.create_user = '" + doctorCode + "' AND i.status != 0    \n"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer list2 = jdbcTemplate.queryForObject(sql2, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //家医接收 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql3 = "SELECT COUNT(distinct i.patient) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_specialist.wlyy_specialist_patient_relation pr \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE i.create_user = '" + doctorCode + "' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient AND s.status = 1 \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND s.expenses_status = 1 AND pr.patient=p.code and pr.team_code = i.team_code and pr.`status`>=0 and pr.sign_status=1 and pr.is_manage=1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer list3 = jdbcTemplate.queryForObject(sql3, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        String sql3 = "SELECT COUNT(distinct i.patient) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                " FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                " wlyy_specialist.wlyy_specialist_patient_relation pr \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                " WHERE i.create_user = '" + doctorCode + "' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient AND s.status = 1 \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                " AND s.expenses_status = 1 AND pr.patient=p.code and pr.team_code = i.team_code and pr.`status`>=0 and pr.sign_status=1 and pr.is_manage=1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        Integer list3 = jdbcTemplate.queryForObject(sql3, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        object.put("deorsumvergenceCount", list1);//下转人数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        object.put("rehabilitationPlan", list2);//康复计划 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        object.put("patientReceiveCount", list3);//家医接收人数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        object.put("unPatientReceiveCount", list1 - list3);//家医未接收人数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        object.put("patientReceiveCount", list3);//家医接收人数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        object.put("unPatientReceiveCount", list1 - list3);//家医未接收人数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return object; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 |