|  | @ -509,9 +509,6 @@ public class SignPatientLabelInfoService extends BaseService {
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 查询某个标签类型的所有标签居民数统计
 | 
	
		
			
				|  |  |      *
 | 
	
	
		
			
				|  | @ -526,7 +523,7 @@ public class SignPatientLabelInfoService extends BaseService {
 | 
	
		
			
				|  |  |             throw new Exception("doctor info can not find");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<SignPatientLabel> labels = labelService.getLabelsByTypeAndTeam(labelType, teamCode);
 | 
	
		
			
				|  |  |         List<SignPatientLabel> labels = labelService.getLabelsByTypeAndTeam(labelType, teamCode.toString());
 | 
	
		
			
				|  |  |         JSONArray result = new JSONArray();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         SignPatientLabel labelNo = new SignPatientLabel();
 | 
	
	
		
			
				|  | @ -653,13 +650,15 @@ public class SignPatientLabelInfoService extends BaseService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public int getPatientAmountByTeam(Long teamCode) throws Exception{
 | 
	
		
			
				|  |  |         List<SignFamily> signFamilies =  signFamilyDao.findByAdminTeamIdAndStatus(teamCode, 1);
 | 
	
		
			
				|  |  |     public int getPatientAmountByTeam(Long teamCode) throws Exception {
 | 
	
		
			
				|  |  |         List<SignFamily> signFamilies = signFamilyDao.findByAdminTeamIdAndStatus(teamCode, 1);
 | 
	
		
			
				|  |  |         return signFamilies.size();
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 查询某个标签类型的所有标签居民数统计,或者所有类型
 | 
	
		
			
				|  |  |      *
 | 
	
	
		
			
				|  | @ -667,14 +666,14 @@ public class SignPatientLabelInfoService extends BaseService {
 | 
	
		
			
				|  |  |      * @param teamCode  标签类型为4时,不能为空
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONArray getPatientAmountByTeamGroupLable(Long teamCode,String labelType) throws Exception {
 | 
	
		
			
				|  |  |     public JSONArray getPatientAmountByTeamGroupLable(Long teamCode, String labelType) throws Exception {
 | 
	
		
			
				|  |  |         Boolean isAll = false;
 | 
	
		
			
				|  |  |         List<SignPatientLabel> labels = new ArrayList<>();
 | 
	
		
			
				|  |  |         if("0".equals(labelType)){
 | 
	
		
			
				|  |  |             labels =  labelService.getTeamAllLabels(teamCode);
 | 
	
		
			
				|  |  |         if ("0".equals(labelType)) {
 | 
	
		
			
				|  |  |             labels = labelService.getTeamAllLabels(teamCode);
 | 
	
		
			
				|  |  |             isAll = true;
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             labels = labelService.getLabelsByTypeAndTeam(labelType,teamCode);
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             labels = labelService.getLabelsByTypeAndTeam(labelType, teamCode.toString());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         JSONArray result = new JSONArray();
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -693,8 +692,8 @@ public class SignPatientLabelInfoService extends BaseService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (labels != null) {
 | 
	
		
			
				|  |  |             for (SignPatientLabel label : labels) {
 | 
	
		
			
				|  |  |                 if(isAll){//查询所有
 | 
	
		
			
				|  |  |                  labelType  =  label.getLabelType();
 | 
	
		
			
				|  |  |                 if (isAll) {//查询所有
 | 
	
		
			
				|  |  |                     labelType = label.getLabelType();
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 JSONObject json = new JSONObject();
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -736,7 +735,7 @@ public class SignPatientLabelInfoService extends BaseService {
 | 
	
		
			
				|  |  |                         throw new Exception("label is not exist");
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     if (teamCode > 0) {
 | 
	
		
			
				|  |  |                         args = new Object[]{teamCode,teamCode};
 | 
	
		
			
				|  |  |                         args = new Object[]{teamCode, teamCode};
 | 
	
		
			
				|  |  |                     } else {
 | 
	
		
			
				|  |  |                         args = new Object[]{};
 | 
	
		
			
				|  |  |                     }
 | 
	
	
		
			
				|  | @ -755,9 +754,9 @@ public class SignPatientLabelInfoService extends BaseService {
 | 
	
		
			
				|  |  |                                 (teamCode > 0 ? "    AND t1.admin_team_code = ? " : "");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         if (teamCode > 0) {
 | 
	
		
			
				|  |  |                             args = new Object[]{labelType, teamCode, labelType,teamCode};
 | 
	
		
			
				|  |  |                             args = new Object[]{labelType, teamCode, labelType, teamCode};
 | 
	
		
			
				|  |  |                         } else {
 | 
	
		
			
				|  |  |                             args = new Object[]{labelType,labelType};
 | 
	
		
			
				|  |  |                             args = new Object[]{labelType, labelType};
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     } else {
 | 
	
		
			
				|  |  |                         sql = " SELECT " +
 | 
	
	
		
			
				|  | @ -804,8 +803,6 @@ public class SignPatientLabelInfoService extends BaseService {
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 设置患者标签
 | 
	
		
			
				|  |  |      *
 | 
	
	
		
			
				|  | @ -817,7 +814,7 @@ public class SignPatientLabelInfoService extends BaseService {
 | 
	
		
			
				|  |  |      * @param custom      自定义标签
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public int setPatientLabels(String patient, String idcard, String patientName, String health, String disease, String custom) {
 | 
	
		
			
				|  |  |     public int setPatientLabels(String patient, String idcard, String patientName, String health, String disease, String custom, String doctor) {
 | 
	
		
			
				|  |  |         Patient p = patientDao.findByCode(patient);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (p == null && (StringUtils.isEmpty(idcard) || StringUtils.isEmpty(patientName))) {
 | 
	
	
		
			
				|  | @ -843,122 +840,184 @@ public class SignPatientLabelInfoService extends BaseService {
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         JSONArray teams = adminTeamService.findPatientDoctorTeam(patient, doctor);
 | 
	
		
			
				|  |  |         List<String> teamCodes = new ArrayList<>();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(teams.length() > 0){
 | 
	
		
			
				|  |  |             for(int i = 0; i < teams.length(); i++){
 | 
	
		
			
				|  |  |                 teamCodes.add(String.valueOf(teams.getJSONObject(i).getLong("id")));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             return -4;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String[] diseaseArr = disease.split(",");
 | 
	
		
			
				|  |  |         String[] customArr = custom.split(",");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         // 健康情况标签
 | 
	
		
			
				|  |  |         int healthAmount = labelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient, "2", 1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (StringUtils.isNotEmpty(health)) {
 | 
	
		
			
				|  |  |             SignPatientLabelInfo healthLabel = new SignPatientLabelInfo();
 | 
	
		
			
				|  |  |             SignPatientLabel label = labelService.getLabelByCodeAndType(health, "2");
 | 
	
		
			
				|  |  |             SignPatientLabelInfo healthEx = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(patient, health, "2", 1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (label == null) {
 | 
	
		
			
				|  |  |                 return -1;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (healthEx == null) {
 | 
	
		
			
				|  |  |                 // 健康情况标签
 | 
	
		
			
				|  |  |                 int healthAmount = labelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient, "2", 1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             healthLabel.setPatient(patient);
 | 
	
		
			
				|  |  |             healthLabel.setPname(patientName);
 | 
	
		
			
				|  |  |             healthLabel.setLabelType("2");
 | 
	
		
			
				|  |  |             healthLabel.setLabel(health);
 | 
	
		
			
				|  |  |             healthLabel.setLabelName(label.getLabelName());
 | 
	
		
			
				|  |  |             healthLabel.setStatus(1);
 | 
	
		
			
				|  |  |             healthLabel.setCzrq(new Date());
 | 
	
		
			
				|  |  |                 SignPatientLabelInfo healthLabel = new SignPatientLabelInfo();
 | 
	
		
			
				|  |  |                 SignPatientLabel label = labelService.getLabelByCodeAndType(health, "2");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             labelInfoDao.save(healthLabel);
 | 
	
		
			
				|  |  |                 if (label == null) {
 | 
	
		
			
				|  |  |                     return -1;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 healthLabel.setPatient(patient);
 | 
	
		
			
				|  |  |                 healthLabel.setPname(patientName);
 | 
	
		
			
				|  |  |                 healthLabel.setLabelType("2");
 | 
	
		
			
				|  |  |                 healthLabel.setLabel(health);
 | 
	
		
			
				|  |  |                 healthLabel.setLabelName(label.getLabelName());
 | 
	
		
			
				|  |  |                 healthLabel.setStatus(1);
 | 
	
		
			
				|  |  |                 healthLabel.setCzrq(new Date());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 labelInfoDao.save(healthLabel);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             return -2;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         // 疾病类型标签
 | 
	
		
			
				|  |  |         int disAmount = labelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient, "3", 1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (diseaseArr != null && diseaseArr.length > 0) {
 | 
	
		
			
				|  |  |             List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndLabelTypeAndStatus(patient, "3", 1);
 | 
	
		
			
				|  |  |             Map<String, SignPatientLabelInfo> labelMap = new HashMap<>();
 | 
	
		
			
				|  |  |             List<String> disList = Arrays.asList(diseaseArr);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             for (SignPatientLabelInfo label : labels) {
 | 
	
		
			
				|  |  |                 labelMap.put(label.getLabel(), label);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 if (!disList.contains(label.getLabel())) {
 | 
	
		
			
				|  |  |                     label.setStatus(0);
 | 
	
		
			
				|  |  |                     labelInfoDao.save(label);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             for (String diseaseLabel : diseaseArr) {
 | 
	
		
			
				|  |  |                 if (StringUtils.isEmpty(diseaseLabel)) {
 | 
	
		
			
				|  |  |                     continue;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 SignPatientLabelInfo disLabel = new SignPatientLabelInfo();
 | 
	
		
			
				|  |  |                 SignPatientLabel label = labelService.getLabelByCodeAndType(diseaseLabel, "3");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 if (label == null) {
 | 
	
		
			
				|  |  |                     return -1;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 SignPatientLabelInfo diseaseEx = labelMap.get(diseaseLabel);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 disLabel.setPatient(patient);
 | 
	
		
			
				|  |  |                 disLabel.setPname(patientName);
 | 
	
		
			
				|  |  |                 disLabel.setLabelType("3");
 | 
	
		
			
				|  |  |                 disLabel.setLabel(diseaseLabel);
 | 
	
		
			
				|  |  |                 disLabel.setLabelName(label.getLabelName());
 | 
	
		
			
				|  |  |                 disLabel.setStatus(1);
 | 
	
		
			
				|  |  |                 disLabel.setCzrq(new Date());
 | 
	
		
			
				|  |  |                 if (diseaseEx == null) {
 | 
	
		
			
				|  |  |                     SignPatientLabelInfo disLabel = new SignPatientLabelInfo();
 | 
	
		
			
				|  |  |                     SignPatientLabel label = labelService.getLabelByCodeAndType(diseaseLabel, "3");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 labelInfoDao.save(disLabel);
 | 
	
		
			
				|  |  |                     if (label == null) {
 | 
	
		
			
				|  |  |                         return -1;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     disLabel.setPatient(patient);
 | 
	
		
			
				|  |  |                     disLabel.setPname(patientName);
 | 
	
		
			
				|  |  |                     disLabel.setLabelType("3");
 | 
	
		
			
				|  |  |                     disLabel.setLabel(diseaseLabel);
 | 
	
		
			
				|  |  |                     disLabel.setLabelName(label.getLabelName());
 | 
	
		
			
				|  |  |                     disLabel.setStatus(1);
 | 
	
		
			
				|  |  |                     disLabel.setCzrq(new Date());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     labelInfoDao.save(disLabel);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             // 疾病类型标签
 | 
	
		
			
				|  |  |             int disAmount = labelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient, "3", 1);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         // 自定义标签
 | 
	
		
			
				|  |  |         int cusAmount = labelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient, "4", 1);
 | 
	
		
			
				|  |  |         List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndLabelTypeAndStatus(patient, "4", 1);
 | 
	
		
			
				|  |  |         Map<String, SignPatientLabelInfo> labelMap = new HashMap<>();
 | 
	
		
			
				|  |  |         List<String> custList = Arrays.asList(customArr);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         for (SignPatientLabelInfo label : labels) {
 | 
	
		
			
				|  |  |             labelMap.put(label.getLabel(), label);
 | 
	
		
			
				|  |  |             SignPatientLabel lb = labelService.getLabelByCodeAndType(label.getLabel(),"4");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if(!custList.contains(label.getLabel())) {
 | 
	
		
			
				|  |  |                 if (lb.getLabelCode().equals("1") || lb.getLabelCode().equals("2") || teamCodes.contains(String.valueOf(lb.getTeamCode()))) {
 | 
	
		
			
				|  |  |                     label.setStatus(0);
 | 
	
		
			
				|  |  |                     labelInfoDao.save(label);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (customArr != null && customArr.length > 0) {
 | 
	
		
			
				|  |  |             for (String customLabel : customArr) {
 | 
	
		
			
				|  |  |                 if (StringUtils.isEmpty(customLabel)) {
 | 
	
		
			
				|  |  |                     continue;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 SignPatientLabelInfo cusLabel = new SignPatientLabelInfo();
 | 
	
		
			
				|  |  |                 SignPatientLabel label = labelService.getLabelByCodeAndType(customLabel, "4");
 | 
	
		
			
				|  |  |                 SignPatientLabelInfo customEx = labelMap.get(customLabel);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 if (label == null) {
 | 
	
		
			
				|  |  |                     return -1;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 if (customEx == null) {
 | 
	
		
			
				|  |  |                     SignPatientLabelInfo cusLabel = new SignPatientLabelInfo();
 | 
	
		
			
				|  |  |                     SignPatientLabel label = labelService.getLabelByCodeAndType(customLabel, "4");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     if (label == null) {
 | 
	
		
			
				|  |  |                         return -1;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 cusLabel.setPatient(patient);
 | 
	
		
			
				|  |  |                 cusLabel.setPname(patientName);
 | 
	
		
			
				|  |  |                 cusLabel.setLabelType("4");
 | 
	
		
			
				|  |  |                 cusLabel.setLabel(customLabel);
 | 
	
		
			
				|  |  |                 cusLabel.setLabelName(label.getLabelName());
 | 
	
		
			
				|  |  |                 cusLabel.setStatus(1);
 | 
	
		
			
				|  |  |                 cusLabel.setCzrq(new Date());
 | 
	
		
			
				|  |  |                     cusLabel.setPatient(patient);
 | 
	
		
			
				|  |  |                     cusLabel.setPname(patientName);
 | 
	
		
			
				|  |  |                     cusLabel.setLabelType("4");
 | 
	
		
			
				|  |  |                     cusLabel.setLabel(customLabel);
 | 
	
		
			
				|  |  |                     cusLabel.setLabelName(label.getLabelName());
 | 
	
		
			
				|  |  |                     cusLabel.setStatus(1);
 | 
	
		
			
				|  |  |                     cusLabel.setCzrq(new Date());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 labelInfoDao.save(cusLabel);
 | 
	
		
			
				|  |  |                     labelInfoDao.save(cusLabel);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         // 卫计委三大分组
 | 
	
		
			
				|  |  |         int wjwAmount = labelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient, "1", 1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (diseaseArr != null && diseaseArr.length > 0 && (Arrays.asList(diseaseArr).contains("1")
 | 
	
		
			
				|  |  |                 || Arrays.asList(diseaseArr).contains("2"))) {
 | 
	
		
			
				|  |  |             SignPatientLabelInfo disLabel = new SignPatientLabelInfo();
 | 
	
		
			
				|  |  |             SignPatientLabelInfo mbEx = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(patient, "2", "1", 1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             disLabel.setPatient(patient);
 | 
	
		
			
				|  |  |             disLabel.setPname(patientName);
 | 
	
		
			
				|  |  |             disLabel.setLabelType("1");
 | 
	
		
			
				|  |  |             disLabel.setLabel("2");
 | 
	
		
			
				|  |  |             disLabel.setLabelName("慢病人群");
 | 
	
		
			
				|  |  |             disLabel.setStatus(1);
 | 
	
		
			
				|  |  |             disLabel.setCzrq(new Date());
 | 
	
		
			
				|  |  |             if(mbEx == null) {
 | 
	
		
			
				|  |  |                 // 卫计委三大分组
 | 
	
		
			
				|  |  |                 int wjwAmount = labelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient, "1", 1);
 | 
	
		
			
				|  |  |                 SignPatientLabelInfo disLabel = new SignPatientLabelInfo();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 disLabel.setPatient(patient);
 | 
	
		
			
				|  |  |                 disLabel.setPname(patientName);
 | 
	
		
			
				|  |  |                 disLabel.setLabelType("1");
 | 
	
		
			
				|  |  |                 disLabel.setLabel("2");
 | 
	
		
			
				|  |  |                 disLabel.setLabelName("慢病人群");
 | 
	
		
			
				|  |  |                 disLabel.setStatus(1);
 | 
	
		
			
				|  |  |                 disLabel.setCzrq(new Date());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             labelInfoDao.save(disLabel);
 | 
	
		
			
				|  |  |                 labelInfoDao.save(disLabel);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             int age = IdCardUtil.getAgeForIdcard(idcard);
 | 
	
		
			
				|  |  |             SignPatientLabelInfo disLabel = new SignPatientLabelInfo();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             disLabel.setPatient(patient);
 | 
	
		
			
				|  |  |             disLabel.setPname(patientName);
 | 
	
		
			
				|  |  |             disLabel.setLabelType("1");
 | 
	
		
			
				|  |  |             disLabel.setStatus(1);
 | 
	
		
			
				|  |  |             disLabel.setCzrq(new Date());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (age >= 65) {
 | 
	
		
			
				|  |  |                 disLabel.setLabel("3");
 | 
	
		
			
				|  |  |                 disLabel.setLabelName("65岁以上人群");
 | 
	
		
			
				|  |  |             String lbCode = "",lbName = "";
 | 
	
		
			
				|  |  |             if(age >= 65){
 | 
	
		
			
				|  |  |                 lbCode = "3";
 | 
	
		
			
				|  |  |                 lbName = "65岁以上人群";
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 disLabel.setLabel("1");
 | 
	
		
			
				|  |  |                 disLabel.setLabelName("普通人群");
 | 
	
		
			
				|  |  |                 lbCode = "1";
 | 
	
		
			
				|  |  |                 lbName = "普通人群";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             labelInfoDao.save(disLabel);
 | 
	
		
			
				|  |  |             SignPatientLabelInfo wjwEx = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(patient, lbCode, "1", 1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if(wjwEx == null) {
 | 
	
		
			
				|  |  |                 // 卫计委三大分组
 | 
	
		
			
				|  |  |                 int wjwAmount = labelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient, "1", 1);
 | 
	
		
			
				|  |  |                 SignPatientLabelInfo disLabel = new SignPatientLabelInfo();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 disLabel.setPatient(patient);
 | 
	
		
			
				|  |  |                 disLabel.setPname(patientName);
 | 
	
		
			
				|  |  |                 disLabel.setLabelType("1");
 | 
	
		
			
				|  |  |                 disLabel.setStatus(1);
 | 
	
		
			
				|  |  |                 disLabel.setCzrq(new Date());
 | 
	
		
			
				|  |  |                 disLabel.setLabel(lbCode);
 | 
	
		
			
				|  |  |                 disLabel.setLabelName(lbName);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 labelInfoDao.save(disLabel);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return 1;
 | 
	
	
		
			
				|  | @ -990,7 +1049,7 @@ public class SignPatientLabelInfoService extends BaseService {
 | 
	
		
			
				|  |  |      * @param labelType 标签类型
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONArray getPatientLabelByLabelTypeAndTeamCode(String patient, String labelType, Long teamCode, String doctor) {
 | 
	
		
			
				|  |  |     public JSONArray getPatientLabelByLabelTypeAndTeamCode(String patient, String labelType, long teamCode, String doctor) {
 | 
	
		
			
				|  |  |         List<SignPatientLabelInfo> labels = new ArrayList<>();
 | 
	
		
			
				|  |  |         JSONArray result = new JSONArray();
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -1000,10 +1059,11 @@ public class SignPatientLabelInfoService extends BaseService {
 | 
	
		
			
				|  |  |             labels = labelInfoDao.findByPatientAndLabelTypeAndStatus(patient, labelType, 1);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         // 查询居民签约团队
 | 
	
		
			
				|  |  |         SignFamily ssSign = signFamilyDao.findSignByPatient(patient, 1);
 | 
	
		
			
				|  |  |         SignFamily jtSign = signFamilyDao.findSignByPatient(patient, 2);
 | 
	
		
			
				|  |  |         Long ssTeam = 0L;
 | 
	
		
			
				|  |  |         Long jtTeam = 0L;
 | 
	
		
			
				|  |  |         long ssTeam = 0L;
 | 
	
		
			
				|  |  |         long jtTeam = 0L;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (ssSign != null && (doctor.equals(ssSign.getDoctor()) ||
 | 
	
		
			
				|  |  |                 doctor.equals(ssSign.getDoctorHealth()))) {
 | 
	
	
		
			
				|  | @ -1021,10 +1081,27 @@ public class SignPatientLabelInfoService extends BaseService {
 | 
	
		
			
				|  |  |                 if (label.getLabelType().equals("4") && !label.getLabel().equals("1") && !label.getLabel().equals("2")) {
 | 
	
		
			
				|  |  |                     SignPatientLabel lb = labelService.getLabelByCodeAndType(label.getLabel(), "4");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     if (teamCode != null && teamCode > 0 && teamCode != lb.getTeamCode()) {
 | 
	
		
			
				|  |  |                     // 有指定团队时不在团队内的过滤
 | 
	
		
			
				|  |  |                     if (teamCode > 0 && teamCode != lb.getTeamCode()) {
 | 
	
		
			
				|  |  |                         continue;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     if (teamCode < 1) {
 | 
	
		
			
				|  |  |                         // 是否为签约团队标签
 | 
	
		
			
				|  |  |                         boolean teamLabelFlag = false;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         if (ssTeam > 0 && ssTeam == lb.getTeamCode()) {
 | 
	
		
			
				|  |  |                             teamLabelFlag = true;
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         if (jtTeam > 0 && jtTeam == lb.getTeamCode()) {
 | 
	
		
			
				|  |  |                             teamLabelFlag = true;
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         // 有签约关系时,判断标签是否在签约团队标签,不是签约团队标签不显示;无签约关系时返回全部
 | 
	
		
			
				|  |  |                         if ((ssTeam > 0 || jtTeam > 0) && !teamLabelFlag) {
 | 
	
		
			
				|  |  |                             continue;
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     AdminTeam team = adminTeamService.getTeam(lb.getTeamCode());
 | 
	
		
			
				|  |  |                     Doctor doc = doctorDao.findByCode(lb.getCreator());
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -1317,9 +1394,6 @@ public class SignPatientLabelInfoService extends BaseService {
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 添加居民到某个标签
 | 
	
		
			
				|  |  |      *
 | 
	
	
		
			
				|  | @ -1503,10 +1577,10 @@ public class SignPatientLabelInfoService extends BaseService {
 | 
	
		
			
				|  |  |         } else if (StringUtils.isEmpty(labelCode) && StringUtils.isNotEmpty(labelType)) {
 | 
	
		
			
				|  |  |             args = new Object[]{labelType, "%" + filter + "%", "%" + filter + "%"};
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             args = new Object[]{ "%" + filter + "%", "%" + filter + "%"};
 | 
	
		
			
				|  |  |             args = new Object[]{"%" + filter + "%", "%" + filter + "%"};
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |        String sql = "select DISTINCT t.* from (" + sqlTemp+ ") t limit " + page + "," + pagesize;
 | 
	
		
			
				|  |  |         String sql = "select DISTINCT t.* from (" + sqlTemp + ") t limit " + page + "," + pagesize;
 | 
	
		
			
				|  |  |         signList = jdbcTemplate.queryForList(sql, args);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (signList != null && signList.size() > 0) {
 | 
	
	
		
			
				|  | @ -1632,19 +1706,19 @@ public class SignPatientLabelInfoService extends BaseService {
 | 
	
		
			
				|  |  |      * @param filter 搜索关键字
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONArray searchTeamsPatients(String filter,  long teamCode, int page, int pagesize) throws Exception {
 | 
	
		
			
				|  |  |     public JSONArray searchTeamsPatients(String filter, long teamCode, int page, int pagesize) throws Exception {
 | 
	
		
			
				|  |  |         JSONArray reArray = new JSONArray();
 | 
	
		
			
				|  |  |         Map<String, JSONArray> map = new HashMap<>();
 | 
	
		
			
				|  |  |         Map<Long, AdminTeam> teamMap = new HashMap<>();
 | 
	
		
			
				|  |  |         List<AdminTeam> teams = null;
 | 
	
		
			
				|  |  |         int start = page * pagesize;
 | 
	
		
			
				|  |  |         int size = pagesize;
 | 
	
		
			
				|  |  |             teams = new ArrayList<>();
 | 
	
		
			
				|  |  |             AdminTeam teamTemp = adminTeamService.getTeam(teamCode);
 | 
	
		
			
				|  |  |             if (teamTemp == null) {
 | 
	
		
			
				|  |  |                 throw new Exception("adminTeam is not exist");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             teams.add(teamTemp);
 | 
	
		
			
				|  |  |         teams = new ArrayList<>();
 | 
	
		
			
				|  |  |         AdminTeam teamTemp = adminTeamService.getTeam(teamCode);
 | 
	
		
			
				|  |  |         if (teamTemp == null) {
 | 
	
		
			
				|  |  |             throw new Exception("adminTeam is not exist");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         teams.add(teamTemp);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String sql = "select distinct t.* from (" +
 | 
	
		
			
				|  |  |                 " select " +
 | 
	
	
		
			
				|  | @ -1731,7 +1805,7 @@ public class SignPatientLabelInfoService extends BaseService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String tempsql = " select * from wlyy_sign_family where " +
 | 
	
		
			
				|  |  |                 " status > 0 and admin_team_code = ? ";
 | 
	
		
			
				|  |  |         args = new Object[]{ teamCode};
 | 
	
		
			
				|  |  |         args = new Object[]{teamCode};
 | 
	
		
			
				|  |  |         sql = "select t.* from (" + tempsql + ") t limit " + start + "," + pagesize;
 | 
	
		
			
				|  |  |         signList = jdbcTemplate.queryForList(sql, args);
 | 
	
		
			
				|  |  | 
 |