浏览代码

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

lyr 8 年之前
父节点
当前提交
397dbfa4ef

+ 54 - 7
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java

@ -32,7 +32,9 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.util.MD5;
import org.apache.commons.beanutils.converters.IntegerConverter;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Page;
@ -40,7 +42,9 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.persistence.DynamicSpecifications;
import org.springside.modules.persistence.DynamicSpecifications;
@ -713,7 +717,7 @@ public class DoctorInfoService extends BaseService {
        if (doctors.size() > 0) {
        if (doctors.size() > 0) {
            for (Doctor doc : doctors) {
            for (Doctor doc : doctors) {
                if(workingDoctor.size() > end){
                if (workingDoctor.size() > end) {
                    break;
                    break;
                }
                }
                if (type != 1) {
                if (type != 1) {
@ -739,13 +743,56 @@ public class DoctorInfoService extends BaseService {
        return returnList;
        return returnList;
    }
    }
    @Transactional
    public JSONArray findWorkingDoctorListByDept(String dept, String hospital, String level, String key) throws Exception {
        String sql = "select * from wlyy_doctor where dept = ? and hospital = ? and status = 1";
        Object[] args = null;
        if (!StringUtils.isEmpty(level)) {
            sql += " and level = ? ";
        }
        if (!StringUtils.isEmpty(key)) {
            sql += " and name like ? ";
        }
        if (StringUtils.isNotEmpty(level) && StringUtils.isNotEmpty(key)) {
            args = new Object[]{dept, hospital, Integer.valueOf(level), "%" + key + "%"};
        } else if (StringUtils.isEmpty(level) && StringUtils.isNotEmpty(key)) {
            args = new Object[]{dept, hospital, "%" + key + "%"};
        } else if (StringUtils.isNotEmpty(level) && StringUtils.isEmpty(key)) {
            args = new Object[]{dept, hospital, Integer.valueOf(level)};
        } else {
            args = new Object[]{dept, hospital};
        }
        List<Doctor> doctors = jdbcTemplate.query(sql, args, new BeanPropertyRowMapper<Doctor>(Doctor.class));
        JSONArray workingDoctor = new JSONArray();
        if (doctors.size() > 0) {
            for (Doctor doc : doctors) {
                JSONObject iswork = workTimeService.isDoctorWorking(doc.getCode());
                if (iswork.getString("status").equals("1")) {
                    JSONObject docJson = new JSONObject(doc);
                    if (docJson.has("password")) {
                        docJson.remove("password");
                    }
                    if (docJson.has("salt")) {
                        docJson.remove("salt");
                    }
                    workingDoctor.put(docJson);
                }
            }
        }
        return workingDoctor;
    }
    @Transactional
    @Transactional
    public void updateTeamHealthDoctor(String newDoctorCode, String oldDoctorCode, String patient) throws Exception {
    public void updateTeamHealthDoctor(String newDoctorCode, String oldDoctorCode, String patient) throws Exception {
        //得到患者的签约信息
        //得到患者的签约信息
        SignFamily signFamily = signFamilyDao.findByPatient(patient);
        SignFamily signFamily = signFamilyDao.findByPatient(patient);
        //得到签约中的健管师
        //得到签约中的健管师
        oldDoctorCode=signFamily.getDoctorHealth();
        oldDoctorCode = signFamily.getDoctorHealth();
        //如果存在旧的健管师
        //如果存在旧的健管师
        if (!org.springframework.util.StringUtils.isEmpty(oldDoctorCode)) {
        if (!org.springframework.util.StringUtils.isEmpty(oldDoctorCode)) {
            //判断患者对旧的健管师是否存在健康咨询
            //判断患者对旧的健管师是否存在健康咨询
@ -786,16 +833,16 @@ public class DoctorInfoService extends BaseService {
    }
    }
    @Transactional
    @Transactional
    public int updateTeamHealthDoctorsAll(String newDoctorCode,String doctor) throws Exception {
    public int updateTeamHealthDoctorsAll(String newDoctorCode, String doctor) throws Exception {
        List<String> patients = signFamilyDao.findNohealthByDoctor(doctor);
        List<String> patients = signFamilyDao.findNohealthByDoctor(doctor);
        boolean hasNoTeam = false;
        boolean hasNoTeam = false;
        if(patients != null){
        if (patients != null) {
            for (String patient : patients) {
            for (String patient : patients) {
                try {
                try {
                    if(updateTeamHealthDoctorAll(newDoctorCode, patient) == -1){
                    if (updateTeamHealthDoctorAll(newDoctorCode, patient) == -1) {
                        hasNoTeam = true;
                        hasNoTeam = true;
                    }
                    }
                }catch (Exception e){
                } catch (Exception e) {
                    e.printStackTrace();
                    e.printStackTrace();
                }
                }
            }
            }
@ -808,7 +855,7 @@ public class DoctorInfoService extends BaseService {
    public int updateTeamHealthDoctorAll(String newDoctorCode, String patient) throws Exception {
    public int updateTeamHealthDoctorAll(String newDoctorCode, String patient) throws Exception {
        //得到患者的签约信息
        //得到患者的签约信息
        SignFamily signFamily = signFamilyDao.findByPatient(patient);
        SignFamily signFamily = signFamilyDao.findByPatient(patient);
        if(StringUtils.isEmpty(signFamily.getTeamCode())){
        if (StringUtils.isEmpty(signFamily.getTeamCode())) {
            return -1;
            return -1;
        }
        }
        Doctor newD = doctorDao.findByCode(newDoctorCode);
        Doctor newD = doctorDao.findByCode(newDoctorCode);

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

@ -1010,25 +1010,31 @@ public class SignPatientLabelInfoService extends BaseService {
        String sql = "select distinct t.* from (" +
        String sql = "select distinct t.* from (" +
                " select " +
                " select " +
                "     patient " +
                "     ,name " +
                "     ,openid " +
                "     ,admin_team_code " +
                "     f.patient " +
                "     ,f.name " +
                "     ,f.openid " +
                "     ,f.admin_team_code " +
                "     ,p.sex " +
                "     ,p.idcard " +
                "     ,p.photo " +
                " from " +
                " from " +
                "     wlyy_sign_family " +
                "     wlyy_sign_family f,wlyy_patient p " +
                " where " +
                " where " +
                "      doctor = ? and admin_team_code = ? and status > 0 and name like ? " +
                "      f.patient = p.code and f.doctor = ? and f.admin_team_code = ? and f.status > 0 and f.name like ? " +
                " union all " +
                " union all " +
                "select " +
                "select " +
                "     patient " +
                "     ,name " +
                "     ,openid " +
                "     ,admin_team_code " +
                "     f1.patient " +
                "     ,f1.name " +
                "     ,f1.openid " +
                "     ,f1.admin_team_code " +
                "     ,p1.sex " +
                "     ,p1.idcard " +
                "     ,p1.photo " +
                " from " +
                " from " +
                "     wlyy_sign_family " +
                "     wlyy_sign_family f1,wlyy_patient p1" +
                " where " +
                " where " +
                "      doctor_health = ? and admin_team_code = ? and status > 0 and name like ? " +
                ") t " + (page < 0 ? "" :"limit " + start + "," + size);
                "     f1.patient = p1.code and f1.doctor_health = ? and f1.admin_team_code = ? and f1.status > 0 and f1.name like ? " +
                ") t " + (page < 0 ? "" : "limit " + start + "," + size);
        if (teams != null) {
        if (teams != null) {
            for (AdminTeam team : teams) {
            for (AdminTeam team : teams) {
@ -1040,10 +1046,13 @@ public class SignPatientLabelInfoService extends BaseService {
                    for (Map<String, Object> p : result) {
                    for (Map<String, Object> p : result) {
                        JSONObject pJson = new JSONObject();
                        JSONObject pJson = new JSONObject();
                        pJson.put("code", String.valueOf(p.get("patient")));
                        pJson.put("name", String.valueOf(p.get("name")));
                        pJson.put("openid", String.valueOf(p.get("openid")));
                        pJson.put("adminTeamCode", String.valueOf(p.get("admin_team_code")));
                        pJson.put("code", p.get("patient"));
                        pJson.put("name", p.get("name") != null ? p.get("name") : "");
                        pJson.put("openid", p.get("openid") != null ? p.get("openid") : "");
                        pJson.put("adminTeamCode", p.get("admin_team_code") != null ? p.get("admin_team_code") : "");
                        pJson.put("sex", p.get("sex") != null ? p.get("sex") : "");
                        pJson.put("age", p.get("idcard") != null ? IdCardUtil.getAgeForIdcard(String.valueOf(p.get("idcard"))) : "");
                        pJson.put("photo", p.get("photo") != null ? p.get("photo") : "");
                        List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(String.valueOf(p.get("patient")), 1);
                        List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(String.valueOf(p.get("patient")), 1);
                        pJson.put("labels", labels == null ? "" : labels);
                        pJson.put("labels", labels == null ? "" : labels);

+ 35 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java

@ -334,6 +334,37 @@ public class DoctorController extends BaseController {
        }
        }
    }
    }
    /**
     * 根据科室查询当前在工作医生
     *
     * @param dept
     * @param hospital
     * @param level
     * @param key
     * @return
     */
    @RequestMapping(value = "/findDoctorByDeptAndName")
    @ResponseBody
    public String findWorkingDoctorByDept(@RequestParam(required = true) String dept,
                                          @RequestParam(required = true) String hospital,
                                          @RequestParam(required = false, defaultValue = "") String level,
                                          @RequestParam(required = false, defaultValue = "") String key) {
        try {
            if (StringUtils.isEmpty(dept)) {
                return error(-1, "科室不能为空");
            }
            if (StringUtils.isEmpty(hospital)) {
                return error(-1, "医院不能为空");
            }
            JSONArray doctors = doctorInfoService.findWorkingDoctorListByDept(dept, hospital, level, key);
            return write(200, "查询成功", "data", doctors);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    /**
    /**
     * 名医列表
     * 名医列表
     *
     *
@ -1478,10 +1509,10 @@ public class DoctorController extends BaseController {
            if (StringUtils.isNotEmpty(isAll) && isAll.equals("1")) {
            if (StringUtils.isNotEmpty(isAll) && isAll.equals("1")) {
                int result = doctorInfoService.updateTeamHealthDoctorsAll(newDoctorCode, getUID());
                int result = doctorInfoService.updateTeamHealthDoctorsAll(newDoctorCode, getUID());
                if(result == 1){
                    return write(200,"分配健管师成功");
                } else if(result == 2){
                    return write(200,"部分居民因没有服务团队分配失败");
                if (result == 1) {
                    return write(200, "分配健管师成功");
                } else if (result == 2) {
                    return write(200, "部分居民因没有服务团队分配失败");
                }
                }
            } else {
            } else {
                if (StringUtils.isEmpty(patients)) {
                if (StringUtils.isEmpty(patients)) {