Browse Source

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

chenweida 7 years ago
parent
commit
b950bfc28f

+ 1 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/HealthEduArticlePatientService.java

@ -118,6 +118,7 @@ public class HealthEduArticlePatientService extends BaseService {
                "     , wlyy_health_edu_article b" +
                " where" +
                "      a.article = b.code" +
                " and (a.type =1 or a.type is null or a.type = '')"+  //添加类型判断是集美的推送还是三师原来的推送
                " and a.patient = ?" +
                (id > 0 ? " and a.id < ? " : "") +
                (wheaType > 0 ? " and a.wheaType = ? " : "") +

+ 243 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -497,6 +497,249 @@ public class SignPatientLabelInfoService extends BaseService {
        }
    }
    /**
     * 根据标签查询患者信息
     *
     * @param labelCode 标签code
     * @param labelType 标签类型
     * @return
     */
    public JSONArray getPatientByLabelCount(String doctor, String labelCode, String labelType, Long teamCode) throws Exception {
        Doctor doc = doctorDao.findByCode(doctor);
        if (doc == null) {
            throw new Exception("doctor info can not find");
        }
        Map<String, JSONObject> result = new TreeMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        String sql = "";
        Object[] args = null;
        if (labelType.equals("5")) {
            Calendar today = Calendar.getInstance();
            Calendar startDate = Calendar.getInstance();
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            sql = "select * " +
                    " from " +
                    "     wlyy_sign_family " +
                    " where (doctor = ? or doctor_health = ?) and status > 0 and admin_team_code = ? ";
            if (labelCode.equals("1")) {
                int week = today.get(Calendar.DAY_OF_WEEK) - 2;
                if (week == -1) {
                    week = 6;
                }
                startDate.add(Calendar.DATE, -week);
                sql += " and apply_date between '" + (df.format(startDate.getTime()) + " 00:00:00")
                        + "' and '" + (df.format(today.getTime()) + " 23:59:59'");
            } else if (labelCode.equals("2")) {
                startDate.set(Calendar.DATE, 1);
                sql += " and apply_date between '" + (df.format(startDate.getTime()) + " 00:00:00")
                        + "' and '" + (df.format(today.getTime()) + " 23:59:59'");
            } else if (labelCode.equals("3")) {
                startDate.add(Calendar.DATE, 30);
                sql += " and end between '" + (df.format(today.getTime()) + " 00:00:00")
                        + "' and '" + (df.format(startDate.getTime()) + " 23:59:59'");
            } else {
                throw new Exception("label is not exist");
            }
            sql += " order by openid desc,convert(name using gbk) ";
            args = new Object[]{doctor, doctor, teamCode};
        }else if("1".equals(labelType)){
            sql = "SELECT " +
                    " f.* " +
                    "FROM " +
                    " wlyy_sign_family_server s ,( " +
                    "  SELECT " +
                    "   t1.*, p.openid AS ptOpenid " +
                    "  FROM " +
                    "   wlyy_sign_family t1, " +
                    "   wlyy_patient p " +
                    "  WHERE " +
                    "  p. CODE = t1.patient " +
                    "  AND ( " +
                    "   t1.doctor = ? " +
                    "   OR t1.doctor_health = ? " +
                    "  ) " +
                    "  AND t1. STATUS > 0 " +
                    "  AND t1.admin_team_code = ?" +
                    " ) f " +
                    "WHERE " +
                    " f. CODE = s.sign_code " +
                    " AND s.server_type ='"+labelCode+"' " +
                    " ORDER BY " +
                    " f.ptOpenid DESC";
            args = new Object[]{doctor, doctor, teamCode};
        } else {
            if (labelCode.equals("0")) {
                sql = "SELECT " +
                        "    t1.* " +
                        " FROM " +
                        "    wlyy_sign_family t1 " +
                        " left join " +
                        "    (select l.patient,l.label,l.label_type,l.label_name from wlyy_sign_family f left join wlyy_sign_patient_label_info l on f.patient = l.patient where (f.doctor = '" + doctor + "' or f.doctor_health = '" + doctor + "') and f.status > 0 and l.label_type = ? and l.status = 1) t2 " +
                        " on t1.patient = t2.patient " +
                        " WHERE " +
                        "    t2.patient is null " +
                        "    AND (t1.doctor = ? or t1.doctor_health = ?) " +
                        "    AND t1.status > 0 " +
                        "    AND t1.admin_team_code = ? order by t1.openid desc,convert(t1.name using gbk) ";
                args = new Object[]{labelType, doctor, doctor, teamCode};
            }else {
                sql = "SELECT " +
                        "    t1.* " +
                        " FROM " +
                        "    wlyy_sign_family t1, " +
                        "    wlyy_sign_patient_label_info t2 " +
                        " 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 = ? order by t1.openid desc,convert(t1.name using gbk) ";
                args = new Object[]{labelCode, labelType, doctor, doctor, teamCode};
            }
        }
        signList = jdbcTemplate.queryForList(sql, args);
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
                if (p == null) {
                    continue;
                }
                if (result.containsKey(p.getCode())) {
                    JSONObject jsonP = result.get(p.getCode());
                    if (!String.valueOf(jsonP.get("signType")).equals(String.valueOf(sign.get("type")))) {
                        jsonP.put("signType", 3);
                    }
                    if (String.valueOf(sign.get("type")).equals("2")) {
                        jsonP.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
                        // 缴费情况
                        jsonP.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
                        // 缴费时间
                        jsonP.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
                        // 缴费类型
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            boolean epTime = false;
                            try {
                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (!epTime) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", 1);
                            }
                        }
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (!epTime) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind", 1);
                        }
                    }
                    continue;
                }
                //List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
                JSONObject json = new JSONObject();
                // 设置患者标识
                json.put("code", p.getCode());
                // 设置患者姓名
                json.put("name", p.getName());
                // 设置患者手机号
                json.put("mobile", p.getMobile());
                // 设置患者微信openid
                json.put("openid", StringUtils.isNotEmpty(p.getOpenid()) ? p.getOpenid() : "");
                // 设置患者联系电话
                json.put("phone", p.getPhone());
                // 设置患者紧急联系人
                json.put("emerMobile", sign.get("emer_mobile") == null ? "" : String.valueOf(sign.get("emer_mobile")));
                // 设置患者头像
                json.put("photo", p.getPhoto());
                // 设置患者年龄
                json.put("age", IdCardUtil.getAgeForIdcard(p.getIdcard()));
                // 设置患者性别
                json.put("sex", p.getSex());
                // 设置签约日期
                json.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
                // 设置签约类型
                json.put("signType", sign.get("type") == null ? "" : sign.get("type"));
                // 身份证号
                json.put("idcard", p.getIdcard());
                // 社保号
                json.put("ssc", p.getSsc());
                if (String.valueOf(sign.get("type")).equals("2")) {
                    // 缴费情况
                    json.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
                    // 缴费时间
                    json.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
                    // 缴费类型
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                } else {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (!epTime) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind", 1);
                }
                // 患者标签
                //json.put("labels", labels == null ? "" : labels);
                result.put(p.getCode(), json);
            }
        }
        if (result.size() > 0) {
            List<JSONObject> list = Lists.newArrayList(result.values());
            return new JSONArray(list);
        } else {
            return new JSONArray();
        }
    }
    /**
     * 获取团队下的患者
     *

+ 65 - 10
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -44,6 +44,7 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -1162,7 +1163,7 @@ public class FamilyContractService extends BaseService {
                }
            }
            new Thread(new SignUploadTask(sf.getCode(), httpUtil,jwUrl)).start();
            new Thread(new SignUploadTask(sf.getCode(), httpUtil, jwUrl)).start();
            JSONObject participants = new JSONObject();
            participants.put(sf.getPatient(), 0);
            if (StringUtils.equals(sf.getDoctor(), sf.getDoctorHealth())) {//全科和建管同一个人
@ -1182,8 +1183,8 @@ public class FamilyContractService extends BaseService {
        }
        BusinessLogs.info(BusinessLogs.BusinessType.sign, signDoctorCode, sf.getPatient(), new JSONObject(sf));
        //签约成功之后给患者新增标签
        String openId=sf.getOpenid();
       hospital=sf.getHospital();
        String openId = sf.getOpenid();
        hospital = sf.getHospital();
        return temp;
    }
@ -1501,7 +1502,7 @@ public class FamilyContractService extends BaseService {
                    String ms = sf.getName() + ",您好!祝贺您,成功签约" + doc.getName() + "医生团队,您已可以享受家庭医生所带来的无微不至的健康保健服务。" +
                            "为了给您提供更好的服务,请尽快完成缴费。您可登录签约居民的微信账号,进入签约管理,选择待缴费的签约记录进行缴费操作,如需线下缴费,请尽快到" + (hos != null ? hos.getName() : "") + "社区(地址:" +
                            (hos != null ? hos.getAddress() : "") + ")缴费。";
                    data.put("content",ms);
                    data.put("content", ms);
                    //String first = (String) json.get("first");
                    data.remove("first");
                    data.put("first", weiXinOpenIdUtils.getTitleMes(p, j.getInt("relation"), p.getName()));
@ -1509,7 +1510,7 @@ public class FamilyContractService extends BaseService {
                }
            }
            new Thread(new SignUploadTask(sf.getCode(), httpUtil,jwUrl)).start();
            new Thread(new SignUploadTask(sf.getCode(), httpUtil, jwUrl)).start();
            JSONObject participants = new JSONObject();
            participants.put(sf.getPatient(), 0);
            if (StringUtils.equals(sf.getDoctor(), sf.getDoctorHealth())) {//全科和建管同一个人
@ -1529,8 +1530,8 @@ public class FamilyContractService extends BaseService {
        result.put("status", 1);
        BusinessLogs.info(BusinessLogs.BusinessType.sign, caller, sf.getPatient(), new JSONObject(sf));
        //签约成功之后给患者新增标签
        String openId=sf.getOpenid();
        String hospital=sf.getHospital();
        String openId = sf.getOpenid();
        String hospital = sf.getHospital();
        return result;
    }
@ -1665,8 +1666,8 @@ public class FamilyContractService extends BaseService {
        }
        //根据openId给患者清掉标签
        String openId=sf.getOpenid();
        String hospital=sf.getHospital();
        String openId = sf.getOpenid();
        String hospital = sf.getHospital();
        return 1;
    }
@ -2845,7 +2846,7 @@ public class FamilyContractService extends BaseService {
     */
    public SignFamily getSignFamilyBySessionId(String sessionId, String patient) {
        SignFamily signFamily = null;
        String sql = "select id from " +im_dataBase_name + ".topics where  session_id = '" + sessionId + "' order by create_time desc limit 0, 1";
        String sql = "select id from " + im_dataBase_name + ".topics where  session_id = '" + sessionId + "' order by create_time desc limit 0, 1";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        if (list != null && list.size() > 0) {
            String consultCode = list.get(0).get("id").toString();
@ -3998,4 +3999,58 @@ public class FamilyContractService extends BaseService {
        }
    }
    /**
     * 查找医生所属团队下的某个居民
     *
     * @param teamCode
     * @param patientName
     * @param page
     * @param pageSize
     * @return
     */
    public List<Patient> signPatientsByName(Long teamCode, String patientName, Integer page, Integer pageSize) {
        StringBuffer sb = new StringBuffer("SELECT " +
                "  p.* " +
                " FROM " +
                "  wlyy_sign_family a ," +
                "  wlyy_patient p ," +
                "WHERE " +
                "  a.admin_team_code =? " +
                " AND a.patient=p.`code` " +
                " AND a.`status` IN (1, 2) ");
        List params = new ArrayList<>();
        params.add(teamCode);
        if (!org.springframework.util.StringUtils.isEmpty(patientName)) {
            sb.append(" AND a.`name` LIKE ? ");
            params.add("%" + patientName + "%");
        }
        pageSize = page * pageSize;
        page = (page - 1) * pageSize;
        sb.append(" limit " + page + "," + pageSize);
        List<Patient> patients = jdbcTemplate.query(sb.toString(), params.toArray(), new BeanPropertyRowMapper(Patient.class));
        return patients;
    }
    public Integer signPatientsByNameCount(Long teamCode, String patientName) {
        StringBuffer sb = new StringBuffer("SELECT " +
                "  p.* " +
                " FROM " +
                "  wlyy_sign_family a ," +
                "  wlyy_patient p ," +
                "WHERE " +
                "  a.admin_team_code =? " +
                " AND a.patient=p.`code` " +
                " AND a.`status` IN (1, 2) ");
        List params = new ArrayList<>();
        params.add(teamCode);
        if (!org.springframework.util.StringUtils.isEmpty(patientName)) {
            sb.append(" AND a.`name` LIKE ? ");
            params.add("%" + patientName + "%");
        }
        Integer patients = jdbcTemplate.queryForObject(sb.toString(), params.toArray(), Integer.class);
        return patients;
    }
}

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/DoctorService.java

@ -154,8 +154,8 @@ public class DoctorService extends TokenService {
            args.add(level);
        }
        List<Doctor> doctorList = jdbcTemplate.query(sql, args.toArray(), new BeanPropertyRowMapper(Doctor.class));
        Integer doctorList = jdbcTemplate.queryForObject(sql, args.toArray(), Integer.class);
        return doctorList.size();
        return doctorList;
    }
}

+ 15 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcDoctorController.java

@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.service.SignFamilyService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
@ -44,7 +44,8 @@ public class GcDoctorController extends BaseController {
    private DoctorService doctorService;
    @Autowired
    private AdminTeamService adminTeamService;
    @Autowired
    private FamilyContractService familyContractService;
    @RequestMapping(value = "/doctor", method = RequestMethod.GET)
@ -116,6 +117,7 @@ public class GcDoctorController extends BaseController {
        }
        return new ResultListModel(adminTeamModelList);
    }
    @RequestMapping(value = "/signPatientsByName", method = RequestMethod.GET)
    @ApiOperation("查找医生所属团队下的某个居民")
    public ResultPageListModel<PatientModel> signPatientsByName(
@ -125,10 +127,17 @@ public class GcDoctorController extends BaseController {
            @ApiParam(name = "pageSize", value = "每页大小", required = true) @RequestParam(value = "pageSize", required = true, defaultValue = "10") Integer pageSize
    ) {
        try {
            return new ResultPageListModel();
            List<Patient> patients = familyContractService.signPatientsByName(teamCode, patientName, page, pageSize);
            List<PatientModel> patientModels = new ArrayList<>();
            if (patients != null && patients.size() > 0) {
                patients.stream().forEach(one -> {
                    PatientModel patientModel = new PatientModel();
                    BeanUtils.copyProperties(one, patientModel);
                    patientModels.add(patientModel);
                });
            }
           Integer count= familyContractService.signPatientsByNameCount(teamCode, patientName);
            return new ResultPageListModel(page,pageSize,count,patientModels);
        } catch (Exception e) {
            return new ResultPageListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());
        }

+ 27 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcEduArticleController.java

@ -58,6 +58,32 @@ public class GcEduArticleController extends WeixinBaseController {
    @Autowired
    private GcEduArticleService gcEduArticleService;
    /**
     *
     * @param doctorCode
     * @param page
     * @param pagesize
     * @return
     */
    @RequestMapping(value = "logs", method = RequestMethod.POST)
    @ApiOperation("查询医生给患者推送记录 ")
    @ResponseBody
    public String getPatientHealthLogs(
            @ApiParam(name = "doctorCode", value = "医生code,为空从useragent取", required = false) @RequestParam(value = "doctorCode", required = false) String doctorCode,
            @ApiParam(name = "page", value = "当前页 起始1", required = false) @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "pagesize", value = "每页显示条数", required = false) @RequestParam(value = "pagesize", required = false) int pagesize) {
        try {
            if(org.springframework.util.StringUtils.isEmpty(doctorCode)){
                doctorCode=getUID();
            }
            //List<Map<String, Object>> result = gcEduArticleService.findByDoctor(doctorCode, page, pagesize);
            return write(200, "查询成功!", "list", "");
        } catch (Exception e) {
            return write(-1, "查询失败!");
        }
    }
    /**
     * 参考原来的教育文章推送
     * http://172.19.103.88:9092/wlyy//doctor/health/edu/send?code=2e6467b5bb2f4b81b598633624d7f98e&patient=e911d1b756cd4680ab241ab76a463282&teamCode=1&attachedContent=
@ -137,7 +163,7 @@ public class GcEduArticleController extends WeixinBaseController {
            json.put("doctorName", one.getDoctorName());
            json.put("represented", patient.getCode());//被代理人
            json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
            json.put("remark", org.springframework.util.StringUtils.isEmpty(one.getAttachedContent())?"  ":one.getAttachedContent());
            json.put("remark", org.springframework.util.StringUtils.isEmpty(one.getAttachedContent()) ? "  " : one.getAttachedContent());
            if (StringUtils.isNotBlank(patient.getOpenid())) {
                pushMsgTask.putWxMsg(getAccessToken(), 9,

+ 6 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcLableController.java

@ -101,7 +101,7 @@ public class GcLableController extends BaseController {
            @ApiParam(name = "pageSize", value = "每页大小", required = true) @RequestParam(value = "pageSize", required = true, defaultValue = "10") Integer pageSize
    ) {
        try {
            JSONArray result = signPatientLabelInfoService.getPatientByLabel("totoD2017031502222", labelCode, labelType, teamCode, page-1, pageSize);
            JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page-1, pageSize);
            List<PatientModel> patientLabelModels = new ArrayList<>();
            for (int i = 0; i < result.length(); i++) {
                JSONObject jo = result.getJSONObject(i);
@ -115,7 +115,11 @@ public class GcLableController extends BaseController {
                patientLabelModels.add(patientModel);
            }
            return new ResultPageListModel(page,pageSize,0,patientLabelModels);
            return new ResultPageListModel(
                    page,
                    pageSize,
                    signPatientLabelInfoService.getPatientByLabelCount(getUID(), labelCode, labelType, teamCode).length()
                    ,patientLabelModels);
        } catch (Exception e) {
            return new ResultPageListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());
        }