浏览代码

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

liuwenbin 7 年之前
父节点
当前提交
3de87c8b52

+ 25 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/customer/CustomerSynergyManageController.java

@ -113,4 +113,29 @@ public class CustomerSynergyManageController extends BaseController {
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/takeWorkorderNum", method = RequestMethod.GET)
    @ApiOperation(value = "获取协同服务取号信息")
    public String takeWorkorderNum(@ApiParam(name="workorderCode",value="协同服务工单code",required = false)
                                @RequestParam(required = true)String workorderCode,
                                @ApiParam(name="townCode",value="所属区县",required = false)
                                @RequestParam(required = false)String townCode,
                                @ApiParam(name="hospitalCode",value="所属社区",required = false)
                                @RequestParam(required = false)String hospitalCode,
                                @ApiParam(name="diseaseCode",value="疾病类型",required = false)
                                @RequestParam(required = false)String diseaseCode,
                                @ApiParam(name="healthCode",value="健康情况",required = false)
                                @RequestParam(required = false)String healthCode,
                                @ApiParam(name="serveCode",value="服务类型",required = false)
                                @RequestParam(required = false)String serveCode,
                                @ApiParam(name="isFollow",value="是否待跟进(1是,0否)",required = false)
                                @RequestParam(required = false)Integer isFollow){
        try {
            Map<String,Object> resultMap = synergyManageService.takeWorkorderNum(workorderCode,townCode,hospitalCode,
                    diseaseCode,healthCode,serveCode,isFollow);
            return write(200,"取号成功","data", resultMap);
        }catch (Exception e){
            error(e);
            return error(-1,"取号失败");
        }
    }
}

+ 1 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/SignFamilyDao.java

@ -34,7 +34,7 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    @Query("select a from SignFamily a where a.patient = ?1 and a.status >= 0")
    List<SignFamily> findAllSignByPatient(String patient);
    @Query("select a from SignFamily a where a.patient = ?1 and a.status > 0 and a.expensesStatus='1'")
    @Query("select a from SignFamily a where a.patient = ?1 and a.status =1 and a.expensesStatus='1'")
    SignFamily findSignByPatient(String patient);
    @Query("select a from SignFamily a where a.patient = ?1 and a.status > 0 and a.expensesStatus ='1' order by a.czrq desc")

+ 86 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/SignPatientLabelInfoDao.java

@ -0,0 +1,86 @@
package com.yihu.wlyy.repository;
import com.yihu.wlyy.entity.SignPatientLabelInfo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by lyr on 2016/10/9.
 */
public interface SignPatientLabelInfoDao extends
        PagingAndSortingRepository<SignPatientLabelInfo, Long>,
        JpaSpecificationExecutor<SignPatientLabelInfo> {
    /**
     * 查询某个患者的标签
     *
     * @param patient 患者
     * @param status  状态
     * @return
     */
    List<SignPatientLabelInfo> findByPatientAndStatus(String patient, Integer status);
    /**
     * 查询某个患者的标签
     *
     * @param patient 患者
     * @param status  状态
     * @return
     */
    @Query("select f from SignPatientLabelInfo f,SignPatientLabel l where f.patient = ?1 and f.status = ?2 and f.label = l.labelCode and f.labelType =l.labelType" +
            " and l.status = ?2 and (l.labelType <> '4' or l.teamCode = ?3 or ( l.labelType = '4' and l.labelCode in (1,2)) )")
    List<SignPatientLabelInfo> findByPatientAndStatusByTeam(String patient, Integer status, Long teamCode);
    /**
     * 查询某个患者的某个类型标签
     *
     * @param patient   患者
     * @param labelType 标签类型
     * @param status    状态
     * @return
     */
    List<SignPatientLabelInfo> findByPatientAndLabelTypeAndStatus(String patient, String labelType, Integer status);
    /**
     * 查询某个患者的某个类型的某个标签
     *
     * @param patient   患者
     * @param labelCode  标签代码
     * @param labelType 标签类型
     * @param status    状态
     * @return
     */
    SignPatientLabelInfo findByPatientAndLabelAndLabelTypeAndStatus(String patient, String labelCode, String labelType, Integer status);
    /**
     * 删除患者的某个标签类型的所有指定状态标签
     *
     * @param patient
     * @param labelType
     * @param status
     * @return
     */
    @Modifying
    @Query("update SignPatientLabelInfo set status = 0 where patient = ?1 and labelType = ?2 and status = ?3")
    int deleteByPatientAndLabelTypeAndStatus(String patient, String labelType, Integer status);
    @Modifying
    @Query("update SignPatientLabelInfo set status = 0 where label = ?1 and status = 1")
    int deleteByLabel(String labelCode);
    /**
     * 更新某个标签名称
     *
     * @param labelName
     * @param labelCode
     * @return
     */
    @Modifying
    @Query("update SignPatientLabelInfo a set a.labelName = ?1 where a.label= ?2 and a.labelType = '4' ")
    int updateLabelName(String labelName, String labelCode);
}

+ 3 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageSynergyWorkorderCustomerLogDao.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.repository.synergy;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderCustomerLogDO;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
@ -8,5 +9,6 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 */
public interface ManageSynergyWorkorderCustomerLogDao extends PagingAndSortingRepository<ManageSynergyWorkorderCustomerLogDO, Long> {
    @Query("select count(distinct l.callCode) from ManageSynergyWorkorderCustomerLogDO l where l.servicePatientCode=?1 ")
    Integer callNumByWorkorder(String servicePatientCode);
}

+ 84 - 20
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/SynergyManageService.java

@ -1,15 +1,23 @@
package com.yihu.wlyy.service.synergy;
import com.yihu.wlyy.entity.Patient;
import com.yihu.wlyy.entity.SignFamily;
import com.yihu.wlyy.entity.SignPatientLabelInfo;
import com.yihu.wlyy.entity.User;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderExecutorDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerDO;
import com.yihu.wlyy.repository.PatientDao;
import com.yihu.wlyy.repository.SignFamilyDao;
import com.yihu.wlyy.repository.SignPatientLabelInfoDao;
import com.yihu.wlyy.repository.UserDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkOrderDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkorderCustomerLogDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkorderExecutorDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkorderServicerDao;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.util.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
@ -43,6 +51,14 @@ public class SynergyManageService extends BaseJpaService {
    private ManageSynergyWorkorderExecutorDao workorderExecutorDao;
    @Autowired
    private UserDao userDao;
    @Autowired
    private ManageSynergyWorkorderCustomerLogDao manageSynergyWorkorderCustomerLogDao;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private SignPatientLabelInfoDao signPatientLabelInfoDao;
    /**
     * 根据服务编码获取工单
@ -330,25 +346,45 @@ public class SynergyManageService extends BaseJpaService {
     * @param workorderCode
     * @param townCode
     * @param hospitalCode
     * @param labelType
     * @param labelCode
     */
    public void takeWorkorderNum(String workorderCode,String townCode,String hospitalCode,Integer labelType,String labelCode) throws Exception{
    public Map<String,Object> takeWorkorderNum(String workorderCode,String townCode,String hospitalCode,
                                               String diseaseCode,String healthCode,String serveCode,Integer isFollow) throws Exception{
        String whereSql ="";
        String leftSql ="";
        if(StringUtils.isNotEmpty(townCode)){
            whereSql+=" and s.town='"+townCode+"' ";
        }
        if(StringUtils.isNotEmpty(hospitalCode)){
            whereSql+=" and s.hospital='"+hospitalCode+"' ";
        }
        String sql =" select DISTINCT w.*,s.mobile,s.service_patient_name,s.service_patient_code, " +
        String labelSql ="";
        if(StringUtils.isNotEmpty(diseaseCode)||StringUtils.isNotEmpty(healthCode)||StringUtils.isNotEmpty(serveCode)){
            leftSql +=" LEFT JOIN wlyy_sign_patient_label_info i on i.patient=s.service_patient_code and i.status=1 " ;
            if(StringUtils.isNotEmpty(diseaseCode)){
                labelSql+=" or (i.label='"+diseaseCode+"' and i.label_type='3') ";//疾病类型
            }
            if(StringUtils.isNotEmpty(healthCode)){
                labelSql+=" or (i.label='"+healthCode+"' and i.label_type='2') ";//健康情况
            }
            if(StringUtils.isNotEmpty(serveCode)){
                labelSql+=" or (i.label='"+serveCode+"' and i.label_type='1') ";//服务类型
            }
        }
        if(StringUtils.isNotEmpty(labelSql)){
            whereSql+= " and ( "+labelSql.substring(3)+" )";
        }
        if(isFollow!=null&&isFollow==1){//跟进
            leftSql+=" LEFT JOIN manage_synergy_workorder_servicer_log ll on ll.service_patient_code=s.code ";
            whereSql+=" and ll.follow_up=2 ";
        }
        String sql =" select DISTINCT w.*,s.mobile,s.service_patient_name,s.service_patient_code,s.code as servicerCode,s.town_name,s.hospital_name " +
                " w.create_user_name " +
                " from manage_synergy_workorder_servicer s " +
                " LEFT JOIN manage_synergy_workorder w on s.workorder_code=w.code and w.del=1 and w.status=2 " +
                " LEFT JOIN manage_synergy_workorder_executor e on e.workorder_code=w.code and e.del=1 " +
                " LEFT JOIN wlyy_sign_patient_label_info i on i.patient=s.service_patient_code and i.status=1 " +
                " LEFT JOIN manage_synergy_workorder w on s.workorder_code=w.code " +
                " LEFT JOIN manage_synergy_workorder_executor e on e.workorder_code=w.code " + leftSql+
                " LEFT JOIN manage_synergy_workorder_customer_log l on l.service_patient_code=s.service_patient_code " +
                " where s.status=1 and i.label='"+labelCode+"' and i.label_type='"+labelType+"' and s.workorderCode='"+workorderCode+"' " +
                " where s.status=1  and s.workorderCode='"+workorderCode+"' " +
                " and w.del=1 and w.status=2 and e.del=1 "+
                whereSql+" order by l.id desc";
        List<Map<String,Object>> resultWorkorderList = jdbcTemplate.queryForList(sql);
        Map<String,Object> resultMap = new HashMap<>();
@ -357,17 +393,45 @@ public class SynergyManageService extends BaseJpaService {
            //居民信息
            resultMap.put("mobile",workorderMap.get("mobile"));//电话号码
            resultMap.put("mobile",workorderMap.get("mobile"));//居民姓名
            resultMap.put("mobile",workorderMap.get("mobile"));//已呼叫次数
            resultMap.put("mobile",workorderMap.get("mobile"));//性别
            resultMap.put("mobile",workorderMap.get("mobile"));//年龄
            resultMap.put("mobile",workorderMap.get("mobile"));//所属区县
            resultMap.put("mobile",workorderMap.get("mobile"));//所属社区
            resultMap.put("mobile",workorderMap.get("mobile"));//签约医生
            resultMap.put("mobile",workorderMap.get("mobile"));//健管师
            resultMap.put("mobile",workorderMap.get("mobile"));//疾病类型
            resultMap.put("mobile",workorderMap.get("mobile"));//健康情况
            resultMap.put("mobile",workorderMap.get("mobile"));//服务类型
            Integer callNum = manageSynergyWorkorderCustomerLogDao.callNumByWorkorder(workorderMap.get("servicerCode")+"");
            resultMap.put("callNum",callNum);//已呼叫次数
            Patient patient =patientDao.findByCode(workorderMap.get("service_patient_code")+"");
            Integer sex = patient.getSex();
            String sexName ="";
            if(sex==1){
                sexName="男";
            }else if(sex==2){
                sexName="女";
            }else{
                sexName="未知";
            }
            resultMap.put("sex",sexName);//性别
            Integer age = IdCardUtil.getAgeForIdcard(patient.getIdcard());
            resultMap.put("age",age);//年龄
            resultMap.put("townName",workorderMap.get("town_name"));//所属区县
            resultMap.put("hospitalName",workorderMap.get("hospital_name"));//所属社区
            SignFamily signFamily = signFamilyDao.findSignByPatient(workorderMap.get("service_patient_code")+"");
            resultMap.put("signDoctor",signFamily.getDoctor());//签约医生(即:工单创建医生)
            resultMap.put("healthDoctor",signFamily.getDoctorHealthName());//健管师
            List<SignPatientLabelInfo> labelDiseaseType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(workorderMap.get("service_patient_code")+"",  "3", 1);
            String diseaseType="";
            for(SignPatientLabelInfo one:labelDiseaseType){
                diseaseType+=","+one.getLabelName();
            }
            resultMap.put("diseaseType",StringUtils.isNotEmpty(diseaseType)?diseaseType.substring(1):"");//疾病类型
            List<SignPatientLabelInfo> labelHealthType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(workorderMap.get("service_patient_code")+"",  "2", 1);
            String healthType="";
            for(SignPatientLabelInfo one:labelHealthType){
                healthType+=","+one.getLabelName();
            }
            resultMap.put("healthType",StringUtils.isNotEmpty(healthType)?healthType.substring(1):"");//健康情况
            List<SignPatientLabelInfo> labelServeType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(workorderMap.get("service_patient_code")+"",  "2", 1);
            String serveType="";
            for(SignPatientLabelInfo one:labelServeType){
                serveType+=","+one.getLabelName();
            }
            resultMap.put("serveType",StringUtils.isNotEmpty(serveType)?serveType.substring(1):"");//服务类型
            return resultMap;
        }else{
            throw new Exception("没有任务");
        }