浏览代码

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

chenweida 7 年之前
父节点
当前提交
2f7b6dd109

+ 11 - 7
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyScreenResult.java

@ -35,19 +35,19 @@ public class SurveyScreenResult extends IdEntity implements Serializable{
    //筛查结果设置中相关code
    private String screenResultCode;
    //筛查结果分值
    private int screenResultScore;
    private Integer screenResultScore;
    //筛查结果
    private String screenResult;
    //是否高危预警(0不是  1是)
    private int isDanger;
    private Integer isDanger;
    //是否预约(0未预约 1已预约)
    private int order;
    private Integer order;
    //是否跟踪(0未跟踪 1已跟踪)
    private int following;
    private Integer following;
    //是否进行健康教育(0没有  1有)
    private int isEducate;
    private Integer isEducate;
    //是否完成(0未完成 1已完成)
    private int over;
    private Integer over;
    //预约记录code
    private String reservationCode;
    //创建时间
@ -70,7 +70,7 @@ public class SurveyScreenResult extends IdEntity implements Serializable{
    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 isDanger, 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, String screenResultCode, Integer screenResultScore, String screenResult, Integer isDanger, Integer order, Integer following, Integer isEducate, Integer over, String reservationCode, Date czrq, int isAgain, String parentCode, String originCode, String adviceCode, String otherAdvice, int source, Date updateTime) {
        this.code = code;
        this.templateCode = templateCode;
        this.templateTitle = templateTitle;
@ -79,11 +79,13 @@ public class SurveyScreenResult extends IdEntity implements Serializable{
        this.patientCode = patientCode;
        this.openId = openId;
        this.patientName = patientName;
        this.screenResultCode = screenResultCode;
        this.screenResultScore = screenResultScore;
        this.screenResult = screenResult;
        this.isDanger = isDanger;
        this.order = order;
        this.following = following;
        this.isEducate = isEducate;
        this.over = over;
        this.reservationCode = reservationCode;
        this.czrq = czrq;
@ -92,6 +94,8 @@ public class SurveyScreenResult extends IdEntity implements Serializable{
        this.originCode = originCode;
        this.adviceCode = adviceCode;
        this.otherAdvice = otherAdvice;
        this.source = source;
        this.updateTime = updateTime;
    }
    @Column(name = "code")

+ 6 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/specialist/SpecialDiseaseDao.java

@ -2,14 +2,17 @@ package com.yihu.wlyy.repository.specialist;
import com.yihu.wlyy.entity.specialist.SpecialDisease;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Trick on 2018/7/4.
 */
public interface SpecialDiseaseDao extends
        PagingAndSortingRepository<SpecialDisease, Long>,
        JpaSpecificationExecutor<SpecialDisease> {
public interface SpecialDiseaseDao extends PagingAndSortingRepository<SpecialDisease, Long>, JpaSpecificationExecutor<SpecialDisease> {
    SpecialDisease findByCode(String code);
    List<SpecialDisease> findByDel(String del);
}

+ 21 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java

@ -1811,4 +1811,25 @@ public class PatientInfoService extends BaseService {
        }
        return patientList;
    }
    public List<Map<String,Object>> getPatientSignByDoctor(int pageNo,int pageSize,String keyWord,String doctor)throws Exception{
        int start = (pageNo-1)*pageSize;
        String sql = "SELECT `name`,patient,mobile,idcard,openid FROM wlyy_sign_family WHERE `status`>0 AND (doctor='"+doctor+"' OR doctor_health='"+doctor+"')";
        if (StringUtils.isNotEmpty(keyWord)){
            sql += " and name LIKE '%"+keyWord+"%'";
        }
        sql += " limit ?,?";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql,new Object[]{start,pageSize});
        for (Map<String,Object> map : list){
            String idcard = String.valueOf(map.get("idcard"));
            map.put("sex",IdCardUtil.getSexForIdcard(idcard));
            map.put("age",IdCardUtil.getAgeForIdcard(idcard));
            /*String healthSql ="SELECT value1,value2 FROM device.wlyy_patient_health_index WHERE user='"+String.valueOf(map.get("patient"))+"' AND type=3 ORDER BY record_date DESC LIMIT 1";
            List<Map<String,Object>> healthMapList = jdbcTemplate.queryForList(healthSql);
            if (healthMapList!=null && healthMapList.size()>0){
                map.putAll(healthMapList.get(0));
            }*/
        }
        return list;
    }
}

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

@ -3,8 +3,10 @@ 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.entity.patient.SignFamily;
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.survey.ManagerQuestionnaireService;
import com.yihu.wlyy.util.IdCardUtil;
@ -48,6 +50,8 @@ public class SurveyScreenResultService extends BaseService {
    private DoctorDao doctorDao;
    @Autowired
    private SurveyAdviceDao surveyAdviceDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    private Logger logger = LoggerFactory.getLogger(this.getClass());
@ -67,8 +71,8 @@ public class SurveyScreenResultService extends BaseService {
     */
    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+"'";
        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)){
            sql += " AND ssr.is_danger= "+isDanger;
        }
@ -80,7 +84,7 @@ public class SurveyScreenResultService extends BaseService {
        }
        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)){
            //已跟踪
@ -88,11 +92,17 @@ public class SurveyScreenResultService extends BaseService {
        }
        if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("3",dealType)){
            //已接诊
            sql += " AND ssr.reservtion_code is not null";
            sql += " AND ssr.order = 2";
        }
        if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("4",dealType)){
            //待处理
            sql +=" AND ssr.`order` = 0 AND ssr.following= 0";
        }
        Map<String,Object> map = jdbcTemplate.queryForMap(countSql);
        List<Map<String,Object>> maps = jdbcTemplate.queryForList(sql);
        sql += " limit "+start+","+pageSize;
        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);
        return map;
    }
@ -138,7 +148,6 @@ public class SurveyScreenResultService extends BaseService {
                    JSONArray options = question.getJSONArray("options");
                    for (int j = 0; j < options.length(); j++) {
                        JSONObject option = new JSONObject(options.get(j).toString());
                        String code = getCode();
                        int score = Integer.parseInt(option.getString("score"));
                        totalScore += score;
                    }
@ -161,7 +170,7 @@ public class SurveyScreenResultService extends BaseService {
        surveyScreenResult.setSource(source);
        //是来自再次评估
        if (isAgain==1){
            surveyScreenResult.setPatientName(lastCode);
            surveyScreenResult.setParentCode(lastCode);
            surveyScreenResult.setOriginCode(originCode);
        }else {
            //来自第一次筛查评分
@ -172,8 +181,20 @@ public class SurveyScreenResultService extends BaseService {
            surveyScreenResult.setTemplateTitle(surveyTemplates.getTitle());
            surveyScreenResult.setDisease(surveyTemplates.getDiseaseType());
        }
        surveyScreenResult.setDoctor(doctor);
        surveyScreenResult.setParentCode(patientCode);
        //来自医生发放和自我评估不一样来源
        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());
@ -204,26 +225,27 @@ public class SurveyScreenResultService extends BaseService {
            json.put("message","没有改筛查结果!");
            return json;
        }
        String idcard = String.valueOf(infoMap.get("idcard"));
        /*String idcard = String.valueOf(infoMap.get("idcard"));
        infoMap.put("sex",IdCardUtil.getSexForIdcard(idcard));
        infoMap.put("age",IdCardUtil.getAgeForIdcard(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 doctorCode = String.valueOf(infoMap.get("doctor"));
        String patientCode = String.valueOf(infoMap.get("patient_code"));
        Doctor doctor = doctorDao.findByCode(doctorCode);
       /* 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);
        /*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[]{surveyScreenResultCode,patientCode,templateCode});
        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);
@ -236,13 +258,17 @@ public class SurveyScreenResultService extends BaseService {
            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=?";
        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==1){
        if (order>0){
            //已转诊
            //@TODO
            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"));
@ -260,8 +286,9 @@ public class SurveyScreenResultService extends BaseService {
    }
    public List<SurveyTemplateAdvice> getTemplateAdviceList(String templateCode){
        return surveyTemplateAdviceDao.getByTemplateCode(templateCode);
    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{
@ -294,7 +321,7 @@ public class SurveyScreenResultService extends BaseService {
            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";
        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;
@ -357,4 +384,8 @@ public class SurveyScreenResultService extends BaseService {
        return  resultMap;
    }
    public void getSpecialDoctorScreenList(String doctor,int type,int pageNo,int pageSize){
    }
}

+ 21 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java

@ -569,4 +569,25 @@ public class PatientInfoController extends BaseController {
            return error( -1, "查询失败!");
        }
    }
    @RequestMapping(value = "/getPatientSignByDoctor",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("查询医生的签约居民")
    public String getPatientSignByDoctor(@ApiParam(value = "关键搜索词", name = "keyWord") @RequestParam(value = "keyWord",required = false,defaultValue = "")String keyWord,
                                         @ApiParam(name="pageNo",value="第几页",defaultValue = "1") @RequestParam(value="pageNo",required = true) String pageNo,
                                         @ApiParam(name="pageSize",value="",defaultValue = "10") @RequestParam(value="pageSize",required = true) String pageSize){
        if (StringUtils.isBlank(pageSize)) {
            pageSize = "10";
        }
        if (pageNo.equals("0")){
            pageNo = "1";
        }
        try {
            return  write(200,"查找成功!","data",patientInfoService.getPatientSignByDoctor(Integer.parseInt(pageNo),Integer.parseInt(pageSize),keyWord,getUID()));
        } catch (Exception e) {
            error(e);
            return error( -1, "查询失败!");
        }
    }
}

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

@ -1,6 +1,7 @@
package com.yihu.wlyy.web.doctor.survey;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.specialist.SpecialDiseaseDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.app.survey.SurveyScreenResultService;
import com.yihu.wlyy.task.PushMsgTask;
@ -40,6 +41,8 @@ public class DoctorSurveyScreenResultController extends BaseController {
    private WechatTemplateConfigDao templateConfigDao;
    @Autowired
    private SurveyScreenResultService surveyScreenResultService;
    @Autowired
    private SpecialDiseaseDao specialDiseaseDao;
    private Logger logger = LoggerFactory.getLogger(this.getClass());
@ -54,14 +57,14 @@ public class DoctorSurveyScreenResultController extends BaseController {
     * @return
     */
    @RequestMapping(value = "getResultList", method = RequestMethod.GET)
    @ApiOperation(value = "获取问卷列表")
    @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 = "处理方式(1已预约 2已跟踪 3已接诊 4待处理)")@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){
                                @ApiParam(value = "是否高危预警(0否 1是)")@RequestParam(value = "isDanger",required = false) String isDanger){
        try {
            return write(200, "查询成功!", "data", surveyScreenResultService.getResultList(pageNo,pageSize,getUID(),diseaseType,dealType,isDanger,patientName));
        } catch (Exception e) {
@ -70,6 +73,18 @@ public class DoctorSurveyScreenResultController extends BaseController {
        }
    }
    @RequestMapping(value = "getSpecialDisease", method = RequestMethod.GET)
    @ApiOperation(value = "获取专科疾病类型")
    @ResponseBody
    public String getSpecialDisease(){
        try {
            return write(200, "查询成功!", "data", specialDiseaseDao.findByDel("1"));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
    /**
     * 获取筛查问卷列表
@ -137,10 +152,10 @@ public class DoctorSurveyScreenResultController extends BaseController {
    public String updateAfterEducate(@ApiParam(value = "筛查记录code")@RequestParam(value = "code") String code) {
        try {
            surveyScreenResultService.updateColume("is_educate",1,code);
            return write(200, "发送健康教育成功!");
            return write(200, "更新健康教育成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "发送健康教育失败!");
            return write(-1, "更新健康教育失败!");
        }
    }

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

@ -569,7 +569,7 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
    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 = "筛查入口(labelType=5时要填),0是第一次筛查 1是再次评估")@RequestParam(value = "isAgain")int isAgain,
                              @ApiParam(value = "来源(1医生发放 2居民自我评估)")@RequestParam(value = "source")int source) {
        try {

+ 55 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/survey/PatientQuestionnaireController.java

@ -8,6 +8,7 @@ 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.ManagerQuestionnaireService;
import com.yihu.wlyy.service.survey.PatientQuestionnaireService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
@ -44,6 +45,8 @@ public class    PatientQuestionnaireController extends BaseController {
    private QuestionnaireUsersDao questionnaireUsersDao;
    @Autowired
    private SurveyScreenResultService surveyScreenResultService;
    @Autowired
    private ManagerQuestionnaireService managerQuestionnaireService;
    @RequestMapping(value = "getSurveySummary", method = RequestMethod.GET)
    @ApiOperation(value = "居民端获取问卷概述")
@ -106,7 +109,7 @@ public class    PatientQuestionnaireController extends BaseController {
                                @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()));
            return write(200, "获取成功!", "data", surveyScreenResultService.patientGetList(pageNo,pageSize,labelType,getRepUID()));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
@ -120,10 +123,60 @@ public class    PatientQuestionnaireController extends BaseController {
                                         @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()));
            return write(200, "获取成功!", "data", surveyScreenResultService.getResultByTemplateCode(pageNo,pageSize,templateCode,getRepUID()));
        } 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 = "/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 = "saveScreenAnswer", 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, "保存失败!");
        }
    }
}