Browse Source

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

lyr 8 years ago
parent
commit
d8d27e3cd1

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

@ -1,6 +1,7 @@
package com.yihu.wlyy.service.app.label;
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.DoctorPatientGroupInfo;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
@ -14,6 +15,7 @@ import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDiseaseDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.IdCardUtil;
import org.apache.commons.beanutils.converters.CalendarConverter;
@ -57,6 +59,8 @@ public class SignPatientLabelInfoService extends BaseService {
    SignFamilyDao signFamilyDao;
    @Autowired
    StringRedisTemplate redisTemplate;
    @Autowired
    AdminTeamService adminTeamService;
    /**
     * 查询单个居民信息
@ -243,7 +247,7 @@ public class SignPatientLabelInfoService extends BaseService {
        }
        String sqlDoc = sql.replaceAll("repdoctor", "doctor");
        String sqlDocHealth = sql.replaceAll("repdoctor", "doctor_health").replaceAll("t1", "t3").replaceAll("t2", "t4").replaceAll("repf","repf1").replaceAll("repl","repl1");
        String sqlDocHealth = sql.replaceAll("repdoctor", "doctor_health").replaceAll("t1", "t3").replaceAll("t2", "t4").replaceAll("repf", "repf1").replaceAll("repl", "repl1");
        sql = "select t.* from (" + sqlDoc + " union all " + sqlDocHealth + ") t limit " + start + "," + pagesize;
@ -612,7 +616,7 @@ public class SignPatientLabelInfoService extends BaseService {
                }
                String sqlDoc = sql.replaceAll("repdoctor", "doctor");
                String sqlDocHealth = sql.replaceAll("repdoctor", "doctor_health").replaceAll("t1", "t3").replaceAll("t2", "t4").replaceAll("repf","repf1").replaceAll("repl","repl1");
                String sqlDocHealth = sql.replaceAll("repdoctor", "doctor_health").replaceAll("t1", "t3").replaceAll("t2", "t4").replaceAll("repf", "repf1").replaceAll("repl", "repl1");
                sql = "select count(DISTINCT t.patient) count from (" + sqlDoc + " union all " + sqlDocHealth + ") t";
@ -978,6 +982,101 @@ public class SignPatientLabelInfoService extends BaseService {
        return result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
    }
    /**
     * 查询所有团队下患者
     *
     * @param filter 搜索关键字
     * @param doctor 医生
     * @return
     */
    public JSONArray searchTeamsPatients(String filter, String doctor, long teamCode, int page, int pagesize) throws Exception {
        JSONArray reArray = new JSONArray();
        Map<String, JSONArray> map = new HashMap<>();
        Map<Long, AdminTeam> teamMap = new HashMap<>();
        List<AdminTeam> teams = null;
        int start = page * pagesize;
        int size = pagesize;
        if (teamCode > 0) {
            teams = new ArrayList<>();
            AdminTeam team = adminTeamService.getTeam(teamCode);
            if (team == null) {
                throw new Exception("adminTeam is not exist");
            }
            teams.add(team);
        } else {
            teams = adminTeamService.getDoctorTeams(doctor);
        }
        String sql = "select distinct t.* from (" +
                " select " +
                "     patient " +
                "     ,name " +
                "     ,openid " +
                "     ,admin_team_code " +
                " from " +
                "     wlyy_sign_family " +
                " where " +
                "      doctor = ? and admin_team_code = ? and status > 0 and name like ? " +
                " union all " +
                "select " +
                "     patient " +
                "     ,name " +
                "     ,openid " +
                "     ,admin_team_code " +
                " from " +
                "     wlyy_sign_family " +
                " where " +
                "      doctor_health = ? and admin_team_code = ? and status > 0 and name like ? " +
                ") t limit " + start + "," + size;
        if (teams != null) {
            for (AdminTeam team : teams) {
                teamMap.put(team.getId(), team);
                List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{doctor, team.getId(),
                        "%" + filter + "%", doctor, team.getId(), "%" + filter + "%"});
                if (result != null && result.size() > 0) {
                    for (Map<String, Object> p : result) {
                        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")));
                        List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(String.valueOf(p.get("patient")), 1);
                        pJson.put("labels", labels == null ? "" : labels);
                        if (map.containsKey(String.valueOf(p.get("admin_team_code")))) {
                            JSONArray array = map.get(String.valueOf(p.get("admin_team_code")));
                            array.put(pJson);
                        } else {
                            JSONArray array = new JSONArray();
                            array.put(pJson);
                            map.put(String.valueOf(p.get("admin_team_code")), array);
                        }
                    }
                }
            }
            if (map != null && map.size() > 0) {
                for (String key : map.keySet()) {
                    AdminTeam team = teamMap.get(Long.valueOf(key));
                    JSONObject tJson = new JSONObject();
                    tJson.put("teamCode", team.getId());
                    tJson.put("teamName", team.getName());
                    tJson.put("patients", map.get(key));
                    reArray.put(tJson);
                }
            }
        }
        return reArray;
    }
    /**
     * 添加居民到某个标签
     *

+ 36 - 15
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -3,14 +3,13 @@ package com.yihu.wlyy.web.doctor.patient;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -21,6 +20,7 @@ import java.util.List;
 */
@RestController
@RequestMapping(value = "/doctor/patient_label_info")
@Api("居民管理")
public class SignPatientLabelInfoController extends BaseController {
    @Autowired
@ -33,17 +33,16 @@ public class SignPatientLabelInfoController extends BaseController {
     * @return
     */
    @RequestMapping(value = "/patient")
    @ResponseBody
    public String getPatient(String patient){
        try{
            if(StringUtils.isEmpty(patient)){
                return error(-1,"居民不能为空");
    public String getPatient(String patient) {
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "居民不能为空");
            }
            JSONObject p = labelInfoService.getPatient(patient);
            return write(200,"查询成功","data",p);
        }catch (Exception e){
            return write(200, "查询成功", "data", p);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"查询失败");
            return error(-1, "查询失败");
        }
    }
@ -102,7 +101,7 @@ public class SignPatientLabelInfoController extends BaseController {
            }
            page = page - 1;
            JSONArray result = labelInfoService.getPatientByTeamCode(getUID(), teamCode, exLabelCode,exLabelType,page, pagesize);
            JSONArray result = labelInfoService.getPatientByTeamCode(getUID(), teamCode, exLabelCode, exLabelType, page, pagesize);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
@ -207,13 +206,13 @@ public class SignPatientLabelInfoController extends BaseController {
     * @return
     */
    @RequestMapping(value = "/patient_search")
    public String searchPatientByNameOrLabel(@RequestParam(required = true)String filter,
    public String searchPatientByNameOrLabel(@RequestParam(required = true) String filter,
                                             @RequestParam(required = false) String labelCode,
                                             @RequestParam(required = false) String labelType,
                                             @RequestParam(required = false) Long teamCode,
                                             @RequestParam(required = false) String exLabelCode,
                                             @RequestParam(required = false) String exLabelType,
                                             @RequestParam(required = true)int page, @RequestParam(required = true)int pagesize) {
                                             @RequestParam(required = true) int page, @RequestParam(required = true) int pagesize) {
        try {
            if (StringUtils.isEmpty(filter)) {
                return error(-1, "搜索字段不能为空");
@ -242,6 +241,27 @@ public class SignPatientLabelInfoController extends BaseController {
        }
    }
    @RequestMapping(value = "/patient_search_all", method = RequestMethod.GET)
    @ApiOperation("根据姓名搜索所有团队下居民")
    public String searchPatients(@RequestParam(required = true) String filter,
                                 @RequestParam(required = false, defaultValue = "0") long teamCode,
                                 @RequestParam(required = false, defaultValue = "0") int page,
                                 @RequestParam(required = false, defaultValue = "15") int pagesize) {
        try {
            if (StringUtils.isEmpty(filter)) {
                return error(-1, "查询参数不能为空");
            }
            JSONArray result = labelInfoService.searchTeamsPatients(filter, getUID(), teamCode, page, pagesize);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    /**
     * 添加居民到某个标签
     *
@ -353,4 +373,5 @@ public class SignPatientLabelInfoController extends BaseController {
        }
    }
}