|  | @ -4,14 +4,11 @@ import java.util.*;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.consult.ConsultTeam;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.doctor.team.sign.*;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.organization.Hospital;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.dict.SystemDict;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.doctor.profile.Doctor;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroupInfo;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.doctor.profile.DoctorService;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.message.Message;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.patient.Patient;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.patient.PatientDisease;
 | 
	
	
		
			
				|  | @ -91,8 +88,6 @@ public class FamilyContractService extends BaseService {
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private ConsultTeamDao consultTeamDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private JdbcTemplate jdbcTemplate;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private WlyySignFamilyCodeDao wlyySignFamilyCodeDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private SystemDictDao systemDictDao;
 | 
	
	
		
			
				|  | @ -110,6 +105,14 @@ public class FamilyContractService extends BaseService {
 | 
	
		
			
				|  |  |     MessageService messageService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     AdminTeamService adminTeamService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     SignPatientLabelDao labelDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     SignPatientLabelLogDao labelLogDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     SignPatientLabelInfoDao labelInfoDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     JdbcTemplate jdbcTemplate;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public SignFamily findSignFamilyByCode(String code) {
 | 
	
		
			
				|  |  |         return signFamilyDao.findByCodeAndType(code, 2);
 | 
	
	
		
			
				|  | @ -1953,10 +1956,10 @@ public class FamilyContractService extends BaseService {
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(docMap.size() > 0){
 | 
	
		
			
				|  |  |             result.put("teamDoctors",new JSONArray(docMap.values()));
 | 
	
		
			
				|  |  |         if (docMap.size() > 0) {
 | 
	
		
			
				|  |  |             result.put("teamDoctors", new JSONArray(docMap.values()));
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             result.put("teamDoctors",new JSONArray());
 | 
	
		
			
				|  |  |             result.put("teamDoctors", new JSONArray());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return result;
 | 
	
	
		
			
				|  | @ -1978,34 +1981,128 @@ public class FamilyContractService extends BaseService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (ssSign != null) {
 | 
	
		
			
				|  |  |             JSONObject qkDoc = new JSONObject();
 | 
	
		
			
				|  |  |             qkDoc.put("doctor",ssSign.getDoctor());
 | 
	
		
			
				|  |  |             qkDoc.put("doctorName",ssSign.getDoctorName());
 | 
	
		
			
				|  |  |             qkDoc.put("doctor", ssSign.getDoctor());
 | 
	
		
			
				|  |  |             qkDoc.put("doctorName", ssSign.getDoctorName());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             ssArray.put("doctor", qkDoc);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             JSONObject jgDoc = new JSONObject();
 | 
	
		
			
				|  |  |             jgDoc.put("doctor",ssSign.getDoctorHealth());
 | 
	
		
			
				|  |  |             jgDoc.put("doctorName",ssSign.getDoctorHealthName());
 | 
	
		
			
				|  |  |             jgDoc.put("doctor", ssSign.getDoctorHealth());
 | 
	
		
			
				|  |  |             jgDoc.put("doctorName", ssSign.getDoctorHealthName());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             ssArray.put("doctorHealth", jgDoc);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (jtSign != null) {
 | 
	
		
			
				|  |  |             JSONObject qkDoc = new JSONObject();
 | 
	
		
			
				|  |  |             qkDoc.put("doctor",jtSign.getDoctor());
 | 
	
		
			
				|  |  |             qkDoc.put("doctorName",jtSign.getDoctorName());
 | 
	
		
			
				|  |  |             qkDoc.put("doctor", jtSign.getDoctor());
 | 
	
		
			
				|  |  |             qkDoc.put("doctorName", jtSign.getDoctorName());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             jtArray.put("doctor", qkDoc);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             JSONObject jgDoc = new JSONObject();
 | 
	
		
			
				|  |  |             jgDoc.put("doctor",jtSign.getDoctorHealth());
 | 
	
		
			
				|  |  |             jgDoc.put("doctorName",jtSign.getDoctorHealthName());
 | 
	
		
			
				|  |  |             jgDoc.put("doctor", jtSign.getDoctorHealth());
 | 
	
		
			
				|  |  |             jgDoc.put("doctorName", jtSign.getDoctorHealthName());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             jtArray.put("doctorHealth", jgDoc);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         result.put("ssSign",ssArray);
 | 
	
		
			
				|  |  |         result.put("jtSign",jtSign);
 | 
	
		
			
				|  |  |         result.put("ssSign", ssArray);
 | 
	
		
			
				|  |  |         result.put("jtSign", jtSign);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Map<String, List<Patient>> getPatientByLevel(String doctorCode) {
 | 
	
		
			
				|  |  |         Map<String, List<Patient>> returnMap = new HashMap<>();
 | 
	
		
			
				|  |  |         Doctor doctor = doctorDao.findByCode(doctorCode);
 | 
	
		
			
				|  |  |         //判断当前用户是健康管理师还是全科
 | 
	
		
			
				|  |  |         if (doctor.getLevel() == 3) {
 | 
	
		
			
				|  |  |             //健康管理师
 | 
	
		
			
				|  |  |             List<Patient> jkgl = signFamilyDao.findByDoctorHealthPatient(doctorCode);
 | 
	
		
			
				|  |  |             returnMap.put("jk", jkgl);
 | 
	
		
			
				|  |  |         } else if (doctor.getLevel() == 2) {
 | 
	
		
			
				|  |  |             //全科医生
 | 
	
		
			
				|  |  |             List<Patient> qkys = signFamilyDao.findByDoctorPatient(doctorCode);
 | 
	
		
			
				|  |  |             returnMap.put("qk", qkys);
 | 
	
		
			
				|  |  |             //健康管理师
 | 
	
		
			
				|  |  |             List<Patient> jkgl = signFamilyDao.findByDoctorHealthPatient(doctorCode);
 | 
	
		
			
				|  |  |             returnMap.put("jk", jkgl);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return returnMap;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public JSONObject getPatientByLable(String doctorCode, String labelType) throws Exception {
 | 
	
		
			
				|  |  |         JSONObject returnMap = new JSONObject();
 | 
	
		
			
				|  |  |         Doctor doctor = doctorDao.findByCode(doctorCode);
 | 
	
		
			
				|  |  |         //判断当前用户是健康管理师还是全科
 | 
	
		
			
				|  |  |         List<Map<String, Object>> datas = null;
 | 
	
		
			
				|  |  |         if (doctor.getLevel() == 3) {
 | 
	
		
			
				|  |  |             //健康管理师
 | 
	
		
			
				|  |  |             String sql = "SELECT sf. CODE signcode, " +
 | 
	
		
			
				|  |  |                     " p.`name` name, " +
 | 
	
		
			
				|  |  |                     " p. CODE `code`, " +
 | 
	
		
			
				|  |  |                     " case p.openid when null then 0 when \"\" then 0 else 1 end hasopenid, "+
 | 
	
		
			
				|  |  |                     " sp.id labelid, " +
 | 
	
		
			
				|  |  |                     " sp.label_name labelname, " +
 | 
	
		
			
				|  |  |                     " sp.label_type labeltype, "+
 | 
	
		
			
				|  |  |                     " p.idcard idcard " +
 | 
	
		
			
				|  |  |            " FROM " +
 | 
	
		
			
				|  |  |                     " wlyy_sign_family sf, " +
 | 
	
		
			
				|  |  |                     " wlyy_patient p, " +
 | 
	
		
			
				|  |  |                     " wlyy_sign_patient_label_info sp " +
 | 
	
		
			
				|  |  |            " WHERE" +
 | 
	
		
			
				|  |  |                     " sf.patient = p.CODE " +
 | 
	
		
			
				|  |  |                     " AND p. CODE = sp.patient " +
 | 
	
		
			
				|  |  |                     " AND sf.type = 2 " +
 | 
	
		
			
				|  |  |                     " AND sf. STATUS >= 0 " +
 | 
	
		
			
				|  |  |                     " and sp.`status`=1 " +
 | 
	
		
			
				|  |  |                     " and sf.doctor_health = ? " +
 | 
	
		
			
				|  |  |                     " and sp.label_type= ?";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //查找居民
 | 
	
		
			
				|  |  |             datas = jdbcTemplate.queryForList(sql, doctorCode, labelType);
 | 
	
		
			
				|  |  |         } else if (doctor.getLevel() == 2) {
 | 
	
		
			
				|  |  |             //健康管理师
 | 
	
		
			
				|  |  |             String sql = "SELECT sf. CODE signcode, " +
 | 
	
		
			
				|  |  |                     " p.`name` name, " +
 | 
	
		
			
				|  |  |                     " p. CODE `code`, " +
 | 
	
		
			
				|  |  |                     " sp.id labelid, " +
 | 
	
		
			
				|  |  |                     " sp.label_name labelname, " +
 | 
	
		
			
				|  |  |                     " case p.openid when null then 0 when \"\" then 0 else 1 end hasopenid, "+
 | 
	
		
			
				|  |  |                     " sp.label_type labeltype, "+
 | 
	
		
			
				|  |  |                     " p.idcard idcard " +
 | 
	
		
			
				|  |  |             " FROM " +
 | 
	
		
			
				|  |  |                     " wlyy_sign_family sf, " +
 | 
	
		
			
				|  |  |                     " wlyy_patient p, " +
 | 
	
		
			
				|  |  |                     " wlyy_sign_patient_label_info sp " +
 | 
	
		
			
				|  |  |             " WHERE" +
 | 
	
		
			
				|  |  |                     " sf.patient = p.CODE " +
 | 
	
		
			
				|  |  |                     " AND p. CODE = sp.patient " +
 | 
	
		
			
				|  |  |                     " AND sf.type = 2 " +
 | 
	
		
			
				|  |  |                     " AND sf. STATUS >= 0 " +
 | 
	
		
			
				|  |  |                     " and sp.`status`=1 " +
 | 
	
		
			
				|  |  |                     " and ( sf.doctor = ? or sf.doctor_health = ? ) " +
 | 
	
		
			
				|  |  |                     " and sp.label_type= ?";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //查找居民
 | 
	
		
			
				|  |  |             datas = jdbcTemplate.queryForList(sql, doctorCode,doctorCode, labelType);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             throw new Exception("参数错误");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //根据类别查找标签
 | 
	
		
			
				|  |  |         List<SignPatientLabel> s = labelDao.findByLabelTypeAndStatus(labelType, 1);
 | 
	
		
			
				|  |  |         if (s != null && s.size() > 0) {
 | 
	
		
			
				|  |  |             for (SignPatientLabel one : s) {
 | 
	
		
			
				|  |  |                 returnMap.put(one.getLabelCode(), new JSONArray());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (datas != null && datas.size() > 0) {
 | 
	
		
			
				|  |  |                 for (Map<String, Object> map : datas) {
 | 
	
		
			
				|  |  |                     JSONObject jo=new JSONObject(map);
 | 
	
		
			
				|  |  |                     returnMap.getJSONArray(jo.get("labeltype").toString()).put(jo);;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return returnMap;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |