Forráskód Böngészése

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

huangwenjie 7 éve
szülő
commit
6126ad21a7

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

@ -206,7 +206,7 @@ public class SurveyScreenResult extends IdEntity implements Serializable{
        this.isDanger = isDanger;
    }
    @Column(name = "order")
    @Column(name = "is_order")
    public int getOrder() {
        return order;
    }

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

@ -6,13 +6,14 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.lang.annotation.Native;
import java.util.List;
/**
 * Created by zhangdan on 2018/7/4.
 */
public interface SurveyTemplateResultDao extends PagingAndSortingRepository<SurveyTemplateResult, Long> {
    @Query("select a from SurveyTemplateResult a where a.templateCode=?1 and a.lowScore<=?2 and a.highScore>=?2")
    @Query(value = "SELECT * FROM  wlyy_survey_template_result WHERE template_code =?1 AND IF(high_score IS NULL,low_score<=?2,low_score <= ?2 AND high_score >= ?2)",nativeQuery = true)
    SurveyTemplateResult getByTemplateCodeAndLowScoreAndHighScore (String template,int score);
}

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

@ -47,11 +47,15 @@ public class SurveyScreenResultService extends BaseService {
    @Autowired
    private SurveyTemplateQuestionsDao surveyTemplateQuestionsDao;
    @Autowired
    private SurveyOptionAnswersDao surveyOptionAnswersDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private SurveyAdviceDao surveyAdviceDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private ManagerQuestionnaireService managerQuestionnaireService;
    private Logger logger = LoggerFactory.getLogger(this.getClass());
@ -117,7 +121,7 @@ public class SurveyScreenResultService extends BaseService {
     */
    public List<SurveyTemplates> getScreenList(int pageNo,int pageSize,int labelType){
        int start = (pageNo-1)*pageSize;
        String sql = "SELECT st.* FROM wlyy_survey_templates st LEFT JOIN wlyy_survey_label_info sli ON st.`code`= sli.relation_code WHERE st.del = 1 and sli.label="+labelType+" limit "+start+","+pageSize;
        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+" order by st.create_time desc limit "+start+","+pageSize;
        List<SurveyTemplates> surveyTemplatesList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(SurveyTemplates.class));
        return surveyTemplatesList;
    }
@ -129,7 +133,7 @@ public class SurveyScreenResultService extends BaseService {
     * @param source
     * @param jsonData
     */
    public String saveScreenResult(String patientCode,String doctor,int isAgain,int source, JSONObject jsonData){
    public String saveScreenResultAndAnswer(String patientCode,String doctor,int isAgain,int source, JSONObject jsonData)throws Exception{
        System.out.println("********保存筛查结果--jsonData********* " + jsonData);
        String surveyCode = jsonData.get("surveyCode").toString();
        SurveyTemplates surveyTemplates = surveyTemplatesDao.findById(surveyCode);
@ -138,6 +142,7 @@ public class SurveyScreenResultService extends BaseService {
        //解析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());
@ -148,7 +153,20 @@ 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());
                        int score = Integer.parseInt(option.getString("score"));
                        /*String code = getCode();
                        String optionCode = option.get("optionCode").toString();
                        String comment = null;
                        int haveComment = 0;
                        if (option.has("comment")) {
                            comment = option.get("comment").toString();
                            haveComment = 1;
                        }
                        //保存到选择题答案表
                        SurveyOptionAnswers optionAnswer = new SurveyOptionAnswers(code, patientCode, surveyCode, qstCode, optionCode, comment, type, createTime,patient.getOpenid());
                        surveyOptionAnswersDao.save(optionAnswer);
                        //选择题修改统计表数量
                        surveyStatisticsDao.modifyAmount(surveyCode, qstCode, optionCode);*/
                        int score = option.getInt("score");
                        totalScore += score;
                    }
                }
@ -204,6 +222,7 @@ public class SurveyScreenResultService extends BaseService {
        surveyScreenResult.setOver(1);
        surveyScreenResult.setCzrq(new Date());
        surveyScreenResult.setIsAgain(1);
        surveyScreenResult.setIsEducate(0);
        surveyScreenResult.setScreenResultScore(totalScore);
        if (surveyTemplateResult!=null){
            surveyScreenResult.setScreenResultCode(surveyTemplateResult.getCode());
@ -211,8 +230,8 @@ public class SurveyScreenResultService extends BaseService {
            surveyScreenResult.setScreenResult(surveyTemplateResult.getResult());
        }
        surveyScreenResultDao.save(surveyScreenResult);
        managerQuestionnaireService.saveAnswer(patientCode,code,jsonData);
        return code;
    }
    public JSONObject getScreenResultDetail(String code)throws Exception{
@ -321,6 +340,10 @@ public class SurveyScreenResultService extends BaseService {
            mapList.add(sMap);
        }
        map.put("screenList",mapList);
        return map;
    }
    public Map<String,Object> patientGetResult(String patientCode){
        Map<String,Object> map = new HashedMap();
        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);

+ 123 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistScreenResultService.java

@ -0,0 +1,123 @@
package com.yihu.wlyy.service.specialist;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.specialist.PatientDiseaseServer;
import com.yihu.wlyy.entity.specialist.SpecialDisease;
import com.yihu.wlyy.entity.specialist.TeamDiseaseRelation;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelInfoDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.specialist.PatientDiseaseServerDao;
import com.yihu.wlyy.repository.specialist.SpecialDiseaseDao;
import com.yihu.wlyy.repository.specialist.TeamDiseaseRelationDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.http.HttpResponse;
import com.yihu.wlyy.util.http.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by Trick on 2018/5/31.
 */
@Service
@Transactional
public class SpecialistScreenResultService extends BaseService {
    private static org.slf4j.Logger logger = LoggerFactory.getLogger(SpecialistScreenResultService.class);
    @Autowired
    private SignPatientLabelDao signPatientLabelDao;
    @Autowired
    private SignPatientLabelInfoDao signPatientLabelInfoDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Value("${specialist.url}")
    private String specialistUrl;
    @Autowired
    private DoctorAdminTeamDao doctorAdminTeamDao;
    @Autowired
    private TeamDiseaseRelationDao teamDiseaseRelationDao;
    @Autowired
    private PatientDiseaseServerDao patientDiseaseServerDao;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private SpecialDiseaseDao specialDiseaseDao;
    @Autowired
    private MessageDao messageDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    public JSONArray getScreenList(String doctor,int type,Integer page,Integer size) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("doctor", doctor);
        param.put("type", type);
        param.put("pageNo", page);
        param.put("pageSize", size);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/getScreenResult", param);
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
            return  rs.getJSONArray("detailModelList");
        }
        return null;
    }
    public JSONObject getScreenCount(String doctor) throws Exception {
        JSONObject jsonObject = new JSONObject();
        Map<String, Object> param = new HashedMap();
        param.put("doctor", doctor);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/getScreenCount", param);
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
            jsonObject =  rs.getJSONObject("obj");
            return  jsonObject;
        }
        jsonObject.put("status",-1);
        jsonObject.put("message",rs.get("message"));
        return jsonObject;
    }
    public JSONObject getSpecialScreenResultDetail(String code) throws Exception {
        Map<String, Object> param = new HashedMap();
        JSONObject jsonObject = new JSONObject();
        param.put("code", code);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/getScreenResultDetail", param);
        JSONObject rs = new JSONObject(response.getContent());
        if (rs.getInt("status")==200) {
            jsonObject = rs.getJSONObject("obj");
            return  jsonObject;
        }
        jsonObject.put("status",-1);
        jsonObject.put("message",rs.get("message"));
        return jsonObject;
    }
}

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

@ -1759,7 +1759,7 @@ public class ManagerQuestionnaireService extends BaseService {
//            获取每一道题的信息
            JSONObject question = new JSONObject(questions.get(i).toString());
            String qstCode = question.get("qstCode").toString();
            int qstsort = Integer.parseInt(question.get("sort").toString());
            //int qstsort = Integer.parseInt(question.get("sort").toString());
            int type = Integer.parseInt(question.get("type").toString());
            if (type != 2) {
                if (question.has("options")) {
@ -1769,7 +1769,7 @@ public class ManagerQuestionnaireService extends BaseService {
                        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());
                        //int optsort = Integer.parseInt(option.get("sort").toString());
                        String comment = null;
                        int haveComment = 0;
                        if (option.has("comment")) {

+ 62 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/SpecialistScreenResultController.java

@ -0,0 +1,62 @@
package com.yihu.wlyy.web.doctor.specialist;
import com.yihu.wlyy.service.specialist.SpecialistScreenResultService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
 * Created by zhangdan on 2018/7/6.
 */
@RestController
@RequestMapping(value = "/doctor/specialist/screen", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "专科医生-疾病筛查部分")
public class SpecialistScreenResultController extends BaseController {
    @Autowired
    private SpecialistScreenResultService specialistScreenResultService;
    @RequestMapping(value = "/getList",method = RequestMethod.GET)
    @ApiOperation(value = "专科医生获取筛查记录列表")
    public String createSpecialistPatientRelation(@ApiParam(name = "doctor", value = "专科医生ID")@RequestParam(value = "doctor")String doctor,
                                                                         @ApiParam(value = "当前页")@RequestParam(value = "pageNo") int pageNo,
                                                                         @ApiParam(value = "显示记录数")@RequestParam(value = "pageSize") int pageSize,
                                                                         @ApiParam(value = "1已跟踪 2已预约")@RequestParam(value = "type",required = false) int type){
        try {
            return write(200,"获取成功!","data",specialistScreenResultService.getScreenList(doctor,type,pageNo,pageSize));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
    @RequestMapping(value = "getScreenCount",method = RequestMethod.POST)
    @ApiOperation(value = "专科医生首页--筛查已跟踪和已预约的数目")
    public String findSpecialistPatientRelation(@ApiParam(name = "doctor", value = "专科医生ID")@RequestParam(value = "doctor")String doctor){
        try {
            return write(200,"获取成功!","data",specialistScreenResultService.getScreenCount(doctor));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
    @RequestMapping(value = "getScreenResultDetail",method = RequestMethod.GET)
    @ApiOperation(value = "查看筛查结果记录详情")
    public String getScreenResultDetail(@ApiParam(value = "筛查结果唯一code")@RequestParam(value = "code") String code) {
        try {
            return write(200,"获取成功!","data",specialistScreenResultService.getSpecialScreenResultDetail(code));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
}

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

@ -568,19 +568,18 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
    @ResponseBody
    public String saveAnswer( @RequestParam String jsonData,
                              @ApiParam(value = "居民code")@RequestParam(value = "patientCode")String patientCode,
                              @ApiParam(value = "问卷标签")@RequestParam(value = "labelType")int labelType,
                              @ApiParam(value = "问卷标签")@RequestParam(value = "labelType")Integer 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);
                return  write(200, "保存成功!","data",surveyScreenResultService.saveScreenResultAndAnswer(patientCode,getUID(),isAgain,source,json));
            }else {
                managerQuestionnaireService.saveAnswer(patientCode, "",json);
                return write(200, "保存成功!");
            }
            managerQuestionnaireService.saveAnswer(patientCode, screenResultcode,json);
            return write(200, "保存成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "保存失败!");

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

@ -102,8 +102,8 @@ public class    PatientQuestionnaireController extends BaseController {
    //----------------------------------疾病筛查-----------------------------------------//
    @RequestMapping(value = "getResultAndScreenList", method = RequestMethod.GET)
    @ApiOperation(value = "根据问卷标签类型获取筛查问卷列表和自己的筛查结果")
    @RequestMapping(value = "getScreenList", method = RequestMethod.GET)
    @ApiOperation(value = "根据问卷标签类型获取筛查问卷列表")
    @ResponseBody
    public String getResultAndScreenList(@ApiParam(value = "当前页")@RequestParam(value = "pageNo") int pageNo,
                                @ApiParam(value = "显示记录数")@RequestParam(value = "pageSize") int pageSize,
@ -116,6 +116,18 @@ public class    PatientQuestionnaireController extends BaseController {
        }
    }
    @RequestMapping(value = "getResultList", method = RequestMethod.GET)
    @ApiOperation(value = "获取自己的筛查结果")
    @ResponseBody
    public String getResultnList() {
        try {
            return write(200, "获取成功!", "data", surveyScreenResultService.patientGetResult(getRepUID()));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "getResultByTemplateCode", method = RequestMethod.GET)
    @ApiOperation(value = "居民查看具体一个筛查模板自己的结果")
    @ResponseBody
@ -167,12 +179,12 @@ public class    PatientQuestionnaireController extends BaseController {
            JSONObject json = new JSONObject(jsonData);
            //如果是评分筛查还要保存最后记录
            String screenResultcode = "";
            if (labelType==5){
                screenResultcode = surveyScreenResultService.saveScreenResult(patientCode,getUID(),isAgain,source,json);
                return  write(200, "保存成功!","data",surveyScreenResultService.saveScreenResultAndAnswer(patientCode,getUID(),isAgain,source,json));
            }else {
                managerQuestionnaireService.saveAnswer(patientCode, "",json);
                return write(200, "保存成功!");
            }
            managerQuestionnaireService.saveAnswer(patientCode, screenResultcode,json);
            return write(200, "保存成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "保存失败!");