| 
					
				 | 
			
			
				@ -0,0 +1,1727 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.rehabilitation.service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSON; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.doctor.dao.BaseDoctorDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.doctor.dao.BaseDoctorRoleDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.doctor.BaseDoctorDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.BasePatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.door.SignFamily; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.hospital.doctor.Frequency; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.patient.Message; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.patient.Patient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.specialist.SpecialistPatientRelationDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.specialist.rehabilitation.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.util.TransforSqlUtl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.BasePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.rehabilitation.GuidanceMessageLogDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.rehabilitation.RehabilitationDetailAppointmentDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.rehabilitation.RehabilitationOperateRecordsDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.rehabilitation.SpecialistPatientRelationDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.Envelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.MixEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.ObjEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.rm.base.BaseRequestMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.rm.specialist.SpecialistMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.common.IdCardUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.date.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.rehabilitation.dao.FrequencyDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.rehabilitation.dao.PatientRehabilitationPlanDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.rehabilitation.dao.RehabilitationDetailDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.rehabilitation.dao.SignFamilyDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.collections.map.HashedMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.json.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.BeanPropertyRowMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.JdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.text.DecimalFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.text.SimpleDateFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * Created by 刘文彬 on 2018/8/16. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				public class RehabilitationManageService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Value("${basedb.name}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private String basedb; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private JdbcTemplate jdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private RehabilitationDetailDao rehabilitationDetailDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PatientRehabilitationPlanDao patientRehabilitationPlanDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private GuidanceMessageLogDao guidanceMessageLogDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private SpecialistPatientRelationDao specialistPatientRelationDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private RehabilitationOperateRecordsDao rehabilitationOperateRecordsDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private RehabilitationDetailAppointmentDao rehabilitationDetailAppointmentDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseDoctorDao baseDoctorDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseDoctorRoleDao baseDoctorRoleDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BasePatientDao  basePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private SignFamilyDao signFamilyDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private SpecialistEvaluateSevice specialistEvaluateSevice; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private FrequencyDao frequencyDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 预约协诊 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @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){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        RehabilitationDetailAppointmentDO appointment = new RehabilitationDetailAppointmentDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        appointment.setAppointmentTime(sendTime+":00"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        appointment.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        appointment.setDoctor(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        appointment.setDoctorName(doctorName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        appointment.setAppointmentDoctor(appointmentDoctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        appointment.setAppointmentDoctorName(appointmentDoctorName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        appointment.setIsSend(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        appointment.setRehabilitationPlanDetailId(planDetailId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        appointment.setPatient(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rehabilitationDetailAppointmentDao.save(appointment); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return ObjEnvelop.getSuccess("获取成功",appointment); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 康复管理(专科)-- 计划列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param doctorCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param diseaseCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param planType 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param todaybacklog 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param page 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param pageSize 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public MixEnvelop<Map<String,Object>, Map<String,Object>> findRehabilitationPlan(String doctorCode, String diseaseCode, Integer planType,Integer todaybacklog, String patientCondition,Integer page, Integer pageSize) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer doctorType =null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseDoctorDO doctor = baseDoctorDao.findById(doctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<BaseDoctorRoleDO> baseDoctorRoleDO = baseDoctorRoleDao.findByDoctorCode(doctor.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for(BaseDoctorRoleDO baseDoctorRoleDO1:baseDoctorRoleDO){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if ("specialist".equalsIgnoreCase(baseDoctorRoleDO1.getRoleCode())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                doctorType = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                doctorType = 2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = " select DISTINCT p.* " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " from wlyy_rehabilitation_plan_detail a INNER JOIN wlyy_patient_rehabilitation_plan p " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " on a.plan_id = p.id  " ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(doctorType==2){//家医是根据签约关系过滤 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" INNER JOIN 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+"' )  "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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(planType!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " and p.plan_type="+planType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotEmpty(diseaseCode)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" and p.disease='"+diseaseCode+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotEmpty(patientCondition)){//姓名idcard模糊查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql +=" AND EXISTS (select code from base_patient where  `id` = p.patient and ( `name` LIKE '%"+patientCondition+"%' or idcard like '%"+patientCondition+"%') )"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int count = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO patient =null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(patientRehabilitationPlanDOList.size()>0&&patientRehabilitationPlanDOList.get(0).get("id")!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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("sex","1".equals(sex)?"男":("2".equals(sex)?"女":"未知")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                resultMap.put("patientName",one.get("patientName")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                resultMap.put("patientCode",one.get("patient")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patient = basePatientDao.findById(one.get("patient").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (patient!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    resultMap.put("photo",patient!=null?patient.getPhoto():""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Integer age = IdCardUtil.getAgeForIdcard(patient.getIdcard()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String sex = IdCardUtil.getSexForIdcard_new(patient.getIdcard()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    resultMap.put("age",age); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    resultMap.put("sex","1".equals(sex)?"男":("2".equals(sex)?"女":"未知")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    SignFamily signFamily = signFamilyDao.findByPatient(one.get("patient").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (signFamily != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        resultMap.put("hospitalName",signFamily.getHospitalName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        resultMap.put("hospitalName",""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                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 planTypeName = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                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")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //今日待办(即今日全部的项目) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                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 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 allCount = rehabilitationDetailDao.findAllByPlanId(one.get("id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                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)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 康复管理更多计划 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param currentDoctorCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patientCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public ObjEnvelop findRehabilitationPlanDetailList(String currentDoctorCode,String patientCode) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = " select DISTINCT r.* from 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<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //专科医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String specialistRelationSql = "select r.*,t.name as teamName,h.name as specialistHospitalName from 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"));//专科医生所在医院 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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 ) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String, Object> signFamilyMap = signFamilyList.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                resultMap.put("signFamilyAdminTeamName", signFamilyMap.get("teamName")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                resultMap.put("familyHospitalName", signFamilyMap.get("hospital_name"));//家庭医生所在医院 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Integer familyUnfinishCount1 = rehabilitationDetailDao.unfinishItemByDoctor(signFamilyMap.get("doctor") + "", patientCode, 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Integer familyFinishCount1 = rehabilitationDetailDao.findItemByDoctor(signFamilyMap.get("doctor") + "", patientCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Integer familyServiceCount1 = rehabilitationDetailDao.completeServiceByDoctor(signFamilyMap.get("doctor") + "", patientCode, 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if ((signFamilyMap.get("doctor") + "").equals(signFamilyMap.get("doctor_health") + "")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    resultMap.put("signFamilyFinishItemCount", familyFinishCount1 - familyUnfinishCount1);//完成项目 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    resultMap.put("signFamilyServiceRecordCount", familyServiceCount1);//服务次数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Integer familyUnfinishCount2 = rehabilitationDetailDao.unfinishItemByDoctor(signFamilyMap.get("doctor_health") + "", patientCode, 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Integer familyFinishCount2 = rehabilitationDetailDao.findItemByDoctor(signFamilyMap.get("doctor_health") + "", patientCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Integer familyServiceCount2 = rehabilitationDetailDao.completeServiceByDoctor(signFamilyMap.get("doctor_health") + "", patientCode, 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    resultMap.put("signFamilyFinishItemCount", familyFinishCount1 - familyUnfinishCount1 + familyFinishCount2 - familyUnfinishCount2);//完成项目 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    resultMap.put("signFamilyServiceRecordCount", familyServiceCount1 + familyServiceCount2);//服务次数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //基础信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                resultMap.put("hospitalName", signFamilyMap.get("hospital_name")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Integer age = IdCardUtil.getAgeForIdcard(signFamilyMap.get("idcard") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String sex = IdCardUtil.getSexForIdcard_new(signFamilyMap.get("idcard") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                resultMap.put("age", age); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                resultMap.put("sex", "1".equals(sex) ? "男" : ("2".equals(sex) ? "女" : "未知")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<String> disease = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(Map<String,Object> one2:diseaseList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                disease.add(one2.get("disease_name")+""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //安排类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String planTypeName = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Integer planTypeTemp = one.getPlanType(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                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)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    isOperator = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //已完成 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                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 allFinishCount = rehabilitationDetailDao.findByStatusAndPlanId(1,one.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Integer allCount = rehabilitationDetailDao.findAllByPlanId(one.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                planMap.put("allCount",allCount);//总数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                planMap.put("allFinishCount",allFinishCount);//全部已完成数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                rehabilitationPlanList.add(planMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            resultMap.put("rehabilitationPlanList",rehabilitationPlanList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BasePatientDO p = basePatientDao.findById(patientCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            resultMap.put("patientPhoto",p.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            resultList.add(resultMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 日历 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @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{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String[] planIdlist = planId.split(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        StringBuilder planCondition = new StringBuilder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        planCondition .append("'"+planIdlist[0]+"'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (int i=1;i<planIdlist.length;i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            planCondition .append(",'"+planIdlist[i]+"'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = " select d.* from 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+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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(taskExecutor.equals("1")){ //我的任务 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+="and d.doctor='"+doctorCode+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(taskExecutor.equals("2")){//他人任务 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+="and d.doctor <>'"+doctorCode+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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<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)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                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{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            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){//专科医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if(m.containsKey("specialist")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            specialist = (Map<String,Integer>)m.get("specialist"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }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")+""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put(executeTime,m); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        /*List list = new ArrayList(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for(String key : map.keySet()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String,Object> result = map.get(key); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("executeTime", key); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            list.add(result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 日历列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @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){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String[] planIdlist = planId.split(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        StringBuilder planCondition = new StringBuilder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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,i.name from 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){// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql+="and d.doctor='"+doctorCode+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }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("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(status!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+= "and d.status="+status; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql +="  order by d.execute_time desc "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailAll2(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> rehabilitationDetailList = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,rehabilitationDetailList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 多个康复计划服务项目内容列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param planDetailIds 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public ObjEnvelop serviceItemList(String planDetailIds,String doctorCode) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String[] s = planDetailIds.split(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String planDetailList = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for(String one:s){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            planDetailList +=",'"+one+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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_rehabilitation_plan_detail d " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " 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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        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<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer isMyTask = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(StringUtils.isNotEmpty(doctorCode)&&doctorCode.equals(one.get("executeDoctor")+"")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                isMyTask=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"));//执行时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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"));//计划的状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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;} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                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);//状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //是否完成任务 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<RehabilitationOperateRecordsDO> operateList = rehabilitationOperateRecordsDao.findByRehabilitationDetailId(one.get("id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer operate = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(operateList.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                operate =1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                RehabilitationOperateRecordsDO temp = operateList.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                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")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            resultMap.put("operate",operate);//是否完成任务(默认0:未完成,1:已完成) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<SignFamily> list = signFamilyDao.findByPatientAndExpensesStatusAndStatus(one.get("patient").toString(),"1",1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                resultMap.put("familyDoctorCode",list.get(0).getDoctor()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                resultMap.put("familyDoctorName",list.get(0).getDoctorName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                resultMap.put("familyDoctorCode",""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                resultMap.put("familyDoctorName",""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            resultList.add(resultMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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  "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ,a.appointment_time appointmentTime,a.appointment_doctor appointmentDoctor,a.appointment_doctor_name appointmentDoctorName,d.reservation_type reservationType" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " from wlyy_rehabilitation_plan_detail d " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN wlyy_rehabilitation_service_item h on d.hospital_service_item_id = h.code "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN wlyy_plan_detail_appointment a on d.id=.a.rehabilitation_plan_detail_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " 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<>()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 协诊预约信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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("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"));//执行时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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;} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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、随访 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //是否完成任务 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer operate = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(operateList.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            RehabilitationOperateRecordsDO temp = operateList.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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(itemType!=1&&itemType!=0){*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                resultMap.put("relationRecordCode",temp.getRelationRecordCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                resultMap.put("completeTimeShort",DateUtil.dateToStr(completeTime,"yyyy/MM/dd")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  /*          }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<SignFamily> list = signFamilyDao.findByPatientAndExpensesStatusAndStatus(one.get("patient").toString(),"1",1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            resultMap.put("familyDoctorCode",list.get(0).getDoctor()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            resultMap.put("familyDoctorName",list.get(0).getDoctorName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            resultMap.put("familyDoctorCode",""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            resultMap.put("familyDoctorName",""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("operate",operate);//是否完成任务(默认0:未完成,1:已完成) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 康复管理居民详情页 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patientCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public ObjEnvelop patientRehabilitationDetail(String patientCode){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> resultMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<SignFamily> listFamiluy = signFamilyDao.findByPatientAndExpensesStatusAndStatus(patientCode,"1",1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String healthDoctor = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String healthDoctorName =null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String generalDoctor = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String generalDoctorName = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String patientName = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer age = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sex = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String signHospitalName = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        org.json.JSONObject json = new org.json.JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String healthyConditionSql =" select  label_name,label from 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")+"":""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO patient = basePatientDao.findById(patientCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(listFamiluy.size()>0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SignFamily signFamily = listFamiluy.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthDoctor = signFamily.getDoctorHealth(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthDoctorName = signFamily.getDoctorHealthName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            generalDoctor = signFamily.getDoctor(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            generalDoctorName = signFamily.getDoctorName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientName = signFamily.getName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            signHospitalName = signFamily.getHospitalName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //个人基础信息(康复机构) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String patientInfoSql = " SELECT DISTINCT hospital_name from wlyy_rehabilitation_plan_detail d LEFT JOIN 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<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String rehabilitationOrg = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for(Map<String,Object> one:patientInfoList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            rehabilitationOrg+=","+one.get("hospital_name"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        patientInfo.put("rehabilitationOrg",StringUtils.isNotEmpty(rehabilitationOrg)?rehabilitationOrg.substring(1):""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("patientInfo",patientInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //服务医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //完成项目=全部的服务项目-未完成的服务项目 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            serviceDoctorList.add(generalDoctorMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String specialistRelationSql = "select DISTINCT d.doctor,d.doctor_name from wlyy_rehabilitation_plan_detail d LEFT JOIN 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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseDoctorDO baseDoctorDO = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (Map<String,Object> d:serviceDoctorList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BaseDoctorDO baseDoctorDO1 = baseDoctorDao.findById(d.get("doctorCode").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            d.put("doctorPhoto",baseDoctorDO1!=null?baseDoctorDO1.getPhoto():""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("serviceDoctorList",serviceDoctorList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //康复计划 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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;} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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 allCount = rehabilitationDetailDao.findAllByPlanId(one.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("allCount",allCount);//总数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<RehabilitationDetailDO> detailList = rehabilitationDetailDao.getAllRehabilitationDetail(one.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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",""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            planList.add(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("planList",planList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //康复计划-已完成、进行中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("planUnderway",planUnderway);//进行中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("planFinish",planFinish);//已完成 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("healthyCondition",healthyCondition); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("healthyConditionType",healthyConditionType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("patientName",patientName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("signHospitalName",signHospitalName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        age = IdCardUtil.getAgeForIdcard(patient.getIdcard()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sex = IdCardUtil.getSexForIdcard_new(patient.getIdcard()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("patientCode", patientCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("patientName", patient.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("age",age); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("sex",sex); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("photo",patient.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("mobile",patient.getMobile()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //近期康复相关记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        String currentTime = DateUtil.getStringDate(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String planDetailSql = " select d.*,h.name,h.code,s.complete_time from wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_rehabilitation_service_item h on d.hospital_service_item_id=h.code" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN 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+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotEmpty(endTime)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            planDetailSql += "  and d.execute_time<='"+endTime+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String statusName = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            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);//状态名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            planDetailList.add(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("planDetailList",planDetailList);//康复相关记录列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String planDetailCountSql = " select d.status as num from wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_rehabilitation_service_item h on d.hospital_service_item_id=h.code" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  LEFT JOIN 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){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 保存康复管理指导留言信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param messageId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param doctor 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Envelop saveGuidanceMessage(String messageId,String doctor,String content,String planDetailId,Integer contentType) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer doctorType =null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (doctorDO!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<BaseDoctorRoleDO> baseDoctorRoleDO = baseDoctorRoleDao.findByDoctorCode(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (baseDoctorRoleDO!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (BaseDoctorRoleDO baseDoctorRoleDO1:baseDoctorRoleDO){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if ("specialist".equalsIgnoreCase(baseDoctorRoleDO1.getRoleCode())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        doctorType=1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        doctorType=2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<String> patientList = rehabilitationDetailDao.findPatientById(planDetailId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String patient = patientList.size()>0?patientList.get(0):""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        GuidanceMessageLogDO guidanceMessageLogDO = new GuidanceMessageLogDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        guidanceMessageLogDO.setMessageId(messageId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        guidanceMessageLogDO.setPlanDetailId(planDetailId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        guidanceMessageLogDO.setContent(content); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        guidanceMessageLogDO.setDoctor(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        guidanceMessageLogDO.setContentType(contentType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        guidanceMessageLogDO.setDoctorType(doctorType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer adminTeamCode = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String doctorName = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(doctorType==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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 adminTeamName = adminTeam.get(0).get("name").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        guidanceMessageLogDO.setAdminTeamCode(adminTeamCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        guidanceMessageLogDO.setAdminTeamName(adminTeamName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        guidanceMessageLogDO.setDoctorName(doctorName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        guidanceMessageLogDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        guidanceMessageLogDO.setUpdateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        guidanceMessageLogDao.save(guidanceMessageLogDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return Envelop.getSuccess(SpecialistMapping.api_success); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 康复管理-更新康复计划操作完成日志状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param planDetailId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param status 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Envelop updateStatusRehabilitationOperate(Integer status,String planDetailId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(rehabilitationOperateRecordsDao.updateStatus(status,planDetailId)>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           return Envelop.getSuccess(SpecialistMapping.api_success); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return Envelop.getError("更新失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * app端居民详情服务医生列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patientCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public ObjEnvelop serviceDoctorList(String patientCode){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<SignFamily> list = signFamilyDao.findByPatientAndExpensesStatusAndStatus(patientCode,"1",1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String healthDoctor = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String healthDoctorName =null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String generalDoctor = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String generalDoctorName = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(list!=null&&list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SignFamily signFamily = list.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthDoctor = signFamily.getDoctorHealth(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthDoctorName = signFamily.getDoctorHealthName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            generalDoctor = signFamily.getDoctor(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            generalDoctorName = signFamily.getDoctorName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //服务医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //完成项目=全部的服务项目-未完成的服务项目 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            serviceDoctorList.add(healthDoctorMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String specialistRelationSql = "select DISTINCT d.doctor,d.doctor_name from wlyy_rehabilitation_plan_detail d LEFT JOIN 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","专科医生"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            serviceDoctorList.add(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,serviceDoctorList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * app端、微信端计划的服务项目列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param planId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param searchTask 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param status 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param executeStartTime 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param executeEndTime 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 每日康复服务通知 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @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"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        List<Object> list = rehabilitationDetailDao.dailyJob(startTime,endTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String ids = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(String one2 : listMap){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ids += ","+one2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            one.put("planDetailIds",StringUtils.isNotEmpty(ids)?ids.substring(1):""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 明日康复计划提醒 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param startTime 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @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"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        List<Object> list = rehabilitationDetailDao.dailyJob(startTime,endTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String ids = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(String one2 : listMap){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ids += ","+one2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            one.put("planDetailIds",StringUtils.isNotEmpty(ids)?ids.substring(1):""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 每日康复计划提醒 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param startTime 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @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"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        List<Object> list = rehabilitationDetailDao.dailyJob(startTime,endTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String ids = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(String one2 : listMap){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ids += ","+one2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            one.put("planDetailIds",StringUtils.isNotEmpty(ids)?ids.substring(1):""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            RehabilitationDetailDO detailDO = rehabilitationDetailDao.findById(planDeatilId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            detailDO.setStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNoneBlank(status)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                detailDO.setStatus(Integer.parseInt(status)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            detailDO.setUpdateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //如果整个计划的服务项都完成了,整个计划也完成了 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    allCount++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (rehabilitationDetailDOList.size()>0 && rehabilitationDetailDOList.size()==allCount){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                planId = rehabilitationDetailDOList.get(0).getPlanId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patientRehabilitationPlanDao.updateStatusAndTimeById(2,planId, new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw  new Exception("更新服务状态失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //更新返回数据提供发送消息使用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql ="SELECT" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " i.service_item_id," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.doctor_code," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " r.patient_code," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " pd.hospital" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_rehabilitation_plan_detail pd" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " 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){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //保存wlyy_message 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String hospotal = resultMap.get("hospital").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String patient = resultMap.get("patient_code").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String doctor = resultMap.get("doctor_code").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Message message = new Message(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        message.setType(21); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        message.setSender(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        message.setReceiver(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        message.setRelationCode(planDeatilId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        specialistEvaluateSevice.sendMessage(message,hospotal,patient,null,null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //发送微信模板消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int evaluation = resultMap.get("evaluation")==null?0:Integer.parseInt(resultMap.get("evaluation").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (evaluation == 1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String serviceItemId = resultMap.get("service_item_id").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String title = resultMap.get("title").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BasePatientDO p = basePatientDao.findById(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BaseDoctorDO doctor1 = baseDoctorDao.findById(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String patientName = p.getName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String openId = p.getOpenid(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            /*WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_service","fwxmpj"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String first = templateConfig.getFirst(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            first = first.replace("key1",(patientName==null?"":patientName)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String keyword1 = templateConfig.getKeyword1(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            org.json.JSONObject json = new org.json.JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            json.put("keyword1", title); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            json.put("keyword2",doctor1.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            json.put("keyword3", sdf.format(new Date())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            json.put("toUser", p.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            json.put("represented",p.getCode());//被代理人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            json.put("remark", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            json.put("doctor",doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            json.put("planIds", planDetailId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            first = first.replace("key2",title); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            json.put("first", first); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(StringUtils.isNotBlank(p.getOpenid())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 25, openId, p.getName(), json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //发送代理人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(p.getCode(), p.getOpenid()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (jsonArray != null && jsonArray.length() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    for (int i = 0; i < jsonArray.length(); i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        org.json.JSONObject j = jsonArray.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        Patient member = (Patient) j.get("member"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        org.json.JSONObject data = json; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        data.remove("toUser"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        data.put("toUser", member.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        data.remove("first"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        data.put("first", weiXinOpenIdUtils.getTitleMes(p, j.getInt("relation"), p.getName()) + first); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 25, member.getOpenid(), p.getName(), data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return resultMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 电话关怀拨打电话后生成对应记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param jsonStr 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public RehabilitationOperateRecordsDO planDetailAfterCall(String jsonStr){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject jsonObject = JSON.parseObject(jsonStr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        /*{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            "rehabilitationDetailId":"808080eb764ba46b017669712c640012", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "doctorCode":"7e06886207e843948ae65d8f91d6ca97", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "doctorName":"兰冠勇" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        RehabilitationDetailDO rehabilitationDetailDO = rehabilitationDetailDao.findById(jsonObject.getString("rehabilitationDetailId")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PatientRehabilitationPlanDO patientRehabilitationPlanDO = patientRehabilitationPlanDao.findById(rehabilitationDetailDO.getPlanId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        RehabilitationOperateRecordsDO rehabilitationOperateRecordsDO = new RehabilitationOperateRecordsDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rehabilitationOperateRecordsDO.setId(getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (rehabilitationDetailDO.getExecuteTime()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            rehabilitationOperateRecordsDO.setReserveTime(rehabilitationDetailDO.getExecuteTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rehabilitationOperateRecordsDO.setStatus(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rehabilitationOperateRecordsDO.setRelationRecordImg("[]"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rehabilitationOperateRecordsDO.setRehabilitationDetailId(rehabilitationDetailDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rehabilitationOperateRecordsDO.setPatientCode(patientRehabilitationPlanDO.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rehabilitationOperateRecordsDO.setPatientName(patientRehabilitationPlanDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rehabilitationOperateRecordsDO.setDoctorCode(jsonObject.getString("doctorCode")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rehabilitationOperateRecordsDO.setDoctorName(jsonObject.getString("doctorName")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rehabilitationOperateRecordsDO.setRelationRecordType(5); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rehabilitationOperateRecordsDO.setCompleteTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rehabilitationOperateRecordsDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        rehabilitationOperateRecordsDO.setUpdateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(rehabilitationDetailDO.getFrequencyCode())){//限定频次的 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            rehabilitationDetailDO.setStatus(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            rehabilitationDetailDao.save(rehabilitationDetailDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            rehabilitationOperateRecordsDO.setRelationRecordType(8); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return rehabilitationOperateRecordsDao.save(rehabilitationOperateRecordsDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 更新康复计划项目状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param status 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param planDetailId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Envelop updatePlanDetailStatusById(Integer status,String planDetailId) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(rehabilitationDetailDao.updateStatusById(status,planDetailId)>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return Envelop.getSuccess(SpecialistMapping.api_success); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return Envelop.getError("更新失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Envelop updatePlanDetailExecuteTimeById(Date executeTime,String planDetailId) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(rehabilitationDetailDao.updateExecuteTime(executeTime,planDetailId)>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return Envelop.getSuccess(SpecialistMapping.api_success); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return Envelop.getError("更新失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 计划总进度 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param planId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public ObjEnvelop planSchedule(String planId,String patientCode){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> resultMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer allCount = rehabilitationDetailDao.findAllByPlanId(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()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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("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()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO basePatientDO = basePatientDao.findById(patientCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer age = IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sex = IdCardUtil.getSexForIdcard_new(basePatientDO.getIdcard()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("sex","1".equals(sex)?"男":("2".equals(sex)?"女":"未知")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("age",age); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("patientPhoto",basePatientDO.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("patientName",basePatientDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        resultMap.put("patientCode",basePatientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String healthyConditionSql =" select  label_name,label from wlyy_sign_patient_label_info where status=1 and patient='"+basePatientDO.getId()+"' 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("idcard",basePatientDO.getIdcard()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        resultMap.put("healthyCondition",healthyCondition); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 根据居民获取康复计划 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patient 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public ObjEnvelop planListByPatient(String patient){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<PatientRehabilitationPlanDO> list = patientRehabilitationPlanDao.findByPatients(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 医生已计划数,已完成计划数(居民数) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param doctorCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    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 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        List<Object> list = rehabilitationDetailDao.dailyJob(startTime,endTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " 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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            listMap = rehabilitationDetailDao.findByPatientAndDoctor(startTime,endTime,doctorCode,patientCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String ids = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(Map<String,Object> one2 : list2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ids += ","+one2.get("id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            one.put("planDetailIds",StringUtils.isNotEmpty(ids)?ids.substring(1):""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 根据ids获取数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param ids 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    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(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        envelop.setObj(rehabilitationDetailDOS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return envelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 查询频次列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Frequency> selectFrequences(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Frequency> frequencieList = frequencyDao.findByDel(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return frequencieList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public ObjEnvelop getServiceItemsAfterStop(String planId)throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> reslutMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql ="SELECT" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.patient," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.name," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.title," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.disease_name,p.abort_reason,p.abort_time,p.create_time,p.patient_img," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " a.*" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_patient_rehabilitation_plan p" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN (" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  SELECT" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  d.id," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  d.plan_id," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  d.hospital," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  d.hospital_name," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  i.code as service_item_id," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  i.name as service_item_name," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  d.expense," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  r.doctor_code," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  r.doctor_name," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  r.complete_time, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  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_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+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql = TransforSqlUtl.wlyy_patient_rehabilitation_planName(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql = TransforSqlUtl.wlyy_rehabilitation_operate_recordsDoctorName(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer allCount = rehabilitationDetailDao.findAllByPlanId(planId);//计划总服务项目数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer finishCount = list.size();//完成服务项目数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        double totalExpense = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Set<String> hospitalSet = new HashSet(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Set<String> serviceDoctor = new HashSet(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        DecimalFormat df = new DecimalFormat("0.00"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            totalExpense += expense; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            map.put("expense",df.format(expense/100)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //组装机构和服务医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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") + "")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    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(",", "、")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (list!=null&&list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            reslutMap.put("patientName",list.get(0).get("name")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            reslutMap.put("abortTime",list.get(0).get("abort_time")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            reslutMap.put("hospitalName",list.get(0).get("hospital_name")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            reslutMap.put("abortReason",list.get(0).get("abort_reason")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String patientCode = String.valueOf(list.get(0).get("patient")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            reslutMap.put("patientCode", patientCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            reslutMap.put("disease_name", list.get(0).get("disease_name")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            reslutMap.put("create_time", list.get(0).get("create_time")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            reslutMap.put("patient_img", list.get(0).get("patient_img")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BasePatientDO patient = basePatientDao.findById(patientCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (patient!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                reslutMap.put("openid", patient.getOpenid()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                reslutMap.put("ssc",patient.getSsc()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                reslutMap.put("mobile",patient.getMobile()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,reslutMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String getCode() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return UUID.randomUUID().toString().replaceAll("-", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |