Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

8 years ago
parent
commit
e5f104c2b3

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

@ -786,17 +786,49 @@ public class DoctorInfoService extends BaseService {
    }
    @Transactional
    public void updateTeamHealthDoctorsAll(String newDoctorCode,String doctor) throws Exception {
    public int updateTeamHealthDoctorsAll(String newDoctorCode,String doctor) throws Exception {
        List<String> patients = signFamilyDao.findNohealthByDoctor(doctor);
        boolean hasNoTeam = false;
        if(patients != null){
            for (String patient : patients) {
                try {
                    updateTeamHealthDoctor(newDoctorCode, "", patient);
                    if(updateTeamHealthDoctorAll(newDoctorCode, patient) == -1){
                        hasNoTeam = true;
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        }
        return hasNoTeam ? 2 : 1;
    }
    @Transactional
    public int updateTeamHealthDoctorAll(String newDoctorCode, String patient) throws Exception {
        //得到患者的签约信息
        SignFamily signFamily = signFamilyDao.findByPatient(patient);
        if(StringUtils.isEmpty(signFamily.getTeamCode())){
            return -1;
        }
        Doctor newD = doctorDao.findByCode(newDoctorCode);
        //修改签约中的健康管理师
        signFamily.setDoctorHealth(newD.getCode());
        signFamily.setDoctorHealthName(newD.getName());
        //添加新的健康管理师到服务团队里
        DoctorTeamMember newDoctorTeamMember = new DoctorTeamMember();
        newDoctorTeamMember.setTeam(signFamily.getTeamCode());
        newDoctorTeamMember.setCzrq(new Date());
        newDoctorTeamMember.setName(newD.getName());
        newDoctorTeamMember.setMemberCode(newD.getCode());
        newDoctorTeamMember.setType(3);
        newDoctorTeamMember.setSignType("2");
        newDoctorTeamMember.setDel("1");
        newDoctorTeamMember.setCode(UUID.randomUUID().toString().replace("-", ""));
        doctorTeamDoctor.save(newDoctorTeamMember);
        return 1;
    }
    /**

+ 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 " + (page < 0 ? "" :"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;
    }
    /**
     * 添加居民到某个标签
     *

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

@ -1476,7 +1476,13 @@ public class DoctorController extends BaseController {
                                          @RequestParam(required = false) String isAll) {
        try {
            if (StringUtils.isNotEmpty(isAll) && isAll.equals("1")) {
                doctorInfoService.updateTeamHealthDoctorsAll(newDoctorCode, getUID());
                int result = doctorInfoService.updateTeamHealthDoctorsAll(newDoctorCode, getUID());
                if(result == 1){
                    return write(200,"分配健管师成功");
                } else if(result == 2){
                    return write(200,"部分居民因没有服务团队分配失败");
                }
            } else {
                if (StringUtils.isEmpty(patients)) {
                    return error(-1, "居民不能为空");

+ 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 {
        }
    }
}

+ 8 - 8
patient-co-wlyy/src/main/webapp/WEB-INF/web.xml

@ -53,14 +53,14 @@
    <filter-name>shiroFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping> -->
  <filter>
    <filter-name>sitemeshFilter</filter-name>
    <filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>sitemeshFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <!--<filter>-->
    <!--<filter-name>sitemeshFilter</filter-name>-->
    <!--<filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>-->
  <!--</filter>-->
  <!--<filter-mapping>-->
    <!--<filter-name>sitemeshFilter</filter-name>-->
    <!--<url-pattern>/*</url-pattern>-->
  <!--</filter-mapping>-->
  <servlet>
    <servlet-name>springServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>