Sfoglia il codice sorgente

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

LiTaohong 6 anni fa
parent
commit
ba8fe9a7e5

+ 20 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistPatientRelationDO.java

@ -73,6 +73,10 @@ public class SpecialistPatientRelationDO extends UuidIdentityEntityWithOperator
    private Date signDate;//签约日期
    @Column(name = "remark")
    private String remark;//记录专科医生审核原因等
    @Column(name = "sign_certificate")
    private String signCertificate;//签约证明
    @Column(name = "health_status_code")
    private String healthStatusCode;//健康状况编码
    public String getSaasId() {
@ -236,4 +240,20 @@ public class SpecialistPatientRelationDO extends UuidIdentityEntityWithOperator
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public String getSignCertificate() {
        return signCertificate;
    }
    public void setSignCertificate(String signCertificate) {
        this.signCertificate = signCertificate;
    }
    public String getHealthStatusCode() {
        return healthStatusCode;
    }
    public void setHealthStatusCode(String healthStatusCode) {
        this.healthStatusCode = healthStatusCode;
    }
}

+ 2 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/specialist/SpecialistMapping.java

@ -38,6 +38,8 @@ public class SpecialistMapping {
        public static final String getSpecialistSignFamilyPatientByName ="/getSpecialistSignFamilyPatientByName";
        public static final String getPatientAndDiseaseByDoctor ="/getPatientAndDiseaseByDoctor";
        public static final String searchPatientInSpecialist ="/searchPatientInSpecialist";
        public static final String searchPatientInSpeciaInfo ="/searchPatientInSpeciaInfo";
        public static final String createPatientInSpeciaRelation ="/createPatientInSpeciaRelation";

+ 52 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/SpecialistController.java

@ -1,8 +1,10 @@
package com.yihu.jw.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.specialist.SpecialistPatientRelationDO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.specialist.*;
import com.yihu.jw.rm.specialist.SpecialistMapping;
@ -10,6 +12,7 @@ import com.yihu.jw.service.SpecialistService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.web.bind.annotation.*;
@ -388,4 +391,53 @@ public class SpecialistController extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = SpecialistMapping.specialist.searchPatientInSpeciaInfo)
    @ApiOperation(value = "根据病人和医生id病人的家签信息、专科开通信息")
    public ObjEnvelop<Object> searchPatientInSpecialist(
            @ApiParam(name = "doctorCode", value = "医生code",required = true)
            @RequestParam(value = "doctorCode",required = true)String doctorCode,
            @ApiParam(name = "patientCode", value = "居民id")
            @RequestParam(value = "patientCode",required = true)String patientCode){
        try {
            JSONObject object=specialistService.doctorForSpecialistInfo(doctorCode,patientCode);
            return  success(object);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = SpecialistMapping.specialist.createPatientInSpeciaRelation)
    @ApiOperation(value = "专科医生发起签约")
    public ObjEnvelop<SpecialistPatientRelationDO> createPatientInSpeciaRelation(
            @ApiParam(name = "jsonData", value = "签约关系json")
            @RequestParam(value = "jsonData") String jsonData) {
        try {
            SpecialistPatientRelationDO specialistPatientRelationDO=toEntity(jsonData,SpecialistPatientRelationDO.class);
            if(StringUtils.isBlank(specialistPatientRelationDO.getPatient())){
                return failed("病人编码不能为空!",ObjEnvelop.class);
            }
            if(StringUtils.isBlank(specialistPatientRelationDO.getPatientName())){
                return failed("病人姓名不能为空!",ObjEnvelop.class);
            }
            if(StringUtils.isBlank(specialistPatientRelationDO.getDoctor())){
                return failed("医生编码不能为空!",ObjEnvelop.class);
            }
            if(StringUtils.isBlank(specialistPatientRelationDO.getDoctorName())){
                return failed("医生姓名不能为空!",ObjEnvelop.class);
            }
            if(null==specialistPatientRelationDO.getTeamCode()){
                return failed("医生团队不能为空!",ObjEnvelop.class);
            }
            return specialistService.createPatientInSpeciaRelation(specialistPatientRelationDO);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
        }
    }
}

+ 77 - 10
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistService.java

@ -1,5 +1,6 @@
package com.yihu.jw.service;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.dao.*;
import com.yihu.jw.entity.specialist.*;
import com.yihu.jw.restmodel.web.MixEnvelop;
@ -7,6 +8,7 @@ import com.yihu.jw.restmodel.specialist.*;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.rm.specialist.SpecialistMapping;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -15,8 +17,10 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
/**
 * Created by Trick on 2018/4/25.
@ -776,15 +780,19 @@ public class SpecialistService{
     */
    public MixEnvelop searchPatientInSpecialist(String doctorCode,String keywords,Integer page,Integer pageSize) throws Exception{
        String sql1 = " select count(1) as num ";
        String sql2 = " select p.name as name,p.idcard,p.code,p.photo ";
        String sql2 = " select p.name as name,p.idcard,p.code,p.photo,CASE WHEN wsf.status ='-4' THEN '已到期' WHEN wsf.status ='0' THEN '待签约' WHEN wsf.status ='1' THEN '已签约' WHEN wsf.status ='2' THEN '已签约' WHEN wsf.status ='3' THEN '已签约' ELSE '待签约' END  status  ";
        String whereSql ="";
        if(!StringUtils.isEmpty(keywords)){
            whereSql+=" and (p.name like '%"+keywords+"%' or p.idcard like '%"+keywords+"%' or p.mobile like '%"+keywords+"%') ";
        }
        String centerSql =" from "+basedb+".wlyy_patient p " +
                " LEFT JOIN wlyy_specialist.wlyy_specialist_patient_relation r on p.code=r.patient and sign_status='1' and doctor='"+doctorCode+"'"+
                " where r.id is not null "+whereSql;
        String sqlCount=sql1+centerSql;
        String centerSql =" from "+basedb+".wlyy_patient p LEFT JOIN  "+basedb+".wlyy_sign_family wsf ON p.code=wsf.patient AND wsf.type='1'" +
                " WHERE p.code not in (SELECT r.patient FROM  wlyy_specialist.wlyy_specialist_patient_relation r WHERE r.sign_status = '1' and doctor='"+doctorCode+"')"+" AND p.openid IS NOT NULL "+
               whereSql;
        String countCenterSql =" from "+basedb+".wlyy_patient p " +
                " WHERE p.code not in (SELECT r.patient FROM  wlyy_specialist.wlyy_specialist_patient_relation r WHERE r.sign_status = '1' and doctor='"+doctorCode+"')"+" AND p.openid IS NOT NULL "+
                whereSql;
        String sqlCount=sql1+countCenterSql;
        String sql=sql2+centerSql+" LIMIT "+(page-1)*pageSize+","+pageSize;
        List<Map<String,Object>> map = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> countMap = jdbcTemplate.queryForList(sqlCount);
@ -800,6 +808,7 @@ public class SpecialistService{
            m.put("name",one.get("name"));
            m.put("age",age);
            m.put("sex",sex);
            m.put("status",one.get("status"));
            if("1".equals(sex)){
                sexName="男";
            }else if("2".equals(sex)){
@ -812,17 +821,75 @@ public class SpecialistService{
            m.put("photo",one.get("photo"));
            resultList.add(m);
        }
        Long co=Long.parseLong("100");
        return MixEnvelop.getSuccessListWithPage(SpecialistMapping.api_success,resultList,page,pageSize,countMap.size()>0?Long.valueOf(countMap.get(0).get("num")+""):0);
//        return MixEnvelop.getSuccessListWithPage(SpecialistMapping.api_success,resultList,page,pageSize,co);
    }
    /**
     * 医生的专科信息
     * @param doctor
     * 病人的家签信息、专科开通信息
     * @param doctorCode 医生code
     * @param patientCode 病人id
     */
    public ObjEnvelop doctorForSpecialistInfo(String doctor){
    public JSONObject doctorForSpecialistInfo(String doctorCode, String patientCode)  throws Exception{
        JSONObject jsonObject = new JSONObject();
        //1、获取居民基础信息
        String preSql = "SELECT p.name as name,CASE p.sex WHEN 1 THEN '男' WHEN 2 THEN '女' ELSE '未知' END as sex,IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') as age," +
                " p.photo as photo,p.idcard as idcard,p.mobile as mobile,p.medicare_number as medicareNumber,p.ssc as ssc," +
                " CASE  WHEN wsf.doctor_name is null THEN '无' ELSE wsf.doctor_name END as doctorName,CASE  WHEN wsf.hospital_name is NULL THEN '无' ELSE wsf.hospital_name END as hospitalName,CASE  WHEN wsf.mobile is NULL THEN '无' ELSE wsf.mobile END as doctorMobole ";
        String patientSql = " from " + basedb + ".wlyy_patient p LEFT JOIN " + basedb + ".wlyy_sign_family wsf " +
                " ON p.code=wsf.patient AND wsf.type='2' AND wsf.status='1' " +
                " LEFT JOIN " + basedb + ".wlyy_doctor wd ON wsf.doctor =wd.code WHERE p.code='" + patientCode + "'";
        //一个居民 生效的家签信息只会有一条
        Map<String, Object> map = jdbcTemplate.queryForMap(preSql + patientSql);
        jsonObject.put("patientInfo", map);
        //2、获取医生信息(所属医院、科室、姓名)
        String doctorSql = "SELECT wd.hospital_name as hospitalName,wd.dept_name as deptName,wd.name as name FROM " + basedb + ".wlyy_doctor wd WHERE wd.code='" + doctorCode + "'";
        jsonObject.put("doctorInfo", jdbcTemplate.queryForMap(doctorSql));
        //3、获取该医生所属团队及团队成员信息
        String teamSql = "SELECT at.name teamName, tm.team_id , tm.doctor_code, wd.NAME as doctorName  FROM " + basedb + ".wlyy_doctor wd LEFT JOIN  " + basedb + ".wlyy_admin_team_member tm ON wd. CODE = tm.doctor_code, " + basedb + ".wlyy_admin_team at " +
                "WHERE tm.team_id IN ( SELECT watm.team_id teamId FROM  " + basedb + ".wlyy_admin_team_member watm WHERE watm.doctor_code ='" + doctorCode + "'" + " AND watm.available = '1' ) AND tm.available='1' AND `at`.id=tm.team_id";
        List<Map<String, Object>> teamList = jdbcTemplate.queryForList(teamSql);
        Map<Integer, List<Map<String, Object>>> m = teamList.stream().collect(Collectors.groupingBy(tem -> ((Integer) tem.get("team_id")).intValue(), Collectors.toList()));
        List<Map<String, Object>> mapList = new ArrayList<>();
        for (Integer i : m.keySet()) {
            Map<String, Object> objectMap = new HashMap<>();
            objectMap.put("teamId", i);
            objectMap.put("teamName", m.get(i).get(0).get("teamName"));
            objectMap.put("teamDoctors", m.get(i));
            mapList.add(objectMap);
        }
        jsonObject.put("teamAndDoctors", mapList);
        //获取专科团队疾病标签
        teamSql = "SELECT wtdr.disease_name from  wlyy.wlyy_team_disease_relation wtdr WHERE wtdr.team_code IN ( SELECT watm.team_id teamId FROM  " + basedb + ".wlyy_admin_team_member watm WHERE watm.doctor_code ='" + doctorCode + "'" + " AND watm.available = '1' ) AND wtdr.del='1'";
        //new BeanPropertyRowMapper(
        List<String> stringList = jdbcTemplate.queryForList(teamSql, String.class);
        jsonObject.put("teamDisease", stringList.stream().collect(Collectors.joining(" ")));
        //疾病标签
        teamSql = "SELECT wspl.label_code,wspl.label_name from  wlyy.wlyy_sign_patient_label wspl WHERE wspl.label_type='8' AND status='1'";
        List<Map<String, Object>> signPatientLabelList = jdbcTemplate.queryForList(teamSql);
        jsonObject.put("signPatientLabels", signPatientLabelList);
        return jsonObject;
    }
        Map<String,Object> resultMap = new HashMap<>();
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultMap);
    /**
     * 专科医生发起签约
     * @param specialistPatientRelationDO
     * @return
     * @throws Exception
     */
    public ObjEnvelop<SpecialistPatientRelationDO> createPatientInSpeciaRelation(SpecialistPatientRelationDO specialistPatientRelationDO) throws Exception {
        specialistPatientRelationDO.setSignStatus("1");
        specialistPatientRelationDO.setSignDate(new Date());
        specialistPatientRelationDO.setCreateUser(specialistPatientRelationDO.getDoctor());
        specialistPatientRelationDO.setCreateUserName(specialistPatientRelationDO.getDoctorName());
        specialistPatientRelationDO.setStatus("1");//计管师分配状态
        specialistPatientRelationDO.setSignYear(String.valueOf(DateUtil.getNowYear()));
        specialistPatientRelationDO.setSignDate(new Date());
        specialistPatientRelationDO = specialistPatientRelationDao.save(specialistPatientRelationDO);
        return ObjEnvelop.getSuccess("success", specialistPatientRelationDO);
    }
}