| 
					
				 | 
			
			
				@ -3,24 +3,27 @@ package com.yihu.wlyy.service.app.scheme; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSON; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.sun.media.jfxmedia.track.Track; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.device.entity.DevicePatientHealthIndex; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.doctor.DoctorSwitch; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodPressure; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodSugger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.doctor.scheme.vo.DoctorSchemeBloodPressureVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.doctor.scheme.vo.DoctorSchemeBloodSuggerVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.patient.Patient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.patient.PatientSchemeList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.patient.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.patient.vo.PatientVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.repository.doctor.DoctoreSchemeBloodPressureDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.repository.doctor.DoctrorSchemeBloodSuggerDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.repository.doctor.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.repository.patient.PatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.repository.patient.TrackPatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.repository.patient.scheme.PatientSchemeListDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.util.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.collections.map.HashedMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.BeanPropertyRowMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.JdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.orm.jpa.JpaTransactionManager; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -62,6 +65,21 @@ public class DoctorSchemeService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DevicePatientHealthIndexDao devicePatientHealthIndexDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PatientAimBloodSuggerDao patientAimBloodSuggerDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PatientAimBloodPressureDao patientAimBloodPressureDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DoctorSwitchDao doctorSwitchDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private TrackPatientDao trackPatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Value("${im.data_base_name}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private String im_dataBase_name; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 根据团队CODE/居民标签/病情/设备绑定状态查询团队具名CODE列表 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -532,7 +550,13 @@ public class DoctorSchemeService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            result.add(sugar_unusual_count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //1.4.2 重点关注居民 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<TrackPatient> list = trackPatientDao.findByDoctorCodeAndTeamcode(doctorcode,Integer.parseInt(teamCode)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(list!=null&&list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("trackPatientCount",list.size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("trackPatientCount",0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -554,4 +578,639 @@ public class DoctorSchemeService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            doctoreSchemeBloodPressureDao.updateDelStatus(1,doctorcode,schemecode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String,Object> getPatientHealthIndex(String patient,String startDate,String endDate,String type){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        startDate = startDate+" 00:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        endDate = endDate+" 23:59:59"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String highSql ="SELECT  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " (bf.befHighCount + aft.aftHighCount) AS highCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(1) AS befHighCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " device.wlyy_patient_health_index i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.type = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value2 in(1,3,5,7) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 > 6.1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date >='"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date <='"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.user ='"+patient+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ) bf, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " (  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(1) AS aftHighCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " device.wlyy_patient_health_index i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.type = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value2 in(2,4,6) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 > 7.8 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date >='"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date <='"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.user ='"+patient+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ) aft"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String stdSql ="SELECT  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " (bf.befHighCount + aft.aftHighCount) AS stdCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(1) AS befHighCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " device.wlyy_patient_health_index i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.type = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value2 in(1,3,5,7) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 <= 6.1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 >= 3.9 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date >='"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date <='"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.user ='"+patient+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ) bf, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " (  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(1) AS aftHighCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " device.wlyy_patient_health_index i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.type = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value2 in(2,4,6) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 <= 7.8 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 >= 4.4 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date >='"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date <='"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.user ='"+patient+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ) aft"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String lowSql ="SELECT  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " (bf.befHighCount + aft.aftHighCount) AS lowCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(1) AS befHighCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " device.wlyy_patient_health_index i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.type = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value2 in(1,3,5,7) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 <= 3.9 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date >='"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date <='"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.user ='"+patient+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ) bf, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " (  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(1) AS aftHighCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " device.wlyy_patient_health_index i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.type = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value2 in(2,4,6) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 <= 4.4 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date >='"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date <='"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.user ='"+patient+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ) aft"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String pHighSql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " count(1) AS highCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " device.wlyy_patient_health_index i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.type = '2' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 >= 139 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date >='"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date <='"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.user ='"+patient+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String  pStdSql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " count(1) AS stdCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " device.wlyy_patient_health_index i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.type = '2' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 <= 139 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 >= 90 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date >='"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date <='"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.user ='"+patient+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String pLowSql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " count(1) AS lowCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " device.wlyy_patient_health_index i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.type = '2' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 <= 90 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date >='"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date <='"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.user ='"+patient+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> rs = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //0血檀 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("0".equals(type)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //1.高 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> high = jdbcTemplate.queryForList(highSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(high!=null&&high.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> h = high.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                rs.put("highCount",h.get("highCount")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //2.正常 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> std = jdbcTemplate.queryForList(pStdSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(std!=null&&std.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> st = std.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                rs.put("stdCount",st.get("stdCount")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //3.偏低 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> low = jdbcTemplate.queryForList(pLowSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(low!=null&&low.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> lw = low.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                rs.put("lowCount",lw.get("lowCount")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //其他血压 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //1.高 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> high = jdbcTemplate.queryForList(pHighSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(high!=null&&high.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> h = high.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                rs.put("highCount",h.get("highCount")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //2.正常 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> std = jdbcTemplate.queryForList(stdSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(std!=null&&std.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> st = std.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                rs.put("stdCount",st.get("stdCount")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //3.偏低 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> low = jdbcTemplate.queryForList(lowSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(low!=null&&low.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> lw = low.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                rs.put("lowCount",lw.get("lowCount")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return rs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String,Object> getPatientHealthIndex(String startDate,String endDate,String type,Long teamCode,String doctor){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        startDate = startDate+" 00:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        endDate = endDate+" 23:59:59"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String highSql ="SELECT  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " (bf.befHighCount + aft.aftHighCount) AS highCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(1) AS befHighCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " device.wlyy_patient_health_index i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.type = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value2 in(1,3,5,7) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 > 6.1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date >='"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date <='"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ) bf, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " (  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(1) AS aftHighCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " device.wlyy_patient_health_index i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.type = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value2 in(2,4,6) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 > 7.8 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date >='"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date <='"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ) aft"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String stdSql ="SELECT  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " (bf.befHighCount + aft.aftHighCount) AS stdCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(1) AS befHighCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " device.wlyy_patient_health_index i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.type = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value2 in(1,3,5,7) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 <= 6.1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 >= 3.9 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date >='"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date <='"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ) bf, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " (  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(1) AS aftHighCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " device.wlyy_patient_health_index i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.type = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value2 in(2,4,6) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 <= 7.8 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 >= 4.4 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date >='"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date <='"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ) aft"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String lowSql ="SELECT  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " (bf.befHighCount + aft.aftHighCount) AS lowCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(1) AS befHighCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " device.wlyy_patient_health_index i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.type = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value2 in(1,3,5,7) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 <= 3.9 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date >='"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date <='"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ) bf, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " (  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(1) AS aftHighCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " device.wlyy_patient_health_index i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.type = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value2 in(2,4,6) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 <= 4.4 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date >='"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date <='"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ) aft"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String pHighSql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " count(1) AS highCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " device.wlyy_patient_health_index i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.type = '2' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 >= 139 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date >='"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date <='"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String  pStdSql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " count(1) AS stdCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " device.wlyy_patient_health_index i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.type = '2' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 <= 139 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 >= 90 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date >='"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date <='"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String pLowSql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " count(1) AS lowCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " device.wlyy_patient_health_index i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.type = '2' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.value1 <= 90 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date >='"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date <='"+endDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +teamCode+")"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> rs = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //0血檀 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("0".equals(type)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //1.高 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> high = jdbcTemplate.queryForList(highSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(high!=null&&high.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> h = high.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                rs.put("highCount",h.get("highCount")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //2.正常 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> std = jdbcTemplate.queryForList(pStdSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(std!=null&&std.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> st = std.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                rs.put("stdCount",st.get("stdCount")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //3.偏低 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> low = jdbcTemplate.queryForList(pLowSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(low!=null&&low.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> lw = low.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                rs.put("lowCount",lw.get("lowCount")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //其他血压 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //1.高 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> high = jdbcTemplate.queryForList(pHighSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(high!=null&&high.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> h = high.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                rs.put("highCount",h.get("highCount")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //2.正常 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> std = jdbcTemplate.queryForList(stdSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(std!=null&&std.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> st = std.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                rs.put("stdCount",st.get("stdCount")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //3.偏低 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String,Object>> low = jdbcTemplate.queryForList(lowSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(low!=null&&low.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> lw = low.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                rs.put("lowCount",lw.get("lowCount")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return rs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String,Object> getTrackPatientInfo(String patient){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> rs = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("wxSport",0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String hsql = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.value1 AS weight, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.value2 AS height, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.value3 AS BMI " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " device.wlyy_patient_health_index i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.type = '3'  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.user ='"+patient+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ORDER BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.record_date DESC LIMIT 1,1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String xtSchSql="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " l.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_patient_scheme_list l " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " l.type = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND l.patientcode = '"+patient+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String xySchSql="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " l.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_patient_scheme_list l " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " l.type = 2 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND l.patientcode = '"+patient+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> hList = jdbcTemplate.queryForList(hsql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(hList!=null&&hList.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String,Object> body = hList.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            rs.put("body",body); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            rs.put("body",null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> xtList = jdbcTemplate.queryForList(xtSchSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(xtList!=null&&xtList.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            rs.put("sugger","1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            rs.put("sugger","0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> xyList = jdbcTemplate.queryForList(xySchSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(xyList!=null&&xyList.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            rs.put("pressure","1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            rs.put("pressure","0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return  rs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String,Object> getControlObjectives(String patient){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> rs = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PatientAimBloodSugger patientAimBloodSugger =  patientAimBloodSuggerDao.findByPatientcode(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PatientAimBloodPressure patientAimBloodPressure = patientAimBloodPressureDao.findByPatientcode(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("patientAimBloodSugger",patientAimBloodSugger); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("patientAimBloodPressure",patientAimBloodPressure); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return rs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String,Object>> getBodyInfo(String patient,String startDate,String endDate,Integer page,Integer size){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        startDate = startDate+" 00:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        endDate = endDate + " 23:59:59"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.record_date, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.value1 AS weight, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.value2 AS height, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.value3 AS BMI " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " device.wlyy_patient_health_index i " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.del = '1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.type = 3 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.`user` = '"+patient+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date >='"+startDate+"'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND i.record_date <='"+endDate+"'"+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ORDER BY " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.record_date DESC LIMIT "+(page-1)*size+","+size; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return rs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String setDoctorSwitchTrackPatient(String doctor,String state){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        DoctorSwitch doctorSwitch =doctorSwitchDao.findByDoctor(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(doctorSwitch!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            doctorSwitch.setAlertPatientSwitch(state); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            DoctorSwitch dw = new DoctorSwitch(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            dw.setDoctor(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            dw.setAlertPatientSwitch(state); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            dw.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            doctorSwitchDao.save(dw); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return "0"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String,Object> getDoctorSwitchTrackPatient(String doctor){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        DoctorSwitch doctorSwitch = doctorSwitchDao.findByDoctor(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> rs = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("alertPatientSwitch",doctorSwitch.getAlertPatientSwitch()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return rs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String,Object> getTrackPatientCountTitle(Integer teamCode,String doctor,String startDate,String endDate){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<TrackPatient> trackPatients = trackPatientDao.findByDoctorCodeAndTeamcode(doctor,teamCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> rs = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("trackPatientCount",trackPatients.size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(1) AS total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_track_patient t " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.doctor_code = '"+doctor+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.team_code = '"+teamCode+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.create_time >= '"+startDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.create_time <= '"+endDate+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(list!=null&&list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Long total = (Long)list.get(0).get("total"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            rs.put("trackPatientAddCount",total); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            rs.put("trackPatientAddCount",0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return rs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public  Map<String,Object> getTrackPatientServerCount(Long teamCode,String patient,String doctor,String startDate,String endDate){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        startDate = startDate + " 00:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        endDate = endDate + " 23:59:59"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> rs = new  HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //咨询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("consultCount",getConsultByteam(teamCode,doctor,startDate,endDate)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //随访 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("followupCount",getFollowByTeam(teamCode,doctor,startDate,endDate)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //获取健康指导 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("guidanceCount",getGuidanceByTeam(teamCode,doctor,startDate,endDate)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //获取待预约 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("reservationCount",getReservationByteam(teamCode,doctor,startDate,endDate)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //续方审核 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rs.put("reviewedCount",getPresCount(teamCode,doctor,startDate,endDate)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return rs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取咨询数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param startDate 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param endDate 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Long getConsultByteam(Long id, String doctor,String startDate, String endDate) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String imDataBaseName = im_dataBase_name; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //咨询量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String consult_sql = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  COUNT(1) consultCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_admin_team_member m JOIN(" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT d.id,t.create_time FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  " + imDataBaseName + ".Topics t, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  " + imDataBaseName + ".Participants p, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  " + imDataBaseName + ".Doctors d, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  Wlyy_Consult_Team c, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  " + imDataBaseName + ".Patients s " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  d.id = p.participant_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND c.type <> 8  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND c.consult = t.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND c.patient = s.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND p.session_id = t.session_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND c.admin_team_code =" + id + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.create_time >= '" + startDate + "' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.create_time <= '" + endDate + "'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND c.patient IN(" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  SELECT t.patient_code FROM wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +id+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " )" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " )c ON c.id = m.doctor_code " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " m.team_id = "  + id+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " m.doctor_code ='"+doctor+"'" ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //获取咨詢數 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, Object> consultCout = jdbcTemplate.queryForMap(consult_sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (consultCout.get("consultCount") == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            consultCout.put("consultCount", 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return (Long)consultCout.get("consultCount"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Long getReservationByteam(Long id,String doctor, String startDate, String endDate) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //获取待预约 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String reservation_sql = "SELECT COUNT(1) AS reservationCount FROM wlyy_patient_reservation  w WHERE w.admin_team_code =" + id + " AND w.czrq <='" + endDate + "' AND w.czrq >='" + startDate + "' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //获取待预约 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, Object> reservationCout = jdbcTemplate.queryForMap(reservation_sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (reservationCout.get("reservationCount") == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            reservationCout.put("reservationCount", 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return (Long)reservationCout.get("reservationCount"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Long getEduArticleByTeam(Long id,String doctor, String startDate, String endDate) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //获取健康教育 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String article_sql = "SELECT COUNT(1) AS articleCount FROM wlyy_health_edu_article_patient w WHERE  w.admin_team_code =" + id + " AND w.czrq <='" + endDate + "' AND w.czrq >='" + startDate + "'" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //获取健康教育 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, Object> articleCout = jdbcTemplate.queryForMap(article_sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (articleCout.get("articleCount") == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            articleCout.put("articleCount", 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return (Long)articleCout.get("articleCount"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Long getGuidanceByTeam(Long id,String doctor, String startDate, String endDate) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //获取健康指导 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String guidance_sql = "SELECT COUNT(1) AS guidanceCount  FROM wlyy_patient_health_guidance w WHERE w.admin_team_code =" + id + " AND w.czrq <='" + endDate + "' AND w.czrq >='" + startDate + "' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND w.doctor ='"+doctor+"' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //获取健康指导 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, Object> guidanceCout = jdbcTemplate.queryForMap(guidance_sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (guidanceCout.get("guidanceCount") == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            guidanceCout.put("guidanceCount", 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return (Long)guidanceCout.get("guidanceCount"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Long getFollowByTeam(Long id,String doctor, String startDate, String endDate) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //随访数目 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String followup_sql = "SELECT COUNT(1) AS followupCount from wlyy_followup w WHERE w.admin_team_code=" + id + " AND  w.create_time >='" + startDate + "' AND w.create_time<='" + endDate + "' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND w.doctor_code ='"+doctor+"' AND w.patient_code IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.doctor_code ='"+doctor+"' AND t.team_code = " +id+") "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //随访数目 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, Object> followupCout = jdbcTemplate.queryForMap(followup_sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (followupCout.get("followupCount") == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            followupCout.put("followupCount", 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return (Long)followupCout.get("followupCount"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Long getPresCount(Long id,String doctor, String startDate, String endDate){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " count(1) AS reviewedCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_prescription p " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " JOIN wlyy_prescription_reviewed r ON r.prescription_code = p.`code` " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.doctor = '"+doctor+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND p.admin_team_id = " + id + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND r.reviewed_time >= '"+startDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND r.reviewed_time <= '"+endDate+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND p.patient IN ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " SELECT t.patient_code " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM wlyy_track_patient t " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE t.doctor_code ='"+doctor+"' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND t.team_code = " +id+")"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //审核数目 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, Object> reviewedCount = jdbcTemplate.queryForMap(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (reviewedCount.get("reviewedCount") == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            reviewedCount.put("reviewedCount", 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return (Long)reviewedCount.get("reviewedCount"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |