Jelajahi Sumber

修改疾病筛查推送人数接口

humingfen 6 tahun lalu
induk
melakukan
bfd639c611

+ 10 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyAnswers.java

@ -28,6 +28,8 @@ public class SurveyAnswers extends IdEntity implements Serializable {
//    用户openId
    private String openId;
    //调查问卷结果code
    private String questionResultCode;
    public SurveyAnswers() {
    }
@ -106,4 +108,12 @@ public class SurveyAnswers extends IdEntity implements Serializable {
    public void setOpenId(String openId) {
        this.openId = openId;
    }
    public String getQuestionResultCode() {
        return questionResultCode;
    }
    public void setQuestionResultCode(String questionResultCode) {
        this.questionResultCode = questionResultCode;
    }
}

+ 4 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/survey/SurveyQuestionnaireDao.java

@ -9,6 +9,9 @@ import java.util.List;
public interface SurveyQuestionnaireDao extends PagingAndSortingRepository<SurveyQuestionnaire,Long>,JpaSpecificationExecutor<SurveyQuestionnaire> {
    @Query("select q from SurveyQuestionnaire q where q.surveyCode = ?1")
    @Query("select q from SurveyQuestionnaire q where q.surveyCode = ?1 and (q.questionType = 0 or q.questionType = 1) ")
    List<SurveyQuestionnaire> findBySurveyCode(String surveyCode);
    @Query("select q from SurveyQuestionnaire q where q.surveyCode = ?1 and q.questionType = 2 ")
    List<SurveyQuestionnaire> findEssayQuestionBySurveyCode(String surverCode);
}

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

@ -54,8 +54,8 @@ public class QuestionnaireManageService extends BaseJpaService {
        String servicer = "";
        int size = workorderServicerDOS.size();
        int len = 0;
        if(size > 5){
            len = 5;
        if(size > 3){
            len = 3;
        }else {
            len = size;
        }
@ -151,11 +151,11 @@ public class QuestionnaireManageService extends BaseJpaService {
        SurveyQuestionResult questionResult = questionResultDao.findByCode(code);
        String patient = questionResult.getPatientCode();
        String surverCode = questionResult.getSurveyCode();
        //获取模板问题
        //获取单选、多选问题
        List<SurveyQuestionnaire> questionList = surveyQuestionnaireDao.findBySurveyCode(surverCode);
        //查找选项和答案
        //查找单选、多选选项和答案
        Map<String, Object> answerMap = new HashMap<>();
        String sql = "SELECT soa.*, sqo.content FROM wlyy_survey_option_answers soa LEFT JOIN wlyy_survey_questionnaire_options sqo ON soa.options_code= sqo.code WHERE soa.screen_result_code = ? AND soa.patient=? AND soa.survey_code=?";
        String sql = "SELECT soa.*, sqo.content FROM wlyy_survey_option_answers soa LEFT JOIN wlyy_survey_questionnaire_options sqo ON soa.options_code= sqo.code AND soa.survey_code = sqo.survey_code AND sqo.del=1 WHERE soa.screen_result_code = ? AND soa.patient=? AND soa.survey_code=?";
        List<Map<String, Object>> optionAnswersList = jdbcTemplate.queryForList(sql, new Object[]{code, patient, surverCode});
        for (SurveyQuestionnaire question : questionList) {
            List<Map<String, Object>> optionList = new ArrayList<>();
@ -170,6 +170,26 @@ public class QuestionnaireManageService extends BaseJpaService {
            map.put("option", optionList);
            answerMap.put(question.getSort() + "", map);
        }
        //获取问答题列表
        List<SurveyQuestionnaire> essayQuestionList = surveyQuestionnaireDao.findEssayQuestionBySurveyCode(surverCode);
        String s = "SELECT a.*, q.title " +
                "FROM wlyy_survey_answers a  " +
                "LEFT JOIN wlyy_survey_questionnaire q ON a.question_code= q.code AND a.survey_code = q.survey_code AND q.del=1 AND q.question_type = 2 " +
                "WHERE a.question_result_code = ? AND a.patient= ? AND a.survey_code= ?";
        List<Map<String, Object>> questionAnswersList = jdbcTemplate.queryForList(s, new Object[]{code, patient, surverCode});
        for (SurveyQuestionnaire essayQuestion : essayQuestionList) {
            List<Map<String, Object>> list = new ArrayList<>();
            Map<String, Object> map = new HashMap<>();
            map.put("question", essayQuestion);
            String qusCode = essayQuestion.getCode();
            for (Map<String, Object> question : questionAnswersList) {
                if (question.get("question_code").equals(qusCode)) {
                    list.add(question);
                }
            }
            map.put("option", list);
            answerMap.put(essayQuestion.getSort() + "", map);
        }
        json.put("answer", answerMap);
        return json;
    }

+ 1 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/SynergyManageService.java

@ -417,7 +417,7 @@ public class SynergyManageService extends BaseJpaService {
            //获取处理结果
            if(status == 3) {
                map.put("resultRemark", workorderDO.getDealResultRemark());
                map.put("completeTime", workorderDO.getCompleteTime());
                map.put("completeTime", sdf.format(workorderDO.getCompleteTime()));
                List<ManageSynergyAccessoryDO> accessoryList = accessoryList(workorderCode);
                map.put("accessoryList",accessoryList);//附件列表
            }

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

@ -9,6 +9,7 @@ import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.jimeiJkEdu.JMJkEduArticleService;
import com.yihu.wlyy.service.survey.ManagerQuestionnaireService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.IdCardUtil;
@ -88,6 +89,8 @@ public class SurveyScreenResultService extends BaseService {
    private WechatTemplateConfigDao templateConfigDao;
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private JMJkEduArticleService jmJkEduArticleService;
    private Logger logger = LoggerFactory.getLogger(this.getClass());
@ -1105,9 +1108,10 @@ public class SurveyScreenResultService extends BaseService {
    //获取筛查居民信息
    public List<Map<String, Object>> initPatient(String doctor, String labelType, String serverType, Long teamCode) {
        String sql = "SELECT DISTINCT p.`code` as servicePatientCode, p.`name` as servicePatientName, t1.ssc,t1.idcard,t1.mobile,t1.hospital,t1.hospital_name as hospitalName, h.town,h.town_name as townName " +
                "FROM  wlyy_sign_family t1  LEFT JOIN wlyy_patient p on p. CODE = t1.patient   " +
                "FROM  wlyy_sign_family t1 " +
                "LEFT JOIN wlyy_patient p on p. CODE = t1.patient   " +
                "LEFT JOIN wlyy_sign_patient_label_info t2 on t2.patient = t1.patient and t2.label_type = " + labelType + " and t2.status=1 " +
                "RIGHT JOIN wlyy_sign_family_server s on s.sign_code = t1.code" +
                "RIGHT JOIN wlyy_sign_family_server s on s.sign_code = t1.code " +
                "LEFT JOIN dm_hospital h on t1.hospital = h.`code` " +
                "WHERE ( t1.doctor = ? OR t1.doctor_health = ?) AND t1. STATUS > 0  AND t1.admin_team_code = ? " ;
        if(StringUtils.isNotBlank(serverType)){
@ -1127,6 +1131,37 @@ public class SurveyScreenResultService extends BaseService {
     * @return
     * @throws Exception
     */
    public JSONObject createWorkOrder(String jsonData, String patientInfo, String doctor) throws Exception {
        JSONObject object = new JSONObject(jsonData);
//        JSONArray patientInfos = new JSONArray(patientInfo);
        Doctor d = doctorService.findDoctorByCode(doctor);
        //获取关联业务名称
        if(object.getInt("type") == 4){
            Survey survey = surveyDao.findById(object.getString("relationCode"));
            object.put("relationCodeName", survey.getTitle());
            object.put("createUserRole", 2);
        }else if(object.getInt("type") == 5){
            SurveyTemplates templates = surveyTemplatesDao.findById(object.getString("relationCode"));
            object.put("relationCodeName", templates.getTitle());
            object.put("createUserRole", 1);
            object.put("hospital", d.getHospital());
            object.put("hospitalName", d.getHospitalName());
        }
        object.put("createUser", d.getCode());
        object.put("createUserName", d.getName());
        object.put("createUserType", 1);
        Map<String, Object> param = new HashedMap();
        param.put("patientInfo", patientInfo);
        param.put("jsonData", object.toString());
        HttpResponse response = null;
        response = HttpUtils.doPost(customerUrl + "synergy/questionnaire/createWorkOrder", param);
        JSONObject rs = new JSONObject(response.getContent());
        if(rs.getInt("status") == 200) {
            return rs;
        }
        throw new Exception();
    }
    public JSONObject createWorkOrder(String jsonData, List<Map<String, Object>> patientInfo, String doctor) throws Exception {
        JSONObject object = new JSONObject(jsonData);
        JSONArray patientInfos = new JSONArray(patientInfo);
@ -1157,4 +1192,135 @@ public class SurveyScreenResultService extends BaseService {
        }
        throw new Exception();
    }
    public List<Map<String, Object>> initPatients(String userCode, String[] groups, String group, String labelType, Long teamCode, String patients, Set<String> patientSet) throws Exception {
        List<Map<String, Object>> patientInfos = new ArrayList<>();
        if (StringUtils.isNotBlank(group) && groups.length > 0) {
            //递归患者数据
            for (String g : groups) {
                List<Map<String, Object>> patientInfo = getPatientByGroup(userCode,g, labelType, teamCode, 0, 100);
                for (Map<String, Object> patient : patientInfo){
                    int size = patientSet.size();
                    patientSet.add((String) patient.get("servicePatientCode"));
                    if (patientSet.size() > size){
                        patientInfos.add(patient);
                    }
                }
            }
        }
        //查出patients的居民信息
        if(StringUtils.isNotBlank(patients)){
            String sql = "SELECT DISTINCT p.`code` as servicePatientCode, p.`name` as servicePatientName, s.ssc,s.idcard,s.mobile,s.hospital,s.hospital_name as hospitalName, h.town,h.town_name as townName  " +
                    "FROM     wlyy_patient p " +
                    "LEFT JOIN wlyy_sign_family s on p.`code` = s.patient AND s.`status`>0 " +
                    "LEFT JOIN dm_hospital h on s.hospital = h.`code` " +
                    "where   p.`code` in (" + patients + ")";
            patientInfos = jdbcTemplate.queryForList(sql);
        }
        return patientInfos;
    }
    private List<Map<String, Object>> getPatientByGroup(String userCode, String labelCode, String labelType, Long teamCode, int page, int pagesize) throws Exception {
        List<Map<String, Object>> result = getPatientByLabel(userCode, labelCode, labelType, teamCode, page, pagesize, false, "",false,null,null,null);
        if (result.size() == 100) {
            getPatientByGroup(userCode,labelCode, labelType, teamCode, page + 1, pagesize);
        }
        return result;
    }
    public List<Map<String, Object>> getPatientByLabel(String doctor, String labelCode, String labelType,
                                                       Long teamCode, int page, int pagesize, boolean isSlowDisease,
                                                       String diseaseCondition, boolean isFollowWeChat, String trackFlag, String sDate, String eDate) throws Exception {
        Doctor doc = doctorDao.findByCode(doctor);
        if (doc == null) {
            throw new Exception("doctor info can not find");
        }
        List<Map<String, Object>> signList = new ArrayList<>();
        int start = page * pagesize;
        String sql = "";
        Object[] args = null;
        if("1".equals(labelType)){
            sql ="  SELECT " +
                    "  DISTINCT p.`code` as servicePatientCode, p.`name` as servicePatientName, t1.ssc,t1.idcard,t1.mobile,t1.hospital,t1.hospital_name as hospitalName, h.town,h.town_name as townName  " +
                    "  FROM " +
                    "   wlyy_sign_family t1 " +
                    "   LEFT JOIN wlyy_patient p on p. CODE = t1.patient " +
                    "   LEFT JOIN wlyy_sign_patient_label_info t2 on t2.patient = t1.patient and t2.label_type = 3 and t2.status=1 " +
                    "   LEFT JOIN dm_hospital h on t1.hospital = h.`code`"+
                    "   RIGHT JOIN wlyy_sign_family_server s on s.sign_code = t1.code and s.server_type = '"+labelCode+"' "+
                    "  WHERE ( " +
                    "   t1.doctor = ? " +
                    "   OR t1.doctor_health = ? " +
                    "  ) " +
                    "  AND t1. STATUS > 0  AND t1.admin_team_code = ?";
            if(StringUtils.isNotBlank(diseaseCondition)){
                sql = sql + " AND p.disease_condition ="+diseaseCondition;
            }
            if(isFollowWeChat){
                sql += "  AND p.openid IS NOT NULL AND p.openid <>'' ";
            }
            args = new Object[]{doctor, doctor, teamCode};
        }else if("3".equals(labelType) && isSlowDisease){
            //慢病管理
            sql = "SELECT " +
                    "  DISTINCT t1.* " +
                    "  FROM  wlyy_sign_family t1 " +
                    "  LEFT JOIN wlyy_patient p on p.code = t1.patient  "+
                    "  RIGHT JOIN wlyy_sign_patient_label_info t2 on t2.patient = t1.patient ";
            if(StringUtils.isNotBlank(trackFlag) && "1".equals(trackFlag)){
                sql = sql +" JOIN wlyy_track_patient tp ON tp.patient_code = p.code";
            }
            sql = sql + " WHERE t2.label = ?";
            if(org.apache.commons.lang3.StringUtils.isNotBlank(diseaseCondition)) {
                sql = sql + " AND p.disease_condition = ? ";
            }
            sql = sql + "    AND t2.label_type = ? " +
                    "    AND t2.status = 1 " +
                    "    AND t1.patient = t2.patient " +
                    "    AND (t1.doctor = ? or t1.doctor_health = ?)" +
                    "    AND t1.status > 0 " +
                    "    AND t1.admin_team_code = ? ";
            if(isFollowWeChat){
                sql += "  AND p.openid IS NOT NULL AND p.openid <>'' ";
            }
            if(StringUtils.isNotBlank(trackFlag) && "1".equals(trackFlag)){
                sql = sql + " AND tp.del='1'  AND tp.doctor_code ='"+doctor+"' AND tp.team_code ="+teamCode;
                if(org.apache.commons.lang3.StringUtils.isNotBlank(sDate)&& org.apache.commons.lang3.StringUtils.isNotBlank(eDate)){
                    sql += " AND tp.create_time >='"+sDate+" 00:00:00' AND tp.create_time <='"+eDate+" 23:59:59' ";
                }
            }
            sql = sql + " order by p.standard_status DESC ,p.disease_condition DESC,t2.label DESC,t1.openid DESC ,convert(t1.name using gbk) ";
            if(StringUtils.isNotBlank(diseaseCondition)) {
                args = new Object[]{labelCode, diseaseCondition, labelType, doctor, doctor, teamCode};
            }else{
                args = new Object[]{labelCode, labelType, doctor, doctor,  teamCode};
            }
        } else {
                sql = "SELECT " +
                        " DISTINCT p.`code` as servicePatientCode, p.`name` as servicePatientName, t1.ssc,t1.idcard,t1.mobile,t1.hospital,t1.hospital_name as hospitalName, h.town,h.town_name as townName " +
                        " FROM wlyy_sign_family t1 " +
                        " LEFT JOIN wlyy_sign_patient_label_info t2 on t1.patient = t2.patient " +
                        " LEFT JOIN wlyy_patient p on p.`code` = t1.patient " +
                        " LEFT JOIN dm_hospital h on t1.hospital = h.`code`"+
                        " WHERE " +
                        "    t2.label = ? " +
                        "    AND t2.label_type = ? " +
                        "    AND t2.status = 1 " +
                        "    AND t1.patient = t2.patient " +
                        "    AND (t1.doctor = ? or t1.doctor_health = ?)" +
                        "    AND t1.status > 0 " +
                        "    AND t1.admin_team_code = ? "+
                        "    AND p.`status` =1 ";
                if(isFollowWeChat){
                    sql += "  AND p.openid IS NOT NULL AND p.openid <>'' ";
                }
                args = new Object[]{labelCode, labelType, doctor, doctor, teamCode};
        }
        sql += " limit " + start + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        return signList;
    }
}

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

@ -1775,7 +1775,7 @@ public class ManagerQuestionnaireService extends BaseService {
        return  json;
    }
    public void saveAnswer(String patient,String screenResultCode, JSONObject jsonData) throws Exception {
    public void saveAnswer(String patient,String resultCode, JSONObject jsonData) throws Exception {
        System.out.println("********jsonData********* " + jsonData);
        //解析json保存各种答案
        String surveyCode = jsonData.get("surveyCode").toString();
@ -1805,7 +1805,7 @@ public class ManagerQuestionnaireService extends BaseService {
                        }
//                 保存到选择题答案表
                        SurveyOptionAnswers optionAnswer = new SurveyOptionAnswers(code, patient, surveyCode, qstCode, optionCode, comment, type, createTime);
                        optionAnswer.setScreenResultCode(screenResultCode);
                        optionAnswer.setScreenResultCode(resultCode);
                        surveyOptionAnswersDao.save(optionAnswer);
//                选择题修改统计表数量
                        surveyStatisticsDao.modifyAmount(surveyCode, qstCode, optionCode);
@ -1818,6 +1818,7 @@ public class ManagerQuestionnaireService extends BaseService {
//                    保存到问答题答案表
                    String code = getCode();
                    SurveyAnswers surveyAnswer = new SurveyAnswers(code, surveyCode, patient, qstCode, content, createTime);
                    surveyAnswer.setQuestionResultCode(resultCode);
                    surveyAnswersDao.save(surveyAnswer);
//                问答题保存到统计表(只负责更改数量不负责创建)
                    surveyStatisticsDao.modifyAmount(surveyCode, qstCode);
@ -1875,7 +1876,7 @@ public class ManagerQuestionnaireService extends BaseService {
        }
        tableSql += " , wlyy_patient p  ";
        whereSql += " and p.code=w.patient AND p.openid IS NOT NULL and p.openid <>'' ";
        whereSql += " and p.code=w.patient ";
        if (StringUtils.isNotBlank(labelSexType)) {
            whereSql += " and p.sex in (" + labelSexType + ") ";
        }

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

@ -5,6 +5,7 @@ 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.service.jimeiJkEdu.JMJkEduArticleService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
@ -12,14 +13,17 @@ import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
 * 医生端-疾病筛查
@ -44,11 +48,14 @@ public class DoctorSurveyScreenResultController extends WeixinBaseController {
    private SurveyScreenResultService surveyScreenResultService;
    @Autowired
    private SpecialDiseaseDao specialDiseaseDao;
    @Autowired
    private JMJkEduArticleService jmJkEduArticleService;
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    /**
     * 获取筛查结果列表
     *
     * @param pageNo
     * @param pageSize
     * @param diseaseType
@ -60,14 +67,14 @@ public class DoctorSurveyScreenResultController extends WeixinBaseController {
    @RequestMapping(value = "getResultList", method = RequestMethod.GET)
    @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已接诊 4待处理)")@RequestParam(value = "dealType",required = false) String dealType,
                                @ApiParam(value = "搜索居民的姓名")@RequestParam(value = "patientName",required = false) String patientName,
                                @ApiParam(value = "是否高危预警(0否 1是)")@RequestParam(value = "isDanger",required = false) String isDanger){
    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已接诊 4待处理)") @RequestParam(value = "dealType", required = false) String dealType,
                                @ApiParam(value = "搜索居民的姓名") @RequestParam(value = "patientName", required = false) String patientName,
                                @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));
            return write(200, "查询成功!", "data", surveyScreenResultService.getResultList(pageNo, pageSize, getUID(), diseaseType, dealType, isDanger, patientName));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
@ -77,7 +84,7 @@ public class DoctorSurveyScreenResultController extends WeixinBaseController {
    @RequestMapping(value = "getSpecialDisease", method = RequestMethod.GET)
    @ApiOperation(value = "获取专科疾病类型")
    @ResponseBody
    public String getSpecialDisease(){
    public String getSpecialDisease() {
        try {
            return write(200, "查询成功!", "data", specialDiseaseDao.findByDel("1"));
        } catch (Exception e) {
@ -89,6 +96,7 @@ public class DoctorSurveyScreenResultController extends WeixinBaseController {
    /**
     * 获取筛查问卷列表
     *
     * @param pageNo
     * @param pageSize
     * @param labelType
@ -97,12 +105,12 @@ public class DoctorSurveyScreenResultController extends WeixinBaseController {
    @RequestMapping(value = "getScreenList", method = RequestMethod.POST)
    @ApiOperation(value = "根据问卷标签类型获取筛查问卷列表")
    @ResponseBody
    public String getScreenList(@ApiParam(value = "当前页")@RequestParam(value = "pageNo") int pageNo,
                                @ApiParam(value = "显示记录数")@RequestParam(value = "pageSize") int pageSize,
                                @ApiParam(value = "问卷类型标签")@RequestParam(value = "labelType") int labelType,
                                @ApiParam(value = "问卷题目")@RequestParam(value = "title",required = false) String title) {
    public String getScreenList(@ApiParam(value = "当前页") @RequestParam(value = "pageNo") int pageNo,
                                @ApiParam(value = "显示记录数") @RequestParam(value = "pageSize") int pageSize,
                                @ApiParam(value = "问卷类型标签") @RequestParam(value = "labelType") int labelType,
                                @ApiParam(value = "问卷题目") @RequestParam(value = "title", required = false) String title) {
        try {
            return write(200, "获取成功!", "data", surveyScreenResultService.getScreenList(pageNo,pageSize,labelType,title));
            return write(200, "获取成功!", "data", surveyScreenResultService.getScreenList(pageNo, pageSize, labelType, title));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
@ -112,7 +120,7 @@ public class DoctorSurveyScreenResultController extends WeixinBaseController {
    @RequestMapping(value = "getScreenResultDetail", method = RequestMethod.GET)
    @ApiOperation(value = "查看筛查结果记录详情")
    @ResponseBody
    public String getScreenResultDetail(@ApiParam(value = "筛查结果唯一code")@RequestParam(value = "code") String code) {
    public String getScreenResultDetail(@ApiParam(value = "筛查结果唯一code") @RequestParam(value = "code") String code) {
        try {
            return write(200, "获取成功!", "data", surveyScreenResultService.getScreenResultDetail(code));
        } catch (Exception e) {
@ -124,7 +132,7 @@ public class DoctorSurveyScreenResultController extends WeixinBaseController {
    @RequestMapping(value = "getTemplateAdvice", method = RequestMethod.GET)
    @ApiOperation(value = "获取健康建议列表")
    @ResponseBody
    public String getTemplateAdvice(@ApiParam(value = "筛查模板code")@RequestParam(value = "templateCode") String templateCode) {
    public String getTemplateAdvice(@ApiParam(value = "筛查模板code") @RequestParam(value = "templateCode") String templateCode) {
        try {
            return write(200, "获取成功!", "data", surveyScreenResultService.getTemplateAdviceList(templateCode));
        } catch (Exception e) {
@ -136,14 +144,14 @@ public class DoctorSurveyScreenResultController extends WeixinBaseController {
    @RequestMapping(value = "updateAfterFollwoing", method = RequestMethod.POST)
    @ApiOperation(value = "医生跟踪")
    @ResponseBody
    public String updateAfterFollwoing(@ApiParam(value = "筛查记录code")@RequestParam(value = "code") String code,
                                    @ApiParam(value = "建议code,多个逗号隔开")@RequestParam(value = "adviceCodes") String advicCcodes,
                                    @ApiParam(value = "其他建议")@RequestParam(value = "otherAdvice",required = false) String otherAdvice) {
    public String updateAfterFollwoing(@ApiParam(value = "筛查记录code") @RequestParam(value = "code") String code,
                                       @ApiParam(value = "建议code,多个逗号隔开") @RequestParam(value = "adviceCodes") String advicCcodes,
                                       @ApiParam(value = "其他建议") @RequestParam(value = "otherAdvice", required = false) String otherAdvice) {
        try {
            if (otherAdvice.length()>200){
                return write(-1,"其他建议的字数不得超过200字");
            if (otherAdvice.length() > 200) {
                return write(-1, "其他建议的字数不得超过200字");
            }
            surveyScreenResultService.updateAfterFollowing(code,advicCcodes,otherAdvice);
            surveyScreenResultService.updateAfterFollowing(code, advicCcodes, otherAdvice);
            return write(200, "跟踪成功!");
        } catch (Exception e) {
            e.printStackTrace();
@ -154,9 +162,9 @@ public class DoctorSurveyScreenResultController extends WeixinBaseController {
    @RequestMapping(value = "updateAfterEducate", method = RequestMethod.POST)
    @ApiOperation(value = "医生筛查后进行健康教育")
    @ResponseBody
    public String updateAfterEducate(@ApiParam(value = "筛查记录code")@RequestParam(value = "code") String code) {
    public String updateAfterEducate(@ApiParam(value = "筛查记录code") @RequestParam(value = "code") String code) {
        try {
            surveyScreenResultService.updateColume("is_educate",1,code);
            surveyScreenResultService.updateColume("is_educate", 1, code);
            return write(200, "更新健康教育成功!");
        } catch (Exception e) {
            e.printStackTrace();
@ -169,7 +177,7 @@ public class DoctorSurveyScreenResultController extends WeixinBaseController {
    @ResponseBody
    public String screenStatics() {
        try {
            return write(200, "获取数据成功!","data",surveyScreenResultService.screenStatics(getUID()));
            return write(200, "获取数据成功!", "data", surveyScreenResultService.screenStatics(getUID()));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取数据失败!");
@ -186,10 +194,10 @@ public class DoctorSurveyScreenResultController extends WeixinBaseController {
    @ApiOperation(value = "获取筛选条件数量(医生所签约)")
    @ResponseBody
    public String getAmountByDoctor(
            @ApiParam(value = "筛选条件",defaultValue = "{\"sex\":1,\"disease\":[2,5,6],\"healthCondition\":[0],\"service\":[1,3]}")
            @ApiParam(value = "筛选条件", defaultValue = "{\"sex\":1,\"disease\":[2,5,6],\"healthCondition\":[0],\"service\":[1,3]}")
            @RequestParam String json) {
        try {
            int amount = surveyScreenResultService.getAmountByDoctor(json,getUID());
            int amount = surveyScreenResultService.getAmountByDoctor(json, getUID());
            return write(200, "查询成功!", "amount", amount);
        } catch (Exception e) {
            e.printStackTrace();
@ -225,14 +233,14 @@ public class DoctorSurveyScreenResultController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "/getCount",method = RequestMethod.POST)
    @RequestMapping(value = "/getCount", method = RequestMethod.POST)
    @ApiOperation(value = "确认疾病筛查推送人数")
    public String getCount(@ApiParam(name = "labelType", value = "疾病类型", defaultValue = "3")
                               @RequestParam(value = "labelType", required = false) String labelType,
                           @ApiParam(name = "serverType",value = "服务类型,多个条件以逗号分割")
                               @RequestParam(value = "serverType", required = false) String serverType,
                           @ApiParam(name = "teamCode",value = "行政团队id")
                               @RequestParam(value = "teamCode", required = true) Long teamCode){
                           @RequestParam(value = "labelType", required = false) String labelType,
                           @ApiParam(name = "serverType", value = "服务类型,多个条件以逗号分割")
                           @RequestParam(value = "serverType", required = false) String serverType,
                           @ApiParam(name = "teamCode", value = "行政团队id")
                           @RequestParam(value = "teamCode", required = true) Long teamCode) {
        try {
            List<Map<String, Object>> patientInfo = surveyScreenResultService.initPatient(getUID(), labelType, serverType, teamCode);
            return write(200, "查询成功!", "data", patientInfo.size());
@ -243,22 +251,50 @@ public class DoctorSurveyScreenResultController extends WeixinBaseController {
    }
    @RequestMapping(value = "/createWorkOrder",method = RequestMethod.POST)
    @RequestMapping(value = "/createWorkOrder", method = RequestMethod.POST)
    @ApiOperation(value = "创建协同服务")
    public String getAllQuestions(@ApiParam(name = "jsonData",value = "协同服务json字符串")
                                  @RequestParam(value = "jsonData",required = true)String jsonData,
                                  @ApiParam(name = "labelType", value = "疾病类型", defaultValue = "3")
                                  @RequestParam(value = "labelType", required = false) String labelType,
                                  @ApiParam(name = "serverType",value = "服务类型,多个条件以逗号分割")
                                  @RequestParam(value = "serverType", required = false) String serverType,
                                  @ApiParam(name = "teamCode",value = "行政团队id")
                                  @RequestParam(value = "teamCode", required = true) Long teamCode){
    public String getAllQuestions(@ApiParam(name = "jsonData", value = "协同服务json字符串")
                                  @RequestParam(value = "jsonData", required = true) String jsonData,
                                  @ApiParam(name = "patientInfo", value = "居民信息")
                                  @RequestParam(value = "patientInfo", required = true) String patientInfo) {
        try {
            List<Map<String, Object>> patientInfo = surveyScreenResultService.initPatient(getUID(), labelType, serverType, teamCode);
            return write(200, "创建成功!", "data", surveyScreenResultService.createWorkOrder(jsonData, patientInfo, getUID()));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "创建失败!");
        }
    }
    @RequestMapping(value = "doctorSendScreenToPatients", method = RequestMethod.GET)
    @ApiOperation("确认疾病筛查推送人数")
    public String doctorSendArticleToPatients(
            @RequestParam(value = "patient", required = false) String patient,
            @RequestParam(value = "group", required = false, defaultValue = "") String group,
            @RequestParam(value = "labelType", required = false) String labelType,
            @RequestParam(value = "teamCode", required = true) Long teamCode) {
        try {
            String[] patients = new String[]{};
            String[] groups = new String[]{};
            if (StringUtils.isEmpty(patient) && StringUtils.isEmpty(group)) {
                return new String("请至少选择一个患者!");
            } else {
                if (StringUtils.isNotBlank(group)) {
                    if (group.contains(",")) {
                        groups = group.split(",");
                    } else {
                        groups = new String[]{group};
                    }
                }
            }
            Set<String> patientSet = new HashSet<>(); //放入set中可以去重复
            List<Map<String, Object>> patientInfo = surveyScreenResultService.initPatients(getUID(), groups, group, labelType, teamCode, patient, patientSet);
            if (patientInfo.size() == 0) {
                return new String("请至少选择一个患者!");
            }
            return write(200, "查询成功!", "data", patientInfo);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
}