hzp před 8 roky
rodič
revize
91cabef130
69 změnil soubory, kde provedl 797 přidání a 7599 odebrání
  1. 52 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/dict/DmDrugsGroup.java
  2. 88 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/dict/DmDrugsGroupItem.java
  3. 0 55
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/dict/Medicines.java
  4. 0 107
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpItemRecord.java
  5. 0 150
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpItemRecordAnswer.java
  6. 0 115
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpItemRecordQuestion.java
  7. 0 93
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpItemRecordQuestionOption.java
  8. 0 43
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpPlanDoctor.java
  9. 0 98
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpPlanRemind.java
  10. 0 130
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpPlanStage.java
  11. 0 187
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpPlanStageItem.java
  12. 0 105
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpPlanStageItemQuestion.java
  13. 0 83
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpPlanStageItemQuestionOption.java
  14. 0 47
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpPlanStageTarget.java
  15. 0 97
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpQuestion.java
  16. 0 67
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpQuestionOption.java
  17. 0 132
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpSummary.java
  18. 0 99
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpTc.java
  19. 0 67
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpTcOption.java
  20. 0 122
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpTemplate.java
  21. 0 77
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpTemplatePlan.java
  22. 0 85
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpTemplateQuestion.java
  23. 0 53
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpTemplateQuestionOption.java
  24. 194 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/followup/Followup.java
  25. 52 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/followup/FollowupClassDrugs.java
  26. 71 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/followup/FollowupContent.java
  27. 102 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/followup/FollowupDrugs.java
  28. 3 7
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/dict/MedicinesDao.java
  29. 14 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/dict/DmDrugsGroupItemDao.java
  30. 2 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpTcDao.java
  31. 0 41
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpItemRecordAnswerDao.java
  32. 0 50
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpItemRecordDao.java
  33. 0 43
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpItemRecordQuestionDao.java
  34. 0 30
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpItemRecordQuestionOptionDao.java
  35. 0 62
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpPlanDao.java
  36. 0 21
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpPlanRemindDao.java
  37. 0 37
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpPlanStageDao.java
  38. 0 54
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpPlanStageItemDao.java
  39. 0 25
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpPlanStageItemQuestionDao.java
  40. 0 18
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpPlanStageItemQuestionOptionDao.java
  41. 0 21
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpPlanStageTargetDao.java
  42. 0 15
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpQuestionOptionDao.java
  43. 0 43
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpSummaryDao.java
  44. 0 23
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpTemplateDao.java
  45. 0 17
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpTemplatePlanDao.java
  46. 0 25
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpTemplateQuestionDao.java
  47. 0 19
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpTemplateQuestionOptionDao.java
  48. 2 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpPlanDoctorDao.java
  49. 2 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpQuestionDao.java
  50. 2 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpTcOptionDao.java
  51. 0 612
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpExecutionService.java
  52. 0 106
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpPlanRemindService.java
  53. 64 300
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java
  54. 0 29
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/medicines/MedicinesService.java
  55. 0 328
      patient-co-wlyy/src/main/java/com/yihu/wlyy/task/FollowUpTask.java
  56. 149 379
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java
  57. 0 876
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpControllerGeorge.java
  58. 0 58
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpPlanRemindController.java
  59. 0 79
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/followup/FollowUpPlanRemindController.java
  60. 0 573
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/followup/PatientFollowUpController.java
  61. 0 483
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/followup/PatientFollowUpService.java
  62. 0 138
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/followup/vo/FollowUpItemRecordAnswerVO.java
  63. 0 130
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/followup/vo/FollowUpItemRecordDetailVO.java
  64. 0 71
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/followup/vo/FollowUpItemRecordQuestionOptionVO.java
  65. 0 91
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/followup/vo/FollowUpItemRecordQuestionVO.java
  66. 0 129
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/followup/vo/FollowUpItemRecordVO.java
  67. 0 127
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/followup/vo/FollowUpPlanStageItemVO.java
  68. 0 147
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/followup/vo/FollowupPlanVO.java
  69. 0 369
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthRecordController.java

+ 52 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/dict/DmDrugsGroup.java

@ -0,0 +1,52 @@
package com.yihu.wlyy.entity.dict;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 药品分组
 * hzp add 20161207
 */
@Entity
@Table(name = "dm_drugs_group")
public class DmDrugsGroup extends IdEntity {
	private String groupCode;// 分组代码
	private String groupName;// 分组名称
	private Integer order; //排序
	private String status;// 是否有效
	public String getGroupCode() {
		return groupCode;
	}
	public void setGroupCode(String groupCode) {
		this.groupCode = groupCode;
	}
	public String getGroupName() {
		return groupName;
	}
	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}
	public Integer getOrder() {
		return order;
	}
	public void setOrder(Integer order) {
		this.order = order;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
}

+ 88 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/dict/DmDrugsGroupItem.java

@ -0,0 +1,88 @@
package com.yihu.wlyy.entity.dict;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 药品分组管理
 * hzp add 20161207
 */
@Entity
@Table(name = "dm_drugs_group_item")
public class DmDrugsGroupItem extends IdEntity {
	private String groupCode;// 分组代码
	private String groupName;// 分组名称
	private String drugsCode;// 药品代码
	private String drugsName;// 药品名称
	private String drugsQpy;// 药品名称全拼
	private String drugsSpy;// 药品名称首拼
	private Integer order; //排序
	private String status;// 是否有效
	public String getGroupCode() {
		return groupCode;
	}
	public void setGroupCode(String groupCode) {
		this.groupCode = groupCode;
	}
	public String getGroupName() {
		return groupName;
	}
	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}
	public String getDrugsCode() {
		return drugsCode;
	}
	public void setDrugsCode(String drugsCode) {
		this.drugsCode = drugsCode;
	}
	public String getDrugsName() {
		return drugsName;
	}
	public void setDrugsName(String drugsName) {
		this.drugsName = drugsName;
	}
	public String getDrugsQpy() {
		return drugsQpy;
	}
	public void setDrugsQpy(String drugsQpy) {
		this.drugsQpy = drugsQpy;
	}
	public String getDrugsSpy() {
		return drugsSpy;
	}
	public void setDrugsSpy(String drugsSpy) {
		this.drugsSpy = drugsSpy;
	}
	public Integer getOrder() {
		return order;
	}
	public void setOrder(Integer order) {
		this.order = order;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
}

+ 0 - 55
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/dict/Medicines.java

@ -1,55 +0,0 @@
package com.yihu.wlyy.entity.dict;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 药品字典项目
 * @author George
 */
@Entity
@Table(name = "dm_medicines")
public class Medicines extends IdEntity {
	private static final long serialVersionUID = -6408087441099619157L;
	private String code;// 药品标识
	private String name;// 药品名称
	private Integer type;// 药品类型:1健康记录
	private String del;// 作废标识,1正常,0作废
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	public String getDel() {
		return del;
	}
	public void setDel(String del) {
		this.del = del;
	}
}

+ 0 - 107
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpItemRecord.java

@ -1,107 +0,0 @@
package com.yihu.wlyy.entity.follow;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
/**
 * 患者随访记录表
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_followup_item_record")
public class FollowUpItemRecord extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -4722079233600864444L;
	// 随访记录标识
	private String code;
	// 随访计划标识
	private String plan;
	// 随访计划阶段标识
	private String stage;
	// 随访计划阶段随访项标识
	private String item;
	// 类型:1问卷,2体测
	private Integer type;
	// 标题
	private String title;
	// 状态:0未作答,1已作答,2已完成
	private Integer status;
	// 生成日期
	private Date czrq;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getPlan() {
		return plan;
	}
	public void setPlan(String plan) {
		this.plan = plan;
	}
	public String getStage() {
		return stage;
	}
	public void setStage(String stage) {
		this.stage = stage;
	}
	public String getItem() {
		return item;
	}
	public void setItem(String item) {
		this.item = item;
	}
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
}

+ 0 - 150
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpItemRecordAnswer.java

@ -1,150 +0,0 @@
package com.yihu.wlyy.entity.follow;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
/**
 * 随访患者回答记录表
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_followup_item_record_answer")
public class FollowUpItemRecordAnswer extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 5305404035288580927L;
	// 随访计划标识
	private String plan;
	// 随访计划阶段标识
	private String stage;
	// 随访计划阶段随访项标识
	private String item;
	// 随访记录标识
	private String record;
	// 代填写医生标识
	private String doctor;
	// 代填写医生姓名
	private String doctorName;
	// 问题类型:1问卷,2体测
	private Integer type;
	// 体测指标类型:1血糖,2血压,3体重,4腰围
	private Integer index;
	// 问题标识
	private String question;
	// 选项标识
	private String option;
	// 回答内容
	private String answer;
	// 回答时间
	private Date czrq;
	public String getPlan() {
		return plan;
	}
	public void setPlan(String plan) {
		this.plan = plan;
	}
	public String getStage() {
		return stage;
	}
	public void setStage(String stage) {
		this.stage = stage;
	}
	public String getItem() {
		return item;
	}
	public void setItem(String item) {
		this.item = item;
	}
	public String getRecord() {
		return record;
	}
	public void setRecord(String record) {
		this.record = record;
	}
	public String getDoctor() {
		return doctor;
	}
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}
	public String getDoctorName() {
		return doctorName;
	}
	public void setDoctorName(String doctorName) {
		this.doctorName = doctorName;
	}
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	@Column(name="tc_index")
	public Integer getIndex() {
		return index;
	}
	public void setIndex(Integer index) {
		this.index = index;
	}
	public String getQuestion() {
		return question;
	}
	public void setQuestion(String question) {
		this.question = question;
	}
	@Column(name="option_code")
	public String getOption() {
		return option;
	}
	public void setOption(String option) {
		this.option = option;
	}
	public String getAnswer() {
		return answer;
	}
	public void setAnswer(String answer) {
		this.answer = answer;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
}

+ 0 - 115
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpItemRecordQuestion.java

@ -1,115 +0,0 @@
package com.yihu.wlyy.entity.follow;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 随访记录随访问题表
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_followup_item_record_question")
public class FollowUpItemRecordQuestion extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 540101607077150029L;
	// 问题标识(关联wlyy_followup_plan_stage_item_question表的code)
	private String code;
	// 随访计划标识
	private String plan;
	// 随访计划阶段标识
	private String stage;
	// 随访计划阶段随访项标识
	private String item;
	// 随访记录标识
	private String record;
	// 问题标题
	private String title;
	// 问题类型:1单选,2多选,3问答
	private Integer type;
	// 体测指标类型:1血糖,2血压,3体重,4腰围
	private Integer index;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getPlan() {
		return plan;
	}
	public void setPlan(String plan) {
		this.plan = plan;
	}
	public String getStage() {
		return stage;
	}
	public void setStage(String stage) {
		this.stage = stage;
	}
	public String getItem() {
		return item;
	}
	public void setItem(String item) {
		this.item = item;
	}
	public String getRecord() {
		return record;
	}
	public void setRecord(String record) {
		this.record = record;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	@Column(name="tc_index")
	public Integer getIndex() {
		return index;
	}
	public void setIndex(Integer index) {
		this.index = index;
	}
	public FollowUpItemRecordQuestion() {
		super();
	}
	public FollowUpItemRecordQuestion(String item, Integer index) {
		super();
		this.item = item;
		this.index = index;
	}
}

+ 0 - 93
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpItemRecordQuestionOption.java

@ -1,93 +0,0 @@
package com.yihu.wlyy.entity.follow;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 随访记录随访问题选项表
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_followup_item_record_question_option")
public class FollowUpItemRecordQuestionOption extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -5293620282726268474L;
	// 随访项标识
	private String code;
	// 随访计划标识
	private String plan;
	// 随访计划阶段标识
	private String stage;
	// 随访计划阶段随访项标识
	private String item;
	// 问题标识(关联wlyy_followup_item_record_question表的code)
	private String record;
	// 随访项标识
	private String question;
	// 选项描述
	private String des;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getPlan() {
		return plan;
	}
	public void setPlan(String plan) {
		this.plan = plan;
	}
	public String getStage() {
		return stage;
	}
	public void setStage(String stage) {
		this.stage = stage;
	}
	public String getRecord() {
		return record;
	}
	public void setRecord(String record) {
		this.record = record;
	}
	public String getQuestion() {
		return question;
	}
	public void setQuestion(String question) {
		this.question = question;
	}
	public String getItem() {
		return item;
	}
	public void setItem(String item) {
		this.item = item;
	}
	public String getDes() {
		return des;
	}
	public void setDes(String des) {
		this.des = des;
	}
}

+ 0 - 43
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpPlanDoctor.java

@ -1,43 +0,0 @@
package com.yihu.wlyy.entity.follow;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 医生相关的随访计划表
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_followup_plan_doctor")
public class FollowUpPlanDoctor extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 2600515443489417609L;
	
	// 随访计划标识
	private String plan;
	// 医生标识
	private String doctor;
	public String getPlan() {
		return plan;
	}
	public void setPlan(String plan) {
		this.plan = plan;
	}
	public String getDoctor() {
		return doctor;
	}
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}
}

+ 0 - 98
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpPlanRemind.java

@ -1,98 +0,0 @@
package com.yihu.wlyy.entity.follow;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
/**
 * 随访提醒
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_followup_plan_remind")
public class FollowUpPlanRemind extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 7204801650136946874L;
	// 患者标识
	private String patient;
	// 医生标识
	private String doctor;
	// 医生姓名
	private String doctorName;
	// 计划标识
	private String plan;
	// 提醒内容
	private String content;
	// 患者是否已读,1未读,0已读
	private Integer read;
	// 发布时间
	private Date czrq;
	public String getPatient() {
		return patient;
	}
	public void setPatient(String patient) {
		this.patient = patient;
	}
	public String getDoctor() {
		return doctor;
	}
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}
	@Column(name = "doctor_name")
	public String getDoctorName() {
		return doctorName;
	}
	public void setDoctorName(String doctorName) {
		this.doctorName = doctorName;
	}
	public String getPlan() {
		return plan;
	}
	public void setPlan(String plan) {
		this.plan = plan;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public Integer getRead() {
		return read;
	}
	public void setRead(Integer read) {
		this.read = read;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
}

+ 0 - 130
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpPlanStage.java

@ -1,130 +0,0 @@
package com.yihu.wlyy.entity.follow;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
/**
 * 随访计划阶段表
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_followup_plan_stage")
public class FollowUpPlanStage extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -1393541823392336558L;
	// 计划标识
	private String code;
	// 医生标识
	private String doctor;
	// 医生姓名
	private String doctorName;
	// 随访计划标识
	private String plan;
	// 阶段序号
	private Integer seq;
	// 类型:1定时,2不定时
	private Integer type;
	// 结束日期
	private Date endDate;
	// 目标
	private String target;
	// 执行状态:-1暂停,0未开始,1进行中,2已结束
	private Integer status;
	// 添加时间
	private Date czrq;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getDoctor() {
		return doctor;
	}
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}
	@Column(name = "doctor_name")
	public String getDoctorName() {
		return doctorName;
	}
	public void setDoctorName(String doctorName) {
		this.doctorName = doctorName;
	}
	public String getPlan() {
		return plan;
	}
	public void setPlan(String plan) {
		this.plan = plan;
	}
	public Integer getSeq() {
		return seq;
	}
	public void setSeq(Integer seq) {
		this.seq = seq;
	}
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	@Column(name = "end_date")
	public Date getEndDate() {
		return endDate;
	}
	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}
	public String getTarget() {
		return target;
	}
	public void setTarget(String target) {
		this.target = target;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
}

+ 0 - 187
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpPlanStageItem.java

@ -1,187 +0,0 @@
package com.yihu.wlyy.entity.follow;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
/**
 * 随访计划随访阶段随访项
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_followup_plan_stage_item")
public class FollowUpPlanStageItem extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1437387574146491933L;
	// 随访项标识
	private String code;
	// 随访计划标识
	private String plan;
	// 随访计划阶段标识
	private String stage;
	// 随访项类型:1问卷,2体测
	private Integer type;
	// 标题
	private String title;
	// 推送类型:1按时间,2按次数
	private Integer pushType;
	// 推送次数
	private Integer pushTimes;
	// 推送周期
	private Integer pushCycle;
	// 推送周期单位:1天,2周,3月
	private Integer pushCycleUnit;
	// 下一次推送日期
	private Date nextPushDate;
	// 推送开始日期
	private Date pushBegin;
	// 推送结束日期
	private Date pushEnd;
	// 已推送次数
	private Integer times;
	// 执行状态:-1暂停,0未开始,1进行中,2已结束
	private Integer status;
	// 添加时间
	private Date czrq;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getPlan() {
		return plan;
	}
	public void setPlan(String plan) {
		this.plan = plan;
	}
	public String getStage() {
		return stage;
	}
	public void setStage(String stage) {
		this.stage = stage;
	}
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	@Column(name = "push_type")
	public Integer getPushType() {
		return pushType;
	}
	public void setPushType(Integer pushType) {
		this.pushType = pushType;
	}
	@Column(name = "push_times")
	public Integer getPushTimes() {
		return pushTimes;
	}
	public void setPushTimes(Integer pushTimes) {
		this.pushTimes = pushTimes;
	}
	@Column(name = "push_cycle")
	public Integer getPushCycle() {
		return pushCycle;
	}
	public void setPushCycle(Integer pushCycle) {
		this.pushCycle = pushCycle;
	}
	@Column(name = "push_cycle_unit")
	public Integer getPushCycleUnit() {
		return pushCycleUnit;
	}
	public void setPushCycleUnit(Integer pushCycleUnit) {
		this.pushCycleUnit = pushCycleUnit;
	}
	@Column(name = "next_push_date")
	public Date getNextPushDate() {
		return nextPushDate;
	}
	public void setNextPushDate(Date nextPushDate) {
		this.nextPushDate = nextPushDate;
	}
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
	@Column(name = "push_begin")
	public Date getPushBegin() {
		return pushBegin;
	}
	public void setPushBegin(Date pushBegin) {
		this.pushBegin = pushBegin;
	}
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
	@Column(name = "push_end")
	public Date getPushEnd() {
		return pushEnd;
	}
	public void setPushEnd(Date pushEnd) {
		this.pushEnd = pushEnd;
	}
	public Integer getTimes() {
		return times;
	}
	public void setTimes(Integer times) {
		this.times = times;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
}

+ 0 - 105
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpPlanStageItemQuestion.java

@ -1,105 +0,0 @@
package com.yihu.wlyy.entity.follow;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 随访计划随访阶段随访项随访问题表
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_followup_plan_stage_item_question")
public class FollowUpPlanStageItemQuestion extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 5847192233459637021L;
	// 计划标识
	private String code;
	// 随访计划标识
	private String plan;
	// 随访计划阶段标识
	private String stage;
	// 随访计划阶段随访项标识
	private String item;
	// 问题类型:1单选,2多选,3问答
	private int type;
	// 体测指标类型:1血糖,2血压,3体重,4腰围
	private int index;
	// 问题标题
	private String title;
	// 问题选项jsonarray字符串
	private String options;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getPlan() {
		return plan;
	}
	public void setPlan(String plan) {
		this.plan = plan;
	}
	public String getStage() {
		return stage;
	}
	public void setStage(String stage) {
		this.stage = stage;
	}
	public String getItem() {
		return item;
	}
	public void setItem(String item) {
		this.item = item;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	@Column(name="tc_index")
	public int getIndex() {
		return index;
	}
	public void setIndex(int index) {
		this.index = index;
	}
	public String getOptions() {
		return options;
	}
	public void setOptions(String options) {
		this.options = options;
	}
}

+ 0 - 83
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpPlanStageItemQuestionOption.java

@ -1,83 +0,0 @@
package com.yihu.wlyy.entity.follow;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 随访计划随访阶段随访项随访问题选项表
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_followup_plan_stage_item_question_option")
public class FollowUpPlanStageItemQuestionOption extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1926217205131580173L;
	
	// 计划标识
	private String code;
	// 随访计划标识
	private String plan;
	// 随访计划阶段标识
	private String stage;
	// 随访计划阶段随访项标识
	private String item;
	// 问题标识
	private String question;
	// 选项描述
	private String des;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getPlan() {
		return plan;
	}
	public void setPlan(String plan) {
		this.plan = plan;
	}
	public String getStage() {
		return stage;
	}
	public void setStage(String stage) {
		this.stage = stage;
	}
	public String getItem() {
		return item;
	}
	public void setItem(String item) {
		this.item = item;
	}
	public String getQuestion() {
		return question;
	}
	public void setQuestion(String question) {
		this.question = question;
	}
	public String getDes() {
		return des;
	}
	public void setDes(String des) {
		this.des = des;
	}
}

+ 0 - 47
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpPlanStageTarget.java

@ -1,47 +0,0 @@
package com.yihu.wlyy.entity.follow;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
/**
 * 随访计划阶段目标定义表
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_followup_plan_stage_target")
public class FollowUpPlanStageTarget extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 5640171793746829106L;
	// 目标内容
	private String content;
	// 添加时间
	private Date czrq;
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
}

+ 0 - 97
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpQuestion.java

@ -1,97 +0,0 @@
package com.yihu.wlyy.entity.follow;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
/**
 * 问卷随访问题定义表
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_followup_question")
public class FollowUpQuestion extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 5769694811442591436L;
	// 问卷随访项标识
	private String code;
	// 医生标识,0代表为系统随访项
	private String doctor;
	// 标题
	private String title;
	// 选项json串用于查询
	private String content;
	// 随访项类型:1单选,2多选,3问答
	private int type;
	// 添加时间
	private Date czrq;
	// 作废标识:1正常,0作废
	private String del;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getDoctor() {
		return doctor;
	}
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	public String getDel() {
		return del;
	}
	public void setDel(String del) {
		this.del = del;
	}
}

+ 0 - 67
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpQuestionOption.java

@ -1,67 +0,0 @@
package com.yihu.wlyy.entity.follow;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
/**
 * 问卷随访问题选项定义表
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_followup_question_option")
public class FollowUpQuestionOption extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -4964102972826887666L;
	// 随访项标识
	private String question;
	// 选项描述
	private String des;
	// 添加时间
	private Date czrq;
	// 作废标识:1正常,0作废
	private String del;
	public String getQuestion() {
		return question;
	}
	public void setQuestion(String question) {
		this.question = question;
	}
	public String getDes() {
		return des;
	}
	public void setDes(String des) {
		this.des = des;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	public String getDel() {
		return del;
	}
	public void setDel(String del) {
		this.del = del;
	}
}

+ 0 - 132
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpSummary.java

@ -1,132 +0,0 @@
package com.yihu.wlyy.entity.follow;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
/**
 * 随访总结表
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_followup_summary")
public class FollowUpSummary extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 7782474429888928914L;
	
	// 计划标识(计划总结)
	private String plan;
	// 阶段标识(阶段总结)
	private String stage;
	// 随访项标识(随访项小结)
	private String item;
	// 随访纪录
	private String record;
	// 小结类别(1、计划  2、阶段 3、随访项 4、随访纪录)
	private Integer type;
	// 控制结果
	private String result;
	// 总结内容
	private String summary;
	// 总结医生标识
	private String doctor;
	// 总结医生姓名
	private String doctorName;
	// 总结时间
	private Date czrq;
	public String getPlan() {
		return plan;
	}
	public void setPlan(String plan) {
		this.plan = plan;
	}
	public String getStage() {
		return stage;
	}
	public void setStage(String stage) {
		this.stage = stage;
	}
	public String getItem() {
		return item;
	}
	public void setItem(String item) {
		this.item = item;
	}
	public String getResult() {
		return result;
	}
	public void setResult(String result) {
		this.result = result;
	}
	public String getSummary() {
		return summary;
	}
	public void setSummary(String summary) {
		this.summary = summary;
	}
	public String getDoctor() {
		return doctor;
	}
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}
	@Column(name = "doctor_name")
	public String getDoctorName() {
		return doctorName;
	}
	public void setDoctorName(String doctorName) {
		this.doctorName = doctorName;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	
	public String getRecord() {
		return record;
	}
	
	public void setRecord(String record) {
		this.record = record;
	}
	
	@Column(name = "type",nullable=true)
	public Integer getType() {
		return type;
	}
	
	public void setType(Integer type) {
		this.type = type;
	}
}

+ 0 - 99
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpTc.java

@ -1,99 +0,0 @@
package com.yihu.wlyy.entity.follow;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
/**
 * 体测随访体测类型定义表
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_followup_tc")
public class FollowUpTc extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -8716595132524893297L;
	// 问卷随访项标识
	private String code;
	// 医生标识,0代表为系统随访项
	private String doctor;
	// 体测指标类型(1血糖,2血压,3体重,4腰围)
	private int index;
	// 标题
	private String title;
	// 选项json串用于查询
	private String content;
	// 添加时间
	private Date czrq;
	// 作废标识:1正常,0作废
	private String del;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getDoctor() {
		return doctor;
	}
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}
	@Column(name="tc_index")
	public int getIndex() {
		return index;
	}
	public void setIndex(int index) {
		this.index = index;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	public String getDel() {
		return del;
	}
	public void setDel(String del) {
		this.del = del;
	}
}

+ 0 - 67
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpTcOption.java

@ -1,67 +0,0 @@
package com.yihu.wlyy.entity.follow;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
/**
 * 体测随访体测选项定义表
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_followup_tc_option")
public class FollowUpTcOption extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -6888005765146117378L;
	
	// 体测类型标识
	private String tc;
	// 选项描述
	private String des;
	// 添加时间
	private Date czrq;
	// 作废标识:1正常,0作废
	private String del;
	public String getTc() {
		return tc;
	}
	public void setTc(String tc) {
		this.tc = tc;
	}
	public String getDes() {
		return des;
	}
	public void setDes(String des) {
		this.des = des;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	public String getDel() {
		return del;
	}
	public void setDel(String del) {
		this.del = del;
	}
}

+ 0 - 122
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpTemplate.java

@ -1,122 +0,0 @@
package com.yihu.wlyy.entity.follow;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
/**
 * 随访模板表
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_followup_template")
public class FollowUpTemplate extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -2024415185108853435L;
	// 模板标识
	private String code;
	// 医生标识,0表示系统模板
	private String doctor;
	// 随访标题
	private String title;
	// 模板类型:1问卷模板,2体测模板
	private int type;
	// 推送类型:1按时间,2按次数
	private int pushType;
	// 推送次数
	private int pushTimes;
	// 推送周期
	private int pushCycle;
	// 推送周期单位:1天,2周,3月
	private int pushCycleUnit;
	// 添加时间
	private Date czrq;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getDoctor() {
		return doctor;
	}
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	@Column(name = "push_type")
	public int getPushType() {
		return pushType;
	}
	public void setPushType(int pushType) {
		this.pushType = pushType;
	}
	@Column(name = "push_times")
	public int getPushTimes() {
		return pushTimes;
	}
	public void setPushTimes(int pushTimes) {
		this.pushTimes = pushTimes;
	}
	@Column(name = "push_cycle")
	public int getPushCycle() {
		return pushCycle;
	}
	public void setPushCycle(int pushCycle) {
		this.pushCycle = pushCycle;
	}
	@Column(name = "push_cycle_unit")
	public int getPushCycleUnit() {
		return pushCycleUnit;
	}
	public void setPushCycleUnit(int pushCycleUnit) {
		this.pushCycleUnit = pushCycleUnit;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
}

+ 0 - 77
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpTemplatePlan.java

@ -1,77 +0,0 @@
package com.yihu.wlyy.entity.follow;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
/**
 * 随访计划模板表
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_followup_template_plan")
public class FollowUpTemplatePlan extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -8066223279215991845L;
	// 计划标识
	private String code;
	// 标题/随访计划名称
	private String title;
	// 医生标识
	private String doctor;
	// 随访模板阶段内容
	private String stages;
	// 添加时间
	private Date czrq;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getDoctor() {
		return doctor;
	}
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}
	public String getStages() {
		return stages;
	}
	public void setStages(String stages) {
		this.stages = stages;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
}

+ 0 - 85
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpTemplateQuestion.java

@ -1,85 +0,0 @@
package com.yihu.wlyy.entity.follow;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 随访模板问题表
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_followup_template_question")
public class FollowUpTemplateQuestion extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -5526025233518595839L;
	// 随访项标识
	private String code;
	// 模板标识
	private String template;
	// 问题标题
	private String title;
	// 问题类型:1单选,2多选,3问答
	private int type;
	// 体测指标类型:1血糖,2血压,3体重,4腰围
	private int index;
	// 问题选项jsonarray串
	private String options;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getTemplate() {
		return template;
	}
	public void setTemplate(String template) {
		this.template = template;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	@Column(name="tc_index")
	public int getIndex() {
		return index;
	}
	public void setIndex(int index) {
		this.index = index;
	}
	public String getOptions() {
		return options;
	}
	public void setOptions(String options) {
		this.options = options;
	}
}

+ 0 - 53
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/follow/FollowUpTemplateQuestionOption.java

@ -1,53 +0,0 @@
package com.yihu.wlyy.entity.follow;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 随访模板问题选项表
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_followup_template_question_option")
public class FollowUpTemplateQuestionOption extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 7595748812881094910L;
	
	// 模板标识
	private String template;
	// 问题标题
	private String question;
	// 选项描述
	private String des;
	public String getTemplate() {
		return template;
	}
	public void setTemplate(String template) {
		this.template = template;
	}
	public String getQuestion() {
		return question;
	}
	public void setQuestion(String question) {
		this.question = question;
	}
	public String getDes() {
		return des;
	}
	public void setDes(String des) {
		this.des = des;
	}
}

+ 194 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/followup/Followup.java

@ -0,0 +1,194 @@
package com.yihu.wlyy.entity.followup;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
/**
 * 随访记录表
 * @author hzp add 2016-12-07
 *
 */
@Entity
@Table(name = "wlyy_followup")
public class Followup extends IdEntity {
	//随访编号【基卫】
	private String followupNo;
	//随访时间
	private Date followupDate;
	//计划下次随访时间
	private Date followupNextDate;
	//随访类型【字典VISIT_WAY_CODE】
	private String followupType;
	//随访类别【1.高血压 2.糖尿病】
	private String followupClass;
	//随访管理状态【字典MANAGER_STATUS】
	private String followupManagerStatus;
	//医生代码
	private String doctorCode;
	//医生姓名
	private String doctorName;
	//社区代码
	private String orgCode;
	//社区名称
	private String orgName;
	//患者代码
	private String patientCode;
	//患者姓名
	private String patientName;
	//患者身份证
	private String idcard;
	//数据来源 1基卫 2APP
	private String dataFrom;
	//状态 0取消 1已完成 2未开始 3进行中
	private String status;
	//电话随访内容
	private String followupContentPhone;
	//创建时间
	private Date createTime;
	public String getFollowupNo() {
		return followupNo;
	}
	public void setFollowupNo(String followupNo) {
		this.followupNo = followupNo;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getFollowupDate() {
		return followupDate;
	}
	public void setFollowupDate(Date followupDate) {
		this.followupDate = followupDate;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getFollowupNextDate() {
		return followupNextDate;
	}
	public void setFollowupNextDate(Date followupNextDate) {
		this.followupNextDate = followupNextDate;
	}
	public String getFollowupType() {
		return followupType;
	}
	public void setFollowupType(String followupType) {
		this.followupType = followupType;
	}
	public String getFollowupClass() {
		return followupClass;
	}
	public void setFollowupClass(String followupClass) {
		this.followupClass = followupClass;
	}
	public String getFollowupManagerStatus() {
		return followupManagerStatus;
	}
	public void setFollowupManagerStatus(String followupManagerStatus) {
		this.followupManagerStatus = followupManagerStatus;
	}
	public String getDoctorCode() {
		return doctorCode;
	}
	public void setDoctorCode(String doctorCode) {
		this.doctorCode = doctorCode;
	}
	public String getDoctorName() {
		return doctorName;
	}
	public void setDoctorName(String doctorName) {
		this.doctorName = doctorName;
	}
	public String getOrgCode() {
		return orgCode;
	}
	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}
	public String getOrgName() {
		return orgName;
	}
	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}
	public String getPatientCode() {
		return patientCode;
	}
	public void setPatientCode(String patientCode) {
		this.patientCode = patientCode;
	}
	public String getPatientName() {
		return patientName;
	}
	public void setPatientName(String patientName) {
		this.patientName = patientName;
	}
	public String getIdcard() {
		return idcard;
	}
	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}
	public String getDataFrom() {
		return dataFrom;
	}
	public void setDataFrom(String dataFrom) {
		this.dataFrom = dataFrom;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public String getFollowupContentPhone() {
		return followupContentPhone;
	}
	public void setFollowupContentPhone(String followupContentPhone) {
		this.followupContentPhone = followupContentPhone;
	}
}

+ 52 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/followup/FollowupClassDrugs.java

@ -0,0 +1,52 @@
package com.yihu.wlyy.entity.followup;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 疾病关联用药
 * @author hzp add 2016-12-07
 *
 */
@Entity
@Table(name = "wlyy_followup_class_drugs")
public class FollowupClassDrugs extends IdEntity {
	//随访类别:1.高血压 2.糖尿病
	private String followupClass;
	//药品代码
	private String drugsCode;
	//创建时间
	private Date createTime;
	public String getFollowupClass() {
		return followupClass;
	}
	public void setFollowupClass(String followupClass) {
		this.followupClass = followupClass;
	}
	public String getDrugsCode() {
		return drugsCode;
	}
	public void setDrugsCode(String drugsCode) {
		this.drugsCode = drugsCode;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
}

+ 71 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/followup/FollowupContent.java

@ -0,0 +1,71 @@
package com.yihu.wlyy.entity.followup;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 随访面访详情
 * @author hzp add 2016-12-07
 *
 */
@Entity
@Table(name = "wlyy_followup_content")
public class FollowupContent extends IdEntity {
	//随访ID
	private Long followupId;
	//随访项目【字典FOLLOWUP_PROJECT】
	private String followupProject;
	//随访项目问题
	private String followupKey;
	//随访项目回答
	private String followupValue;
	//创建时间
	private Date createTime;
	public Long getFollowupId() {
		return followupId;
	}
	public void setFollowupId(Long followupId) {
		this.followupId = followupId;
	}
	public String getFollowupProject() {
		return followupProject;
	}
	public void setFollowupProject(String followupProject) {
		this.followupProject = followupProject;
	}
	public String getFollowupKey() {
		return followupKey;
	}
	public void setFollowupKey(String followupKey) {
		this.followupKey = followupKey;
	}
	public String getFollowupValue() {
		return followupValue;
	}
	public void setFollowupValue(String followupValue) {
		this.followupValue = followupValue;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
}

+ 102 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/followup/FollowupDrugs.java

@ -0,0 +1,102 @@
package com.yihu.wlyy.entity.followup;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 随访用药记录
 * @author hzp add 2016-12-07
 *
 */
@Entity
@Table(name = "wlyy_followup_drugs")
public class FollowupDrugs extends IdEntity {
	//随访ID
	private Long followupId;
	//药品代码
	private String drugsCode;
	//药品名称
	private String drugsName;
	//药品分组(糖尿病--胰岛特殊处理)
	private String drugsGroup;
	//次剂量
	private Double dose;
	//用药单位【字典MEASURE_UNIT_DICT】
	private String unit;
	//用药频率【字典RECIPE_FREQUENCY_DICT】
	private String frequency;
	//创建时间
	private Date createTime;
	public Long getFollowupId() {
		return followupId;
	}
	public void setFollowupId(Long followupId) {
		this.followupId = followupId;
	}
	public String getDrugsCode() {
		return drugsCode;
	}
	public void setDrugsCode(String drugsCode) {
		this.drugsCode = drugsCode;
	}
	public String getDrugsName() {
		return drugsName;
	}
	public void setDrugsName(String drugsName) {
		this.drugsName = drugsName;
	}
	public String getDrugsGroup() {
		return drugsGroup;
	}
	public void setDrugsGroup(String drugsGroup) {
		this.drugsGroup = drugsGroup;
	}
	public Double getDose() {
		return dose;
	}
	public void setDose(Double dose) {
		this.dose = dose;
	}
	public String getUnit() {
		return unit;
	}
	public void setUnit(String unit) {
		this.unit = unit;
	}
	public String getFrequency() {
		return frequency;
	}
	public void setFrequency(String frequency) {
		this.frequency = frequency;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
}

+ 3 - 7
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/dict/MedicinesDao.java

@ -5,17 +5,13 @@
 *******************************************************************************/
package com.yihu.wlyy.repository.dict;
import java.util.List;
import com.yihu.wlyy.entity.dict.DmDrugsGroup;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.dict.Medicines;
public interface MedicinesDao extends PagingAndSortingRepository<Medicines, Long>, JpaSpecificationExecutor<Medicines> {
import java.util.List;
	@Query("select a from Medicines a where a.type = ?1 and a.del = '1'")
	List<Medicines> findAll(int type);
public interface DmDrugsGroupDao extends PagingAndSortingRepository<DmDrugsGroup, Long>, JpaSpecificationExecutor<DmDrugsGroup> {
}

+ 14 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/dict/DmDrugsGroupItemDao.java

@ -0,0 +1,14 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.dict;
import com.yihu.wlyy.entity.dict.DmDrugsGroupItem;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface DmDrugsGroupItemDao extends PagingAndSortingRepository<DmDrugsGroupItem, Long>, JpaSpecificationExecutor<DmDrugsGroupItem> {
}

+ 2 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpTcDao.java

@ -8,8 +8,8 @@ package com.yihu.wlyy.repository.followup;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpTc;
import com.yihu.wlyy.entity.followup.Followup;
public interface FollowUpTcDao extends PagingAndSortingRepository<FollowUpTc, Long>, JpaSpecificationExecutor<FollowUpTc> {
public interface FollowupDao extends PagingAndSortingRepository<Followup, Long>, JpaSpecificationExecutor<Followup> {
}

+ 0 - 41
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpItemRecordAnswerDao.java

@ -1,41 +0,0 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.followup;
import java.util.List;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpItemRecordAnswer;
public interface FollowUpItemRecordAnswerDao extends
		PagingAndSortingRepository<FollowUpItemRecordAnswer, Long>,
		JpaSpecificationExecutor<FollowUpItemRecordAnswer> {
	List<FollowUpItemRecordAnswer> findByItemAndRecord(String item, String record);
	@Query("select a from FollowUpItemRecordAnswer a where a.question = ?1 ")
	List<FollowUpItemRecordAnswer> getFollowUpItemRecordAnswerByQuestionCode(
			String code);
	
	List<FollowUpItemRecordAnswer> findByItemOrderByCzrqDesc(String item);
	@Query("select DISTINCT(a.question) from FollowUpItemRecordAnswer a where a.record = ?1 ")
	List<FollowUpItemRecordAnswer> findByRecordDistinQuestion(String recordCode);
	@Query("select a from FollowUpItemRecordAnswer a where a.question = ?1 and a.type= 2 and a.index= ?2")
	List<FollowUpItemRecordAnswer> getFollowUpItemRecordAnswerByQuestionCodeAndTypeAndIndex(
			String code, int type);
	@Query("select a from FollowUpItemRecordAnswer a where a.question = ?1 ")
	List<FollowUpItemRecordAnswer> findbyQuestion(String question);
	@Query("select a from FollowUpItemRecordAnswer a where a.record = ?1 and a.question=?2")
	List<FollowUpItemRecordAnswer> findByRecordCodeAndQuestion(String recoredCode,String questionCode);
}

+ 0 - 50
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpItemRecordDao.java

@ -1,50 +0,0 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.followup;
import java.util.List;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpItemRecord;
public interface FollowUpItemRecordDao extends PagingAndSortingRepository<FollowUpItemRecord, Long>, JpaSpecificationExecutor<FollowUpItemRecord> {
	/**
	 * 根据计划code查找出随访项的每个周期
	 * 
	 * @param code
	 * @return
	 */
	@Query("select a from FollowUpItemRecord a where a.plan = ?1 order by a.czrq desc")
	List<FollowUpItemRecord> findByPlanCode(String code);
	@Query("select a from FollowUpItemRecord a where a.code = ?1")
	FollowUpItemRecord getFollowUpItemRecordByCode(String recoredCode);
	List<FollowUpItemRecord> findByItemOrderByCzrqDesc(String item);
	FollowUpItemRecord findByCode(String code);
	List<FollowUpItemRecord> findByTitle(String queryParam);
	@Query("select a from FollowUpItemRecord a where  a.title=?1 order by a.czrq desc")
	List<FollowUpItemRecord> getFollowUpPlanStageItemListByTitle(String title, String userid);
	@Query("select a from FollowUpItemRecord a where a.plan = ?1  order by a.czrq desc")
	List<FollowUpItemRecord> getFollowUpPlanStageItemListByPlanCode(String planCode);
	int countByItem(String item);
	@Query("select a from FollowUpItemRecord a where a.plan = ?1 and a.type=?2 order by a.czrq desc")
	List<FollowUpItemRecord> getFollowUpPlanStageItemListByPlanCodeAndType(String planCode, String type);
	@Query("select distinct(a.item) from FollowUpItemRecord a where a.plan = ?1 and a.type=?2 order by a.czrq desc")
	List<String> findByPlanCodeAndTypeDistinctItemCode(String planCode, int type);
}

+ 0 - 43
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpItemRecordQuestionDao.java

@ -1,43 +0,0 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.followup;
import java.util.List;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpItemRecordQuestion;
public interface FollowUpItemRecordQuestionDao extends PagingAndSortingRepository<FollowUpItemRecordQuestion, Long>, JpaSpecificationExecutor<FollowUpItemRecordQuestion> {
	List<FollowUpItemRecordQuestion> findByPlanAndStageAndItemAndRecord(String plan, String stage, String item, String record);
	@Query("select a from FollowUpItemRecordQuestion a where a.record = ?1 ")
	List<FollowUpItemRecordQuestion> getFollowUpItemRecordQuestionByRecoredCode(String recoredCode);
	@Query("select a from FollowUpItemRecordQuestion a where a.item = ?3 ")
	List<FollowUpItemRecordQuestion> findByPlanAndStageAndItem(String plan, String stage, String code);
	@Query("select a from FollowUpItemRecordQuestion a where a.item = ?1 ")
	List<FollowUpItemRecordQuestion> findByPlanAndStageAndItem(String code);
	@Query("select a from FollowUpItemRecordQuestion a where a.record = ?1 ")
	List<FollowUpItemRecordQuestion> findByRecord(String recordCode);
	@Query("select distinct(a.index) from FollowUpItemRecordQuestion a where a.item = ?1 ")
	List<Integer> getByItemCodeDistinctType(String itemCode);
	@Query("select a from FollowUpItemRecordQuestion a where a.item = ?1 and a.index=?2")
	List<FollowUpItemRecordQuestion> findByItemAndType(String code, int index);
	@Query("select a from FollowUpItemRecordQuestion a where a.item = ?1")
	List<FollowUpItemRecordQuestion> findByItemCode(String itemCode);
	@Query("select a from FollowUpItemRecordQuestion a where a.code = ?1")
	FollowUpItemRecordQuestion findByCode(String question);
}

+ 0 - 30
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpItemRecordQuestionOptionDao.java

@ -1,30 +0,0 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.followup;
import java.util.List;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpItemRecordQuestionOption;
public interface FollowUpItemRecordQuestionOptionDao extends PagingAndSortingRepository<FollowUpItemRecordQuestionOption, Long>, JpaSpecificationExecutor<FollowUpItemRecordQuestionOption> {
	
	List<FollowUpItemRecordQuestionOption> findByPlanAndStageAndItemAndRecordAndQuestion(String plan,String stage,String item,String record,String question);
	@Query("select a from FollowUpItemRecordQuestionOption a where a.question = ?1 ")
	List<FollowUpItemRecordQuestionOption> getFollowUpItemRecordQuestionOptionByQuestionCode(
			String code);
	@Query("select a from FollowUpItemRecordQuestionOption a where a.code = ?1 ")
	FollowUpItemRecordQuestionOption findByCode(String option);
	@Query("select a from FollowUpItemRecordQuestionOption a where a.record = ?1 and a.question=?2")
	List<FollowUpItemRecordQuestionOption> findByRecordAndQuestion(String recoredCode,String querstionCode);
}

+ 0 - 62
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpPlanDao.java

@ -1,62 +0,0 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.followup;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpPlan;
public interface FollowUpPlanDao extends PagingAndSortingRepository<FollowUpPlan, Long>, JpaSpecificationExecutor<FollowUpPlan> {
	// 查询已结束的随访计划
	@Query("SELECT a FROM FollowUpPlan a, FollowUpPlanDoctor b WHERE a.code = b.plan AND b.doctor = ?1 AND a.status = 1")
	Page<FollowUpPlan> findByDoctorFinish(String doctor, Pageable pageRequest);
	// 查询已结束的随访计划
	@Query("SELECT a FROM FollowUpPlan a, FollowUpPlanDoctor b WHERE a.code = b.plan AND b.doctor = ?1 AND a.status = 1 AND a.id < ?2")
	Page<FollowUpPlan> findByDoctorFinish(String doctor, long id, Pageable pageRequest);
	// 查询未结束的随访计划
	@Query("SELECT a FROM FollowUpPlan a, FollowUpPlanDoctor b WHERE a.code = b.plan AND b.doctor = ?1 AND a.status <> 1")
	Page<FollowUpPlan> findByDoctor(String doctor, Pageable pageRequest);
	// 查询未结束的随访计划
	@Query("SELECT a FROM FollowUpPlan a, FollowUpPlanDoctor b WHERE a.code = b.plan AND b.doctor = ?1 AND a.status <> 1 AND a.id < ?2")
	Page<FollowUpPlan> findByDoctor(String doctor, long id, Pageable pageRequest);
	// 根据code查询随访计
	FollowUpPlan findByCode(String code);
	@Query("select a from FollowUpPlan a where a.patient=?1 and  a.id < ?2  order by a.id desc, a.czrq desc")
	Page<FollowUpPlan> getfollowupPlanListLeft(String userid, long id, Pageable pageRequest);
	@Query("select a from FollowUpPlan a where a.patient=?1  order by a.id desc, a.czrq desc")
	Page<FollowUpPlan> getfollowupPlanListLeft(String userid, Pageable pageRequest);
	@Query("select a from FollowUpPlan a where a.patient=?1 and  a.id < ?2 and  a.title like ?3 order by a.id desc, a.czrq desc")
	Page<FollowUpPlan> getfollowupPlanListLeft(String userId, long id, String title, Pageable pageRequest);
	@Query("select a from FollowUpPlan a  where a.patient=?1 and  a.title like ?2 order by a.id desc, a.czrq desc")
	Page<FollowUpPlan> getfollowupPlanListLeft(String userId, String title, Pageable pageRequest);
	@Query("select a from FollowUpPlan a  where a.patient=?1 order by  a.czrq desc")
	List<FollowUpPlan> findByPatient(String userid);
	@Modifying
	@Query("update FollowUpPlan a set a.wjAmount = a.wjAmount + 1 where a.code = ?1")
	int increaseWjAmount(String plan);
	@Modifying
	@Query("update FollowUpPlan a set a.tcAmount = a.tcAmount + 1 where a.code = ?1")
	int increaseTcAmount(String plan);
}

+ 0 - 21
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpPlanRemindDao.java

@ -1,21 +0,0 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.followup;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpPlanRemind;
public interface FollowUpPlanRemindDao extends PagingAndSortingRepository<FollowUpPlanRemind, Long>, JpaSpecificationExecutor<FollowUpPlanRemind> {
	@Modifying
	@Query("update FollowUpPlanRemind a set a.read = 0 where a.id = ?1")
	int updateRead(long id);
}

+ 0 - 37
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpPlanStageDao.java

@ -1,37 +0,0 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.followup;
import java.util.List;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpPlanStage;
public interface FollowUpPlanStageDao extends PagingAndSortingRepository<FollowUpPlanStage, Long>, JpaSpecificationExecutor<FollowUpPlanStage> {
	/**
	 * 根据计划code查询阶段
	 * @param code
	 * @return
	 */
	@Query("select a from FollowUpPlanStage a where a.plan = ?1 order by a.czrq desc")
	List<FollowUpPlanStage> findByPlanCode(String code);
	List<FollowUpPlanStage> findByPlan(String plan);
	FollowUpPlanStage findByCode(String code);
	@Modifying
	@Query("update FollowUpPlanStage a set a.status = ?1 where a.plan = ?2")
	int updateStatusByPlan(int status, String plan);
	
	@Query("select a from FollowUpPlanStage a where a.plan = ?1 and a.seq = ?2")
	FollowUpPlanStage findNextStage(String plan, int seq);
}

+ 0 - 54
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpPlanStageItemDao.java

@ -1,54 +0,0 @@
package com.yihu.wlyy.repository.followup;
import java.util.Date;
import java.util.List;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpPlanStageItem;
public interface FollowUpPlanStageItemDao extends PagingAndSortingRepository<FollowUpPlanStageItem, Long>, JpaSpecificationExecutor<FollowUpPlanStageItem> {
	List<FollowUpPlanStageItem> findByPlanAndStage(String plan, String stage);
	FollowUpPlanStageItem findByCode(String code);
	/**
	 * 根据计划code查找出随访计划
	 * 
	 * @param code
	 * @return
	 */
	@Query("select a from FollowUpPlanStageItem a where a.plan = ?1 order by a.czrq desc")
	List<FollowUpPlanStageItem> findByPlanCode(String code);
	
	@Query("select a from FollowUpPlanStageItem a where a.stage = ?1")
	List<FollowUpPlanStageItem> findByStage(String stage);
	// 查询未结束的且到推送日期的随访项
	@Query("select a from FollowUpPlanStageItem a where a.nextPushDate = ?1 and a.status = 1")
	List<FollowUpPlanStageItem> findByNextPushDate(Date nextPushDate);
	
	@Modifying
	@Query("update FollowUpPlanStageItem a set a.status = ?1 where a.plan = ?2")
	int updateStatusByPlan(int status, String plan);
	
	@Modifying
	@Query("update FollowUpPlanStageItem a set a.status = ?1 where a.stage = ?2")
	int updateStatusByStage(int status, String stage);
	
	//查询阶段下是否还有未结束的随访项
	@Query("select count(1) from FollowUpPlanStageItem a where a.stage = ?1 and a.code <> ?2 and a.status <> 2")
	int hasOtherUnfinish(String stage, String item);
	@Query("select a from FollowUpPlanStageItem a where a.plan = ?1 and a.status = 1")
	List<FollowUpPlanStageItem> findByPlanCodeAndType(String planCode, int index);
	@Query("select a from FollowUpPlanStageItem a where a.code = ?1 ")
	List<FollowUpPlanStageItem> findByItem(String itemCode);
}

+ 0 - 25
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpPlanStageItemQuestionDao.java

@ -1,25 +0,0 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.followup;
import java.util.List;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpPlanStageItemQuestion;
public interface FollowUpPlanStageItemQuestionDao extends PagingAndSortingRepository<FollowUpPlanStageItemQuestion, Long>, JpaSpecificationExecutor<FollowUpPlanStageItemQuestion> {
	
	List<FollowUpPlanStageItemQuestion> findByItem(String item);
	@Query("select a from FollowUpPlanStageItemQuestion a where a.item = ?1")
	List<FollowUpPlanStageItemQuestion> findByItemCode(String itemCode);
	@Query("select a from FollowUpPlanStageItemQuestion a where a.code = ?1")
	List<FollowUpPlanStageItemQuestion> findByCode(String question);
}

+ 0 - 18
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpPlanStageItemQuestionOptionDao.java

@ -1,18 +0,0 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.followup;
import java.util.List;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpPlanStageItemQuestionOption;
public interface FollowUpPlanStageItemQuestionOptionDao extends PagingAndSortingRepository<FollowUpPlanStageItemQuestionOption, Long>, JpaSpecificationExecutor<FollowUpPlanStageItemQuestionOption> {
	List<FollowUpPlanStageItemQuestionOption> findByItem(String item);
}

+ 0 - 21
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpPlanStageTargetDao.java

@ -1,21 +0,0 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.followup;
import java.util.List;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpPlanStageTarget;
public interface FollowUpPlanStageTargetDao extends PagingAndSortingRepository<FollowUpPlanStageTarget, Long>, JpaSpecificationExecutor<FollowUpPlanStageTarget> {
	@Query("select a from FollowUpPlanStageTarget a order by a.id")
	List<FollowUpPlanStageTarget> findAll();
}

+ 0 - 15
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpQuestionOptionDao.java

@ -1,15 +0,0 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.followup;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpQuestionOption;
public interface FollowUpQuestionOptionDao extends PagingAndSortingRepository<FollowUpQuestionOption, Long>, JpaSpecificationExecutor<FollowUpQuestionOption> {
}

+ 0 - 43
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpSummaryDao.java

@ -1,43 +0,0 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.followup;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpSummary;
public interface FollowUpSummaryDao extends PagingAndSortingRepository<FollowUpSummary, Long>, JpaSpecificationExecutor<FollowUpSummary> {
	@Query("select p from FollowUpSummary p where p.plan = ?1 and p.type=1 order by czrq desc")
	List<FollowUpSummary> findByPlanCode(String planCode);
	@Query("select p from FollowUpSummary p where p.item = ?1 and p.type=3 order by czrq desc")
	List<FollowUpSummary> findByItemCode(String code);
	FollowUpSummary findByRecordAndType(String record, int type);
	FollowUpSummary findByItemAndType(String item, int type);
	FollowUpSummary findByStageAndType(String stage, int type);
	FollowUpSummary findByPlanAndType(String plan, int type);
	@Query("select a from FollowUpSummary a where a.item=?1 and  a.id < ?2  order by  a.czrq desc")
	Page<FollowUpSummary> findByItemCode(String itemCode, long id, Pageable pageRequest);
	@Query("select a from FollowUpSummary a where a.item=?1  order by  a.czrq desc")
	Page<FollowUpSummary> findByItemCode(String itemCode, Pageable pageRequest);
	@Query("select p from FollowUpSummary p where p.plan = ?1 and ( p.type=1 or  p.type=2 )order by czrq desc")
	List<FollowUpSummary> findByPlanCodeAndType(String planCode);
}

+ 0 - 23
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpTemplateDao.java

@ -1,23 +0,0 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.followup;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpTemplate;
public interface FollowUpTemplateDao extends PagingAndSortingRepository<FollowUpTemplate, Long>, JpaSpecificationExecutor<FollowUpTemplate> {
	FollowUpTemplate findByCode(String template);
	@Modifying
	@Query("delete from FollowUpTemplate a where a.code = ?1")
	int deleteByCode(String template);
}

+ 0 - 17
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpTemplatePlanDao.java

@ -1,17 +0,0 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.followup;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpTemplatePlan;
public interface FollowUpTemplatePlanDao extends PagingAndSortingRepository<FollowUpTemplatePlan, Long>, JpaSpecificationExecutor<FollowUpTemplatePlan> {
	FollowUpTemplatePlan findByCode(String template);
}

+ 0 - 25
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpTemplateQuestionDao.java

@ -1,25 +0,0 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.followup;
import java.util.List;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpTemplateQuestion;
public interface FollowUpTemplateQuestionDao extends PagingAndSortingRepository<FollowUpTemplateQuestion, Long>, JpaSpecificationExecutor<FollowUpTemplateQuestion> {
	List<FollowUpTemplateQuestion> findByTemplate(String template);
	
	@Modifying
	@Query("delete from FollowUpTemplateQuestion a where a.template = ?1")
	int deleteByTemplate(String template);
}

+ 0 - 19
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpTemplateQuestionOptionDao.java

@ -1,19 +0,0 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.followup;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpTemplateQuestionOption;
public interface FollowUpTemplateQuestionOptionDao extends PagingAndSortingRepository<FollowUpTemplateQuestionOption, Long>, JpaSpecificationExecutor<FollowUpTemplateQuestionOption> {
	@Modifying
	@Query("delete from FollowUpTemplateQuestionOption a where a.template = ?1")
	int deleteByTemplate(String template);
}

+ 2 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpPlanDoctorDao.java

@ -5,11 +5,10 @@
 *******************************************************************************/
package com.yihu.wlyy.repository.followup;
import com.yihu.wlyy.entity.followup.FollowupClassDrugs;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpPlanDoctor;
public interface FollowUpPlanDoctorDao extends PagingAndSortingRepository<FollowUpPlanDoctor, Long>, JpaSpecificationExecutor<FollowUpPlanDoctor> {
public interface FollowupClassDrugsDao extends PagingAndSortingRepository<FollowupClassDrugs, Long>, JpaSpecificationExecutor<FollowupClassDrugs> {
}

+ 2 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpQuestionDao.java

@ -5,11 +5,10 @@
 *******************************************************************************/
package com.yihu.wlyy.repository.followup;
import com.yihu.wlyy.entity.followup.FollowupContent;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpQuestion;
public interface FollowUpQuestionDao extends PagingAndSortingRepository<FollowUpQuestion, Long>, JpaSpecificationExecutor<FollowUpQuestion> {
public interface FollowupContentDao extends PagingAndSortingRepository<FollowupContent, Long>, JpaSpecificationExecutor<FollowupContent> {
}

+ 2 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpTcOptionDao.java

@ -5,11 +5,10 @@
 *******************************************************************************/
package com.yihu.wlyy.repository.followup;
import com.yihu.wlyy.entity.followup.FollowupDrugs;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.follow.FollowUpTcOption;
public interface FollowUpTcOptionDao extends PagingAndSortingRepository<FollowUpTcOption, Long>, JpaSpecificationExecutor<FollowUpTcOption> {
public interface FollowupDrugsDao extends PagingAndSortingRepository<FollowupDrugs, Long>, JpaSpecificationExecutor<FollowupDrugs> {
}

+ 0 - 612
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpExecutionService.java

@ -1,612 +0,0 @@
package com.yihu.wlyy.service.app.followup;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.transaction.Transactional;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.yihu.wlyy.entity.follow.FollowUpItemRecord;
import com.yihu.wlyy.entity.follow.FollowUpItemRecordAnswer;
import com.yihu.wlyy.entity.follow.FollowUpPlan;
import com.yihu.wlyy.entity.follow.FollowUpPlanStage;
import com.yihu.wlyy.entity.follow.FollowUpPlanStageItem;
import com.yihu.wlyy.entity.follow.FollowUpPlanStageItemQuestion;
import com.yihu.wlyy.entity.follow.FollowUpPlanStageItemQuestionOption;
import com.yihu.wlyy.entity.follow.FollowUpSummary;
import com.yihu.wlyy.repository.followup.FollowUpItemRecordAnswerDao;
import com.yihu.wlyy.repository.followup.FollowUpItemRecordDao;
import com.yihu.wlyy.repository.followup.FollowUpPlanDao;
import com.yihu.wlyy.repository.followup.FollowUpPlanStageDao;
import com.yihu.wlyy.repository.followup.FollowUpPlanStageItemDao;
import com.yihu.wlyy.repository.followup.FollowUpPlanStageItemQuestionDao;
import com.yihu.wlyy.repository.followup.FollowUpPlanStageItemQuestionOptionDao;
import com.yihu.wlyy.repository.followup.FollowUpSummaryDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
/**
 * 随访计划执行情况
 * 
 * @author lyr
 * 
 */
@Component
@Transactional(rollbackOn = Exception.class)
public class FollowUpExecutionService extends BaseService {
	@Autowired
	private FollowUpPlanDao planDao;
	@Autowired
	private FollowUpPlanStageDao planStageDao;
	@Autowired
	private FollowUpPlanStageItemDao planStageItemDao;
	@Autowired
	private FollowUpPlanStageItemQuestionDao questionDao;
	@Autowired
	private FollowUpPlanStageItemQuestionOptionDao questionOptionDao;
	@Autowired
	private FollowUpItemRecordDao recordDao;
	@Autowired
	private FollowUpItemRecordAnswerDao reocrdAnswerDao;
	@Autowired
	private FollowUpSummaryDao summaryDao;
	/**
	 * 随访计划执行情况
	 * 
	 * @param plan String 计划标识
	 * @return
	 */
	public JSONObject getPlanDetails(String plan) {
		// 随访计划
		FollowUpPlan followUpPlan = planDao.findByCode(plan);
		// 随访计划阶段
		List<FollowUpPlanStage> stages = planStageDao.findByPlan(plan);
		// 随访计划随访项
		List<FollowUpPlanStageItem> items = planStageItemDao.findByPlanCode(plan);
		// 阶段随访项对应
		Map<String, List<FollowUpPlanStageItem>> stageItems = new HashMap<String, List<FollowUpPlanStageItem>>();
		// 随访计划
		JSONObject planJson = new JSONObject(followUpPlan);
		// 计划下阶段数组
		JSONArray stageArray = new JSONArray();
		if (stages != null) {
			if (items != null) {
				for (FollowUpPlanStageItem item : items) {
					if (stageItems.containsKey(item.getStage())) {
						stageItems.get(item.getStage()).add(item);
					} else {
						List<FollowUpPlanStageItem> itemList = new ArrayList<FollowUpPlanStageItem>();
						itemList.add(item);
						stageItems.put(item.getStage(), itemList);
					}
				}
			}
			for (FollowUpPlanStage stage : stages) {
				// 随访计划阶段
				JSONObject stageJson = new JSONObject(stage);
				if (stageItems.containsKey(stage.getCode())) {
					stageJson.put("items", stageItems.get(stage.getCode()));
				} else {
					List<FollowUpPlanStageItem> itemList = new ArrayList<FollowUpPlanStageItem>();
					stageJson.put("items", itemList);
				}
				stageArray.put(stageJson);
			}
		}
		planJson.put("stages", stageArray);
		return planJson;
	}
	/**
	 * 随访计划调查情况
	 * 
	 * @param item String 随访项标识
	 * @return
	 */
	public JSONArray getItemInvestigation(String item) {
		List<FollowUpPlanStageItemQuestion> questions = questionDao.findByItem(item);
		List<FollowUpPlanStageItemQuestionOption> options = questionOptionDao.findByItem(item);
		List<FollowUpItemRecordAnswer> answers = reocrdAnswerDao.findByItemOrderByCzrqDesc(item);
		Map<String, JSONObject> answerOptions = new HashMap<String, JSONObject>();
		Map<String, JSONArray> quesAnswers = new HashMap<String, JSONArray>();
		if (options != null) {
			for (FollowUpPlanStageItemQuestionOption option : options) {
				answerOptions.put(option.getCode(), new JSONObject(option));
			}
		}
		if (answers != null) {
			// 问题对应答案
			for (FollowUpItemRecordAnswer answer : answers) {
				JSONObject answerJson = new JSONObject(answer);
				if (answer.getOption() != null && !answer.getOption().isEmpty()) {
					if (answerOptions.containsKey(answer.getOption())) {
						answerJson.put("answerOption", answerOptions.get(answer.getOption()));
					} else {
						answerJson.put("answerOption", "");
					}
				}
				if (quesAnswers.containsKey(answer.getQuestion())) {
					quesAnswers.get(answer.getQuestion()).put(answerJson);
				} else {
					JSONArray answerList = new JSONArray();
					answerList.put(answerJson);
					quesAnswers.put(answer.getQuestion(), answerList);
				}
			}
		}
		JSONArray quesArrayJson = new JSONArray();
		if (questions != null) {
			// 生成随访项问题周期纪录回答JSON
			for (FollowUpPlanStageItemQuestion question : questions) {
				JSONObject quesJson = new JSONObject(question);
				if (quesAnswers.containsKey(question.getCode())) {
					quesJson.put("answers", quesAnswers.get(question.getCode()));
				} else {
					quesJson.put("answers", new ArrayList<FollowUpItemRecordAnswer>());
				}
				quesArrayJson.put(quesJson);
			}
		}
		return quesArrayJson;
	}
	/**
	 * 随访计划随访项调查明细
	 * 
	 * @param item String 随访项标识
	 * @return
	 */
	public JSONObject getItemInverstigationDetails(String item) {
		FollowUpPlanStageItem planStageItem = planStageItemDao.findByCode(item);
		List<FollowUpItemRecord> records = recordDao.findByItemOrderByCzrqDesc(item);
		if (planStageItem != null) {
			JSONObject itemJson = new JSONObject(planStageItem);
			if (records != null) {
				itemJson.put("records", records);
			} else {
				itemJson.put("records", new ArrayList<FollowUpItemRecord>());
			}
			return itemJson;
		}
		return new JSONObject();
	}
	/**
	 * 随访纪录作答详细
	 * 
	 * @param item String 随访项标识
	 * @param record String 随访项纪录标识
	 * @return
	 */
	public JSONObject getItemRecordAnswerDetails(String item, String record) {
		FollowUpItemRecord itemRecord = recordDao.findByCode(record);
		List<FollowUpPlanStageItemQuestion> questions = questionDao.findByItem(item);
		List<FollowUpPlanStageItemQuestionOption> options = questionOptionDao.findByItem(item);
		List<FollowUpItemRecordAnswer> answers = reocrdAnswerDao.findByItemAndRecord(item, record);
		if (itemRecord != null) {
			JSONObject itemJson = new JSONObject(itemRecord);
			FollowUpPlan followUpPlan = planDao.findByCode(itemRecord.getPlan());
			itemJson.put("patient", followUpPlan != null ? followUpPlan.getPatient() : "");
			itemJson.put("patientName", followUpPlan != null ? followUpPlan.getPatientName() : "");
			Map<String, List<FollowUpPlanStageItemQuestionOption>> optionsMap = new HashMap<String, List<FollowUpPlanStageItemQuestionOption>>();
			Map<String, List<FollowUpItemRecordAnswer>> answersMap = new HashMap<String, List<FollowUpItemRecordAnswer>>();
			if (options != null) {
				// 问题对应选项
				for (FollowUpPlanStageItemQuestionOption option : options) {
					if (optionsMap.containsKey(option.getQuestion())) {
						optionsMap.get(option.getQuestion()).add(option);
					} else {
						List<FollowUpPlanStageItemQuestionOption> optionList = new ArrayList<FollowUpPlanStageItemQuestionOption>();
						optionList.add(option);
						optionsMap.put(option.getQuestion(), optionList);
					}
				}
			}
			if (answers != null) {
				// 问题对应答案
				for (FollowUpItemRecordAnswer answer : answers) {
					if (answersMap.containsKey(answer.getQuestion())) {
						answersMap.get(answer.getQuestion()).add(answer);
					} else {
						List<FollowUpItemRecordAnswer> answerList = new ArrayList<FollowUpItemRecordAnswer>();
						answerList.add(answer);
						answersMap.put(answer.getQuestion(), answerList);
					}
				}
			}
			if (questions != null) {
				JSONArray quesArrayJson = new JSONArray();
				for (FollowUpPlanStageItemQuestion question : questions) {
					JSONObject quesJson = new JSONObject(question);
					if (optionsMap.containsKey(question.getCode())) {
						quesJson.put("options", optionsMap.get(question.getCode()));
					} else {
						quesJson.put("options", new ArrayList<FollowUpPlanStageItemQuestionOption>());
					}
					if (answersMap.containsKey(question.getCode())) {
						quesJson.put("answers", answersMap.get(question.getCode()));
					} else {
						quesJson.put("answers", new ArrayList<FollowUpItemRecordAnswer>());
					}
					quesArrayJson.put(quesJson);
				}
				itemJson.put("questions", quesArrayJson);
			}
			// 完成情况下获取总结
			if (itemRecord.getStatus() == 2) {
				FollowUpSummary summmary = summaryDao.findByRecordAndType(record, 4);
				itemJson.put("summary", new JSONObject(summmary));
			}
			return itemJson;
		}
		return new JSONObject();
	}
	/**
	 * 随访项详细
	 * 
	 * @param item String 随访项标识
	 * @return
	 */
	public JSONObject getItemDetails(String item) {
		FollowUpPlanStageItem planStageItem = planStageItemDao.findByCode(item);
		List<FollowUpPlanStageItemQuestion> questions = questionDao.findByItem(item);
		List<FollowUpPlanStageItemQuestionOption> options = questionOptionDao.findByItem(item);
		if (planStageItem != null) {
			JSONObject itemJson = new JSONObject(planStageItem);
			Map<String, List<FollowUpPlanStageItemQuestionOption>> optionsMap = new HashMap<String, List<FollowUpPlanStageItemQuestionOption>>();
			if (options != null) {
				// 问题对应选项
				for (FollowUpPlanStageItemQuestionOption option : options) {
					if (optionsMap.containsKey(option.getQuestion())) {
						optionsMap.get(option.getQuestion()).add(option);
					} else {
						List<FollowUpPlanStageItemQuestionOption> optionList = new ArrayList<FollowUpPlanStageItemQuestionOption>();
						optionList.add(option);
						optionsMap.put(option.getQuestion(), optionList);
					}
				}
			}
			if (questions != null) {
				JSONArray quesArrayJson = new JSONArray();
				for (FollowUpPlanStageItemQuestion question : questions) {
					JSONObject quesJson = new JSONObject(question);
					if (optionsMap.containsKey(question.getCode())) {
						quesJson.put("options", optionsMap.get(question.getCode()));
					} else {
						quesJson.put("options", new ArrayList<FollowUpItemRecordAnswer>());
					}
					quesArrayJson.put(quesJson);
				}
				itemJson.put("questions", quesArrayJson);
			}
			return itemJson;
		}
		return new JSONObject();
	}
	/**
	 * 随访项总结提交
	 * 
	 * @param summary FollowUpSummary 随访项总结
	 * @return
	 */
	@Transactional
	public void saveSummary(int type, int status, FollowUpSummary summary) {
		// 提交总结时状态改变
		if (type == 4) {
			FollowUpItemRecord record = recordDao.findByCode(summary.getRecord());
			record.setStatus(status);
		}
		summaryDao.save(summary);
	}
	/**
	 * 计划状态设置
	 * 
	 * @param status
	 * @param planCode
	 */
	public void setPlanStatus(int status, String planCode) {
		FollowUpPlan plan = planDao.findByCode(planCode);
		List<FollowUpPlanStage> stages = planStageDao.findByPlan(planCode);
		List<FollowUpPlanStageItem> items = planStageItemDao.findByPlanCode(planCode);
		// 计划状态修改
		plan.setStatus(status);
		// 计划下阶段状态修改
		for (FollowUpPlanStage stage : stages) {
			if (status == 2) {
				stage.setStatus(status);
			} else if (stage.getStatus() != 2 && stage.getStatus() != 0) {
				stage.setStatus(status);
			}
		}
		// 计划下随访项状态修改
		for (FollowUpPlanStageItem item : items) {
			if (status == 2) {
				item.setStatus(status);
			} else if (item.getStatus() != 2 && item.getStatus() != 0) {
				item.setStatus(status);
			}
		}
	}
	/**
	 * 阶段状态设置
	 * 
	 * @param status
	 * @param stageCode
	 */
	public void setStageStatus(int status, String stageCode) {
		FollowUpPlanStage stage = planStageDao.findByCode(stageCode);
		List<FollowUpPlanStageItem> items = planStageItemDao.findByPlanAndStage(stage.getPlan(), stageCode);
		// 阶段状态修改
		stage.setStatus(status);
		// 阶段下随访项状态修改
		for (FollowUpPlanStageItem item : items) {
			item.setStatus(status);
		}
	}
	/**
	 * 随访项状态设置
	 * 
	 * @param status
	 * @param itemCode
	 */
	public void setItemStatus(int status, String itemCode) {
		FollowUpPlanStageItem item = planStageItemDao.findByCode(itemCode);
		item.setStatus(status);
	}
	/**
	 * 随访代答
	 * 
	 * @param answers List<FollowUpItemRecordAnswer> 随访答案
	 * @throws Exception 
	 */
	public void saveRecordAnswers(List<FollowUpItemRecordAnswer> answers) throws Exception {
		reocrdAnswerDao.save(answers);
		if (answers.size() > 0) {
			FollowUpItemRecord record = recordDao.findByCode(answers.get(0).getRecord());
			if (record != null) {
				FollowUpPlan plan = planDao.findByCode(record.getPlan());
				if (record.getType() == 1) {
					record.setStatus(1);
					plan.setWjFinishAmount(plan.getWjFinishAmount() + 1);
				} else {
					// 得到当前问卷的答案数
					List<FollowUpItemRecordAnswer> answerList = reocrdAnswerDao.findByRecordDistinQuestion(record.getCode());
					// 得到当前问卷的问题数目
					List<FollowUpPlanStageItemQuestion> questions = questionDao.findByItem(record.getItem());
					if (answerList != null && questions != null) {
						if (questions.size() == answerList.size()) {
							record.setStatus(1);
							plan.setTcAmount(plan.getTcFinishAmount() + 1);
						}
					}
				}
			} else {
				throw new Exception("找不到对应随访周期记录!");
			}
		}
	}
	/**
	 * 随访频率变更
	 * 
	 * @param item String 随访项标识
	 * @param frequency JSONObject 频率
	 * @throws Exception 
	 */
	public void changeItemFrequency(String item, JSONObject frequency) throws Exception {
		FollowUpPlanStageItem planStageItem = planStageItemDao.findByCode(item);
		// 设置随访周期、开始时间、周期单位
		planStageItem.setPushBegin(DateUtil.strToDateShort(frequency.getString("pushBegin")));
		planStageItem.setPushCycle(frequency.getInt("pushCycle"));
		planStageItem.setPushCycleUnit(frequency.getInt("pushCycleUnit"));
		Calendar today = Calendar.getInstance();
		if (frequency.getInt("pushType") == 1) {
			planStageItem.setPushEnd(DateUtil.strToDateShort(frequency.getString("pushEnd")));
			Calendar cld = Calendar.getInstance();
			cld.setTime(planStageItem.getPushBegin());
			int unit = Calendar.DATE;
			if (planStageItem.getPushCycleUnit() == 2) {
				unit = Calendar.WEEK_OF_MONTH;
			} else if (planStageItem.getPushCycleUnit() == 3) {
				unit = Calendar.MONTH;
			}
			while (cld.before(planStageItem.getNextPushDate())) {
				cld.add(unit, planStageItem.getPushCycle());
			}
			if (cld.after(planStageItem.getPushEnd())) {
				cld.setTime(planStageItem.getPushEnd());
			}
			if (cld.get(Calendar.YEAR) == today.get(Calendar.YEAR) && cld.get(Calendar.MONTH) == today.get(Calendar.MONTH) && cld.get(Calendar.DATE) == today.get(Calendar.DATE)) {
				cld.add(Calendar.DATE, 1);
			}
			planStageItem.setNextPushDate(cld.getTime());
		} else {
			// 下次执行时间调整
			planStageItem.setPushTimes(frequency.getInt("pushTimes"));
			int executeFinish = recordDao.countByItem(item);
			int executeLeft = planStageItem.getPushTimes() - executeFinish;
			if (executeLeft > 0) {
				Calendar cld = Calendar.getInstance();
				cld.setTime(planStageItem.getPushBegin());
				switch (planStageItem.getPushCycleUnit()) {
				case 1:
					cld.add(Calendar.DATE, executeFinish * planStageItem.getPushCycle());
					break;
				case 2:
					cld.add(Calendar.WEEK_OF_MONTH, executeFinish * planStageItem.getPushCycle());
					break;
				case 3:
					cld.add(Calendar.MONTH, executeFinish * planStageItem.getPushCycle());
					break;
				default:
					break;
				}
				if (cld.get(Calendar.YEAR) == today.get(Calendar.YEAR) && cld.get(Calendar.MONTH) == today.get(Calendar.MONTH) && cld.get(Calendar.DATE) == today.get(Calendar.DATE)) {
					cld.add(Calendar.DATE, 1);
				}
				planStageItem.setNextPushDate(cld.getTime());
			}
		}
	}
	/**
	 * 随访计划编辑
	 * 
	 * @param stages 阶段
	 * @param items 随访项
	 * @param questions 问题
	 * @param options 问题选项
	 */
	public void editPlan(List<FollowUpPlanStage> stages, List<FollowUpPlanStageItem> items, List<FollowUpPlanStageItemQuestion> questions, List<FollowUpPlanStageItemQuestionOption> options) {
		if (stages.size() > 0) {
			planStageDao.save(stages);
		}
		if (items.size() > 0) {
			planStageItemDao.save(items);
		}
		if (questions.size() > 0) {
			questionDao.save(questions);
		}
		if (options.size() > 0) {
			questionOptionDao.save(options);
		}
	}
	/**
	 * 总结获取
	 * 
	 * @param type String 总结类别
	 * @param summary 对应总结标识
	 * @return
	 */
	public JSONObject getSummary(int type, String summary) {
		FollowUpSummary summaryEntity = new FollowUpSummary();
		// 根据总结类型获取对应的总结数据
		switch (type) {
		case 1:
			summaryEntity = summaryDao.findByPlanAndType(summary, type);
			break;
		case 2:
			summaryEntity = summaryDao.findByStageAndType(summary, type);
			break;
		case 3:
			summaryEntity = summaryDao.findByItemAndType(summary, type);
			break;
		case 4:
			summaryEntity = summaryDao.findByRecordAndType(summary, type);
			break;
		default:
			break;
		}
		return summaryEntity != null ? new JSONObject(summaryEntity) : new JSONObject();
	}
	/**
	 * 阶段编辑
	 * 
	 * @param stage
	 * @param stageJson
	 * @throws Exception 
	 */
	public void editStage(String stage, JSONObject stageJson) throws Exception {
		FollowUpPlanStage planStage = planStageDao.findByCode(stage);
		if (planStage != null) {
			// 阶段周期变更
			planStage.setType(stageJson.getInt("type"));
			planStage.setEndDate(DateUtil.strToDateShort(stageJson.getString("endDate")));
			planStage.setTarget(stageJson.getString("target"));
		} else {
			throw new Exception("未找到对应阶段!");
		}
	}
}

+ 0 - 106
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpPlanRemindService.java

@ -1,106 +0,0 @@
package com.yihu.wlyy.service.app.followup;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Component;
import org.springside.modules.persistence.DynamicSpecifications;
import org.springside.modules.persistence.SearchFilter;
import org.springside.modules.persistence.SearchFilter.Operator;
import com.yihu.wlyy.entity.follow.FollowUpPlanRemind;
import com.yihu.wlyy.repository.followup.FollowUpPlanRemindDao;
import com.yihu.wlyy.service.BaseService;
/**
 * 随访提醒业务处理类型
 * @author George
 *
 */
@Component
@Transactional(rollbackOn = Exception.class)
public class FollowUpPlanRemindService extends BaseService {
	@Autowired
	private FollowUpPlanRemindDao followUpPlanRemindDao;
	/**
	 * 添加随访提醒
	 * @param patient 患者标识
	 * @param doctor 医生标识
	 * @param doctorName 医生姓名
	 * @param plan 随访计划标识
	 * @param content 提醒内容
	 * @return
	 */
	public FollowUpPlanRemind add(String patient, String doctor, String doctorName, String plan, String content) {
		FollowUpPlanRemind remind = new FollowUpPlanRemind();
		remind.setContent(content);
		remind.setCzrq(new Date());
		remind.setDoctor(doctor);
		remind.setDoctorName(doctorName);
		remind.setPatient(patient);
		remind.setPlan(plan);
		remind.setRead(1);
		return followUpPlanRemindDao.save(remind);
	}
	/**
	 * 更新为已读
	 * @param id
	 * @return
	 */
	public int read(long id) {
		return followUpPlanRemindDao.updateRead(id);
	}
	/**
	 * 根据id查询随访提醒
	 * @param id
	 * @return
	 */
	public FollowUpPlanRemind findById(long id) {
		FollowUpPlanRemind remind = followUpPlanRemindDao.findOne(id);
		// 更新为已读
		if (remind.getRead() == 1) {
			remind.setRead(0);
			followUpPlanRemindDao.save(remind);
		}
		return remind;
	}
	/**
	 * 查询患者的随访提醒列表
	 * @param patient
	 * @param id
	 * @param pagesize
	 * @return
	 */
	public Page<FollowUpPlanRemind> findByPatient(String patient, long id, int pagesize) {
		if (pagesize <= 0) {
			pagesize = 10;
		}
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(0, pagesize, sort);
		// 设置查询条件
		Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
		filters.put("patient", new SearchFilter("patient", Operator.EQ, patient));
		if (id > 0) {
			filters.put("id", new SearchFilter("id", Operator.LT, id));
		}
		Specification<FollowUpPlanRemind> spec = DynamicSpecifications.bySearchFilter(filters.values(), FollowUpPlanRemind.class);
		return followUpPlanRemindDao.findAll(spec, pageRequest);
	}
}

+ 64 - 300
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java

@ -1,59 +1,20 @@
package com.yihu.wlyy.service.app.followup;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Component;
import org.springside.modules.persistence.DynamicSpecifications;
import org.springside.modules.persistence.SearchFilter;
import org.springside.modules.persistence.SearchFilter.Operator;
import com.yihu.wlyy.entity.follow.FollowUpItemRecord;
import com.yihu.wlyy.entity.follow.FollowUpItemRecordQuestion;
import com.yihu.wlyy.entity.follow.FollowUpItemRecordQuestionOption;
import com.yihu.wlyy.entity.follow.FollowUpPlan;
import com.yihu.wlyy.entity.follow.FollowUpPlanDoctor;
import com.yihu.wlyy.entity.follow.FollowUpPlanStage;
import com.yihu.wlyy.entity.follow.FollowUpPlanStageItem;
import com.yihu.wlyy.entity.follow.FollowUpPlanStageItemQuestion;
import com.yihu.wlyy.entity.follow.FollowUpPlanStageItemQuestionOption;
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.repository.followup.FollowUpItemRecordDao;
import com.yihu.wlyy.repository.followup.FollowUpItemRecordQuestionDao;
import com.yihu.wlyy.repository.followup.FollowUpItemRecordQuestionOptionDao;
import com.yihu.wlyy.repository.followup.FollowUpPlanDao;
import com.yihu.wlyy.repository.followup.FollowUpPlanDoctorDao;
import com.yihu.wlyy.repository.followup.FollowUpPlanStageDao;
import com.yihu.wlyy.repository.followup.FollowUpPlanStageItemDao;
import com.yihu.wlyy.repository.followup.FollowUpPlanStageItemQuestionDao;
import com.yihu.wlyy.repository.followup.FollowUpPlanStageItemQuestionOptionDao;
import com.yihu.wlyy.repository.followup.FollowUpPlanStageTargetDao;
import com.yihu.wlyy.repository.followup.FollowUpQuestionDao;
import com.yihu.wlyy.repository.followup.FollowUpTcDao;
import com.yihu.wlyy.repository.followup.FollowUpTemplateDao;
import com.yihu.wlyy.repository.followup.FollowUpTemplatePlanDao;
import com.yihu.wlyy.repository.followup.FollowUpTemplateQuestionDao;
import com.yihu.wlyy.repository.followup.FollowUpTemplateQuestionOptionDao;
import com.yihu.wlyy.repository.followup.FollowupDao;
import com.yihu.wlyy.service.BaseService;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * 随访干预业务处理类型
 * @author George
 * 随访服务
 * @author hzp add 2016-12-07
 *
 */
@Component
@ -61,307 +22,110 @@ import com.yihu.wlyy.service.BaseService;
public class FollowUpService extends BaseService {
	@Autowired
	private FollowUpPlanDao followUpPlanDao;
	@Autowired
	private FollowUpPlanStageDao followUpPlanStageDao;
	@Autowired
	private FollowUpTemplatePlanDao followUpTemplatePlanDao;
	@Autowired
	private FollowUpTemplateDao followUpTemplateDao;
	@Autowired
	private FollowUpTemplateQuestionDao followUpTemplateQuestionDao;
	@Autowired
	private FollowUpTemplateQuestionOptionDao followUpTemplateQuestionOptionDao;
	@Autowired
	private FollowUpPlanStageTargetDao followUpPlanStageTargetDao;
	@Autowired
	private FollowUpTcDao followUpTcDao;
	@Autowired
	private FollowUpQuestionDao followUpQuestionDao;
	@Autowired
	private FollowUpPlanDoctorDao followUpPlanDoctorDao;
	@Autowired
	private FollowUpPlanStageItemDao followUpPlanStageItemDao;
	@Autowired
	private FollowUpPlanStageItemQuestionDao followUpPlanStageItemQuestionDao;
	@Autowired
	private FollowUpPlanStageItemQuestionOptionDao followUpPlanStageItemQuestionOptionDao;
	@Autowired
	private FollowUpItemRecordDao followUpItemRecordDao;
	@Autowired
	private FollowUpItemRecordQuestionDao followUpItemRecordQuestionDao;
	@Autowired
	private FollowUpItemRecordQuestionOptionDao followUpItemRecordQuestionOptionDao;
	private FollowupDao followUpPlanDao;
	/**
	 * 查询与医生相关的随访计划
	 * @param doctor 医生标识
	 * @param type 查询类型:1已发起,2已结束
	 * @param id
	 * @param pagesize 分页大小
	 * @return
	 */
	public Page<FollowUpPlan> findPlanByDoctor(String doctor, int type, long id, int pagesize) {
		if (pagesize <= 0) {
			pagesize = 10;
		}
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(0, pagesize, sort);
		switch (type) {
		case 1:
			// 已发起
			if (id > 0) {
				return followUpPlanDao.findByDoctor(doctor, id, pageRequest);
			} else {
				return followUpPlanDao.findByDoctor(doctor, pageRequest);
			}
		case 2:
			// 已线束
			if (id > 0) {
				return followUpPlanDao.findByDoctorFinish(doctor, id, pageRequest);
			} else {
				return followUpPlanDao.findByDoctorFinish(doctor, pageRequest);
			}
		}
		return null;
	}
	 * 获取医生随访列表
     */
	public List<Map<String,String>> getListByDoctor(String doctorCode,String startTime,String endTime,String page,String pageSize) throws Exception
	{
		List<Map<String,String>> re = new ArrayList<>();
	/**
	 * 查询医生随访计划模板
	 * @param doctor 医生标识
	 * @param id
	 * @param pagesize
	 * @return
	 */
	public Page<FollowUpTemplatePlan> findPlanTemplateByDoctor(String doctor, long id, int pagesize) {
		if (pagesize <= 0) {
			pagesize = 10;
		}
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(0, pagesize, sort);
		// 设置查询条件
		Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
		// 指定医生
		filters.put("doctor", new SearchFilter("doctor", Operator.EQ, doctor));
		if (id > 0) {
			filters.put("id", new SearchFilter("id", Operator.LT, id));
		}
		Specification<FollowUpTemplatePlan> spec = DynamicSpecifications.bySearchFilter(filters.values(), FollowUpTemplatePlan.class);
		return followUpTemplatePlanDao.findAll(spec, pageRequest);
		return re;
	}
	/**
	 * 查询医生的随访模板
	 * @param doctor 医生标识
	 * @param kind 查询类型:0全部模板,1系统模板,2自定义模板
	 * @param type 模板类型:0全部类型,1问卷模板,2体测模板
	 * @param id
	 * @param pagesize 分页大小
	 * @return
	 *新增随访计划(简单)
	 */
	public Page<FollowUpTemplate> findTemplateByDoctor(String doctor, int kind, int type, long id, int pagesize) {
		if (pagesize <= 0) {
			pagesize = 10;
		}
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(0, pagesize, sort);
		// 设置查询条件
		Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
		if (kind == 1) {
			// 查询系统模板
			filters.put("doctor", new SearchFilter("doctor", Operator.EQ, "0"));
		} else if (kind == 2) {
			// 查询医生自定义模板
			filters.put("doctor", new SearchFilter("doctor", Operator.EQ, doctor));
		}
		if (type == 1 || type == 2) {
			// 模板类型过滤
			filters.put("doctor", new SearchFilter("type", Operator.EQ, type));
		}
		if (id > 0) {
			filters.put("id", new SearchFilter("id", Operator.LT, id));
		}
		Specification<FollowUpTemplate> spec = DynamicSpecifications.bySearchFilter(filters.values(), FollowUpTemplate.class);
		return followUpTemplateDao.findAll(spec, pageRequest);
	}
	public void addFollowupPlan(String doctorCode,String patientCode,String date) throws Exception {
	/**
	 * 阶段目标列表查询
	 * @return
	 */
	public List<FollowUpPlanStageTarget> findTargetList() {
		return followUpPlanStageTargetDao.findAll();
	}
	/**
	 * 查询体测题目列表
	 * @param doctor 医生标识
	 * @param type 查询类型:0全部,1系统,2自定义
	 * @param id
	 * @param pagesize 分页大小
	 * @return
	 *开始随访记录
	 */
	public Page<FollowUpTc> findTcList(String doctor, int type, long id, int pagesize) {
		if (pagesize <= 0) {
			pagesize = 10;
		}
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(0, pagesize, sort);
		// 设置查询条件
		Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
		if (type == 1) {
			// 查询系统问题
			filters.put("doctor", new SearchFilter("doctor", Operator.EQ, "0"));
		} else if (type == 2) {
			// 查询医生自定义问题
			filters.put("doctor", new SearchFilter("doctor", Operator.EQ, doctor));
		}
		if (id > 0) {
			filters.put("id", new SearchFilter("id", Operator.LT, id));
		}
		Specification<FollowUpTc> spec = DynamicSpecifications.bySearchFilter(filters.values(), FollowUpTc.class);
		return followUpTcDao.findAll(spec, pageRequest);
	}
	public void startFollowup(String id,String date,String followupType,String followupClass,String followupManagerStatus) throws Exception {
	/**
	 * 查询问卷题目列表
	 * @param doctor 医生标识
	 * @param type 查询类型:0全部,1系统,2自定义
	 * @param id
	 * @param pagesize 分页大小
	 * @return
	 */
	public Page<FollowUpQuestion> findQuestionList(String doctor, int type, long id, int pagesize) {
		if (pagesize <= 0) {
			pagesize = 10;
		}
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(0, pagesize, sort);
		// 设置查询条件
		Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
		if (type == 1) {
			// 查询系统问题
			filters.put("doctor", new SearchFilter("doctor", Operator.EQ, "0"));
		} else if (type == 2) {
			// 查询医生自定义问题
			filters.put("doctor", new SearchFilter("doctor", Operator.EQ, doctor));
		}
		if (id > 0) {
			filters.put("id", new SearchFilter("id", Operator.LT, id));
		}
		Specification<FollowUpQuestion> spec = DynamicSpecifications.bySearchFilter(filters.values(), FollowUpQuestion.class);
		return followUpQuestionDao.findAll(spec, pageRequest);
	}
	/**
	 * 随访模板保存
	 * @param template 模板对象
	 * @param questionList 模板问题列表
	 * @param optionsList 问题选项列表
	 *新增临时随访记录(返回ID)
	 */
	public void saveTemplate(FollowUpTemplate template, List<FollowUpTemplateQuestion> questionList, List<FollowUpTemplateQuestionOption> optionsList) {
		followUpTemplateDao.save(template);
		followUpTemplateQuestionDao.save(questionList);
		followUpTemplateQuestionOptionDao.save(optionsList);
	public String addFollowup(String doctorCode,String patientCode,String date,String followupType,String followupClass,String followupManagerStatus) throws Exception {
		String re ="";
		return re;
	}
	/**
	 * 查询随访计划模板信息
	 * @param template
	 * @return
	 *取消随访计划
	 */
	public FollowUpTemplatePlan findPlanTemplateByCode(String template) {
		return followUpTemplatePlanDao.findByCode(template);
	public void cancelFollowupPlan(String id) throws Exception {
	}
	/*********************************** 随访详情 *******************************************************************/
	/**
	 * 添加随访计划模板
	 * @param FollowUpTemplatePlan 随访计划模板对象
	 * 获取面访项目列表
	 */
	public void addPlanTemplate(FollowUpTemplatePlan planTemplate) {
		followUpTemplatePlanDao.save(planTemplate);
	public List<Map<String,String>> getFollowupProject(String id) throws Exception
	{
		List<Map<String,String>> re = new ArrayList<>();
		return re;
	}
	/**
	 * 删除随访计划模板
	 * @param planTemplate
	 * 获取面访项目数据
	 */
	public void deletePlanTemplate(FollowUpTemplatePlan planTemplate) {
		followUpTemplatePlanDao.delete(planTemplate);
	public List<Map<String,String>> getFollowupProjectData(String id,String followupProject) throws Exception
	{
		List<Map<String,String>> re = new ArrayList<>();
		return re;
	}
	/**
	 * 添加随访计划
	 * @param planList 随访计划列表
	 * @param planDoctorList 医生相关的随访计划列表
	 * @param stageList 随访阶段列表
	 * @param stageItemList 随访项列表
	 * @param questionList 随访问题列表
	 * @param optionList 随访问题选项列表
	 * @param recordList 随访记录列表
	 * @param recordQuestionList 随访记录问题列表
	 * @param recordQuestionOptionList 随访记录问题选项列表
	 * 获取面访用药数据
	 */
	public void addPlan(List<FollowUpPlan> planList, List<FollowUpPlanDoctor> planDoctorList, List<FollowUpPlanStage> stageList, List<FollowUpPlanStageItem> stageItemList, List<FollowUpPlanStageItemQuestion> questionList, List<FollowUpPlanStageItemQuestionOption> optionList, List<FollowUpItemRecord> recordList, List<FollowUpItemRecordQuestion> recordQuestionList, List<FollowUpItemRecordQuestionOption> recordQuestionOptionList) {
		followUpPlanDao.save(planList);
		followUpPlanDoctorDao.save(planDoctorList);
		followUpPlanStageDao.save(stageList);
		followUpPlanStageItemDao.save(stageItemList);
		followUpPlanStageItemQuestionDao.save(questionList);
		followUpPlanStageItemQuestionOptionDao.save(optionList);
		followUpItemRecordDao.save(recordList);
		followUpItemRecordQuestionDao.save(recordQuestionList);
		followUpItemRecordQuestionOptionDao.save(recordQuestionOptionList);
	public List<Map<String,String>> getFollowupDrugs(String id) throws Exception
	{
		List<Map<String,String>> re = new ArrayList<>();
		return re;
	}
	/**
	 * 查询随访模板详情
	 * @param template
	 * @return
	 *保存面访项目数据
	 */
	public FollowUpTemplate findTemplateInfo(String template) {
		return followUpTemplateDao.findByCode(template);
	public void saveFollowupProjectData(String id,String followupProject,String followupProjectData) throws Exception {
	}
	/**
	 * 查询模板问题列表
	 * @param template
	 * @return
	 *保存面访用药数据
	 */
	public List<FollowUpTemplateQuestion> findTemplateQuestions(String template) {
		return followUpTemplateQuestionDao.findByTemplate(template);
	public void saveFollowupDrugs(String id,String followupProjectData,String drugsData) throws Exception {
	}
	/*********************************** 电话随访 *****************************************************************/
	/**
	 * 查询模板对象
	 * @param template
	 * @return
	 *获取电话随访内容
	 */
	public FollowUpTemplate findTemplateByCode(String template) {
		return followUpTemplateDao.findByCode(template);
	public String getFollowupPhone(String id) throws Exception {
		String re = "";
		return re;
	}
	
	/**
	 * 删除随访模板
	 * @param template
	 *记录电话随访内容
	 */
	public void deleteTemplate(String template){
		followUpTemplateDao.deleteByCode(template);
		followUpTemplateQuestionDao.deleteByTemplate(template);
		followUpTemplateQuestionOptionDao.deleteByTemplate(template);
	public void saveFollowupPhone(String id,String content) throws Exception {
	}
}

+ 0 - 29
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/medicines/MedicinesService.java

@ -1,29 +0,0 @@
package com.yihu.wlyy.service.app.medicines;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.yihu.wlyy.entity.dict.Medicines;
import com.yihu.wlyy.repository.dict.MedicinesDao;
import com.yihu.wlyy.service.BaseService;
@Component
@Transactional(rollbackFor = Exception.class)
public class MedicinesService extends BaseService {
	@Autowired
	private MedicinesDao medicinesDao;
	/**
	 * 查询所有的药品信息
	 * @param type 药品类型:1健康记录
	 * @return
	 */
	public List<Medicines> findAllMedicines(int type) {
		return medicinesDao.findAll(type);
	}
}

+ 0 - 328
patient-co-wlyy/src/main/java/com/yihu/wlyy/task/FollowUpTask.java

@ -1,328 +0,0 @@
package com.yihu.wlyy.task;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import javax.transaction.Transactional;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import com.yihu.wlyy.entity.follow.FollowUpItemRecord;
import com.yihu.wlyy.entity.follow.FollowUpItemRecordQuestion;
import com.yihu.wlyy.entity.follow.FollowUpItemRecordQuestionOption;
import com.yihu.wlyy.entity.follow.FollowUpPlan;
import com.yihu.wlyy.entity.follow.FollowUpPlanStage;
import com.yihu.wlyy.entity.follow.FollowUpPlanStageItem;
import com.yihu.wlyy.entity.follow.FollowUpPlanStageItemQuestion;
import com.yihu.wlyy.repository.followup.FollowUpItemRecordDao;
import com.yihu.wlyy.repository.followup.FollowUpItemRecordQuestionDao;
import com.yihu.wlyy.repository.followup.FollowUpItemRecordQuestionOptionDao;
import com.yihu.wlyy.repository.followup.FollowUpPlanDao;
import com.yihu.wlyy.repository.followup.FollowUpPlanStageDao;
import com.yihu.wlyy.repository.followup.FollowUpPlanStageItemDao;
import com.yihu.wlyy.repository.followup.FollowUpPlanStageItemQuestionDao;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.MessageType;
@Component("followUpTask")
@Service
@Transactional(rollbackOn = Exception.class)
public class FollowUpTask {
	private static Logger logger = LoggerFactory.getLogger(FollowUpTask.class);
	@Autowired
	private FollowUpPlanDao followUpPlanDao;
	@Autowired
	private FollowUpPlanStageDao followUpPlanStageDao;
	@Autowired
	private FollowUpPlanStageItemDao followUpPlanStageItemDao;
	@Autowired
	private FollowUpPlanStageItemQuestionDao followUpPlanStageItemQuestionDao;
	@Autowired
	private FollowUpItemRecordDao followUpItemRecordDao;
	@Autowired
	private FollowUpItemRecordQuestionDao followUpItemRecordQuestionDao;
	@Autowired
	private FollowUpItemRecordQuestionOptionDao followUpItemRecordQuestionOptionDao;
	public void push() {
		logger.info("begin push");
		List<FollowUpPlanStageItem> items = followUpPlanStageItemDao.findByNextPushDate(DateUtil.getNowDateShort());
		if (items == null) {
			return;
		}
		for (FollowUpPlanStageItem item : items) {
			if (item == null) {
				continue;
			}
			try {
				// 查询计划信息
				FollowUpPlan plan = followUpPlanDao.findByCode(item.getPlan());
				// 查询阶段信息
				FollowUpPlanStage stage = followUpPlanStageDao.findByCode(item.getStage());
				if (plan.getStatus() == -1) {
					// 计划已暂停
					continue;
				}
				if (stage.getStatus() == -1) {
					// 阶段已暂停
					continue;
				}
				// 状态反更新,防止出现数据不同步
				if (!checkStatus(plan, stage)) {
					// 状态不同步,同步状态位,不再处理该随访项
					continue;
				}
				// 判断定时阶段是否到期
				if (checkStageEndDate(plan, stage)) {
					continue;
				}
				// 推送随访记录
				doPush(plan, stage, item);
			} catch (Exception e) {
				e.printStackTrace();
				logger.error("FollowUpTask push error:", e);
			}
		}
	}
	/**
	 * 校验随访计划的状态是否同步
	 * @param plan 随访计划
	 * @param stage 随访阶段
	 * @return
	 */
	private boolean checkStatus(FollowUpPlan plan, FollowUpPlanStage stage) {
		if (plan.getStatus() == 1) {
			// 如果计划已结束,关闭所有的随访阶段和随访项
			followUpPlanStageDao.updateStatusByPlan(2, plan.getCode());
			followUpPlanStageItemDao.updateStatusByPlan(2, plan.getCode());
			return false;
		} else if (stage.getStatus() == 2) {
			// 如果随访阶段已结束,关闭所有的随访项
			followUpPlanStageItemDao.updateStatusByStage(2, stage.getCode());
			return false;
		}
		return true;
	}
	/**
	 * 判断定时随访阶段是否到期
	 * @param plan
	 * @param stage
	 * @return
	 */
	private boolean checkStageEndDate(FollowUpPlan plan, FollowUpPlanStage stage) {
		if (stage.getType() == 1 && stage.getEndDate().compareTo(DateUtil.getNowDateShort()) <= 0) {
			// 阶段定时已到,更新阶段状态为已完成
			stage.setStatus(2);
			followUpPlanStageDao.save(stage);
			// 更新阶段下随访项为已完成
			followUpPlanStageItemDao.updateStatusByStage(2, stage.getCode());
			// 查询下一计划阶段
			FollowUpPlanStage nextStage = followUpPlanStageDao.findNextStage(plan.getCode(), stage.getSeq() + 1);
			if (nextStage == null) {
				// 没有下一阶段,表示计划已完成
				plan.setStatus(1);
				followUpPlanDao.save(plan);
			} else {
				// 开启下一阶段
				nextStage.setStatus(1);
				followUpPlanStageDao.save(nextStage);
				// 查询阶段下随访项列表
				List<FollowUpPlanStageItem> itemList = followUpPlanStageItemDao.findByStage(nextStage.getCode());
				for (FollowUpPlanStageItem tempItem : itemList) {
					if (tempItem == null) {
						continue;
					}
					if (tempItem.getPushBegin().compareTo(DateUtil.getNowDateShort()) <= 0) {
						// 已到推送日期,推送随访记录
						doPush(plan, nextStage, tempItem);
					}
				}
			}
			return true;
		}
		return false;
	}
	/**
	 * 推送随访记录
	 * @param plan 随访计划
	 * @param stage 随访计划阶段
	 * @param item 随访计划阶段随访项
	 */
	private void doPush(FollowUpPlan plan, FollowUpPlanStage stage, FollowUpPlanStageItem item) {
		// 推送次数+1
		item.setTimes(item.getTimes() + 1);
		// 生成随访记录
		FollowUpItemRecord record = new FollowUpItemRecord();
		record.setCode(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());
		// 查询随访项问题列表
		List<FollowUpItemRecordQuestion> recordQuestionList = new ArrayList<FollowUpItemRecordQuestion>();
		// 随访记录问题选项列表
		List<FollowUpItemRecordQuestionOption> recordQuestionOptionList = new ArrayList<FollowUpItemRecordQuestionOption>();
		// 随访记录问题列表
		List<FollowUpPlanStageItemQuestion> questions = followUpPlanStageItemQuestionDao.findByItem(item.getCode());
		// 生成随访问题
		for (FollowUpPlanStageItemQuestion question : questions) {
			if (question == null) {
				continue;
			}
			// 新的问题
			FollowUpItemRecordQuestion recordQuestion = new FollowUpItemRecordQuestion();
			recordQuestion.setCode(question.getCode());
			recordQuestion.setIndex(question.getIndex());
			recordQuestion.setItem(item.getCode());
			recordQuestion.setPlan(plan.getCode());
			recordQuestion.setRecord(record.getCode());
			recordQuestion.setStage(stage.getCode());
			recordQuestion.setTitle(question.getTitle());
			recordQuestion.setType(question.getType());
			recordQuestionList.add(recordQuestion);
			// 新的选项
			if (StringUtils.isNotEmpty(question.getOptions())) {
				JSONArray options = new JSONArray(question.getOptions());
				for (int i = 0; i < options.length(); i++) {
					JSONObject json = options.getJSONObject(i);
					// 新的问题选项
					FollowUpItemRecordQuestionOption option = new FollowUpItemRecordQuestionOption();
					option.setCode(getCode());
					option.setDes(json.getString("des"));
					option.setItem(item.getCode());
					option.setPlan(plan.getCode());
					option.setQuestion(question.getCode());
					option.setRecord(record.getCode());
					option.setStage(stage.getCode());
					// 添加到选项列表
					recordQuestionOptionList.add(option);
				}
			}
		}
		// 计算下一次推送日期
		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(DateUtil.getNowDateShort(), days));
		} else {
			// 按月推送
			nextPushDate = DateUtil.strToDateShort(DateUtil.getNextMonth(DateUtil.getNowDateShort(), item.getPushCycle()));
		}
		// 随访项是否已完成
		boolean isFinish = false;
		if (stage.getType() == 1 && stage.getEndDate().compareTo(nextPushDate) <= 0) {
			// 下次推送已晚于阶段结束日期
			isFinish = true;
			// 设置随访项已完成
			item.setStatus(2);
			item.setNextPushDate(nextPushDate);
		} else {
			if (item.getPushType() == 1 && nextPushDate.before(item.getPushEnd())) {
				// 按时间推送且未过推送结束日期
				item.setNextPushDate(nextPushDate);
			} else if (item.getPushType() == 2 && item.getPushTimes() > item.getTimes()) {
				// 接次数推送且推送次数大于已推送次数
				item.setNextPushDate(nextPushDate);
			} else {
				isFinish = true;
				// 设置随访项已完成
				item.setStatus(2);
				item.setNextPushDate(nextPushDate);
			}
		}
		if (item.getType() == 1) {
			// 问卷随访数+1
			plan.setWjAmount(plan.getWjAmount() + 1);
			// followUpPlanDao.increaseWjAmount(plan.getCode());
		} else if (item.getType() == 2) {
			// 体测随访数+1
			plan.setTcAmount(plan.getTcAmount() + 1);
			// followUpPlanDao.increaseTcAmount(plan.getCode());
		}
		followUpPlanDao.save(plan);
		// 更新阶段对象
		followUpPlanStageItemDao.save(item);
		// 保存问题选项到数据库
		followUpItemRecordQuestionOptionDao.save(recordQuestionOptionList);
		// 保存问题到数据库
		followUpItemRecordQuestionDao.save(recordQuestionList);
		// 保存记录到数据库
		followUpItemRecordDao.save(record);
		// 发送推送消息给患者端
		PushMsgTask.getInstance().put(plan.getPatient(), MessageType.MESSAGE_TYPE_PATIENT_NEW_FOLLOW_UP.P_FU_01.name(), MessageType.MESSAGE_TYPE_PATIENT_NEW_FOLLOW_UP.随访计划.name(), MessageType.MESSAGE_TYPE_PATIENT_NEW_FOLLOW_UP.您有新的随访计划.name(), record.getCode());
		// 随访项已结束
		if (isFinish) {
			// 查询是否还有未完成的随访项
			int amount = followUpPlanStageItemDao.hasOtherUnfinish(stage.getCode(), item.getCode());
			if (amount == 0) {
				// 全部随访项已完成,更新随访阶段状态为已完成
				stage.setStatus(2);
				followUpPlanStageDao.save(stage);
				// 查询是否还有未完成的随访阶段
				FollowUpPlanStage nextStage = followUpPlanStageDao.findNextStage(plan.getCode(), stage.getSeq() + 1);
				if (nextStage == null) {
					// 所有随访阶段已完成,更新随访计划为已完成
					plan.setStatus(1);
					followUpPlanDao.save(plan);
				} else {
					// 开启下一随访阶段
					nextStage.setStatus(1);
					followUpPlanStageDao.save(nextStage);
					// 查询阶段下随访项列表
					List<FollowUpPlanStageItem> itemList = followUpPlanStageItemDao.findByStage(nextStage.getCode());
					for (FollowUpPlanStageItem tempItem : itemList) {
						if (tempItem == null) {
							continue;
						}
						if (tempItem.getPushBegin().compareTo(DateUtil.getNowDateShort()) <= 0) {
							// 已到推送日期,推送随访记录
							tempItem.setStatus(1);
							doPush(plan, nextStage, tempItem);
						}
					}
				}
			}
		}
	}
	private String getCode() {
		return UUID.randomUUID().toString().replaceAll("-", "");
	}
}

+ 149 - 379
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java

@ -1,11 +1,11 @@
package com.yihu.wlyy.web.doctor.followup;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.*;
import com.yihu.wlyy.service.app.followup.FollowUpService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -14,472 +14,242 @@ 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.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.follow.FollowUpItemRecordAnswer;
import com.yihu.wlyy.entity.follow.FollowUpPlanStage;
import com.yihu.wlyy.entity.follow.FollowUpPlanStageItem;
import com.yihu.wlyy.entity.follow.FollowUpPlanStageItemQuestion;
import com.yihu.wlyy.entity.follow.FollowUpPlanStageItemQuestionOption;
import com.yihu.wlyy.entity.follow.FollowUpSummary;
import com.yihu.wlyy.service.app.followup.FollowUpExecutionService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
/**
 * 医生端:随访干预
 * 医生端:随访接口
 * 
 * @author George
 * @author hzp add 2016-12-07
 *
 */
@Controller
@RequestMapping(value = "/doctor/followup", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-随访干预")
@Api(description = "医生端-随访接口")
public class DoctorFollowUpController extends BaseController {
	@Autowired
	private FollowUpExecutionService executionService;
	@Autowired
	private DoctorService doctorService;
	private FollowUpService followUpService;
	/**
	 * 随访计划执行情况
	 * 
	 * @param planId String 计划标识
	 * @return
	 */
	@RequestMapping(value = "/plandetails")
	/*************************************** 随访计划 ****************************************************************************/
	@ApiOperation("获取随访列表")
	@RequestMapping(value = "/list", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getPlanDetails(String plan) {
	public String getList(@ApiParam(name="startTime",value="开始时间",defaultValue = "2016-12-07 00:00:00")
							  @RequestParam(value="startTime",required = true) String startTime,
							  @ApiParam(name="endTime",value="结束时间",defaultValue = "2016-12-14 00:00:00")
							  @RequestParam(value="endTime",required = true) String endTime,
						      @ApiParam(name="page",value="第几页",defaultValue = "1")
							  @RequestParam(value="page",required = true) String page,
							  @ApiParam(name="pageSize",value="每页几行",defaultValue = "10")
							  @RequestParam(value="pageSize",required = true) String pageSize) {
		try {
			return write(200, "查询成功!", "data", executionService.getPlanDetails(plan));
			List<Map<String,String>> result = followUpService.getListByDoctor(getUID(),startTime,endTime,page,pageSize);
			return write(200, "获取随访列表成功!", "data", result);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败!");
			return invalidUserException(e, -1, "获取随访列表失败!");
		}
	}
	/**
	 * 随访计划调查情况
	 * 
	 * @param item String 随访项标识
	 * @return
	 */
	@RequestMapping(value = "/investigation")
	@ApiOperation("新增随访计划(简单)")
	@RequestMapping(value = "/addFollowupPlan", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String getItemInvestigation(String item) {
	public String addFollowupPlan(@ApiParam(name="patient",value="患者代码",defaultValue = "")
						  @RequestParam(value="patient",required = true) String patient,
						  @ApiParam(name="date",value="下次随访时间",defaultValue = "2016-12-14 20:00:00")
						  @RequestParam(value="date",required = true) String date) {
		try {
			return write(200, "查询成功!", "list", executionService.getItemInvestigation(item));
			followUpService.addFollowupPlan(getUID(),patient,date);
			return write(200, "新增随访计划成功!");
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败!");
			return invalidUserException(e, -1, "新增随访计划失败!");
		}
	}
	/**
	 * 随访项调查明细
	 * 
	 * @param item String 随访项标识
	 * @return
	 */
	@RequestMapping(value = "/inverstigationdetails")
	@ApiOperation("开始随访记录")
	@RequestMapping(value = "/startFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String getItemInverstigationDetails(String item) {
	public String startFollowup(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
								 @RequestParam(value="id",required = true) String id,
								 @ApiParam(name="date",value="下次随访时间",defaultValue = "2016-12-14 20:00:00")
								 @RequestParam(value="date",required = true) String date,
								 @ApiParam(name="followupType",value="随访方式【字典VISIT_WAY_CODE】",defaultValue = "")
								 @RequestParam(value="followupType",required = true) String followupType,
								 @ApiParam(name="followupClass",value="随访方式【字典VISIT_WAY_CODE】",defaultValue = "")
								 @RequestParam(value="followupClass",required = true) String followupClass,
								 @ApiParam(name="followupManagerStatus",value="随访管理状态【字典MANAGER_STATUS】",defaultValue = "")
								 @RequestParam(value="followupManagerStatus",required = false) String followupManagerStatus) {
		try {
			return write(200, "查询成功!", "data", executionService.getItemInverstigationDetails(item));
			followUpService.startFollowup(id,date,followupType,followupClass,followupManagerStatus);
			return write(200, "新增随访计划成功!");
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败!");
			return invalidUserException(e, -1, "新增随访计划失败!");
		}
	}
	/**
	 * 随访纪录作答详细
	 * 
	 * @param item String 随访项标识
	 * @param record String 随访项纪录标识
	 * @return
	 */
	@RequestMapping(value = "/itemanswersdetails")
	@ApiOperation("新增临时随访记录(返回ID)")
	@RequestMapping(value = "/startFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String getItemRecordAnswerDetails(String item, String record) {
	public String addFollowup(
			                    @ApiParam(name="patient",value="患者代码",defaultValue = "")
								@RequestParam(value="patient",required = true) String patient,
								@ApiParam(name="date",value="下次随访时间",defaultValue = "2016-12-14 20:00:00")
								@RequestParam(value="date",required = true) String date,
								@ApiParam(name="followupType",value="随访方式【字典VISIT_WAY_CODE】",defaultValue = "")
								@RequestParam(value="followupType",required = true) String followupType,
								@ApiParam(name="followupClass",value="随访类别【1.高血压 2.糖尿病】",defaultValue = "")
								@RequestParam(value="followupClass",required = true) String followupClass,
								@ApiParam(name="followupManagerStatus",value="随访管理状态【字典MANAGER_STATUS】",defaultValue = "")
								@RequestParam(value="followupManagerStatus",required = false) String followupManagerStatus) {
		try {
			return write(200, "查询成功!", "data", executionService.getItemRecordAnswerDetails(item, record));
			String response = followUpService.addFollowup(getUID(),patient,date,followupType,followupClass,followupManagerStatus);
			return write(200, "新增临时随访记录成功!","data",response);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败!");
			return invalidUserException(e, -1, "新增临时随访记录失败!");
		}
	}
	/**
	 * 随访项详细
	 * 
	 * @param item String 随访项标识
	 * @return
	 */
	@RequestMapping(value = "/itemdetails")
	@ApiOperation("取消随访计划")
	@RequestMapping(value = "/cancelFollowupPlan", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String getItemDetails(String item) {
	public String cancelFollowupPlan(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
								      @RequestParam(value="id",required = true) String id)
	{
		try {
			return write(200, "查询成功!", "data", executionService.getItemDetails(item));
			followUpService.cancelFollowupPlan(id);
			return write(200, "取消随访计划成功!");
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败!");
			return invalidUserException(e, -1, "取消随访计划失败!");
		}
	}
	/**
	 * 随访项总结提交
	 * 
	 * @param summary String 随访总结JSON
	 * @return
	 */
	@RequestMapping(value = "/summarysubmit")
	/*********************************** 随访详情 *******************************************************************/
	@ApiOperation("获取面访项目列表")
	@RequestMapping(value = "/getFollowupProject", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String saveSummary(int type, int status, String summary) {
		String errMsg = "";
	public String getFollowupProject(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
									 @RequestParam(value="id",required = true) String id)
	{
		try {
			ObjectMapper mapper = new ObjectMapper();
			FollowUpSummary summaryEntity = mapper.readValue(summary, FollowUpSummary.class);
			Doctor doctor = doctorService.findDoctorByCode(getUID());
			switch (type) {
			case 1:
				if (summaryEntity.getPlan().isEmpty()) {
					errMsg = "计划标识不能为空";
				}
				break;
			case 2:
				if (summaryEntity.getPlan().isEmpty()) {
					errMsg = "阶段标识不能为空";
				}
				break;
			case 3:
				if (summaryEntity.getPlan().isEmpty()) {
					errMsg = "随访项标识不能为空";
				}
				break;
			case 4:
				if (summaryEntity.getPlan().isEmpty()) {
					errMsg = "随访纪录标识不能为空";
				}
				break;
			default:
				break;
			}
			summaryEntity.setId((long) 0);
			summaryEntity.setCzrq(new Date());
			summaryEntity.setType(type);
			summaryEntity.setDoctor(doctor.getCode());
			summaryEntity.setDoctorName(doctor.getName());
			List<Map<String,String>> list = followUpService.getFollowupProject(id);
			executionService.saveSummary(type, status, summaryEntity);
			return success("提交总结成功");
			return write(200, "获取面访项目列表成功!","data",list);
		} catch (Exception e) {
			error(e);
			return error(-1, "提交总结失败" + (errMsg.length() > 0 ? ("," + errMsg) : "") + "!");
			return invalidUserException(e, -1, "获取面访项目列表失败!");
		}
	}
	/**
	 * 医生代答随访
	 * 
	 * @param answers 随访答案JSON
	 * @return
	 */
	@RequestMapping(value = "/doctoranswer")
	@ApiOperation("获取面访项目数据")
	@RequestMapping(value = "/getFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String saveRecordAnswers(String answers) {
	public String getFollowupProjectData(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
									 @RequestParam(value="id",required = true) String id,
									 @ApiParam(name="followupProject",value="面访项目",defaultValue = "")
									 @RequestParam(value="followupProject",required = true) String followupProject)
	{
		try {
			ObjectMapper mapper = new ObjectMapper();
			FollowUpItemRecordAnswer[] answerArray = mapper.readValue(answers, FollowUpItemRecordAnswer[].class);
			Doctor doctor = doctorService.findDoctorByCode(getUID());
			for (FollowUpItemRecordAnswer answer : answerArray) {
				answer.setCzrq(new Date());
				answer.setDoctor(doctor.getCode());
				answer.setDoctorName(doctor.getName());
			}
			executionService.saveRecordAnswers(Arrays.asList(answerArray));
			List<Map<String,String>> list = followUpService.getFollowupProjectData(id,followupProject);
			return success("提交成功!");
			return write(200, "获取面访项目数据成功!","data",list);
		} catch (Exception e) {
			error(e);
			return error(-1, "提交失败 !");
			return invalidUserException(e, -1, "获取面访项目数据失败!");
		}
	}
	/**
	 * 随访频率变更
	 * 
	 * @param item String 随访项标识
	 * @param frequency String 频率信息
	 * @return
	 */
	@RequestMapping(value = "/itemfrequencychange")
	@ApiOperation("获取面访用药数据")
	@RequestMapping(value = "/getFollowupDrugs", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String changeItemFrequency(String item, String frequency) {
	public String getFollowupDrugs(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
									@RequestParam(value="id",required = true) String id)
	{
		try {
			JSONObject fJsonObject = new JSONObject(frequency);
			executionService.changeItemFrequency(item, fJsonObject);
			return success("提交成功!");
			List<Map<String,String>> list = followUpService.getFollowupDrugs(id);
			return write(200, "获取面访用药数据成功!","data",list);
		} catch (Exception e) {
			error(e);
			return error(-1, "提交失败 !");
			return invalidUserException(e, -1, "获取面访用药数据失败!");
		}
	}
	/**
	 * 随访计划编辑
	 * 
	 * @param stages
	 * @return
	 */
	@RequestMapping(value = "/planedit")
	@ApiOperation("保存面访项目数据")
	@RequestMapping(value = "/saveFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String editPlan(String stages) {
	public String saveFollowupProjectData(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
								   @RequestParam(value="id",required = true) String id,
								   @ApiParam(name="followupProject",value="面访项目",defaultValue = "")
								   @RequestParam(value="followupProject",required = true) String followupProject,
								   @ApiParam(name="followupProjectData",value="面访项目数据",defaultValue = "")
								   @RequestParam(value="followupProjectData",required = true) String followupProjectData)
	{
		try {
			JSONArray stageArray = new JSONArray(stages);
			// 随访阶段列表
			List<FollowUpPlanStage> stageList = new ArrayList<FollowUpPlanStage>();
			// 随访项列表
			List<FollowUpPlanStageItem> stageItemList = new ArrayList<FollowUpPlanStageItem>();
			// 随访问题列表
			List<FollowUpPlanStageItemQuestion> questionList = new ArrayList<FollowUpPlanStageItemQuestion>();
			// 随访问题选项列表
			List<FollowUpPlanStageItemQuestionOption> optionList = new ArrayList<FollowUpPlanStageItemQuestionOption>();
			// 查询医生信息
			Doctor doctor = doctorService.findDoctorByCode(getUID());
			if (stageArray != null && stageArray.length() > 0) {
				for (int j = 0; j < stageArray.length(); j++) {
					JSONObject tempStage = stageArray.getJSONObject(j);
					// 新的随访阶段
					FollowUpPlanStage stage = new FollowUpPlanStage();
					// 设置阶段标识
					stage.setCode(tempStage.getString("code"));
					stage.setCzrq(new Date());
					// 设置医生标识
					stage.setDoctor(doctor.getCode());
					// 设置医生姓名
					stage.setDoctorName(doctor.getName());
					// 设置阶段结束日期
					stage.setEndDate(DateUtil.strToDateShort(tempStage.getString("endDate")));
					// 设置随访计划标识
					stage.setPlan(tempStage.getString("plan"));
					// 设置阶段序号
					stage.setSeq(tempStage.getInt("seq"));
					// 设置状态
					if (j == 0) {
						// 默认开始第一阶段
						stage.setStatus(1);
					} else {
						// 其他阶段未开始
						stage.setStatus(0);
					}
					// 设置阶段目标
					stage.setTarget(tempStage.getString("target"));
					// 设置类型:1定时,2不定时
					stage.setType(tempStage.getInt("type"));
			followUpService.saveFollowupProjectData(id,followupProject,followupProjectData);
					if (tempStage.getString("code").isEmpty()) {
						// 设置阶段标识
						stage.setCode(executionService.getCode());
						// 添加到阶段列表
						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(executionService.getCode());
							item.setCzrq(new Date());
							// 设置随访计划标识
							item.setPlan(tempStage.getString("plan"));
							// 设置推送类型:1按时间,2按次数
							item.setPushType(tempItem.getInt("pushType"));
							// 设置推送周期
							item.setPushCycle(tempItem.getInt("pushCycle"));
							// 设置推送开始时间
							item.setPushBegin(DateUtil.strToDateShort(tempItem.getString("pushBegin")));
							// 设置推送周期单位:1天,2周,3月
							item.setPushCycleUnit(tempItem.getInt("pushCycleUnit"));
							if (item.getPushType() == 1) {
								// 设置推送结束日期
								item.setPushEnd(DateUtil.strToDateShort(tempItem.getString("pushEnd")));
							} else if (item.getPushType() == 2) {
								// 设置推送次数
								item.setPushTimes(tempItem.getInt("pushTimes"));
							}
							// 设置阶段标识
							item.setStage(stage.getCode());
							// 设置执行状态:-1暂停,0未开始,1进行中,2已结束
							if (item.getCzrq().before(item.getPushBegin())) {
								// 推送时间未到,未开始
								item.setStatus(0);
							} else {
								// 已到推送时间,正在进行
								item.setStatus(1);
							}
							// 设置随访项标题
							item.setTitle(tempItem.getString("title"));
							// 设置随访项类型:1问卷,2体测
							item.setType(tempItem.getInt("type"));
							// 添加随访项列表
							stageItemList.add(item);
							// ==========================================随访问题=========================================
							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(executionService.getCode());
									if (item.getType() == 2) {
										// 体测随访,设置体测指标类型:1血糖,2血压,3体重,4腰围
										question.setIndex(tempQuestion.getInt("index"));
									}
									// 设置随访标识
									question.setItem(item.getCode());
									// 设置随访计划标识
									question.setPlan(tempStage.getString("plan"));
									// 设置随访计划阶段标识
									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);
									// ====================================问题选项========================================
									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.getJSONObject(u).getString("des");
											if (StringUtils.isEmpty(des)) {
												continue;
											}
											// 新的问题选项
											FollowUpPlanStageItemQuestionOption option = new FollowUpPlanStageItemQuestionOption();
											// 设置选项标识
											option.setCode(executionService.getCode());
											// 设置选项描述
											option.setDes(des);
											// 设置随访项标识
											option.setItem(item.getCode());
											// 设置随访计划标识
											option.setPlan(tempStage.getString("plan"));
											// 设置问题标识
											option.setQuestion(question.getCode());
											// 设置阶段标识
											option.setStage(stage.getCode());
											// 添加到选项列表
											optionList.add(option);
											JSONObject tempJson = new JSONObject();
											tempJson.put("code", option.getCode());
											tempJson.put("des", option.getDes());
											tempArray.put(tempJson);
										}
									}
								}
							}
						}
					}
				}
			}
			// 保存到数据库
			executionService.editPlan(stageList, stageItemList, questionList, optionList);
			return success("提交成功!");
			return write(200, "保存面访项目数据成功!");
		} catch (Exception e) {
			error(e);
			return error(-1, "提交失败 !");
			return invalidUserException(e, -1, "保存面访项目数据失败!");
		}
	}
	/**
	 * 总结获取
	 * 
	 * @param type
	 * @param summary
	 * @return
	 */
	@RequestMapping(value = "/summary")
	@ApiOperation("保存面访用药数据")
	@RequestMapping(value = "/saveFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String getSummary(int type, String summary) {
	public String saveFollowupDrugs(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
										  @RequestParam(value="id",required = true) String id,
										  @ApiParam(name="followupProjectData",value="面访项目数据",defaultValue = "")
										  @RequestParam(value="followupProjectData",required = true) String followupProjectData,
									      @ApiParam(name="drugsData",value="面访项目数据",defaultValue = "")
										  @RequestParam(value="drugsData",required = true) String drugsData)
	{
		try {
			return write(200, "查询成功!", "data", executionService.getSummary(type, summary));
			followUpService.saveFollowupDrugs(id,followupProjectData,drugsData);
			return write(200, "保存面访用药数据成功!");
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败!");
			return invalidUserException(e, -1, "保存面访用药数据失败!");
		}
	}
	/**
	 * 阶段周期编辑
	 *  
	 * @param stage String 阶段标识
	 * @param frequency 周期JSON
	 * @return
	 */
	@RequestMapping(value = "/stageedit")
	/*********************************** 电话随访 *****************************************************************/
	@ApiOperation("获取电话随访内容")
	@RequestMapping(value = "/getFollowupPhone", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String editStage(String stage, String frequency) {
	public String saveFollowupPhone(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
									@RequestParam(value="id",required = true) String id) {
		try {
			JSONObject fJsonObject = new JSONObject(frequency);
			executionService.editStage(stage, fJsonObject);
			return success("提交成功!");
			String response = followUpService.getFollowupPhone(id);
			return write(200, "获取电话随访内容成功!","data",response);
		} catch (Exception e) {
			error(e);
			return error(-1, "提交失败 !");
			return invalidUserException(e, -1, "获取电话随访内容失败!");
		}
	}
	/**
	 * 
	 * 
	 * @param type
	 * @param status
	 * @param identity
	 * @return
	 */
	@RequestMapping(value = "/statuschange")
	@ApiOperation("记录电话随访内容")
	@RequestMapping(value = "/saveFollowupPhone", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String setStatus(int type, int status, String identity) {
	public String saveFollowupPhone(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
								  @RequestParam(value="id",required = true) String id,
								  @ApiParam(name="content",value="电话随访内容",defaultValue = "")
								  @RequestParam(value="content",required = true) String content) {
		try {
			if (type == 1) {
				executionService.setPlanStatus(status, identity);
			} else if (type == 2) {
				executionService.setStageStatus(status, identity);
			} else {
				executionService.setItemStatus(status, identity);
			}
			followUpService.saveFollowupPhone(id,content);
			return success("设置成功!");
			return write(200, "记录电话随访内容成功!");
		} catch (Exception e) {
			error(e);
			return error(-1, "设置失败 !");
			return invalidUserException(e, -1, "记录电话随访内容失败!");
		}
	}
}

+ 0 - 876
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpControllerGeorge.java

@ -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, "随访计划保存失败!");
		}
	}
}

+ 0 - 58
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpPlanRemindController.java

@ -1,58 +0,0 @@
package com.yihu.wlyy.web.doctor.followup;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
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.ResponseBody;
import com.yihu.wlyy.entity.follow.FollowUpPlanRemind;
import com.yihu.wlyy.service.app.followup.FollowUpPlanRemindService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.MessageType;
import com.yihu.wlyy.web.BaseController;
/**
 * 医生端:随访提醒
 * @author George
 *
 */
@Controller
@RequestMapping(value = "/doctor/followup/remind", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "随访提醒")
public class DoctorFollowUpPlanRemindController extends BaseController {
	@Autowired
	private FollowUpPlanRemindService followUpPlanRemindService;
	/**
	 * 添加随访提醒
	 * @param patient 患者标识
	 * @param doctorName 医生姓名
	 * @param plan 计划标识
	 * @param content 提醒内容
	 * @return
	 */
	@RequestMapping(value = "add")
	@ResponseBody
	public String add(String patient, String doctorName, String plan, String content) {
		try {
			FollowUpPlanRemind remind = followUpPlanRemindService.add(patient, getUID(), doctorName, plan, content);
			if (remind == null) {
				// 添加失败
				return error(-1, "提醒失败!");
			} else {
				// 添加成功
				// 推送消息给患者
				PushMsgTask.getInstance().put(patient, MessageType.MESSAGE_TYPE_PATIENT_FOLLOW_UP_TIPS.P_FU_02.name(), MessageType.MESSAGE_TYPE_PATIENT_FOLLOW_UP_TIPS.随访提醒.name(), MessageType.MESSAGE_TYPE_PATIENT_FOLLOW_UP_TIPS.您有新的随访提醒.name(), String.valueOf(remind.getId()));
				return success("提醒成功!");
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "提醒失败!");
		}
	}
}

+ 0 - 79
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/followup/FollowUpPlanRemindController.java

@ -1,79 +0,0 @@
package com.yihu.wlyy.web.patient.followup;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.yihu.wlyy.entity.follow.FollowUpPlanRemind;
import com.yihu.wlyy.service.app.followup.FollowUpPlanRemindService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
/**
 * 患者端:随访提醒控制类
 * @author George
 *
 */
@Controller
@RequestMapping(value = "/patient/followup/remind")
public class FollowUpPlanRemindController extends BaseController {
	@Autowired
	private FollowUpPlanRemindService followUpPlanRemindService;
	/**
	 * 查询患者随访提醒列表
	 * @param id
	 * @param pagesize
	 * @return
	 */
	public String list(long id, int pagesize) {
		try {
			JSONArray array = new JSONArray();
			Page<FollowUpPlanRemind> page = followUpPlanRemindService.findByPatient(getUID(), id, pagesize);
			for (FollowUpPlanRemind remind : page) {
				if (remind == null) {
					continue;
				}
				JSONObject json = new JSONObject();
				json.put("id", remind.getId());
				// 设置医生标识
				json.put("doctor", remind.getDoctor());
				// 设置医生姓名
				json.put("doctorName", remind.getDoctorName());
				// 设置随访计划标识
				json.put("plan", remind.getPlan());
				// 设置提醒内容
				json.put("content", remind.getContent());
				// 设置患者查看标识:1未读,0已读
				json.put("read", remind.getRead());
				// 设置提醒时间
				json.put("czrq", DateUtil.dateToStrLong(remind.getCzrq()));
				array.put(json);
			}
			return write(200, "查询成功!", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败!");
		}
	}
	/**
	 * 更新为已读
	 * @param id
	 * @return
	 */
	public String read(long id) {
		try {
			followUpPlanRemindService.read(id);
			return success("操作成功!");
		} catch (Exception e) {
			error(e);
			return error(-1, "更新已读失败!");
		}
	}
}

+ 0 - 573
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/followup/PatientFollowUpController.java

@ -1,573 +0,0 @@
package com.yihu.wlyy.web.patient.followup;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import io.swagger.annotations.Api;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
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.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.follow.FollowUpItemRecord;
import com.yihu.wlyy.entity.follow.FollowUpItemRecordAnswer;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.patient.followup.vo.FollowUpItemRecordAnswerVO;
import com.yihu.wlyy.web.patient.followup.vo.FollowUpItemRecordDetailVO;
import com.yihu.wlyy.web.patient.followup.vo.FollowUpItemRecordQuestionOptionVO;
import com.yihu.wlyy.web.patient.followup.vo.FollowUpItemRecordQuestionVO;
import com.yihu.wlyy.web.patient.followup.vo.FollowupPlanVO;
/**
 * 患者端:随访干预
 * 
 * @author cwd
 * 
 */
@Controller
@RequestMapping(value = "/patient/followup", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "患者端-随访干预")
public class PatientFollowUpController extends BaseController {
	@Autowired
	private PatientFollowUpService patientFollowUpService;
	/**
	 * 主页-随访计划列表
	 * 
	 * @param pagesize
	 *            每页显示条数   /patient/followup/followupPlanList
	 * @param pagenum 当前页
	 * @return
	 */
	@RequestMapping(value = "followupPlanList")
	@ResponseBody
	public String followupPlanList(
			@RequestParam("id")long id, 
			@RequestParam("pagesize")int pagesize, 
			@RequestParam(value="title",required=false)String title) {
		try {
			String userId = super.getUID();
			List<FollowupPlanVO> followupPlanVOs = patientFollowUpService
					.followupPlanList(userId, id, pagesize, title);
			JSONArray array = new JSONArray();
			for (FollowupPlanVO followupPlanVO : followupPlanVOs) {
				JSONObject jo = new JSONObject();
				// 添加計劃
				jo.put("title", followupPlanVO.getTitle());
				// 添加日期
				jo.put("czrq", DateUtil.dateToStrShort(followupPlanVO.getCzrq()));
				// 添加code
				jo.put("code", followupPlanVO.getCode());
				// 添加狀態
				jo.put("status", followupPlanVO.getStatus());
				jo.put("id", followupPlanVO.getId());
				// 添加狀態  -1暂停,0进行中,1已结束
				switch (followupPlanVO.getStatus()) {
				case -1:
					jo.put("statusName", "暂停");
					break;
				case 0:
					jo.put("statusName", "进行中");
					break;
				case 1:
					jo.put("statusName", "已结束");
					break;
				}
				// 添加名称
				jo.put("doctorName", followupPlanVO.getDoctorName());
				jo.put("photo", followupPlanVO.getDoctorPhoto());
				array.put(jo);
			}
			return write(200, "查询成功!", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败!");
		}
	}
	/**
	 * 主页-随访计划-根据计划code查找随访项
	 * 
	 * @param planCode
	 * @param title
	 * @return
	 */
	@RequestMapping(value = "getFollowUpPlanStageItemListByParam")
	@ResponseBody
	public String getFollowUpPlanStageItemListByParam(
			@RequestParam(value="planCode",required=false) String planCode,
			@RequestParam(value="type",required=false) String type,
			@RequestParam(value="title",required=false)String title) {
		try {
			JSONArray array = new JSONArray();
			String uid=super.getUID();
			List<FollowUpItemRecord> followupPlanVOs = patientFollowUpService
					.getFollowUpPlanStageItemListByPlanCode(uid,planCode,title,type);
			for (FollowUpItemRecord followUpItemRecord : followupPlanVOs) {
				JSONObject jo = new JSONObject();
				// 添加計劃
				jo.put("title", followUpItemRecord.getTitle());
				
				jo.put("id", followUpItemRecord.getId());
				// 添加日期
				jo.put("czrq", DateUtil.dateToStrShort(followUpItemRecord.getCzrq()));
				// 添加code
				jo.put("code", followUpItemRecord.getCode());
				// 添加item
				jo.put("itemCode", followUpItemRecord.getItem());
				//类型
				jo.put("type", followUpItemRecord.getType());
				// 添加狀態
				jo.put("status", followUpItemRecord.getStatus());
				// 添加狀態  0进行中,1已结束
				if(followUpItemRecord.getStatus()==0){
					jo.put("statusName", "进行中");
				}else{
					jo.put("statusName", "已结束");
				}
				array.put(jo);
			}
			
			return write(200, "查询成功!", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败!");
		}
	}
	/**
	 * 主页-随访计划-查看单个随访周期的详细信息
	 * 
	 * @param recoredCode
	 * @return
	 */
	@RequestMapping(value = "followupPlanListLeftDetail")
	@ResponseBody
	public String followupPlanListLeftDetail(String recoredCode) {
		try {
			String userId = super.getUID();
			FollowUpItemRecordDetailVO followUpItemRecordDetailVO = patientFollowUpService
					.getFollowUpItemRecordDetailById(recoredCode);
			JSONObject jo = new JSONObject();
			jo.put("title", followUpItemRecordDetailVO.getTitle());
			jo.put("id", followUpItemRecordDetailVO.getId());
			jo.put("plan", followUpItemRecordDetailVO.getPlan());
			jo.put("stage", followUpItemRecordDetailVO.getStage());
			jo.put("item", followUpItemRecordDetailVO.getItem());
			jo.put("code", followUpItemRecordDetailVO.getCode());
			jo.put("czrq", DateUtil.dateToStrShort(followUpItemRecordDetailVO.getCzrq()));
			jo.put("type", followUpItemRecordDetailVO.getType());
			switch (followUpItemRecordDetailVO.getType()) {
			case 1:
				jo.put("typeName", "问卷");
				break;
			case 2:
				jo.put("typeName", "体侧");
				break;
			}
			jo.put("status", followUpItemRecordDetailVO.getStatus());
			if(followUpItemRecordDetailVO.getStatus()==0){
				jo.put("statusName", "进行中");
			}else{
				jo.put("statusName", "已完成");
			}
			jo.put("doctor", followUpItemRecordDetailVO.getDoctor());
			jo.put("doctorName", followUpItemRecordDetailVO.getDoctorName());
			JSONArray array = new JSONArray();
			// 遍历所有问题
			for (FollowUpItemRecordQuestionVO followUpItemRecordQuestionVO : followUpItemRecordDetailVO
					.getFollowUpItemRecordQuestionVO()) {
				JSONObject joTemp = new JSONObject();
				// 设置问题
				joTemp.put("title", followUpItemRecordQuestionVO.getTitle());
				joTemp.put("plan", followUpItemRecordQuestionVO.getPlan());
				joTemp.put("stage", followUpItemRecordQuestionVO.getStage());
				joTemp.put("item", followUpItemRecordQuestionVO.getItem());
				joTemp.put("record", followUpItemRecordQuestionVO.getRecord());
				joTemp.put("code", followUpItemRecordQuestionVO.getCode());
				joTemp.put("type", followUpItemRecordQuestionVO.getType());
				//1单选,2多选,3问答
				switch (followUpItemRecordDetailVO.getType()) {
				case 1:
					jo.put("typeName", "单选");
					break;
				case 2:
					jo.put("typeName", "多选");
					break;
				case 3:
					jo.put("typeName", "问答");
					break;
				}
				//1血糖,2血压,3体重,4腰围
				joTemp.put("index", followUpItemRecordQuestionVO.getIndex());
				switch (followUpItemRecordDetailVO.getStatus()) {
				case 1:
					jo.put("indexName", "血糖");
					break;
				case 2:
					jo.put("indexName", "血压");
					break;
				case 3:
					jo.put("indexName", "体重");
					break;
				case 4:
					jo.put("indexName", "腰围");
					break;
				}
				// 设置问题的选项
				JSONArray option = new JSONArray();
				for (FollowUpItemRecordQuestionOptionVO followUpItemRecordQuestionOptionVO : followUpItemRecordQuestionVO
						.getFollowUpItemRecordQuestionOptions()) {
					JSONObject optionJO = new JSONObject();
					optionJO.put("plan", followUpItemRecordQuestionOptionVO.getPlan());
					optionJO.put("stage", followUpItemRecordQuestionOptionVO.getStage());
					optionJO.put("item", followUpItemRecordQuestionOptionVO.getItem());
					optionJO.put("record", followUpItemRecordQuestionOptionVO.getRecord());
					optionJO.put("question",followUpItemRecordQuestionOptionVO.getQuestion());
					optionJO.put("code",followUpItemRecordQuestionOptionVO.getCode());
					optionJO.put("des",followUpItemRecordQuestionOptionVO.getDes());
					option.put(optionJO);
				}
				joTemp.put("option", option);
				// 设置问题的答案
				// 如果已经回答 设置答案
				JSONArray answer = new JSONArray();
				for(FollowUpItemRecordAnswerVO followUpItemRecordAnswerVO:followUpItemRecordQuestionVO.getFollowUpItemRecordAnswerVOs()){
					JSONObject answerJO = new JSONObject();
					answerJO.put("answer",followUpItemRecordAnswerVO.getAnswer());
					answerJO.put("option",followUpItemRecordAnswerVO.getOption());
					answerJO.put("plan", followUpItemRecordAnswerVO.getPlan());
					answerJO.put("stage", followUpItemRecordAnswerVO.getStage());
					answerJO.put("item", followUpItemRecordAnswerVO.getItem());
					answerJO.put("type", followUpItemRecordAnswerVO.getType());//1单选,2多选,3问答
					switch (followUpItemRecordDetailVO.getStatus()) {
						case 1:
							jo.put("typeName", "单选");
							break;
						case 2:
							jo.put("typeName", "多选");
							break;
						case 3:
							jo.put("typeName", "问答");
							break;
						}
					answerJO.put("record", followUpItemRecordAnswerVO.getRecord());
					answerJO.put("question",followUpItemRecordAnswerVO.getQuestion());
					answerJO.put("index",followUpItemRecordAnswerVO.getIndex());
					switch (followUpItemRecordDetailVO.getStatus()) {
						case 1:
							jo.put("indexName", "血糖");
							break;
						case 2:
							jo.put("indexName", "血压");
							break;
						case 3:
							jo.put("indexName", "体重");
							break;
						case 4:
							jo.put("indexName", "腰围");
							break;
						}
					answerJO.put("doctor", followUpItemRecordAnswerVO.getDoctor());
					answerJO.put("doctorName", followUpItemRecordAnswerVO.getDoctorName());
					answer.put(answerJO);
				}
				joTemp.put("answer", answer);
			array.put(joTemp);
			}
			jo.put("question", array);
			return write(200, "查询成功!", "data", jo);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败!");
		}
	}
	/**
	 * 主页-随访计划-保存单个随访周期的答案
	 * 
	 * @return
	@RequestMapping(value = "saveFollowUpItemRecordAnswer")
	@ResponseBody
	public String saveFollowUpItemRecordAnswer(int type,String jsonData) {
		try {
			String userId = super.getUID();
			
			JSONArray array = new JSONArray();
			
			return write(200, "保存成功!");
		} catch (Exception e) {
			error(e);
			return error(-1, "保存失败!");
		}
	}
	 */
	/**
	 * 完成情况
	 * {
	 * 		doctorName:"医生姓名“,
	 *      czrq:" yyyy-MM-dd",
	 *      title:"标题"
	 *      wjAmount:"总问卷随访数",
	 *      wjFinishAmount:"已完成问卷随访数",
	 *      tcAmount:"总体测随访数",
	 *      tcFinishAmount:"已完成体测随访数",
	 *      planCode:"",
	 *      docSummary:[
	 *                {
	 *                  summary:"医生总结",
	 *                  doctorName:"医生名字",
	 *                  czrq:"完成时间",
	 *                  photo:"",
	 *                  type:"1、计划  2、阶段 3、随访项 4、随访纪录",
	 *                  typeName:"",
	 *                }
	 *             ]
	 * }
	 * @param id
	 * @param pagesize
	 * @return
	 */
	@RequestMapping(value = "getPlanDetail")
	@ResponseBody
	public String getPlanDetail(
			@RequestParam("planCode") String planCode) {
		try {
			JSONObject jo=patientFollowUpService.getPlanDetail(planCode);
			return write(200, "查询成功!", "list", jo);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败!");
		}
	}
	/**
	 * 完成情况-问卷详情
	 * 
	 * @param itemCode
	 * @return
	 *  *{
		    "msg": "查询成功!",
		    "data": {
		        "question": [ {
		                "answer": [{
		                        "czrq": "2016-05-31",
		                        "desc": [
		                            "胃散",
		                            "泻立停"
		                        ] }
		                ],
		                "title": "吃了什么药"
		            },
		            {
		                "answer": [],
		                "title": "体征检测"
		            },
		    },
		    "status": 200
		}
	 */
	@RequestMapping(value = "getFollowUpWJs")
	@ResponseBody
	public String getFollowUpWJs(
			@RequestParam("itemCode") String itemCode) {
		try {
			JSONObject jo=patientFollowUpService.getFollowUpWJs(itemCode);
			return write(200, "查询成功!", "data", jo);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败!");
		}
	}
	/**
	 * 完成情况-医生小结
	 * 
	 * @param planCode
	 * @return
	 * 
	 * {
	 *    title:"",
		  summary:[{
		   summary:"总结“,
		   czrq:"yyyy-mm-dd",
		   title:"标题",
		   doctorName:"医生名字"
		   photo:"",
		   id:""
		  }]
	 * }
	 * 
	 *
	 */
	@RequestMapping(value = "getItemDetail")
	@ResponseBody
	public String getItemDetail(
			@RequestParam("id")long id, 
			@RequestParam("pagesize")int pagesize, 
			@RequestParam("itemCode") String itemCode) {
		try {
			JSONObject jo=patientFollowUpService.getItemDetail(id,pagesize,itemCode);
			return write(200, "查询成功!", "data", jo);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败!");
		}
	}
	
	/**
	 * 随访保存
	 * 
	 * @param answers 随访答案JSON
	 * @return
	 */
	@RequestMapping(value = "/saveRecordAnswers")
	@ResponseBody
	public String saveRecordAnswers(String answers){
		try{
			ObjectMapper mapper = new ObjectMapper();
			FollowUpItemRecordAnswer[] answerArray = mapper.readValue(answers, FollowUpItemRecordAnswer[].class);
			
			for(FollowUpItemRecordAnswer answer : answerArray){
				answer.setCzrq(new Date());
			}
			
			patientFollowUpService.saveRecordAnswers(Arrays.asList(answerArray));
			
			return success("提交成功!");
		}
		catch(Exception e){
			error(e);
			return error(-1, "提交失败 !");
		}
	}
	
	/**
	 * 完成情况-体征详情
	 * 1血糖,2血压,3体重,4腰围
	 * @param itemCode
	 * @return
	 *   "msg":"查询成功!",
		    "data":{
		        "title":"血压(舒张压)",
		        "datas":[
		            [
		                {
		                    "answer":"80",
		                    "czrq":"2016-05-31"
		                },
		                {
		                    "answer":"220",
		                    "czrq":"2016-05-31"
		                }
		            ]
		        ]
		    },
		    "status":200
		}
	 */
	@RequestMapping(value = "getFollowUpTZs")
	@ResponseBody
	public String getFollowUpTZs(
			@RequestParam("question") String question) {
		try {
			JSONObject jo=patientFollowUpService.getFollowUpTZs(question);
			return write(200, "查询成功!", "data", jo);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败!");
		}
	}
	/**
	 * 
	 * @param itemCode  目前沒用的接口
	 * @return
	 *  [{
	 *    itemCode:"",
	 *    index:"",
	 *    indexName:""
	 * },{
	 *    itemCode:"",
	 *    index:"",
	 *    indexName:""
	 * }]
	 */
	@RequestMapping(value = "getTypeList")
	@ResponseBody
	public String getTypeList(
			@RequestParam("itemCode") String itemCode) {
		try {
			JSONArray jo=patientFollowUpService.getTypeList(itemCode);
			return write(200, "查询成功!", "list", jo);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败!");
		}
	}
	
	/**
	 * 
	 * @param itemCode
	 * @return
	 *  [{
	 *    title:"",
	 *    question:""
	 * },{
	 *    title:"",
	 *    question:""
	 * }]
	 */
	@RequestMapping(value = "getQuestionList")
	@ResponseBody
	public String getQuestionList(
			@RequestParam("itemCode") String itemCode) {
		try {
			JSONArray jo=patientFollowUpService.getQuestionList(itemCode);
			return write(200, "查询成功!", "list", jo);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败!");
		}
	}
	/**
	 * 
	 * @param planCode
	 * @param type
	 * @return
	 * {
	 *    title:"",
	 *    item:[{
	 *       title:"",
	 *       item:"",
	 *       plan:"",
	 *       stage:"",
	 *    }]
	 * 
	 * }
	 */
	@RequestMapping(value = "getItemList")
	@ResponseBody
	public String getItemList(
			@RequestParam("planCode") String planCode,
			@RequestParam("type") int type) {
		try {
			JSONObject jo=patientFollowUpService.getItemList(planCode,type);
			return write(200, "查询成功!", "data", jo);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败!");
		}
	}
	
}

+ 0 - 483
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/followup/PatientFollowUpService.java

@ -1,483 +0,0 @@
package com.yihu.wlyy.web.patient.followup;
import java.util.ArrayList;
import java.util.List;
import javax.transaction.Transactional;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.follow.FollowUpItemRecord;
import com.yihu.wlyy.entity.follow.FollowUpItemRecordAnswer;
import com.yihu.wlyy.entity.follow.FollowUpItemRecordQuestion;
import com.yihu.wlyy.entity.follow.FollowUpItemRecordQuestionOption;
import com.yihu.wlyy.entity.follow.FollowUpPlan;
import com.yihu.wlyy.entity.follow.FollowUpPlanStageItem;
import com.yihu.wlyy.entity.follow.FollowUpPlanStageItemQuestion;
import com.yihu.wlyy.entity.follow.FollowUpSummary;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.followup.FollowUpItemRecordAnswerDao;
import com.yihu.wlyy.repository.followup.FollowUpItemRecordDao;
import com.yihu.wlyy.repository.followup.FollowUpItemRecordQuestionDao;
import com.yihu.wlyy.repository.followup.FollowUpItemRecordQuestionOptionDao;
import com.yihu.wlyy.repository.followup.FollowUpPlanDao;
import com.yihu.wlyy.repository.followup.FollowUpPlanStageDao;
import com.yihu.wlyy.repository.followup.FollowUpPlanStageItemDao;
import com.yihu.wlyy.repository.followup.FollowUpPlanStageItemQuestionDao;
import com.yihu.wlyy.repository.followup.FollowUpSummaryDao;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.patient.followup.vo.FollowUpItemRecordAnswerVO;
import com.yihu.wlyy.web.patient.followup.vo.FollowUpItemRecordDetailVO;
import com.yihu.wlyy.web.patient.followup.vo.FollowUpItemRecordQuestionOptionVO;
import com.yihu.wlyy.web.patient.followup.vo.FollowUpItemRecordQuestionVO;
import com.yihu.wlyy.web.patient.followup.vo.FollowupPlanVO;
@Service("patientFollowUpService")
public class PatientFollowUpService {
	@Autowired
	private FollowUpPlanDao followUpPlanDao;// 计划Dao
	@Autowired
	private FollowUpPlanStageDao followUpPlanStageDao;// 阶段dao
	@Autowired
	private FollowUpPlanStageItemDao followUpPlanStageItemDao;// 随访dao
	@Autowired
	private FollowUpItemRecordDao followUpItemRecordDao;// 周期dao
	@Autowired
	private FollowUpPlanStageItemQuestionDao followUpPlanStageItemQuestionDao;
	@Autowired
	private FollowUpItemRecordQuestionDao followUpItemRecordQuestionDao; // 周期问题Dao
	@Autowired
	private FollowUpItemRecordQuestionOptionDao followUpItemRecordQuestionOptionDao;// 周期选项dao
	@Autowired
	private FollowUpItemRecordAnswerDao followUpItemRecordAnswerDao;// 周期答案dao
	@Autowired
	private FollowUpSummaryDao followUpSummaryDao;
	@Autowired
	private DoctorDao doctorDao;
	public List<FollowUpItemRecord> getFollowUpPlanStageItemListByPlanCode(
			String userid, String planCode, String title, String type) {
		if (!StringUtils.isEmpty(planCode)) {
			return followUpItemRecordDao
					.getFollowUpPlanStageItemListByPlanCode(planCode);
		} else if (!StringUtils.isEmpty(type)) {
			return followUpItemRecordDao
					.getFollowUpPlanStageItemListByPlanCodeAndType(planCode,
							type);
		} else {
			List<FollowUpItemRecord> returnFollowUpItemRecord = new ArrayList<FollowUpItemRecord>();
			List<FollowUpPlan> followUpPlans = followUpPlanDao
					.findByPatient(userid);
			for (FollowUpPlan followUpPlan : followUpPlans) {
				List<FollowUpItemRecord> data = followUpItemRecordDao
						.getFollowUpPlanStageItemListByPlanCode(followUpPlan
								.getCode());
				returnFollowUpItemRecord.addAll(data);
			}
			return returnFollowUpItemRecord;
		}
	}
	public List<FollowupPlanVO> followupPlanList(String userId, long id,
			int pagesize, String title) throws Exception {
		List<FollowupPlanVO> returnList = new ArrayList<FollowupPlanVO>();
		if (pagesize <= 0) {
			pagesize = 10;
		}
		// 分页信息
		PageRequest pageRequest = new PageRequest(0, pagesize);
		// 设置查询条件
		Page<FollowUpPlan> followUpPlans = null;
		// 得到当前用户的计划
		if (StringUtils.isEmpty(title)) {
			if (id > 0) {
				followUpPlans = followUpPlanDao.getfollowupPlanListLeft(userId,
						id, pageRequest);
			} else {
				followUpPlans = followUpPlanDao.getfollowupPlanListLeft(userId,
						pageRequest);
			}
		} else {
			if (id > 0) {
				followUpPlans = followUpPlanDao.getfollowupPlanListLeft(userId,
						id, title, pageRequest);
			} else {
				followUpPlans = followUpPlanDao.getfollowupPlanListLeft(userId,
						title, pageRequest);
			}
		}
		if (followUpPlans != null) {
			for (FollowUpPlan followUpPlan : followUpPlans) {
				FollowupPlanVO followupPlanVO = new FollowupPlanVO();
				BeanUtils.copyProperties(followUpPlan, followupPlanVO);
				Doctor doctor = doctorDao
						.findByCode(followupPlanVO.getDoctor());
				followupPlanVO.setDoctorPhoto(doctor.getPhoto());
				returnList.add(followupPlanVO);
			}
		}
		return returnList;
	}
	public FollowUpItemRecordDetailVO getFollowUpItemRecordDetailById(
			String recoredCode) {
		FollowUpItemRecordDetailVO followUpItemRecordDetailVO = new FollowUpItemRecordDetailVO();
		FollowUpItemRecord followUpItemRecord = followUpItemRecordDao
				.getFollowUpItemRecordByCode(recoredCode);
		BeanUtils
				.copyProperties(followUpItemRecord, followUpItemRecordDetailVO);
		FollowUpPlan followUpPlan = followUpPlanDao
				.findByCode(followUpItemRecord.getPlan());
		followUpItemRecordDetailVO.setDoctor(followUpPlan.getDoctor());
		followUpItemRecordDetailVO.setDoctorName(followUpPlan.getDoctorName());
		// 得到本次隨訪週期的所有問題
		List<FollowUpItemRecordQuestion> followUpItemRecordQuestions = followUpItemRecordQuestionDao
				.getFollowUpItemRecordQuestionByRecoredCode(recoredCode);
		for (FollowUpItemRecordQuestion followUpItemRecordQuestion : followUpItemRecordQuestions) {
			FollowUpItemRecordQuestionVO followUpItemRecordQuestionVO = new FollowUpItemRecordQuestionVO();
			BeanUtils.copyProperties(followUpItemRecordQuestion,
					followUpItemRecordQuestionVO);
			// 得到问题的所有选项
			List<FollowUpItemRecordQuestionOption> FollowUpItemRecordQuestionOptions = followUpItemRecordQuestionOptionDao
					.findByRecordAndQuestion(recoredCode,followUpItemRecordQuestion.getCode());
			// 设置问题的所有选项
			List<FollowUpItemRecordQuestionOptionVO> FollowUpItemRecordQuestionOptionVOs = new ArrayList<FollowUpItemRecordQuestionOptionVO>();
			for (FollowUpItemRecordQuestionOption followUpItemRecordQuestionOption : FollowUpItemRecordQuestionOptions) {
				FollowUpItemRecordQuestionOptionVO followUpItemRecordQuestionOptionVO = new FollowUpItemRecordQuestionOptionVO();
				BeanUtils.copyProperties(followUpItemRecordQuestionOption,
						followUpItemRecordQuestionOptionVO);
				FollowUpItemRecordQuestionOptionVOs
						.add(followUpItemRecordQuestionOptionVO);
			}
			followUpItemRecordQuestionVO
					.setFollowUpItemRecordQuestionOptions(FollowUpItemRecordQuestionOptionVOs);
			// 如果已经回答 设置答案
			List<FollowUpItemRecordAnswer> followUpItemRecordAnswers = followUpItemRecordAnswerDao
					.findByRecordCodeAndQuestion(recoredCode,followUpItemRecordQuestion.getCode());
			// 判断是否有答案
			if (followUpItemRecordAnswers != null
					&& followUpItemRecordAnswers.size() > 0) {
				for (FollowUpItemRecordAnswer followUpItemRecordAnswer : followUpItemRecordAnswers) {
					FollowUpItemRecordAnswerVO followUpItemRecordAnswerVO = new FollowUpItemRecordAnswerVO();
					BeanUtils.copyProperties(followUpItemRecordAnswer,
							followUpItemRecordAnswerVO);
					followUpItemRecordQuestionVO
							.getFollowUpItemRecordAnswerVOs().add(
									followUpItemRecordAnswerVO);
				}
			}
			followUpItemRecordDetailVO.getFollowUpItemRecordQuestionVO().add(
					followUpItemRecordQuestionVO);
		}
		return followUpItemRecordDetailVO;
	}
	public JSONObject getPlanDetail(String planCode) {
		JSONObject jo = new JSONObject();
		FollowUpPlan followUpPlan = followUpPlanDao.findByCode(planCode);
		jo.put("title", followUpPlan.getTitle());
		jo.put("doctorName", followUpPlan.getDoctorName());
		jo.put("czrq", DateUtil.dateToStrShort(followUpPlan.getCzrq()));
		jo.put("wjAmount", followUpPlan.getWjAmount());
		jo.put("wjFinishAmount", followUpPlan.getWjFinishAmount());
		jo.put("tcAmount", followUpPlan.getTcAmount());
		jo.put("tcFinishAmount", followUpPlan.getTcFinishAmount());
		jo.put("planCode", followUpPlan.getCode());
		List<FollowUpSummary> followUpSummarys = followUpSummaryDao
				.findByPlanCodeAndType(planCode);
		JSONArray ja = new JSONArray();
		for (FollowUpSummary followUpSummary : followUpSummarys) {
			JSONObject joTemp = new JSONObject();
			joTemp.put("summary", followUpSummary.getSummary());
			joTemp.put("doctorName", followUpSummary.getDoctorName());
			joTemp.put("type", followUpSummary.getType());
			// 1、计划 2、阶段 3、随访项 4、随访纪录
			switch (followUpSummary.getType()) {
			case 1:
				joTemp.put("typeName", "计划");
				break;
			case 2:
				joTemp.put("typeName", "阶段");
				break;
			case 3:
				joTemp.put("typeName", "随访项 ");
				break;
			case 4:
				joTemp.put("typeName", "随访纪录");
				break;
			}
			joTemp.put("czrq",
					DateUtil.dateToStrLong(followUpSummary.getCzrq()));
			Doctor doctor = doctorDao.findByCode(followUpSummary.getDoctor());
			joTemp.put("photo", doctor == null ? "" : doctor.getPhoto());
			// joTemp。put
			ja.put(joTemp);
		}
		jo.put("docSummary", ja);
		return jo;
	}
	public JSONObject getItemDetail(long id, int pageSize, String itemCode) {
		JSONObject jo = new JSONObject();
		// 根据计划code找出所有的随访 时间倒叙
		FollowUpPlanStageItem followUpPlanStageItem = followUpPlanStageItemDao
				.findByCode(itemCode);
		jo.put("title", followUpPlanStageItem.getTitle());
		JSONArray ja = new JSONArray();
		// 根据随访code找出每次随访的总结
		PageRequest pageRequest = new PageRequest(0, pageSize);
		Page<FollowUpSummary> followUpSummarys = null;
		if (id > 0) {
			followUpSummarys = followUpSummaryDao.findByItemCode(itemCode, id,
					pageRequest);
		} else {
			followUpSummarys = followUpSummaryDao.findByItemCode(itemCode,
					pageRequest);
		}
		if (followUpSummarys != null && followUpSummarys.getSize() > 0) {
			for (FollowUpSummary followUpSummary : followUpSummarys) {
				JSONObject joTemp = new JSONObject();
				joTemp.put("summary", followUpSummary.getSummary());
				joTemp.put("czrq",
						DateUtil.dateToStrShort(followUpSummary.getCzrq()));
				joTemp.put("title", followUpPlanStageItem.getTitle());
				joTemp.put("doctorName", followUpSummary.getDoctorName());
				joTemp.put("id", followUpSummary.getId());
				joTemp.put("photo",
						doctorDao.findByCode(followUpSummary.getDoctor())
								.getPhoto());
				ja.put(joTemp);
			}
		}
		jo.put("summary", ja);
		return jo;
	}
	public JSONObject getFollowUpTZs(String question) {
		JSONObject jo = new JSONObject();
		List<FollowUpPlanStageItemQuestion> followUpPlanStageItemQuestions=followUpPlanStageItemQuestionDao.findByCode(question);
		jo.put("title", followUpPlanStageItemQuestions.get(0).getTitle());
		//根據questionCode找出所有問卷的答案 
		List<FollowUpItemRecordAnswer> followUpItemRecordAnswers=followUpItemRecordAnswerDao.findbyQuestion(question);
		JSONArray  jaTmep = new JSONArray();	
		for(FollowUpItemRecordAnswer followUpItemRecordAnswer: followUpItemRecordAnswers){
			JSONObject joTemp = new JSONObject();
			joTemp.put("answer", followUpItemRecordAnswer.getAnswer());
			joTemp.put("czrq", DateUtil.dateToStrShort(followUpItemRecordAnswer.getCzrq()));
			FollowUpItemRecordQuestionOption followUpItemRecordQuestionOption= followUpItemRecordQuestionOptionDao.findByCode(followUpItemRecordAnswer.getOption());
			joTemp.put("desc",followUpItemRecordQuestionOption.getDes());
			jaTmep.put(joTemp);
		}
		jo.put("datas", jaTmep);
		return jo;
	}
	/**
	 * 
	 * { titile:"随访计划title", question:{ 是否按时吃药:{ 2016-03-03:[吃了很多],
	 * 2016-03-04:[吃了很少,吃了不少] }.
	 * 
	 * 问题名字:{ 日期:[答案] } }
	 * 
	 * @param itemCode
	 * @return
	 */
	public JSONObject getFollowUpWJs(String itemCode) {
		FollowUpPlanStageItem followUpPlanStageItem = followUpPlanStageItemDao
				.findByCode(itemCode);
		// 根据随访code查找本次随访的所有问题
		List<FollowUpItemRecordQuestion> followUpItemRecordQuestions = followUpItemRecordQuestionDao
				.findByPlanAndStageAndItem(followUpPlanStageItem.getCode());
		JSONObject joTmep = new JSONObject();
		for (FollowUpItemRecordQuestion followUpItemRecordQuestion : followUpItemRecordQuestions) {
			if (followUpItemRecordQuestion != null) {
				// 找出答案
				List<FollowUpItemRecordAnswer> followUpItemRecordAnswers = followUpItemRecordAnswerDao
						.getFollowUpItemRecordAnswerByQuestionCode(followUpItemRecordQuestion
								.getCode());
				JSONObject answerJA = null;
				if (!joTmep.has(followUpItemRecordQuestion.getTitle())) {
					answerJA = new JSONObject();
				} else {
					answerJA = (JSONObject) joTmep
							.get(followUpItemRecordQuestion.getTitle());
				}
				JSONArray answerJO = new JSONArray();
				String key = "";
				for (FollowUpItemRecordAnswer followUpItemRecordAnswer : followUpItemRecordAnswers) {
					if (followUpItemRecordAnswer != null) {
						// 判断是问答还是单选或者多选
						if (followUpItemRecordQuestion.getType() == 3) {
							answerJO.put(followUpItemRecordAnswer.getAnswer());
						} else {
							FollowUpItemRecordQuestionOption followUpItemRecordQuestionOption = followUpItemRecordQuestionOptionDao
									.findByCode(followUpItemRecordAnswer
											.getOption());
							if (followUpItemRecordQuestionOption != null) {
								answerJO.put(followUpItemRecordQuestionOption
										.getDes());
							}
						}
						key = DateUtil.dateToStrLong(followUpItemRecordAnswer
								.getCzrq());
					}
				}
				answerJA.put(key, answerJO);
				joTmep.put(followUpItemRecordQuestion.getTitle(), answerJA);
			}
		}
		// 数据格式转换
		JSONObject returnJSONObjectTemp = new JSONObject();
		JSONArray jaTemp = new JSONArray();
		for (String key : joTmep.keySet()) {
			JSONObject jo = (JSONObject) joTmep.get(key);
			JSONArray answerJA = new JSONArray();
			for (String jokey : jo.keySet()) {
				JSONObject joAnswer = new JSONObject();
				if (!StringUtils.isEmpty(jokey)) {
					joAnswer.put("czrq", DateUtil.dateToStrShort(DateUtil
							.strToDateLong(jokey)));
					joAnswer.put("desc", jo.get(jokey));
					answerJA.put(joAnswer);
				}
			}
			jo = new JSONObject();
			jo.put("answer", answerJA);
			jo.put("title", key);
			jaTemp.put(jo);
		}
		returnJSONObjectTemp.put("title", followUpPlanStageItem.getTitle());
		returnJSONObjectTemp.put("question", jaTemp);
		return returnJSONObjectTemp;
	}
	@Transactional
	public void saveRecordAnswers(List<FollowUpItemRecordAnswer> asList) {
		// 保存答案
		followUpItemRecordAnswerDao.save(asList);
		// 修改对应的recored的标识 1问卷,2体测
		FollowUpItemRecordAnswer followUpItemRecordAnswer = asList.get(0);
		int type = followUpItemRecordAnswer.getType();
		if (type == 1) {
			// 1问卷
			FollowUpItemRecord followUpItemRecord = followUpItemRecordDao
					.findByCode(followUpItemRecordAnswer.getRecord());
			followUpItemRecord.setStatus(1);// 修改标识为已经完成
			followUpItemRecordDao.save(followUpItemRecord);
			// 修改计划的计数器
			FollowUpPlan followUpPlan = followUpPlanDao
					.findByCode(followUpItemRecord.getPlan());
			int count = followUpPlan.getWjFinishAmount();
			followUpPlan.setWjFinishAmount(count++);
		} else {
			// 2体测
			FollowUpItemRecord followUpItemRecord = followUpItemRecordDao
					.findByCode(followUpItemRecordAnswer.getRecord());
			String recordCode = followUpItemRecord.getCode();
			// 得到当前问卷的答案数
			List<FollowUpItemRecordAnswer> followUpItemRecordAnswers = followUpItemRecordAnswerDao
					.findByRecordDistinQuestion(recordCode);
			// 得到当前问卷的问题数目
			List<FollowUpItemRecordQuestion> followUpItemRecordQuestions = followUpItemRecordQuestionDao
					.findByRecord(recordCode);
			if (followUpItemRecordAnswers != null
					&& followUpItemRecordAnswers.size() > 0) {
				if (followUpItemRecordQuestions.size() == followUpItemRecordAnswers
						.size()) {
					followUpItemRecord.setStatus(1);// 修改标识为已经完成
					// 修改计划的计数器
					FollowUpPlan followUpPlan = followUpPlanDao
							.findByCode(followUpItemRecord.getPlan());
					int count = followUpPlan.getTcFinishAmount();
					followUpPlan.setTcAmount(count++);
					// 修改计划的计数器
				}
			}
		}
	}
	public JSONArray getTypeList(String itemCode) {
		JSONArray ja = new JSONArray();
		List<Integer> followUpItemRecordQuestions = followUpItemRecordQuestionDao
				.getByItemCodeDistinctType(itemCode);
		if (followUpItemRecordQuestions != null
				&& followUpItemRecordQuestions.size() > 0) {
			for (Integer index : followUpItemRecordQuestions) {
				JSONObject jo = new JSONObject();
				jo.put("index", index);
				jo.put("itemCode", itemCode);
				switch (index) {
				case 1:
					jo.put("indexName", "血糖");
					break;
				case 2:
					jo.put("indexName", "血压");
					break;
				case 3:
					jo.put("indexName", "体重");
					break;
				case 4:
					jo.put("indexName", "腰围");
					break;
				}
				ja.put(jo);
			}
		}
		return ja;
	}
	public JSONObject getItemList(String planCode, int type) {
		JSONObject jo = new JSONObject();
		FollowUpPlan followUpPlan = followUpPlanDao.findByCode(planCode);
		jo.put("title", followUpPlan.getTitle());
		List<String> itemCodes = followUpItemRecordDao
				.findByPlanCodeAndTypeDistinctItemCode(planCode, type);
		JSONArray ja = new JSONArray();
		if (itemCodes != null && itemCodes.size() > 0) {
			for (String itemCode : itemCodes) {
				FollowUpPlanStageItem followUpPlanStageItem = followUpPlanStageItemDao
						.findByCode(itemCode);
				JSONObject joTemp = new JSONObject();
				joTemp.put("title", followUpPlanStageItem.getTitle());
				joTemp.put("plan", followUpPlanStageItem.getPlan());
				joTemp.put("item", followUpPlanStageItem.getCode());
				joTemp.put("stage", followUpPlanStageItem.getStage());
				ja.put(joTemp);
			}
		}
		jo.put("item", ja);
		return jo;
	}
	public JSONArray getQuestionList(String itemCode) {
		JSONArray ja=new JSONArray();
		List<FollowUpPlanStageItemQuestion> followUpItemRecordQuestions=followUpPlanStageItemQuestionDao.findByItemCode(itemCode);
		for(FollowUpPlanStageItemQuestion followUpItemRecordQuestion:followUpItemRecordQuestions){
			JSONObject joTemp = new JSONObject();
				joTemp.put("title", followUpItemRecordQuestion.getTitle());
				joTemp.put("item", followUpItemRecordQuestion.getItem());
				joTemp.put("question", followUpItemRecordQuestion.getCode());
				ja.put(joTemp);
		}
		return ja;
	}
}

+ 0 - 138
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/followup/vo/FollowUpItemRecordAnswerVO.java

@ -1,138 +0,0 @@
package com.yihu.wlyy.web.patient.followup.vo;
import java.util.Date;
public class FollowUpItemRecordAnswerVO {
	// 随访计划标识
	private String plan;
	// 随访计划阶段标识
	private String stage;
	// 随访计划阶段随访项标识
	private String item;
	// 随访记录标识
	private String record;
	// 代填写医生标识
	private String doctor;
	// 代填写医生姓名
	private String doctorName;
	// 问题类型:1问卷,2体测
	private int type;
	// 体测指标类型:1血糖,2血压,3体重,4腰围
	private int index;
	// 问题标识
	private String question;
	// 选项标识
	private String option;
	// 回答内容
	private String answer;
	// 回答时间
	private Date czrq;
	// 非业务主键
	protected Long id;
	public String getPlan() {
		return plan;
	}
	public void setPlan(String plan) {
		this.plan = plan;
	}
	public String getStage() {
		return stage;
	}
	public void setStage(String stage) {
		this.stage = stage;
	}
	public String getItem() {
		return item;
	}
	public void setItem(String item) {
		this.item = item;
	}
	public String getRecord() {
		return record;
	}
	public void setRecord(String record) {
		this.record = record;
	}
	public String getDoctor() {
		return doctor;
	}
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}
	public String getDoctorName() {
		return doctorName;
	}
	public void setDoctorName(String doctorName) {
		this.doctorName = doctorName;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public int getIndex() {
		return index;
	}
	public void setIndex(int index) {
		this.index = index;
	}
	public String getQuestion() {
		return question;
	}
	public void setQuestion(String question) {
		this.question = question;
	}
	public String getOption() {
		return option;
	}
	public void setOption(String option) {
		this.option = option;
	}
	public String getAnswer() {
		return answer;
	}
	public void setAnswer(String answer) {
		this.answer = answer;
	}
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
}

+ 0 - 130
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/followup/vo/FollowUpItemRecordDetailVO.java

@ -1,130 +0,0 @@
package com.yihu.wlyy.web.patient.followup.vo;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class FollowUpItemRecordDetailVO {
	// 非业务主键
	protected Long id;
	// 随访记录标识
	private String code;
	// 随访计划标识
	private String plan;
	// 随访计划阶段标识
	private String stage;
	// 随访计划阶段随访项标识
	private String item;
	// 类型:1问卷,2体测
	private int type;
	// 标题
	private String title;
	// 状态:0进行中,1已完成
	private int status;
	// 生成日期
	private Date czrq;
	// 医生
	private String doctor;
	// 医生名字
	private String doctorName;
	List<FollowUpItemRecordQuestionVO> followUpItemRecordQuestionVO = new ArrayList<FollowUpItemRecordQuestionVO>();
	public Long getId() {
		return id;
	}
	public String getDoctor() {
		return doctor;
	}
	public String getDoctorName() {
		return doctorName;
	}
	public void setDoctorName(String doctorName) {
		this.doctorName = doctorName;
	}
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getPlan() {
		return plan;
	}
	public void setPlan(String plan) {
		this.plan = plan;
	}
	public String getStage() {
		return stage;
	}
	public void setStage(String stage) {
		this.stage = stage;
	}
	public String getItem() {
		return item;
	}
	public void setItem(String item) {
		this.item = item;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	public List<FollowUpItemRecordQuestionVO> getFollowUpItemRecordQuestionVO() {
		return followUpItemRecordQuestionVO;
	}
	public void setFollowUpItemRecordQuestionVO(
			List<FollowUpItemRecordQuestionVO> followUpItemRecordQuestionVO) {
		this.followUpItemRecordQuestionVO = followUpItemRecordQuestionVO;
	}
}

+ 0 - 71
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/followup/vo/FollowUpItemRecordQuestionOptionVO.java

@ -1,71 +0,0 @@
package com.yihu.wlyy.web.patient.followup.vo;
public class FollowUpItemRecordQuestionOptionVO {
	// 非业务主键
	protected Long id;
	// 随访项标识
	private String code;
	// 随访计划标识
	private String plan;
	// 随访计划阶段标识
	private String stage;
	// 随访计划阶段随访项标识
	private String item;
	// 问题标识(关联wlyy_followup_item_record_question表的code)
	private String record;
	// 随访项标识
	private String question;
	// 选项描述
	private String des;
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getPlan() {
		return plan;
	}
	public void setPlan(String plan) {
		this.plan = plan;
	}
	public String getStage() {
		return stage;
	}
	public void setStage(String stage) {
		this.stage = stage;
	}
	public String getItem() {
		return item;
	}
	public void setItem(String item) {
		this.item = item;
	}
	public String getRecord() {
		return record;
	}
	public void setRecord(String record) {
		this.record = record;
	}
	public String getQuestion() {
		return question;
	}
	public void setQuestion(String question) {
		this.question = question;
	}
	public String getDes() {
		return des;
	}
	public void setDes(String des) {
		this.des = des;
	}
	
	
}

+ 0 - 91
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/followup/vo/FollowUpItemRecordQuestionVO.java

@ -1,91 +0,0 @@
package com.yihu.wlyy.web.patient.followup.vo;
import java.util.ArrayList;
import java.util.List;
public class FollowUpItemRecordQuestionVO {
	// 随访项标识
	private String code;
	// 随访计划标识
	private String plan;
	// 随访计划阶段标识
	private String stage;
	// 随访计划阶段随访项标识
	private String item;
	// 随访记录标识
	private String record;
	// 问题标题
	private String title;
	// 问题类型:1单选,2多选,3问答
	private int type;
	// 体测指标类型:1血糖,2血压,3体重,4腰围
	private int index;
	//选择项
	private List<FollowUpItemRecordQuestionOptionVO> followUpItemRecordQuestionOptions = new ArrayList<FollowUpItemRecordQuestionOptionVO>();
    //答案
	private List<FollowUpItemRecordAnswerVO> followUpItemRecordAnswerVOs= new ArrayList<FollowUpItemRecordAnswerVO>();
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getPlan() {
		return plan;
	}
	public void setPlan(String plan) {
		this.plan = plan;
	}
	public String getStage() {
		return stage;
	}
	public void setStage(String stage) {
		this.stage = stage;
	}
	public String getItem() {
		return item;
	}
	public void setItem(String item) {
		this.item = item;
	}
	public String getRecord() {
		return record;
	}
	public void setRecord(String record) {
		this.record = record;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public int getIndex() {
		return index;
	}
	public void setIndex(int index) {
		this.index = index;
	}
	public List<FollowUpItemRecordQuestionOptionVO> getFollowUpItemRecordQuestionOptions() {
		return followUpItemRecordQuestionOptions;
	}
	public void setFollowUpItemRecordQuestionOptions(
			List<FollowUpItemRecordQuestionOptionVO> followUpItemRecordQuestionOptions) {
		this.followUpItemRecordQuestionOptions = followUpItemRecordQuestionOptions;
	}
	public List<FollowUpItemRecordAnswerVO> getFollowUpItemRecordAnswerVOs() {
		return followUpItemRecordAnswerVOs;
	}
	public void setFollowUpItemRecordAnswerVOs(
			List<FollowUpItemRecordAnswerVO> followUpItemRecordAnswerVOs) {
		this.followUpItemRecordAnswerVOs = followUpItemRecordAnswerVOs;
	}
	
	
}

+ 0 - 129
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/followup/vo/FollowUpItemRecordVO.java

@ -1,129 +0,0 @@
package com.yihu.wlyy.web.patient.followup.vo;
import java.util.Date;
public class FollowUpItemRecordVO {
	// 非业务主键
	protected Long id;
	// 计划标识
	private String code;
	// 随访计划标识
	private String plan;
	// 随访计划阶段标识
	private String stage;
	// 类型:1定时,2不定时
	private int type;
	// 标题
	private String title;
	// 推送类型:1按时间,2按次数
	private int pushType;
	// 推送次数
	private int pushTimes;
	// 推送周期
	private int pushCycle;
	// 推送周期单位:1天,2周,3月
	private int pushCycleUnit;
	// 下一次推送日期
	private Date nextPushDate;
	// 推送开始日期
	private Date pushBegin;
	// 推送结束日期
	private Date pushEnd;
	// 执行状态:-1暂停,0未开始,1进行中,2已结束
	private int status;
	// 添加时间
	private Date czrq;
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getPlan() {
		return plan;
	}
	public void setPlan(String plan) {
		this.plan = plan;
	}
	public String getStage() {
		return stage;
	}
	public void setStage(String stage) {
		this.stage = stage;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public int getPushType() {
		return pushType;
	}
	public void setPushType(int pushType) {
		this.pushType = pushType;
	}
	public int getPushTimes() {
		return pushTimes;
	}
	public void setPushTimes(int pushTimes) {
		this.pushTimes = pushTimes;
	}
	public int getPushCycle() {
		return pushCycle;
	}
	public void setPushCycle(int pushCycle) {
		this.pushCycle = pushCycle;
	}
	public int getPushCycleUnit() {
		return pushCycleUnit;
	}
	public void setPushCycleUnit(int pushCycleUnit) {
		this.pushCycleUnit = pushCycleUnit;
	}
	public Date getNextPushDate() {
		return nextPushDate;
	}
	public void setNextPushDate(Date nextPushDate) {
		this.nextPushDate = nextPushDate;
	}
	public Date getPushBegin() {
		return pushBegin;
	}
	public void setPushBegin(Date pushBegin) {
		this.pushBegin = pushBegin;
	}
	public Date getPushEnd() {
		return pushEnd;
	}
	public void setPushEnd(Date pushEnd) {
		this.pushEnd = pushEnd;
	}
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	
	
}

+ 0 - 127
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/followup/vo/FollowUpPlanStageItemVO.java

@ -1,127 +0,0 @@
package com.yihu.wlyy.web.patient.followup.vo;
import java.util.Date;
public class FollowUpPlanStageItemVO {
	// 非业务主键
	protected Long id;
	// 计划标识
	private String code;
	// 随访计划标识
	private String plan;
	// 随访计划阶段标识
	private String stage;
	// 类型:1定时,2不定时
	private int type;
	// 标题
	private String title;
	// 推送类型:1按时间,2按次数
	private int pushType;
	// 推送次数
	private int pushTimes;
	// 推送周期
	private int pushCycle;
	// 推送周期单位:1天,2周,3月
	private int pushCycleUnit;
	// 下一次推送日期
	private Date nextPushDate;
	// 推送开始日期
	private Date pushBegin;
	// 推送结束日期
	private Date pushEnd;
	// 执行状态:-1暂停,0进行中,1已结束
	private int status;
	// 添加时间
	private Date czrq;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getPlan() {
		return plan;
	}
	public void setPlan(String plan) {
		this.plan = plan;
	}
	public String getStage() {
		return stage;
	}
	public void setStage(String stage) {
		this.stage = stage;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public int getPushType() {
		return pushType;
	}
	public void setPushType(int pushType) {
		this.pushType = pushType;
	}
	public int getPushTimes() {
		return pushTimes;
	}
	public void setPushTimes(int pushTimes) {
		this.pushTimes = pushTimes;
	}
	public int getPushCycle() {
		return pushCycle;
	}
	public void setPushCycle(int pushCycle) {
		this.pushCycle = pushCycle;
	}
	public int getPushCycleUnit() {
		return pushCycleUnit;
	}
	public void setPushCycleUnit(int pushCycleUnit) {
		this.pushCycleUnit = pushCycleUnit;
	}
	public Date getNextPushDate() {
		return nextPushDate;
	}
	public void setNextPushDate(Date nextPushDate) {
		this.nextPushDate = nextPushDate;
	}
	public Date getPushBegin() {
		return pushBegin;
	}
	public void setPushBegin(Date pushBegin) {
		this.pushBegin = pushBegin;
	}
	public Date getPushEnd() {
		return pushEnd;
	}
	public void setPushEnd(Date pushEnd) {
		this.pushEnd = pushEnd;
	}
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
}

+ 0 - 147
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/followup/vo/FollowupPlanVO.java

@ -1,147 +0,0 @@
package com.yihu.wlyy.web.patient.followup.vo;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class FollowupPlanVO {
	// 非业务主键
	protected Long id;
	// 计划标识
	private String code;
	// 标题/随访计划名称
	private String title;
	// 医生标识
	private String doctor;
	// 医生姓名
	private String doctorName;
	// 医生头像
	private String doctorPhoto;
	// 三师团队标识
	private String team;
	// 患者标识
	private String patient;
	// 患者姓名
	private String patientName;
	// 计划状态:-1暂停,0进行中,1已结束
	private int status;
	// 总问卷随访数
	private int wjAmount;
	// 已完成问卷随访数
	private int wjFinishAmount;
	// 总体测随访数
	private int tcAmount;
	// 已完成体测随访数
	private int tcFinishAmount;
	// 添加时间
	private Date czrq;
	// 随访记录
	private List<FollowUpPlanStageItemVO> followUpPlanStageItemVO = new ArrayList<FollowUpPlanStageItemVO>();
	// 随访周期纪录
	private List<FollowUpItemRecordVO> followUpItemRecordVO = new ArrayList<FollowUpItemRecordVO>();
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getDoctor() {
		return doctor;
	}
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}
	public String getDoctorName() {
		return doctorName;
	}
	public void setDoctorName(String doctorName) {
		this.doctorName = doctorName;
	}
	public String getTeam() {
		return team;
	}
	public void setTeam(String team) {
		this.team = team;
	}
	public String getPatient() {
		return patient;
	}
	public void setPatient(String patient) {
		this.patient = patient;
	}
	public String getPatientName() {
		return patientName;
	}
	public void setPatientName(String patientName) {
		this.patientName = patientName;
	}
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}
	public int getWjAmount() {
		return wjAmount;
	}
	public void setWjAmount(int wjAmount) {
		this.wjAmount = wjAmount;
	}
	public int getWjFinishAmount() {
		return wjFinishAmount;
	}
	public void setWjFinishAmount(int wjFinishAmount) {
		this.wjFinishAmount = wjFinishAmount;
	}
	public int getTcAmount() {
		return tcAmount;
	}
	public void setTcAmount(int tcAmount) {
		this.tcAmount = tcAmount;
	}
	public int getTcFinishAmount() {
		return tcFinishAmount;
	}
	public void setTcFinishAmount(int tcFinishAmount) {
		this.tcFinishAmount = tcFinishAmount;
	}
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	public List<FollowUpPlanStageItemVO> getFollowUpPlanStageItemVO() {
		return followUpPlanStageItemVO;
	}
	public void setFollowUpPlanStageItemVO(
			List<FollowUpPlanStageItemVO> followUpPlanStageItemVO) {
		this.followUpPlanStageItemVO = followUpPlanStageItemVO;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public List<FollowUpItemRecordVO> getFollowUpItemRecordVO() {
		return followUpItemRecordVO;
	}
	public void setFollowUpItemRecordVO(
			List<FollowUpItemRecordVO> followUpItemRecordVO) {
		this.followUpItemRecordVO = followUpItemRecordVO;
	}
	public String getDoctorPhoto() {
		return doctorPhoto;
	}
	public void setDoctorPhoto(String doctorPhoto) {
		this.doctorPhoto = doctorPhoto;
	}
	
}

+ 0 - 369
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthRecordController.java

@ -1,369 +0,0 @@
package com.yihu.wlyy.web.patient.health;
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.dict.Medicines;
import com.yihu.wlyy.entity.patient.PatientHealthRecordDiet;
import com.yihu.wlyy.entity.patient.PatientHealthRecordMedication;
import com.yihu.wlyy.entity.patient.PatientHealthRecordSports;
import com.yihu.wlyy.entity.education.Sports;
import com.yihu.wlyy.entity.education.SportsType;
import com.yihu.wlyy.service.app.health.PatientHealthRecordService;
import com.yihu.wlyy.service.app.medicines.MedicinesService;
import com.yihu.wlyy.service.app.sports.SportsService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.WeixinBaseController;
/**
 * 健康记录控制类
 * @author George
 *
 */
@Controller
@RequestMapping(value = "/patient/health_record", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "患者端-健康记录")
public class PatientHealthRecordController extends WeixinBaseController {
	@Autowired
	private SportsService sportsService;
	@Autowired
	private MedicinesService medicinesService;
	@Autowired
	private PatientHealthRecordService patientHealthRecordService;
	/**
	 * 运动强度查询接口
	 * @return
	 */
	@RequestMapping(value = "sports_type")
	@ResponseBody
	public String sportsType() {
		try {
			JSONArray array = new JSONArray();
			List<SportsType> list = sportsService.finsAllSportsType();
			if (list != null) {
				for (SportsType temp : list) {
					if (temp == null) {
						continue;
					}
					JSONObject json = new JSONObject();
					json.put("code", temp.getCode());
					json.put("name", temp.getName());
					array.put(json);
				}
			}
			return write(200, "查询成功", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败");
		}
	}
	/**
	 * 运动类型查询接口
	 * @return
	 */
	@RequestMapping(value = "sports")
	@ResponseBody
	public String sports() {
		try {
			JSONArray array = new JSONArray();
			List<Sports> list = sportsService.finsAllSports();
			if (list != null) {
				for (Sports temp : list) {
					if (temp == null) {
						continue;
					}
					JSONObject json = new JSONObject();
					json.put("code", temp.getCode());
					json.put("name", temp.getName());
					array.put(json);
				}
			}
			return write(200, "查询成功", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败");
		}
	}
	/**
	 * 查询药品列表
	 * @return
	 */
	@RequestMapping(value = "medicines")
	@ResponseBody
	public String medicines() {
		try {
			JSONArray array = new JSONArray();
			List<Medicines> list = medicinesService.findAllMedicines(1);
			if (list != null) {
				for (Medicines temp : list) {
					if (temp == null) {
						continue;
					}
					JSONObject json = new JSONObject();
					json.put("code", temp.getCode());
					json.put("name", temp.getName());
					array.put(json);
				}
			}
			return write(200, "查询成功", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败");
		}
	}
	/**
	 * 添加运动记录
	 * @param record_date 记录时间
	 * @param sportsTime 运动时长(分)
	 * @param sportsType 运动强度标识
	 * @param sports 运动类型标识
	 * @return
	 */
	@RequestMapping(value = "add_sports")
	@ResponseBody
	public String addSports(String record_date, double sportsTime, String sportsType, String sports) {
		try {
			PatientHealthRecordSports record = new PatientHealthRecordSports();
			record.setDel("1");
			record.setCzrq(new Date());
			record.setPatient(getUID());
			record.setRecordDate(DateUtil.strToDateShort(record_date));
			record.setSortDate(DateUtil.strToDateAppendNowTime(record_date, DateUtil.YYYY_MM_DD_HH_MM_SS));
			record.setSportsTime(sportsTime);
			if (patientHealthRecordService.addSports(record, sportsType, sports) != null) {
				return success("保存成功");
			} else {
				return error(-1, "保存失败");
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "保存失败");
		}
	}
	/**
	 * 添加用药记录
	 * @param record_date 记录时间
	 * @param medicines 药品标识
	 * @param medicines_name 药品名称
	 * @return
	 */
	@RequestMapping(value = "add_medication")
	@ResponseBody
	public String addMedication(String record_date, String medicines, String medicines_name) {
		try {
			PatientHealthRecordMedication record = new PatientHealthRecordMedication();
			record.setDel("1");
			record.setCzrq(new Date());
			record.setPatient(getUID());
			record.setRecordDate(DateUtil.strToDateShort(record_date));
			record.setSortDate(DateUtil.strToDateAppendNowTime(record_date, DateUtil.YYYY_MM_DD_HH_MM_SS));
			record.setMedicines(medicines);
			record.setMedicinesName(medicines_name);
			if (patientHealthRecordService.addMedication(record) != null) {
				return success("保存成功");
			} else {
				return error(-1, "保存失败");
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "保存失败");
		}
	}
	/**
	 * 添加饮食记录接口
	 * @param record_date 记录时间
	 * @param content 饮食内容
	 * @param images 图片HTTP地址,多图以逗号分隔
	 * @return
	 */
	@RequestMapping(value = "add_diet")
	@ResponseBody
	public String add(String record_date, String content, @RequestParam(required = false) String images) {
		try {
			PatientHealthRecordDiet record = new PatientHealthRecordDiet();
			record.setDel("1");
			record.setCzrq(new Date());
			record.setPatient(getUID());
			record.setRecordDate(DateUtil.strToDateShort(record_date));
			record.setSortDate(DateUtil.strToDateAppendNowTime(record_date, DateUtil.YYYY_MM_DD_HH_MM_SS));
			record.setContent(content);
			// 从微信服务器获取图片
			if (StringUtils.isEmpty(images)) {
				images = fetchWxImages();
			}
			if (StringUtils.isNotEmpty(images)) {
				images = CommonUtil.copyTempImage(images);
			}
			record.setImages(images);
			if (patientHealthRecordService.addDiet(record) != null) {
				return success("保存成功");
			} else {
				return error(-1, "保存失败");
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "保存失败");
		}
	}
	/**
	 * 最近填写的运动、用药、饮食内容
	 * @return
	 */
	@RequestMapping(value = "recent")
	@ResponseBody
	public String recent() {
		try {
			JSONObject json = patientHealthRecordService.findRecentByPatient(getUID());
			if (json != null) {
				return write(200, "查询成功", "data", json);
			} else {
				return error(-1, "查询失败");
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败");
		}
	}
	/**
	 * 运动记录查询接口
	 * @param pagesize 分页大小
	 * @return
	 */
	@RequestMapping(value = "list_sports")
	@ResponseBody
	public String sports(String start,String end,int page, int pagesize) {
		try {
			Page<PatientHealthRecordSports> data = patientHealthRecordService.findSportsByPatientPage(getUID(), start,end,page, pagesize);
			if (data != null) {
				JSONArray array = new JSONArray();
				for (PatientHealthRecordSports record : data) {
					if (record == null) {
						continue;
					}
					JSONObject json = new JSONObject();
					json.put("id", record.getId());
					// 设置记录标识
					json.put("code", record.getCode());
					// 设置记录日期
					json.put("record_date", DateUtil.dateToStrShort(record.getRecordDate()));
					json.put("sortDate", DateUtil.dateToStrLong(record.getSortDate()));
					// 设置运动时长(分钟)
					json.put("sports_time", record.getSportsTime());
					// 设置运动强度
					json.put("sports_type", record.getSportsTypeName());
					// 设置运动类型
					json.put("sports", record.getSportsName());
					array.put(json);
				}
				return write(200, "查询成功", "list", array);
			} else {
				return error(-1, "查询失败");
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败");
		}
	}
	/**
	 * 用药记录查询接口
	 * @param pagesize 分页大小
	 * @return
	 */
	@RequestMapping(value = "list_medication")
	@ResponseBody
	public String medication(String start,String end,int page, int pagesize) {
		try {
			Page<PatientHealthRecordMedication> data = patientHealthRecordService.findMedicalByPatientPage(getUID(), start, end, page, pagesize);
			if (data != null) {
				JSONArray array = new JSONArray();
				for (PatientHealthRecordMedication record : data) {
					if (record == null) {
						continue;
					}
					JSONObject json = new JSONObject();
					json.put("id", record.getId());
					// 设置记录标识
					json.put("code", record.getCode());
					// 设置记录日期
					json.put("record_date", DateUtil.dateToStrShort(record.getRecordDate()));
					json.put("sortDate", DateUtil.dateToStrLong(record.getSortDate()));
					// 药品名称
					json.put("medicines", record.getMedicinesName());
					array.put(json);
				}
				return write(200, "查询成功", "list", array);
			} else {
				return error(-1, "查询失败");
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败");
		}
	}
	/**
	 * 饮食记录查询接口
	 * @param pagesize 分页大小
	 * @return
	 */
	@RequestMapping(value = "list_diet")
	@ResponseBody
	public String diet(String start,String end,int page,int pagesize) {
		try {
			Page<PatientHealthRecordDiet> data = patientHealthRecordService.findDietByPatientPage(getUID(),start,end,page, pagesize);
			if (data != null) {
				JSONArray array = new JSONArray();
				for (PatientHealthRecordDiet record : data) {
					if (record == null) {
						continue;
					}
					JSONObject json = new JSONObject();
					json.put("id", record.getId());
					// 设置记录标识
					json.put("code", record.getCode());
					// 设置记录日期
					json.put("record_date", DateUtil.dateToStrShort(record.getRecordDate()));
					json.put("sortDate", DateUtil.dateToStrLong(record.getSortDate()));
					// 设置饮食内容
					json.put("content", record.getContent());
					// 设置图片URL,多图以逗号分隔
					json.put("images", record.getImages());
					array.put(json);
				}
				return write(200, "查询成功", "list", array);
			} else {
				return error(-1, "查询失败");
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败");
		}
	}
}