Browse Source

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

chenweida 7 years ago
parent
commit
344c9cd76c

+ 3 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/SwaggerConfig.java

@ -65,9 +65,12 @@ public class SwaggerConfig {
    private List<Parameter> addToken() {
        ParameterBuilder tokenPar = new ParameterBuilder();
        ParameterBuilder userAgentPar = new ParameterBuilder();
        List<Parameter> pars = new ArrayList<Parameter>();
        userAgentPar.name("userAgent").description(userAgentJson).modelRef(new ModelRef("string")).parameterType("header").required(false).defaultValue("").build();
        tokenPar.name("accesstoken").description("accesstoken").modelRef(new ModelRef("string")).parameterType("header").required(false).defaultValue("").build();
        pars.add(tokenPar.build());
        pars.add(userAgentPar.build());
        return pars;
    }

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

@ -4,6 +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.team.AdminTeamService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
@ -11,12 +12,14 @@ import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.third.gateway.vo.AdminTeamModel;
import com.yihu.wlyy.web.third.gateway.vo.DoctorModel;
import com.yihu.wlyy.web.third.gateway.vo.PatientModel;
import com.yihu.wlyy.web.third.gateway.vo.base.BaseResultModel;
import com.yihu.wlyy.web.third.gateway.vo.base.ResultListModel;
import com.yihu.wlyy.web.third.gateway.vo.base.ResultOneModel;
import com.yihu.wlyy.web.third.gateway.vo.base.ResultPageListModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
@ -43,6 +46,7 @@ public class GcDoctorController extends BaseController {
    private AdminTeamService adminTeamService;
    @RequestMapping(value = "/doctor", method = RequestMethod.GET)
    @ApiOperation("根据医生code查询医生信息")
    public ResultOneModel<DoctorModel> doctor(
@ -112,5 +116,21 @@ public class GcDoctorController extends BaseController {
        }
        return new ResultListModel(adminTeamModelList);
    }
    @RequestMapping(value = "/signPatientsByName", method = RequestMethod.GET)
    @ApiOperation("查找医生所属团队下的某个居民")
    public ResultPageListModel<PatientModel> signPatientsByName(
            @ApiParam(name = "teamCode", value = "所属团队", required = true) @RequestParam(value = "teamCode", required = true) Long teamCode,
            @ApiParam(name = "patientName", value = "患者名称", required = true) @RequestParam(value = "patientName", required = true) String patientName,
            @ApiParam(name = "page", value = "当前页(1开始)", required = true) @RequestParam(value = "page", required = true, defaultValue = "1") Integer page,
            @ApiParam(name = "pageSize", value = "每页大小", required = true) @RequestParam(value = "pageSize", required = true, defaultValue = "10") Integer pageSize
    ) {
        try {
            return new ResultPageListModel();
        } catch (Exception e) {
            return new ResultPageListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());
        }
    }
}

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

@ -3,7 +3,10 @@ package com.yihu.wlyy.web.third.gateway.controller.doctor;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.app.label.SignPatientLabelService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.third.gateway.service.GcLabelService;
import com.yihu.wlyy.web.third.gateway.vo.DictModel;
import com.yihu.wlyy.web.third.gateway.vo.HospitalModel;
import com.yihu.wlyy.web.third.gateway.vo.PatientLabelModel;
import com.yihu.wlyy.web.third.gateway.vo.PatientModel;
@ -39,22 +42,19 @@ public class GcLableController extends BaseController {
    private SignPatientLabelService signPatientLabelService;
    @Autowired
    private SignPatientLabelInfoService signPatientLabelInfoService;
    @Autowired
    private GcLabelService labelService;
    @Autowired
    private PatientService patientService;
    @RequestMapping(value = "/labels", method = RequestMethod.GET)
    @ApiOperation("根据分组类型查找标签")
    public ResultListModel<List<PatientLabelModel>> labels(
            @ApiParam(name = "type", value = "1:服务类型(卫计委三大分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = true) @RequestParam(value = "type", required = true) String type,
            @ApiParam(name = "team", value = "type是4的时候需要传team", required = false) @RequestParam(value = "team", required = false) Long team
            @ApiParam(name = "labelType", value = "1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = true) @RequestParam(value = "labelType", required = true) String labelType
    ) {
        try {
            List<SignPatientLabel> signPatientLabels = signPatientLabelService.getLabelsByTypeAndTeam(type, String.valueOf(team));
            List<PatientLabelModel> patientLabelModels = new ArrayList<>();
            for (SignPatientLabel signPatientLabel : signPatientLabels) {
                PatientLabelModel patientLabelModel = new PatientLabelModel();
                BeanUtils.copyProperties(signPatientLabel, patientLabelModel);
                patientLabelModels.add(patientLabelModel);
            }
            return new ResultListModel(patientLabelModels);
            List<DictModel> dictModels = labelService.getLabelsByTypeAndTeam(labelType);
            return new ResultListModel(dictModels);
        } catch (Exception e) {
            return new ResultListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());
        }
@ -63,14 +63,21 @@ public class GcLableController extends BaseController {
    @RequestMapping(value = "/labelsWithNum", method = RequestMethod.GET)
    @ApiOperation("根据分组类型查找标签已经标签下的患者数目")
    public ResultListModel<List<PatientLabelModel>> labelsWithNum(
            @ApiParam(name = "type", value = "1:服务类型(卫计委三大分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = true) @RequestParam(value = "type", required = true) String type,
            @ApiParam(name = "team", value = "医生所属的团队ID", required = true) @RequestParam(value = "team", required = true) Long team
            @ApiParam(name = "labelType", value = "1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = true) @RequestParam(value = "labelType", required = true) String labelType,
            @ApiParam(name = "teamCode", value = "医生所属的团队ID", required = true) @RequestParam(value = "teamCode", required = true) Long teamCode
    ) {
        try {
            JSONArray signPatientLabels = signPatientLabelInfoService.getPatientAmountByTeamGroupLable(team, type);
            JSONArray result = null;
            if ("1".equals(labelType)) {
                //卫纪委服务类型
                result = patientService.getSignByTeamCodeGpbyServer(teamCode);
            } else {
                //其他标签
                result = labelService.getPatientAmountByTeamGroupLable(teamCode, labelType);
            }
            List<PatientLabelModel> patientLabelModels = new ArrayList<>();
            for (int i = 0; i < signPatientLabels.length(); i++) {
                JSONObject jo = signPatientLabels.getJSONObject(i);
            for (int i = 0; i < result.length(); i++) {
                JSONObject jo = result.getJSONObject(i);
                PatientLabelModel patientLabelModel = new PatientLabelModel();
                patientLabelModel.setLabelCode(jo.getString("labelCode"));
                patientLabelModel.setLabelName(jo.getString("labelName"));
@ -94,21 +101,21 @@ 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(getUID(), labelCode, labelType, teamCode, page, pageSize);
            JSONArray result = signPatientLabelInfoService.getPatientByLabel("totoD2017031502222", labelCode, labelType, teamCode, page-1, pageSize);
            List<PatientModel> patientLabelModels = new ArrayList<>();
            for (int i = 0; i < result.length(); i++) {
                JSONObject jo = result.getJSONObject(i);
                PatientModel patientModel = new PatientModel();
                patientModel.setCode(jo.getString("code"));
                patientModel.setName(jo.getString("name"));
                patientModel.setWechatFocusRemind(jo.getString("wechatFocusRemind"));
                patientModel.setWechatFocusRemind(jo.getInt("wechatFocusRemind")+"");
                patientModel.setPhoto(jo.getString("photo"));
                patientModel.setSex(jo.getInt("sex"));
                patientModel.setAge(jo.getInt("age"));
                patientLabelModels.add(patientModel);
            }
            return new ResultPageListModel();
            return new ResultPageListModel(page,pageSize,0,patientLabelModels);
        } catch (Exception e) {
            return new ResultPageListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());
        }

+ 166 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcLabelService.java

@ -0,0 +1,166 @@
package com.yihu.wlyy.web.third.gateway.service;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.service.app.label.SignPatientLabelService;
import com.yihu.wlyy.web.third.gateway.vo.DictModel;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2017/8/31.
 */
@Service
public class GcLabelService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private SignPatientLabelService labelService;
    /**
     * 根据类别获取分组
     * @param type
     * @return
     */
    public List<DictModel> getLabelsByTypeAndTeam(String type) {
        String sql = "";
        switch (type) {
            case "1": {
                sql = "select s.code code,s.name name from wlyy_sign_dict s where s.year='2017' order by s.sort asc";
                break;
            }
            case "2": {
                sql = "select label_code code, label_name name from wlyy_sign_patient_label  where label_type=2 and status=1";
                break;
            }
            case "3": {
                sql = "select label_code code, label_name name from wlyy_sign_patient_label  where label_type=3 and status=1";
                break;
            }
            case "4": {
                sql = "select label_code code, label_name name from wlyy_sign_patient_label  where label_type=4 and status=1";
                break;
            }
        }
        List<DictModel> returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
        return returnList;
    }
    /**
     *
     * @param teamCode 团队code
     * @param labelType 1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)
     * @return
     * @throws Exception
     */
    public JSONArray getPatientAmountByTeamGroupLable(Long teamCode, String labelType) throws Exception {
        Boolean isAll = false;
        List<SignPatientLabel> labels = new ArrayList<>();
        if ("0".equals(labelType)) {
            labels = labelService.getTeamAllLabels(teamCode);
            isAll = true;
        } else {
            labels = labelService.getLabelsByTypeAndTeam(labelType, teamCode.toString());
        }
        org.json.JSONArray result = new org.json.JSONArray();
        SignPatientLabel labelNo = new SignPatientLabel();
        if (!labelType.equals("5")) {
            labelNo.setLabelCode("0");
            labelNo.setLabelName(labelType.equals("1") ? "未分组" : "未标注");
            labelNo.setStatus(1);
            labelNo.setIsSystem(1);
            labelNo.setLabelType(labelType);
            labelNo.setSort(999999999);
            labels.add(labelNo);
        }
        if (labels != null) {
            for (SignPatientLabel label : labels) {
                if (isAll) {//查询所有
                    labelType = label.getLabelType();
                }
                JSONObject json = new JSONObject();
                json.put("labelCode", label.getLabelCode());
                json.put("labelName", label.getLabelName());
                json.put("isSystem", label.getIsSystem());
                int amount = 0;
                String sql = "";
                Object[] args;
                if (label.getLabelCode().equals("0")) {
                    sql = " SELECT " +
                            "     count(DISTINCT t1.patient) count" +
                            " FROM" +
                            "     wlyy_sign_family t1 " +
                            " left join " +
                            "    (select repl.patient,repl.label,repl.label_type,repl.label_name from wlyy_sign_family repf left join wlyy_sign_patient_label_info repl on repf.patient = repl.patient where repf.admin_team_code = ? and repf.status > 0 and repl.label_type = ? and repl.status = 1) t2 " +
                            " on t1.patient = t2.patient ," +
                            " wlyy_patient t3 " +
                            " WHERE" +
                            "     t2.patient is null " +
                            "    AND t1.patient = t3.code" +
                            "     AND t1.status > 0 " +
                            "     AND t1.admin_team_code = ? ";
                    args = new Object[]{teamCode, labelType, teamCode};
                } else {
                    sql = " SELECT " +
                            "     count(DISTINCT t1.patient) count" +
                            " FROM" +
                            "     wlyy_sign_family t1, " +
                            "     wlyy_sign_patient_label_info t2, " +
                            "     wlyy_patient t3 " +
                            " WHERE" +
                            "     t1.patient = t2.patient " +
                            "     AND t1.patient = t3.code " +
                            "     AND t2.label = ? " +
                            "     AND t2.label_type = ? " +
                            "     AND t2.status = 1 " +
                            "     AND t1.status > 0 " +
                            "    AND t1.admin_team_code = ? ";
                    args = new Object[]{label.getLabelCode(), labelType, teamCode};
                }
                List<Map<String, Object>> count = jdbcTemplate.queryForList(sql, args);
                if (count != null && count.size() > 0 && count.get(0).containsKey("count")) {
                    amount = Integer.valueOf(String.valueOf(count.get(0).get("count")));
                }
                json.put("amount", amount);
                int focusAmount = 0;
                sql += labelType.equals("5") ? " AND LENGTH(TRIM(IFNULL(t3.openid,''))) > 0 " : " AND LENGTH(TRIM(IFNULL(t3.openid,''))) > 0 ";
                List<Map<String, Object>> focusCount = jdbcTemplate.queryForList(sql, args);
                if (focusCount != null && focusCount.size() > 0 && focusCount.get(0).containsKey("count")) {
                    focusAmount = Integer.valueOf(String.valueOf(focusCount.get(0).get("count")));
                }
                json.put("focusAmount", focusAmount);
                if (label.getLabelCode().equals("0") && labelType.equals("1") && amount < 1) {
                    continue;
                }
                result.put(json);
            }
        }
        return result;
    }
}

+ 26 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/vo/DictModel.java

@ -0,0 +1,26 @@
package com.yihu.wlyy.web.third.gateway.vo;
/**
 * Created by chenweida on 2017/8/31.
 */
public class DictModel {
    private String name;
    private String code;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
}