Kaynağa Gözat

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

trick9191 7 yıl önce
ebeveyn
işleme
ed232aa876

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

@ -30,7 +30,7 @@ public class Prescription extends IdEntity {
    private String patient;                  //关联 wlyy_patient code
    private String patientName;             //患者名称
    private Integer type;                    //1 处方 2 续方
    private Integer status;                  //状态 (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 10 审核通过/开方中  , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送  41配送失败  42配送中   43配送到服务站  100配送到患者手中/已完成)
    private Integer status;                  //状态 (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 3.调整完成 4.调整失败 10 审核通过/开方中  , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送  41配送失败  42配送中   43配送到服务站  100配送到患者手中/已完成)
    private String doctor;                   //开处方的医生code 关联 wlyy_doctor
    private String doctorName;               //医生名称
    private Long adminTeamId;             //患者签约的行政团队

+ 32 - 10
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionLog.java

@ -52,23 +52,45 @@ public class PrescriptionLog extends IdEntity {
    //状态枚举
    public enum PrescriptionLogStatus {
        //续方取消
        pay_outtime("支付超时", -3),
        patient_canel("患者自己取消", -2),
        // 审核不通过
        no_reviewed("审核不通过", -1),
        revieweding("待审核", 0),
        //审核中
        changeing("调整中", 2),
        reviewed_success("审核通过/开方中", 10),
        wait_pay("开方完成/待支付", 20),
        change_success("调整成功",3),
        change_error("调整失败",4),
        Pharmacist_examination_error("药师审核失败",5),
        add_error("开方失败",6),
        reviewed_success(" 医生审核(CA)通过", 10),
        //药师审核中
        Pharmacist_examination("药师审核中",20),
        //开方中/药师审核成功
        adding("开方中/药师审核成功",30),
        //待支付
        wait_pay("开方完成/待支付", 40),
        pay_error("支付失败", 41),
        //配药中
        pay_success("支付成功/待配药", 50),
        //等待领药
        wait_expressage("配药成功/待配送", 60),
        pay_error("支付失败", 21),
        pay_success("支付成功/待配药", 30),
        wait_expressage("配药成功/待配送", 40),
        expressageing_error("配送失败", 41),
        expressageJGS("分配健管师", 42),
        //配送中
        expressageing_error("配送失败", 61),
        expressageJGS("分配健管师", 62),
        expressageing("配送中", 65),
        expressage2hospital("配送到服务站", 69),
        expressageing("配送中", 45),
        expressage2hospital("配送到服务站", 49),
        //已完成
        finish("配送到患者手中/已完成", 100);
        private String name;

+ 3 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionReviewed.java

@ -58,11 +58,12 @@ public class PrescriptionReviewed extends IdEntity {
    private String deptName;                   //科室名称
    private String doctor;                  //审核医生
    private String doctorName;                  //审核医生名称
    private Integer status;               //  1审核通过1 0待审核  -1  审核通过   -2无效审核
    private Integer status;               //  1审核通过1 0待审核  -1  审核不通过   -2无效审核
    private String reason;                  //审核不通过原因
    private String remark;                  //备注
    private Date reviewedTime;           //审核时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getReviewedTime() {
        return reviewedTime;
    }
@ -87,6 +88,7 @@ public class PrescriptionReviewed extends IdEntity {
        this.prescriptionCode = prescriptionCode;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }

+ 3 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionAdjustDao.java

@ -4,9 +4,12 @@ import com.yihu.wlyy.entity.patient.prescription.PrescriptionAdjust;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Trick on 2017/8/2.
 */
public interface PrescriptionAdjustDao extends PagingAndSortingRepository<PrescriptionAdjust, Long>,JpaSpecificationExecutor<PrescriptionAdjust> {
    List<PrescriptionAdjust> findByPrescriptionCode(String code);
}

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

@ -168,6 +168,7 @@ public class PrescriptionInfoService extends BaseService {
        Prescription prescription = prescriptionDao.findByCode(code);
        List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
        PrescriptionReviewed reviewed =  prescriptionReviewedDao.findByPrescriptionCode(code);
        List<PrescriptionAdjust> prescriptionAdjusts = prescriptionAdjustDao.findByPrescriptionCode(code);
        JSONObject rs = new JSONObject();
        if(prescription!=null&&StringUtils.isNotBlank(prescription.getPatient())){
            Patient p = patientDao.findByCode(prescription.getPatient());
@ -178,13 +179,18 @@ public class PrescriptionInfoService extends BaseService {
        if(prescription.getStatus()==10){
            Long s = (prescription.getCreateTime().getTime()-new Date().getTime())/1000;
            rs.put("time",s);
            //rs.put("time",s);
            if(s>172800){
                prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.pay_outtime.getValue());
                prescriptionDao.save(prescription);
            }
        }else{
            rs.put("time","");
            //rs.put("time","");
        }
        if(prescriptionAdjusts!=null&&prescriptionAdjusts.size()>0){
            rs.put("isAdjust",true);
        }else{
            rs.put("isAdjust",false);
        }
        rs.put("reviewed",reviewed);
        rs.put("prescription",prescription);
@ -456,4 +462,115 @@ public class PrescriptionInfoService extends BaseService {
        return new JSONArray(list);
    }
    /**
     * 获取订单记录
     * @param type 1.需跟踪订单 2.已经接受订单
     * @param doctor 医生code
     * @param nameKey 用户姓名关键字
     * @param startDate 开始时间
     * @param endDate 结束时间
     * @param hospital 服务站
     * @param state 状态
     * @param page 起始页
     * @param size 分页大小
     * @return
     */
    public JSONArray getDoctorPrescriptionExpressage(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`, " +
                " TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, " +
                " p.sex, " +
                " p.photo, " +
                " pr.`status`, " +
                " pr.`code`, " +
                " LEFT(pr.create_time,19) AS createTime, " +
                " pr.doctor " +
                " 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 " +
                " WHERE 1=1 " );
        List<Object> params = new ArrayList<>();
        setExpressageSql(pre_sql,params,type, doctor,  nameKey, startDate, endDate, hospital, state, 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 setExpressageSql(StringBuffer pre_sql,List<Object> param,String type,String doctor, String nameKey,String startDate,String endDate,String hospital,String state,Integer page,Integer size){
        if(StringUtils.isNotBlank(type)){
            if("1".equals(type)){
                pre_sql.append(" AND e.expressageCode = ?");
                param.add(doctor);
            }else{
                pre_sql.append(" AND e.acceptCode = ?");
                param.add(doctor);
            }
        }
        if(StringUtils.isNotBlank(nameKey)){
            pre_sql.append(" AND p.name = ? ");
            param.add("%"+nameKey+"%");
        }
        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);
        }
        pre_sql.append(" ORDER BY pr.create_time DESC ");
        if(page!=null&&size!=null){
            pre_sql.append(" LIMIT "+(page-1)*size+","+size);
        }
    }
    public JSONObject getPrescriptionExpressageFilter(){
        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> 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.wait_expressage.getValue());
//        states.add(map4);
//
//        Map<String,Object> map5 = new HashMap<>();
//        map2.put("name","配药完成");
//        map2.put("code",PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getValue());
//        states.add(map2);
        return rs;
    }
}

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

@ -58,7 +58,7 @@ public class PrescriptionInfoController extends BaseController{
                                        @RequestParam(required = false)@ApiParam(name="startDate",value="开始时间")String startDate,
                                        @RequestParam(required = false)@ApiParam(name="endDate",value="结束时间")String endDate,
                                        @RequestParam(required = false)@ApiParam(name="nameKeyword",value="患者姓名模糊匹配")String nameKeyword,
                                        @RequestParam(required = false)@ApiParam(name="nameKeyword",value="患者姓名模糊匹配")String patient,
                                        @RequestParam(required = false)@ApiParam(name="patient",value="患者Code")String patient,
                                        @RequestParam(required = false)@ApiParam(name="page",value="起始页")Integer page,
                                        @RequestParam(required = false)@ApiParam(name="size",value="每页条数")Integer size){
        try {
@ -183,4 +183,23 @@ public class PrescriptionInfoController extends BaseController{
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/getDoctorPrescriptionExpressage", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取续方订单列表")
    public String getDoctorPrescriptionExpressage(@RequestParam(required = true) @ApiParam(value = "1:需跟踪;2:已接收", name = "type")  String type,
                                                  @RequestParam(required = true) @ApiParam(value = "患者姓名关键字", name = "nameKey")String nameKey,
                                                  @RequestParam(required = true) @ApiParam(value = "开始时间", name = "startDate")String startDate,
                                                  @RequestParam(required = true) @ApiParam(value = "结束时间", name = "endDate")String endDate,
                                                  @RequestParam(required = true) @ApiParam(value = "服务站", name = "hospital")String hospital,
                                                  @RequestParam(required = true) @ApiParam(value = "配送状态", name = "state")String state,
                                                  @RequestParam(required = true) @ApiParam(value = "页数", name = "page")Integer page,
                                                  @RequestParam(required = true) @ApiParam(value = "每页大小", name = "size")Integer size){
        try {
            return write(200, "操作成功!", "data",prescriptionInfoService.getDoctorPrescriptionExpressage(type,getUID(),nameKey,startDate,endDate,hospital,state,page,size));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
}