| 
					
				 | 
			
			
				@ -39,14 +39,12 @@ import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.text.DecimalFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.text.ParseException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.text.SimpleDateFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.time.DayOfWeek; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.time.LocalDate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.time.ZoneId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.time.ZonedDateTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.time.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.time.format.DateTimeFormatter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.time.format.TextStyle; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.concurrent.CompletableFuture; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.concurrent.ExecutionException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.concurrent.ExecutorService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.concurrent.Executors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -7351,4 +7349,327 @@ public class StatisticsEsService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("todayFree", todayFree);//今日新增 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return resultMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取开通网络问诊的医生和科室数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public HashMap<String, Object> getNetworkDoctorAndDeptCount() throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String deptSql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	count( DISTINCT b.dept_code ) \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	base_doctor a\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	INNER JOIN base_doctor_hospital b ON a.id = b.doctor_code \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	1 = 1 \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	AND a.del='1' AND b.del='1'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	AND a.outpatient_type IS NOT NULL \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	AND a.outpatient_type <> '' \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	AND b.dept_code IS NOT NULL "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String doctorSql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	count( DISTINCT a.id ) \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	base_doctor a \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	1 = 1 \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	AND a.del = '1' \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	AND a.outpatient_type IS NOT NULL \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	AND a.outpatient_type <> ''"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        CompletableFuture<Integer> future01 = CompletableFuture.supplyAsync(() -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer integer = jdbcTemplate.queryForObject(deptSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return integer; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }, execute); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        CompletableFuture<Integer> future02 = CompletableFuture.supplyAsync(() -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer integer = jdbcTemplate.queryForObject(doctorSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return integer; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }, execute); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        CompletableFuture.allOf(future01, future02).get(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer deptCount = future01.get(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer doctorCount = future02.get(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HashMap<String, Object> resultMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("deptCount", deptCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("doctorCount", doctorCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return resultMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 查询患者行为动态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String, Object>> getPatientBehavior() throws ExecutionException, InterruptedException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql01 = "SELECT q.*,CONCAT('患者',q.patientName,'发起了',q.title)'description' FROM (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "		patient_name 'patientName',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "		CASE \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "			WHEN outpatient_type='1' THEN '在线复诊'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "			WHEN outpatient_type='2' THEN '协同门诊'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "			WHEN outpatient_type='3' AND type='1' THEN '图文咨询'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "			WHEN outpatient_type='3' AND type='2' THEN '视频咨询'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "		END 'title',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "		DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%S') 'createTime'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "		wlyy_outpatient \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	WHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "		1 = 1 \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "		AND pay_status IN ( '1', '2' )\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "		ORDER BY create_time DESC LIMIT 5\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ")q"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql02 = "SELECT q.*,CONCAT('患者',q.patientName,'购药成功了')'description' FROM (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	patient_name 'patientName',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  CASE \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	 WHEN `status`='30' THEN '购药成功'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	END 'title',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	DATE_FORMAT( create_time, '%Y-%m-%d %H:%i:%S' ) 'createTime' \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	wlyy_prescription \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	`status` = '30' ORDER BY create_time DESC LIMIT 5\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ")q"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql03 = "SELECT q.*,CONCAT('患者',q.patientName,'出院转',q.title,'诊后管理') 'description' FROM (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	`name` 'patientName',disease_name 'title',DATE_FORMAT( create_time, '%Y-%m-%d %H:%i:%S' ) 'createTime'  \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	wlyy_patient_rehabilitation_plan \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "ORDER BY\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	create_time DESC \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	LIMIT 5\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ")q"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        CompletableFuture<List<Map<String, Object>>> future01 = CompletableFuture.supplyAsync(() -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql01); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }, execute); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        CompletableFuture<List<Map<String, Object>>> future02 = CompletableFuture.supplyAsync(() -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql02); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }, execute); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        CompletableFuture<List<Map<String, Object>>> future03 = CompletableFuture.supplyAsync(() -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql03); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }, execute); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        CompletableFuture.allOf(future01, future02, future03).get(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> list01 = future01.get(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> list02 = future02.get(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> list03 = future03.get(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 合并列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> mergedList = new ArrayList<>(list01); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        mergedList.addAll(list02); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        mergedList.addAll(list03); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 按 createTime 排序 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        mergedList.sort((m1, m2) -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String c1 = (String) m1.get("createTime"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String c2 = (String) m2.get("createTime"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            LocalDateTime t1 = LocalDateTime.parse(c1, formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            LocalDateTime t2 = LocalDateTime.parse(c2, formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return t2.compareTo(t1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        System.out.println(mergedList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return mergedList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 查询医生服务动态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String, Object>> getDoctorBehavior() throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql01 = "SELECT q.*,CONCAT(q.deptName,q.doctorName,'医生接诊了',q.patientName,'患者')'description' FROM (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	doctor_name 'doctorName',dept_name 'deptName',patient_name 'patientName',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%S') 'createTime'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	wlyy_outpatient \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	1 = 1 \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	AND pay_status IN ( '1', '2' )\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	ORDER BY create_time DESC LIMIT 5\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ")q"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql02 = "SELECT q.*,CONCAT(q.deptName,q.doctorName,'医生为',q.patientName,'患者开具了处方')'description'  FROM (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	a.doctor_name 'doctorName',b.dept_name 'deptName',a.patient_name 'patientName',\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%i:%S' ) 'createTime' \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	wlyy_prescription a INNER JOIN base_doctor_hospital b ON a.doctor=b.doctor_code\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	a.`status` >= '30' ORDER BY a.create_time DESC LIMIT 10\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ")q"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        CompletableFuture<List<Map<String, Object>>> future01 = CompletableFuture.supplyAsync(() -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql01); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }, execute); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        CompletableFuture<List<Map<String, Object>>> future02 = CompletableFuture.supplyAsync(() -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql02); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }, execute); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        CompletableFuture.allOf(future01, future02).get(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> list01 = future01.get(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> list02 = future02.get(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 合并列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> mergedList = new ArrayList<>(list01); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        mergedList.addAll(list02); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 按 createTime 排序 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        mergedList.sort((m1, m2) -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String c1 = (String) m1.get("createTime"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String c2 = (String) m2.get("createTime"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            LocalDateTime t1 = LocalDateTime.parse(c1, formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            LocalDateTime t2 = LocalDateTime.parse(c2, formatter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return t2.compareTo(t1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        System.out.println(mergedList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return mergedList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 图文问诊、视频问诊:两种方式,医生书写病历时有填写诊断 根据这个诊断排行 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String, Object>> getReExaminationRanking() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	icd10,icd10_name,	count( 1 ) 'visitCount' \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	wlyy_outpatient \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE 1=1\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	AND pay_status IN ( '1', '2' ) \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	AND outpatient_type='3' AND type IN('1','2')\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	AND icd10_name IS NOT NULL \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "GROUP BY\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	icd10,icd10_name \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "ORDER BY\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	count(1) DESC\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "LIMIT 5"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String, Object>> getDeptAndDoctor(ScreenQvo qvo) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> list = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("1".equals(qvo.getType())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //查询所有科室 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String sql = "SELECT distinct dept_code 'deptCode',dept_name 'deptName' FROM base_doctor_hospital WHERE del='1'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(qvo.getDeptName())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " and dept_name like  '%" + qvo.getDeptName() + "%'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //根据科室或者名称查医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("2".equals(qvo.getType())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String sql = "SELECT distinct b.id 'doctorId',b.`name` 'doctorName' FROM base_doctor_hospital a \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "INNER JOIN base_doctor  b ON a.doctor_code=b.id \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "WHERE  1=1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(qvo.getDeptCode())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " and a.dept_code = '" + qvo.getDeptCode() + "' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(qvo.getDoctorName())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql += " and b.`name` LIKE '%" + qvo.getDoctorName() + "%'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 查询服务评价详情 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String, Object>> getDoctorSeverScopeDetail(ScreenQvo qvo) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String limitSql = "LIMIT " + (qvo.getPage() - 1) * qvo.getPageSize() + "," + qvo.getPageSize(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	b.dept_code 'deptCode',b.dept_name 'deptName',c.id 'doctorId',c.`name` 'doctorName', AVG(a.score) 'score' \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	base_evaluate_score a\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	INNER JOIN base_doctor_hospital b ON a.doctor = b.doctor_code \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	INNER JOIN base_doctor c ON b.doctor_code=c.id\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	1 = 1 \n"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(qvo.getStartDate()) && StringUtils.isNotBlank(qvo.getEndDate())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND a.create_time >='" + qvo.getStartDate() + "' AND a.create_time <='" + qvo.getEndDate() + " 23:59:59' \n"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(qvo.getDeptCode())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND b.dept_code='" + qvo.getDeptCode() + "' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(qvo.getDoctorName())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += "  AND c.`name` LIKE '%" + qvo.getDoctorName() + "%' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql += " GROUP BY b.dept_code,c.id "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(qvo.getPageSwitch()) && "1".equals(qvo.getPageSwitch())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += limitSql; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String, Object>> getDoctorFreeDetail(ScreenQvo qvo) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String limitSql = "LIMIT " + (qvo.getPage() - 1) * qvo.getPageSize() + "," + qvo.getPageSize(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT q.*,(q.drugFee+q.checkFree) 'totalFree' FROM (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	p.doctor,p.doctor_name 'doctorName',a.dept_code 'deptCode',a.dept_name 'deptName', COALESCE(ROUND(SUM(p.drug_fee),2), 0) AS drugFee ,0 'checkFree'\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	wlyy_prescription p\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	INNER JOIN wlyy_outpatient o ON p.outpatient_id = o.id \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	INNER JOIN base_doctor_hospital a ON p.doctor=a.doctor_code\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	1 = 1 \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	AND p.STATUS >= 30\n"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(qvo.getStartDate()) && StringUtils.isNotBlank(qvo.getEndDate())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += "	AND p.create_time>='" + qvo.getStartDate() + "' AND a.create_time<='" + qvo.getEndDate() + " 23:59:59'\n"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(qvo.getDeptCode())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND a.dept_code='" + qvo.getDeptCode() + "' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(qvo.getDoctorName())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += "  AND p.doctor_name LIKE '%" + qvo.getDoctorName() + "%' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql += " GROUP BY a.dept_code,a.doctor_code\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "UNION ALL	\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "SELECT\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	o.doctor,o.doctor_name 'doctorName',a.dept_code'deptCode', a.dept_name 'deptName',0 'drugFee',COALESCE(ROUND(SUM(bop.pay_price),2), 0)  AS checkFree \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "FROM\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	wlyy_outpatient o\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	INNER JOIN base_business_order_pay bop ON o.id = bop.relation_code \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	INNER JOIN base_doctor_hospital a ON o.doctor=a.doctor_code\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "WHERE\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	o.pay_status = 1 \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "	AND o.`status` IN ( 1, 2, 3 )\n"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(qvo.getStartDate()) && StringUtils.isNotBlank(qvo.getEndDate())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += "	AND o.create_time>='" + qvo.getStartDate() + "' AND o.create_time<='" + qvo.getEndDate() + " 23:59:59'\n"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(qvo.getDeptCode())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND a.dept_code='" + qvo.getDeptCode() + "' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(qvo.getDoctorName())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += "  AND o.doctor_name LIKE '%" + qvo.getDoctorName() + "%' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql += "	GROUP BY a.dept_code,a.doctor_code\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ")q WHERE 1=1 \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "GROUP BY q.deptCode,q.doctorName ORDER BY (q.drugFee+q.checkFree) DESC \n"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(qvo.getPageSwitch()) && "1".equals(qvo.getPageSwitch())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += limitSql; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |