|  | @ -1,8 +1,16 @@
 | 
												
													
														
															|  | package com.yihu.wlyy.service.app.survey;
 |  | 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.doctor.survey.*;
 | 
												
													
														
															|  | 
 |  | import com.yihu.wlyy.entity.patient.Patient;
 | 
												
													
														
															|  | 
 |  | import com.yihu.wlyy.entity.patient.SignFamily;
 | 
												
													
														
															|  | import com.yihu.wlyy.repository.doctor.*;
 |  | import com.yihu.wlyy.repository.doctor.*;
 | 
												
													
														
															|  | 
 |  | import com.yihu.wlyy.repository.patient.PatientDao;
 | 
												
													
														
															|  | 
 |  | import com.yihu.wlyy.repository.patient.SignFamilyDao;
 | 
												
													
														
															|  | import com.yihu.wlyy.service.BaseService;
 |  | 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.apache.commons.lang3.StringUtils;
 | 
												
													
														
															|  | import org.json.JSONArray;
 |  | import org.json.JSONArray;
 | 
												
													
														
															|  | import org.json.JSONObject;
 |  | import org.json.JSONObject;
 | 
												
											
												
													
														
															|  | @ -23,32 +31,48 @@ import java.util.*;
 | 
												
													
														
															|  | @Transactional
 |  | @Transactional
 | 
												
													
														
															|  | public class SurveyScreenResultService extends BaseService {
 |  | public class SurveyScreenResultService extends BaseService {
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private SurveyQuestionnaireDao surveyQuestionnaireDao;
 |  | 
 | 
												
													
														
															|  | 
 |  |     SurveyStatisticsDao surveyStatisticsDao;
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private SurveyQuestionnaireOptionsDao surveyQuestionnaireOptionsDao;
 |  | 
 | 
												
													
														
															|  | 
 |  |     private JdbcTemplate jdbcTemplate;
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private SurveyDao surveyDao;
 |  | 
 | 
												
													
														
															|  | 
 |  |     private SurveyTemplatesDao surveyTemplatesDao;
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private SurveyUserDao surveyUserDao;
 |  | 
 | 
												
													
														
															|  | 
 |  |     private PatientDao patientDao;
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private SurveyOptionAnswersDao surveyOptionAnswersDao;
 |  | 
 | 
												
													
														
															|  | 
 |  |     private SurveyScreenResultDao surveyScreenResultDao;
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private SurveyAnswersDao surveyAnswersDao;
 |  | 
 | 
												
													
														
															|  | 
 |  |     private SurveyTemplateResultDao surveyTemplateResultDao;
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     SurveyStatisticsDao surveyStatisticsDao;
 |  | 
 | 
												
													
														
															|  | 
 |  |     private SurveyTemplateAdviceDao surveyTemplateAdviceDao;
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private JdbcTemplate jdbcTemplate;
 |  | 
 | 
												
													
														
															|  | 
 |  |     private SurveyTemplateQuestionsDao surveyTemplateQuestionsDao;
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private SurveyTemplatesDao surveyTemplatesDao;
 |  | 
 | 
												
													
														
															|  | 
 |  |     private DoctorDao doctorDao;
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     private SurveyAdviceDao surveyAdviceDao;
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     private SignFamilyDao signFamilyDao;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     private Logger logger = LoggerFactory.getLogger(this.getClass());
 |  |     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 {
 |  |     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;
 |  |         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+"'";
 |  | 
 | 
												
													
														
															|  |         String countSql = "SELECT count(*) num FROM wlyy_survey_screen_result ssr WHERE 1=1 AND ssr.over = 1 and ssr.doctor='"+doctor+"'";
 |  | 
 | 
												
													
														
															|  | 
 |  |         String sql = "SELECT ssr.* FROM wlyy_survey_screen_result ssr WHERE 1=1 AND ssr.over = 1 and ssr.source=1 and ssr.doctor='"+doctor+"'";
 | 
												
													
														
															|  | 
 |  |         //String countSql = "SELECT count(*) num FROM wlyy_survey_screen_result ssr WHERE 1=1 AND ssr.over = 1 and ssr.doctor='"+doctor+"'";
 | 
												
													
														
															|  |         if (StringUtils.isNotEmpty(isDanger)){
 |  |         if (StringUtils.isNotEmpty(isDanger)){
 | 
												
													
														
															|  |             sql += " AND ssr.is_danger= "+isDanger;
 |  |             sql += " AND ssr.is_danger= "+isDanger;
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
											
												
													
														
															|  | @ -60,7 +84,7 @@ public class SurveyScreenResultService extends BaseService {
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("1",dealType)){
 |  |         if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("1",dealType)){
 | 
												
													
														
															|  |             //已预约
 |  |             //已预约
 | 
												
													
														
															|  |             sql += " AND ssr.`order` = 1";
 |  | 
 | 
												
													
														
															|  | 
 |  |             sql += " AND ssr.order = 1";
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("2",dealType)){
 |  |         if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("2",dealType)){
 | 
												
													
														
															|  |             //已跟踪
 |  |             //已跟踪
 | 
												
											
												
													
														
															|  | @ -68,16 +92,29 @@ public class SurveyScreenResultService extends BaseService {
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("3",dealType)){
 |  |         if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("3",dealType)){
 | 
												
													
														
															|  |             //已接诊
 |  |             //已接诊
 | 
												
													
														
															|  |             sql += " AND ssr.reservtion_code is not null";
 |  | 
 | 
												
													
														
															|  | 
 |  |             sql += " AND ssr.order = 2";
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         Map<String,Object> map = jdbcTemplate.queryForMap(countSql);
 |  | 
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("4",dealType)){
 | 
												
													
														
															|  | 
 |  |             //待处理
 | 
												
													
														
															|  | 
 |  |             sql +=" AND ssr.`order` = 0 AND ssr.following= 0";
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         List<Map<String,Object>> maps = jdbcTemplate.queryForList(sql);
 | 
												
													
														
															|  |         sql += " limit "+start+","+pageSize;
 |  |         sql += " limit "+start+","+pageSize;
 | 
												
													
														
															|  |         List<SurveyScreenResult> surveyScreenResultList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(SurveyScreenResult.class));
 |  |         List<SurveyScreenResult> surveyScreenResultList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(SurveyScreenResult.class));
 | 
												
													
														
															|  | 
 |  |         Map<String,Object> map = new HashedMap();
 | 
												
													
														
															|  | 
 |  |         map.put("num",maps.size());
 | 
												
													
														
															|  |         map.put("data",surveyScreenResultList);
 |  |         map.put("data",surveyScreenResultList);
 | 
												
													
														
															|  |         return map;
 |  |         return map;
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     /**
 | 
												
													
														
															|  | 
 |  |      * 筛查模板列表
 | 
												
													
														
															|  | 
 |  |      * @param pageNo
 | 
												
													
														
															|  | 
 |  |      * @param pageSize
 | 
												
													
														
															|  | 
 |  |      * @param labelType
 | 
												
													
														
															|  | 
 |  |      * @return
 | 
												
													
														
															|  | 
 |  |      */
 | 
												
													
														
															|  |     public List<SurveyTemplates> getScreenList(int pageNo,int pageSize,int labelType){
 |  |     public List<SurveyTemplates> getScreenList(int pageNo,int pageSize,int labelType){
 | 
												
													
														
															|  |         int start = (pageNo-1)*pageSize;
 |  |         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;
 |  |         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 +122,270 @@ public class SurveyScreenResultService extends BaseService {
 | 
												
													
														
															|  |         return surveyTemplatesList;
 |  |         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();
 |  |         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");
 |  |         JSONArray questions = jsonData.getJSONArray("questions");
 | 
												
													
														
															|  | 
 |  |         int totalScore = 0;
 | 
												
													
														
															|  |         for (int i = 0; i < questions.length(); i++) {
 |  |         for (int i = 0; i < questions.length(); i++) {
 | 
												
													
														
															|  | //            获取每一道题的信息
 |  | 
 | 
												
													
														
															|  | 
 |  |             //获取每一道题的信息
 | 
												
													
														
															|  |             JSONObject question = new JSONObject(questions.get(i).toString());
 |  |             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());
 |  |             int type = Integer.parseInt(question.get("type").toString());
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             if (type != 2) {
 |  |             if (type != 2) {
 | 
												
													
														
															|  |                 if (question.has("options")) {
 |  |                 if (question.has("options")) {
 | 
												
													
														
															|  | //               获取每道题的所有选项
 |  | 
 | 
												
													
														
															|  | 
 |  |                     //获取每道题的所有选项
 | 
												
													
														
															|  |                     JSONArray options = question.getJSONArray("options");
 |  |                     JSONArray options = question.getJSONArray("options");
 | 
												
													
														
															|  |                     for (int j = 0; j < options.length(); j++) {
 |  |                     for (int j = 0; j < options.length(); j++) {
 | 
												
													
														
															|  |                         JSONObject option = new JSONObject(options.get(j).toString());
 |  |                         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.setParentCode(lastCode);
 | 
												
													
														
															|  | 
 |  |             surveyScreenResult.setOriginCode(originCode);
 | 
												
													
														
															|  | 
 |  |         }else {
 | 
												
													
														
															|  | 
 |  |             //来自第一次筛查评分
 | 
												
													
														
															|  | 
 |  |             surveyScreenResult.setOriginCode(code);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if (surveyTemplates!=null){
 | 
												
													
														
															|  | 
 |  |             surveyScreenResult.setTemplateCode(surveyTemplates.getCode());
 | 
												
													
														
															|  | 
 |  |             surveyScreenResult.setTemplateTitle(surveyTemplates.getTitle());
 | 
												
													
														
															|  | 
 |  |             surveyScreenResult.setDisease(surveyTemplates.getDiseaseType());
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         //来自医生发放和自我评估不一样来源
 | 
												
													
														
															|  | 
 |  |         if (source==1){
 | 
												
													
														
															|  | 
 |  |             surveyScreenResult.setDoctor(doctor);
 | 
												
													
														
															|  | 
 |  |         }else {
 | 
												
													
														
															|  | 
 |  |             SignFamily signFamily = signFamilyDao.findByPatient(patientCode);
 | 
												
													
														
															|  | 
 |  |             if (signFamily!=null && StringUtils.isNotEmpty(signFamily.getDoctor())){
 | 
												
													
														
															|  | 
 |  |                 surveyScreenResult.setDoctor(signFamily.getDoctor());
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |             if (signFamily!=null && StringUtils.isNotEmpty(signFamily.getDoctorHealth())){
 | 
												
													
														
															|  | 
 |  |                 surveyScreenResult.setDoctor(signFamily.getDoctorHealth());
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         surveyScreenResult.setPatientCode(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;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             } 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);
 |  | 
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     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 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";
 | 
												
													
														
															|  | 
 |  |         List<Map<String,Object>> healthMapList = jdbcTemplate.queryForList(healthSql);
 | 
												
													
														
															|  | 
 |  |         if (healthMapList!=null && healthMapList.size()>0){
 | 
												
													
														
															|  | 
 |  |             json.put("health",healthMapList.get(0));
 | 
												
													
														
															|  | 
 |  |         }*/
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         //题目和答案
 | 
												
													
														
															|  | 
 |  |         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[]{code,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='"+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>0){
 | 
												
													
														
															|  | 
 |  |             //已转诊
 | 
												
													
														
															|  | 
 |  |             String doctorSql ="SELECT pr.doctor_name FROM wlyy_survey_screen_result ssr LEFT JOIN wlyy_patient_reservation pr ON ssr.reservation_code= pr.`code` where ssr.`code`='"+code+"'";
 | 
												
													
														
															|  | 
 |  |             List<String> list= jdbcTemplate.queryForList(doctorSql,String.class);
 | 
												
													
														
															|  | 
 |  |             if (list!=null && list.size()>0){
 | 
												
													
														
															|  | 
 |  |                 json.put("specialDoctorName",list.get(0));
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         }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<Map<String,Object>> getTemplateAdviceList(String templateCode){
 | 
												
													
														
															|  | 
 |  |         String sql ="SELECT st.template_code,sa.code adviceCode,sa.advice FROM wlyy_survey_template_advice st LEFT JOIN wlyy_survey_advice sa ON st.advice_code=sa.`code` WHERE st.template_code='"+templateCode+"'";
 | 
												
													
														
															|  | 
 |  |         return jdbcTemplate.queryForList(sql);
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     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=?";
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  | //        更改调查对象表答题状态为已答
 |  | 
 | 
												
													
														
															|  |         surveyUserDao.modifyStatus(surveyCode, patient);
 |  | 
 | 
												
													
														
															|  | 
 |  |         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 WHERE patient_code='"+patientCode+"' ORDER BY czrq DESC) a  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++;
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         //筛查记录
 | 
												
													
														
															|  | 
 |  |         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;
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     public void getSpecialDoctorScreenList(String doctor,int type,int pageNo,int pageSize){
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | }
 |  | }
 |