فهرست منبع

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

trick9191 7 سال پیش
والد
کامیت
15fa65b8a6

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

@ -37,9 +37,9 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
        // 多个拦截器组成一个拦截器链
        // addPathPatterns 用于添加拦截规则
        // excludePathPatterns 用户排除拦截
        registry.addInterceptor(doctorInterceptor).addPathPatterns("/doctor/**", "/statistics/province/**", "/statistics/**");
        registry.addInterceptor(patientInterceptor).addPathPatterns("/patient/**");
        registry.addInterceptor(userInterceptor).addPathPatterns("/user/**");
//        registry.addInterceptor(doctorInterceptor).addPathPatterns("/doctor/**", "/statistics/province/**", "/statistics/**");
//        registry.addInterceptor(patientInterceptor).addPathPatterns("/patient/**");
//        registry.addInterceptor(userInterceptor).addPathPatterns("/user/**");
        super.addInterceptors(registry);
        logger.info("init doctorInterceptor,patientInterceptor");

+ 9 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionExpressage.java

@ -36,7 +36,8 @@ public class PrescriptionExpressage extends IdEntity{
    private Integer weight;                  //快递重量  单位是g
    //配送人信息
    private String hospitalName;            // 如果配送方式是健管师那么这个字段存服务站名称,如果是快递配送那么是快递公司名称
    private String hospitalAddress;         // 机构地址
    private String hospitalAddress;         // 配送机构地址
    private String hospitalCode;            //配送机构code
    private String expressageName;          //配送人名称
    private String expressageCode;          //配送人code
    private String expressageMobile;        //配送人电话
@ -55,6 +56,13 @@ public class PrescriptionExpressage extends IdEntity{
    private Integer del;    //1可用 0删除
    public String getHospitalCode() {
        return hospitalCode;
    }
    public void setHospitalCode(String hospitalCode) {
        this.hospitalCode = hospitalCode;
    }
    @Column(name = "code", unique = true , nullable=false)
    public String getCode() {

+ 0 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorAdminTeamDao.java

@ -93,5 +93,4 @@ public interface DoctorAdminTeamDao extends
    //  查询当前医生是否为团队长
    @Query("SELECT t.id from AdminTeam t WHERE t.available = true  AND t.leaderCode = ?1 ")
    Integer findLeader(String leaderCode);
}

+ 203 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -1,10 +1,16 @@
package com.yihu.wlyy.service.app.prescription;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinMessageUtils;
import org.json.JSONObject;
import com.yihu.wlyy.entity.dict.SystemDict;
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.patient.prescription.*;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
@ -13,9 +19,9 @@ import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.util.ImUtill;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -58,6 +64,8 @@ public class PrescriptionInfoService extends BaseService {
    @Autowired
    private ImUtill imUtill;
    @Autowired
    private DoctorAdminTeamDao doctorAdminTeamDao;
    @Autowired
    private MessageDao messageDao;
    private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
@ -546,7 +554,7 @@ public class PrescriptionInfoService extends BaseService {
     * @param size 分页大小
     * @return
     */
    public JSONArray getDoctorPrescriptionExpressage(String type,String doctor, String nameKey,String startDate,String endDate,String hospital,String state,Integer page,Integer size){
    public JSONArray getHDoctorPrescriptionExpressage(String type,String doctor, String nameKey,String startDate,String endDate,String hospital,String state,Integer page,Integer size){
        StringBuffer pre_sql = new StringBuffer("SELECT " +
                " p.`name`, " +
@ -584,7 +592,7 @@ public class PrescriptionInfoService extends BaseService {
            }
        }
        if(StringUtils.isNotBlank(nameKey)){
            pre_sql.append(" AND p.name = ? ");
            pre_sql.append(" AND p.name LIKE ? ");
            param.add("%"+nameKey+"%");
        }
        if(StringUtils.isNotBlank(startDate)){
@ -672,4 +680,196 @@ public class PrescriptionInfoService extends BaseService {
        }
        return 0;
    }
    public JSONObject getPrescriptionExpressageAsdoctorFilter(){
        JSONObject rs = new JSONObject();
        List<Map<String,Object>> states = new ArrayList<>();
        Map<String,Object> map1 = new HashMap<>();
        map1.put("name","订单已支付");
        map1.put("code",PrescriptionLog.PrescriptionLogStatus.pay_success.getValue());
        states.add(map1);
        Map<String,Object> map2 = new HashMap<>();
        map2.put("name","配药完成");
        map2.put("code",PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue());
        states.add(map2);
        Map<String,Object> map3 = new HashMap<>();
        map3.put("name","配送中");
        map3.put("code",PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
        states.add(map3);
        Map<String,Object> map4 = new HashMap<>();
        map4.put("name","药品到达服务站");
        map4.put("code",PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getValue());
        states.add(map4);
        Map<String,Object> map5 = new HashMap<>();
        map2.put("name","配药完成");
        map2.put("code",PrescriptionLog.PrescriptionLogStatus.finish.getValue());
        states.add(map2);
        //设置配送状态下拉框
        rs.put("states",states);
        //1 自取 2快递配送 3健管师配送
        List<Map<String,Object>> dispensaryTypes = new ArrayList<>();
        Map<String,Object> type1 = new HashMap<>();
        type1.put("name","自取");
        type1.put("code","1");
        dispensaryTypes.add(type1);
        Map<String,Object> type2 = new HashMap<>();
        type2.put("name","快递配送");
        type2.put("code","2");
        dispensaryTypes.add(type2);
        Map<String,Object> type3 = new HashMap<>();
        type3.put("name","健管师配送");
        type3.put("code","3");
        dispensaryTypes.add(type3);
        //设置配送状态下拉框
        rs.put("dispensaryTypes",dispensaryTypes);
        return rs;
    }
    public JSONArray getDoctorPrescriptionExpressage(String teamCode, String nameKey,String startDate,String endDate,String hospital,String state,String dispensaryType,String AllocationType,Integer page,Integer size){
        StringBuffer pre_sql = new StringBuffer("SELECT " +
                " p.`name`, " +
                " TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, " +
                " p.sex, " +
                " p.photo, " +
                " pr.`status`, " +
                " pr.`code`, " +
                " LEFT(pr.create_time,19) AS createTime, " +
                " pr.doctor, " +
                " pr.dispensary_type,"+
                " e.expressage_code AS expressageCode "+
                " FROM " +
                " wlyy_prescription pr " +
                " LEFT JOIN wlyy_patient p ON pr.patient = p.`code` " +
                " JOIN wlyy_prescription_expressage e ON pr.code = e.prescription_code " +
                " JOIN wlyy_prescription_reviewed r ON pr.code = r.prescription_code " +
                " WHERE 1=1 " );
        List<Object> params = new ArrayList<>();
        setDoctorExpressageSql(pre_sql,params, teamCode,  nameKey, startDate, endDate, hospital, state,dispensaryType,AllocationType, page, size);
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(pre_sql.toString(),params.toArray());
        //通过缓存查找药品和疾病
        for(Map<String,Object> map :rs){
            String code = (String)map.get("code");
            map.put("prescriptionInfo",prescriptionDiagnosisService.getPrescriptionInfo(code));
            map.put("prescriptionDt", prescriptionDiagnosisService.getPrescriptionDiagnosis(code));
        }
        return new JSONArray(rs);
    }
    public void setDoctorExpressageSql(StringBuffer pre_sql,List<Object> param,String teamCode, String nameKey,String startDate,String endDate,String hospital,String state,String dispensaryType,String AllocationType,Integer page,Integer size){
        if(StringUtils.isNotBlank(nameKey)){
            pre_sql.append(" AND p.name LIKE ? ");
            param.add("%"+nameKey+"%");
        }
        if(StringUtils.isNotBlank(teamCode)){
            pre_sql.append(" AND p.admin_team_id = ? ");
            param.add("%"+teamCode+"%");
        }
        if(StringUtils.isNotBlank(startDate)){
            pre_sql.append(" AND pr.create_time >= ? ");
            param.add(startDate+" 00:00:00");
        }
        if(StringUtils.isNotBlank(endDate)){
            pre_sql.append(" AND pr.create_time <= ? ");
            param.add(startDate+" 23:59:59");
        }
        if(StringUtils.isNotBlank(hospital)){
            pre_sql.append(" AND e.hospital_code = ? ");
            param.add(hospital);
        }
        if(StringUtils.isNotBlank(state)){
            pre_sql.append(" AND pr.status = ? ");
            param.add(state);
        }
        if(StringUtils.isNotBlank(dispensaryType)){
            pre_sql.append(" AND pr.dispensary_type = ? ");
            param.add(dispensaryType);
        }
        if(StringUtils.isNotBlank(AllocationType)){
            //1为未分配建管师列表
            if("1".equals(AllocationType)){
                pre_sql.append(" AND pr.expressage_code IS NULL ");
            }
        }
        pre_sql.append(" ORDER BY r.reviewed_time DESC ");
        if(page!=null&&size!=null){
            pre_sql.append(" LIMIT "+(page-1)*size+","+size);
        }
    }
    public JSONObject getCountExpressage(String teamCode){
        StringBuffer pre_sql = new StringBuffer("SELECT count(1) AS count FROM  " +
                "  wlyy_prescription pr " +
                "  JOIN wlyy_prescription_expressage e ON pr.code = e.prescription_code " +
                "  WHERE pr.admin_team_id = ? "+
                "  AND pr.dispensary_type =3" +
                "  AND e.expressage_code IS NULL");
        List<Map<String,Object>> list = jdbcTemplate.queryForList(pre_sql.toString(),new Object[]{teamCode});
        if(list!=null&&list.size()>0){
            Map<String,Object> map = list.get(0);
            return new JSONObject(map);
        }else{
            JSONObject rs = new JSONObject();
            rs.put("count",0);
            return rs;
        }
    }
    public JSONArray getHospitalListTitle(String teamCode){
        StringBuffer pre_sql = new StringBuffer("SELECT e.hospital_code AS hospitalCode ,e.hospital_name AS hospitalName FROM " +
                "  wlyy_prescription pr " +
                "  JOIN wlyy_prescription_expressage e ON pr.code = e.prescription_code " +
                "  WHERE pr.admin_team_id = ? "+
                "  AND e.expressage_code IS NULL " +
                "  AND pr.dispensary_type =3 " +
                "  GROUP BY e.hospital_code ");
        List<Map<String,Object>> list = jdbcTemplate.queryForList(pre_sql.toString(),new Object[]{teamCode});
        return new JSONArray(list);
    }
    public JSONArray getTeamHealthDoctorCount(String doctor){
        Doctor d = doctorDao.findByCode(doctor);
        List<AdminTeam> adminTeams = doctorAdminTeamDao.findByOrgCode(d.getHospital());
        List<Map<String,Object>> rsList = new ArrayList<>();
        if(adminTeams!=null&&adminTeams.size()>0){
            for(AdminTeam adminTeam : adminTeams){
                Map<String,Object> m = new HashedMap();
                m.put("adminTeamCode",adminTeam.getId());
                m.put("adminTeamName",adminTeam.getName());
                StringBuffer pre_sql = new StringBuffer("SELECT " +
                        " COUNT(1) AS count " +
                        " FROM " +
                        " wlyy_admin_team_member m " +
                        " JOIN wlyy_doctor d ON d. CODE = m.doctor_code " +
                        " WHERE " +
                        " d.`level` = 3 " +
                        " AND m.team_id = ? ");
                List<Map<String,Object>> list = jdbcTemplate.queryForList(pre_sql.toString(),new Object[]{adminTeam.getId()});
                if(list!=null&&list.size()>0){
                    Map<String,Object> map = list.get(0);
                    m.put("count",map.get("count"));
                }else{
                    m.put("count",0);
                }
                rsList.add(m);
            }
        }
        return new JSONArray(rsList);
    }
}

+ 69 - 14
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java

@ -42,7 +42,6 @@ public class PrescriptionInfoController extends BaseController{
    @RequestMapping(value = "/getPrescriptionFilter", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取过滤规则信息列表")
    public String getPrescriptionFilter(){
        try {
@ -54,7 +53,6 @@ public class PrescriptionInfoController extends BaseController{
    }
    @RequestMapping(value = "/getDoctorPrescription", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取全科医生/建管师续方列表/搜索")
    public String getDoctorPrescription(@RequestParam(required = true)@ApiParam(value = "团队code", name = "teamCode") Integer teamCode,
                                        @RequestParam(required = false)@ApiParam(value = "续方状态", name = "state") String state,
@ -74,7 +72,6 @@ public class PrescriptionInfoController extends BaseController{
    }
    @RequestMapping(value = "/getContinuedPrescriptionAsDoctor", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "续方详情")
    public String getContinuedPrescriptionAsDoctor(@RequestParam(required = true)@ApiParam(value = "续方CODE", name = "code") String code,
                                                   @RequestParam(required = true)@ApiParam(value = "团队长标识:1:是;2否", name = "type") String type){
@ -87,7 +84,6 @@ public class PrescriptionInfoController extends BaseController{
    }
    @RequestMapping(value = "/reviewPrescription", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "续方审核")
    public String reviewPrescription(@RequestParam(required = true)@ApiParam(value = "续方CODE", name = "code") String code,
                                     @RequestParam(required = false)@ApiParam(value = "不同意原因", name = "reason") String reason,
@ -101,7 +97,6 @@ public class PrescriptionInfoController extends BaseController{
    }
    @RequestMapping(value = "/updatePresInfo", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "调整处方")
    @ObserverRequired
    public String updatePresInfo(@RequestParam(required = true)@ApiParam(value = "续方CODE", name = "code") String code,
@ -117,7 +112,6 @@ public class PrescriptionInfoController extends BaseController{
    }
    @RequestMapping(value = "/getInfoTitle", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "调整处方-药品分类及种类数目")
    public String getInfoTitle(){
        try {
@ -129,7 +123,6 @@ public class PrescriptionInfoController extends BaseController{
    }
    @RequestMapping(value = "/getInfoListByParentCode", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "药品类别获取药品")
    private String getInfoListByParentCode(@RequestParam(required = true)@ApiParam(value = "药品类别Code", name = "code") String code){
        try {
@ -178,7 +171,6 @@ public class PrescriptionInfoController extends BaseController{
    }
    @RequestMapping(value = "/getDrugTimes", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "药品品使用频次字典")
    public String getDrugTimes(){
        try {
@ -189,10 +181,9 @@ public class PrescriptionInfoController extends BaseController{
        }
    }
    @RequestMapping(value = "/getDoctorPrescriptionExpressage", method = RequestMethod.GET)
    @ResponseBody
    @RequestMapping(value = "/getHDoctorPrescriptionExpressage", method = RequestMethod.GET)
    @ApiOperation(value = "获取续方订单列表")
    public String getDoctorPrescriptionExpressage(@RequestParam(required = false) @ApiParam(value = "1:需跟踪;2:已接收", name = "type")  String type,
    public String getHDoctorPrescriptionExpressage(@RequestParam(required = false) @ApiParam(value = "1:需跟踪;2:已接收", name = "type")  String type,
                                                  @RequestParam(required = false) @ApiParam(value = "患者姓名关键字", name = "nameKey")String nameKey,
                                                  @RequestParam(required = false) @ApiParam(value = "开始时间", name = "startDate")String startDate,
                                                  @RequestParam(required = false) @ApiParam(value = "结束时间", name = "endDate")String endDate,
@ -201,7 +192,7 @@ public class PrescriptionInfoController extends BaseController{
                                                  @RequestParam(required = false) @ApiParam(value = "页数", name = "page")Integer page,
                                                  @RequestParam(required = false) @ApiParam(value = "每页大小", name = "size")Integer size){
        try {
            return write(200, "操作成功!", "data",prescriptionInfoService.getDoctorPrescriptionExpressage(type,"hxmD201703150222",nameKey,startDate,endDate,hospital,state,page,size));
            return write(200, "操作成功!", "data",prescriptionInfoService.getHDoctorPrescriptionExpressage(type,getUID(),nameKey,startDate,endDate,hospital,state,page,size));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -209,11 +200,75 @@ public class PrescriptionInfoController extends BaseController{
    }
    @RequestMapping(value = "/getPrescriptionExpressageFilter", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取续方订单列表过滤条件")
    public String getPrescriptionExpressageFilter(){
        try {
            return write(200, "操作成功!", "data",prescriptionInfoService.getPrescriptionExpressageFilter("hxmD201703150222"));
            return write(200, "操作成功!", "data",prescriptionInfoService.getPrescriptionExpressageFilter(getUID()));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/getPrescriptionExpressageAsdoctorFilter", method = RequestMethod.GET)
    @ApiOperation(value = "获取全科医生续方订单列表过滤条件")
    public String getPrescriptionExpressageAsdoctorFilter(){
        try {
            return write(200, "操作成功!", "data",prescriptionInfoService.getPrescriptionExpressageAsdoctorFilter());
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/getDoctorPrescriptionExpressage", method = RequestMethod.GET)
    @ApiOperation(value = "获取全科医生续方订单列表过滤条件")
    public String getDoctorPrescriptionExpressage(@RequestParam(required = false) @ApiParam(value = "团队Code", name = "teamCode")String teamCode,
                                                  @RequestParam(required = false) @ApiParam(value = "居民搜素关键字", name = "nameKey")String nameKey,
                                                  @RequestParam(required = false) @ApiParam(value = "开始时间", name = "startDate")String startDate,
                                                  @RequestParam(required = false) @ApiParam(value = "结束时间", name = "endDate")String endDate,
                                                  @RequestParam(required = false) @ApiParam(value = "机构", name = "hospital")String hospital,
                                                  @RequestParam(required = false) @ApiParam(value = "配送状态", name = "state")String state,
                                                  @RequestParam(required = false) @ApiParam(value = "配送方式:1 自取 2快递配送 3健管师配送", name = "dispensaryType")String dispensaryType,
                                                  @RequestParam(required = false) @ApiParam(value = "未分配健管师", name = "传1为未分配健管师")String AllocationType,
                                                  @RequestParam(required = false) @ApiParam(value = "起始页", name = "page")Integer page,
                                                  @RequestParam(required = false) @ApiParam(value = "每页大小", name = "size")Integer size){
        try {
            return write(200, "操作成功!", "data",
                    prescriptionInfoService.
                            getDoctorPrescriptionExpressage(teamCode, nameKey, startDate, endDate, hospital, state, dispensaryType,AllocationType, page, size));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/getCountExpressage", method = RequestMethod.GET)
    @ApiOperation(value = "获取指定团队未分配建管师订单数目")
    public String getCountExpressage(@RequestParam(required = true) @ApiParam(value = "团队Code", name = "teamCode")String teamCode){
        try {
            return write(200, "操作成功!", "data", prescriptionInfoService.getCountExpressage(teamCode));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/getHospitalListTitle", method = RequestMethod.GET)
    @ApiOperation(value = "获取指定团队未分配建管师订单数目")
    public String getHospitalListTitle(@RequestParam(required = true) @ApiParam(value = "团队Code", name = "teamCode")String teamCode){
        try {
            return write(200, "操作成功!", "data", prescriptionInfoService.getHospitalListTitle(teamCode));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/getTeamHealthDoctorCount", method = RequestMethod.GET)
    @ApiOperation(value = "获取医生同社区底下所有团队建管师数目")
    public String getTeamHealthDoctorCount(){
        try {
            return write(200, "操作成功!", "data", prescriptionInfoService.getTeamHealthDoctorCount(getUID()));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");