| 
					
				 | 
			
			
				@ -1293,8 +1293,12 @@ public class SpecialistService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject transferPatients(String teamCode,String doctorCode,String toDoctorCode,String patients){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject transferPatients(String teamCode,String toTeamCode,String doctorCode,String toDoctorCode,String patients){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String[] patient = patients.split(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        boolean flag=false;//同团队时 teamCode==toTeamCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (!teamCode.equals(toTeamCode)){//跨团队 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            flag=true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql =" select name from wlyy.wlyy_doctor where code='"+toDoctorCode+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String toDoctorName = jdbcTemplate.queryForObject(sql,String.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql =" select name from wlyy.wlyy_doctor where code='"+doctorCode+"'"; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1305,6 +1309,8 @@ public class SpecialistService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray specialistPatientRelation = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray rehabilitationOperateRecords = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (String patientCode:patient){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql ="select name from wlyy.wlyy_patient where code='"+patientCode+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String patientName = jdbcTemplate.queryForObject(sql,String.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<PatientRehabilitationPlanDO> planList  = patientRehabilitationPlanDao.findByPatientAndCreateUserAndTeamCode(patientCode,doctorCode,Integer.parseInt(teamCode));{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (PatientRehabilitationPlanDO plan:planList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    plan.setCreateUser(toDoctorCode); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1312,6 +1318,9 @@ public class SpecialistService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    plan.setUpdateUser(doctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    plan.setUpdateUserName(doctorName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    plan.setUpdateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (flag){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        plan.setTeamCode(Integer.parseInt(toTeamCode)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientRehabilitationPlanDao.save(plan); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    planObject.add(plan.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    PatientRehabilitationPlanLogDO planLogDO = new PatientRehabilitationPlanLogDO(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1319,10 +1328,12 @@ public class SpecialistService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    planLogDO.setPlanId(plan.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    planLogDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    planLogDO.setCreateUser(doctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    planLogDO.setCreateUserName(toDoctorName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    planLogDO.setCreateUserName(doctorName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientRehabilitationPlanLogDao.save(planLogDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    List<RehabilitationDetailDO> planDetails  = rehabilitationDetailDao.findByPlanIdAndTypeAndDoctorAndStatusNot(plan.getId(),2,doctorCode,1);//未完成的任务 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    for (RehabilitationDetailDO planDetail:planDetails){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        planDetail.setCreateUser(toDoctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        planDetail.setCreateUserName(toDoctorName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        planDetail.setDoctor(toDoctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        planDetail.setDoctorName(toDoctorName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        planDetail.setUpdateTime(new Date()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1343,15 +1354,74 @@ public class SpecialistService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<SpecialistPatientRelationDO> relations = specialistPatientRelationDao.findListByTeamCodeAndPatientAndDoctor(Integer.parseInt(teamCode),patientCode,doctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (SpecialistPatientRelationDO relation:relations){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                relation.setDoctor(toDoctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                relation.setDoctorName(toDoctorName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                relation.setUpdateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                relation.setUpdateUser(doctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                relation.setUpdateUserName(doctorName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                specialistPatientRelationDao.save(relation); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                specialistPatientRelation.add(relation.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (flag){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                SpecialistPatientRelationDO relations = specialistPatientRelationDao.findByTeamCodeAndPatient(Integer.parseInt(toTeamCode),patientCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                SpecialistPatientRelationDO relationDoBefore = specialistPatientRelationDao.findByTeamCodeAndPatient(Integer.parseInt(teamCode),patientCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (relations==null){//跨团队时  患者未与目标团队签约 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    SpecialistPatientRelationDO relationDO = new SpecialistPatientRelationDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relationDO.setId(UUID.randomUUID().toString().replace("-","")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relationDO.setDoctorName(toDoctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relationDO.setDoctorName(toDoctorName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relationDO.setPatient(patientCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relationDO.setPatientName(patientName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relationDO.setTeamCode(Integer.parseInt(toTeamCode)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relationDO.setSignStatus("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relationDO.setStatus("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relationDO.setSignYear(DateUtil.getSignYear()+""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relationDO.setSignDate(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relationDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relationDO.setCreateUser(toDoctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relationDO.setCreateUserName(toDoctorName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relationDO.setUpdateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (StringUtils.isNotBlank(relationDoBefore.getDiseaseCode())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        relationDO.setDiseaseCode(relationDoBefore.getDiseaseCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (relationDoBefore.getDiseaseCode()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        relationDO.setIsManage(relationDoBefore.getIsManage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (StringUtils.isNotBlank(relationDoBefore.getManageUser())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        relationDO.setManageUser(relationDoBefore.getManageUser()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (StringUtils.isNotBlank(relationDoBefore.getManageTime().toString())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        relationDO.setManageTime(relationDoBefore.getManageTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (StringUtils.isNotBlank(relationDoBefore.getRemindTime())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        relationDO.setRemindTime(relationDoBefore.getRemindTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    specialistPatientRelationDao.save(relationDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    specialistPatientRelation.add(relationDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sql = "UPDATE wlyy.wlyy_patient_disease_server set specialist_relation_code='"+relationDO.getId()+"' \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            "where specialist_relation_code='"+relationDoBefore.getId()+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jdbcTemplate.execute(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relations.setCreateUser(toDoctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relations.setCreateUserName(toDoctorName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relations.setDoctor(toDoctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relations.setDoctorName(toDoctorName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relations.setUpdateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relations.setUpdateUser(doctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relations.setUpdateUserName(doctorName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    specialistPatientRelationDao.save(relations); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    specialistPatientRelation.add(relations.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sql = "UPDATE wlyy.wlyy_patient_disease_server set specialist_relation_code='"+relations.getId()+"' \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            "where specialist_relation_code='"+relationDoBefore.getId()+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jdbcTemplate.execute(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            else{// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<SpecialistPatientRelationDO> relations = specialistPatientRelationDao.findListByTeamCodeAndPatientAndDoctor(Integer.parseInt(teamCode),patientCode,doctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (SpecialistPatientRelationDO relation:relations){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relation.setCreateUser(toDoctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relation.setCreateUserName(toDoctorName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relation.setDoctor(toDoctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relation.setDoctorName(toDoctorName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relation.setUpdateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relation.setUpdateUser(doctorCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    relation.setUpdateUserName(doctorName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    specialistPatientRelationDao.save(relation); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    specialistPatientRelation.add(relation.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("planList",planObject); 
			 |