Selaa lähdekoodia

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

liuwenbin 6 vuotta sitten
vanhempi
commit
93f3e4a424

+ 5 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/QuestionnaireManageService.java

@ -99,9 +99,11 @@ public class QuestionnaireManageService extends BaseJpaService {
    public String saveResultAndAnswer(String patientCode, Integer labelType, String customerCode, Integer source, String jsonData, String serviceCode) throws Exception {
        String url = wlyyUrl + "third/synergy/questionnaire/saveResultAndAnswer";
        //查找发放问卷的医生
        String sql = "SELECT w.create_user from manage_synergy_workorder_servicer s, manage_synergy_workorder w " +
        String sql = "SELECT w.create_user, s.relation_code from manage_synergy_workorder_servicer s, manage_synergy_workorder w " +
                "where s.workorder_code = w.`code` and s.`code`= '" + serviceCode + "'";
        String doctor = jdbcTemplate.queryForObject(sql, String.class);
        Map<String, Object> map = jdbcTemplate.queryForList(sql).get(0);
        String doctor = (String) map.get("create_user");
        String resultCode = (String) map.get("relation_code");
        String response = "";
        Map<String, Object> params = new HashMap<>();
        params.put("labelType", labelType);
@ -111,6 +113,7 @@ public class QuestionnaireManageService extends BaseJpaService {
        params.put("source", source);
        params.put("isAgain", 0);
        params.put("doctor", doctor);
        params.put("resultCode", resultCode);
        try {
            response = httpClientUtil.post(url, params);
        } catch (Exception e) {

+ 3 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyAnswersDao.java

@ -6,8 +6,6 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Reece on 2017/3/9.
 */
@ -20,4 +18,7 @@ public interface SurveyAnswersDao extends PagingAndSortingRepository<SurveyAnswe
    @Query("select  count(distinct t.patient) from SurveyAnswers t where t.content is not null and t.surveyCode=?1 and t.questionCode=?2 ")
    int countByRelationCode(String surveyCode, String questionId);
    @Query("select  t from SurveyAnswers t where t.questionResultCode = ?1 and t.surveyCode = ?2 and t.questionCode = ?3 and t.patient = ?4")
    SurveyAnswers findSurveyAnswer(String resultCode, String surveyCode, String qstCode, String patient);
}

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

@ -23,4 +23,7 @@ public interface SurveyOptionAnswersDao extends PagingAndSortingRepository<Surve
    @Query("select a from  SurveyOptionAnswers a where a.patient=?1 and a.surveyCode=?2")
    List<SurveyOptionAnswers> getBySurveyCodeAndPatient(String patient,String surveyCode);
    @Query("select a from SurveyOptionAnswers a where a.patient = ?1 and a.surveyCode = ?2 and a.questionCode = ?3 and a.screenResultCode = ?4")
    SurveyOptionAnswers findOptionAnswer(String patient, String surveyCode, String qstCode, String resultCode);
}

+ 2 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyQuestionResultDao.java

@ -7,4 +7,6 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 * Created by humingfen on 2018/9/29.
 */
public interface SurveyQuestionResultDao extends PagingAndSortingRepository<SurveyQuestionResult, Long> {
    SurveyQuestionResult findByCode(String resultCode);
}

+ 2 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyScreenResultDao.java

@ -5,7 +5,6 @@ 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;
/**
@ -29,6 +28,8 @@ public interface SurveyScreenResultDao extends PagingAndSortingRepository<Survey
    @Query("select a from  SurveyScreenResult a where a.reservationCode=?1")
    List<SurveyScreenResult> getByReservationCode(String reservationCode);
    SurveyScreenResult findByCode(String resultCode);
    /*@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);*/

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

@ -170,19 +170,26 @@ public class SurveyScreenResultService extends BaseService {
    }
    /**
     * 保存筛查结果
     * 保存更新筛查结果
     *
     * @param patientCode
     * @param doctor
     * @param source
     * @param jsonData
     */
    public String saveScreenResultAndAnswer(String patientCode, String doctor, int isAgain, int source, JSONObject jsonData) throws Exception {
    public String saveScreenResultAndAnswer(String patientCode, String doctor, int isAgain, int source, JSONObject jsonData, String resultCode) throws Exception {
        System.out.println("********保存筛查结果--jsonData********* " + jsonData);
        String surveyCode = jsonData.get("surveyCode").toString();
        SurveyTemplates surveyTemplates = surveyTemplatesDao.findById(surveyCode);
        Patient patient = patientDao.findByCode(patientCode);
        SurveyScreenResult surveyScreenResult = new SurveyScreenResult();
        SurveyScreenResult surveyScreenResult = null;
        if(StringUtils.isNotBlank(resultCode)){
            surveyScreenResult = surveyScreenResultDao.findByCode(resultCode);
        }else {
            surveyScreenResult = new SurveyScreenResult();
            resultCode = getCode();
            surveyScreenResult.setCode(resultCode);
        }
        //解析json保存各种答案--获取一维数组
        JSONArray questions = jsonData.getJSONArray("questions");
        int totalScore = 0;
@ -227,8 +234,7 @@ public class SurveyScreenResultService extends BaseService {
            originCode = surveyScreenResultList.get(0).getOriginCode();
            surveyScreenResultDao.updateNoAgain(lastCode);
        }
        String code = getCode();
        surveyScreenResult.setCode(code);
        surveyScreenResult.setSource(source);
        //是来自再次评估
        if (isAgain == 1) {
@ -236,7 +242,7 @@ public class SurveyScreenResultService extends BaseService {
            surveyScreenResult.setOriginCode(originCode);
        } else {
            //来自第一次筛查评分
            surveyScreenResult.setOriginCode(code);
            surveyScreenResult.setOriginCode(resultCode);
        }
        if (surveyTemplates != null) {
            surveyScreenResult.setTemplateCode(surveyTemplates.getCode());
@ -274,8 +280,8 @@ public class SurveyScreenResultService extends BaseService {
            surveyScreenResult.setScreenResult(surveyTemplateResult.getResult());
        }
        surveyScreenResultDao.save(surveyScreenResult);
        managerQuestionnaireService.saveAnswer(patientCode, code, jsonData);
        return code;
        managerQuestionnaireService.saveAnswer(patientCode, resultCode, jsonData);
        return resultCode;
    }
    public JSONObject getScreenResultDetail(String code) throws Exception {

+ 45 - 25
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/ManagerQuestionnaireService.java

@ -1803,9 +1803,17 @@ public class ManagerQuestionnaireService extends BaseService {
                            comment = option.get("comment").toString();
                            haveComment = 1;
                        }
//                 保存到选择题答案表
                        SurveyOptionAnswers optionAnswer = new SurveyOptionAnswers(code, patient, surveyCode, qstCode, optionCode, comment, type, createTime);
                        optionAnswer.setScreenResultCode(resultCode);
//                 保存或者更新到选择题答案表
                        SurveyOptionAnswers optionAnswer = null;
                        if (StringUtils.isNotBlank(resultCode)){
                            optionAnswer = surveyOptionAnswersDao.findOptionAnswer(patient, surveyCode, qstCode, resultCode);
                            optionAnswer.setOptionsCode(optionCode);
                            optionAnswer.setOptionComment(comment);
                            optionAnswer.setCreateTime(new Date());
                        }else {
                            optionAnswer = new SurveyOptionAnswers(code, patient, surveyCode, qstCode, optionCode, comment, type, createTime);
                            optionAnswer.setScreenResultCode(resultCode);
                        }
                        surveyOptionAnswersDao.save(optionAnswer);
//                选择题修改统计表数量
                        surveyStatisticsDao.modifyAmount(surveyCode, qstCode, optionCode);
@ -1815,10 +1823,17 @@ public class ManagerQuestionnaireService extends BaseService {
            } else {
                String content = question.get("content").toString();
                if (!StringUtils.isEmpty(content)) {
//                    保存到问答题答案表
                    String code = getCode();
                    SurveyAnswers surveyAnswer = new SurveyAnswers(code, surveyCode, patient, qstCode, content, createTime);
                    surveyAnswer.setQuestionResultCode(resultCode);
//                    保存或者更新问答题答案表
                    SurveyAnswers surveyAnswer = null;
                    if (StringUtils.isNotBlank(resultCode)){
                        surveyAnswer = surveyAnswersDao.findSurveyAnswer(resultCode, surveyCode, qstCode, patient);
                        surveyAnswer.setContent(content);
                        surveyAnswer.setCreateTime(new Date());
                    }else {
                        String code = getCode();
                        surveyAnswer = new SurveyAnswers(code, surveyCode, patient, qstCode, content, createTime);
                        surveyAnswer.setQuestionResultCode(resultCode);
                    }
                    surveyAnswersDao.save(surveyAnswer);
//                问答题保存到统计表(只负责更改数量不负责创建)
                    surveyStatisticsDao.modifyAmount(surveyCode, qstCode);
@ -1913,35 +1928,40 @@ public class ManagerQuestionnaireService extends BaseService {
    }
    /**
     * 保存问卷调查结果和答案
     * 保存更新问卷调查结果和答案
     * @param jsonData
     * @param patientCode
     * @param customerCode
     * @param doctor
     * @param resultCode
     * @return
     * @throws Exception
     */
    public String saveQuestionResultAndAnswer(JSONObject jsonData, String patientCode, String customerCode, String doctor) throws Exception {
    public String saveQuestionResultAndAnswer(JSONObject jsonData, String patientCode, String customerCode, String doctor, String resultCode) throws Exception {
        String surveyCode = jsonData.get("surveyCode").toString();
        Survey survey = surveyDao.findById(surveyCode);
        Patient patient = patientDao.findByCode(patientCode);
        User user = userDao.findByCode(customerCode);
        Doctor d = doctorDao.findByCode(doctor);
        SurveyQuestionResult questionResult =  new SurveyQuestionResult();
        String code = getCode();
        questionResult.setCode(code);
        questionResult.setSurveyCode(survey.getCode());
        questionResult.setSurveyTitle(survey.getTitle());
        questionResult.setPatientCode(patient.getCode());
        questionResult.setPatientName(patient.getName());
        questionResult.setDoctor(doctor);
        questionResult.setDoctorName(d.getName());
        questionResult.setType(1);
        questionResult.setCreateUser(customerCode);
        questionResult.setCreateUserName(user.getName());
        questionResult.setCreateTime(new Date());
        questionResultDao.save(questionResult);
        this.saveAnswer(patientCode, code, jsonData);
        return code;
        SurveyQuestionResult questionResult = null;
        //判断更新还是新建
        if(StringUtils.isBlank(resultCode)){
            questionResult = new SurveyQuestionResult();
            resultCode = getCode();
            questionResult.setCode(resultCode);
            questionResult.setSurveyCode(survey.getCode());
            questionResult.setSurveyTitle(survey.getTitle());
            questionResult.setPatientCode(patient.getCode());
            questionResult.setPatientName(patient.getName());
            questionResult.setDoctor(doctor);
            questionResult.setDoctorName(d.getName());
            questionResult.setType(1);
            questionResult.setCreateUser(customerCode);
            questionResult.setCreateUserName(user.getName());
            questionResult.setCreateTime(new Date());
            questionResultDao.save(questionResult);
        }
        this.saveAnswer(patientCode, resultCode, jsonData);
        return resultCode;
    }
}

+ 5 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/synergy/SynergyManagerController.java

@ -198,21 +198,22 @@ public class SynergyManagerController extends BaseController{
    }
    @RequestMapping(value = "/questionnaire/saveResultAndAnswer", method = RequestMethod.POST)
    @ApiOperation(value = "保存用户问卷答案")
    @ApiOperation(value = "保存更新用户问卷答案")
    public String saveResultAndAnswer( @ApiParam(name = "jsonData", value = "问题和答案字符串")@RequestParam(value = "jsonData") String jsonData,
                                       @ApiParam(name = "patientCode", value = "居民code")@RequestParam(value = "patientCode")String patientCode,
                                       @ApiParam(name = "doctor", value = "医生code")@RequestParam(value = "doctor")String doctor,
                                       @ApiParam(name = "customerCode", value = "客服code")@RequestParam(value = "customerCode")String customerCode,
                                       @ApiParam(name = "labelType", value = "问卷标签")@RequestParam(value = "labelType")Integer labelType,
                                       @ApiParam(name = "isAgain", value = "筛查入口(labelType=5时要填),0是第一次筛查 1是再次评估")@RequestParam(value = "isAgain", required = false)int isAgain,
                                       @ApiParam(name = "source", value = "来源(1医生发放 2居民自我评估)")@RequestParam(value = "source")int source) {
                                       @ApiParam(name = "source", value = "来源(1医生发放 2居民自我评估)")@RequestParam(value = "source")int source,
                                       @ApiParam(name = "resultCode", value = "问卷结果code")@RequestParam(value = "resultCode")String resultCode) {
        try {
            JSONObject json = new JSONObject(jsonData);
            if (labelType == 5){
                return  write(200, "保存成功!","data",surveyScreenResultService.saveScreenResultAndAnswer(patientCode, doctor, isAgain, source, json));
                return  write(200, "保存成功!","data",surveyScreenResultService.saveScreenResultAndAnswer(patientCode, doctor, isAgain, source, json, resultCode));
            }else {
                return write(200, "保存成功!", "data", managerQuestionnaireService.saveQuestionResultAndAnswer(json, patientCode, customerCode, doctor));
                return write(200, "保存成功!", "data", managerQuestionnaireService.saveQuestionResultAndAnswer(json, patientCode, customerCode, doctor, resultCode));
            }
        } catch (Exception e) {
            e.printStackTrace();