|  | @ -52,15 +52,16 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 预约协诊
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param doctor
 | 
	
		
			
				|  |  |      * @param doctorName
 | 
	
		
			
				|  |  |      * @param sendTime
 | 
	
		
			
				|  |  |      * @param planDetailId
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public ObjEnvelop appointmentConsultation(String patient,String doctor, String doctorName,
 | 
	
		
			
				|  |  |             String appointmentDoctor,String appointmentDoctorName,String sendTime, String planDetailId){
 | 
	
		
			
				|  |  |     public ObjEnvelop appointmentConsultation(String patient, String doctor, String doctorName,
 | 
	
		
			
				|  |  |                                               String appointmentDoctor, String appointmentDoctorName, String sendTime, String planDetailId) {
 | 
	
		
			
				|  |  |         RehabilitationDetailAppointmentDO appointment = new RehabilitationDetailAppointmentDO();
 | 
	
		
			
				|  |  |         appointment.setAppointmentTime(sendTime+":00");
 | 
	
		
			
				|  |  |         appointment.setAppointmentTime(sendTime + ":00");
 | 
	
		
			
				|  |  |         appointment.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         appointment.setDoctor(doctor);
 | 
	
		
			
				|  |  |         appointment.setDoctorName(doctorName);
 | 
	
	
		
			
				|  | @ -71,12 +72,13 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |         appointment.setPatient(patient);
 | 
	
		
			
				|  |  |         rehabilitationDetailAppointmentDao.save(appointment);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess("获取成功",appointment);
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess("获取成功", appointment);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 康复管理(专科)-- 计划列表
 | 
	
		
			
				|  |  |      * @param doctorType 1.专科,2.家医
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param doctorType   1.专科,2.家医
 | 
	
		
			
				|  |  |      * @param doctorCode
 | 
	
		
			
				|  |  |      * @param diseaseCode
 | 
	
		
			
				|  |  |      * @param planType
 | 
	
	
		
			
				|  | @ -86,150 +88,155 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public MixEnvelop<Map<String,Object>, Map<String,Object>> findRehabilitationPlan(Integer doctorType,String doctorCode, String diseaseCode, Integer planType,Integer todaybacklog, String patientCondition,Integer page, Integer pageSize) throws Exception{
 | 
	
		
			
				|  |  |     public MixEnvelop<Map<String, Object>, Map<String, Object>> findRehabilitationPlan(Integer doctorType, String doctorCode, String diseaseCode, Integer planType, Integer todaybacklog, String patientCondition, Integer page, Integer pageSize) throws Exception {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String sql = " select DISTINCT p.* " +
 | 
	
		
			
				|  |  |                 " from wlyy_specialist.wlyy_rehabilitation_plan_detail a INNER JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p " +
 | 
	
		
			
				|  |  |                 " on a.plan_id = p.id  " ;
 | 
	
		
			
				|  |  |         if(doctorType==2){//家医是根据签约关系过滤
 | 
	
		
			
				|  |  |             sql+=" INNER JOIN wlyy.wlyy_sign_family f ON f.patient = p.patient \n" +
 | 
	
		
			
				|  |  |                 " on a.plan_id = p.id  ";
 | 
	
		
			
				|  |  |         if (doctorType == 2) {//家医是根据签约关系过滤
 | 
	
		
			
				|  |  |             sql += " INNER JOIN wlyy.wlyy_sign_family f ON f.patient = p.patient \n" +
 | 
	
		
			
				|  |  |                     "\tand f.expenses_status=1\n" +
 | 
	
		
			
				|  |  |                     "\tAND f.STATUS >= 1 \n" +
 | 
	
		
			
				|  |  |                     "\tAND ( f.doctor = '"+doctorCode+"' OR f.doctor_health = '"+doctorCode+"' )  ";
 | 
	
		
			
				|  |  |                     "\tAND ( f.doctor = '" + doctorCode + "' OR f.doctor_health = '" + doctorCode + "' )  ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         sql += " where 1=1 ";
 | 
	
		
			
				|  |  |         if(todaybacklog!=null&&todaybacklog==1){
 | 
	
		
			
				|  |  |             String todayStart = DateUtil.getStringDateShort()+" "+"00:00:00";
 | 
	
		
			
				|  |  |             String todayEnd = DateUtil.getStringDateShort()+" "+"23:59:59";
 | 
	
		
			
				|  |  |             sql += " and a.execute_time>='"+todayStart+"' and a.execute_time<='"+todayEnd+"'";
 | 
	
		
			
				|  |  |         if (todaybacklog != null && todaybacklog == 1) {
 | 
	
		
			
				|  |  |             String todayStart = DateUtil.getStringDateShort() + " " + "00:00:00";
 | 
	
		
			
				|  |  |             String todayEnd = DateUtil.getStringDateShort() + " " + "23:59:59";
 | 
	
		
			
				|  |  |             sql += " and a.execute_time>='" + todayStart + "' and a.execute_time<='" + todayEnd + "'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(planType!=null){
 | 
	
		
			
				|  |  |             sql += " and p.plan_type="+planType;
 | 
	
		
			
				|  |  |         if (planType != null) {
 | 
	
		
			
				|  |  |             sql += " and p.plan_type=" + planType;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotEmpty(diseaseCode)){
 | 
	
		
			
				|  |  |             sql+=" and p.disease='"+diseaseCode+"'";
 | 
	
		
			
				|  |  |         if (StringUtils.isNotEmpty(diseaseCode)) {
 | 
	
		
			
				|  |  |             sql += " and p.disease='" + diseaseCode + "'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotEmpty(patientCondition)){//姓名idcard模糊查询
 | 
	
		
			
				|  |  |             sql +=" AND EXISTS (select code from wlyy.wlyy_patient where  `code` = p.patient and ( `name` LIKE '%"+patientCondition+"%' or idcard like '%"+patientCondition+"%') )";
 | 
	
		
			
				|  |  |         if (StringUtils.isNotEmpty(patientCondition)) {//姓名idcard模糊查询
 | 
	
		
			
				|  |  |             sql += " AND EXISTS (select code from wlyy.wlyy_patient where  `code` = p.patient and ( `name` LIKE '%" + patientCondition + "%' or idcard like '%" + patientCondition + "%') )";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (doctorType==1){
 | 
	
		
			
				|  |  |             sql +=" AND (p.create_user = '"+doctorCode+"' \n" +
 | 
	
		
			
				|  |  |                     "\tOR a.doctor = '"+doctorCode+"' ) ";
 | 
	
		
			
				|  |  |         if (doctorType == 1) {
 | 
	
		
			
				|  |  |             sql += " AND (p.create_user = '" + doctorCode + "' \n" +
 | 
	
		
			
				|  |  |                     "\tOR a.doctor = '" + doctorCode + "' ) ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         sql = TransforSqlUtl.wlyy_patient_rehabilitation_planAll2(sql);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         int count = 0;
 | 
	
		
			
				|  |  |         if(rstotal!=null&&rstotal.size()>0&&rstotal.get(0).get("id")!=null){
 | 
	
		
			
				|  |  |         if (rstotal != null && rstotal.size() > 0 && rstotal.get(0).get("id") != null) {
 | 
	
		
			
				|  |  |             count = rstotal.size();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         sql += " ORDER BY p.create_time DESC LIMIT "+(page-1)*pageSize+","+pageSize;
 | 
	
		
			
				|  |  |         List<Map<String,Object>> patientRehabilitationPlanDOList = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> resultList = new ArrayList<>();
 | 
	
		
			
				|  |  |         if(patientRehabilitationPlanDOList.size()>0&&patientRehabilitationPlanDOList.get(0).get("id")!=null){
 | 
	
		
			
				|  |  |         sql += " ORDER BY p.create_time DESC LIMIT " + (page - 1) * pageSize + "," + pageSize;
 | 
	
		
			
				|  |  |         List<Map<String, Object>> patientRehabilitationPlanDOList = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         List<Map<String, Object>> resultList = new ArrayList<>();
 | 
	
		
			
				|  |  |         if (patientRehabilitationPlanDOList.size() > 0 && patientRehabilitationPlanDOList.get(0).get("id") != null) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             for(Map<String,Object> one:patientRehabilitationPlanDOList){
 | 
	
		
			
				|  |  |                 Map<String,Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  |             for (Map<String, Object> one : patientRehabilitationPlanDOList) {
 | 
	
		
			
				|  |  |                 Map<String, Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  | //                Integer age = IdCardUtil.getAgeForIdcard(one.get("idcard")+"");
 | 
	
		
			
				|  |  | //                String sex = IdCardUtil.getSexForIdcard_new(one.get("idcard")+"");
 | 
	
		
			
				|  |  | //                resultMap.put("age",age);
 | 
	
		
			
				|  |  |                 resultMap.put("hospitalName",one.get("hospital_name"));
 | 
	
		
			
				|  |  |                 resultMap.put("hospitalName", one.get("hospital_name"));
 | 
	
		
			
				|  |  | //                resultMap.put("sex","1".equals(sex)?"男":("2".equals(sex)?"女":"未知"));
 | 
	
		
			
				|  |  |                 resultMap.put("patientName",one.get("patientName"));
 | 
	
		
			
				|  |  |                 resultMap.put("patientCode",one.get("patient"));
 | 
	
		
			
				|  |  |                 resultMap.put("id",one.get("id"));
 | 
	
		
			
				|  |  |                 resultMap.put("status",one.get("status"));//康复计划状态
 | 
	
		
			
				|  |  |                 resultMap.put("patientName", one.get("patientName"));
 | 
	
		
			
				|  |  |                 resultMap.put("patientCode", one.get("patient"));
 | 
	
		
			
				|  |  |                 resultMap.put("id", one.get("id"));
 | 
	
		
			
				|  |  |                 resultMap.put("status", one.get("status"));//康复计划状态
 | 
	
		
			
				|  |  |                 //健康情况
 | 
	
		
			
				|  |  |                 String healthyConditionSql =" select  label_name,label from "+basedb+".wlyy_sign_patient_label_info where status=1 and patient='"+one.get("patient")+"' and label_type=8";
 | 
	
		
			
				|  |  |                 List<Map<String,Object>> healthyConditionList = jdbcTemplate.queryForList(healthyConditionSql);
 | 
	
		
			
				|  |  |                 String healthyCondition = healthyConditionList.size()>0?healthyConditionList.get(0).get("label_name")+"":"";
 | 
	
		
			
				|  |  |                 String healthyConditionType = healthyConditionList.size()>0?healthyConditionList.get(0).get("label")+"":"";
 | 
	
		
			
				|  |  |                 resultMap.put("healthyCondition",healthyCondition);
 | 
	
		
			
				|  |  |                 resultMap.put("healthyConditionType",healthyConditionType);
 | 
	
		
			
				|  |  |                 String healthyConditionSql = " select  label_name,label from " + basedb + ".wlyy_sign_patient_label_info where status=1 and patient='" + one.get("patient") + "' and label_type=8";
 | 
	
		
			
				|  |  |                 List<Map<String, Object>> healthyConditionList = jdbcTemplate.queryForList(healthyConditionSql);
 | 
	
		
			
				|  |  |                 String healthyCondition = healthyConditionList.size() > 0 ? healthyConditionList.get(0).get("label_name") + "" : "";
 | 
	
		
			
				|  |  |                 String healthyConditionType = healthyConditionList.size() > 0 ? healthyConditionList.get(0).get("label") + "" : "";
 | 
	
		
			
				|  |  |                 resultMap.put("healthyCondition", healthyCondition);
 | 
	
		
			
				|  |  |                 resultMap.put("healthyConditionType", healthyConditionType);
 | 
	
		
			
				|  |  |                 //安排类型
 | 
	
		
			
				|  |  |                 String planTypeName = null;
 | 
	
		
			
				|  |  |                 Integer planTypeTemp = (Integer)one.get("plan_type");
 | 
	
		
			
				|  |  |                 switch (planTypeTemp){
 | 
	
		
			
				|  |  |                     case 1:planTypeName="康复计划" ;break;
 | 
	
		
			
				|  |  |                     case 2:planTypeName="(转)社区医院" ;break;
 | 
	
		
			
				|  |  |                     case 3:planTypeName="(转)转家庭病床" ;break;
 | 
	
		
			
				|  |  |                 Integer planTypeTemp = (Integer) one.get("plan_type");
 | 
	
		
			
				|  |  |                 switch (planTypeTemp) {
 | 
	
		
			
				|  |  |                     case 1:
 | 
	
		
			
				|  |  |                         planTypeName = "康复计划";
 | 
	
		
			
				|  |  |                         break;
 | 
	
		
			
				|  |  |                     case 2:
 | 
	
		
			
				|  |  |                         planTypeName = "(转)社区医院";
 | 
	
		
			
				|  |  |                         break;
 | 
	
		
			
				|  |  |                     case 3:
 | 
	
		
			
				|  |  |                         planTypeName = "(转)转家庭病床";
 | 
	
		
			
				|  |  |                         break;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 resultMap.put("planTypeName",planTypeName);
 | 
	
		
			
				|  |  |                 resultMap.put("planCreateUser",one.get("create_user"));
 | 
	
		
			
				|  |  |                 resultMap.put("planTypeName", planTypeName);
 | 
	
		
			
				|  |  |                 resultMap.put("planCreateUser", one.get("create_user"));
 | 
	
		
			
				|  |  |                 //今日待办(即今日全部的项目)
 | 
	
		
			
				|  |  |                 Date beginTime = DateUtil.strToDateLong(DateUtil.getStringDateShort()+ " "+"00:00:00");
 | 
	
		
			
				|  |  |                 Date endTime = DateUtil.strToDateLong(DateUtil.getStringDateShort()+ " "+"23:59:59");
 | 
	
		
			
				|  |  |                 Integer todayBacklogCount = rehabilitationDetailDao.todayBacklogCount(one.get("id").toString(),beginTime,endTime);
 | 
	
		
			
				|  |  |                 resultMap.put("todayBacklogCount",todayBacklogCount);//今日待办总数
 | 
	
		
			
				|  |  |                 Date beginTime = DateUtil.strToDateLong(DateUtil.getStringDateShort() + " " + "00:00:00");
 | 
	
		
			
				|  |  |                 Date endTime = DateUtil.strToDateLong(DateUtil.getStringDateShort() + " " + "23:59:59");
 | 
	
		
			
				|  |  |                 Integer todayBacklogCount = rehabilitationDetailDao.todayBacklogCount(one.get("id").toString(), beginTime, endTime);
 | 
	
		
			
				|  |  |                 resultMap.put("todayBacklogCount", todayBacklogCount);//今日待办总数
 | 
	
		
			
				|  |  |                 //已完成
 | 
	
		
			
				|  |  |                 Integer finishedCount = rehabilitationDetailDao.completenessCount(1,one.get("id").toString(),beginTime,endTime);
 | 
	
		
			
				|  |  |                 resultMap.put("finishedCount",finishedCount);//已完成
 | 
	
		
			
				|  |  |                 Integer finishedCount = rehabilitationDetailDao.completenessCount(1, one.get("id").toString(), beginTime, endTime);
 | 
	
		
			
				|  |  |                 resultMap.put("finishedCount", finishedCount);//已完成
 | 
	
		
			
				|  |  |                 //未完成
 | 
	
		
			
				|  |  |                 Integer notstartedCount = rehabilitationDetailDao.completenessCount(0,one.get("id").toString(),beginTime,endTime);//未开始
 | 
	
		
			
				|  |  |                 Integer underwayCount = rehabilitationDetailDao.completenessCount(2,one.get("id").toString(),beginTime,endTime);//已预约
 | 
	
		
			
				|  |  |                 Integer unfinishedCount = notstartedCount+underwayCount;
 | 
	
		
			
				|  |  |                 resultMap.put("unfinishedCount",unfinishedCount);//未完成
 | 
	
		
			
				|  |  |                 Integer notstartedCount = rehabilitationDetailDao.completenessCount(0, one.get("id").toString(), beginTime, endTime);//未开始
 | 
	
		
			
				|  |  |                 Integer underwayCount = rehabilitationDetailDao.completenessCount(2, one.get("id").toString(), beginTime, endTime);//已预约
 | 
	
		
			
				|  |  |                 Integer unfinishedCount = notstartedCount + underwayCount;
 | 
	
		
			
				|  |  |                 resultMap.put("unfinishedCount", unfinishedCount);//未完成
 | 
	
		
			
				|  |  |                 //完成度(已完成/(已完成+未完成))
 | 
	
		
			
				|  |  |                 Integer allFinishCount = rehabilitationDetailDao.findByStatusAndPlanId(1,one.get("id").toString());
 | 
	
		
			
				|  |  |                 Integer allFinishCount = rehabilitationDetailDao.findByStatusAndPlanId(1, one.get("id").toString());
 | 
	
		
			
				|  |  |                 Integer allCount = rehabilitationDetailDao.findAllByPlanId(one.get("id").toString());
 | 
	
		
			
				|  |  |                 resultMap.put("allCount",allCount);//总数
 | 
	
		
			
				|  |  |                 resultMap.put("allFinishCount",allFinishCount);//全部已完成数
 | 
	
		
			
				|  |  |                 resultMap.put("createTime",one.get("create_time"));
 | 
	
		
			
				|  |  |                 resultMap.put("allCount", allCount);//总数
 | 
	
		
			
				|  |  |                 resultMap.put("allFinishCount", allFinishCount);//全部已完成数
 | 
	
		
			
				|  |  |                 resultMap.put("createTime", one.get("create_time"));
 | 
	
		
			
				|  |  |                 resultList.add(resultMap);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return MixEnvelop.getSuccessListWithPage(SpecialistMapping.api_success,resultList,page,pageSize,Long.valueOf(count));
 | 
	
		
			
				|  |  |         return MixEnvelop.getSuccessListWithPage(SpecialistMapping.api_success, resultList, page, pageSize, Long.valueOf(count));
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 康复管理更多计划
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param currentDoctorCode
 | 
	
		
			
				|  |  |      * @param patientCode
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public ObjEnvelop findRehabilitationPlanDetailList(String currentDoctorCode,String patientCode) throws Exception{
 | 
	
		
			
				|  |  |         String sql = " select DISTINCT r.* from wlyy_specialist.wlyy_specialist_patient_relation r join wlyy_patient_rehabilitation_plan p on r.patient=p.patient where r.sign_status ='1' and r.status in('0','1') and r.patient='"+patientCode+"' ";
 | 
	
		
			
				|  |  |     public ObjEnvelop findRehabilitationPlanDetailList(String currentDoctorCode, String patientCode) throws Exception {
 | 
	
		
			
				|  |  |         String sql = " select DISTINCT r.* from wlyy_specialist.wlyy_specialist_patient_relation r join wlyy_patient_rehabilitation_plan p on r.patient=p.patient where r.sign_status ='1' and r.status in('0','1') and r.patient='" + patientCode + "' ";
 | 
	
		
			
				|  |  |         sql = TransforSqlUtl.specialistPatientRelationAll2(sql);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> specialistPatientRelationList = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> resultList = new ArrayList<>();
 | 
	
		
			
				|  |  |         for(Map<String,Object> temp: specialistPatientRelationList){
 | 
	
		
			
				|  |  |             String doctorCode = temp.get("doctor")+"";
 | 
	
		
			
				|  |  |             Map<String,Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  |         List<Map<String, Object>> specialistPatientRelationList = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         List<Map<String, Object>> resultList = new ArrayList<>();
 | 
	
		
			
				|  |  |         for (Map<String, Object> temp : specialistPatientRelationList) {
 | 
	
		
			
				|  |  |             String doctorCode = temp.get("doctor") + "";
 | 
	
		
			
				|  |  |             Map<String, Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  |             Integer isOperator = 0;
 | 
	
		
			
				|  |  |             resultMap.put("patientCode",patientCode);//居民code
 | 
	
		
			
				|  |  |             String healthyConditionSql =" select  label_name,label from "+basedb+".wlyy_sign_patient_label_info where status=1 and patient='"+patientCode+"' and label_type=8";
 | 
	
		
			
				|  |  |             List<Map<String,Object>> healthyConditionList = jdbcTemplate.queryForList(healthyConditionSql);
 | 
	
		
			
				|  |  |             String healthyCondition = healthyConditionList.size()>0?healthyConditionList.get(0).get("label_name")+"":"";
 | 
	
		
			
				|  |  |             String healthyConditionType = healthyConditionList.size()>0?healthyConditionList.get(0).get("label")+"":"";
 | 
	
		
			
				|  |  |             resultMap.put("healthyCondition",healthyCondition);
 | 
	
		
			
				|  |  |             resultMap.put("healthyConditionType",healthyConditionType);
 | 
	
		
			
				|  |  |             resultMap.put("patientCode", patientCode);//居民code
 | 
	
		
			
				|  |  |             String healthyConditionSql = " select  label_name,label from " + basedb + ".wlyy_sign_patient_label_info where status=1 and patient='" + patientCode + "' and label_type=8";
 | 
	
		
			
				|  |  |             List<Map<String, Object>> healthyConditionList = jdbcTemplate.queryForList(healthyConditionSql);
 | 
	
		
			
				|  |  |             String healthyCondition = healthyConditionList.size() > 0 ? healthyConditionList.get(0).get("label_name") + "" : "";
 | 
	
		
			
				|  |  |             String healthyConditionType = healthyConditionList.size() > 0 ? healthyConditionList.get(0).get("label") + "" : "";
 | 
	
		
			
				|  |  |             resultMap.put("healthyCondition", healthyCondition);
 | 
	
		
			
				|  |  |             resultMap.put("healthyConditionType", healthyConditionType);
 | 
	
		
			
				|  |  |             //专科医生
 | 
	
		
			
				|  |  |             String specialistRelationSql = "select r.*,t.name as teamName,h.name as specialistHospitalName from wlyy_specialist.wlyy_specialist_patient_relation r left join "+basedb+".wlyy_admin_team t on r.team_code=t.id left join "+basedb+".dm_hospital h on t.org_code=h.code where r.sign_status ='1' and r.status in('0','1') and r.patient='"+patientCode+"' and r.doctor='"+doctorCode+"'";
 | 
	
		
			
				|  |  |             String specialistRelationSql = "select r.*,t.name as teamName,h.name as specialistHospitalName from wlyy_specialist.wlyy_specialist_patient_relation r left join " + basedb + ".wlyy_admin_team t on r.team_code=t.id left join " + basedb + ".dm_hospital h on t.org_code=h.code where r.sign_status ='1' and r.status in('0','1') and r.patient='" + patientCode + "' and r.doctor='" + doctorCode + "'";
 | 
	
		
			
				|  |  |             specialistRelationSql = TransforSqlUtl.specialistPatientRelationAll2(specialistRelationSql);
 | 
	
		
			
				|  |  |             List<Map<String,Object>> specialistRelationList = jdbcTemplate.queryForList(specialistRelationSql);
 | 
	
		
			
				|  |  |             Map<String,Object> specialistMap = specialistRelationList.get(0);
 | 
	
		
			
				|  |  |             resultMap.put("specialistAdminTeamName",specialistMap.get("teamName"));
 | 
	
		
			
				|  |  |             resultMap.put("specialistHospitalName",specialistMap.get("specialistHospitalName"));//专科医生所在医院
 | 
	
		
			
				|  |  |             List<Map<String, Object>> specialistRelationList = jdbcTemplate.queryForList(specialistRelationSql);
 | 
	
		
			
				|  |  |             Map<String, Object> specialistMap = specialistRelationList.get(0);
 | 
	
		
			
				|  |  |             resultMap.put("specialistAdminTeamName", specialistMap.get("teamName"));
 | 
	
		
			
				|  |  |             resultMap.put("specialistHospitalName", specialistMap.get("specialistHospitalName"));//专科医生所在医院
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Integer specialistUnfinishCount1 = rehabilitationDetailDao.unfinishItemByDoctor(doctorCode,patientCode,1);
 | 
	
		
			
				|  |  |             Integer specialistFinishCount1 = rehabilitationDetailDao.findItemByDoctor(doctorCode,patientCode);
 | 
	
		
			
				|  |  |             Integer specialistServiceCount1 = rehabilitationDetailDao.completeServiceByDoctor(doctorCode,patientCode,1);
 | 
	
		
			
				|  |  |             Integer specialistUnfinishCount1 = rehabilitationDetailDao.unfinishItemByDoctor(doctorCode, patientCode, 1);
 | 
	
		
			
				|  |  |             Integer specialistFinishCount1 = rehabilitationDetailDao.findItemByDoctor(doctorCode, patientCode);
 | 
	
		
			
				|  |  |             Integer specialistServiceCount1 = rehabilitationDetailDao.completeServiceByDoctor(doctorCode, patientCode, 1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Integer specialistUnfinishCount2 = rehabilitationDetailDao.unfinishItemByDoctor(specialistMap.get("health_assistant")+"",patientCode,1);
 | 
	
		
			
				|  |  |             Integer specialistFinishCount2 = rehabilitationDetailDao.findItemByDoctor(specialistMap.get("health_assistant")+"",patientCode);
 | 
	
		
			
				|  |  |             Integer specialistServiceCount2 = rehabilitationDetailDao.completeServiceByDoctor(specialistMap.get("health_assistant")+"",patientCode,1);
 | 
	
		
			
				|  |  |             Integer specialistUnfinishCount2 = rehabilitationDetailDao.unfinishItemByDoctor(specialistMap.get("health_assistant") + "", patientCode, 1);
 | 
	
		
			
				|  |  |             Integer specialistFinishCount2 = rehabilitationDetailDao.findItemByDoctor(specialistMap.get("health_assistant") + "", patientCode);
 | 
	
		
			
				|  |  |             Integer specialistServiceCount2 = rehabilitationDetailDao.completeServiceByDoctor(specialistMap.get("health_assistant") + "", patientCode, 1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             resultMap.put("specialistFinishItemCount",specialistFinishCount1-specialistUnfinishCount1+specialistFinishCount2-specialistUnfinishCount2);//完成项目
 | 
	
		
			
				|  |  |             resultMap.put("specialistServiceRecordCount",specialistServiceCount1+specialistServiceCount2);//服务次数
 | 
	
		
			
				|  |  |             resultMap.put("specialistFinishItemCount", specialistFinishCount1 - specialistUnfinishCount1 + specialistFinishCount2 - specialistUnfinishCount2);//完成项目
 | 
	
		
			
				|  |  |             resultMap.put("specialistServiceRecordCount", specialistServiceCount1 + specialistServiceCount2);//服务次数
 | 
	
		
			
				|  |  |             //家庭医生(包括全科医生、健管师)
 | 
	
		
			
				|  |  |             String signFamilySql = "SELECT f.*,t.name as teamName FROM "+basedb+".wlyy_sign_family f LEFT JOIN "+basedb+".wlyy_admin_team t on f.admin_team_code=t.id where f.status =1 and f.expenses_status='1' and f.patient='"+patientCode+"'";
 | 
	
		
			
				|  |  |             List<Map<String,Object>> signFamilyList = jdbcTemplate.queryForList(signFamilySql);
 | 
	
		
			
				|  |  |             if(signFamilyList != null && signFamilyList.size() >0 ) {
 | 
	
		
			
				|  |  |             String signFamilySql = "SELECT f.*,t.name as teamName FROM " + basedb + ".wlyy_sign_family f LEFT JOIN " + basedb + ".wlyy_admin_team t on f.admin_team_code=t.id where f.status =1 and f.expenses_status='1' and f.patient='" + patientCode + "'";
 | 
	
		
			
				|  |  |             List<Map<String, Object>> signFamilyList = jdbcTemplate.queryForList(signFamilySql);
 | 
	
		
			
				|  |  |             if (signFamilyList != null && signFamilyList.size() > 0) {
 | 
	
		
			
				|  |  |                 Map<String, Object> signFamilyMap = signFamilyList.get(0);
 | 
	
		
			
				|  |  |                 resultMap.put("signFamilyAdminTeamName", signFamilyMap.get("teamName"));
 | 
	
		
			
				|  |  |                 resultMap.put("familyHospitalName", signFamilyMap.get("hospital_name"));//家庭医生所在医院
 | 
	
	
		
			
				|  | @ -258,198 +265,205 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |                 resultMap.put("patientName", signFamilyMap.get("patientName"));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //疾病类型
 | 
	
		
			
				|  |  |             String diseaseSql = " select s.* from "+basedb+".wlyy_patient_disease_server s where s.del=1 and s.patient='"+patientCode+"' and s.specialist_relation_code='"+specialistMap.get("id")+"' ";
 | 
	
		
			
				|  |  |             List<Map<String,Object>> diseaseList = jdbcTemplate.queryForList(diseaseSql);
 | 
	
		
			
				|  |  |             String diseaseSql = " select s.* from " + basedb + ".wlyy_patient_disease_server s where s.del=1 and s.patient='" + patientCode + "' and s.specialist_relation_code='" + specialistMap.get("id") + "' ";
 | 
	
		
			
				|  |  |             List<Map<String, Object>> diseaseList = jdbcTemplate.queryForList(diseaseSql);
 | 
	
		
			
				|  |  |             List<String> disease = new ArrayList<>();
 | 
	
		
			
				|  |  |             for(Map<String,Object> one2:diseaseList){
 | 
	
		
			
				|  |  |                 disease.add(one2.get("disease_name")+"");
 | 
	
		
			
				|  |  |             for (Map<String, Object> one2 : diseaseList) {
 | 
	
		
			
				|  |  |                 disease.add(one2.get("disease_name") + "");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             resultMap.put("diseaseList",disease);
 | 
	
		
			
				|  |  |             resultMap.put("diseaseList", disease);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //计划列表
 | 
	
		
			
				|  |  |             List<PatientRehabilitationPlanDO> list = patientRehabilitationPlanDao.findByPatientAndCreateUser(patientCode,doctorCode);
 | 
	
		
			
				|  |  |             List<Map<String,Object>> rehabilitationPlanList = new ArrayList<>();
 | 
	
		
			
				|  |  |             for(PatientRehabilitationPlanDO one:list){
 | 
	
		
			
				|  |  |                 Map<String,Object> planMap = new HashMap<>();
 | 
	
		
			
				|  |  |                 planMap.put("planId",one.getId());
 | 
	
		
			
				|  |  |             List<PatientRehabilitationPlanDO> list = patientRehabilitationPlanDao.findByPatientAndCreateUser(patientCode, doctorCode);
 | 
	
		
			
				|  |  |             List<Map<String, Object>> rehabilitationPlanList = new ArrayList<>();
 | 
	
		
			
				|  |  |             for (PatientRehabilitationPlanDO one : list) {
 | 
	
		
			
				|  |  |                 Map<String, Object> planMap = new HashMap<>();
 | 
	
		
			
				|  |  |                 planMap.put("planId", one.getId());
 | 
	
		
			
				|  |  |                 //安排类型
 | 
	
		
			
				|  |  |                 String planTypeName = null;
 | 
	
		
			
				|  |  |                 Integer planTypeTemp = one.getPlanType();
 | 
	
		
			
				|  |  |                 switch (planTypeTemp){
 | 
	
		
			
				|  |  |                     case 1:planTypeName="康复计划" ;break;
 | 
	
		
			
				|  |  |                     case 2:planTypeName="(转)社区医院" ;break;
 | 
	
		
			
				|  |  |                     case 3:planTypeName="(转)转家庭病床" ;break;
 | 
	
		
			
				|  |  |                 switch (planTypeTemp) {
 | 
	
		
			
				|  |  |                     case 1:
 | 
	
		
			
				|  |  |                         planTypeName = "康复计划";
 | 
	
		
			
				|  |  |                         break;
 | 
	
		
			
				|  |  |                     case 2:
 | 
	
		
			
				|  |  |                         planTypeName = "(转)社区医院";
 | 
	
		
			
				|  |  |                         break;
 | 
	
		
			
				|  |  |                     case 3:
 | 
	
		
			
				|  |  |                         planTypeName = "(转)转家庭病床";
 | 
	
		
			
				|  |  |                         break;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 planMap.put("planTypeName",planTypeName);
 | 
	
		
			
				|  |  |                 planMap.put("status",one.getStatus());//0已中止,1进行中,2已完成
 | 
	
		
			
				|  |  |                 if(currentDoctorCode.equals(doctorCode)){
 | 
	
		
			
				|  |  |                 planMap.put("planTypeName", planTypeName);
 | 
	
		
			
				|  |  |                 planMap.put("status", one.getStatus());//0已中止,1进行中,2已完成
 | 
	
		
			
				|  |  |                 if (currentDoctorCode.equals(doctorCode)) {
 | 
	
		
			
				|  |  |                     isOperator = 1;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 planMap.put("isOperator",isOperator);
 | 
	
		
			
				|  |  |                 planMap.put("isOperator", isOperator);
 | 
	
		
			
				|  |  |                 //状态(0未完成,1已完成,2已预约)
 | 
	
		
			
				|  |  |                 //今日待办
 | 
	
		
			
				|  |  |                 Date beginTime = DateUtil.strToDateLong(DateUtil.getStringDateShort()+ " "+"00:00:00");
 | 
	
		
			
				|  |  |                 Date endTime = DateUtil.strToDateLong(DateUtil.getStringDateShort()+ " "+"23:59:59");
 | 
	
		
			
				|  |  |                 Integer todayBacklogCount = rehabilitationDetailDao.todayBacklogCount(one.getId(),beginTime,endTime);
 | 
	
		
			
				|  |  |                 planMap.put("todayBacklogCount",todayBacklogCount);
 | 
	
		
			
				|  |  |                 Date beginTime = DateUtil.strToDateLong(DateUtil.getStringDateShort() + " " + "00:00:00");
 | 
	
		
			
				|  |  |                 Date endTime = DateUtil.strToDateLong(DateUtil.getStringDateShort() + " " + "23:59:59");
 | 
	
		
			
				|  |  |                 Integer todayBacklogCount = rehabilitationDetailDao.todayBacklogCount(one.getId(), beginTime, endTime);
 | 
	
		
			
				|  |  |                 planMap.put("todayBacklogCount", todayBacklogCount);
 | 
	
		
			
				|  |  |                 //已完成
 | 
	
		
			
				|  |  |                 Integer finishedCount = rehabilitationDetailDao.completenessCount(1,one.getId(),beginTime,endTime);
 | 
	
		
			
				|  |  |                 planMap.put("finishedCount",finishedCount);//已完成
 | 
	
		
			
				|  |  |                 Integer finishedCount = rehabilitationDetailDao.completenessCount(1, one.getId(), beginTime, endTime);
 | 
	
		
			
				|  |  |                 planMap.put("finishedCount", finishedCount);//已完成
 | 
	
		
			
				|  |  |                 //未完成
 | 
	
		
			
				|  |  |                 Integer notstartedCount = rehabilitationDetailDao.completenessCount(0,one.getId(),beginTime,endTime);//未完成
 | 
	
		
			
				|  |  |                 Integer underwayCount = rehabilitationDetailDao.completenessCount(2,one.getId(),beginTime,endTime);//已预约
 | 
	
		
			
				|  |  |                 Integer unfinishedCount = notstartedCount+underwayCount;
 | 
	
		
			
				|  |  |                 planMap.put("unfinishedCount",unfinishedCount);//未完成
 | 
	
		
			
				|  |  |                 Integer notstartedCount = rehabilitationDetailDao.completenessCount(0, one.getId(), beginTime, endTime);//未完成
 | 
	
		
			
				|  |  |                 Integer underwayCount = rehabilitationDetailDao.completenessCount(2, one.getId(), beginTime, endTime);//已预约
 | 
	
		
			
				|  |  |                 Integer unfinishedCount = notstartedCount + underwayCount;
 | 
	
		
			
				|  |  |                 planMap.put("unfinishedCount", unfinishedCount);//未完成
 | 
	
		
			
				|  |  |                 //完成度(已完成/(已完成+未完成))
 | 
	
		
			
				|  |  |                 Integer allFinishCount = rehabilitationDetailDao.findByStatusAndPlanId(1,one.getId());
 | 
	
		
			
				|  |  |                 Integer allFinishCount = rehabilitationDetailDao.findByStatusAndPlanId(1, one.getId());
 | 
	
		
			
				|  |  |                 Integer allCount = rehabilitationDetailDao.findAllByPlanId(one.getId());
 | 
	
		
			
				|  |  |                 planMap.put("allCount",allCount);//总数
 | 
	
		
			
				|  |  |                 planMap.put("allFinishCount",allFinishCount);//全部已完成数
 | 
	
		
			
				|  |  |                 planMap.put("allCount", allCount);//总数
 | 
	
		
			
				|  |  |                 planMap.put("allFinishCount", allFinishCount);//全部已完成数
 | 
	
		
			
				|  |  |                 rehabilitationPlanList.add(planMap);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             resultMap.put("rehabilitationPlanList",rehabilitationPlanList);
 | 
	
		
			
				|  |  |             resultMap.put("rehabilitationPlanList", rehabilitationPlanList);
 | 
	
		
			
				|  |  |             resultList.add(resultMap);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultList);
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success, resultList);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 日历
 | 
	
		
			
				|  |  |      * @param planId 计划id
 | 
	
		
			
				|  |  |      * @param searchTask 快速查找任务(1、我的任务,2、随访,3、复诊,4、健康教育)
 | 
	
		
			
				|  |  |      * @param status 任务状态(0未完成,1已完成,2已预约)
 | 
	
		
			
				|  |  |      * @param doctorCode 登陆医生
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param planId       计划id
 | 
	
		
			
				|  |  |      * @param searchTask   快速查找任务(1、我的任务,2、随访,3、复诊,4、健康教育)
 | 
	
		
			
				|  |  |      * @param status       任务状态(0未完成,1已完成,2已预约)
 | 
	
		
			
				|  |  |      * @param doctorCode   登陆医生
 | 
	
		
			
				|  |  |      * @param taskExecutor 任务执行者 0全部;1我的任务 2他人任务
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public ObjEnvelop calendarPlanDetail(String executeStartTime,String executeEndTime,String planId,Integer searchTask,Integer status,String doctorCode,String taskExecutor) throws Exception{
 | 
	
		
			
				|  |  |     public ObjEnvelop calendarPlanDetail(String executeStartTime, String executeEndTime, String planId, Integer searchTask, Integer status, String doctorCode, String taskExecutor) throws Exception {
 | 
	
		
			
				|  |  |         String[] planIdlist = planId.split(",");
 | 
	
		
			
				|  |  |         StringBuilder planCondition = new StringBuilder();
 | 
	
		
			
				|  |  |         planCondition .append("'"+planIdlist[0]+"'");
 | 
	
		
			
				|  |  |         for (int i=1;i<planIdlist.length;i++){
 | 
	
		
			
				|  |  |             planCondition .append(",'"+planIdlist[i]+"'");
 | 
	
		
			
				|  |  |         planCondition.append("'" + planIdlist[0] + "'");
 | 
	
		
			
				|  |  |         for (int i = 1; i < planIdlist.length; i++) {
 | 
	
		
			
				|  |  |             planCondition.append(",'" + planIdlist[i] + "'");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String sql = " select d.* from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
 | 
	
		
			
				|  |  |                 " LEFT JOIN wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id " +
 | 
	
		
			
				|  |  |                 " where  d.plan_id in ("+planCondition+") " ;
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(executeStartTime)){
 | 
	
		
			
				|  |  |             sql += " and d.execute_time>='"+executeStartTime+"' ";
 | 
	
		
			
				|  |  |                 " where  d.plan_id in (" + planCondition + ") ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(executeStartTime)) {
 | 
	
		
			
				|  |  |             sql += " and d.execute_time>='" + executeStartTime + "' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(executeEndTime)){
 | 
	
		
			
				|  |  |             sql += " and d.execute_time<='"+executeEndTime+"' ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(executeEndTime)) {
 | 
	
		
			
				|  |  |             sql += " and d.execute_time<='" + executeEndTime + "' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(searchTask!=null){
 | 
	
		
			
				|  |  |             if(searchTask==8){
 | 
	
		
			
				|  |  |                 sql+=" and d.doctor='"+doctorCode+"' " ;
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 sql+=" and i.code="+searchTask+" " ;
 | 
	
		
			
				|  |  |         if (searchTask != null) {
 | 
	
		
			
				|  |  |             if (searchTask == 8) {
 | 
	
		
			
				|  |  |                 sql += " and d.doctor='" + doctorCode + "' ";
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 sql += " and i.code=" + searchTask + " ";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(taskExecutor.equals("1")){ //我的任务
 | 
	
		
			
				|  |  |             sql+="and d.doctor='"+doctorCode+"' ";
 | 
	
		
			
				|  |  |         if (taskExecutor.equals("1")) { //我的任务
 | 
	
		
			
				|  |  |             sql += "and d.doctor='" + doctorCode + "' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(taskExecutor.equals("2")){//他人任务
 | 
	
		
			
				|  |  |             sql+="and d.doctor <>'"+doctorCode+"' ";
 | 
	
		
			
				|  |  |         if (taskExecutor.equals("2")) {//他人任务
 | 
	
		
			
				|  |  |             sql += "and d.doctor <>'" + doctorCode + "' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(status!=null){
 | 
	
		
			
				|  |  |             sql+= " and d.status="+status;
 | 
	
		
			
				|  |  |         if (status != null) {
 | 
	
		
			
				|  |  |             sql += " and d.status=" + status;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         sql += " ORDER BY d.execute_time ";
 | 
	
		
			
				|  |  |         sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailAll2(sql);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> rehabilitationDetailList = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         List<Map<String, Object>> rehabilitationDetailList = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  | //        List<RehabilitationDetailDO> rehabilitationDetailList = rehabilitationDetailDao.findByPlanId(DateUtil.strToDate(executeStartTime),DateUtil.strToDate(executeEndTime),planId);
 | 
	
		
			
				|  |  |         Map<String,Map<String,Object>> map = new LinkedHashMap<>();
 | 
	
		
			
				|  |  |         for(Map<String,Object> one:rehabilitationDetailList){
 | 
	
		
			
				|  |  |             String executeTime = DateUtil.dateToStr((Date) one.get("execute_time"),DateUtil.YYYY_MM_DD);
 | 
	
		
			
				|  |  |             Map<String,Object> m = null;
 | 
	
		
			
				|  |  |             if(map.containsKey(executeTime)){
 | 
	
		
			
				|  |  |         Map<String, Map<String, Object>> map = new LinkedHashMap<>();
 | 
	
		
			
				|  |  |         for (Map<String, Object> one : rehabilitationDetailList) {
 | 
	
		
			
				|  |  |             String executeTime = DateUtil.dateToStr((Date) one.get("execute_time"), DateUtil.YYYY_MM_DD);
 | 
	
		
			
				|  |  |             Map<String, Object> m = null;
 | 
	
		
			
				|  |  |             if (map.containsKey(executeTime)) {
 | 
	
		
			
				|  |  |                 m = map.get(executeTime);
 | 
	
		
			
				|  |  |                 Map<String,Integer> family = null;
 | 
	
		
			
				|  |  |                 Map<String,Integer> specialist = null;
 | 
	
		
			
				|  |  |                 if(one.get("type")!=null){
 | 
	
		
			
				|  |  |                     if((Integer)one.get("type")==1){//家庭医生
 | 
	
		
			
				|  |  |                         if(m.containsKey("family")){
 | 
	
		
			
				|  |  |                             family = (Map<String,Integer>)m.get("family");
 | 
	
		
			
				|  |  |                         }else{
 | 
	
		
			
				|  |  |                 Map<String, Integer> family = null;
 | 
	
		
			
				|  |  |                 Map<String, Integer> specialist = null;
 | 
	
		
			
				|  |  |                 if (one.get("type") != null) {
 | 
	
		
			
				|  |  |                     if ((Integer) one.get("type") == 1) {//家庭医生
 | 
	
		
			
				|  |  |                         if (m.containsKey("family")) {
 | 
	
		
			
				|  |  |                             family = (Map<String, Integer>) m.get("family");
 | 
	
		
			
				|  |  |                         } else {
 | 
	
		
			
				|  |  |                             family = new HashMap<>();
 | 
	
		
			
				|  |  |                             family.put("all",0);
 | 
	
		
			
				|  |  |                             family.put("finish",0);
 | 
	
		
			
				|  |  |                             family.put("all", 0);
 | 
	
		
			
				|  |  |                             family.put("finish", 0);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         if((Integer)one.get("status")==1){
 | 
	
		
			
				|  |  |                             family.put("finish",family.get("finish")+1);
 | 
	
		
			
				|  |  |                         if ((Integer) one.get("status") == 1) {
 | 
	
		
			
				|  |  |                             family.put("finish", family.get("finish") + 1);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         family.put("all",family.get("all")+1);
 | 
	
		
			
				|  |  |                         m.put("family",family);
 | 
	
		
			
				|  |  |                     }else if((Integer)one.get("type")==2){//专科医生
 | 
	
		
			
				|  |  |                         family.put("all", family.get("all") + 1);
 | 
	
		
			
				|  |  |                         m.put("family", family);
 | 
	
		
			
				|  |  |                     } else if ((Integer) one.get("type") == 2) {//专科医生
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         if(m.containsKey("specialist")){
 | 
	
		
			
				|  |  |                         if (m.containsKey("specialist")) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                             specialist = (Map<String,Integer>)m.get("specialist");
 | 
	
		
			
				|  |  |                         }else{
 | 
	
		
			
				|  |  |                             specialist = (Map<String, Integer>) m.get("specialist");
 | 
	
		
			
				|  |  |                         } else {
 | 
	
		
			
				|  |  |                             specialist = new HashMap<>();
 | 
	
		
			
				|  |  |                             specialist.put("all",0);
 | 
	
		
			
				|  |  |                             specialist.put("finish",0);
 | 
	
		
			
				|  |  |                             specialist.put("all", 0);
 | 
	
		
			
				|  |  |                             specialist.put("finish", 0);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         if((Integer)one.get("status")==1){
 | 
	
		
			
				|  |  |                             specialist.put("finish",(specialist.get("finish"))+1);
 | 
	
		
			
				|  |  |                         if ((Integer) one.get("status") == 1) {
 | 
	
		
			
				|  |  |                             specialist.put("finish", (specialist.get("finish")) + 1);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         specialist.put("all",(specialist.get("all"))+1);
 | 
	
		
			
				|  |  |                         m.put("specialist",specialist);
 | 
	
		
			
				|  |  |                         specialist.put("all", (specialist.get("all")) + 1);
 | 
	
		
			
				|  |  |                         m.put("specialist", specialist);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 m = new HashMap<>();
 | 
	
		
			
				|  |  | //                m.put("specialist",new HashMap<String,Object>());
 | 
	
		
			
				|  |  |                 if(one.get("type")!=null){
 | 
	
		
			
				|  |  |                     if((Integer)one.get("type")==1){//家庭医生
 | 
	
		
			
				|  |  |                         Map<String,Integer> family = new HashMap<>();
 | 
	
		
			
				|  |  |                         family.put("all",0);
 | 
	
		
			
				|  |  |                         family.put("finish",0);
 | 
	
		
			
				|  |  |                         if((Integer)one.get("status")==1){
 | 
	
		
			
				|  |  |                             family.put("finish",family.get("finish")+1);
 | 
	
		
			
				|  |  |                 if (one.get("type") != null) {
 | 
	
		
			
				|  |  |                     if ((Integer) one.get("type") == 1) {//家庭医生
 | 
	
		
			
				|  |  |                         Map<String, Integer> family = new HashMap<>();
 | 
	
		
			
				|  |  |                         family.put("all", 0);
 | 
	
		
			
				|  |  |                         family.put("finish", 0);
 | 
	
		
			
				|  |  |                         if ((Integer) one.get("status") == 1) {
 | 
	
		
			
				|  |  |                             family.put("finish", family.get("finish") + 1);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         family.put("all",family.get("all")+1);
 | 
	
		
			
				|  |  |                         m.put("family",family);
 | 
	
		
			
				|  |  |                     }else if((Integer)one.get("type")==2){//专科医生
 | 
	
		
			
				|  |  |                         Map<String,Integer> specialist = new HashMap<>();
 | 
	
		
			
				|  |  |                         specialist.put("all",0);
 | 
	
		
			
				|  |  |                         specialist.put("finish",0);
 | 
	
		
			
				|  |  |                         if((Integer)one.get("status")==1){
 | 
	
		
			
				|  |  |                             specialist.put("finish",specialist.get("finish")+1);
 | 
	
		
			
				|  |  |                         family.put("all", family.get("all") + 1);
 | 
	
		
			
				|  |  |                         m.put("family", family);
 | 
	
		
			
				|  |  |                     } else if ((Integer) one.get("type") == 2) {//专科医生
 | 
	
		
			
				|  |  |                         Map<String, Integer> specialist = new HashMap<>();
 | 
	
		
			
				|  |  |                         specialist.put("all", 0);
 | 
	
		
			
				|  |  |                         specialist.put("finish", 0);
 | 
	
		
			
				|  |  |                         if ((Integer) one.get("status") == 1) {
 | 
	
		
			
				|  |  |                             specialist.put("finish", specialist.get("finish") + 1);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         specialist.put("all",specialist.get("all")+1);
 | 
	
		
			
				|  |  |                         m.put("specialist",specialist);
 | 
	
		
			
				|  |  |                         specialist.put("all", specialist.get("all") + 1);
 | 
	
		
			
				|  |  |                         m.put("specialist", specialist);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //myTaskFlag,1:有自己任务,0:没有自己任务
 | 
	
		
			
				|  |  |             if(StringUtils.isNotEmpty(doctorCode)){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 if(m.containsKey("myTaskFlag")){
 | 
	
		
			
				|  |  |                     if((Integer)m.get("myTaskFlag")==0){
 | 
	
		
			
				|  |  |                         if(doctorCode.equals(one.get("doctor").toString())){
 | 
	
		
			
				|  |  |                             m.put("myTaskFlag",1);
 | 
	
		
			
				|  |  |                         }else{
 | 
	
		
			
				|  |  |                             m.put("myTaskFlag",0);
 | 
	
		
			
				|  |  |             if (StringUtils.isNotEmpty(doctorCode)) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 if (m.containsKey("myTaskFlag")) {
 | 
	
		
			
				|  |  |                     if ((Integer) m.get("myTaskFlag") == 0) {
 | 
	
		
			
				|  |  |                         if (doctorCode.equals(one.get("doctor").toString())) {
 | 
	
		
			
				|  |  |                             m.put("myTaskFlag", 1);
 | 
	
		
			
				|  |  |                         } else {
 | 
	
		
			
				|  |  |                             m.put("myTaskFlag", 0);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }else{
 | 
	
		
			
				|  |  |                     if(doctorCode.equals(one.get("doctor").toString())){
 | 
	
		
			
				|  |  |                         m.put("myTaskFlag",1);
 | 
	
		
			
				|  |  |                     }else{
 | 
	
		
			
				|  |  |                         m.put("myTaskFlag",0);
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     if (doctorCode.equals(one.get("doctor").toString())) {
 | 
	
		
			
				|  |  |                         m.put("myTaskFlag", 1);
 | 
	
		
			
				|  |  |                     } else {
 | 
	
		
			
				|  |  |                         m.put("myTaskFlag", 0);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if(m.containsKey("planDetailIds")){
 | 
	
		
			
				|  |  |                 m.put("planDetailIds",m.get("planDetailIds")+","+one.get("id"));
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 m.put("planDetailIds",one.get("id")+"");
 | 
	
		
			
				|  |  |             if (m.containsKey("planDetailIds")) {
 | 
	
		
			
				|  |  |                 m.put("planDetailIds", m.get("planDetailIds") + "," + one.get("id"));
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 m.put("planDetailIds", one.get("id") + "");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             map.put(executeTime,m);
 | 
	
		
			
				|  |  |             map.put(executeTime, m);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         /*List list = new ArrayList();
 | 
	
		
			
				|  |  |         for(String key : map.keySet()){
 | 
	
	
		
			
				|  | @ -457,322 +471,355 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |             result.put("executeTime", key);
 | 
	
		
			
				|  |  |             list.add(result);
 | 
	
		
			
				|  |  |         }*/
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success,map);
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success, map);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 日历列表
 | 
	
		
			
				|  |  |      * @param planId 计划id
 | 
	
		
			
				|  |  |      * @param searchTask 快速查找任务(1、我的任务,2、随访,3、复诊,4、健康教育)
 | 
	
		
			
				|  |  |      * @param status 任务状态(0未完成,1已完成,2已预约)
 | 
	
		
			
				|  |  |      * @param doctorCode 登陆医生
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param planId       计划id
 | 
	
		
			
				|  |  |      * @param searchTask   快速查找任务(1、我的任务,2、随访,3、复诊,4、健康教育)
 | 
	
		
			
				|  |  |      * @param status       任务状态(0未完成,1已完成,2已预约)
 | 
	
		
			
				|  |  |      * @param doctorCode   登陆医生
 | 
	
		
			
				|  |  |      * @param taskExecutor 任务执行者 0全部;1我的任务 2他人任务
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public ObjEnvelop calendarPlanDetailList(String planId,Integer searchTask,Integer status,String doctorCode,String executeStartTime,String executeEndTime,String taskExecutor){
 | 
	
		
			
				|  |  |     public ObjEnvelop calendarPlanDetailList(String planId, Integer searchTask, Integer status, String doctorCode, String executeStartTime, String executeEndTime, String taskExecutor) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String[] planIdlist = planId.split(",");
 | 
	
		
			
				|  |  |         StringBuilder planCondition = new StringBuilder();
 | 
	
		
			
				|  |  |         planCondition .append("'"+planIdlist[0]+"'");
 | 
	
		
			
				|  |  |         for (int i=1;i<planIdlist.length;i++){
 | 
	
		
			
				|  |  |             planCondition .append(",'"+planIdlist[i]+"'");
 | 
	
		
			
				|  |  |         planCondition.append("'" + planIdlist[0] + "'");
 | 
	
		
			
				|  |  |         for (int i = 1; i < planIdlist.length; i++) {
 | 
	
		
			
				|  |  |             planCondition.append(",'" + planIdlist[i] + "'");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String sql = " select d.*,DATE_FORMAT(d.execute_time,'%Y/%m/%d %H:%i') as executeTime ,i.code,IF(d.followup_detail_type=1,'社区随访(厦心)',i.name) name,1 as flag from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
 | 
	
		
			
				|  |  |                 " LEFT JOIN wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id  " +
 | 
	
		
			
				|  |  |                 " where  d.plan_id in ("+planCondition+" )AND  d.execute_time IS NOT NULL  and d.execute_time <>'' " ;
 | 
	
		
			
				|  |  |         if(searchTask!=null){
 | 
	
		
			
				|  |  |             if(searchTask==8){//
 | 
	
		
			
				|  |  |                 if(StringUtils.isNotBlank(doctorCode)){
 | 
	
		
			
				|  |  |                     sql+=" and d.doctor='"+doctorCode+"' ";
 | 
	
		
			
				|  |  |                 " where  d.plan_id in (" + planCondition + " )AND  d.execute_time IS NOT NULL  and d.execute_time <>'' ";
 | 
	
		
			
				|  |  |         if (searchTask != null) {
 | 
	
		
			
				|  |  |             if (searchTask == 8) {//
 | 
	
		
			
				|  |  |                 if (StringUtils.isNotBlank(doctorCode)) {
 | 
	
		
			
				|  |  |                     sql += " and d.doctor='" + doctorCode + "' ";
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 //sql+=" and i.code="+searchTask+" " ;
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 sql+=" and i.code="+searchTask+" " ;
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 sql += " and i.code=" + searchTask + " ";
 | 
	
		
			
				|  |  |             }/*else if(searchTask==5){
 | 
	
		
			
				|  |  |                 sql+=" and i.reserve=1 " ;
 | 
	
		
			
				|  |  |             }*/
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(taskExecutor.equals("1")){ //我的任务
 | 
	
		
			
				|  |  |             sql+="and d.doctor='"+doctorCode+"' ";
 | 
	
		
			
				|  |  |         if (taskExecutor.equals("1")) { //我的任务
 | 
	
		
			
				|  |  |             sql += "and d.doctor='" + doctorCode + "' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(taskExecutor.equals("2")){//他人任务
 | 
	
		
			
				|  |  |             sql+="and d.doctor <>'"+doctorCode+"' ";
 | 
	
		
			
				|  |  |         if (taskExecutor.equals("2")) {//他人任务
 | 
	
		
			
				|  |  |             sql += "and d.doctor <>'" + doctorCode + "' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(executeEndTime)&&StringUtils.isNoneBlank(executeStartTime)){
 | 
	
		
			
				|  |  |             sql+="and d.execute_time>='"+executeStartTime+"' and d.execute_time<='"+executeEndTime+"' ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(executeEndTime) && StringUtils.isNoneBlank(executeStartTime)) {
 | 
	
		
			
				|  |  |             sql += "and d.execute_time>='" + executeStartTime + "' and d.execute_time<='" + executeEndTime + "' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(status!=null){
 | 
	
		
			
				|  |  |             sql+= "and d.status="+status;
 | 
	
		
			
				|  |  |         if (status != null) {
 | 
	
		
			
				|  |  |             sql += "and d.status=" + status;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         sql +="  order by d.execute_time desc ";
 | 
	
		
			
				|  |  |         sql += "  order by d.execute_time desc ";
 | 
	
		
			
				|  |  |         sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailAll2(sql);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> rehabilitationDetailList = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         List<Map<String, Object>> rehabilitationDetailList = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String planPatientSql = " SELECT p.patient FROM wlyy_specialist.wlyy_patient_rehabilitation_plan p " +
 | 
	
		
			
				|  |  |                 "INNER JOIN wlyy.wlyy_sign_family f ON p.patient = f.patient  WHERE p.id in ("+planCondition+" ) " +
 | 
	
		
			
				|  |  |                 "AND f.`status` = 1 AND f.expenses_status = 1 AND  f.doctor = '"+doctorCode+"' ";
 | 
	
		
			
				|  |  |                 "INNER JOIN wlyy.wlyy_sign_family f ON p.patient = f.patient  WHERE p.id in (" + planCondition + " ) " +
 | 
	
		
			
				|  |  |                 "AND f.`status` = 1 AND f.expenses_status = 1 AND  f.doctor = '" + doctorCode + "' ";
 | 
	
		
			
				|  |  |         List<Map<String, Object>> patientCodeList = jdbcTemplate.queryForList(planPatientSql);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<Map<String, Object>> list = null;
 | 
	
		
			
				|  |  |         if (patientCodeList.size()>0&&null!=searchTask) {
 | 
	
		
			
				|  |  |             String patient =  patientCodeList.get(0).get("patient").toString();
 | 
	
		
			
				|  |  |             if (7 == searchTask){ //处方续方 flag 用于判断 1.7.0.5 新增
 | 
	
		
			
				|  |  |         if (patientCodeList.size() > 0 && null != searchTask) {
 | 
	
		
			
				|  |  |             String patient = patientCodeList.get(0).get("patient").toString();
 | 
	
		
			
				|  |  |             if (7 == searchTask) { //处方续方 flag 用于判断 1.7.0.5 新增
 | 
	
		
			
				|  |  |                 String cfxfSql = "SELECT LEFT ( pr.create_time, 19 ) AS executeTime ,LEFT ( pr.pres_create_time, 19 ) AS buildCreateTime , pr.doctor AS doctorCode, pr.doctor_name AS doctorNmae,pr.`status`," +
 | 
	
		
			
				|  |  |                         " pr.hospital_name, pr.hospital, p.`name` AS patientName,p.code AS patientCode,pr.`code` AS id,7 as code, 2 as flag " +
 | 
	
		
			
				|  |  |                         " FROM  wlyy.wlyy_prescription pr  LEFT JOIN wlyy.wlyy_patient p ON pr.patient = p.`code` WHERE " +
 | 
	
		
			
				|  |  |                         "  1 = 1  AND pr.STATUS = '100' AND p.code= '"+patient+"' GROUP BY  pr.CODE ";
 | 
	
		
			
				|  |  |                         "  1 = 1  AND pr.STATUS = '100' AND p.code= '" + patient + "' GROUP BY  pr.CODE ";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 list = jdbcTemplate.queryForList(cfxfSql);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (6 == searchTask){ //随访
 | 
	
		
			
				|  |  |                 String sfSql = "SELECT DISTINCT DATE_FORMAT(wf.followup_date,'%Y/%m/%d %H:%i') followupDate,DATE_FORMAT(wf.followup_plan_date,'%Y/%m/%d %H:%i') executeTime,wf.doctor_code doctorCode,wf.followup_class followupClass, " +
 | 
	
		
			
				|  |  |                         " wf.patient_code AS patientCode,wf.patient_name AS patientName,wf.doctor_name doctorName,wf.`status` AS `status`,wf.org_name orgName," +
 | 
	
		
			
				|  |  |                         " wf.org_code orgCode,sd.value AS `value`, wf.followup_type  followupType,wf.id AS id, 6 AS code,2 as flag FROM  wlyy.wlyy_followup wf " +
 | 
	
		
			
				|  |  |                         " LEFT JOIN wlyy.system_dict sd ON wf.followup_type = sd.CODE " +
 | 
	
		
			
				|  |  |                         " AND sd.dict_name = 'FOLLOWUP_WAY_DICT' WHERE wf.status !=0  AND wf.patient_code = '"+patient+"' order by wf.followup_plan_date desc  ";
 | 
	
		
			
				|  |  |                 list = jdbcTemplate.queryForList(sfSql);
 | 
	
		
			
				|  |  |             /**
 | 
	
		
			
				|  |  |              * 20230918
 | 
	
		
			
				|  |  |              * 说明:这个块原本的查其他的随访。
 | 
	
		
			
				|  |  |              * 这这些数据加入厦心的随访里面.
 | 
	
		
			
				|  |  |              * 现在注释掉,只展示厦心的
 | 
	
		
			
				|  |  |              */
 | 
	
		
			
				|  |  | //            if (6 == searchTask) {
 | 
	
		
			
				|  |  | //                //其他随访
 | 
	
		
			
				|  |  | //                String sfSql = "SELECT DISTINCT DATE_FORMAT(wf.followup_date,'%Y/%m/%d %H:%i') followupDate,DATE_FORMAT(wf.followup_plan_date,'%Y/%m/%d %H:%i') executeTime,wf.doctor_code doctorCode,wf.followup_class followupClass, " +
 | 
	
		
			
				|  |  | //                        " wf.patient_code AS patientCode,wf.patient_name AS patientName,wf.doctor_name doctorName,wf.`status` AS `status`,wf.org_name orgName," +
 | 
	
		
			
				|  |  | //                        " wf.org_code orgCode,sd.value AS `value`, wf.followup_type  followupType,wf.id AS id, 6 AS code,2 as flag " +
 | 
	
		
			
				|  |  | //                        " FROM  wlyy.wlyy_followup wf " +
 | 
	
		
			
				|  |  | //                        " LEFT JOIN wlyy.system_dict sd ON wf.followup_type = sd.CODE " +
 | 
	
		
			
				|  |  | //                        " AND sd.dict_name = 'FOLLOWUP_WAY_DICT' WHERE wf.status !=0  AND wf.patient_code = '" + patient + "' order by wf.followup_plan_date desc  ";
 | 
	
		
			
				|  |  | //                list = jdbcTemplate.queryForList(sfSql);
 | 
	
		
			
				|  |  | //            }
 | 
	
		
			
				|  |  |             if (list != null && list.size() > 0) {
 | 
	
		
			
				|  |  |                 rehabilitationDetailList.addAll(list);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (list!=null&&list.size()>0)rehabilitationDetailList.addAll(list);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success,rehabilitationDetailList);
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success, rehabilitationDetailList);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 多个康复计划服务项目内容列表
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param planDetailIds
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public ObjEnvelop serviceItemList(String planDetailIds,String doctorCode) throws Exception{
 | 
	
		
			
				|  |  |     public ObjEnvelop serviceItemList(String planDetailIds, String doctorCode) throws Exception {
 | 
	
		
			
				|  |  |         String[] s = planDetailIds.split(",");
 | 
	
		
			
				|  |  |         String planDetailList = "";
 | 
	
		
			
				|  |  |         for(String one:s){
 | 
	
		
			
				|  |  |             planDetailList +=",'"+one+"'";
 | 
	
		
			
				|  |  |         for (String one : s) {
 | 
	
		
			
				|  |  |             planDetailList += ",'" + one + "'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String planDetailResult = StringUtils.isNotEmpty(planDetailList)?planDetailList.substring(1):"";
 | 
	
		
			
				|  |  |         String planDetailResult = StringUtils.isNotEmpty(planDetailList) ? planDetailList.substring(1) : "";
 | 
	
		
			
				|  |  |         String sql = "select i.name,i.code,i.content,d.execute_time,d.hospital_name,d.id,d.status,d.type as detailType,d.expense,d.doctor as executeDoctor," +
 | 
	
		
			
				|  |  |                 " d.doctor_name as executeDoctorName,p.patient ,p.id AS planId,p.create_user as createDoctor,p.create_user_name as createDoctorName, p.status as planStatus  " +
 | 
	
		
			
				|  |  |                 " from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
 | 
	
		
			
				|  |  |                 " LEFT JOIN wlyy_specialist.wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id " +
 | 
	
		
			
				|  |  |                 " LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
 | 
	
		
			
				|  |  |                 " where d.id in ("+planDetailResult+") order BY d.execute_time ASC ";
 | 
	
		
			
				|  |  |                 " where d.id in (" + planDetailResult + ") order BY d.execute_time ASC ";
 | 
	
		
			
				|  |  |         sql = TransforSqlUtl.wlyy_patient_rehabilitation_planCreateName(sql);
 | 
	
		
			
				|  |  |         sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailDoctorName(sql);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> serviceItemList = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         List<Map<String, Object>> serviceItemList = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  | //        if(serviceItemList.size()>0){
 | 
	
		
			
				|  |  | //            Map<String,Object> serviceItem = serviceItemList.get(0);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> resultList = new ArrayList<>();
 | 
	
		
			
				|  |  |         for(Map<String,Object> one:serviceItemList){
 | 
	
		
			
				|  |  |             Map<String,Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  |         List<Map<String, Object>> resultList = new ArrayList<>();
 | 
	
		
			
				|  |  |         for (Map<String, Object> one : serviceItemList) {
 | 
	
		
			
				|  |  |             Map<String, Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  |             Integer isMyTask = 0;
 | 
	
		
			
				|  |  |             if(StringUtils.isNotEmpty(doctorCode)&&doctorCode.equals(one.get("executeDoctor")+"")){
 | 
	
		
			
				|  |  |                 isMyTask=1;
 | 
	
		
			
				|  |  |             if (StringUtils.isNotEmpty(doctorCode) && doctorCode.equals(one.get("executeDoctor") + "")) {
 | 
	
		
			
				|  |  |                 isMyTask = 1;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             resultMap.put("isMyTask",isMyTask);//0不是自己的任务,1是自己的任务
 | 
	
		
			
				|  |  |             resultMap.put("isMyTask", isMyTask);//0不是自己的任务,1是自己的任务
 | 
	
		
			
				|  |  | //            if(!(one.get("specialistDoctor")+"").equals((one.get("create_user")+""))){
 | 
	
		
			
				|  |  | //                executeDoctorList.add(one.get("create_user_name")+"");
 | 
	
		
			
				|  |  | //            }
 | 
	
		
			
				|  |  |             List<String> executeDoctorList = new ArrayList<>();
 | 
	
		
			
				|  |  |             executeDoctorList.add(one.get("executeDoctorName")+"");
 | 
	
		
			
				|  |  |             resultMap.put("executeDoctorList",executeDoctorList);//执行医生名称列表
 | 
	
		
			
				|  |  |             resultMap.put("executeDoctorCode",one.get("executeDoctor")+"");//执行医生code
 | 
	
		
			
				|  |  |             resultMap.put("executeDoctorName",one.get("executeDoctorName")+"");//执行医生code
 | 
	
		
			
				|  |  |             resultMap.put("specialistDoctorCode",one.get("createDoctor")+"");//创建人(专科)医生code
 | 
	
		
			
				|  |  |             resultMap.put("specialistDoctorName",one.get("createDoctorName")+"");//创建人(专科)医生名字
 | 
	
		
			
				|  |  |             resultMap.put("title",one.get("name"));//项目标题
 | 
	
		
			
				|  |  |             resultMap.put("planDetaiId",one.get("id"));//计划服务项目id
 | 
	
		
			
				|  |  |             resultMap.put("planId",one.get("planId"));//计划id
 | 
	
		
			
				|  |  |             resultMap.put("shortExecuteTime",DateUtil.dateToStr((Date) one.get("execute_time"),DateUtil.HH_MM));//项目标题
 | 
	
		
			
				|  |  |             resultMap.put("content",one.get("content"));//项目内容
 | 
	
		
			
				|  |  |             resultMap.put("hospitalName",one.get("hospital_name"));//地点
 | 
	
		
			
				|  |  |             resultMap.put("executeTime",one.get("execute_time"));//执行时间
 | 
	
		
			
				|  |  |             executeDoctorList.add(one.get("executeDoctorName") + "");
 | 
	
		
			
				|  |  |             resultMap.put("executeDoctorList", executeDoctorList);//执行医生名称列表
 | 
	
		
			
				|  |  |             resultMap.put("executeDoctorCode", one.get("executeDoctor") + "");//执行医生code
 | 
	
		
			
				|  |  |             resultMap.put("executeDoctorName", one.get("executeDoctorName") + "");//执行医生code
 | 
	
		
			
				|  |  |             resultMap.put("specialistDoctorCode", one.get("createDoctor") + "");//创建人(专科)医生code
 | 
	
		
			
				|  |  |             resultMap.put("specialistDoctorName", one.get("createDoctorName") + "");//创建人(专科)医生名字
 | 
	
		
			
				|  |  |             resultMap.put("title", one.get("name"));//项目标题
 | 
	
		
			
				|  |  |             resultMap.put("planDetaiId", one.get("id"));//计划服务项目id
 | 
	
		
			
				|  |  |             resultMap.put("planId", one.get("planId"));//计划id
 | 
	
		
			
				|  |  |             resultMap.put("shortExecuteTime", DateUtil.dateToStr((Date) one.get("execute_time"), DateUtil.HH_MM));//项目标题
 | 
	
		
			
				|  |  |             resultMap.put("content", one.get("content"));//项目内容
 | 
	
		
			
				|  |  |             resultMap.put("hospitalName", one.get("hospital_name"));//地点
 | 
	
		
			
				|  |  |             resultMap.put("executeTime", one.get("execute_time"));//执行时间
 | 
	
		
			
				|  |  |             DecimalFormat df = new DecimalFormat("0.00");
 | 
	
		
			
				|  |  |             resultMap.put("expense", one.get("expense")!=null?df.format(((Integer)one.get("expense")*1.00)):0);//收费
 | 
	
		
			
				|  |  |             resultMap.put("reserve",null);//是否需要预约(1预约、0不预约)
 | 
	
		
			
				|  |  |             resultMap.put("planStatus",one.get("planStatus"));//计划的状态
 | 
	
		
			
				|  |  |             resultMap.put("expense", one.get("expense") != null ? df.format(((Integer) one.get("expense") * 1.00)) : 0);//收费
 | 
	
		
			
				|  |  |             resultMap.put("reserve", null);//是否需要预约(1预约、0不预约)
 | 
	
		
			
				|  |  |             resultMap.put("planStatus", one.get("planStatus"));//计划的状态
 | 
	
		
			
				|  |  |             Integer status = Integer.valueOf(one.get("status").toString());//状态(0未完成,1已完成,2已预约)
 | 
	
		
			
				|  |  |             String statusName = "";
 | 
	
		
			
				|  |  |             switch (status){
 | 
	
		
			
				|  |  |                 case 0:{statusName="未完成";break;}
 | 
	
		
			
				|  |  |                 case 1:{statusName="已完成";break;}
 | 
	
		
			
				|  |  |                 case 2:{statusName="已预约";break;}
 | 
	
		
			
				|  |  |             switch (status) {
 | 
	
		
			
				|  |  |                 case 0: {
 | 
	
		
			
				|  |  |                     statusName = "未完成";
 | 
	
		
			
				|  |  |                     break;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 case 1: {
 | 
	
		
			
				|  |  |                     statusName = "已完成";
 | 
	
		
			
				|  |  |                     break;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 case 2: {
 | 
	
		
			
				|  |  |                     statusName = "已预约";
 | 
	
		
			
				|  |  |                     break;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             resultMap.put("statusName",statusName);//状态
 | 
	
		
			
				|  |  |             resultMap.put("statusName", statusName);//状态
 | 
	
		
			
				|  |  |             //指导与汇报
 | 
	
		
			
				|  |  |             List<GuidanceMessageLogDO> messageList = guidanceMessageLogDao.findByPlanDetailId(one.get("id").toString());
 | 
	
		
			
				|  |  |             List<Map<String,Object>> messageMapList = new ArrayList<>();
 | 
	
		
			
				|  |  |             for(GuidanceMessageLogDO one2:messageList){
 | 
	
		
			
				|  |  |                 Map<String,Object> map = new HashMap<>();
 | 
	
		
			
				|  |  |                 map.put("doctorName",one2.getDoctorName());
 | 
	
		
			
				|  |  |                 map.put("adminTeamName",one2.getAdminTeamName());
 | 
	
		
			
				|  |  |                 map.put("content",one2.getContent());
 | 
	
		
			
				|  |  |                 map.put("contentType",one2.getContentType());
 | 
	
		
			
				|  |  |                 map.put("createTime",DateUtil.dateToStr(one2.getCreateTime(),"MM-dd HH:mm"));
 | 
	
		
			
				|  |  |             List<Map<String, Object>> messageMapList = new ArrayList<>();
 | 
	
		
			
				|  |  |             for (GuidanceMessageLogDO one2 : messageList) {
 | 
	
		
			
				|  |  |                 Map<String, Object> map = new HashMap<>();
 | 
	
		
			
				|  |  |                 map.put("doctorName", one2.getDoctorName());
 | 
	
		
			
				|  |  |                 map.put("adminTeamName", one2.getAdminTeamName());
 | 
	
		
			
				|  |  |                 map.put("content", one2.getContent());
 | 
	
		
			
				|  |  |                 map.put("contentType", one2.getContentType());
 | 
	
		
			
				|  |  |                 map.put("createTime", DateUtil.dateToStr(one2.getCreateTime(), "MM-dd HH:mm"));
 | 
	
		
			
				|  |  |                 messageMapList.add(map);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |            /* Integer itemType = (Integer) one.get("itemType");*/
 | 
	
		
			
				|  |  |             resultMap.put("messageList",messageMapList);//指导与汇报记录
 | 
	
		
			
				|  |  |             resultMap.put("patient",one.get("patient"));
 | 
	
		
			
				|  |  |             resultMap.put("itemType",one.get("code"));
 | 
	
		
			
				|  |  |             resultMap.put("detaiType",one.get("detaiType"));
 | 
	
		
			
				|  |  |             resultMap.put("status",status);//状态
 | 
	
		
			
				|  |  |             /* Integer itemType = (Integer) one.get("itemType");*/
 | 
	
		
			
				|  |  |             resultMap.put("messageList", messageMapList);//指导与汇报记录
 | 
	
		
			
				|  |  |             resultMap.put("patient", one.get("patient"));
 | 
	
		
			
				|  |  |             resultMap.put("itemType", one.get("code"));
 | 
	
		
			
				|  |  |             resultMap.put("detaiType", one.get("detaiType"));
 | 
	
		
			
				|  |  |             resultMap.put("status", status);//状态
 | 
	
		
			
				|  |  |             //是否完成任务
 | 
	
		
			
				|  |  |             List<RehabilitationOperateRecordsDO> operateList = rehabilitationOperateRecordsDao.findByRehabilitationDetailId(one.get("id").toString());
 | 
	
		
			
				|  |  |             Integer operate = 0;
 | 
	
		
			
				|  |  |             if(operateList.size()>0){
 | 
	
		
			
				|  |  |                 operate =1;
 | 
	
		
			
				|  |  |             if (operateList.size() > 0) {
 | 
	
		
			
				|  |  |                 operate = 1;
 | 
	
		
			
				|  |  |                 RehabilitationOperateRecordsDO temp = operateList.get(0);
 | 
	
		
			
				|  |  |                 operate =1;
 | 
	
		
			
				|  |  |                 operate = 1;
 | 
	
		
			
				|  |  |                 Date completeTime = temp.getCompleteTime();
 | 
	
		
			
				|  |  |                 String completeTimeStr = DateUtil.dateToStr(completeTime,DateUtil.YYYY_MM_DD_HH_MM);
 | 
	
		
			
				|  |  |                 resultMap.put("completeTime",completeTimeStr);//完成时间
 | 
	
		
			
				|  |  |                 resultMap.put("operatorDoctorName",temp.getDoctorName());//执行医生名称
 | 
	
		
			
				|  |  |                 resultMap.put("node",temp.getNode());
 | 
	
		
			
				|  |  |                 resultMap.put("relationRecordImg",(temp.getRelationRecordImg()!=null&&StringUtils.isNotEmpty(temp.getRelationRecordImg()))?(new JSONArray(temp.getRelationRecordImg())):null);//json格式
 | 
	
		
			
				|  |  |                 resultMap.put("relationRecordCode",temp.getRelationRecordCode());
 | 
	
		
			
				|  |  |                 resultMap.put("completeTimeShort",DateUtil.dateToStr(completeTime,"yyyy/MM/dd"));
 | 
	
		
			
				|  |  |                 String completeTimeStr = DateUtil.dateToStr(completeTime, DateUtil.YYYY_MM_DD_HH_MM);
 | 
	
		
			
				|  |  |                 resultMap.put("completeTime", completeTimeStr);//完成时间
 | 
	
		
			
				|  |  |                 resultMap.put("operatorDoctorName", temp.getDoctorName());//执行医生名称
 | 
	
		
			
				|  |  |                 resultMap.put("node", temp.getNode());
 | 
	
		
			
				|  |  |                 resultMap.put("relationRecordImg", (temp.getRelationRecordImg() != null && StringUtils.isNotEmpty(temp.getRelationRecordImg())) ? (new JSONArray(temp.getRelationRecordImg())) : null);//json格式
 | 
	
		
			
				|  |  |                 resultMap.put("relationRecordCode", temp.getRelationRecordCode());
 | 
	
		
			
				|  |  |                 resultMap.put("completeTimeShort", DateUtil.dateToStr(completeTime, "yyyy/MM/dd"));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             resultMap.put("operate",operate);//是否完成任务(默认0:未完成,1:已完成)
 | 
	
		
			
				|  |  |             resultMap.put("operate", operate);//是否完成任务(默认0:未完成,1:已完成)
 | 
	
		
			
				|  |  |             resultList.add(resultMap);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultList);
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success, resultList);
 | 
	
		
			
				|  |  | //        }
 | 
	
		
			
				|  |  | //        return MixEnvelop.getError("没有该服务项详情信息!");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 康复计划服务项目确认页
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param planDetailId
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public ObjEnvelop serviceItem(String planDetailId,String doctorCode,String recordId) throws Exception{
 | 
	
		
			
				|  |  |     public ObjEnvelop serviceItem(String planDetailId, String doctorCode, String recordId) throws Exception {
 | 
	
		
			
				|  |  |         String sql = "select h.name as title,h.content as content,h.code as itemType,d.id,d.execute_time,d.hospital_name,d.status,d.type,d.expense,d.doctor as executeDoctor, " +
 | 
	
		
			
				|  |  |                 " d.doctor_name as executeDoctorName,p.patient ,p.name as patientName,p.create_user as createDoctor,p.create_user_name as createDoctorName, p.status as planStatus," +
 | 
	
		
			
				|  |  |                 " p.disease,p.disease_name as diseaseName,p.title as planTitle,d.plan_id as planId,d.relation_code as relationCode,d.frequency_code as frequencyCode,d.remark  "+
 | 
	
		
			
				|  |  |                 " p.disease,p.disease_name as diseaseName,p.title as planTitle,d.plan_id as planId,d.relation_code as relationCode,d.frequency_code as frequencyCode,d.remark  " +
 | 
	
		
			
				|  |  |                 " ,a.appointment_time appointmentTime,a.appointment_doctor appointmentDoctor,a.appointment_doctor_name appointmentDoctorName,d.reservation_type reservationType,d.followup_detail_type followupDetailType " +
 | 
	
		
			
				|  |  |                 " from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
 | 
	
		
			
				|  |  |                 " LEFT JOIN wlyy_specialist.wlyy_rehabilitation_service_item h on d.hospital_service_item_id = h.code "+
 | 
	
		
			
				|  |  |                 " LEFT JOIN wlyy_specialist.wlyy_rehabilitation_service_item h on d.hospital_service_item_id = h.code " +
 | 
	
		
			
				|  |  |                 " LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
 | 
	
		
			
				|  |  |                 " LEFT JOIN wlyy_specialist.wlyy_plan_detail_appointment a on d.id=.a.rehabilitation_plan_detail_id " +
 | 
	
		
			
				|  |  |                 " where d.id = '"+planDetailId+"'";
 | 
	
		
			
				|  |  |                 " where d.id = '" + planDetailId + "'";
 | 
	
		
			
				|  |  |         sql = TransforSqlUtl.wlyy_patient_rehabilitation_planName2(sql);
 | 
	
		
			
				|  |  |         sql = TransforSqlUtl.wlyy_patient_rehabilitation_planCreateName(sql);
 | 
	
		
			
				|  |  |         sql = TransforSqlUtl.wlyy_plan_detail_appointmentAppDoctorName(sql);
 | 
	
		
			
				|  |  |         sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailDoctorName(sql);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> serviceItemList = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         if (serviceItemList.size()==0){
 | 
	
		
			
				|  |  |             return ObjEnvelop.getSuccess(SpecialistMapping.api_success,new HashMap<>());
 | 
	
		
			
				|  |  |         List<Map<String, Object>> serviceItemList = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         if (serviceItemList.size() == 0) {
 | 
	
		
			
				|  |  |             return ObjEnvelop.getSuccess(SpecialistMapping.api_success, new HashMap<>());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         Map<String,Object> one = serviceItemList.get(0);
 | 
	
		
			
				|  |  |         Map<String,Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  |         Map<String, Object> one = serviceItemList.get(0);
 | 
	
		
			
				|  |  |         Map<String, Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  |         List<String> executeDoctorList = new ArrayList<>();
 | 
	
		
			
				|  |  |         Integer isMyTask = 0;
 | 
	
		
			
				|  |  |         //判断登陆者和执行医生是不是同一个人
 | 
	
		
			
				|  |  |         if(StringUtils.isNotEmpty(doctorCode)&&doctorCode.equals(one.get("executeDoctor")+"")){
 | 
	
		
			
				|  |  |             isMyTask=1;
 | 
	
		
			
				|  |  |         if (StringUtils.isNotEmpty(doctorCode) && doctorCode.equals(one.get("executeDoctor") + "")) {
 | 
	
		
			
				|  |  |             isMyTask = 1;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         // 协诊预约信息
 | 
	
		
			
				|  |  |         resultMap.put("appointmentTime",one.get("appointmentTime"));
 | 
	
		
			
				|  |  |         resultMap.put("appointmentDoctor",one.get("appointmentDoctor"));
 | 
	
		
			
				|  |  |         resultMap.put("appointmentDoctorName",one.get("appointmentDoctorName"));
 | 
	
		
			
				|  |  |         resultMap.put("reservationType",one.get("reservationType"));//复诊类型:1线上,2线下,3远程
 | 
	
		
			
				|  |  |         resultMap.put("followupDetailType",one.get("followupDetailType"));
 | 
	
		
			
				|  |  |         resultMap.put("frequencyCode",one.get("frequencyCode")+"");
 | 
	
		
			
				|  |  |         resultMap.put("isMyTask",isMyTask);//0不是自己的任务,1是自己的任务
 | 
	
		
			
				|  |  |         resultMap.put("appointmentTime", one.get("appointmentTime"));
 | 
	
		
			
				|  |  |         resultMap.put("appointmentDoctor", one.get("appointmentDoctor"));
 | 
	
		
			
				|  |  |         resultMap.put("appointmentDoctorName", one.get("appointmentDoctorName"));
 | 
	
		
			
				|  |  |         resultMap.put("reservationType", one.get("reservationType"));//复诊类型:1线上,2线下,3远程
 | 
	
		
			
				|  |  |         resultMap.put("followupDetailType", one.get("followupDetailType"));
 | 
	
		
			
				|  |  |         resultMap.put("frequencyCode", one.get("frequencyCode") + "");
 | 
	
		
			
				|  |  |         resultMap.put("isMyTask", isMyTask);//0不是自己的任务,1是自己的任务
 | 
	
		
			
				|  |  | //        if(!(one.get("specialistDoctor")+"").equals((one.get("create_user")+""))){
 | 
	
		
			
				|  |  | //            executeDoctorList.add(one.get("create_user_name")+"");
 | 
	
		
			
				|  |  | //        }
 | 
	
		
			
				|  |  |         executeDoctorList.add(one.get("executeDoctorName")+"");//
 | 
	
		
			
				|  |  |         resultMap.put("remark",one.get("remark"));//备注
 | 
	
		
			
				|  |  |         resultMap.put("executeDoctorList",executeDoctorList);//执行医生名称列表
 | 
	
		
			
				|  |  |         resultMap.put("executeDoctorCode",one.get("executeDoctor")+"");//执行医生code
 | 
	
		
			
				|  |  |         resultMap.put("executeDoctorName",one.get("executeDoctorName")+"");//执行医生名称
 | 
	
		
			
				|  |  |         resultMap.put("specialistDoctorCode",one.get("createDoctor")+"");//创建人(专科)医生code
 | 
	
		
			
				|  |  |         resultMap.put("specialistDoctorName",one.get("createDoctorName")+"");//创建人(专科)医生名字
 | 
	
		
			
				|  |  |         resultMap.put("title",one.get("title"));//项目标题
 | 
	
		
			
				|  |  |         resultMap.put("shortExecuteTime",DateUtil.dateToStr((Date) one.get("execute_time"),DateUtil.HH_MM));//项目标题
 | 
	
		
			
				|  |  |         resultMap.put("content",one.get("content"));//项目内容
 | 
	
		
			
				|  |  |         resultMap.put("hospitalName",one.get("hospital_name"));//地点
 | 
	
		
			
				|  |  |         resultMap.put("executeTime",one.get("execute_time"));//执行时间
 | 
	
		
			
				|  |  |         executeDoctorList.add(one.get("executeDoctorName") + "");//
 | 
	
		
			
				|  |  |         resultMap.put("remark", one.get("remark"));//备注
 | 
	
		
			
				|  |  |         resultMap.put("executeDoctorList", executeDoctorList);//执行医生名称列表
 | 
	
		
			
				|  |  |         resultMap.put("executeDoctorCode", one.get("executeDoctor") + "");//执行医生code
 | 
	
		
			
				|  |  |         resultMap.put("executeDoctorName", one.get("executeDoctorName") + "");//执行医生名称
 | 
	
		
			
				|  |  |         resultMap.put("specialistDoctorCode", one.get("createDoctor") + "");//创建人(专科)医生code
 | 
	
		
			
				|  |  |         resultMap.put("specialistDoctorName", one.get("createDoctorName") + "");//创建人(专科)医生名字
 | 
	
		
			
				|  |  |         resultMap.put("title", one.get("title"));//项目标题
 | 
	
		
			
				|  |  |         resultMap.put("shortExecuteTime", DateUtil.dateToStr((Date) one.get("execute_time"), DateUtil.HH_MM));//项目标题
 | 
	
		
			
				|  |  |         resultMap.put("content", one.get("content"));//项目内容
 | 
	
		
			
				|  |  |         resultMap.put("hospitalName", one.get("hospital_name"));//地点
 | 
	
		
			
				|  |  |         resultMap.put("executeTime", one.get("execute_time"));//执行时间
 | 
	
		
			
				|  |  |         DecimalFormat df = new DecimalFormat("0.00");
 | 
	
		
			
				|  |  |         resultMap.put("expense",one.get("expense")!=null?df.format(((Integer)one.get("expense")*1.00)):0);//收费
 | 
	
		
			
				|  |  |         resultMap.put("reserve",one.get("reserve"));//是否需要预约(1预约、0不预约)
 | 
	
		
			
				|  |  |         resultMap.put("planStatus",one.get("planStatus"));//计划的状态
 | 
	
		
			
				|  |  |         resultMap.put("relationCode",one.get("relationCode"));//业务关联code
 | 
	
		
			
				|  |  |         resultMap.put("expense", one.get("expense") != null ? df.format(((Integer) one.get("expense") * 1.00)) : 0);//收费
 | 
	
		
			
				|  |  |         resultMap.put("reserve", one.get("reserve"));//是否需要预约(1预约、0不预约)
 | 
	
		
			
				|  |  |         resultMap.put("planStatus", one.get("planStatus"));//计划的状态
 | 
	
		
			
				|  |  |         resultMap.put("relationCode", one.get("relationCode"));//业务关联code
 | 
	
		
			
				|  |  |         Integer status = Integer.valueOf(one.get("status").toString());//状态(0未完成,1已完成,2已预约)
 | 
	
		
			
				|  |  |         String statusName = "";
 | 
	
		
			
				|  |  |         switch (status){
 | 
	
		
			
				|  |  |             case 0:{statusName="未完成";break;}
 | 
	
		
			
				|  |  |             case 1:{statusName="已完成";break;}
 | 
	
		
			
				|  |  |             case 2:{statusName="已预约";break;}
 | 
	
		
			
				|  |  |             case 3:{statusName="待录入";break;}
 | 
	
		
			
				|  |  |         switch (status) {
 | 
	
		
			
				|  |  |             case 0: {
 | 
	
		
			
				|  |  |                 statusName = "未完成";
 | 
	
		
			
				|  |  |                 break;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             case 1: {
 | 
	
		
			
				|  |  |                 statusName = "已完成";
 | 
	
		
			
				|  |  |                 break;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             case 2: {
 | 
	
		
			
				|  |  |                 statusName = "已预约";
 | 
	
		
			
				|  |  |                 break;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             case 3: {
 | 
	
		
			
				|  |  |                 statusName = "待录入";
 | 
	
		
			
				|  |  |                 break;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         resultMap.put("statusName",statusName);//状态名称
 | 
	
		
			
				|  |  |         resultMap.put("status",status);//状态
 | 
	
		
			
				|  |  |         resultMap.put("disease",one.get("disease"));
 | 
	
		
			
				|  |  |         resultMap.put("diseaseName",one.get("diseaseName"));
 | 
	
		
			
				|  |  |         resultMap.put("planTitle",one.get("planTitle"));
 | 
	
		
			
				|  |  |         resultMap.put("planId",one.get("planId"));
 | 
	
		
			
				|  |  |         resultMap.put("statusName", statusName);//状态名称
 | 
	
		
			
				|  |  |         resultMap.put("status", status);//状态
 | 
	
		
			
				|  |  |         resultMap.put("disease", one.get("disease"));
 | 
	
		
			
				|  |  |         resultMap.put("diseaseName", one.get("diseaseName"));
 | 
	
		
			
				|  |  |         resultMap.put("planTitle", one.get("planTitle"));
 | 
	
		
			
				|  |  |         resultMap.put("planId", one.get("planId"));
 | 
	
		
			
				|  |  |         //指导与汇报
 | 
	
		
			
				|  |  |         List<GuidanceMessageLogDO> messageList = guidanceMessageLogDao.findByPlanDetailId(one.get("id").toString());
 | 
	
		
			
				|  |  |         List<Map<String,Object>> messageMapList = new ArrayList<>();
 | 
	
		
			
				|  |  |         for(GuidanceMessageLogDO one2:messageList){
 | 
	
		
			
				|  |  |             Map<String,Object> map = new HashMap<>();
 | 
	
		
			
				|  |  |             map.put("doctorName",one2.getDoctorName());
 | 
	
		
			
				|  |  |             map.put("adminTeamName",one2.getAdminTeamName());
 | 
	
		
			
				|  |  |             map.put("content",one2.getContent());
 | 
	
		
			
				|  |  |             map.put("contentType",one2.getContentType());
 | 
	
		
			
				|  |  |             map.put("doctorType",one2.getDoctorType());//医生类型
 | 
	
		
			
				|  |  |             map.put("createTime",DateUtil.dateToStr(one2.getCreateTime(),"MM-dd HH:mm"));
 | 
	
		
			
				|  |  |         List<Map<String, Object>> messageMapList = new ArrayList<>();
 | 
	
		
			
				|  |  |         for (GuidanceMessageLogDO one2 : messageList) {
 | 
	
		
			
				|  |  |             Map<String, Object> map = new HashMap<>();
 | 
	
		
			
				|  |  |             map.put("doctorName", one2.getDoctorName());
 | 
	
		
			
				|  |  |             map.put("adminTeamName", one2.getAdminTeamName());
 | 
	
		
			
				|  |  |             map.put("content", one2.getContent());
 | 
	
		
			
				|  |  |             map.put("contentType", one2.getContentType());
 | 
	
		
			
				|  |  |             map.put("doctorType", one2.getDoctorType());//医生类型
 | 
	
		
			
				|  |  |             map.put("createTime", DateUtil.dateToStr(one2.getCreateTime(), "MM-dd HH:mm"));
 | 
	
		
			
				|  |  |             messageMapList.add(map);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         resultMap.put("messageList",messageMapList);//指导与汇报记录
 | 
	
		
			
				|  |  |         resultMap.put("patient",one.get("patient"));
 | 
	
		
			
				|  |  |         resultMap.put("patientName",one.get("patientName"));
 | 
	
		
			
				|  |  |         resultMap.put("type",one.get("itemType"));//1扫码、0上传附件、2、健康教育,3、健康指导,4、随访
 | 
	
		
			
				|  |  |         resultMap.put("messageList", messageMapList);//指导与汇报记录
 | 
	
		
			
				|  |  |         resultMap.put("patient", one.get("patient"));
 | 
	
		
			
				|  |  |         resultMap.put("patientName", one.get("patientName"));
 | 
	
		
			
				|  |  |         resultMap.put("type", one.get("itemType"));//1扫码、0上传附件、2、健康教育,3、健康指导,4、随访
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //是否完成任务
 | 
	
		
			
				|  |  |         List<RehabilitationOperateRecordsDO> operateList = new ArrayList<>();
 | 
	
		
			
				|  |  |         if(StringUtils.isNoneBlank(recordId)){
 | 
	
		
			
				|  |  |             operateList= rehabilitationOperateRecordsDao.findByRehabilitationDetailIdAndId(one.get("id").toString(),recordId);
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             operateList= rehabilitationOperateRecordsDao.findByRehabilitationDetailId(one.get("id").toString());
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(recordId)) {
 | 
	
		
			
				|  |  |             operateList = rehabilitationOperateRecordsDao.findByRehabilitationDetailIdAndId(one.get("id").toString(), recordId);
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             operateList = rehabilitationOperateRecordsDao.findByRehabilitationDetailId(one.get("id").toString());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Integer operate = 0;
 | 
	
		
			
				|  |  |         if(operateList.size()>0){
 | 
	
		
			
				|  |  |         if (operateList.size() > 0) {
 | 
	
		
			
				|  |  |             RehabilitationOperateRecordsDO temp = operateList.get(0);
 | 
	
		
			
				|  |  |             operate =1;
 | 
	
		
			
				|  |  |             operate = 1;
 | 
	
		
			
				|  |  |             Date completeTime = temp.getCompleteTime();
 | 
	
		
			
				|  |  |             String completeTimeStr = DateUtil.dateToStr(completeTime,DateUtil.YYYY_MM_DD_HH_MM);
 | 
	
		
			
				|  |  |             resultMap.put("completeTime",completeTimeStr);//完成时间
 | 
	
		
			
				|  |  |             resultMap.put("operatorDoctorName",temp.getDoctorName());//执行医生名称
 | 
	
		
			
				|  |  |             resultMap.put("node",temp.getNode());
 | 
	
		
			
				|  |  |             resultMap.put("recordStatus",temp.getStatus());//操作记录
 | 
	
		
			
				|  |  |             resultMap.put("recordRelationCode",temp.getRelationCode());
 | 
	
		
			
				|  |  |             resultMap.put("recordFlag",temp.getFlag());
 | 
	
		
			
				|  |  |             resultMap.put("recordId",temp.getId());
 | 
	
		
			
				|  |  |             String completeTimeStr = DateUtil.dateToStr(completeTime, DateUtil.YYYY_MM_DD_HH_MM);
 | 
	
		
			
				|  |  |             resultMap.put("completeTime", completeTimeStr);//完成时间
 | 
	
		
			
				|  |  |             resultMap.put("operatorDoctorName", temp.getDoctorName());//执行医生名称
 | 
	
		
			
				|  |  |             resultMap.put("node", temp.getNode());
 | 
	
		
			
				|  |  |             resultMap.put("recordStatus", temp.getStatus());//操作记录
 | 
	
		
			
				|  |  |             resultMap.put("recordRelationCode", temp.getRelationCode());
 | 
	
		
			
				|  |  |             resultMap.put("recordFlag", temp.getFlag());
 | 
	
		
			
				|  |  |             resultMap.put("recordId", temp.getId());
 | 
	
		
			
				|  |  |             JSONArray imgs = new JSONArray();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (temp.getRelationRecordImg()!=null&&StringUtils.isNotEmpty(temp.getRelationRecordImg())){
 | 
	
		
			
				|  |  |                 resultMap.put("relationRecordImg",(temp.getRelationRecordImg()!=null&&StringUtils.isNotEmpty(temp.getRelationRecordImg()))?(new JSONArray(temp.getRelationRecordImg())):null);//json格式
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             else{
 | 
	
		
			
				|  |  |                 resultMap.put("relationRecordImg",imgs);
 | 
	
		
			
				|  |  |             if (temp.getRelationRecordImg() != null && StringUtils.isNotEmpty(temp.getRelationRecordImg())) {
 | 
	
		
			
				|  |  |                 resultMap.put("relationRecordImg", (temp.getRelationRecordImg() != null && StringUtils.isNotEmpty(temp.getRelationRecordImg())) ? (new JSONArray(temp.getRelationRecordImg())) : null);//json格式
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 resultMap.put("relationRecordImg", imgs);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |          /*   if(itemType!=1&&itemType!=0){*/
 | 
	
		
			
				|  |  |                 resultMap.put("relationRecordCode",temp.getRelationRecordCode());
 | 
	
		
			
				|  |  |                 resultMap.put("completeTimeShort",DateUtil.dateToStr(completeTime,"yyyy/MM/dd"));
 | 
	
		
			
				|  |  |   /*          }*/
 | 
	
		
			
				|  |  |             /*   if(itemType!=1&&itemType!=0){*/
 | 
	
		
			
				|  |  |             resultMap.put("relationRecordCode", temp.getRelationRecordCode());
 | 
	
		
			
				|  |  |             resultMap.put("completeTimeShort", DateUtil.dateToStr(completeTime, "yyyy/MM/dd"));
 | 
	
		
			
				|  |  |             /*          }*/
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         resultMap.put("operate",operate);//是否完成任务(默认0:未完成,1:已完成)
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultMap);
 | 
	
		
			
				|  |  |         resultMap.put("operate", operate);//是否完成任务(默认0:未完成,1:已完成)
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success, resultMap);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 康复管理居民详情页
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param patientCode
 | 
	
		
			
				|  |  |      * @param healthDoctor
 | 
	
		
			
				|  |  |      * @param healthDoctorName
 | 
	
	
		
			
				|  | @ -780,218 +827,244 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |      * @param generalDoctorName
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public ObjEnvelop patientRehabilitationDetail(String patientCode,String healthDoctor,String healthDoctorName,String generalDoctor,String generalDoctorName){
 | 
	
		
			
				|  |  |     public ObjEnvelop patientRehabilitationDetail(String patientCode, String healthDoctor, String healthDoctorName, String generalDoctor, String generalDoctorName) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Map<String,Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  |         Map<String, Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //个人基础信息(康复机构)
 | 
	
		
			
				|  |  |         String patientInfoSql = " SELECT DISTINCT hospital_name from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
 | 
	
		
			
				|  |  |                 " where p.patient='"+patientCode+"' and p.status=1 ";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> patientInfoList = jdbcTemplate.queryForList(patientInfoSql);
 | 
	
		
			
				|  |  |         Map<String,Object> patientInfo = new HashMap<>();
 | 
	
		
			
				|  |  |                 " where p.patient='" + patientCode + "' and p.status=1 ";
 | 
	
		
			
				|  |  |         List<Map<String, Object>> patientInfoList = jdbcTemplate.queryForList(patientInfoSql);
 | 
	
		
			
				|  |  |         Map<String, Object> patientInfo = new HashMap<>();
 | 
	
		
			
				|  |  |         String rehabilitationOrg = "";
 | 
	
		
			
				|  |  |         for(Map<String,Object> one:patientInfoList){
 | 
	
		
			
				|  |  |             rehabilitationOrg+=","+one.get("hospital_name");
 | 
	
		
			
				|  |  |         for (Map<String, Object> one : patientInfoList) {
 | 
	
		
			
				|  |  |             rehabilitationOrg += "," + one.get("hospital_name");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         patientInfo.put("rehabilitationOrg",StringUtils.isNotEmpty(rehabilitationOrg)?rehabilitationOrg.substring(1):"");
 | 
	
		
			
				|  |  |         resultMap.put("patientInfo",patientInfo);
 | 
	
		
			
				|  |  |         patientInfo.put("rehabilitationOrg", StringUtils.isNotEmpty(rehabilitationOrg) ? rehabilitationOrg.substring(1) : "");
 | 
	
		
			
				|  |  |         resultMap.put("patientInfo", patientInfo);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //服务医生
 | 
	
		
			
				|  |  |         //完成项目=全部的服务项目-未完成的服务项目
 | 
	
		
			
				|  |  |         List<Map<String,Object>> serviceDoctorList = new ArrayList<>();
 | 
	
		
			
				|  |  |         List<Map<String, Object>> serviceDoctorList = new ArrayList<>();
 | 
	
		
			
				|  |  |         //全科医生和健管师要是同一个人,就显示全科医生
 | 
	
		
			
				|  |  |   /*      if(!generalDoctor.equals(healthDoctor)){
 | 
	
		
			
				|  |  | */
 | 
	
		
			
				|  |  |             if(StringUtils.isNotEmpty(healthDoctor)){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String,Object> healthDoctorMap =  new HashMap<>();
 | 
	
		
			
				|  |  |                 healthDoctorMap.put("type","健管师");
 | 
	
		
			
				|  |  |                 healthDoctorMap.put("doctorName",healthDoctorName);
 | 
	
		
			
				|  |  |                 healthDoctorMap.put("doctorCode",healthDoctor);
 | 
	
		
			
				|  |  |                 Integer healthUnfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(healthDoctor,patientCode,1);
 | 
	
		
			
				|  |  |                 Integer healthFinishCount = rehabilitationDetailDao.findItemByDoctor(healthDoctor,patientCode);
 | 
	
		
			
				|  |  |                 Integer healthServiceCount = rehabilitationDetailDao.completeServiceByDoctor(healthDoctor,patientCode,1);
 | 
	
		
			
				|  |  |                 healthDoctorMap.put("finishedItem",healthFinishCount-healthUnfinishCount);
 | 
	
		
			
				|  |  |                 healthDoctorMap.put("serviceCount",healthServiceCount);
 | 
	
		
			
				|  |  |                 serviceDoctorList.add(healthDoctorMap);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | /*        }*/
 | 
	
		
			
				|  |  |         if(StringUtils.isNotEmpty(generalDoctor)){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Map<String,Object> generalDoctorMap =  new HashMap<>();
 | 
	
		
			
				|  |  |             generalDoctorMap.put("type","全科医生");
 | 
	
		
			
				|  |  |             generalDoctorMap.put("doctorName",generalDoctorName);
 | 
	
		
			
				|  |  |             generalDoctorMap.put("doctorCode",generalDoctor);
 | 
	
		
			
				|  |  |             Integer generalUnfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(generalDoctor,patientCode,1);
 | 
	
		
			
				|  |  |             Integer generalFinishCount = rehabilitationDetailDao.findItemByDoctor(generalDoctor,patientCode);
 | 
	
		
			
				|  |  |             Integer generalServiceCount = rehabilitationDetailDao.completeServiceByDoctor(generalDoctor,patientCode,1);
 | 
	
		
			
				|  |  |             generalDoctorMap.put("finishedItem",generalFinishCount-generalUnfinishCount);
 | 
	
		
			
				|  |  |             generalDoctorMap.put("serviceCount",generalServiceCount);
 | 
	
		
			
				|  |  |         /*      if(!generalDoctor.equals(healthDoctor)){
 | 
	
		
			
				|  |  |          */
 | 
	
		
			
				|  |  |         if (StringUtils.isNotEmpty(healthDoctor)) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Map<String, Object> healthDoctorMap = new HashMap<>();
 | 
	
		
			
				|  |  |             healthDoctorMap.put("type", "健管师");
 | 
	
		
			
				|  |  |             healthDoctorMap.put("doctorName", healthDoctorName);
 | 
	
		
			
				|  |  |             healthDoctorMap.put("doctorCode", healthDoctor);
 | 
	
		
			
				|  |  |             Integer healthUnfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(healthDoctor, patientCode, 1);
 | 
	
		
			
				|  |  |             Integer healthFinishCount = rehabilitationDetailDao.findItemByDoctor(healthDoctor, patientCode);
 | 
	
		
			
				|  |  |             Integer healthServiceCount = rehabilitationDetailDao.completeServiceByDoctor(healthDoctor, patientCode, 1);
 | 
	
		
			
				|  |  |             healthDoctorMap.put("finishedItem", healthFinishCount - healthUnfinishCount);
 | 
	
		
			
				|  |  |             healthDoctorMap.put("serviceCount", healthServiceCount);
 | 
	
		
			
				|  |  |             serviceDoctorList.add(healthDoctorMap);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         /*        }*/
 | 
	
		
			
				|  |  |         if (StringUtils.isNotEmpty(generalDoctor)) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Map<String, Object> generalDoctorMap = new HashMap<>();
 | 
	
		
			
				|  |  |             generalDoctorMap.put("type", "全科医生");
 | 
	
		
			
				|  |  |             generalDoctorMap.put("doctorName", generalDoctorName);
 | 
	
		
			
				|  |  |             generalDoctorMap.put("doctorCode", generalDoctor);
 | 
	
		
			
				|  |  |             Integer generalUnfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(generalDoctor, patientCode, 1);
 | 
	
		
			
				|  |  |             Integer generalFinishCount = rehabilitationDetailDao.findItemByDoctor(generalDoctor, patientCode);
 | 
	
		
			
				|  |  |             Integer generalServiceCount = rehabilitationDetailDao.completeServiceByDoctor(generalDoctor, patientCode, 1);
 | 
	
		
			
				|  |  |             generalDoctorMap.put("finishedItem", generalFinishCount - generalUnfinishCount);
 | 
	
		
			
				|  |  |             generalDoctorMap.put("serviceCount", generalServiceCount);
 | 
	
		
			
				|  |  |             serviceDoctorList.add(generalDoctorMap);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String specialistRelationSql = "select DISTINCT d.doctor,d.doctor_name from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.type=2 and  p.patient='"+patientCode+"'";
 | 
	
		
			
				|  |  |         String specialistRelationSql = "select DISTINCT d.doctor,d.doctor_name from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.type=2 and  p.patient='" + patientCode + "'";
 | 
	
		
			
				|  |  |         specialistRelationSql = TransforSqlUtl.wlyy_rehabilitation_plan_detailDoctorName2(specialistRelationSql);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> specialistRelationList = jdbcTemplate.queryForList(specialistRelationSql);
 | 
	
		
			
				|  |  |         for(Map<String,Object> one:specialistRelationList){
 | 
	
		
			
				|  |  |             String doctor = one.get("doctor")+"";
 | 
	
		
			
				|  |  |             String doctorName = one.get("doctor_name")+"";
 | 
	
		
			
				|  |  |             Integer unfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(doctor,patientCode,1);
 | 
	
		
			
				|  |  |             Integer finishCount = rehabilitationDetailDao.findItemByDoctor(doctor,patientCode);
 | 
	
		
			
				|  |  |             Integer serviceCount = rehabilitationDetailDao.completeServiceByDoctor(doctor,patientCode,1);
 | 
	
		
			
				|  |  |             Map<String,Object> map =  new HashMap<>();
 | 
	
		
			
				|  |  |             map.put("finishedItem",finishCount-unfinishCount);
 | 
	
		
			
				|  |  |             map.put("serviceCount",serviceCount);
 | 
	
		
			
				|  |  |             map.put("doctorName",doctorName);
 | 
	
		
			
				|  |  |             map.put("doctorCode",doctor);
 | 
	
		
			
				|  |  |             map.put("type","专科医生");
 | 
	
		
			
				|  |  |         List<Map<String, Object>> specialistRelationList = jdbcTemplate.queryForList(specialistRelationSql);
 | 
	
		
			
				|  |  |         for (Map<String, Object> one : specialistRelationList) {
 | 
	
		
			
				|  |  |             String doctor = one.get("doctor") + "";
 | 
	
		
			
				|  |  |             String doctorName = one.get("doctor_name") + "";
 | 
	
		
			
				|  |  |             Integer unfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(doctor, patientCode, 1);
 | 
	
		
			
				|  |  |             Integer finishCount = rehabilitationDetailDao.findItemByDoctor(doctor, patientCode);
 | 
	
		
			
				|  |  |             Integer serviceCount = rehabilitationDetailDao.completeServiceByDoctor(doctor, patientCode, 1);
 | 
	
		
			
				|  |  |             Map<String, Object> map = new HashMap<>();
 | 
	
		
			
				|  |  |             map.put("finishedItem", finishCount - unfinishCount);
 | 
	
		
			
				|  |  |             map.put("serviceCount", serviceCount);
 | 
	
		
			
				|  |  |             map.put("doctorName", doctorName);
 | 
	
		
			
				|  |  |             map.put("doctorCode", doctor);
 | 
	
		
			
				|  |  |             map.put("type", "专科医生");
 | 
	
		
			
				|  |  |             serviceDoctorList.add(map);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         resultMap.put("serviceDoctorList",serviceDoctorList);
 | 
	
		
			
				|  |  |         resultMap.put("serviceDoctorList", serviceDoctorList);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //康复计划
 | 
	
		
			
				|  |  |         List<Map<String,Object>> planList = new ArrayList<>();
 | 
	
		
			
				|  |  |         List<Map<String, Object>> planList = new ArrayList<>();
 | 
	
		
			
				|  |  |         List<PatientRehabilitationPlanDO> list = patientRehabilitationPlanDao.findByPatients(patientCode);
 | 
	
		
			
				|  |  |         Integer planUnderway = 0;//进行中
 | 
	
		
			
				|  |  |         Integer planFinish = 0;//已完成
 | 
	
		
			
				|  |  |         for(PatientRehabilitationPlanDO one:list){
 | 
	
		
			
				|  |  |             if(one.getStatus()==1){
 | 
	
		
			
				|  |  |                 planUnderway+=1;
 | 
	
		
			
				|  |  |             }else if(one.getStatus()==2){
 | 
	
		
			
				|  |  |                 planFinish+=1;
 | 
	
		
			
				|  |  |         for (PatientRehabilitationPlanDO one : list) {
 | 
	
		
			
				|  |  |             if (one.getStatus() == 1) {
 | 
	
		
			
				|  |  |                 planUnderway += 1;
 | 
	
		
			
				|  |  |             } else if (one.getStatus() == 2) {
 | 
	
		
			
				|  |  |                 planFinish += 1;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Map<String,Object> map =  new HashMap<>();
 | 
	
		
			
				|  |  |             Map<String, Object> map = new HashMap<>();
 | 
	
		
			
				|  |  |             //安排类型
 | 
	
		
			
				|  |  |             String planTypeName = null;
 | 
	
		
			
				|  |  |             Integer planTypeTemp = one.getPlanType();
 | 
	
		
			
				|  |  |             switch (planTypeTemp){
 | 
	
		
			
				|  |  |                 case 1:planTypeName="康复计划" ;break;
 | 
	
		
			
				|  |  |                 case 2:planTypeName="(转)社区医院" ;break;
 | 
	
		
			
				|  |  |                 case 3:planTypeName="(转)转家庭病床" ;break;
 | 
	
		
			
				|  |  |             switch (planTypeTemp) {
 | 
	
		
			
				|  |  |                 case 1:
 | 
	
		
			
				|  |  |                     planTypeName = "康复计划";
 | 
	
		
			
				|  |  |                     break;
 | 
	
		
			
				|  |  |                 case 2:
 | 
	
		
			
				|  |  |                     planTypeName = "(转)社区医院";
 | 
	
		
			
				|  |  |                     break;
 | 
	
		
			
				|  |  |                 case 3:
 | 
	
		
			
				|  |  |                     planTypeName = "(转)转家庭病床";
 | 
	
		
			
				|  |  |                     break;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             map.put("createUser",one.getCreateUser());
 | 
	
		
			
				|  |  |             map.put("createUserName",one.getCreateUserName());
 | 
	
		
			
				|  |  |             map.put("planId",one.getId());
 | 
	
		
			
				|  |  |             map.put("planTypeName",planTypeName);
 | 
	
		
			
				|  |  |             map.put("createUser", one.getCreateUser());
 | 
	
		
			
				|  |  |             map.put("createUserName", one.getCreateUserName());
 | 
	
		
			
				|  |  |             map.put("planId", one.getId());
 | 
	
		
			
				|  |  |             map.put("planTypeName", planTypeName);
 | 
	
		
			
				|  |  |             String statusName = "";
 | 
	
		
			
				|  |  |             Integer status = one.getStatus();
 | 
	
		
			
				|  |  |             switch (status){
 | 
	
		
			
				|  |  |                 case 0:{statusName="已中止";break;}
 | 
	
		
			
				|  |  |                 case 1:{statusName="进行中";break;}
 | 
	
		
			
				|  |  |                 case 2:{statusName="已完成";break;}
 | 
	
		
			
				|  |  |             switch (status) {
 | 
	
		
			
				|  |  |                 case 0: {
 | 
	
		
			
				|  |  |                     statusName = "已中止";
 | 
	
		
			
				|  |  |                     break;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 case 1: {
 | 
	
		
			
				|  |  |                     statusName = "进行中";
 | 
	
		
			
				|  |  |                     break;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 case 2: {
 | 
	
		
			
				|  |  |                     statusName = "已完成";
 | 
	
		
			
				|  |  |                     break;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             map.put("planTypeName",planTypeName);//安排类型名称
 | 
	
		
			
				|  |  |             map.put("statusName",statusName);//状态名称
 | 
	
		
			
				|  |  |             map.put("medicalRecordsCode",one.getMedicalRecordsCode());//住院code
 | 
	
		
			
				|  |  |             map.put("adviceContent",one.getAdviceContent());//康复建议
 | 
	
		
			
				|  |  |             map.put("planTypeName", planTypeName);//安排类型名称
 | 
	
		
			
				|  |  |             map.put("statusName", statusName);//状态名称
 | 
	
		
			
				|  |  |             map.put("medicalRecordsCode", one.getMedicalRecordsCode());//住院code
 | 
	
		
			
				|  |  |             map.put("adviceContent", one.getAdviceContent());//康复建议
 | 
	
		
			
				|  |  |             //已完成
 | 
	
		
			
				|  |  |             Integer allFinishCount = rehabilitationDetailDao.findByStatusAndPlanId(1,one.getId());
 | 
	
		
			
				|  |  |             map.put("allFinishCount",allFinishCount);//已完成
 | 
	
		
			
				|  |  |             Integer allFinishCount = rehabilitationDetailDao.findByStatusAndPlanId(1, one.getId());
 | 
	
		
			
				|  |  |             map.put("allFinishCount", allFinishCount);//已完成
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //完成度(已完成/(已完成+未完成))
 | 
	
		
			
				|  |  |             Integer allCount = rehabilitationDetailDao.findAllByPlanId(one.getId());
 | 
	
		
			
				|  |  |             map.put("allCount",allCount);//总数
 | 
	
		
			
				|  |  |             map.put("allCount", allCount);//总数
 | 
	
		
			
				|  |  |             List<RehabilitationDetailDO> detailList = rehabilitationDetailDao.getAllRehabilitationDetail(one.getId());
 | 
	
		
			
				|  |  |             if(detailList.size()>0){
 | 
	
		
			
				|  |  |             if (detailList.size() > 0) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Date executeTimeStart = detailList.get(0).getExecuteTime();
 | 
	
		
			
				|  |  |                 Date executeTimeEnd = detailList.get(detailList.size()-1).getExecuteTime();
 | 
	
		
			
				|  |  |                 String executeStart = DateUtil.dateToStr(executeTimeStart,"yyyy/MM/dd");
 | 
	
		
			
				|  |  |                 String executeEnd = DateUtil.dateToStr(executeTimeEnd,"yyyy/MM/dd");
 | 
	
		
			
				|  |  |                 map.put("time",executeStart+"-"+executeEnd);
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 map.put("time","");
 | 
	
		
			
				|  |  |                 Date executeTimeEnd = detailList.get(detailList.size() - 1).getExecuteTime();
 | 
	
		
			
				|  |  |                 String executeStart = DateUtil.dateToStr(executeTimeStart, "yyyy/MM/dd");
 | 
	
		
			
				|  |  |                 String executeEnd = DateUtil.dateToStr(executeTimeEnd, "yyyy/MM/dd");
 | 
	
		
			
				|  |  |                 map.put("time", executeStart + "-" + executeEnd);
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 map.put("time", "");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             planList.add(map);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         resultMap.put("planList",planList);
 | 
	
		
			
				|  |  |         resultMap.put("planList", planList);
 | 
	
		
			
				|  |  |         //康复计划-已完成、进行中
 | 
	
		
			
				|  |  |         resultMap.put("planUnderway",planUnderway);//进行中
 | 
	
		
			
				|  |  |         resultMap.put("planFinish",planFinish);//已完成
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultMap);
 | 
	
		
			
				|  |  |         resultMap.put("planUnderway", planUnderway);//进行中
 | 
	
		
			
				|  |  |         resultMap.put("planFinish", planFinish);//已完成
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success, resultMap);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 居民康复计划详情页-近期康复相关记录
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param patientCode
 | 
	
		
			
				|  |  |      * @param startTime
 | 
	
		
			
				|  |  |      * @param endTime
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public ObjEnvelop recentPlanDetailRecord(String patientCode,String startTime,String endTime,Integer page, Integer pageSize) throws Exception{
 | 
	
		
			
				|  |  |         Map<String,Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  |     public ObjEnvelop recentPlanDetailRecord(String patientCode, String startTime, String endTime, Integer page, Integer pageSize) throws Exception {
 | 
	
		
			
				|  |  |         Map<String, Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  |         //近期康复相关记录
 | 
	
		
			
				|  |  | //        String currentTime = DateUtil.getStringDate();
 | 
	
		
			
				|  |  |         String planDetailSql = " select d.*,h.name,h.code,s.complete_time from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_rehabilitation_service_item h on d.hospital_service_item_id=h.code" +
 | 
	
		
			
				|  |  |                 " LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id" +
 | 
	
		
			
				|  |  |                 " left join wlyy_rehabilitation_operate_records s on s.rehabilitation_detail_id=d.id " +
 | 
	
		
			
				|  |  |                 " where d.status=1 and p.patient='"+patientCode+"' and d.frequency_code IS NOT NULL AND d.frequency_code <>'' ";
 | 
	
		
			
				|  |  |         if(StringUtils.isNotEmpty(startTime)){
 | 
	
		
			
				|  |  |             planDetailSql += "  and d.execute_Time>='"+startTime+"' ";
 | 
	
		
			
				|  |  |                 " where d.status=1 and p.patient='" + patientCode + "' and d.frequency_code IS NOT NULL AND d.frequency_code <>'' ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNotEmpty(startTime)) {
 | 
	
		
			
				|  |  |             planDetailSql += "  and d.execute_Time>='" + startTime + "' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotEmpty(endTime)){
 | 
	
		
			
				|  |  |             planDetailSql += "  and d.execute_time<='"+endTime+"' ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNotEmpty(endTime)) {
 | 
	
		
			
				|  |  |             planDetailSql += "  and d.execute_time<='" + endTime + "' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         planDetailSql += " ORDER BY s.complete_time DESC LIMIT "+(page-1)*pageSize+","+pageSize;
 | 
	
		
			
				|  |  |         planDetailSql += " ORDER BY s.complete_time DESC LIMIT " + (page - 1) * pageSize + "," + pageSize;
 | 
	
		
			
				|  |  |         planDetailSql = TransforSqlUtl.wlyy_rehabilitation_plan_detailAll2(planDetailSql);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> planDetails = jdbcTemplate.queryForList(planDetailSql);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> planDetailList = new ArrayList<>();
 | 
	
		
			
				|  |  |         for(Map<String,Object> one:planDetails){
 | 
	
		
			
				|  |  |             Date executeTimeDate = (Date)one.get("complete_time");
 | 
	
		
			
				|  |  |             String executeTime = DateUtil.dateToStr(executeTimeDate,"yyyy/MM/dd HH:mm");
 | 
	
		
			
				|  |  |             String content = one.get("code")+"";
 | 
	
		
			
				|  |  |             String title = one.get("name")+"";
 | 
	
		
			
				|  |  |             Integer status = (Integer)one.get("status");
 | 
	
		
			
				|  |  |         List<Map<String, Object>> planDetails = jdbcTemplate.queryForList(planDetailSql);
 | 
	
		
			
				|  |  |         List<Map<String, Object>> planDetailList = new ArrayList<>();
 | 
	
		
			
				|  |  |         for (Map<String, Object> one : planDetails) {
 | 
	
		
			
				|  |  |             Date executeTimeDate = (Date) one.get("complete_time");
 | 
	
		
			
				|  |  |             String executeTime = DateUtil.dateToStr(executeTimeDate, "yyyy/MM/dd HH:mm");
 | 
	
		
			
				|  |  |             String content = one.get("code") + "";
 | 
	
		
			
				|  |  |             String title = one.get("name") + "";
 | 
	
		
			
				|  |  |             Integer status = (Integer) one.get("status");
 | 
	
		
			
				|  |  |             String statusName = "";
 | 
	
		
			
				|  |  |             switch (status){
 | 
	
		
			
				|  |  |                 case 0:{statusName="未完成";break;}
 | 
	
		
			
				|  |  |                 case 1:{statusName="已完成";break;}
 | 
	
		
			
				|  |  |                 case 2:{statusName="已预约";break;}
 | 
	
		
			
				|  |  |             switch (status) {
 | 
	
		
			
				|  |  |                 case 0: {
 | 
	
		
			
				|  |  |                     statusName = "未完成";
 | 
	
		
			
				|  |  |                     break;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 case 1: {
 | 
	
		
			
				|  |  |                     statusName = "已完成";
 | 
	
		
			
				|  |  |                     break;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 case 2: {
 | 
	
		
			
				|  |  |                     statusName = "已预约";
 | 
	
		
			
				|  |  |                     break;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String id = one.get("id").toString();
 | 
	
		
			
				|  |  |             Map<String,Object> map = new HashMap<>();
 | 
	
		
			
				|  |  |             map.put("id",id);//id
 | 
	
		
			
				|  |  |             Map<String, Object> map = new HashMap<>();
 | 
	
		
			
				|  |  |             map.put("id", id);//id
 | 
	
		
			
				|  |  | //            List<RehabilitationOperateRecordsDO> rehabilitationOperateRecords = rehabilitationOperateRecordsDao.findByRehabilitationDetailId(id);
 | 
	
		
			
				|  |  | //            Date completeTime = rehabilitationOperateRecords!=null&&rehabilitationOperateRecords.size()>0?rehabilitationOperateRecords.get(0).getCompleteTime():null;
 | 
	
		
			
				|  |  | //            String completeTimeStr =  completeTime!=null?DateUtil.dateToStr(completeTime,"yyyy/MM/dd HH:mm"):"";
 | 
	
		
			
				|  |  |             map.put("executeTime",executeTime);//执行时间
 | 
	
		
			
				|  |  |             map.put("title",title);//项目标题
 | 
	
		
			
				|  |  |             map.put("content",content);//项目内容
 | 
	
		
			
				|  |  |             map.put("statusName",statusName);//状态名称
 | 
	
		
			
				|  |  |             map.put("executeTime", executeTime);//执行时间
 | 
	
		
			
				|  |  |             map.put("title", title);//项目标题
 | 
	
		
			
				|  |  |             map.put("content", content);//项目内容
 | 
	
		
			
				|  |  |             map.put("statusName", statusName);//状态名称
 | 
	
		
			
				|  |  |             planDetailList.add(map);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         resultMap.put("planDetailList",planDetailList);//康复相关记录列表
 | 
	
		
			
				|  |  |         resultMap.put("planDetailList", planDetailList);//康复相关记录列表
 | 
	
		
			
				|  |  |         String planDetailCountSql = " select d.status as num from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_rehabilitation_service_item h on d.hospital_service_item_id=h.code" +
 | 
	
		
			
				|  |  |                 "  LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where p.patient='"+patientCode+"'";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> planDetailList2 = jdbcTemplate.queryForList(planDetailCountSql);
 | 
	
		
			
				|  |  |                 "  LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where p.patient='" + patientCode + "'";
 | 
	
		
			
				|  |  |         List<Map<String, Object>> planDetailList2 = jdbcTemplate.queryForList(planDetailCountSql);
 | 
	
		
			
				|  |  |         Integer planDetailFinish = 0;
 | 
	
		
			
				|  |  |         Integer planDetailUnfinish = 0;
 | 
	
		
			
				|  |  |         for(Map<String,Object> one:planDetailList2){
 | 
	
		
			
				|  |  |         for (Map<String, Object> one : planDetailList2) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Integer status = (Integer)one.get("num");
 | 
	
		
			
				|  |  |             if(status==1){
 | 
	
		
			
				|  |  |                 planDetailFinish+=1;
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 planDetailUnfinish+=1;
 | 
	
		
			
				|  |  |             Integer status = (Integer) one.get("num");
 | 
	
		
			
				|  |  |             if (status == 1) {
 | 
	
		
			
				|  |  |                 planDetailFinish += 1;
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 planDetailUnfinish += 1;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         resultMap.put("planDetailFinish",planDetailFinish);//已完成
 | 
	
		
			
				|  |  |         resultMap.put("planDetailUnfinish",planDetailUnfinish);//未完成
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultMap);
 | 
	
		
			
				|  |  |         resultMap.put("planDetailFinish", planDetailFinish);//已完成
 | 
	
		
			
				|  |  |         resultMap.put("planDetailUnfinish", planDetailUnfinish);//未完成
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success, resultMap);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 保存康复管理指导留言信息
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param messageId
 | 
	
		
			
				|  |  |      * @param doctor
 | 
	
		
			
				|  |  |      * @param doctorType 1、专科医生,2、家庭医生
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @Transactional
 | 
	
		
			
				|  |  |     public Envelop saveGuidanceMessage(String messageId,String doctor,Integer doctorType,String content,String planDetailId,Integer contentType) throws Exception{
 | 
	
		
			
				|  |  |     public Envelop saveGuidanceMessage(String messageId, String doctor, Integer doctorType, String content, String planDetailId, Integer contentType) throws Exception {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<String> patientList = rehabilitationDetailDao.findPatientById(planDetailId);
 | 
	
		
			
				|  |  |         String patient = patientList.size()>0?patientList.get(0):"";
 | 
	
		
			
				|  |  |         String patient = patientList.size() > 0 ? patientList.get(0) : "";
 | 
	
		
			
				|  |  |         GuidanceMessageLogDO guidanceMessageLogDO = new GuidanceMessageLogDO();
 | 
	
		
			
				|  |  |         guidanceMessageLogDO.setMessageId(messageId);
 | 
	
		
			
				|  |  |         guidanceMessageLogDO.setPlanDetailId(planDetailId);
 | 
	
	
		
			
				|  | @ -1001,19 +1074,19 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |         guidanceMessageLogDO.setDoctorType(doctorType);
 | 
	
		
			
				|  |  |         Integer adminTeamCode = null;
 | 
	
		
			
				|  |  |         String doctorName = null;
 | 
	
		
			
				|  |  |         if(doctorType==1){
 | 
	
		
			
				|  |  |         if (doctorType == 1) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             SpecialistPatientRelationDO specialistPatientRelationDO = specialistPatientRelationDao.findByPatientAndDoctor(doctor,patient);
 | 
	
		
			
				|  |  |             SpecialistPatientRelationDO specialistPatientRelationDO = specialistPatientRelationDao.findByPatientAndDoctor(doctor, patient);
 | 
	
		
			
				|  |  |             adminTeamCode = specialistPatientRelationDO.getTeamCode();
 | 
	
		
			
				|  |  |             doctorName = specialistPatientRelationDO.getDoctorName();
 | 
	
		
			
				|  |  |         }else if(doctorType==2){
 | 
	
		
			
				|  |  |             String signFamilySql = " select f.* from "+basedb+".wlyy_sign_family f where f.status=1 and f.expenses_status='1' and f.patient='"+patient+"'";
 | 
	
		
			
				|  |  |             List<Map<String,Object>> signFamily = jdbcTemplate.queryForList(signFamilySql);
 | 
	
		
			
				|  |  |             adminTeamCode = (Integer)signFamily.get(0).get("admin_team_code");
 | 
	
		
			
				|  |  |         } else if (doctorType == 2) {
 | 
	
		
			
				|  |  |             String signFamilySql = " select f.* from " + basedb + ".wlyy_sign_family f where f.status=1 and f.expenses_status='1' and f.patient='" + patient + "'";
 | 
	
		
			
				|  |  |             List<Map<String, Object>> signFamily = jdbcTemplate.queryForList(signFamilySql);
 | 
	
		
			
				|  |  |             adminTeamCode = (Integer) signFamily.get(0).get("admin_team_code");
 | 
	
		
			
				|  |  |             doctorName = signFamily.get(0).get("doctor_name").toString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String adminTeamSql = " select t.* from "+basedb+".wlyy_admin_team t where t.available=1 and t.id="+adminTeamCode;
 | 
	
		
			
				|  |  |         List<Map<String,Object>> adminTeam = jdbcTemplate.queryForList(adminTeamSql);
 | 
	
		
			
				|  |  |         String adminTeamSql = " select t.* from " + basedb + ".wlyy_admin_team t where t.available=1 and t.id=" + adminTeamCode;
 | 
	
		
			
				|  |  |         List<Map<String, Object>> adminTeam = jdbcTemplate.queryForList(adminTeamSql);
 | 
	
		
			
				|  |  |         String adminTeamName = adminTeam.get(0).get("name").toString();
 | 
	
		
			
				|  |  |         guidanceMessageLogDO.setAdminTeamCode(adminTeamCode);
 | 
	
		
			
				|  |  |         guidanceMessageLogDO.setAdminTeamName(adminTeamName);
 | 
	
	
		
			
				|  | @ -1026,15 +1099,16 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 康复管理-更新康复计划操作完成日志状态
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param planDetailId
 | 
	
		
			
				|  |  |      * @param status
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @Transactional
 | 
	
		
			
				|  |  |     public Envelop updateStatusRehabilitationOperate(Integer status,String planDetailId){
 | 
	
		
			
				|  |  |         if(rehabilitationOperateRecordsDao.updateStatus(status,planDetailId)>0){
 | 
	
		
			
				|  |  |     public Envelop updateStatusRehabilitationOperate(Integer status, String planDetailId) {
 | 
	
		
			
				|  |  |         if (rehabilitationOperateRecordsDao.updateStatus(status, planDetailId) > 0) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |            return Envelop.getSuccess(SpecialistMapping.api_success);
 | 
	
		
			
				|  |  |             return Envelop.getSuccess(SpecialistMapping.api_success);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return Envelop.getError("更新失败!");
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -1042,6 +1116,7 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * app端居民详情服务医生列表
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param patientCode
 | 
	
		
			
				|  |  |      * @param healthDoctor
 | 
	
		
			
				|  |  |      * @param healthDoctorName
 | 
	
	
		
			
				|  | @ -1049,60 +1124,61 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |      * @param generalDoctorName
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public ObjEnvelop serviceDoctorList(String patientCode,String healthDoctor,String healthDoctorName,String generalDoctor,String generalDoctorName){
 | 
	
		
			
				|  |  |     public ObjEnvelop serviceDoctorList(String patientCode, String healthDoctor, String healthDoctorName, String generalDoctor, String generalDoctorName) {
 | 
	
		
			
				|  |  |         //服务医生
 | 
	
		
			
				|  |  |         //完成项目=全部的服务项目-未完成的服务项目
 | 
	
		
			
				|  |  |         List<Map<String,Object>> serviceDoctorList = new ArrayList<>();
 | 
	
		
			
				|  |  |         if(StringUtils.isNotEmpty(generalDoctor)){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Map<String,Object> generalDoctorMap =  new HashMap<>();
 | 
	
		
			
				|  |  |             generalDoctorMap.put("type","全科医生");
 | 
	
		
			
				|  |  |             generalDoctorMap.put("doctorName",generalDoctorName);
 | 
	
		
			
				|  |  |             generalDoctorMap.put("doctorCode",generalDoctor);
 | 
	
		
			
				|  |  |             Integer generalUnfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(generalDoctor,patientCode,1);
 | 
	
		
			
				|  |  |             Integer generalFinishCount = rehabilitationDetailDao.findItemByDoctor(generalDoctor,patientCode);
 | 
	
		
			
				|  |  |             Integer generalServiceCount = rehabilitationDetailDao.completeServiceByDoctor(generalDoctor,patientCode,1);
 | 
	
		
			
				|  |  |             generalDoctorMap.put("finishedItem",generalFinishCount-generalUnfinishCount);
 | 
	
		
			
				|  |  |             generalDoctorMap.put("serviceCount",generalServiceCount);
 | 
	
		
			
				|  |  |         List<Map<String, Object>> serviceDoctorList = new ArrayList<>();
 | 
	
		
			
				|  |  |         if (StringUtils.isNotEmpty(generalDoctor)) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Map<String, Object> generalDoctorMap = new HashMap<>();
 | 
	
		
			
				|  |  |             generalDoctorMap.put("type", "全科医生");
 | 
	
		
			
				|  |  |             generalDoctorMap.put("doctorName", generalDoctorName);
 | 
	
		
			
				|  |  |             generalDoctorMap.put("doctorCode", generalDoctor);
 | 
	
		
			
				|  |  |             Integer generalUnfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(generalDoctor, patientCode, 1);
 | 
	
		
			
				|  |  |             Integer generalFinishCount = rehabilitationDetailDao.findItemByDoctor(generalDoctor, patientCode);
 | 
	
		
			
				|  |  |             Integer generalServiceCount = rehabilitationDetailDao.completeServiceByDoctor(generalDoctor, patientCode, 1);
 | 
	
		
			
				|  |  |             generalDoctorMap.put("finishedItem", generalFinishCount - generalUnfinishCount);
 | 
	
		
			
				|  |  |             generalDoctorMap.put("serviceCount", generalServiceCount);
 | 
	
		
			
				|  |  |             serviceDoctorList.add(generalDoctorMap);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(StringUtils.isNotEmpty(healthDoctor)){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Map<String,Object> healthDoctorMap =  new HashMap<>();
 | 
	
		
			
				|  |  |             healthDoctorMap.put("type","健管师");
 | 
	
		
			
				|  |  |             healthDoctorMap.put("doctorName",healthDoctorName);
 | 
	
		
			
				|  |  |             healthDoctorMap.put("doctorCode",healthDoctor);
 | 
	
		
			
				|  |  |             Integer healthUnfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(healthDoctor,patientCode,1);
 | 
	
		
			
				|  |  |             Integer healthFinishCount = rehabilitationDetailDao.findItemByDoctor(healthDoctor,patientCode);
 | 
	
		
			
				|  |  |             Integer healthServiceCount = rehabilitationDetailDao.completeServiceByDoctor(healthDoctor,patientCode,1);
 | 
	
		
			
				|  |  |             healthDoctorMap.put("finishedItem",healthFinishCount-healthUnfinishCount);
 | 
	
		
			
				|  |  |             healthDoctorMap.put("serviceCount",healthServiceCount);
 | 
	
		
			
				|  |  |         if (StringUtils.isNotEmpty(healthDoctor)) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Map<String, Object> healthDoctorMap = new HashMap<>();
 | 
	
		
			
				|  |  |             healthDoctorMap.put("type", "健管师");
 | 
	
		
			
				|  |  |             healthDoctorMap.put("doctorName", healthDoctorName);
 | 
	
		
			
				|  |  |             healthDoctorMap.put("doctorCode", healthDoctor);
 | 
	
		
			
				|  |  |             Integer healthUnfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(healthDoctor, patientCode, 1);
 | 
	
		
			
				|  |  |             Integer healthFinishCount = rehabilitationDetailDao.findItemByDoctor(healthDoctor, patientCode);
 | 
	
		
			
				|  |  |             Integer healthServiceCount = rehabilitationDetailDao.completeServiceByDoctor(healthDoctor, patientCode, 1);
 | 
	
		
			
				|  |  |             healthDoctorMap.put("finishedItem", healthFinishCount - healthUnfinishCount);
 | 
	
		
			
				|  |  |             healthDoctorMap.put("serviceCount", healthServiceCount);
 | 
	
		
			
				|  |  |             serviceDoctorList.add(healthDoctorMap);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String specialistRelationSql = "select DISTINCT d.doctor,d.doctor_name from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.type=2 AND d.doctor IS  NOT  NULL and  d.doctor <> ''  and  p.patient='"+patientCode+"'";
 | 
	
		
			
				|  |  |         String specialistRelationSql = "select DISTINCT d.doctor,d.doctor_name from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.type=2 AND d.doctor IS  NOT  NULL and  d.doctor <> ''  and  p.patient='" + patientCode + "'";
 | 
	
		
			
				|  |  |         specialistRelationSql = TransforSqlUtl.wlyy_rehabilitation_plan_detailDoctorName2(specialistRelationSql);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> specialistRelationList = jdbcTemplate.queryForList(specialistRelationSql);
 | 
	
		
			
				|  |  |         for(Map<String,Object> one:specialistRelationList){
 | 
	
		
			
				|  |  |             String doctor = one.get("doctor")+"";
 | 
	
		
			
				|  |  |             String doctorName = one.get("doctor_name")+"";
 | 
	
		
			
				|  |  |             Integer unfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(doctor,patientCode,1);
 | 
	
		
			
				|  |  |             Integer finishCount = rehabilitationDetailDao.findItemByDoctor(doctor,patientCode);
 | 
	
		
			
				|  |  |             Integer serviceCount = rehabilitationDetailDao.completeServiceByDoctor(doctor,patientCode,1);
 | 
	
		
			
				|  |  |             Map<String,Object> map =  new HashMap<>();
 | 
	
		
			
				|  |  |             map.put("finishedItem",finishCount-unfinishCount);
 | 
	
		
			
				|  |  |             map.put("serviceCount",serviceCount);
 | 
	
		
			
				|  |  |             map.put("doctorName",doctorName);
 | 
	
		
			
				|  |  |             map.put("doctorCode",doctor);
 | 
	
		
			
				|  |  |             map.put("type","专科医生");
 | 
	
		
			
				|  |  |         List<Map<String, Object>> specialistRelationList = jdbcTemplate.queryForList(specialistRelationSql);
 | 
	
		
			
				|  |  |         for (Map<String, Object> one : specialistRelationList) {
 | 
	
		
			
				|  |  |             String doctor = one.get("doctor") + "";
 | 
	
		
			
				|  |  |             String doctorName = one.get("doctor_name") + "";
 | 
	
		
			
				|  |  |             Integer unfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(doctor, patientCode, 1);
 | 
	
		
			
				|  |  |             Integer finishCount = rehabilitationDetailDao.findItemByDoctor(doctor, patientCode);
 | 
	
		
			
				|  |  |             Integer serviceCount = rehabilitationDetailDao.completeServiceByDoctor(doctor, patientCode, 1);
 | 
	
		
			
				|  |  |             Map<String, Object> map = new HashMap<>();
 | 
	
		
			
				|  |  |             map.put("finishedItem", finishCount - unfinishCount);
 | 
	
		
			
				|  |  |             map.put("serviceCount", serviceCount);
 | 
	
		
			
				|  |  |             map.put("doctorName", doctorName);
 | 
	
		
			
				|  |  |             map.put("doctorCode", doctor);
 | 
	
		
			
				|  |  |             map.put("type", "专科医生");
 | 
	
		
			
				|  |  |             serviceDoctorList.add(map);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success,serviceDoctorList);
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success, serviceDoctorList);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * app端、微信端计划的服务项目列表
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param planId
 | 
	
		
			
				|  |  |      * @param searchTask
 | 
	
		
			
				|  |  |      * @param status
 | 
	
	
		
			
				|  | @ -1110,42 +1186,43 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |      * @param executeEndTime
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public ObjEnvelop appCalendarPlanDetailList(String planId,Integer searchTask,Integer status,String executeStartTime,String executeEndTime){
 | 
	
		
			
				|  |  |     public ObjEnvelop appCalendarPlanDetailList(String planId, Integer searchTask, Integer status, String executeStartTime, String executeEndTime) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Map<String,Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  |         ObjEnvelop objEnvelop = calendarPlanDetailList(planId,searchTask,status,null,executeStartTime,executeEndTime,"0");
 | 
	
		
			
				|  |  |         Integer finishCount = rehabilitationDetailDao.findByStatusAndPlanId(1,planId);
 | 
	
		
			
				|  |  |         Map<String, Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  |         ObjEnvelop objEnvelop = calendarPlanDetailList(planId, searchTask, status, null, executeStartTime, executeEndTime, "0");
 | 
	
		
			
				|  |  |         Integer finishCount = rehabilitationDetailDao.findByStatusAndPlanId(1, planId);
 | 
	
		
			
				|  |  |         Integer allCount = rehabilitationDetailDao.findAllByPlanId(planId);
 | 
	
		
			
				|  |  |         resultMap.put("planDetailList",objEnvelop.getObj());
 | 
	
		
			
				|  |  |         resultMap.put("finishCount",finishCount);
 | 
	
		
			
				|  |  |         resultMap.put("allCount",allCount);
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultMap);
 | 
	
		
			
				|  |  |         resultMap.put("planDetailList", objEnvelop.getObj());
 | 
	
		
			
				|  |  |         resultMap.put("finishCount", finishCount);
 | 
	
		
			
				|  |  |         resultMap.put("allCount", allCount);
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success, resultMap);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 每日康复服务通知
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param startTime
 | 
	
		
			
				|  |  |      * @param endTime
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public ObjEnvelop dailyJob(String startTime,String endTime){
 | 
	
		
			
				|  |  |         String sql = "select d.doctor,p.patient,count(1) as num from wlyy_rehabilitation_plan_detail d left join wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.status!=1 and p.status=1 and d.execute_time>='"+startTime+"' and d.execute_time<='"+endTime+"' GROUP BY d.doctor,p.patient";
 | 
	
		
			
				|  |  |     public ObjEnvelop dailyJob(String startTime, String endTime) {
 | 
	
		
			
				|  |  |         String sql = "select d.doctor,p.patient,count(1) as num from wlyy_rehabilitation_plan_detail d left join wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.status!=1 and p.status=1 and d.execute_time>='" + startTime + "' and d.execute_time<='" + endTime + "' GROUP BY d.doctor,p.patient";
 | 
	
		
			
				|  |  | //        List<Object> list = rehabilitationDetailDao.dailyJob(startTime,endTime);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         String doctorCode = "";
 | 
	
		
			
				|  |  |         String patientCode = "";
 | 
	
		
			
				|  |  |         List<String> listMap  = null;
 | 
	
		
			
				|  |  |         for(Map<String,Object> one:list){
 | 
	
		
			
				|  |  |             doctorCode = one.get("doctor")+"";
 | 
	
		
			
				|  |  |             patientCode = one.get("patient")+"";
 | 
	
		
			
				|  |  |             listMap = rehabilitationDetailDao.findByPatientAndDoctor(startTime,endTime,doctorCode,patientCode);
 | 
	
		
			
				|  |  |         List<String> listMap = null;
 | 
	
		
			
				|  |  |         for (Map<String, Object> one : list) {
 | 
	
		
			
				|  |  |             doctorCode = one.get("doctor") + "";
 | 
	
		
			
				|  |  |             patientCode = one.get("patient") + "";
 | 
	
		
			
				|  |  |             listMap = rehabilitationDetailDao.findByPatientAndDoctor(startTime, endTime, doctorCode, patientCode);
 | 
	
		
			
				|  |  |             String ids = "";
 | 
	
		
			
				|  |  |             for(String one2 : listMap){
 | 
	
		
			
				|  |  |                 ids += ","+one2;
 | 
	
		
			
				|  |  |             for (String one2 : listMap) {
 | 
	
		
			
				|  |  |                 ids += "," + one2;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             one.put("planDetailIds",StringUtils.isNotEmpty(ids)?ids.substring(1):"");
 | 
	
		
			
				|  |  |             one.put("planDetailIds", StringUtils.isNotEmpty(ids) ? ids.substring(1) : "");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success,list);
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success, list);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -1155,24 +1232,24 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |      * @param endTime
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public ObjEnvelop tomorrowJob(String startTime,String endTime){
 | 
	
		
			
				|  |  |         String sql = "select d.doctor,p.patient,count(1) as num,p.id from wlyy_rehabilitation_plan_detail d left join wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.status!=1 and p.status=1 and d.execute_time>='"+startTime+"' and d.execute_time<='"+endTime+"' GROUP BY d.doctor,p.patient";
 | 
	
		
			
				|  |  |     public ObjEnvelop tomorrowJob(String startTime, String endTime) {
 | 
	
		
			
				|  |  |         String sql = "select d.doctor,p.patient,count(1) as num,p.id from wlyy_rehabilitation_plan_detail d left join wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.status!=1 and p.status=1 and d.execute_time>='" + startTime + "' and d.execute_time<='" + endTime + "' GROUP BY d.doctor,p.patient";
 | 
	
		
			
				|  |  | //        List<Object> list = rehabilitationDetailDao.dailyJob(startTime,endTime);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         String doctorCode = "";
 | 
	
		
			
				|  |  |         String patientCode = "";
 | 
	
		
			
				|  |  |         List<String> listMap  = null;
 | 
	
		
			
				|  |  |         for(Map<String,Object> one:list){
 | 
	
		
			
				|  |  |             doctorCode = one.get("doctor")+"";
 | 
	
		
			
				|  |  |             patientCode = one.get("patient")+"";
 | 
	
		
			
				|  |  |             listMap = rehabilitationDetailDao.findByPatientAndDoctor(startTime,endTime,doctorCode,patientCode);
 | 
	
		
			
				|  |  |         List<String> listMap = null;
 | 
	
		
			
				|  |  |         for (Map<String, Object> one : list) {
 | 
	
		
			
				|  |  |             doctorCode = one.get("doctor") + "";
 | 
	
		
			
				|  |  |             patientCode = one.get("patient") + "";
 | 
	
		
			
				|  |  |             listMap = rehabilitationDetailDao.findByPatientAndDoctor(startTime, endTime, doctorCode, patientCode);
 | 
	
		
			
				|  |  |             String ids = "";
 | 
	
		
			
				|  |  |             for(String one2 : listMap){
 | 
	
		
			
				|  |  |                 ids += ","+one2;
 | 
	
		
			
				|  |  |             for (String one2 : listMap) {
 | 
	
		
			
				|  |  |                 ids += "," + one2;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             one.put("planDetailIds",StringUtils.isNotEmpty(ids)?ids.substring(1):"");
 | 
	
		
			
				|  |  |             one.put("planDetailIds", StringUtils.isNotEmpty(ids) ? ids.substring(1) : "");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success,list);
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success, list);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -1183,78 +1260,76 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |      * @param endTime
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public ObjEnvelop dailyByJob(String startTime,String endTime){
 | 
	
		
			
				|  |  |         String sql = "select d.doctor,p.patient,h.service_item_name AS serviceItemName,d.time_type AS timeType from wlyy_rehabilitation_plan_detail d left join wlyy_patient_rehabilitation_plan p on d.plan_id=p.id left join wlyy_hospital_service_item h ON h.id=d.hospital_service_item_id where d.status!=1 and p.status=1 and d.execute_time>='"+startTime+"' and d.execute_time<='"+endTime+"' GROUP BY d.doctor,p.patient,d.execute_time";
 | 
	
		
			
				|  |  |     public ObjEnvelop dailyByJob(String startTime, String endTime) {
 | 
	
		
			
				|  |  |         String sql = "select d.doctor,p.patient,h.service_item_name AS serviceItemName,d.time_type AS timeType from wlyy_rehabilitation_plan_detail d left join wlyy_patient_rehabilitation_plan p on d.plan_id=p.id left join wlyy_hospital_service_item h ON h.id=d.hospital_service_item_id where d.status!=1 and p.status=1 and d.execute_time>='" + startTime + "' and d.execute_time<='" + endTime + "' GROUP BY d.doctor,p.patient,d.execute_time";
 | 
	
		
			
				|  |  | //        List<Object> list = rehabilitationDetailDao.dailyJob(startTime,endTime);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |          String doctorCode = "";
 | 
	
		
			
				|  |  |         List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         String doctorCode = "";
 | 
	
		
			
				|  |  |         String patientCode = "";
 | 
	
		
			
				|  |  |         List<String> listMap  = null;
 | 
	
		
			
				|  |  |        for(Map<String,Object> one:list){
 | 
	
		
			
				|  |  |             doctorCode = one.get("doctor")+"";
 | 
	
		
			
				|  |  |             patientCode = one.get("patient")+"";
 | 
	
		
			
				|  |  |             listMap = rehabilitationDetailDao.findByPatientAndDoctor(startTime,endTime,doctorCode,patientCode);
 | 
	
		
			
				|  |  |         List<String> listMap = null;
 | 
	
		
			
				|  |  |         for (Map<String, Object> one : list) {
 | 
	
		
			
				|  |  |             doctorCode = one.get("doctor") + "";
 | 
	
		
			
				|  |  |             patientCode = one.get("patient") + "";
 | 
	
		
			
				|  |  |             listMap = rehabilitationDetailDao.findByPatientAndDoctor(startTime, endTime, doctorCode, patientCode);
 | 
	
		
			
				|  |  |             String ids = "";
 | 
	
		
			
				|  |  |             for(String one2 : listMap){
 | 
	
		
			
				|  |  |                 ids += ","+one2;
 | 
	
		
			
				|  |  |             for (String one2 : listMap) {
 | 
	
		
			
				|  |  |                 ids += "," + one2;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             one.put("planDetailIds",StringUtils.isNotEmpty(ids)?ids.substring(1):"");
 | 
	
		
			
				|  |  |             one.put("planDetailIds", StringUtils.isNotEmpty(ids) ? ids.substring(1) : "");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success,list);
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success, list);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 更新康复计划项目操作日志并且确认完成更新status.
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param node
 | 
	
		
			
				|  |  |      * @param image
 | 
	
		
			
				|  |  |      * @param planDeatilId
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Map<String,Object> updateNodeAndRelationRecordImg(String node,String image,String status,String planDeatilId,String relationCode)throws Exception{
 | 
	
		
			
				|  |  |         Map<String,Object> resultMap = new HashedMap();
 | 
	
		
			
				|  |  |         try{
 | 
	
		
			
				|  |  |     public Map<String, Object> updateNodeAndRelationRecordImg(String node, String image, String status, String planDeatilId, String relationCode) throws Exception {
 | 
	
		
			
				|  |  |         Map<String, Object> resultMap = new HashedMap();
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             RehabilitationDetailDO detailDO = rehabilitationDetailDao.findById(planDeatilId);
 | 
	
		
			
				|  |  |             detailDO.setStatus(1);
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(status)){
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(status)) {
 | 
	
		
			
				|  |  |                 detailDO.setStatus(Integer.parseInt(status));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             detailDO.setUpdateTime(new Date());
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(relationCode)){
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(relationCode)) {
 | 
	
		
			
				|  |  |                 detailDO.setRelationCode(relationCode);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             rehabilitationDetailDao.save(detailDO);
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(image)&&StringUtils.isNoneBlank(node)){
 | 
	
		
			
				|  |  |                 int j = rehabilitationOperateRecordsDao.updateNodeAndRelationRecordImg(node,image,planDeatilId);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             else if (StringUtils.isNoneBlank(node)){
 | 
	
		
			
				|  |  |                 int j = rehabilitationOperateRecordsDao.updateNodeByPlanDetailId(node,planDeatilId);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             else if (StringUtils.isNoneBlank(image)){//
 | 
	
		
			
				|  |  |                 int j = rehabilitationOperateRecordsDao.updateImagByPlanDetailId(image,planDeatilId);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             else{//跟新为已完成
 | 
	
		
			
				|  |  |                 int j = rehabilitationOperateRecordsDao.updateStatus(1,planDeatilId);
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(image) && StringUtils.isNoneBlank(node)) {
 | 
	
		
			
				|  |  |                 int j = rehabilitationOperateRecordsDao.updateNodeAndRelationRecordImg(node, image, planDeatilId);
 | 
	
		
			
				|  |  |             } else if (StringUtils.isNoneBlank(node)) {
 | 
	
		
			
				|  |  |                 int j = rehabilitationOperateRecordsDao.updateNodeByPlanDetailId(node, planDeatilId);
 | 
	
		
			
				|  |  |             } else if (StringUtils.isNoneBlank(image)) {//
 | 
	
		
			
				|  |  |                 int j = rehabilitationOperateRecordsDao.updateImagByPlanDetailId(image, planDeatilId);
 | 
	
		
			
				|  |  |             } else {//跟新为已完成
 | 
	
		
			
				|  |  |                 int j = rehabilitationOperateRecordsDao.updateStatus(1, planDeatilId);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //如果整个计划的服务项都完成了,整个计划也完成了
 | 
	
		
			
				|  |  |             String allSql ="SELECT * FROM wlyy_rehabilitation_plan_detail where plan_id = (SELECT plan_id FROM `wlyy_rehabilitation_plan_detail` WHERE id='"+planDeatilId+"')";
 | 
	
		
			
				|  |  |             String allSql = "SELECT * FROM wlyy_rehabilitation_plan_detail where plan_id = (SELECT plan_id FROM `wlyy_rehabilitation_plan_detail` WHERE id='" + planDeatilId + "')";
 | 
	
		
			
				|  |  |             allSql = TransforSqlUtl.wlyy_rehabilitation_plan_detailAll(allSql);
 | 
	
		
			
				|  |  |             List<RehabilitationDetailDO> rehabilitationDetailDOList = jdbcTemplate.query(allSql,new BeanPropertyRowMapper<>(RehabilitationDetailDO.class));
 | 
	
		
			
				|  |  |             int allCount=0;
 | 
	
		
			
				|  |  |             String planId="";
 | 
	
		
			
				|  |  |             for (RehabilitationDetailDO rehabilitationDetailDO : rehabilitationDetailDOList){
 | 
	
		
			
				|  |  |                 if (rehabilitationDetailDO.getStatus()==1){
 | 
	
		
			
				|  |  |             List<RehabilitationDetailDO> rehabilitationDetailDOList = jdbcTemplate.query(allSql, new BeanPropertyRowMapper<>(RehabilitationDetailDO.class));
 | 
	
		
			
				|  |  |             int allCount = 0;
 | 
	
		
			
				|  |  |             String planId = "";
 | 
	
		
			
				|  |  |             for (RehabilitationDetailDO rehabilitationDetailDO : rehabilitationDetailDOList) {
 | 
	
		
			
				|  |  |                 if (rehabilitationDetailDO.getStatus() == 1) {
 | 
	
		
			
				|  |  |                     allCount++;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (rehabilitationDetailDOList.size()>0 && rehabilitationDetailDOList.size()==allCount){
 | 
	
		
			
				|  |  |             if (rehabilitationDetailDOList.size() > 0 && rehabilitationDetailDOList.size() == allCount) {
 | 
	
		
			
				|  |  |                 planId = rehabilitationDetailDOList.get(0).getPlanId();
 | 
	
		
			
				|  |  |                 patientRehabilitationPlanDao.updateStatusAndTimeById(2,planId, new Date());
 | 
	
		
			
				|  |  |                 patientRehabilitationPlanDao.updateStatusAndTimeById(2, planId, new Date());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             throw  new Exception("更新服务状态失败!");
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             throw new Exception("更新服务状态失败!");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //更新返回数据提供发送消息使用
 | 
	
		
			
				|  |  |         String sql ="SELECT" +
 | 
	
		
			
				|  |  |         String sql = "SELECT" +
 | 
	
		
			
				|  |  |                 " i.service_item_id," +
 | 
	
		
			
				|  |  |                 " r.doctor_code," +
 | 
	
		
			
				|  |  |                 " r.patient_code," +
 | 
	
	
		
			
				|  | @ -1264,25 +1339,26 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |                 " LEFT JOIN wlyy_hospital_service_item i ON pd.hospital_service_item_id = i.id" +
 | 
	
		
			
				|  |  |                 " LEFT JOIN wlyy_rehabilitation_operate_records r ON pd.id = r.rehabilitation_detail_id" +
 | 
	
		
			
				|  |  |                 " WHERE" +
 | 
	
		
			
				|  |  |                 " pd.id = '"+planDeatilId+"'";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         if (list!=null && list.size()>0){
 | 
	
		
			
				|  |  |                 " pd.id = '" + planDeatilId + "'";
 | 
	
		
			
				|  |  |         List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         if (list != null && list.size() > 0) {
 | 
	
		
			
				|  |  |             resultMap = list.get(0);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String itemSql ="SELECT evaluation,title FROM `wlyy_service_item` WHERE id='"+String.valueOf(resultMap.get("service_item_id"))+"'";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> itemList = jdbcTemplate.queryForList(itemSql);
 | 
	
		
			
				|  |  |         if (itemList!=null && itemList.size()>0){
 | 
	
		
			
				|  |  |             resultMap.put("evaluation",itemList.get(0).get("evaluation"));
 | 
	
		
			
				|  |  |             resultMap.put("title",itemList.get(0).get("title"));
 | 
	
		
			
				|  |  |         String itemSql = "SELECT evaluation,title FROM `wlyy_service_item` WHERE id='" + String.valueOf(resultMap.get("service_item_id")) + "'";
 | 
	
		
			
				|  |  |         List<Map<String, Object>> itemList = jdbcTemplate.queryForList(itemSql);
 | 
	
		
			
				|  |  |         if (itemList != null && itemList.size() > 0) {
 | 
	
		
			
				|  |  |             resultMap.put("evaluation", itemList.get(0).get("evaluation"));
 | 
	
		
			
				|  |  |             resultMap.put("title", itemList.get(0).get("title"));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return resultMap;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 电话关怀拨打电话后生成对应记录
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param jsonStr
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public RehabilitationOperateRecordsDO planDetailAfterCall(String jsonStr){
 | 
	
		
			
				|  |  |     public RehabilitationOperateRecordsDO planDetailAfterCall(String jsonStr) {
 | 
	
		
			
				|  |  |         JSONObject jsonObject = JSON.parseObject(jsonStr);
 | 
	
		
			
				|  |  |         /*{
 | 
	
		
			
				|  |  |             "rehabilitationDetailId":"808080eb764ba46b017669712c640012",
 | 
	
	
		
			
				|  | @ -1294,7 +1370,7 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         RehabilitationOperateRecordsDO rehabilitationOperateRecordsDO = new RehabilitationOperateRecordsDO();
 | 
	
		
			
				|  |  |         rehabilitationOperateRecordsDO.setId(getCode());
 | 
	
		
			
				|  |  |         if (rehabilitationDetailDO.getExecuteTime()!=null){
 | 
	
		
			
				|  |  |         if (rehabilitationDetailDO.getExecuteTime() != null) {
 | 
	
		
			
				|  |  |             rehabilitationOperateRecordsDO.setReserveTime(rehabilitationDetailDO.getExecuteTime());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         rehabilitationOperateRecordsDO.setStatus(3);
 | 
	
	
		
			
				|  | @ -1308,7 +1384,7 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |         rehabilitationOperateRecordsDO.setCompleteTime(new Date());
 | 
	
		
			
				|  |  |         rehabilitationOperateRecordsDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         rehabilitationOperateRecordsDO.setUpdateTime(new Date());
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(rehabilitationDetailDO.getFrequencyCode())){//限定频次的
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(rehabilitationDetailDO.getFrequencyCode())) {//限定频次的
 | 
	
		
			
				|  |  |             rehabilitationDetailDO.setStatus(3);
 | 
	
		
			
				|  |  |             rehabilitationDetailDao.save(rehabilitationDetailDO);
 | 
	
		
			
				|  |  | //            rehabilitationOperateRecordsDO.setRelationRecordType(8);
 | 
	
	
		
			
				|  | @ -1319,12 +1395,13 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 更新康复计划项目状态
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param status
 | 
	
		
			
				|  |  |      * @param planDetailId
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Envelop updatePlanDetailStatusById(Integer status,String planDetailId) throws Exception{
 | 
	
		
			
				|  |  |         if(rehabilitationDetailDao.updateStatusById(status,planDetailId)>0){
 | 
	
		
			
				|  |  |     public Envelop updatePlanDetailStatusById(Integer status, String planDetailId) throws Exception {
 | 
	
		
			
				|  |  |         if (rehabilitationDetailDao.updateStatusById(status, planDetailId) > 0) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             return Envelop.getSuccess(SpecialistMapping.api_success);
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -1332,8 +1409,8 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Envelop updatePlanDetailExecuteTimeById(Date executeTime,String planDetailId) throws Exception{
 | 
	
		
			
				|  |  |         if(rehabilitationDetailDao.updateExecuteTime(executeTime,planDetailId)>0){
 | 
	
		
			
				|  |  |     public Envelop updatePlanDetailExecuteTimeById(Date executeTime, String planDetailId) throws Exception {
 | 
	
		
			
				|  |  |         if (rehabilitationDetailDao.updateExecuteTime(executeTime, planDetailId) > 0) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             return Envelop.getSuccess(SpecialistMapping.api_success);
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -1343,91 +1420,93 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 计划总进度
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param planId
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public ObjEnvelop planSchedule(String planId){
 | 
	
		
			
				|  |  |         Map<String,Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  |     public ObjEnvelop planSchedule(String planId) {
 | 
	
		
			
				|  |  |         Map<String, Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  |         Integer allCount = rehabilitationDetailDao.findAllByPlanId(planId);//计划总服务项目数
 | 
	
		
			
				|  |  |         Integer finishedCount = rehabilitationDetailDao.findByStatusAndPlanId(1,planId);
 | 
	
		
			
				|  |  |         PatientRehabilitationPlanDO p =patientRehabilitationPlanDao.findById(planId);
 | 
	
		
			
				|  |  |         Integer finishedCount = rehabilitationDetailDao.findByStatusAndPlanId(1, planId);
 | 
	
		
			
				|  |  |         PatientRehabilitationPlanDO p = patientRehabilitationPlanDao.findById(planId);
 | 
	
		
			
				|  |  |         SpecialistPatientRelationDO specialistPatientRelationDO;
 | 
	
		
			
				|  |  |         if (p.getTeamCode()!= null) {
 | 
	
		
			
				|  |  |              specialistPatientRelationDO = specialistPatientRelationDao.findByTeamCodeAndPatient(p.getTeamCode(),p.getPatient());
 | 
	
		
			
				|  |  |         if (p.getTeamCode() != null) {
 | 
	
		
			
				|  |  |             specialistPatientRelationDO = specialistPatientRelationDao.findByTeamCodeAndPatient(p.getTeamCode(), p.getPatient());
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             specialistPatientRelationDO = specialistPatientRelationDao.findByDoctorAndPatient(p.getCreateUser(), p.getPatient());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         else {
 | 
	
		
			
				|  |  |              specialistPatientRelationDO = specialistPatientRelationDao.findByDoctorAndPatient(p.getCreateUser(),p.getPatient());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         resultMap.put("allCount",allCount);
 | 
	
		
			
				|  |  |         resultMap.put("finishedCount",finishedCount);
 | 
	
		
			
				|  |  |         resultMap.put("specialistPatientRelationDO",specialistPatientRelationDO);
 | 
	
		
			
				|  |  |         if (p!=null){
 | 
	
		
			
				|  |  |             resultMap.put("disease",p.getDisease());
 | 
	
		
			
				|  |  |             resultMap.put("diseaseName",p.getDiseaseName());
 | 
	
		
			
				|  |  |             resultMap.put("createUser",p.getCreateUser());
 | 
	
		
			
				|  |  |             resultMap.put("planTitle",p.getTitle());
 | 
	
		
			
				|  |  |         resultMap.put("allCount", allCount);
 | 
	
		
			
				|  |  |         resultMap.put("finishedCount", finishedCount);
 | 
	
		
			
				|  |  |         resultMap.put("specialistPatientRelationDO", specialistPatientRelationDO);
 | 
	
		
			
				|  |  |         if (p != null) {
 | 
	
		
			
				|  |  |             resultMap.put("disease", p.getDisease());
 | 
	
		
			
				|  |  |             resultMap.put("diseaseName", p.getDiseaseName());
 | 
	
		
			
				|  |  |             resultMap.put("createUser", p.getCreateUser());
 | 
	
		
			
				|  |  |             resultMap.put("planTitle", p.getTitle());
 | 
	
		
			
				|  |  |             resultMap.put("status", p.getStatus());
 | 
	
		
			
				|  |  |             resultMap.put("patientImg", p.getPatientImg());
 | 
	
		
			
				|  |  |             resultMap.put("adviceContent",p.getAdviceContent());
 | 
	
		
			
				|  |  |             resultMap.put("createTimeDate",DateUtil.dateToStr(p.getCreateTime(),"yyyy-MM-dd"));
 | 
	
		
			
				|  |  |             resultMap.put("createTime", DateUtil.dateToStr(p.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
 | 
	
		
			
				|  |  |             resultMap.put("medicalRecordsCode",p.getMedicalRecordsCode());
 | 
	
		
			
				|  |  |             resultMap.put("adviceContent", p.getAdviceContent());
 | 
	
		
			
				|  |  |             resultMap.put("createTimeDate", DateUtil.dateToStr(p.getCreateTime(), "yyyy-MM-dd"));
 | 
	
		
			
				|  |  |             resultMap.put("createTime", DateUtil.dateToStr(p.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
 | 
	
		
			
				|  |  |             resultMap.put("medicalRecordsCode", p.getMedicalRecordsCode());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | //        resultMap.put("healthyCondition",healthyCondition);
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultMap);
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success, resultMap);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 根据居民获取康复计划
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param patient
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public ObjEnvelop planListByPatient(String patient){
 | 
	
		
			
				|  |  |     public ObjEnvelop planListByPatient(String patient) {
 | 
	
		
			
				|  |  |         List<PatientRehabilitationPlanDO> list = patientRehabilitationPlanDao.findByPatients(patient);
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success,list);
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success, list);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 医生已计划数,已完成计划数(居民数)
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param doctorCode
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public ObjEnvelop patientCount(String doctorCode){
 | 
	
		
			
				|  |  |         Integer count =patientRehabilitationPlanDao.patientCount(doctorCode);
 | 
	
		
			
				|  |  |     public ObjEnvelop patientCount(String doctorCode) {
 | 
	
		
			
				|  |  |         Integer count = patientRehabilitationPlanDao.patientCount(doctorCode);
 | 
	
		
			
				|  |  |         Integer finishCount = patientRehabilitationPlanDao.getFinishPatientCount(doctorCode);
 | 
	
		
			
				|  |  |         Map<String,Object> map = new HashMap<>();
 | 
	
		
			
				|  |  |         map.put("planCount",count);
 | 
	
		
			
				|  |  |         map.put("finishedPlanCount",finishCount);
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success,map);
 | 
	
		
			
				|  |  |         Map<String, Object> map = new HashMap<>();
 | 
	
		
			
				|  |  |         map.put("planCount", count);
 | 
	
		
			
				|  |  |         map.put("finishedPlanCount", finishCount);
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success, map);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public ObjEnvelop dailyJobReserve(String startTime,String endTime){
 | 
	
		
			
				|  |  |     public ObjEnvelop dailyJobReserve(String startTime, String endTime) {
 | 
	
		
			
				|  |  |         String sql = "select DISTINCT d.doctor,p.patient,d.hospital from wlyy_rehabilitation_plan_detail d left join wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
 | 
	
		
			
				|  |  |                 " left join wlyy_hospital_service_item h on d.hospital_service_item_id=h.id " +
 | 
	
		
			
				|  |  |                 " left join wlyy_service_item i on i.id =h.service_item_id "+
 | 
	
		
			
				|  |  |                 " where d.status!=1 and d.execute_time>='"+startTime+"' and d.execute_time<='"+endTime+"' and i.reserve=1 and p.status!=0 and d.status=0 ";
 | 
	
		
			
				|  |  |                 " left join wlyy_service_item i on i.id =h.service_item_id " +
 | 
	
		
			
				|  |  |                 " where d.status!=1 and d.execute_time>='" + startTime + "' and d.execute_time<='" + endTime + "' and i.reserve=1 and p.status!=0 and d.status=0 ";
 | 
	
		
			
				|  |  | //        List<Object> list = rehabilitationDetailDao.dailyJob(startTime,endTime);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         String doctorCode = "";
 | 
	
		
			
				|  |  |         String patientCode = "";
 | 
	
		
			
				|  |  | //        List<String> listMap  = null;
 | 
	
		
			
				|  |  |         for(Map<String,Object> one:list){
 | 
	
		
			
				|  |  |             doctorCode = one.get("doctor")+"";
 | 
	
		
			
				|  |  |             patientCode = one.get("patient")+"";
 | 
	
		
			
				|  |  |             String sql2 ="select d.id from wlyy_rehabilitation_plan_detail d left join wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
 | 
	
		
			
				|  |  |         for (Map<String, Object> one : list) {
 | 
	
		
			
				|  |  |             doctorCode = one.get("doctor") + "";
 | 
	
		
			
				|  |  |             patientCode = one.get("patient") + "";
 | 
	
		
			
				|  |  |             String sql2 = "select d.id from wlyy_rehabilitation_plan_detail d left join wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
 | 
	
		
			
				|  |  |                     " left join wlyy_hospital_service_item h on d.hospital_service_item_id=h.id " +
 | 
	
		
			
				|  |  |                     " left join wlyy_service_item i on i.id =h.service_item_id "+
 | 
	
		
			
				|  |  |                     " where d.status!=1 and d.execute_time>='"+startTime+"' and d.execute_time<='"+endTime+"' and i.reserve=1 and d.doctor='"+doctorCode+"' and p.patient='"+patientCode+"'";
 | 
	
		
			
				|  |  |             List<Map<String,Object>> list2 = jdbcTemplate.queryForList(sql2);
 | 
	
		
			
				|  |  |                     " left join wlyy_service_item i on i.id =h.service_item_id " +
 | 
	
		
			
				|  |  |                     " where d.status!=1 and d.execute_time>='" + startTime + "' and d.execute_time<='" + endTime + "' and i.reserve=1 and d.doctor='" + doctorCode + "' and p.patient='" + patientCode + "'";
 | 
	
		
			
				|  |  |             List<Map<String, Object>> list2 = jdbcTemplate.queryForList(sql2);
 | 
	
		
			
				|  |  | //            listMap = rehabilitationDetailDao.findByPatientAndDoctor(startTime,endTime,doctorCode,patientCode);
 | 
	
		
			
				|  |  |             String ids = "";
 | 
	
		
			
				|  |  |             for(Map<String,Object> one2 : list2){
 | 
	
		
			
				|  |  |                 ids += ","+one2.get("id");
 | 
	
		
			
				|  |  |             for (Map<String, Object> one2 : list2) {
 | 
	
		
			
				|  |  |                 ids += "," + one2.get("id");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             one.put("planDetailIds",StringUtils.isNotEmpty(ids)?ids.substring(1):"");
 | 
	
		
			
				|  |  |             one.put("planDetailIds", StringUtils.isNotEmpty(ids) ? ids.substring(1) : "");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success,list);
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success, list);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -1436,24 +1515,24 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |      * @param ids
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public ObjEnvelop selectByIds(String ids){
 | 
	
		
			
				|  |  |     public ObjEnvelop selectByIds(String ids) {
 | 
	
		
			
				|  |  |         ObjEnvelop envelop = new ObjEnvelop();
 | 
	
		
			
				|  |  |         List idList = Arrays.asList(ids.split(","));
 | 
	
		
			
				|  |  |         StringBuffer buffer = new StringBuffer();
 | 
	
		
			
				|  |  |         for (int i =0;i<idList.size();i++){
 | 
	
		
			
				|  |  |             buffer.append("'"+idList.get(i)+"'").append(",");
 | 
	
		
			
				|  |  |         for (int i = 0; i < idList.size(); i++) {
 | 
	
		
			
				|  |  |             buffer.append("'" + idList.get(i) + "'").append(",");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         buffer.deleteCharAt(buffer.length()-1);
 | 
	
		
			
				|  |  |         String sql = "select * from wlyy_rehabilitation_plan_detail where id in("+buffer+")";
 | 
	
		
			
				|  |  |         buffer.deleteCharAt(buffer.length() - 1);
 | 
	
		
			
				|  |  |         String sql = "select * from wlyy_rehabilitation_plan_detail where id in(" + buffer + ")";
 | 
	
		
			
				|  |  |         sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailAll(sql);
 | 
	
		
			
				|  |  |         List<RehabilitationDetailDO> rehabilitationDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(RehabilitationDetailDO.class));
 | 
	
		
			
				|  |  |         List<RehabilitationDetailDO> rehabilitationDetailDOS = jdbcTemplate.query(sql, new BeanPropertyRowMapper(RehabilitationDetailDO.class));
 | 
	
		
			
				|  |  |         envelop.setObj(rehabilitationDetailDOS);
 | 
	
		
			
				|  |  |         return envelop;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public ObjEnvelop getServiceItemsAfterStop(String planId)throws Exception{
 | 
	
		
			
				|  |  |         Map<String,Object> reslutMap = new HashMap<>();
 | 
	
		
			
				|  |  |         String sql ="SELECT" +
 | 
	
		
			
				|  |  |     public ObjEnvelop getServiceItemsAfterStop(String planId) throws Exception {
 | 
	
		
			
				|  |  |         Map<String, Object> reslutMap = new HashMap<>();
 | 
	
		
			
				|  |  |         String sql = "SELECT" +
 | 
	
		
			
				|  |  |                 " p.patient," +
 | 
	
		
			
				|  |  |                 " p.name," +
 | 
	
		
			
				|  |  |                 " p.title," +
 | 
	
	
		
			
				|  | @ -1476,16 +1555,16 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |                 "  i.code as item_type " +
 | 
	
		
			
				|  |  |                 "  FROM" +
 | 
	
		
			
				|  |  |                 "  wlyy_rehabilitation_plan_detail d" +
 | 
	
		
			
				|  |  |                 "  LEFT JOIN wlyy_rehabilitation_service_item i ON d.hospital_service_item_id = i.code  "+
 | 
	
		
			
				|  |  |                 "  LEFT JOIN wlyy_rehabilitation_service_item i ON d.hospital_service_item_id = i.code  " +
 | 
	
		
			
				|  |  |                 "  LEFT JOIN wlyy_rehabilitation_operate_records r ON d.id = r.rehabilitation_detail_id" +
 | 
	
		
			
				|  |  |                 "  WHERE" +
 | 
	
		
			
				|  |  |                 "  r.`status` = 1" +
 | 
	
		
			
				|  |  |                 " ) a ON p.id = a.plan_id" +
 | 
	
		
			
				|  |  |                 " WHERE" +
 | 
	
		
			
				|  |  |                 " p.id = '"+planId+"'";
 | 
	
		
			
				|  |  |                 " p.id = '" + planId + "'";
 | 
	
		
			
				|  |  |         sql = TransforSqlUtl.wlyy_patient_rehabilitation_planName(sql);
 | 
	
		
			
				|  |  |         sql = TransforSqlUtl.wlyy_rehabilitation_operate_recordsDoctorName(sql);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         Integer allCount = rehabilitationDetailDao.findAllByPlanId(planId);//计划总服务项目数
 | 
	
		
			
				|  |  |         Integer finishCount = list.size();//完成服务项目数
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -1493,33 +1572,33 @@ public class RehabilitationManageService {
 | 
	
		
			
				|  |  |         Set<String> hospitalSet = new HashSet();
 | 
	
		
			
				|  |  |         Set<String> serviceDoctor = new HashSet();
 | 
	
		
			
				|  |  |         DecimalFormat df = new DecimalFormat("0.00");
 | 
	
		
			
				|  |  |         for (Map<String,Object> map : list){
 | 
	
		
			
				|  |  |         for (Map<String, Object> map : list) {
 | 
	
		
			
				|  |  |             double expense = 0;
 | 
	
		
			
				|  |  |             if (StringUtils.isNotEmpty(String .valueOf(map.get("expense"))) && !"null".equals(String .valueOf(map.get("expense")))){
 | 
	
		
			
				|  |  |                 expense =Integer.valueOf(String .valueOf(map.get("expense")));
 | 
	
		
			
				|  |  |             if (StringUtils.isNotEmpty(String.valueOf(map.get("expense"))) && !"null".equals(String.valueOf(map.get("expense")))) {
 | 
	
		
			
				|  |  |                 expense = Integer.valueOf(String.valueOf(map.get("expense")));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             totalExpense += expense;
 | 
	
		
			
				|  |  |             map.put("expense",df.format(expense/100));
 | 
	
		
			
				|  |  |             map.put("expense", df.format(expense / 100));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //组装机构和服务医生
 | 
	
		
			
				|  |  |             if(map.get("hospital") != null){
 | 
	
		
			
				|  |  |                 if(map.get("hospital_name") != null && !hospitalSet.contains(("hospital_name") + "")) {
 | 
	
		
			
				|  |  |             if (map.get("hospital") != null) {
 | 
	
		
			
				|  |  |                 if (map.get("hospital_name") != null && !hospitalSet.contains(("hospital_name") + "")) {
 | 
	
		
			
				|  |  |                     hospitalSet.add(map.get("hospital_name") + "");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if(map.get("doctor_code") != null){
 | 
	
		
			
				|  |  |                 if(map.get("doctor_name") != null && !hospitalSet.contains(("doctor_name") + "")) {
 | 
	
		
			
				|  |  |             if (map.get("doctor_code") != null) {
 | 
	
		
			
				|  |  |                 if (map.get("doctor_name") != null && !hospitalSet.contains(("doctor_name") + "")) {
 | 
	
		
			
				|  |  |                     serviceDoctor.add(map.get("doctor_name") + "");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         reslutMap.put("totalExpense",df.format(totalExpense/100));
 | 
	
		
			
				|  |  |         reslutMap.put("allCount",allCount);
 | 
	
		
			
				|  |  |         reslutMap.put("finishCount",finishCount);
 | 
	
		
			
				|  |  |         reslutMap.put("serviceList",list);
 | 
	
		
			
				|  |  |         reslutMap.put("hospitalAll", hospitalSet.toString().replace("[","").replace("]","").replace(",", "、"));
 | 
	
		
			
				|  |  |         reslutMap.put("serviceDoctor", serviceDoctor.toString().replace("[","").replace("]","").replace(",", "、"));
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success,reslutMap);
 | 
	
		
			
				|  |  |         reslutMap.put("totalExpense", df.format(totalExpense / 100));
 | 
	
		
			
				|  |  |         reslutMap.put("allCount", allCount);
 | 
	
		
			
				|  |  |         reslutMap.put("finishCount", finishCount);
 | 
	
		
			
				|  |  |         reslutMap.put("serviceList", list);
 | 
	
		
			
				|  |  |         reslutMap.put("hospitalAll", hospitalSet.toString().replace("[", "").replace("]", "").replace(",", "、"));
 | 
	
		
			
				|  |  |         reslutMap.put("serviceDoctor", serviceDoctor.toString().replace("[", "").replace("]", "").replace(",", "、"));
 | 
	
		
			
				|  |  |         return ObjEnvelop.getSuccess(SpecialistMapping.api_success, reslutMap);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public String getCode() {
 |