Quellcode durchsuchen

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

huangwenjie vor 7 Jahren
Ursprung
Commit
e387c7717f

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

@ -5,6 +5,7 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
/**
@ -28,4 +29,7 @@ public interface SurveyScreenResultDao extends PagingAndSortingRepository<Survey
    @Query("select a from  SurveyScreenResult a where a.reservationCode=?1")
    List<SurveyScreenResult> getByReservationCode(String reservationCode);
    /*@Modifying
    @Query("update SurveyScreenResult s set s.over=1,s.czrq=?1,s.screenResultScore=?2,s.screenResultCode=?3,s.screenResult=?4,s.isDanger=?5 where s.code=?6")
    void updateScreenAndSaveAnswer(Date czrq, int totalScore, String screenResultCode, String screenResult, int isDanger, String code);*/
}

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

@ -13,6 +13,7 @@ import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.survey.ManagerQuestionnaireService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
@ -433,7 +434,7 @@ public class SurveyScreenResultService extends BaseService {
            if (surveyScreenResult.getFollowing()==1){
                followCount++;
            }
            if (surveyScreenResult.getIsOrder()==1){
            if (surveyScreenResult.getIsOrder()>0){
                orderCount++;
            }
            if (StringUtils.isNotEmpty(surveyScreenResult.getParentCode())){
@ -759,7 +760,9 @@ public class SurveyScreenResultService extends BaseService {
                        String name = null;
                        String openId = null;
                        String first = null;
                        String screenCode =null;
                        try {
                            screenCode = saveAfterBatchScreen(c,openId,name,doctor,wxTemplateCode);
                            p = patientDao.findByCode(c);
                            name = p.getName();
                            openId = p.getOpenid();
@ -767,7 +770,7 @@ public class SurveyScreenResultService extends BaseService {
                            json.put("keyword2", sdf.format(new Date()));
                            json.put("survey", wxTemplateCode+"_"+doctor);
                            json.put("toUser", c);
                            json.put("url","jkpg/html/start-survey.html?survey="+wxTemplateCode+"&doctor="+doctor+"&toUser="+c+"&toName="+name);
                            json.put("url","jkpg/html/wx-template-message.html?survey="+wxTemplateCode+"&doctor="+doctor+"&toUser="+c+"&toName="+name+"&screenCode="+screenCode);
//                          String first = name + ",您好!为了给您提供更好的家庭医生健康服务,现有一份问卷需要您填写。";
                            first = templateConfig.getFirst();
                            first = first.replace("key1",(name==null?"":name));
@ -792,7 +795,7 @@ public class SurveyScreenResultService extends BaseService {
                                    if (StringUtils.isNotBlank(member.getOpenid())) {
                                        json.remove("toUser");
                                        json.put("toUser", member.getCode());
                                        json.put("url","jkpg/html/start-survey.html?survey="+wxTemplateCode+"&doctor="+doctor+"&toUser="+member.getCode()+"&toName="+member.getName());
                                        json.put("url","jkpg/html/wx-template-message.html?survey="+wxTemplateCode+"&doctor="+doctor+"&toUser="+member.getCode()+"&toName="+member.getName()+"&screenCode="+screenCode);
                                        json.remove("first");
                                        try {
                                            json.put("keyword1", keyword1);
@ -1024,4 +1027,81 @@ public class SurveyScreenResultService extends BaseService {
        surveyDao.save(survey);
        return surveyCode;
    }
    public String saveAfterBatchScreen(String patientCode,String openId,String patientName,String doctorCode,String surveyCode){
        SurveyScreenResult surveyScreenResult =  new SurveyScreenResult();
        SurveyTemplates surveyTemplates = surveyTemplatesDao.findById(surveyCode);
        Patient patient = patientDao.findByCode(patientCode);
        String code = getCode();
        surveyScreenResult.setCode(code);
        if (surveyTemplates!=null){
            surveyScreenResult.setTemplateCode(surveyTemplates.getCode());
            surveyScreenResult.setTemplateTitle(surveyTemplates.getTitle());
            surveyScreenResult.setDisease(surveyTemplates.getDiseaseType());
        }
        surveyScreenResult.setDoctor(doctorCode);
        surveyScreenResult.setPatientCode(patientCode);
        if (patient!=null){
            surveyScreenResult.setPatientName(patient.getName());
            surveyScreenResult.setOpenId(patient.getOpenid());
        }else {
            surveyScreenResult.setOpenId(openId);
            surveyScreenResult.setPatientName(patientName);
        }
        surveyScreenResult.setIsDanger(0);
        surveyScreenResult.setIsOrder(0);
        surveyScreenResult.setFollowing(0);
        surveyScreenResult.setIsEducate(0);
        surveyScreenResult.setOver(0);
        surveyScreenResult.setCzrq(new Date());
        surveyScreenResult.setIsAgain(1);
        surveyScreenResult.setOriginCode(code);
        surveyScreenResult.setSource(1);
        surveyScreenResult.setScreenResultScore(0);
        surveyScreenResultDao.save(surveyScreenResult);
        return code;
    }
    public String updateScreenAndSaveAnswer(String patientCode,String screenCode, JSONObject jsonData)throws Exception{
        System.out.println("********保存筛查结果--jsonData********* " + jsonData);
        String surveyCode = jsonData.get("surveyCode").toString();
        SurveyScreenResult surveyScreenResult =  surveyScreenResultDao.getSurveyScreenResultByCode(screenCode);
        //解析json保存各种答案--获取一维数组
        JSONArray questions = jsonData.getJSONArray("questions");
        int totalScore = 0;
        for (int i = 0; i < questions.length(); i++) {
            //获取每一道题的信息
            JSONObject question = new JSONObject(questions.get(i).toString());
            int type = Integer.parseInt(question.get("type").toString());
            if (type != 2) {
                if (question.has("options")) {
                    //获取每道题的所有选项
                    JSONArray options = question.getJSONArray("options");
                    for (int j = 0; j < options.length(); j++) {
                        JSONObject option = new JSONObject(options.get(j).toString());
                        int score = option.getInt("score");
                        totalScore += score;
                    }
                }
            }
        }
        //查询该筛查的结果设置
        SurveyTemplateResult surveyTemplateResult = surveyTemplateResultDao.getByTemplateCodeAndLowScoreAndHighScore(surveyCode,totalScore);
       /* surveyScreenResult.setOver(1);
        surveyScreenResult.setCzrq(new Date());
        surveyScreenResult.setScreenResultScore(totalScore);
        if (surveyTemplateResult!=null){
            surveyScreenResult.setScreenResultCode(surveyTemplateResult.getCode());
            surveyScreenResult.setIsDanger(surveyTemplateResult.getWarning());
            surveyScreenResult.setScreenResult(surveyTemplateResult.getResult());
        }*/
       String sql ="UPDATE wlyy_survey_screen_result SET over=1,czrq=?,screen_result_code=?,screen_result=?,screen_result_score=?,is_danger=? WHERE code=?";
       jdbcTemplate.update(sql,new Object[]{new Date(),surveyTemplateResult.getCode(),surveyTemplateResult.getResult(),totalScore,surveyTemplateResult.getWarning(),screenCode});
        //surveyScreenResultDao.updateScreenAndSaveAnswer(new Date(),totalScore,surveyTemplateResult.getCode(),surveyTemplateResult.getResult(),surveyTemplateResult.getWarning(),screenCode);
        managerQuestionnaireService.saveAnswer(patientCode,surveyScreenResult.getCode(),jsonData);
        return screenCode;
    }
}

+ 39 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/survey/PatientQuestionnaireController.java

@ -2,8 +2,12 @@ package com.yihu.wlyy.web.patient.survey;
import com.google.gson.JsonObject;
import com.yihu.es.entity.QuestionnaireWinningESDO;
import com.yihu.wlyy.entity.doctor.survey.SurveyScreenResult;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.questionnaire.QuestionnaireUsers;
import com.yihu.wlyy.repository.doctor.SurveyScreenResultDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.questionnaire.QuestionnaireUsersDao;
import com.yihu.wlyy.rest.model.common.SimpleResult;
@ -40,17 +44,15 @@ public class    PatientQuestionnaireController extends BaseController {
    @Autowired
    private PatientQuestionnaireService patientQuestionnaireService;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private QuestionnaireService questionnaireService;
    @Autowired
    private QuestionnaireUsersDao questionnaireUsersDao;
    @Autowired
    private SurveyScreenResultService surveyScreenResultService;
    @Autowired
    private ManagerQuestionnaireService managerQuestionnaireService;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private SurveyScreenResultDao surveyScreenResultDao;
    @Autowired
    private PatientDao patientDao;
    @RequestMapping(value = "getSurveySummary", method = RequestMethod.GET)
    @ApiOperation(value = "居民端获取问卷概述")
@ -195,4 +197,35 @@ public class    PatientQuestionnaireController extends BaseController {
        }
    }
    @RequestMapping(value = "checkIsOver", method = RequestMethod.POST)
    @ApiOperation(value = "用户点击消息模板查看该份筛查是否已经完成")
    @ResponseBody
    public String checkIsOver(@ApiParam(value = "筛查记录code")@RequestParam(value = "screenCode")String screenCode) {
        try {
            SurveyScreenResult surveyScreenResult = surveyScreenResultDao.getSurveyScreenResultByCode(screenCode);
            return write(200,"获取成功!","data",surveyScreenResult);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "updateScreenAndSaveAnswer", method = RequestMethod.POST)
    @ApiOperation(value = "用户点击消息模板完成筛查")
    @ResponseBody
    public String updateScreenAndSaveAnswer( @RequestParam String jsonData,
                              @ApiParam(value = "医生code")@RequestParam(value = "doctorCode",required = false)String doctorCode,
                              @ApiParam(value = "筛查记录code")@RequestParam(value = "screenCode")String screenCode) {
        try {
            JSONObject json = new JSONObject(jsonData);
            return  write(200, "保存成功!","data",surveyScreenResultService.updateScreenAndSaveAnswer(getRepUID(),screenCode,json));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "保存失败!");
        }
    }
}