瀏覽代碼

Merge branch 'dev' of zd_123/patient-co-management into dev

trick9191 7 年之前
父節點
當前提交
b6d336c1d5
共有 19 個文件被更改,包括 968 次插入822 次删除
  1. 51 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyAdvice.java
  2. 11 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyOptionAnswers.java
  3. 58 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyScreenResult.java
  4. 42 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyTemplateAdvice.java
  5. 10 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyTemplateOptions.java
  6. 143 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyTemplateResult.java
  7. 19 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyTemplates.java
  8. 17 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyAdviceDao.java
  9. 3 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyOptionAnswersDao.java
  10. 13 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyScreenResultDao.java
  11. 18 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyTemplateAdviceDao.java
  12. 18 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyTemplateResultDao.java
  13. 260 173
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/survey/SurveyScreenResultService.java
  14. 74 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/ManagerQuestionnaireService.java
  15. 0 84
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/DoctorQuestionnaireController.java
  16. 158 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/DoctorSurveyScreenResultController.java
  17. 40 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/ManagerQuestionnaireController.java
  18. 0 563
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/SurveyScreenResultController.java
  19. 33 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/survey/PatientQuestionnaireController.java

+ 51 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyAdvice.java

@ -0,0 +1,51 @@
package com.yihu.wlyy.entity.doctor.survey;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by hmf on 2018/7/4.
 */
@Entity
@Table(name = "wlyy_survey_advice")
public class SurveyAdvice extends IdEntity {
    private String code;
    private String advice;//建议内容
    private Date czrq;//创建时间
    private Integer diseaseType;//疾病类型
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getAdvice() {
        return advice;
    }
    public void setAdvice(String advice) {
        this.advice = advice;
    }
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
    public Integer getDiseaseType() {
        return diseaseType;
    }
    public void setDiseaseType(Integer diseaseType) {
        this.diseaseType = diseaseType;
    }
}

+ 11 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyOptionAnswers.java

@ -33,6 +33,9 @@ public class SurveyOptionAnswers extends IdEntity implements Serializable {
//    用户openId
    private String openId;
    //筛查结果code
    private String screenResultCode;
    public SurveyOptionAnswers() {
    }
@ -131,4 +134,12 @@ public class SurveyOptionAnswers extends IdEntity implements Serializable {
    public void setOpenId(String openId) {
        this.openId = openId;
    }
    public String getScreenResultCode() {
        return screenResultCode;
    }
    public void setScreenResultCode(String screenResultCode) {
        this.screenResultCode = screenResultCode;
    }
}

+ 58 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyScreenResult.java

@ -32,14 +32,20 @@ public class SurveyScreenResult extends IdEntity implements Serializable{
    private String openId;
    //居民名字
    private String patientName;
    //筛查结果设置中相关code
    private String screenResultCode;
    //筛查结果分值
    private int screenResultScore;
    //筛查结果
    private String screenResult;
    //是否高危预警(0不是  1是)
    private int isDanger;
    //是否预约(0未预约 1已预约)
    private int order;
    //是否跟踪(0未跟踪 1已跟踪)
    private int following;
    //是否进行健康教育(0没有  1有)
    private int isEducate;
    //是否完成(0未完成 1已完成)
    private int over;
    //预约记录code
@ -56,11 +62,15 @@ public class SurveyScreenResult extends IdEntity implements Serializable{
    private String adviceCode;
    //其他建议
    private String otherAdvice;
    //来源(1医生发放  2居民自我评估)
    private int source;
    //更新时间
    private Date updateTime;
    public SurveyScreenResult() {
    }
    public SurveyScreenResult(String code, String templateCode, String templateTitle, int disease, String doctor, String patientCode, String openId, String patientName, int screenResultScore, String screenResult, int order, int following, int over, String reservationCode, Date czrq, int isAgain, String parentCode, String originCode, String adviceCode, String otherAdvice) {
    public SurveyScreenResult(String code, String templateCode, String templateTitle, int disease, String doctor, String patientCode, String openId, String patientName, int screenResultScore, String screenResult, int isDanger, int order, int following, int over, String reservationCode, Date czrq, int isAgain, String parentCode, String originCode, String adviceCode, String otherAdvice) {
        this.code = code;
        this.templateCode = templateCode;
        this.templateTitle = templateTitle;
@ -71,6 +81,7 @@ public class SurveyScreenResult extends IdEntity implements Serializable{
        this.patientName = patientName;
        this.screenResultScore = screenResultScore;
        this.screenResult = screenResult;
        this.isDanger = isDanger;
        this.order = order;
        this.following = following;
        this.over = over;
@ -155,6 +166,15 @@ public class SurveyScreenResult extends IdEntity implements Serializable{
        this.patientName = patientName;
    }
    @Column(name = "screen_result_code")
    public String getScreenResultCode() {
        return screenResultCode;
    }
    public void setScreenResultCode(String screenResultCode) {
        this.screenResultCode = screenResultCode;
    }
    @Column(name = "screen_result_score")
    public int getScreenResultScore() {
        return screenResultScore;
@ -173,6 +193,15 @@ public class SurveyScreenResult extends IdEntity implements Serializable{
        this.screenResult = screenResult;
    }
    @Column(name = "is_danger")
    public int getIsDanger() {
        return isDanger;
    }
    public void setIsDanger(int isDanger) {
        this.isDanger = isDanger;
    }
    @Column(name = "order")
    public int getOrder() {
        return order;
@ -191,6 +220,15 @@ public class SurveyScreenResult extends IdEntity implements Serializable{
        this.following = following;
    }
    @Column(name = "is_educate")
    public int getIsEducate() {
        return isEducate;
    }
    public void setIsEducate(int isEducate) {
        this.isEducate = isEducate;
    }
    @Column(name = "over")
    public int getOver() {
        return over;
@ -263,4 +301,23 @@ public class SurveyScreenResult extends IdEntity implements Serializable{
    public void setOtherAdvice(String otherAdvice) {
        this.otherAdvice = otherAdvice;
    }
    @Column(name = "source")
    public int getSource() {
        return source;
    }
    public void setSource(int source) {
        this.source = source;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "update_time")
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}

+ 42 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyTemplateAdvice.java

@ -0,0 +1,42 @@
package com.yihu.wlyy.entity.doctor.survey;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by hmf on 2018/7/4.
 */
@Entity
@Table(name = "wlyy_survey_template_advice")
public class SurveyTemplateAdvice extends IdEntity {
    private String templateCode;//关联的筛查模板code
    private String adviceCode;//建议code
    private Date czrq;//创建时间
    public String getTemplateCode() {
        return templateCode;
    }
    public void setTemplateCode(String templateCode) {
        this.templateCode = templateCode;
    }
    public String getAdviceCode() {
        return adviceCode;
    }
    public void setAdviceCode(String adviceCode) {
        this.adviceCode = adviceCode;
    }
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
}

+ 10 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyTemplateOptions.java

@ -33,6 +33,8 @@ public class SurveyTemplateOptions extends IdEntity implements Serializable {
    private Integer sort;
    //    删除标志(1正常,0删除)
    private Integer del;
    //评分
    private Integer score;
    public SurveyTemplateOptions() {
    }
@ -129,4 +131,12 @@ public class SurveyTemplateOptions extends IdEntity implements Serializable {
    public void setDel(Integer del) {
        this.del = del;
    }
    public Integer getScore() {
        return score;
    }
    public void setScore(Integer score) {
        this.score = score;
    }
}

+ 143 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyTemplateResult.java

@ -0,0 +1,143 @@
package com.yihu.wlyy.entity.doctor.survey;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 问卷调查模板评分筛查表
 * Created by hmf on 2018/7/3.
 */
@Entity
@Table(name = "wlyy_survey_template_result")
public class SurveyTemplateResult extends IdEntity {
    private static final long serialVersionUID = 1L;
    private String code;//筛选结果编码
    private String templateCode;//模板编码
    private Integer lowScore;//分值范围低分
    private Integer highScore;//分值范围高分
    private String result;//分析结果
    private String advice;//筛查建议
    private Integer warning;//是否高危预警(1是,0否)
    private Integer del;//删除标志(1正常,0删除)
    private Date createTime;             //创建时间
    private String createUser;
    private String createUserName;
    private String updateUser;
    private String updateUserName;
    private Date updateTime;//修改时间
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getTemplateCode() {
        return templateCode;
    }
    public void setTemplateCode(String templateCode) {
        this.templateCode = templateCode;
    }
    public Integer getLowScore() {
        return lowScore;
    }
    public void setLowScore(Integer lowScore) {
        this.lowScore = lowScore;
    }
    public Integer getHighScore() {
        return highScore;
    }
    public void setHighScore(Integer highScore) {
        this.highScore = highScore;
    }
    public String getResult() {
        return result;
    }
    public void setResult(String result) {
        this.result = result;
    }
    public String getAdvice() {
        return advice;
    }
    public void setAdvice(String advice) {
        this.advice = advice;
    }
    public Integer getWarning() {
        return warning;
    }
    public void setWarning(Integer warning) {
        this.warning = warning;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    public String getUpdateUser() {
        return updateUser;
    }
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }
    public String getUpdateUserName() {
        return updateUserName;
    }
    public void setUpdateUserName(String updateUserName) {
        this.updateUserName = updateUserName;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}

+ 19 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyTemplates.java

@ -20,6 +20,8 @@ public class SurveyTemplates extends IdEntity implements Serializable{
    private  String title;
//    模板说明
    private String templateComment;
    private Integer diseaseType;//疾病类型,对应专病code
    private String organization;//发布机构
//    创建人(医生编码)
    private String creater;
//    删除标志(1正常,0删除)
@ -29,6 +31,7 @@ public class SurveyTemplates extends IdEntity implements Serializable{
//修改时间
    private  Date updateTime;
    public SurveyTemplates() {
    }
@ -97,4 +100,20 @@ public class SurveyTemplates extends IdEntity implements Serializable{
    public void setDel(int del) {
        this.del = del;
    }
    public Integer getDiseaseType() {
        return diseaseType;
    }
    public void setDiseaseType(Integer diseaseType) {
        this.diseaseType = diseaseType;
    }
    public String getOrganization() {
        return organization;
    }
    public void setOrganization(String organization) {
        this.organization = organization;
    }
}

+ 17 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyAdviceDao.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.survey.SurveyAdvice;
import com.yihu.wlyy.entity.doctor.survey.SurveyTemplateAdvice;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by zhangdan on 2018/7/4.
 */
public interface SurveyAdviceDao extends PagingAndSortingRepository<SurveyAdvice, Long> {
    @Query("select a from SurveyAdvice a where a.code=?1")
    SurveyAdvice getByCode(String code);
}

+ 3 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyOptionAnswersDao.java

@ -20,4 +20,7 @@ public interface SurveyOptionAnswersDao extends PagingAndSortingRepository<Surve
    @Query("select  count(distinct  t.patient) from SurveyOptionAnswers t where t.surveyCode =?1 and t.questionCode=?2 ")
    int countByRelationCode(String id, String questionId);
    @Query("select a from  SurveyOptionAnswers a where a.patient=?1 and a.surveyCode=?2")
    List<SurveyOptionAnswers> getBySurveyCodeAndPatient(String patient,String surveyCode);
}

+ 13 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyScreenResultDao.java

@ -1,6 +1,8 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.survey.SurveyScreenResult;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
@ -9,5 +11,16 @@ import java.util.List;
 * Created by zhangdan on 2018/7/2.
 */
public interface SurveyScreenResultDao extends PagingAndSortingRepository<SurveyScreenResult, Long> {
    @Query("select surveyScreenResult from SurveyScreenResult surveyScreenResult where surveyScreenResult.code=?1")
    SurveyScreenResult getSurveyScreenResultByCode(String code);
    @Query(nativeQuery = true, value = "SELECT * FROM `wlyy_survey_screen_result` WHERE template_code=?1 ORDER BY czrq DESC LIMIT 1")
    List<SurveyScreenResult> findNewOneByTemplateCode(String templateCode);
    @Query("select a from  SurveyScreenResult a where a.parentCode=?1 and a.templateCode=?2")
    List<SurveyScreenResult> getByPatientCodeAndTemplateCode(String patientCode,String templateCode);
    @Modifying
    @Query("update SurveyScreenResult s set s.isAgain=0 where s.code=?1")
    void updateNoAgain(String code);
}

+ 18 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyTemplateAdviceDao.java

@ -0,0 +1,18 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.survey.SurveyScreenResult;
import com.yihu.wlyy.entity.doctor.survey.SurveyTemplateAdvice;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by zhangdan on 2018/7/4.
 */
public interface SurveyTemplateAdviceDao extends PagingAndSortingRepository<SurveyTemplateAdvice, Long> {
    @Query("select a from SurveyTemplateAdvice a where a.templateCode=?1")
    List<SurveyTemplateAdvice> getByTemplateCode(String code);
}

+ 18 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyTemplateResultDao.java

@ -0,0 +1,18 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.survey.SurveyScreenResult;
import com.yihu.wlyy.entity.doctor.survey.SurveyTemplateResult;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by zhangdan on 2018/7/4.
 */
public interface SurveyTemplateResultDao extends PagingAndSortingRepository<SurveyTemplateResult, Long> {
    @Query("select a from SurveyTemplateResult a where a.templateCode=?1 and a.lowScore<=?2 and a.highScore>=?2")
    SurveyTemplateResult getByTemplateCodeAndLowScoreAndHighScore (String template,int score);
}

+ 260 - 173
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/survey/SurveyScreenResultService.java

@ -1,8 +1,14 @@
package com.yihu.wlyy.service.app.survey;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.survey.*;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.doctor.*;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.survey.ManagerQuestionnaireService;
import com.yihu.wlyy.util.IdCardUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -23,28 +29,42 @@ import java.util.*;
@Transactional
public class SurveyScreenResultService extends BaseService {
    @Autowired
    private SurveyQuestionnaireDao surveyQuestionnaireDao;
    SurveyStatisticsDao surveyStatisticsDao;
    @Autowired
    private SurveyQuestionnaireOptionsDao surveyQuestionnaireOptionsDao;
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private SurveyDao surveyDao;
    private SurveyTemplatesDao surveyTemplatesDao;
    @Autowired
    private SurveyUserDao surveyUserDao;
    private PatientDao patientDao;
    @Autowired
    private SurveyOptionAnswersDao surveyOptionAnswersDao;
    private SurveyScreenResultDao surveyScreenResultDao;
    @Autowired
    private SurveyAnswersDao surveyAnswersDao;
    private SurveyTemplateResultDao surveyTemplateResultDao;
    @Autowired
    SurveyStatisticsDao surveyStatisticsDao;
    private SurveyTemplateAdviceDao surveyTemplateAdviceDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    private SurveyTemplateQuestionsDao surveyTemplateQuestionsDao;
    @Autowired
    private SurveyTemplatesDao surveyTemplatesDao;
    private DoctorDao doctorDao;
    @Autowired
    private SurveyAdviceDao surveyAdviceDao;
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    /**
     * 筛查记录结果列表
     * @param pageNo
     * @param pageSize
     * @param doctor
     * @param diseaseType
     * @param dealType
     * @param isDanger
     * @param patientName
     * @return
     * @throws Exception
     */
    public Map<String,Object> getResultList(int pageNo, int pageSize,String doctor,String diseaseType,String dealType,String isDanger,String patientName) throws Exception {
        int start = (pageNo-1)*pageSize;
        String sql = "SELECT ssr.* FROM wlyy_survey_screen_result ssr WHERE 1=1 AND ssr.over = 1  and ssr.doctor='"+doctor+"'";
@ -78,6 +98,13 @@ public class SurveyScreenResultService extends BaseService {
    }
    /**
     * 筛查模板列表
     * @param pageNo
     * @param pageSize
     * @param labelType
     * @return
     */
    public List<SurveyTemplates> getScreenList(int pageNo,int pageSize,int labelType){
        int start = (pageNo-1)*pageSize;
        String sql = "SELECT st.* FROM wlyy_survey_templates st LEFT JOIN wlyy_survey_label_info sli ON st.`code`= sli.relation_code WHERE st.del = 1 and sli.label="+labelType+" limit "+start+","+pageSize;
@ -85,189 +112,249 @@ public class SurveyScreenResultService extends BaseService {
        return surveyTemplatesList;
    }
    public JSONObject getSurveySummary(String patient, String id) throws Exception {
        JSONObject jsonObject = new JSONObject();
        Survey survey = surveyDao.findById(id);
        int complete = surveyUserDao.findByPatient(patient, id);
        String title = survey.getTitle();
        String comment = survey.getSurveyComment();
        int status = survey.getStatus();
        jsonObject.put("title", title);
        jsonObject.put("comment", comment);
        jsonObject.put("status", status);
        jsonObject.put("complete", complete == 0 ? 0 : 1);
        return jsonObject;
    }
    /**
     * @param id   问卷id
     * @param sort 当前问题的sort(初始为1)
     * 保存筛查结果
     * @param patientCode
     * @param doctor
     * @param source
     * @param jsonData
     */
    public JSONObject getQuestions(String id, Integer sort) throws Exception {
        JSONObject jsonObject = new JSONObject();
        SurveyQuestionnaire question = null;
        //      该套问卷总题目数
        int total = surveyQuestionnaireDao.findTotalById(id);
        question = surveyQuestionnaireDao.findTotalByIdAndSort(id, sort);
        int sorts = question.getSort();
        String qstCode = question.getCode();
        String qstTitle = question.getTitle();
        int isRequired = question.getIsRequired();
        if (question.getQuestionCodeNext() != null) {
            String next = question.getQuestionCodeNext();
            SurveyQuestionnaire sq = surveyQuestionnaireDao.findByIdAndQstId(id, next);
            System.out.println("");
            jsonObject.put("nextQuestion", sq == null ? 0 : sq.getSort());
        }
        if (!StringUtils.isEmpty(question.getQuestionComment())) {
            jsonObject.put("comment", question.getQuestionComment());
        }
        int type = question.getQuestionType();
        switch (type) {
            case 0:
                List<SurveyQuestionnaireOptions> options = surveyQuestionnaireOptionsDao.findByIdAndQstCode(id, qstCode);
                List list = new ArrayList();
                for (SurveyQuestionnaireOptions option : options) {
//                        可构造集合,返回选项特定值
                    Map<String, Object> map = new HashMap<>();
                    String content = option.getContent();
                    int optSort = option.getSort();
                    int required = option.getIsRequired();
                    String surCod = option.getSurveyCode();
                    int del = option.getDel();
                    int havaComment = option.getHaveComment();
                    String code = option.getCode();
                    String questionCode = option.getQuestionnaireCode();
                    long optid = option.getId();
                    map.put("content", content);
                    map.put("isRequired", required);
                    map.put("code", code);
                    map.put("del", del);
                    map.put("sort", optSort);
                    map.put("surveyCode", surCod);
                    map.put("havaComment", havaComment);
                    map.put("questionnaireCode", questionCode);
                    map.put("id", optid);
                    if (option.getQuestionCodeNext() != null) {
                        String next = option.getQuestionCodeNext();
                        SurveyQuestionnaire sq = surveyQuestionnaireDao.findByIdAndQstId(id, next);
                        map.put("nextQuestion", sq == null ? 0 : sq.getSort());
                    }
                    list.add(map);
                }
                jsonObject.put("options", list);
                break;
            case 1:
                List<SurveyQuestionnaireOptions> optionss = surveyQuestionnaireOptionsDao.findByIdAndQstCode(id, qstCode);
                List lis = new ArrayList();
                for (SurveyQuestionnaireOptions option : optionss) {
//                        可构造集合,返回选项特定值
                    Map<String, Object> map = new HashMap<>();
                    String content = option.getContent();
                    int optSort = option.getSort();
                    int required = option.getIsRequired();
                    String surCod = option.getSurveyCode();
                    int del = option.getDel();
                    int havaComment = option.getHaveComment();
                    String code = option.getCode();
                    String questionCode = option.getQuestionnaireCode();
                    long optid = option.getId();
                    map.put("content", content);
                    map.put("isRequired", required);
                    map.put("code", code);
                    map.put("del", del);
                    map.put("sort", optSort);
                    map.put("surveyCode", surCod);
                    map.put("havaComment", havaComment);
                    map.put("questionnaireCode", questionCode);
                    map.put("id", optid);
                    if (option.getQuestionCodeNext() != null) {
                        String next = option.getQuestionCodeNext();
                        SurveyQuestionnaire sq = surveyQuestionnaireDao.findByIdAndQstId(id, next);
                        map.put("nextQuestion", sq == null ? 0 : sq.getSort());
                    }
                    lis.add(map);
                }
                jsonObject.put("options", lis);
                Integer maxNum = question.getMaxNum();
                Integer minNum = question.getMinNum();
                jsonObject.put("maxNum", maxNum);
                jsonObject.put("minNum", minNum);
//                jsonObject.put("options", optionss);
                break;
           /* case 2:
                if (question.getQuestionCodeNext() != null) {
                    String next = question.getQuestionCodeNext();
                    SurveyQuestionnaire sq = surveyQuestionnaireDao.findByIdAndQstId(id, next);
                    jsonObject.put("nextQuestion", sq.getSort());
                }
                break;*/
        }
        jsonObject.put("qstCode", qstCode);
        jsonObject.put("qstTitle", qstTitle);
        jsonObject.put("isRequired", isRequired);
        jsonObject.put("type", type);
        jsonObject.put("sort", sorts);
//        题目数量是变量
        jsonObject.put("totalNum", total);
        logger.error("居民获取题目信息==》" + jsonObject);
        return jsonObject;
    }
    public void saveAnswer(String patient, JSONObject jsonData) throws Exception {
        System.out.println("********jsonData********* " + jsonData);
        //解析json保存各种答案
    public String saveScreenResult(String patientCode,String doctor,int isAgain,int source, JSONObject jsonData){
        System.out.println("********保存筛查结果--jsonData********* " + jsonData);
        String surveyCode = jsonData.get("surveyCode").toString();
        Date createTime = new Date();
//        获取一维数组
        SurveyTemplates surveyTemplates = surveyTemplatesDao.findById(surveyCode);
        Patient patient = patientDao.findByCode(patientCode);
        SurveyScreenResult surveyScreenResult =  new SurveyScreenResult();
        //解析json保存各种答案--获取一维数组
        JSONArray questions = jsonData.getJSONArray("questions");
        int totalScore = 0;
        for (int i = 0; i < questions.length(); i++) {
//            获取每一道题的信息
            //获取每一道题的信息
            JSONObject question = new JSONObject(questions.get(i).toString());
            String qstCode = question.get("qstCode").toString();
            int qstsort = Integer.parseInt(question.get("sort").toString());
            int type = Integer.parseInt(question.get("type").toString());
            if (type != 2) {
                if (question.has("options")) {
//               获取每道题的所有选项
                    //获取每道题的所有选项
                    JSONArray options = question.getJSONArray("options");
                    for (int j = 0; j < options.length(); j++) {
                        JSONObject option = new JSONObject(options.get(j).toString());
                        String code = getCode();
                        String optionCode = option.get("optionCode").toString();
                        int optsort = Integer.parseInt(option.get("sort").toString());
                        String comment = null;
                        int haveComment = 0;
                        if (option.has("comment")) {
                            comment = option.get("comment").toString();
                            haveComment = 1;
                        }
//                 保存到选择题答案表
                        SurveyOptionAnswers optionAnswer = new SurveyOptionAnswers(code, patient, surveyCode, qstCode, optionCode, comment, type, createTime);
                        surveyOptionAnswersDao.save(optionAnswer);
//                选择题修改统计表数量
                        surveyStatisticsDao.modifyAmount(surveyCode, qstCode, optionCode);
                        int score = Integer.parseInt(option.getString("score"));
                        totalScore += score;
                    }
                }
            }
        }
        //查询该筛查的结果设置
        SurveyTemplateResult surveyTemplateResult = surveyTemplateResultDao.getByTemplateCodeAndLowScoreAndHighScore(surveyCode,totalScore);
        //更新上一条数据为不可再次评估
        List<SurveyScreenResult> surveyScreenResultList = surveyScreenResultDao.findNewOneByTemplateCode(surveyCode);
        String lastCode = "";
        String originCode = "";
        if (surveyScreenResultList!=null && surveyScreenResultList.size()>0){
            lastCode = surveyScreenResultList.get(0).getCode();
            originCode = surveyScreenResultList.get(0).getOriginCode();
            surveyScreenResultDao.updateNoAgain(lastCode);
        }
        String code = getCode();
        surveyScreenResult.setCode(code);
        surveyScreenResult.setSource(source);
        //是来自再次评估
        if (isAgain==1){
            surveyScreenResult.setPatientName(lastCode);
            surveyScreenResult.setOriginCode(originCode);
        }else {
            //来自第一次筛查评分
            surveyScreenResult.setOriginCode(code);
        }
        if (surveyTemplates!=null){
            surveyScreenResult.setTemplateCode(surveyTemplates.getCode());
            surveyScreenResult.setTemplateTitle(surveyTemplates.getTitle());
            surveyScreenResult.setDisease(surveyTemplates.getDiseaseType());
        }
        surveyScreenResult.setDoctor(doctor);
        surveyScreenResult.setParentCode(patientCode);
        if (patient!=null){
            surveyScreenResult.setPatientName(patient.getName());
            surveyScreenResult.setOpenId(patient.getOpenid());
        }
        surveyScreenResult.setOrder(0);
        surveyScreenResult.setFollowing(0);
        surveyScreenResult.setOver(1);
        surveyScreenResult.setCzrq(new Date());
        surveyScreenResult.setIsAgain(1);
        surveyScreenResult.setScreenResultScore(totalScore);
        if (surveyTemplateResult!=null){
            surveyScreenResult.setScreenResultCode(surveyTemplateResult.getCode());
            surveyScreenResult.setIsDanger(surveyTemplateResult.getWarning());
            surveyScreenResult.setScreenResult(surveyTemplateResult.getResult());
        }
        surveyScreenResultDao.save(surveyScreenResult);
        return code;
    }
    public JSONObject getScreenResultDetail(String code)throws Exception{
        JSONObject json = new JSONObject();
        //登记信息
        String infoSql = "SELECT ssr.*,p.idcard FROM wlyy_survey_screen_result ssr LEFT JOIN wlyy_patient p ON ssr.patient_code=p.code where ssr.code ='"+code+"'";
        Map<String,Object> infoMap = jdbcTemplate.queryForMap(infoSql);
        if (infoMap==null || infoMap.size()==0){
            json.put(code,-1);
            json.put("message","没有改筛查结果!");
            return json;
        }
        String idcard = String.valueOf(infoMap.get("idcard"));
        infoMap.put("sex",IdCardUtil.getSexForIdcard(idcard));
        infoMap.put("age",IdCardUtil.getAgeForIdcard(idcard));
        String templateCode = String.valueOf(infoMap.get("template_code"));
        String doctorCode = String.valueOf(infoMap.get("doctor"));
        String surveyScreenResultCode = String.valueOf(infoMap.get("code"));
        String patientCode = String.valueOf(infoMap.get("patient_code"));
        Doctor doctor = doctorDao.findByCode(doctorCode);
        if (doctor!=null){
            infoMap.put("doctorName",doctor.getName());
        }
        json.put("info",infoMap);
        String healthSql ="SELECT value1,value2 FROM device.wlyy_patient_health_index WHERE user='"+patientCode+"' AND type=3 ORDER BY record_date DESC LIMIT 1";
        Map<String,Object> healthMap = jdbcTemplate.queryForMap(healthSql);
        json.put("health",healthMap);
        //题目和答案
        List<SurveyTemplateQuestions> questionList = surveyTemplateQuestionsDao.findById(templateCode);
        String sql = "SELECT soa.*,sto.score FROM wlyy_survey_option_answers soa LEFT JOIN wlyy_survey_template_options sto ON soa.options_code= sto.code WHERE soa.screen_result_code=? AND soa.patient=? AND soa.survey_code=?";
        List<Map<String,Object>> optionAnswersList = jdbcTemplate.queryForList(sql,new Object[]{surveyScreenResultCode,patientCode,templateCode});
        for (SurveyTemplateQuestions surveyTemplateQuestions : questionList){
            Map<String,Object> map = new HashMap<>();
            map.put("question",surveyTemplateQuestions);
            String qusCode = surveyTemplateQuestions.getCode();
            for (Map<String,Object> option : optionAnswersList){
                if (option.get("question_code").equals(qusCode)){
                    map.put("option",option);
                }
            }
            json.put(surveyTemplateQuestions.getSort()+"",map);
        }
        //结果
        String reultSql ="SELECT ssr.screen_result_score,ssr.screen_result,str.advice FROM wlyy_survey_screen_result ssr LEFT JOIN wlyy_survey_template_result str ON ssr.screen_result_code = str.code WHERE ssr.code=?";
        Map<String,Object> resultMap = jdbcTemplate.queryForMap(reultSql);
        int following = Integer.parseInt(String.valueOf(infoMap.get("following")));
        int order = Integer.parseInt(String.valueOf(infoMap.get("order")));
        if (order==1){
            //已转诊
            //@TODO
            } else {
                String content = question.get("content").toString();
                if (!StringUtils.isEmpty(content)) {
//                    保存到问答题答案表
                    String code = getCode();
                    SurveyAnswers surveyAnswer = new SurveyAnswers(code, surveyCode, patient, qstCode, content, createTime);
                    surveyAnswersDao.save(surveyAnswer);
//                问答题保存到统计表(只负责更改数量不负责创建)
                    surveyStatisticsDao.modifyAmount(surveyCode, qstCode);
        }else if (following==1){
            String adviceCodes = String.valueOf(infoMap.get("advice_code"));
            List<SurveyAdvice> surveyAdviceList = new ArrayList<>();
            if (StringUtils.isNotEmpty(adviceCodes)){
                String[] advicesStr = adviceCodes.split(",");
                for (String adviceCode : advicesStr){
                    surveyAdviceList.add(surveyAdviceDao.getByCode(adviceCode));
                }
            }
            resultMap.put("advice",surveyAdviceList);
        }
        json.put("result",resultMap);
        return json;
    }
    public List<SurveyTemplateAdvice> getTemplateAdviceList(String templateCode){
        return surveyTemplateAdviceDao.getByTemplateCode(templateCode);
    }
    public void updateAfterFollowing(String code,String adviceCodes,String otherAdvice)throws Exception{
        String sql ="UPDATE wlyy_survey_screen_result SET following=1,advice_code=?";
        if (StringUtils.isNotEmpty(otherAdvice)){
            sql += " ,other_advice=?";
        }
        sql +=" where code=?";
        if (StringUtils.isNotEmpty(otherAdvice)){
            jdbcTemplate.update(sql,new Object[]{adviceCodes,otherAdvice,code});
        }else {
            jdbcTemplate.update(sql,new Object[]{adviceCodes,code});
        }
    }
    public void updateColume(String colume,Object value,String code){
        String sql ="UPDATE wlyy_survey_screen_result SET "+colume+"=? where code=?";
        jdbcTemplate.update(sql,new Object[]{value,code});
    }
    public Map<String,Object> patientGetList(int pageNo,int pageSize,int labelType,String patientCode){
        Map<String,Object> map = new HashedMap();
        List<SurveyTemplates> templates = getScreenList(pageNo,pageSize,labelType);
        List<Map<String,Object>> mapList = new ArrayList<>();
        for (SurveyTemplates surveyTemplates : templates){
            Map<String,Object> sMap = new HashedMap();
            sMap.put("surveyTemplate",surveyTemplates);
            int count =  surveyScreenResultDao.getByPatientCodeAndTemplateCode(patientCode,surveyTemplates.getCode()).size();
            sMap.put("myRecordCount",count);
            mapList.add(sMap);
        }
        map.put("screenList",mapList);
        String sql = "SELECT a.* FROM (SELECT * FROM wlyy_survey_screen_result ORDER BY czrq DESC) a WHERE a.patient_code='"+patientCode+"' GROUP BY a.template_code";
        List<SurveyScreenResult> surveyScreenResultList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(SurveyScreenResult.class));
        map.put("result",surveyScreenResultList);
        return map;
    }
    public List<Map<String,Object>> getResultByTemplateCode(int pageNo,int pageSize,String templateCode,String patientCode){
        int start = (pageNo-1)*pageSize;
        String sql ="SELECT st.*,ssr.code screenCode,ssr.screen_result,ssr.screen_result_score,ssr.czrq as screenCzrq,ssr.is_again FROM wlyy_survey_templates st LEFT JOIN wlyy_survey_screen_result ssr ON st.code = ssr.template_code WHERE st.`code`='"+templateCode+"' AND ssr.patient_code='"+patientCode+"' limit ?,?";
        return jdbcTemplate.queryForList(sql,new Object[]{start,pageSize});
    }
    public Map<String,Object> screenStatics(String doctor){
        Map<String,Object> resultMap = new HashedMap();
        String userSql = "SELECT DISTINCT(template_code) FROM wlyy_survey_screen_result WHERE doctor = '"+doctor+"'";
        List<String> userList = jdbcTemplate.queryForList(userSql,String.class);
        //使用筛查表数量
        resultMap.put("useTemplateCount",userList.size());
        String sql = "SELECT * FROM wlyy_survey_screen_result WHERE doctor='"+doctor+"'";
        List<SurveyScreenResult> surveyScreenResultList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(SurveyScreenResult.class));
        //下发问卷数量
        resultMap.put("grantCount",surveyScreenResultList.size());
        int overCount = 0;
        int warnCount = 0;
        int followCount = 0;
        int orderCount = 0 ;
        int againCount = 0;
        int eduCount = 0;
        for (SurveyScreenResult surveyScreenResult : surveyScreenResultList){
            if (surveyScreenResult.getOver()==1){
                overCount++;
            }
            if (surveyScreenResult.getIsDanger()==1){
                warnCount++;
            }
            if (surveyScreenResult.getFollowing()==1){
                followCount++;
            }
            if (surveyScreenResult.getOrder()==1){
                orderCount++;
            }
            if (StringUtils.isNotEmpty(surveyScreenResult.getParentCode())){
                againCount++;
            }
            if (surveyScreenResult.getIsEducate()==1){
                eduCount++;
            }
        }
//        更改调查对象表答题状态为已答
        surveyUserDao.modifyStatus(surveyCode, patient);
        //筛查记录
        resultMap.put("overCount",overCount);
        //疑似高危
        resultMap.put("dangetCount",warnCount);
        //健康跟踪
        resultMap.put("followCount",followCount);
        //已跟踪
        resultMap.put("orderCount",orderCount);
        //再次评估
        resultMap.put("againCount",againCount);
        //健康教育
        resultMap.put("eduCount",eduCount);
        return  resultMap;
    }
}

+ 74 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/ManagerQuestionnaireService.java

@ -786,7 +786,7 @@ public class ManagerQuestionnaireService extends BaseService {
    public JSONObject getAnswers(String id) throws Exception {
        JSONObject jsonObject = new JSONObject();
//一个问卷内的所有问题
        //一个问卷内的所有问题
        List<SurveyQuestionnaire> questions = surveyQuestionnaireDao.findById(id);
        if (questions.size() == 0) {
            return jsonObject;
@ -1727,4 +1727,77 @@ public class ManagerQuestionnaireService extends BaseService {
        return patients;
    }
    public JSONObject getAllQuestions(String surveyTemplateCode)throws Exception{
        JSONObject json = new JSONObject();
        List<SurveyTemplateQuestions> questionList = surveyTemplateQuestionsDao.findById(surveyTemplateCode);
        List<SurveyTemplateOptions> optionsList = surveyTemplateOptionsDao.findByQuestionCode(surveyTemplateCode);
        for (SurveyTemplateQuestions surveyTemplateQuestions : questionList){
            Map<String,Object> map = new HashMap<>();
            String qusCode = surveyTemplateQuestions.getCode();
            List<SurveyTemplateOptions>  resultOptionList = new ArrayList<>();
            for (SurveyTemplateOptions option : optionsList){
                if (option.getTemplateQuestionCode().equals(qusCode)){
                    resultOptionList.add(option);
                }
            }
            map.put("question",surveyTemplateQuestions);
            map.put("option",resultOptionList);
            json.put(surveyTemplateQuestions.getSort()+"",map);
        }
        return  json;
    }
    public void saveAnswer(String patient,String screenResultCode, JSONObject jsonData) throws Exception {
        System.out.println("********jsonData********* " + jsonData);
        //解析json保存各种答案
        String surveyCode = jsonData.get("surveyCode").toString();
        Date createTime = new Date();
//        获取一维数组
        JSONArray questions = jsonData.getJSONArray("questions");
        for (int i = 0; i < questions.length(); i++) {
//            获取每一道题的信息
            JSONObject question = new JSONObject(questions.get(i).toString());
            String qstCode = question.get("qstCode").toString();
            int qstsort = Integer.parseInt(question.get("sort").toString());
            int type = Integer.parseInt(question.get("type").toString());
            if (type != 2) {
                if (question.has("options")) {
//               获取每道题的所有选项
                    JSONArray options = question.getJSONArray("options");
                    for (int j = 0; j < options.length(); j++) {
                        JSONObject option = new JSONObject(options.get(j).toString());
                        String code = getCode();
                        String optionCode = option.get("optionCode").toString();
                        int optsort = Integer.parseInt(option.get("sort").toString());
                        String comment = null;
                        int haveComment = 0;
                        if (option.has("comment")) {
                            comment = option.get("comment").toString();
                            haveComment = 1;
                        }
//                 保存到选择题答案表
                        SurveyOptionAnswers optionAnswer = new SurveyOptionAnswers(code, patient, surveyCode, qstCode, optionCode, comment, type, createTime);
                        optionAnswer.setScreenResultCode(screenResultCode);
                        surveyOptionAnswersDao.save(optionAnswer);
//                选择题修改统计表数量
                        surveyStatisticsDao.modifyAmount(surveyCode, qstCode, optionCode);
                    }
                }
            } else {
                String content = question.get("content").toString();
                if (!StringUtils.isEmpty(content)) {
//                    保存到问答题答案表
                    String code = getCode();
                    SurveyAnswers surveyAnswer = new SurveyAnswers(code, surveyCode, patient, qstCode, content, createTime);
                    surveyAnswersDao.save(surveyAnswer);
//                问答题保存到统计表(只负责更改数量不负责创建)
                    surveyStatisticsDao.modifyAmount(surveyCode, qstCode);
                }
            }
        }
        //更改调查对象表答题状态为已答
        //surveyUserDao.modifyStatus(surveyCode, patient);
    }
}

+ 0 - 84
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/DoctorQuestionnaireController.java

@ -1,84 +0,0 @@
package com.yihu.wlyy.web.doctor.survey;
import com.yihu.wlyy.repository.questionnaire.QuestionnaireUsersDao;
import com.yihu.wlyy.service.questionnaire.QuestionnaireService;
import com.yihu.wlyy.service.survey.PatientQuestionnaireService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
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;
/**
 * Created by zhangdan on 2018/7/3.
 */
@Controller
@RequestMapping(value = "/doctor/questionnaire")
@Api(description = "医生端端问卷调查")
public class DoctorQuestionnaireController extends BaseController {
    @Autowired
    private PatientQuestionnaireService patientQuestionnaireService;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private QuestionnaireService questionnaireService;
    @Autowired
    private QuestionnaireUsersDao questionnaireUsersDao;
    @RequestMapping(value = "getSurveySummary", method = RequestMethod.GET)
    @ApiOperation(value = "居民端获取问卷概述")
    @ResponseBody
    public String getSurveySummary(
            @ApiParam(value = "问卷编码")
            @RequestParam String id) {
        try {
            String patient = getRepUID();
//            String patient = getUID();
            JSONObject jsonObject = patientQuestionnaireService.getSurveySummary(patient, id);
            return write(200, "查询成功!", "data", jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "getQuestions", method = RequestMethod.GET)
    @ApiOperation(value = "按升序获取问卷的问题")
    @ResponseBody
    public String getQuestions(@ApiParam(value = "问卷编码")@RequestParam String templateCode,
            @ApiParam(value = "当前问题的sort(初始为1)")@RequestParam Integer sort) {
        try {
            JSONObject jsonObject = patientQuestionnaireService.getQuestions(templateCode, sort);
            return write(200, "查询成功!", "data", jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "saveAnswer", method = RequestMethod.POST)
    @ApiOperation(value = "保存用户答案")
    @ResponseBody
    public String saveAnswer( @RequestParam String jsonData,
                              @ApiParam(value = "居民code")@RequestParam(value = "patientCode")String patientCode,
                              @ApiParam(value = "问卷标签")@RequestParam(value = "labelType")int labelType) {
        try {
            JSONObject json = new JSONObject(jsonData);
            patientQuestionnaireService.saveAnswer(patientCode, json);
            //@TODO 如果是筛查还要保存结果
            return write(200, "保存成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "保存失败!");
        }
    }
}

+ 158 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/DoctorSurveyScreenResultController.java

@ -0,0 +1,158 @@
package com.yihu.wlyy.web.doctor.survey;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.app.survey.SurveyScreenResultService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
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;
/**
 * 医生端-疾病筛查
 * Created by zhangdan on 2018/7/2.
 */
@Controller
@RequestMapping(value = "/doctor/screen")
@Api(description = "医生端-疾病筛查")
public class DoctorSurveyScreenResultController extends BaseController {
    @Autowired
    private PatientDao patientDao;
    @Autowired
    WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    @Autowired
    private SurveyScreenResultService surveyScreenResultService;
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    /**
     * 获取筛查结果列表
     * @param pageNo
     * @param pageSize
     * @param diseaseType
     * @param dealType
     * @param patientName
     * @param isDanger
     * @return
     */
    @RequestMapping(value = "getResultList", method = RequestMethod.GET)
    @ApiOperation(value = "获取问卷列表")
    @ResponseBody
    public String getResultList(@ApiParam(value = "当前页")@RequestParam(value = "pageNo") int pageNo,
                                @ApiParam(value = "显示记录数")@RequestParam(value = "pageSize") int pageSize,
                                @ApiParam(value = "疾病类型")@RequestParam(value = "diseaseType",required = false) String diseaseType,
                                @ApiParam(value = "处理方式(待处理为空 1已预约 2已跟踪 3已接诊)")@RequestParam(value = "dealType",required = false) String dealType,
                                @ApiParam(value = "搜索居民的姓名")@RequestParam(value = "patientName",required = false) String patientName,
                                @ApiParam(value = "是否高危预警(0否 1是)")@RequestParam(value = "isDanger") String isDanger){
        try {
            return write(200, "查询成功!", "data", surveyScreenResultService.getResultList(pageNo,pageSize,getUID(),diseaseType,dealType,isDanger,patientName));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
    /**
     * 获取筛查问卷列表
     * @param pageNo
     * @param pageSize
     * @param labelType
     * @return
     */
    @RequestMapping(value = "getScreenList", method = RequestMethod.GET)
    @ApiOperation(value = "根据问卷标签类型获取筛查问卷列表")
    @ResponseBody
    public String getScreenList(@ApiParam(value = "当前页")@RequestParam(value = "pageNo") int pageNo,
                                @ApiParam(value = "显示记录数")@RequestParam(value = "pageSize") int pageSize,
                                @ApiParam(value = "问卷类型标签")@RequestParam(value = "labelType") int labelType) {
        try {
            return write(200, "获取成功!", "data", surveyScreenResultService.getScreenList(pageNo,pageSize,labelType));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "getScreenResultDetail", method = RequestMethod.GET)
    @ApiOperation(value = "查看筛查结果记录详情")
    @ResponseBody
    public String getScreenResultDetail(@ApiParam(value = "筛查结果唯一code")@RequestParam(value = "code") String code) {
        try {
            return write(200, "获取成功!", "data", surveyScreenResultService.getScreenResultDetail(code));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "getTemplateAdvice", method = RequestMethod.GET)
    @ApiOperation(value = "获取健康建议列表")
    @ResponseBody
    public String getTemplateAdvice(@ApiParam(value = "筛查模板code")@RequestParam(value = "templateCode") String templateCode) {
        try {
            return write(200, "获取成功!", "data", surveyScreenResultService.getTemplateAdviceList(templateCode));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "updateAfterFollwoing", method = RequestMethod.POST)
    @ApiOperation(value = "医生跟踪")
    @ResponseBody
    public String updateAfterFollwoing(@ApiParam(value = "筛查记录code")@RequestParam(value = "code") String code,
                                    @ApiParam(value = "建议code,多个逗号隔开")@RequestParam(value = "advicCcodes") String advicCcodes,
                                    @ApiParam(value = "其他建议")@RequestParam(value = "otherAdvice",required = false) String otherAdvice) {
        try {
            surveyScreenResultService.updateAfterFollowing(code,advicCcodes,otherAdvice);
            return write(200, "跟踪成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "跟踪失败!");
        }
    }
    @RequestMapping(value = "updateAfterEducate", method = RequestMethod.POST)
    @ApiOperation(value = "医生筛查后进行健康教育")
    @ResponseBody
    public String updateAfterEducate(@ApiParam(value = "筛查记录code")@RequestParam(value = "code") String code) {
        try {
            surveyScreenResultService.updateColume("is_educate",1,code);
            return write(200, "发送健康教育成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "发送健康教育失败!");
        }
    }
    @RequestMapping(value = "screenStatics", method = RequestMethod.POST)
    @ApiOperation(value = "PCIM筛查统计模型")
    @ResponseBody
    public String screenStatics() {
        try {
            return write(200, "获取数据成功!","data",surveyScreenResultService.screenStatics(getUID()));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取数据失败!");
        }
    }
}

+ 40 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/ManagerQuestionnaireController.java

@ -6,6 +6,7 @@ import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.doctor.SurveyUserDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.app.survey.SurveyScreenResultService;
import com.yihu.wlyy.service.survey.ManagerQuestionnaireService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.web.WeixinBaseController;
@ -57,6 +58,8 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
    private PushMsgTask pushMsgTask;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    @Autowired
    private SurveyScreenResultService surveyScreenResultService;
    /**
     * 获取问卷列表
     *
@ -547,5 +550,42 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "/getAllQuestions",method = RequestMethod.GET)
    @ApiOperation(value = "获取所有问卷题目")
    @ResponseBody
    public String getAllQuestions(@ApiParam(name = "surveyTemplateCode",value = "问卷模板code")@RequestParam(value = "surveyTemplateCode",required = true)String surveyTemplateCode){
        try {
            JSONObject jsonObject = managerQuestionnaireService.getAllQuestions(surveyTemplateCode);
            return write(200, "查询成功!", "data", jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "saveAnswer", method = RequestMethod.POST)
    @ApiOperation(value = "保存用户答案")
    @ResponseBody
    public String saveAnswer( @RequestParam String jsonData,
                              @ApiParam(value = "居民code")@RequestParam(value = "patientCode")String patientCode,
                              @ApiParam(value = "问卷标签")@RequestParam(value = "labelType")int labelType,
                              @ApiParam(value = "筛查来(labelType=5时要填),0是第一次筛查 1是再次评估")@RequestParam(value = "isAgain")int isAgain,
                              @ApiParam(value = "来源(1医生发放 2居民自我评估)")@RequestParam(value = "source")int source) {
        try {
            JSONObject json = new JSONObject(jsonData);
            //如果是评分筛查还要保存最后记录
            String screenResultcode = "";
            if (labelType==5){
                screenResultcode = surveyScreenResultService.saveScreenResult(patientCode,getUID(),isAgain,source,json);
            }
            managerQuestionnaireService.saveAnswer(patientCode, screenResultcode,json);
            return write(200, "保存成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "保存失败!");
        }
    }
}

文件差異過大導致無法顯示
+ 0 - 563
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/SurveyScreenResultController.java


+ 33 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/survey/PatientQuestionnaireController.java

@ -5,6 +5,7 @@ import com.yihu.es.entity.QuestionnaireWinningESDO;
import com.yihu.wlyy.entity.questionnaire.QuestionnaireUsers;
import com.yihu.wlyy.repository.questionnaire.QuestionnaireUsersDao;
import com.yihu.wlyy.rest.model.common.SimpleResult;
import com.yihu.wlyy.service.app.survey.SurveyScreenResultService;
import com.yihu.wlyy.service.questionnaire.QuestionnaireService;
import com.yihu.wlyy.service.questionnaire.QuestionnaireUsersService;
import com.yihu.wlyy.service.survey.PatientQuestionnaireService;
@ -41,6 +42,8 @@ public class    PatientQuestionnaireController extends BaseController {
    private QuestionnaireService questionnaireService;
    @Autowired
    private QuestionnaireUsersDao questionnaireUsersDao;
    @Autowired
    private SurveyScreenResultService surveyScreenResultService;
    @RequestMapping(value = "getSurveySummary", method = RequestMethod.GET)
    @ApiOperation(value = "居民端获取问卷概述")
@ -93,4 +96,34 @@ public class    PatientQuestionnaireController extends BaseController {
        }
    }
    //----------------------------------疾病筛查-----------------------------------------//
    @RequestMapping(value = "getResultAndScreenList", method = RequestMethod.GET)
    @ApiOperation(value = "根据问卷标签类型获取筛查问卷列表和自己的筛查结果")
    @ResponseBody
    public String getResultAndScreenList(@ApiParam(value = "当前页")@RequestParam(value = "pageNo") int pageNo,
                                @ApiParam(value = "显示记录数")@RequestParam(value = "pageSize") int pageSize,
                                @ApiParam(value = "问卷类型标签")@RequestParam(value = "labelType") int labelType) {
        try {
            return write(200, "获取成功!", "data", surveyScreenResultService.patientGetList(pageNo,pageSize,labelType,getUID()));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "getResultByTemplateCode", method = RequestMethod.GET)
    @ApiOperation(value = "居民查看具体一个筛查模板自己的结果")
    @ResponseBody
    public String getResultByTemplateCode(@ApiParam(value = "当前页")@RequestParam(value = "pageNo") int pageNo,
                                         @ApiParam(value = "显示记录数")@RequestParam(value = "pageSize") int pageSize,
                                         @ApiParam(value = "问卷code")@RequestParam(value = "templateCode") String templateCode) {
        try {
            return write(200, "获取成功!", "data", surveyScreenResultService.getResultByTemplateCode(pageNo,pageSize,templateCode,getUID()));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
}