Selaa lähdekoodia

Merge branch 'dev' of http://192.168.1.220:10080/trick9191/patient-co-management into dev

trick9191 7 vuotta sitten
vanhempi
commit
be8b30eed8

+ 201 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageService.java

@ -8,21 +8,24 @@ import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.prescription.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.UUID;
import java.util.*;
/**
 * Created by chenweida on 2017/7/27.
 * 订单物流相关
 */
@Service
public class PrescriptionExpressageService {
public class PrescriptionExpressageService extends BaseService {
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
@ -43,6 +46,8 @@ public class PrescriptionExpressageService {
    private DoctorDao doctorDao;
    @Autowired
    private HospitalDao hospitalDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PatientDao patientDao;
@ -247,8 +252,8 @@ public class PrescriptionExpressageService {
        prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
        //回填配送表的配送时间
        PrescriptionExpressage prescriptionExpressage=prescriptionExpressageDao.findByPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
        prescriptionExpressage.setExpressageTime(expressageing );
        PrescriptionExpressage prescriptionExpressage = prescriptionExpressageDao.findByPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
        prescriptionExpressage.setExpressageTime(expressageing);
        //得到patient
        Patient patient = patientDao.findByCode(prescription.getPatient());
@ -458,4 +463,195 @@ public class PrescriptionExpressageService {
            prescriptionExpressage.setExpressageHospitalAddress(hospitalAddress);
        }
    }
    public List<Map<String, Object>> getDrugDeliveryState() {
        String sql = "SELECT * FROM system_dict t WHERE t.dict_name = 'DRUGDELIVERY_STATE' ORDER BY DESC";
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
        return rs;
    }
    public List<Map<String, Object>> getEsListByIDCardOrSSC(String keyWord, Integer page, Integer pageSize) {
        Patient p = null;
        if (StringUtils.isNotBlank(keyWord)) {
            p = patientDao.findByIdcard(keyWord);
            if (p == null) {
                p = patientDao.findBySsc(keyWord);
            }
            if (p != null) {
                int start = (page - 1) * pageSize;
                String sql = "SELECT " +
                        "  py.charge_no AS chargeNo, " +
                        "  p.patient_name AS patientName, " +
                        "  p.patient AS patientCode, " +
                        "  py.pay_time AS payTime, " +
                        "  p.dispensary_type AS dispensaryType, " +
                        "  p.`status` " +
                        " FROM " +
                        " wlyy_prescription p " +
                        " JOIN wlyy_prescription_pay py ON py.prescription_code = p.`code` " +
                        " WHERE " +
                        " p.patient = '" + p.getCode() + "' " +
                        " AND p.`status`>=50 " +
                        " ORDER BY p.`status` ASC " +
                        " LIMIT " + start + "," + pageSize;
                List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
                return list;
            }
        }
        return null;
    }
    public String saveDrugDelivery(String doctor, String prescriptionCode, String reasonCode, String reasonName, String reason) {
        Prescription p = prescriptionDao.findByCode(prescriptionCode);
        Doctor d = doctorDao.findByCode(doctor);
        if (p != null) {
            p.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
            p.setDrugDeliveryflag(1);
            p.setDrugDeliveryOperator(doctor);
            p.setDrugDeliveryOperatorName(d.getName());
            p.setDrugDeliveryReason(reason);
            p.setDrugDeliveryReasonCode(reasonCode);
            p.setDrugDeliveryOperatorName(reasonName);
            p.setDrugDeliveryTime(new Date());
            prescriptionDao.save(p);
            //更新日志
            PrescriptionLog prescriptionLog = new PrescriptionLog();
            prescriptionLog.setPrescriptionCode(p.getCode());
            prescriptionLog.setCode(getCode());
            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.finish.getValue());
            prescriptionLog.setCreateTime(new Date());
            prescriptionLog.setFlag(1);
            prescriptionLog.setUserCode(doctor);
            prescriptionLog.setUserName(d.getName());
            prescriptionLog.setUserType(2);
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
            prescriptionLogDao.save(prescriptionLog);
            //更新二维码(isUse)
            PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeDao.finByCode(prescriptionCode);
            //修改取药码code为已经使用
            prescriptionDispensaryCode.setIsUse(1);
            prescriptionDispensaryCodeDao.save(prescriptionDispensaryCode);
            //更新配送信息
            PrescriptionExpressage prescriptionExpressage = prescriptionExpressageDao.findByPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
            prescriptionExpressage.setHospitalDoctor(doctor);
            prescriptionExpressage.setHospitalDoctorCode(d.getCode());
            prescriptionExpressage.setFetchingMedicineTime(new Date());
            prescriptionExpressageDao.save(prescriptionExpressage);
            return "1";
        }
        return "0";
    }
    public List<Map<String, Object>> getPresStatesList() {
        List<Map<String, Object>> rs = new ArrayList<>();
        Map<String, Object> map1 = new HashedMap();
        map1.put("code", PrescriptionLog.PrescriptionLogStatus.pay_success.getValue());
        map1.put("name", PrescriptionLog.PrescriptionLogStatus.pay_success.getName());
        rs.add(map1);
        Map<String, Object> map2 = new HashedMap();
        map2.put("code", PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue());
        map2.put("name", PrescriptionLog.PrescriptionLogStatus.wait_expressage.getName());
        rs.add(map2);
        Map<String, Object> map3 = new HashedMap();
        map3.put("code", PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
        map3.put("name", PrescriptionLog.PrescriptionLogStatus.expressageing.getName());
        rs.add(map3);
        Map<String, Object> map4 = new HashedMap();
        map4.put("code", PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getValue());
        map4.put("name", PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getName());
        rs.add(map4);
        Map<String, Object> map5 = new HashedMap();
        map5.put("code", PrescriptionLog.PrescriptionLogStatus.finish.getValue());
        map5.put("name", PrescriptionLog.PrescriptionLogStatus.finish.getName());
        rs.add(map5);
        return rs;
    }
    public List<Map<String, Object>> getPresEsPayList(String keyWord, String state, String type, String startDate, String endDate, String operator,String flag,Integer page, Integer pageSize) {
        int start = (page - 1) * pageSize;
        String sql = "SELECT " +
                "  py.charge_no AS chargeNo, " +
                "  p.patient_name AS patientName, " +
                "  p.patient AS patientCode, " +
                "  py.pay_time AS payTime, " +
                "  p.dispensary_type AS dispensaryType, " +
                "  p.drug_delivery_operator_name AS operatorName," +
                "  p.drug_delivery_flag AS drugDeliveryFlag, " +
                "  p.`status` " +
                " FROM " +
                " wlyy_prescription p " +
                " JOIN wlyy_prescription_pay py ON py.prescription_code = p.`code` " +
                " WHERE" +
                " 1=1 ";
        sql = setSQL( sql,keyWord,state,type,startDate,endDate,operator,flag);
        sql +=  " AND p.`status`>=50 " +
                " ORDER BY py.create_time DESC " +
                " LIMIT " + start + "," + pageSize;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    public String setSQL(String sql,String keyWord, String state, String type, String startDate, String endDate,String operator,String flag){
        //关键字搜索
        if(StringUtils.isNotBlank(keyWord)){
            Patient p = patientDao.findByIdcard(keyWord);
            if(p!=null){
                sql += " AND p.patient = '"+p.getCode()+"' ";
            }else{
                p = patientDao.findBySsc(keyWord);
                if(p!=null){
                    sql += " AND p.patient = '"+p.getCode()+"' ";
                }else{
                    sql += " AND ( py.charge_no = '"+keyWord+"' OR p.patient_name ='"+keyWord+"' )";
                }
            }
        }
        if(StringUtils.isNotBlank(state)){
            sql += " AND p.status = "+state ;
        }
        if(StringUtils.isNotBlank(type)){
            sql +=" AND p.dispensary_type =" +type;
        }
        if(StringUtils.isNotBlank(startDate)){
            startDate +=" 00:00:00";
            sql += " AND py.create_time >='"+startDate+"' ";
        }
        if(StringUtils.isNotBlank(endDate)){
            endDate +=" 23:59:59";
            sql += " AND py.create_time <='"+endDate+"' ";
        }
        if(StringUtils.isNotBlank(operator)){
            sql += " AND p.drug_delivery_operator ='"+operator+"' ";
        }
        if(StringUtils.isNotBlank(flag)){
            sql += " AND p.drug_delivery_flag ="+flag+" ";
        }
        return sql;
    }
    public List<Map<String,Object>> getHospitalOperator(String doctor){
        Doctor d = doctorDao.findByCode(doctor);
        String sql = "SELECT " +
                " p.drug_delivery_operator AS operator, " +
                " p.drug_delivery_operator_name AS operatorName " +
                " FROM " +
                " wlyy_prescription p " +
                " WHERE " +
                " p.hospital = '"+d.getHospital()+"' " +
                " GROUP BY " +
                " p.drug_delivery_operator ";
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
        return rs;
    }
}

+ 79 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionExpressageController.java

@ -74,4 +74,83 @@ public class PrescriptionExpressageController extends WeixinBaseController {
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/getDrugDeliveryState", method = RequestMethod.GET)
    @ApiOperation(value = "获取异常原因列表")
    public String getDrugDeliveryState(){
        try {
            return write(200, "获取成功", "data", expressageService.getDrugDeliveryState());
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/getEsListByIDCardOrSSC", method = RequestMethod.GET)
    @ApiOperation(value = "根据医保号和身份证查询订单")
    public String getEsListByIDCardOrSSC(@ApiParam(required = true, name = "keyWord", value = "医保号或身份证") @RequestParam(required = true)String keyWord,
                                         @ApiParam(required = true, name = "page", value = "起始页,重1开始") @RequestParam(required = true)Integer page,
                                         @ApiParam(required = true, name = "pageSize", value = "每页大小") @RequestParam(required = true)Integer pageSize){
        try {
            return write(200, "获取成功", "data", expressageService.getEsListByIDCardOrSSC( keyWord, page, pageSize));
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/saveDrugDelivery", method = RequestMethod.POST)
    @ApiOperation(value = "异常出操作")
    public String saveDrugDelivery(@ApiParam(required = true, name = "prescriptionCode", value = "续方code") @RequestParam(required = true)String prescriptionCode,
                                   @ApiParam(required = true, name = "reasonCode", value = "原因code") @RequestParam(required = true)String reasonCode,
                                   @ApiParam(required = true, name = "reasonName", value = "原因名称") @RequestParam(required = true)String reasonName,
                                   @ApiParam(required = true, name = "reason", value = "详细原因") @RequestParam(required = true)String reason){
        try {
            return write(200, "获取成功", "data", expressageService.saveDrugDelivery( getUID(), prescriptionCode, reasonCode, reasonName, reason));
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/getPresStatesList", method = RequestMethod.GET)
    @ApiOperation(value = "获取续方状态原因列表")
    public String getPresStatesList(){
        try {
            return write(200, "获取成功", "data", expressageService.getPresStatesList());
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/getPresEsPayList", method = RequestMethod.GET)
    @ApiOperation(value = "获取订单列表")
    public String getPresEsPayList(@ApiParam(required = true, name = "keyWord", value = "订单号,接收人,医保号或身份证") @RequestParam(required = false)String keyWord,
                                   @ApiParam(required = true, name = "state", value = "续方状态") @RequestParam(required = false)String state,
                                   @ApiParam(required = true, name = "type", value = "1 自取 2快递配送 3健管师配送") @RequestParam(required = false)String type,
                                   @ApiParam(required = true, name = "startDate", value = "开始时间yyyy-MM--dd") @RequestParam(required = false)String startDate,
                                   @ApiParam(required = true, name = "endDate", value = "结束时间yyyy-MM-dd") @RequestParam(required = false)String endDate,
                                   @ApiParam(required = true, name = "operator", value = "操作人") @RequestParam(required = false)String operator,
                                   @ApiParam(required = true, name = "flag", value = "1.扫描2.异常出药") @RequestParam(required = false)String flag,
                                   @ApiParam(required = true, name = "page", value = "页面") @RequestParam(required = false)Integer page,
                                   @ApiParam(required = true, name = "pageSize", value = "页面大小") @RequestParam(required = false)Integer pageSize){
        try {
            return write(200, "获取成功", "data", expressageService.getPresEsPayList(keyWord,state,type,startDate,endDate,operator,flag,page,pageSize));
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/getHospitalOperator", method = RequestMethod.GET)
    @ApiOperation(value = "获取操作人员下拉列表")
    public String getHospitalOperator(){
        try {
            return write(200, "获取成功", "data", expressageService.getHospitalOperator(getUID()));
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败");
        }
    }
}

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

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.adapter.PresModeAdapter;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
@ -13,6 +14,7 @@ import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
import com.yihu.wlyy.service.app.prescription.PrescriptionPayService;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.service.third.jw.ZyDictService;
import com.yihu.wlyy.web.BaseController;
@ -48,6 +50,8 @@ public class PrescriptionInfoController extends BaseController {
    private ZyDictService zyDictService;
    @Autowired
    private AdminTeamService adminTeamService;
    @Autowired
    private PatientService patientService;
    @RequestMapping(value = "getRecipeMasterList" , method = RequestMethod.GET)
    @ResponseBody
@ -264,6 +268,11 @@ public class PrescriptionInfoController extends BaseController {
                jo.put("dispensaryDispensaryTypeName", prescription.getDispensaryTypeName());//处方配送方式
                jo.put("prescriptionStatus", prescription.getStatus());//处方状态
                jo.put("prescriptionStatusName", prescription.getStatusName(prescription.getStatus(), "",""));//处方状态名称
                Patient p =  patientService.findByCode(prescription.getPatient());
                jo.put("patient",p.getCode());
                jo.put("patientName",p.getName());
                jo.put("IdCard",p.getIdcard());
                jo.put("ssc",p.getSsc());
            }
            return write(200, "查询成功", "data", jo);
        } catch (Exception e) {

+ 13 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionLogController.java

@ -1,9 +1,11 @@
package com.yihu.wlyy.web.doctor.prescription;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressageLog;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.service.app.prescription.PrescriptionExpressageLogService;
import com.yihu.wlyy.service.app.prescription.PrescriptionLogService;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
@ -32,6 +34,8 @@ public class PrescriptionLogController extends BaseController {
    private PrescriptionLogService prescriptionLogService;
    @Autowired
    private PrescriptionExpressageLogService prescriptionExpressageLogService;
    @Autowired
    private PrescriptionService prescriptionService;
    @RequestMapping(value = "/getPrescriptionLogs", method = RequestMethod.GET)
    @ApiOperation(value = "获取处方流程")
@ -125,6 +129,15 @@ public class PrescriptionLogController extends BaseController {
                    JSONObject jo = new JSONObject();
                    jo.put("createTime", DateUtil.dateToStrLong(one.getCreateTime()));
                    jo.put("statusName", one.getStatusName());
                    jo.put("drugDeliveryflag", "0");
                    if(one.getStatus()==100){
                        Prescription prescription = prescriptionService.findByCode(one.getPrescriptionCode());
                        if(prescription!=null&&prescription.getDrugDeliveryflag()==1){
                            jo.put("drugDeliveryflag", "1");
                            jo.put("drugDeliveryOperatorName",prescription.getDrugDeliveryOperatorName());
                            jo.put("drugDelivery",prescription.getDrugDeliveryReasonValue()+","+prescription.getDrugDeliveryReason());
                        }
                    }
                    ja.put(jo);
                }
                return write(200, "获取处方流程成功", "data", ja);