|  | @ -3,14 +3,18 @@ package com.yihu.wlyy.service.app.scheme;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONArray;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.yihu.device.entity.DevicePatientHealthIndex;
 | 
	
		
			
				|  |  | 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.health.repository.DevicePatientHealthIndexDao;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.repository.doctor.DoctoreSchemeBloodPressureDao;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.repository.doctor.DoctoreSchemeBloodSuggerDao;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.repository.doctor.DoctroSchemeBloodSuggerDao;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.repository.patient.PatientDao;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.repository.patient.scheme.PatientSchemeListDao;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.util.DateUtil;
 | 
	
		
			
				|  |  | import org.apache.commons.lang.StringUtils;
 | 
	
	
		
			
				|  | @ -53,6 +57,11 @@ public class DoctorSchemeService {
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private DoctoreSchemeBloodSuggerDao doctoreSchemeBloodSuggerDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PatientDao patientDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private DevicePatientHealthIndexDao devicePatientHealthIndexDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -79,7 +88,7 @@ public class DoctorSchemeService {
 | 
	
		
			
				|  |  |             sql = sql + " and p.disease ="+disease;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(diseaseCondition)){
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(diseaseCondition) && !"-1".equals(diseaseCondition)){
 | 
	
		
			
				|  |  |             sql = sql + " and p.disease_condition IN ("+diseaseCondition +")";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -93,6 +102,8 @@ public class DoctorSchemeService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         sql = sql + " and p.status > 0 and p.disease > 0 ";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<String> result = jdbcTemplate.queryForList(sql,new Object[]{},String.class);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -115,29 +126,30 @@ public class DoctorSchemeService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<DoctorSchemeBloodSugger> schemelist = doctroSchemeBloodSuggerDao.getListByDoctorcode(doctorcode);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         DoctorSchemeBloodSugger defaultSchemeBloodSugger = doctroSchemeBloodSuggerDao.findByCode("default");
 | 
	
		
			
				|  |  |         List<DoctorSchemeBloodSugger> defaultSchemeBloodSugger = doctroSchemeBloodSuggerDao.findByCode("default");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         schemelist.add(defaultSchemeBloodSugger);
 | 
	
		
			
				|  |  |         schemelist.addAll(defaultSchemeBloodSugger);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         for (DoctorSchemeBloodSugger doctorSchemeBloodSugger : schemelist) {
 | 
	
		
			
				|  |  |             if(mapresult.keySet().contains(doctorSchemeBloodSugger.getCode())){
 | 
	
		
			
				|  |  |                 mapresult.get(doctorSchemeBloodSugger.getCode()).add(doctorSchemeBloodSugger);
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 List<DoctorSchemeBloodSugger> list = new ArrayList<>();
 | 
	
		
			
				|  |  |                 list.add(doctorSchemeBloodSugger);
 | 
	
		
			
				|  |  |                 mapresult.put(doctorSchemeBloodSugger.getCode(),list);
 | 
	
		
			
				|  |  |         if(!schemelist.isEmpty()){
 | 
	
		
			
				|  |  |             for (DoctorSchemeBloodSugger doctorSchemeBloodSugger : schemelist) {
 | 
	
		
			
				|  |  |                 if(mapresult.keySet().contains(doctorSchemeBloodSugger.getCode())){
 | 
	
		
			
				|  |  |                     mapresult.get(doctorSchemeBloodSugger.getCode()).add(doctorSchemeBloodSugger);
 | 
	
		
			
				|  |  |                 }else{
 | 
	
		
			
				|  |  |                     List<DoctorSchemeBloodSugger> list = new ArrayList<>();
 | 
	
		
			
				|  |  |                     list.add(doctorSchemeBloodSugger);
 | 
	
		
			
				|  |  |                     mapresult.put(doctorSchemeBloodSugger.getCode(),list);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         for (String key :mapresult.keySet()) {
 | 
	
		
			
				|  |  |             DoctorSchemeBloodSuggerVO doctorSchemeBloodSuggerVO = new DoctorSchemeBloodSuggerVO();
 | 
	
		
			
				|  |  |             doctorSchemeBloodSuggerVO.setCode(key);
 | 
	
		
			
				|  |  |             doctorSchemeBloodSuggerVO.setName(mapresult.get(key).get(0).getName());
 | 
	
		
			
				|  |  |             doctorSchemeBloodSuggerVO.setContent(mapresult.get(key).get(0).getContent());
 | 
	
		
			
				|  |  |             doctorSchemeBloodSuggerVO.setList(mapresult.get(key));
 | 
	
		
			
				|  |  |             result.add(doctorSchemeBloodSuggerVO);
 | 
	
		
			
				|  |  |             for (String key :mapresult.keySet()) {
 | 
	
		
			
				|  |  |                 DoctorSchemeBloodSuggerVO doctorSchemeBloodSuggerVO = new DoctorSchemeBloodSuggerVO();
 | 
	
		
			
				|  |  |                 doctorSchemeBloodSuggerVO.setCode(key);
 | 
	
		
			
				|  |  |                 doctorSchemeBloodSuggerVO.setName(mapresult.get(key).get(0).getName());
 | 
	
		
			
				|  |  |                 doctorSchemeBloodSuggerVO.setContent(mapresult.get(key).get(0).getContent());
 | 
	
		
			
				|  |  |                 doctorSchemeBloodSuggerVO.setList(mapresult.get(key));
 | 
	
		
			
				|  |  |                 result.add(doctorSchemeBloodSuggerVO);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -155,27 +167,29 @@ public class DoctorSchemeService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<DoctorSchemeBloodPressure> schemelist = doctoreSchemeBloodPressureDao.getListByDoctorcode(doctorcode);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         DoctorSchemeBloodPressure defaultSchemeBloodPressure = doctoreSchemeBloodPressureDao.findByCode("default");
 | 
	
		
			
				|  |  |         List<DoctorSchemeBloodPressure> defaultSchemeBloodPressure = doctoreSchemeBloodPressureDao.findByCode("default");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         schemelist.add(defaultSchemeBloodPressure);
 | 
	
		
			
				|  |  |         schemelist.addAll(defaultSchemeBloodPressure);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         for (DoctorSchemeBloodPressure doctorSchemeBloodPressure : schemelist) {
 | 
	
		
			
				|  |  |             if(mapresult.keySet().contains(doctorSchemeBloodPressure.getCode())){
 | 
	
		
			
				|  |  |                 mapresult.get(doctorSchemeBloodPressure.getCode()).add(doctorSchemeBloodPressure);
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 List<DoctorSchemeBloodPressure> list = new ArrayList<>();
 | 
	
		
			
				|  |  |                 list.add(doctorSchemeBloodPressure);
 | 
	
		
			
				|  |  |                 mapresult.put(doctorSchemeBloodPressure.getCode(),list);
 | 
	
		
			
				|  |  |         if(!schemelist.isEmpty()){
 | 
	
		
			
				|  |  |             for (DoctorSchemeBloodPressure doctorSchemeBloodPressure : schemelist) {
 | 
	
		
			
				|  |  |                 if(mapresult.keySet().contains(doctorSchemeBloodPressure.getCode())){
 | 
	
		
			
				|  |  |                     mapresult.get(doctorSchemeBloodPressure.getCode()).add(doctorSchemeBloodPressure);
 | 
	
		
			
				|  |  |                 }else{
 | 
	
		
			
				|  |  |                     List<DoctorSchemeBloodPressure> list = new ArrayList<>();
 | 
	
		
			
				|  |  |                     list.add(doctorSchemeBloodPressure);
 | 
	
		
			
				|  |  |                     mapresult.put(doctorSchemeBloodPressure.getCode(),list);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         for (String key :mapresult.keySet()) {
 | 
	
		
			
				|  |  |             DoctorSchemeBloodPressureVO doctorSchemeBloodPressureVO = new DoctorSchemeBloodPressureVO();
 | 
	
		
			
				|  |  |             doctorSchemeBloodPressureVO.setCode(key);
 | 
	
		
			
				|  |  |             doctorSchemeBloodPressureVO.setName(mapresult.get(key).get(0).getName());
 | 
	
		
			
				|  |  |             doctorSchemeBloodPressureVO.setContent(mapresult.get(key).get(0).getContent());
 | 
	
		
			
				|  |  |             doctorSchemeBloodPressureVO.setList(mapresult.get(key));
 | 
	
		
			
				|  |  |             result.add(doctorSchemeBloodPressureVO);
 | 
	
		
			
				|  |  |             for (String key :mapresult.keySet()) {
 | 
	
		
			
				|  |  |                 DoctorSchemeBloodPressureVO doctorSchemeBloodPressureVO = new DoctorSchemeBloodPressureVO();
 | 
	
		
			
				|  |  |                 doctorSchemeBloodPressureVO.setCode(key);
 | 
	
		
			
				|  |  |                 doctorSchemeBloodPressureVO.setName(mapresult.get(key).get(0).getName());
 | 
	
		
			
				|  |  |                 doctorSchemeBloodPressureVO.setContent(mapresult.get(key).get(0).getContent());
 | 
	
		
			
				|  |  |                 doctorSchemeBloodPressureVO.setList(mapresult.get(key));
 | 
	
		
			
				|  |  |                 result.add(doctorSchemeBloodPressureVO);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return result;
 | 
	
	
		
			
				|  | @ -351,4 +365,147 @@ public class DoctorSchemeService {
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 医生端-获取慢病管理居民管理端数据
 | 
	
		
			
				|  |  |      * @param teamCode
 | 
	
		
			
				|  |  |      * @param getcolor
 | 
	
		
			
				|  |  |      * @param getstands
 | 
	
		
			
				|  |  |      * @param gethealthindex
 | 
	
		
			
				|  |  |      * @param startdate
 | 
	
		
			
				|  |  |      * @param enddate
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONArray getSlowDiseaseTeaminfos(String teamCode, int getcolor, int getstands, int gethealthindex, String startdate, String enddate) throws Exception{
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<Patient> patients = patientDao.findAllSignPatientTeamcode(teamCode);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         JSONArray result = new JSONArray();
 | 
	
		
			
				|  |  |         JSONObject green = new JSONObject();//绿标
 | 
	
		
			
				|  |  |         JSONObject yellow = new JSONObject();//黄标
 | 
	
		
			
				|  |  |         JSONObject red = new JSONObject();//红标
 | 
	
		
			
				|  |  |         JSONObject pressure_standard =  new JSONObject();//血压预警
 | 
	
		
			
				|  |  |         JSONObject sugar_standard =  new JSONObject();//血糖预警
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         JSONObject pressure_count =  new JSONObject();//血压体征总数
 | 
	
		
			
				|  |  |         JSONObject pressure_unusual_ount =  new JSONObject();//血压体征总数
 | 
	
		
			
				|  |  |         JSONObject sugar_count =  new JSONObject();//血糖体征总数
 | 
	
		
			
				|  |  |         JSONObject sugar_unusual_count =  new JSONObject();//血糖体征总数
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         int count = patients.size();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //绿标居民
 | 
	
		
			
				|  |  |         List<Patient> green_patients = new ArrayList<>();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //黄标居民
 | 
	
		
			
				|  |  |         List<Patient> yellow_patients = new ArrayList<>();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //红标居民
 | 
	
		
			
				|  |  |         List<Patient> red_patients = new ArrayList<>();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //高血压居民预警居民CODE
 | 
	
		
			
				|  |  |         List<String> bloodpressure_patientcodes = new ArrayList<>();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //高血糖居民预警居民CODE
 | 
	
		
			
				|  |  |         List<String> bloodsugar_patientcodes = new ArrayList<>();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(!patients.isEmpty()){
 | 
	
		
			
				|  |  |             for (Patient patient : red_patients) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 //获取居民颜色标签
 | 
	
		
			
				|  |  |                 if(1 == getcolor){
 | 
	
		
			
				|  |  |                     switch (patient.getDiseaseCondition()){
 | 
	
		
			
				|  |  |                         case 0:
 | 
	
		
			
				|  |  |                             green_patients.add(patient);
 | 
	
		
			
				|  |  |                             break;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         case 1:
 | 
	
		
			
				|  |  |                             yellow_patients.add(patient);
 | 
	
		
			
				|  |  |                             break;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         case 2:
 | 
	
		
			
				|  |  |                             red_patients.add(patient);
 | 
	
		
			
				|  |  |                             break;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 //获取预警居民CODES
 | 
	
		
			
				|  |  |                 if(1 == getstands && 1 == patient.getStandardStatus()){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     if( 1 == patient.getDisease() || 3 == patient.getDisease()){
 | 
	
		
			
				|  |  |                         bloodpressure_patientcodes.add(patient.getCode());
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     if( 2 == patient.getDisease() || 3 == patient.getDisease()){
 | 
	
		
			
				|  |  |                         bloodsugar_patientcodes.add(patient.getCode());
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(1 == getcolor){
 | 
	
		
			
				|  |  |             green.put("greencount",green_patients.size());
 | 
	
		
			
				|  |  |             yellow.put("yellowcount",yellow_patients.size());
 | 
	
		
			
				|  |  |             red.put("redcount",red_patients.size());
 | 
	
		
			
				|  |  |             result.add(green);
 | 
	
		
			
				|  |  |             result.add(yellow);
 | 
	
		
			
				|  |  |             result.add(red);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(1 == getstands){
 | 
	
		
			
				|  |  |             pressure_standard.put("pressure_standard",bloodpressure_patientcodes);
 | 
	
		
			
				|  |  |             sugar_standard.put("sugar_standard",bloodsugar_patientcodes);
 | 
	
		
			
				|  |  |             result.add(pressure_standard);
 | 
	
		
			
				|  |  |             result.add(sugar_standard);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(1 == gethealthindex){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Date start = DateUtil.strToDate(startdate);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Date end = DateUtil.strToDate(enddate);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             List<DevicePatientHealthIndex> devicePatientHealthIndices = devicePatientHealthIndexDao.findByTeamcodeAndRecordDate("1,2",start,end,teamCode);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             int sugar = 0;
 | 
	
		
			
				|  |  |             int sugar_unusual = 0;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             int pressure = 0;
 | 
	
		
			
				|  |  |             int pressure_unusual = 0;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if(!devicePatientHealthIndices.isEmpty()){
 | 
	
		
			
				|  |  |                 for (DevicePatientHealthIndex devicePatientHealthIndex : devicePatientHealthIndices) {
 | 
	
		
			
				|  |  |                     if( 1 == devicePatientHealthIndex.getType()){
 | 
	
		
			
				|  |  |                         sugar++;
 | 
	
		
			
				|  |  |                         if( 1 == devicePatientHealthIndex.getStatus()){
 | 
	
		
			
				|  |  |                             sugar_unusual++;
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     if( 2 == devicePatientHealthIndex.getType()){
 | 
	
		
			
				|  |  |                         pressure++;
 | 
	
		
			
				|  |  |                         if( 1 == devicePatientHealthIndex.getStatus()){
 | 
	
		
			
				|  |  |                             pressure_unusual++;
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             pressure_count.put("pressure_count",pressure);
 | 
	
		
			
				|  |  |             pressure_unusual_ount.put("pressure_unusual_count",pressure_unusual);
 | 
	
		
			
				|  |  |             sugar_count.put("sugar_count",sugar);
 | 
	
		
			
				|  |  |             sugar_unusual_count.put("sugar_unusual_count",sugar_unusual);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             result.add(pressure_count);
 | 
	
		
			
				|  |  |             result.add(pressure_unusual_ount);
 | 
	
		
			
				|  |  |             result.add(sugar_count);
 | 
	
		
			
				|  |  |             result.add(sugar_unusual_count);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |