| 
					
				 | 
			
			
				@ -1,876 +0,0 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.wlyy.web.doctor.followup; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.Api; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.json.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.json.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.data.domain.Page; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.http.MediaType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Controller; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.RequestMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.RequestMethod; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.RequestParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.ResponseBody; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.follow.FollowUpPlan; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.follow.FollowUpPlanStageTarget; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.follow.FollowUpQuestion; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.follow.FollowUpTc; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.follow.FollowUpTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.follow.FollowUpTemplatePlan; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.follow.FollowUpTemplateQuestion; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.follow.FollowUpTemplateQuestionOption; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.app.followup.FollowUpService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.app.team.DrHealthTeamService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.common.account.DoctorService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.util.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.web.BaseController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * 医生端:随访干预 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * @author George 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@Controller 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@RequestMapping(value = "/doctor/followup", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@Api(description = "随访干预") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				public class DoctorFollowUpControllerGeorge extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					private FollowUpService followUpService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					private DoctorService doctorService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					private DrHealthTeamService drHealthTeamService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * 已发起的随访计划列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param type 查询类型:1已发起,2已结束 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@RequestMapping(value = "planList") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public String planList(int type, long id, int pagesize) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							JSONArray array = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							Page<FollowUpPlan> page = followUpService.findPlanByDoctor(getUID(), type, id, pagesize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (page != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								for (FollowUpPlan plan : page) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									if (plan == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									JSONObject json = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("id", plan.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 计划标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("code", plan.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 计划标题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("title", plan.getTitle()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 患者标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("patient", plan.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 患者姓名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("name", plan.getPatientName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 计划状态:-1暂停,0进行中,1已结束 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("status", plan.getStatus()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 制定日期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("czrq", DateUtil.dateToStrShort(plan.getCzrq())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									array.put(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return write(200, "查询成功!", "list", array); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							error(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return error(-1, "查询失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * 随访计划模板查询接口 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param pagesize 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@RequestMapping(value = "planTemplateList") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public String planTemplateList(long id, int pagesize) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							JSONArray array = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							Page<FollowUpTemplatePlan> page = followUpService.findPlanTemplateByDoctor(getUID(), id, pagesize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (page != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								for (FollowUpTemplatePlan plan : page) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									if (plan == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									JSONObject json = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("id", plan.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 计划标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("code", plan.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 计划标题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("title", plan.getTitle()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 添加日期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("czrq", DateUtil.dateToStrShort(plan.getCzrq())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									array.put(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return write(200, "查询成功!", "list", array); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							error(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return error(-1, "查询失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * 查询医生随访模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param kind 查询类型:0全部模板,1系统模板,2自定义模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param type 模板类型:0全部类型,1问卷模板,2体测模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param pagesize 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@RequestMapping(value = "templateList") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public String templateList(int kind, int type, long id, int pagesize) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							JSONArray array = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							Page<FollowUpTemplate> page = followUpService.findTemplateByDoctor(getUID(), kind, type, id, pagesize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (page != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								for (FollowUpTemplate template : page) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									if (template == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									JSONObject json = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("id", template.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 模板标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("code", template.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 模板标题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("title", template.getTitle()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 模板类型:1问卷模板,2体测模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("type", template.getType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 创建日期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("czrq", DateUtil.dateToStrLong(template.getCzrq())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									array.put(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return write(200, "查询成功!", "list", array); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							error(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return error(-1, "查询失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * 阶段目标列表查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@RequestMapping(value = "targetList") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public String targetList() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							JSONArray array = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							List<FollowUpPlanStageTarget> list = followUpService.findTargetList(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (list != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								for (FollowUpPlanStageTarget target : list) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									if (target == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									JSONObject json = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("id", target.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 目标内容 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("content", target.getContent()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									array.put(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return write(200, "查询成功!", "list", array); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							error(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return error(-1, "查询失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * 体测题目列表查询接口 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param type 查询类型:0全部, 1系统,2自定义 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param pagesize 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@RequestMapping(value = "tcList") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public String tcList(int type, long id, int pagesize) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							JSONArray array = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							Page<FollowUpTc> page = followUpService.findTcList(getUID(), type, id, pagesize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (page != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								for (FollowUpTc tc : page) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									if (tc == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									JSONObject json = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("id", tc.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 设置问题标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("code", tc.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 设置体测指标类型(1血糖,2血压,3体重,4腰围) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("index", tc.getIndex()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 设置标题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("title", tc.getTitle()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 设置选项数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("child", new JSONArray(tc.getContent())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									array.put(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return write(200, "查询成功!", "list", array); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							error(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return error(-1, "查询失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * 问卷题目列表查询接口 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param type 查询类型:0全部, 1系统,2自定义 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param pagesize 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@RequestMapping(value = "questionList") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public String questionList(int type, long id, int pagesize) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							JSONArray array = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							Page<FollowUpQuestion> page = followUpService.findQuestionList(getUID(), type, id, pagesize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (page != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								for (FollowUpQuestion question : page) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									if (question == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									JSONObject json = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("id", question.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 设置问题标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("code", question.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 设置标题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("title", question.getTitle()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 设置问题类型:1单选,2多选,3问答 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("type", question.getType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 设置选项数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									json.put("child", StringUtils.isNotEmpty(question.getContent()) ? new JSONArray(question.getContent()) : new JSONArray()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									array.put(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return write(200, "查询成功!", "list", array); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							error(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return error(-1, "查询失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * 添加随访模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param title 模板标题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param type 模板类型:1问卷模板,2体测模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param questions 模板问题json数据字符串 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param push_type 推送类型:1按时间,2按次数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param push_times 推送次数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param push_cycle 推送周期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param push_cycle_unit 推送周期单位:1天,2周,3月 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@RequestMapping(value = "addTemplate") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public String addTemplate(String title, int type, int push_type, int push_times, int push_cycle, int push_cycle_unit, String questions) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 新的模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							FollowUpTemplate template = new FollowUpTemplate(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 设置模板标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							template.setCode(followUpService.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 设置添加时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							template.setCzrq(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 设置添加医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							template.setDoctor(getUID()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 设置模板标题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							template.setTitle(title); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 设置模板类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							template.setType(type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 设置推送类型:1按时间,2按次数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							template.setPushType(push_type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 设置推送次数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							template.setPushTimes(push_times); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 设置推送周期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							template.setPushCycle(push_cycle); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 设置推送周期单位:1天,2周,3月 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							template.setPushCycleUnit(push_cycle_unit); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							JSONArray array = new JSONArray(questions); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (array == null || array.length() == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return error(-1, "请至少为模板设置一个问题!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 问题列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							List<FollowUpTemplateQuestion> questionList = new ArrayList<FollowUpTemplateQuestion>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 问题选项列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							List<FollowUpTemplateQuestionOption> optionsList = new ArrayList<FollowUpTemplateQuestionOption>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							for (int i = 0; i < array.length(); i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								JSONObject json = array.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 新的模板问题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								FollowUpTemplateQuestion question = new FollowUpTemplateQuestion(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 设置问题标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								question.setCode(followUpService.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 设置体测指标类型:1血糖,2血压,3体重,4腰围 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								if (type == 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									question.setIndex(json.getInt("index")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 设置模板标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								question.setTemplate(template.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 设置问题标题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								question.setTitle(json.getString("title")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								if (type == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 问卷模板可以为单选,多选和问答 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									question.setType(type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} else if (type == 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									// 体测模板只能为问答 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									question.setType(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 设置问题选项jsonarray串 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								question.setOptions(json.getString("options")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 问题选项 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								JSONArray options = json.getJSONArray("options"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								if (options != null && options.length() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									for (int j = 0; j < options.length(); j++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										String des = options.getString(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										if (StringUtils.isEmpty(des)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
											continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										// 新的问题选项 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										FollowUpTemplateQuestionOption option = new FollowUpTemplateQuestionOption(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										// 设置选项描述 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										option.setDes(des); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										// 设置问题标题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										option.setQuestion(question.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										// 设置模板标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										option.setTemplate(template.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										// 添加到选项列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										optionsList.add(option); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 添加到问题列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								questionList.add(question); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 保存到数据库 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							followUpService.saveTemplate(template, questionList, optionsList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return success("模板保存成功!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							error(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return error(-1, "模板保存失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * 删除随访模板接口 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param template 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@RequestMapping(value = "delTemplate") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public String delTemplate(String template) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							FollowUpTemplate fut = followUpService.findTemplateByCode(template); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (fut == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 模板已不存在 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return error(-1, "随访模板不存在或已删除!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} else if (!StringUtils.equals(fut.getDoctor(), getUID())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 非自己的模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return error(-1, "只允许删除自己的随访模板!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 从数据库中删除 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							followUpService.deleteTemplate(template); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return success("模板已删除!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							error(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return error(-1, "模板删除失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * 查询模板详情 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param template 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@RequestMapping(value = "templateInfo") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public String templateInfo(String template) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 查询模板基本信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							FollowUpTemplate templateInfo = followUpService.findTemplateInfo(template); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (templateInfo == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return error(-1, "模板信息不存在!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							JSONObject json = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 模板标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							json.put("code", templateInfo.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 模板标题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							json.put("title", templateInfo.getTitle()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 模板类型:1问卷模板,2体测模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							json.put("type", templateInfo.getType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 推送类型:1按时间,2按次数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							json.put("push_type", templateInfo.getPushType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 推送次数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							json.put("push_times", templateInfo.getPushTimes()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 推送周期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							json.put("push_cycle", templateInfo.getPushCycle()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 推送周期单位:1天,2周,3月 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							json.put("push_cycle_unit", templateInfo.getPushCycleUnit()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 查询模板问题列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							List<FollowUpTemplateQuestion> questionList = followUpService.findTemplateQuestions(template); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							JSONArray questions = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							for (FollowUpTemplateQuestion temp : questionList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								JSONObject question = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 问题标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								question.put("code", temp.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 问题标题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								question.put("title", temp.getTitle()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 问题类型:1单选,2多选,3问答 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								question.put("type", temp.getType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 体测指标类型:1血糖,2血压,3体重,4腰围 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								question.put("index", temp.getIndex()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 设置问题选项 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								if (StringUtils.isNotEmpty(temp.getOptions())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									question.put("options", new JSONArray(temp.getOptions())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								questions.put(question); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							json.put("questions", questions); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return write(200, "模板详情查询成功!", "data", json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							error(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return error(-1, "模板详情查询失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * 添加随访计划模板接口 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param template 模板标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param title 随访计划名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param stages 随访阶段jsonarray字符串 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@RequestMapping(value = "addPlanTemplate") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public String addPlanTemplate(@RequestParam(required = false) String template, String title, String stages) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							JSONArray stageArray = new JSONArray(stages); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (stageArray == null || stageArray.length() == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return error(-1, "请至少为随访计划设置一个阶段!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							FollowUpTemplatePlan plan = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (StringUtils.isNotEmpty(template)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								plan = followUpService.findPlanTemplateByCode(template); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (plan == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 新的随访 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								plan = new FollowUpTemplatePlan(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 设置随访标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							plan.setCode(followUpService.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 设置随访计划模板标题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							plan.setTitle(title); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							plan.setCzrq(new Date(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 设置制定医生标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							plan.setDoctor(getUID()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 设置模板内容 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							plan.setStages(stages); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 保存到数据库 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							followUpService.addPlanTemplate(plan); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return write(200, "随访计划模板保存成功!", "data", plan.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							error(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return error(-1, "随访计划模板保存失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * 删除随访计划模板接口 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param template 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@RequestMapping(value = "delPlanTemplate") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public String delPlanTemplate(String template) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							FollowUpTemplatePlan plan = followUpService.findPlanTemplateByCode(template); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (plan == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 模板已不存在 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return error(-1, "随访计划模板不存在或已删除!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} else if (!StringUtils.equals(plan.getDoctor(), getUID())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 非自己的模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return error(-1, "只允许删除自己的随访计划模板!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 从数据库中删除 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							followUpService.deletePlanTemplate(plan); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return write(200, "模板已删除!", "data", plan.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							error(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return error(-1, "随访计划模板删除失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * 查询随访计划模板详细信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param template 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@RequestMapping(value = "planTemplateInfo") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public String planTemplateInfo(String template) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 查询模板信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							FollowUpTemplatePlan plan = followUpService.findPlanTemplateByCode(template); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							JSONObject json = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 模板标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							json.put("code", plan.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 模板标题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							json.put("title", plan.getTitle()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							// 计划阶段、随访项、问题详细信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							json.put("stages", plan.getStages()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return write(200, "随访计划模板信息查询成功!", "data", json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							error(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return error(-1, "随访计划模板信息查询失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * 添加随访计划接口 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param title 随访计划名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param template 随访计划模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param patients 患者jsonarray字符串 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@RequestMapping(value = "addPlan") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public String addPlan(String title, String template, String patients) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			JSONArray patientArray = new JSONArray(patients); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			if (patientArray == null || patientArray.length() == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				return error(-1, "请至少选择一个患者!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			// 查询随访计划模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			FollowUpTemplatePlan templatePlan = followUpService.findPlanTemplateByCode(template); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			// 随访模板的阶段详情 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			JSONArray stageArray = new JSONArray(templatePlan.getStages()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			if (stageArray == null || stageArray.length() == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				return error(-1, "请至少为随访计划设置一个阶段!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			Map<String, List<DoctorTeamInfo>> cache = new HashMap<String, List<DoctorTeamInfo>>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			// 查询医生信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			Doctor doctor = doctorService.findDoctorByCode(getUID()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			// 随访计划列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			List<FollowUpPlan> planList = new ArrayList<FollowUpPlan>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			// 医生相关的随访计划列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			List<FollowUpPlanDoctor> planDoctorList = new ArrayList<FollowUpPlanDoctor>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			// 随访阶段列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			List<FollowUpPlanStage> stageList = new ArrayList<FollowUpPlanStage>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			// 随访项列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			List<FollowUpPlanStageItem> stageItemList = new ArrayList<FollowUpPlanStageItem>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			// 随访问题列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			List<FollowUpPlanStageItemQuestion> questionList = new ArrayList<FollowUpPlanStageItemQuestion>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			// 随访问题选项列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			List<FollowUpPlanStageItemQuestionOption> optionList = new ArrayList<FollowUpPlanStageItemQuestionOption>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			// 随访记录列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			List<FollowUpItemRecord> recordList = new ArrayList<FollowUpItemRecord>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			// 随访记录问题列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			List<FollowUpItemRecordQuestion> recordQuestionList = new ArrayList<FollowUpItemRecordQuestion>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			// 随访记录问题选项列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			List<FollowUpItemRecordQuestionOption> recordQuestionOptionList = new ArrayList<FollowUpItemRecordQuestionOption>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			// 消息列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			JSONArray messages = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			for (int i = 0; i < patientArray.length(); i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				JSONObject patient = patientArray.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				// 新的随访 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				FollowUpPlan plan = new FollowUpPlan(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				// 设置随访标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				plan.setCode(followUpService.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				plan.setCzrq(new Date(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				// 设置制定医生标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				plan.setDoctor(doctor.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				// 设置制定医生姓名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				plan.setDoctorName(doctor.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				// 设置患者标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				plan.setPatient(patient.getString("patient")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				// 设置患者姓名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				plan.setPatientName(patient.getString("name")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				// 设置为进行中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				plan.setStatus(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				// 查询患者的签约三师团队 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				String team = doctorTeamService.isSingContract(getUID(), plan.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				if (StringUtils.isNotEmpty(team)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					plan.setTeam(team); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					// 查询三师团队下的医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					List<DoctorTeamInfo> teamInfos = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					if (cache.containsKey(team)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//						teamInfos = cache.get(team); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//						teamInfos = doctorTeamService.findDoctorByTeam(team); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					if (teamInfos != null && teamInfos.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//						for (DoctorTeamInfo dti : teamInfos) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							// 新的医生关联计划 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							FollowUpPlanDoctor fpd = new FollowUpPlanDoctor(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							// 设置医生标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							fpd.setDoctor(dti.getDoctor()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							// 设置计划标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							fpd.setPlan(plan.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							// 添加到队列中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							planDoctorList.add(fpd); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				// 设置计划标题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				plan.setTitle(title); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				// 设置统计数量为0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				plan.setWjAmount(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				plan.setWjFinishAmount(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				plan.setTcAmount(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				plan.setTcFinishAmount(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				// 添加到计划列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				planList.add(plan); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				// =====================================计划阶段======================================== 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				for (int j = 0; j < stageArray.length(); j++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					JSONObject tempStage = stageArray.getJSONObject(j); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					// 新的随访阶段 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					FollowUpPlanStage stage = new FollowUpPlanStage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					// 设置阶段标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					stage.setCode(doctorTeamService.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					stage.setCzrq(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					// 设置医生标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					stage.setDoctor(doctor.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					// 设置医生姓名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					stage.setDoctorName(doctor.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					// 设置阶段结束日期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					stage.setEndDate(DateUtil.strToDateShort(tempStage.getString("end_date"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					// 设置随访计划标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					stage.setPlan(plan.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					// 设置阶段序号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					stage.setSeq(j + 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					// 设置状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					if (j == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//						// 默认开始第一阶段 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//						stage.setStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//						// 其他阶段未开始 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//						stage.setStatus(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					// 设置阶段目标 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					stage.setTarget(tempStage.getString("target")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					// 设置类型:1定时,2不定时 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					stage.setType(tempStage.getInt("type")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					// 添加到阶段列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					stageList.add(stage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					// ====================================随访项====================================== 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					JSONArray stageItemArray = tempStage.getJSONArray("items"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					if (stageItemArray != null && stageItemArray.length() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//						for (int k = 0; k < stageItemArray.length(); k++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							JSONObject tempItem = stageItemArray.getJSONObject(k); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							// 新的随访项 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							FollowUpPlanStageItem item = new FollowUpPlanStageItem(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							// 设置随访项标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							item.setCode(doctorTeamService.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							item.setCzrq(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							// 设置随访计划标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							item.setPlan(plan.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							// 设置推送类型:1按时间,2按次数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							item.setPushType(tempItem.getInt("push_type")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							// 设置推送周期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							item.setPushCycle(tempItem.getInt("push_cycle")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							// 设置推送开始时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							item.setPushBegin(DateUtil.strToDateShort(tempItem.getString("push_begin"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							if (item.getPushType() == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								// 设置推送周期单位:1天,2周,3月 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								item.setPushCycleUnit(tempItem.getInt("push_cycle_unit")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								// 设置推送结束日期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								item.setPushEnd(DateUtil.strToDateShort(tempItem.getString("push_end"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							} else if (item.getPushType() == 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								// 设置推送次数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								item.setPushTimes(tempItem.getInt("push_times")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							// 设置阶段标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							item.setStage(stage.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							// 设置执行状态:-1暂停,0未开始,1进行中,2已结束 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							if (stage.getStatus() != 1 || DateUtil.getNowDateShort().before(item.getPushBegin())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								// 推送时间未到,未开始 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								item.setStatus(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								// 已到推送时间,正在进行 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								item.setStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								// 默认为已推送1次 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								item.setTimes(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								// 计算下一次推送日期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								Date nextPushDate = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								if (item.getPushCycleUnit() == 1 || item.getPushCycleUnit() == 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									// 按天数再推算一下个推送日期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									int days = item.getPushCycle(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									if (item.getPushCycleUnit() == 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										// 1周7天 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										days = item.getPushCycle() * 7; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									// 设置下一次推送日期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									nextPushDate = DateUtil.strToDateShort(DateUtil.getNextDay(item.getPushBegin(), days)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									// 按月推送 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									nextPushDate = DateUtil.strToDateShort(DateUtil.getNextMonth(item.getPushBegin(), item.getPushCycle())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								if (item.getPushType() == 1 && nextPushDate.after(item.getPushEnd())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									// 按时间推送且未过推送结束日期 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									item.setNextPushDate(nextPushDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								} else if (item.getPushType() == 2 && item.getPushTimes() > 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									// 接次数推送且推送次数大于1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									item.setNextPushDate(nextPushDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							// 设置随访项标题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							item.setTitle(tempItem.getString("title")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							// 设置随访项类型:1问卷,2体测 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							item.setType(tempItem.getInt("type")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							// 添加随访项列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							stageItemList.add(item); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							// 新的随访记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							FollowUpItemRecord record = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							// 阶段和随访项都已开始执行 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							if (stage.getStatus() == 1 && item.getStatus() == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								// 生成新的随访记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								record = new FollowUpItemRecord(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								record.setCode(doctorTeamService.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								record.setCzrq(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								record.setItem(item.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								record.setPlan(plan.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								record.setStage(stage.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								// 未作答 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								record.setStatus(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								record.setTitle(item.getTitle()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								record.setType(item.getType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								// 添加到记录列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								recordList.add(record); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								// 添加到消息列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								JSONObject message = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								message.put("receiver", plan.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								message.put("type", MessageType.MESSAGE_TYPE_PATIENT_NEW_FOLLOW_UP.P_FU_01.name()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								message.put("title", MessageType.MESSAGE_TYPE_PATIENT_NEW_FOLLOW_UP.随访计划.name()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								message.put("msg", MessageType.MESSAGE_TYPE_PATIENT_NEW_FOLLOW_UP.您有新的随访计划.name()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								message.put("data", record.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								messages.put(message); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							// ==========================================随访问题========================================= 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							JSONArray questionArray = tempItem.getJSONArray("questions"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							if (questionArray != null && questionArray.length() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								for (int l = 0; l < questionArray.length(); l++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									JSONObject tempQuestion = questionArray.getJSONObject(l); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									// 新的随访问题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									FollowUpPlanStageItemQuestion question = new FollowUpPlanStageItemQuestion(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									// 设置问题标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									question.setCode(doctorTeamService.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									if (item.getType() == 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										// 体测随访,设置体测指标类型:1血糖,2血压,3体重,4腰围 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										question.setIndex(tempQuestion.getInt("index")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									// 设置随访标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									question.setItem(item.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									// 设置随访计划标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									question.setPlan(plan.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									// 设置随访计划阶段标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									question.setStage(stage.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									// 设置问题标题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									question.setTitle(tempQuestion.getString("title")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									// 设置问题类型:1单选,2多选,3问答 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									if (item.getType() == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										// 问卷随访 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										question.setType(tempQuestion.getInt("type")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										// 体测随访,只有问答 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										question.setType(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									// 添加问题列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									questionList.add(question); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									// 新的随访记录问题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									FollowUpItemRecordQuestion recordQuestion = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									if (record != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										recordQuestion = new FollowUpItemRecordQuestion(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										recordQuestion.setCode(question.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										recordQuestion.setIndex(question.getIndex()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										recordQuestion.setItem(question.getItem()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										recordQuestion.setPlan(question.getPlan()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										recordQuestion.setRecord(record.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										recordQuestion.setStage(question.getStage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										recordQuestion.setTitle(question.getTitle()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										recordQuestion.setType(question.getType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										// 添加到随访记录问题列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										recordQuestionList.add(recordQuestion); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									// ====================================问题选项======================================== 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									JSONArray optionArray = tempQuestion.getJSONArray("options"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									if (optionArray != null && optionArray.length() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										JSONArray tempArray = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										for (int u = 0; u < optionArray.length(); u++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											String des = optionArray.getString(u); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											if (StringUtils.isEmpty(des)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//												continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											// 新的问题选项 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											FollowUpPlanStageItemQuestionOption option = new FollowUpPlanStageItemQuestionOption(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											// 设置选项标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											option.setCode(doctorTeamService.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											// 设置选项描述 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											option.setDes(des); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											// 设置随访项标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											option.setItem(item.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											// 设置随访计划标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											option.setPlan(plan.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											// 设置问题标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											option.setQuestion(question.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											// 设置阶段标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											option.setStage(stage.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											// 添加到选项列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											optionList.add(option); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											// 新的随访记录问题选项 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											if (recordQuestion != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//												FollowUpItemRecordQuestionOption recordQuestionOption = new FollowUpItemRecordQuestionOption(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//												recordQuestionOption.setCode(doctorTeamService.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//												recordQuestionOption.setDes(des); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//												recordQuestionOption.setItem(item.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//												recordQuestionOption.setPlan(plan.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//												recordQuestionOption.setQuestion(question.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//												recordQuestionOption.setRecord(record.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//												recordQuestionOption.setStage(stage.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//												// 添加到随访记录问题选项列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//												recordQuestionOptionList.add(recordQuestionOption); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											JSONObject tempJson = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											tempJson.put("code", option.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											tempJson.put("des", option.getDes()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//											tempArray.put(tempJson); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										// 设置问题选项jsonarray字符串 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//										question.setOptions(tempArray.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//									} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			// 保存到数据库 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			followUpService.addPlan(planList, planDoctorList, stageList, stageItemList, questionList, optionList, recordList, recordQuestionList, recordQuestionOptionList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			// 发送推送消息给患者端 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			PushMsgTask.getInstance().put(messages); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return success("随访计划保存成功!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							error(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return error(-1, "随访计划保存失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |