瀏覽代碼

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

liuwenbin 7 年之前
父節點
當前提交
a14677f292

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

@ -0,0 +1,335 @@
package com.yihu.wlyy.entity.patient.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Administrator on 2017/7/21.
 * 处方
 */
@Entity
@Table(name = "wlyy_prescription")
public class Prescription extends IdEntity{
    private String code;                    //业务主键
    private String parentCode;             //如果是续方 那就是处方的code
    private Date createTime;               //处方创建时间
    private Date reviewedTime;             //过期时间
    private Date payTime;                   //支付时间
    private Date dosageTime;                //配药完成时间
    private Date dispatchingTime;          //配送员领药时间
    private Date finishTime;                //配送员确认送达或居民确认取药的时间
    private String patient;                  //关联 wlyy_patient code
    private String patientName;             //患者名称
    private Integer type;                    //1 处方 2 续方
    private Integer status;                  //状态 (1 审核不通过 , 0 审核中, 10 待支付 , 20 配药中, 21 等待领药 ,30 配送中 ,100已完成)
    private String doctor;                   //开处方的医生code 关联 wlyy_doctor
    private String doctorName;               //医生名称
    private Integer adminTeamId;             //患者签约的行政团队
    private String hospital;                  //医院 关联 dm_hospital code
    private String hospitalName;              //医院 关联 dm_hospital name
    private String dept;                       //科室code
    private String deptName;                   //科室名称
    private String diagnosisCode;             //诊断的病种code
    private String diagnosis;                  //诊断名称
    private Double ybCost;                     //医保费用
    private Double myCost;                     //自己付费
    private String consult;                    //咨询id 1对1
    private String remark;                     //处方备注
    private String dispensary_code;           //取药编码  关联wlyy_prescription_dispensary_code  code
    private String dispensaryAddress;         //取药地址
    private Integer dispensaryType;            //取药类型:1 自取 2快递配送 3健管师配送
    private String expressNum;                  //快递单号
    private String expressCompanyName;         //快递公司名称
    private String caMessage;                   //ca指纹信息
    @Column(name = "code", unique = true , nullable=false)
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "parent_code")
    public String getParentCode() {
        return parentCode;
    }
    public void setParentCode(String parentCode) {
        this.parentCode = parentCode;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "reviewed_time")
    public Date getReviewedTime() {
        return reviewedTime;
    }
    public void setReviewedTime(Date reviewedTime) {
        this.reviewedTime = reviewedTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "pay_time")
    public Date getPayTime() {
        return payTime;
    }
    public void setPayTime(Date payTime) {
        this.payTime = payTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "dosage_time")
    public Date getDosageTime() {
        return dosageTime;
    }
    public void setDosageTime(Date dosageTime) {
        this.dosageTime = dosageTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "dispatching_time")
    public Date getDispatchingTime() {
        return dispatchingTime;
    }
    public void setDispatchingTime(Date dispatchingTime) {
        this.dispatchingTime = dispatchingTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "finish_time")
    public Date getFinishTime() {
        return finishTime;
    }
    public void setFinishTime(Date finishTime) {
        this.finishTime = finishTime;
    }
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "patient_name")
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    @Column(name = "type")
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Column(name = "admin_team_id")
    public Integer getAdminTeamId() {
        return adminTeamId;
    }
    public void setAdminTeamId(Integer adminTeamId) {
        this.adminTeamId = adminTeamId;
    }
    @Column(name = "hospital")
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    @Column(name = "hospital_name")
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    @Column(name = "dept")
    public String getDept() {
        return dept;
    }
    public void setDept(String dept) {
        this.dept = dept;
    }
    @Column(name = "dept_name")
    public String getDeptName() {
        return deptName;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
    @Column(name = "diagnosis_code")
    public String getDiagnosisCode() {
        return diagnosisCode;
    }
    public void setDiagnosisCode(String diagnosisCode) {
        this.diagnosisCode = diagnosisCode;
    }
    @Column(name = "diagnosis")
    public String getDiagnosis() {
        return diagnosis;
    }
    public void setDiagnosis(String diagnosis) {
        this.diagnosis = diagnosis;
    }
    @Column(name = "yb_cost")
    public Double getYbCost() {
        return ybCost;
    }
    public void setYbCost(Double ybCost) {
        this.ybCost = ybCost;
    }
    @Column(name = "my_cost")
    public Double getMyCost() {
        return myCost;
    }
    public void setMyCost(Double myCost) {
        this.myCost = myCost;
    }
    @Column(name = "consult")
    public String getConsult() {
        return consult;
    }
    public void setConsult(String consult) {
        this.consult = consult;
    }
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Column(name = "dispensary_code")
    public String getDispensary_code() {
        return dispensary_code;
    }
    public void setDispensary_code(String dispensary_code) {
        this.dispensary_code = dispensary_code;
    }
    @Column(name = "dispensary_address")
    public String getDispensaryAddress() {
        return dispensaryAddress;
    }
    public void setDispensaryAddress(String dispensaryAddress) {
        this.dispensaryAddress = dispensaryAddress;
    }
    @Column(name = "dispensary_type")
    public Integer getDispensaryType() {
        return dispensaryType;
    }
    public void setDispensaryType(Integer dispensaryType) {
        this.dispensaryType = dispensaryType;
    }
    @Column(name = "express_num")
    public String getExpressNum() {
        return expressNum;
    }
    public void setExpressNum(String expressNum) {
        this.expressNum = expressNum;
    }
    @Column(name = "express_company_name")
    public String getExpressCompanyName() {
        return expressCompanyName;
    }
    public void setExpressCompanyName(String expressCompanyName) {
        this.expressCompanyName = expressCompanyName;
    }
    @Column(name = "ca_message")
    public String getCaMessage() {
        return caMessage;
    }
    public void setCaMessage(String caMessage) {
        this.caMessage = caMessage;
    }
}

+ 61 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionDispensaryCode.java

@ -0,0 +1,61 @@
package com.yihu.wlyy.entity.patient.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Administrator on 2017/7/21.
 * 处方取码
 */
@Entity
@Table(name = "wlyy_prescription_dispensary_code")
public class PrescriptionDispensaryCode extends IdEntity{
    private String code;                    //年月日8位数字+6位随机数字
    private String prescriptionCode;      //处方code  关联表wlyy_prescription code
    private Date createTime;               //创建时间
    private Date outTime;                  //过期时间
    @Column(name = "code", unique = true , nullable=false)
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "prescription_code")
    public String getPrescriptionCode() {
        return prescriptionCode;
    }
    public void setPrescriptionCode(String prescriptionCode) {
        this.prescriptionCode = prescriptionCode;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "out_time")
    public Date getOutTime() {
        return outTime;
    }
    public void setOutTime(Date outTime) {
        this.outTime = outTime;
    }
}

+ 59 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionInfo.java

@ -0,0 +1,59 @@
package com.yihu.wlyy.entity.patient.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Administrator on 2017/7/21.
 * 处方详细
 */
@Entity
@Table(name = "wlyy_prescription_info")
public class PrescriptionInfo extends IdEntity{
    private String code;                    //业务主键
    private String prescriptionCode;      //处方code 关联表wlyy_prescription code
    private String drugCode;               //药品code
    private String drugName;               //药品名称
    @Column(name = "code",unique = true , nullable=false)
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "prescription_code")
    public String getPrescriptionCode() {
        return prescriptionCode;
    }
    public void setPrescriptionCode(String prescriptionCode) {
        this.prescriptionCode = prescriptionCode;
    }
    @Column(name = "drug_code")
    public String getDrugCode() {
        return drugCode;
    }
    public void setDrugCode(String drugCode) {
        this.drugCode = drugCode;
    }
    @Column(name = "drug_name")
    public String getDrugName() {
        return drugName;
    }
    public void setDrugName(String drugName) {
        this.drugName = drugName;
    }
}

+ 110 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionLog.java

@ -0,0 +1,110 @@
package com.yihu.wlyy.entity.patient.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Administrator on 2017/7/21.
 * 处方日志
 */
@Entity
@Table(name = "wlyy_prescription_log")
public class PrescriptionLog extends IdEntity{
    private String code;                    //业务流程
    private String prescriptionCode;      //处方code 关联表wlyy_prescription code
    private Date createTime;               //处方创建时间
    private Integer type;                    //-1与智业对接的日志   11 创建处方  12 审核成功 13 审核失败 20等待付款 21 付款成功 22付款失败  30等待配药 31配药成功 40开始配送 41配送员已领药 42配送员送达  100处方完成
    private String userCode;                  //医生或者患者code
    private String userName;                  //医生或者患者name
    private Integer userType;                 //1 患者 2医生
    private Integer flag;                      //操作是否成功 1成功 0失败
    private String remark;                     //备注信息
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "prescription_code")
    public String getPrescriptionCode() {
        return prescriptionCode;
    }
    public void setPrescriptionCode(String prescriptionCode) {
        this.prescriptionCode = prescriptionCode;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "type")
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Column(name = "user_code")
    public String getUserCode() {
        return userCode;
    }
    public void setUserCode(String userCode) {
        this.userCode = userCode;
    }
    @Column(name = "user_name")
    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    @Column(name = "user_type")
    public Integer getUserType() {
        return userType;
    }
    public void setUserType(Integer userType) {
        this.userType = userType;
    }
    @Column(name = "flag")
    public Integer getFlag() {
        return flag;
    }
    public void setFlag(Integer flag) {
        this.flag = flag;
    }
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
}

+ 17 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionDispensaryCodeDao.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionDispensaryCode;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Administrator on 2017/7/21.
 * 处方取码
 */
public interface PrescriptionDispensaryCodeDao extends PagingAndSortingRepository<PrescriptionDispensaryCode, Long>, JpaSpecificationExecutor<PrescriptionDispensaryCode> {
//    @Query("select  count(1) from wlyy_prescription_dispensary_code p1 \n" +
//            "LEFT JOIN wlyy_prescription p2 on p1.prescription_Code = p2.code where p2.status in(21,20,100) and p2.patient =?1 ")
//    int dispensaryCodeCount(String patientCode);
}

+ 72 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionDispensaryCodeService.java

@ -0,0 +1,72 @@
package com.yihu.wlyy.service.app.prescription;
import com.yihu.wlyy.repository.prescription.PrescriptionDispensaryCodeDao;
import com.yihu.wlyy.service.BaseService;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Created by Administrator on 2017/7/21.
 *长处方取码
 */
@Service
//@Transactional(rollbackFor = Exception.class)
public class PrescriptionDispensaryCodeService extends BaseService {
//    @Autowired
//    private PrescriptionDispensaryCodeDao prescriptionDispensaryCodeDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public  JSONArray findByStatusAndTime(Integer timeType, String patientCode, Integer status, Integer page, Integer pagesize) {
        // 排序
        //Sort sort = new Sort(Sort.Direction.DESC, "status","createTime");
        // 分页信息
        long timeLimit = 0;
        if(timeType!=null){
            switch (timeType){
                case 1:timeLimit = 7*24*60*60;break;//近一周
                case 2:timeLimit = 7*24*60*60*31;break;//近一月
                case 3:timeLimit = 7*24*60*60*31*6;break;//近半年
                case 4:timeLimit = 7*24*60*60*31*12;break;//近一年
            }
        }
        //PageRequest pageRequest = new PageRequest(page, pagesize, sort);
        List<Object> params = new ArrayList<>();
        String sql = "select * from  wlyy_prescription_dispensary_code a LEFT JOIN wlyy_prescription b on a.prescription_Code=b.code where 1=1 " ;
        if(status!=null){
            sql += " and b.status = ? ";
            params.add(status);
        }else {
            sql += " and b.status in (20,21,100)" ;
        }
        if(timeType!=null){
            sql +=  "and TIMESTAMPDIFF(SECOND, a.create_Time, CURRENT_TIME) > ? ORDER BY b.status desc ,a.create_Time desc ";
            params.add(timeLimit);
        }
        sql += " limit "+(page-1)*pagesize+","+pagesize;
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql,params.toArray());
        JSONArray array = new JSONArray(result);
        return array;
        //return prescriptionDispensaryCodeDao.findByStatusAndTime(timeLimit,patientCode,status,pageRequest);
    }
    public int dispensaryCodeCount(String patientCode){
        String sql = "select  count(1) from wlyy_prescription_dispensary_code p1 \n" +
                " LEFT JOIN wlyy_prescription p2 on p1.prescription_Code = p2.code where p2.status in(21,20,100) and p2.patient =?";// where p2.status in(21,20,100)  and p2.patient =?1
        int count = jdbcTemplate.queryForObject(sql,Integer.class,patientCode);
        return  count;
    }
}

+ 118 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionController.java

@ -0,0 +1,118 @@
package com.yihu.wlyy.web.patient.prescription;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.service.app.medicines.MedicalRecordsService;
import com.yihu.wlyy.service.app.prescription.PrescriptionDispensaryCodeService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
/**
 * Created by Administrator on 2017/7/21.
 *
 */
@Controller
@RequestMapping(value = "/patient/prescription", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "患者端-长处方接口")
public class PatientPrescriptionController extends BaseController {
    @Autowired
    private PrescriptionDispensaryCodeService prescriptionDispensaryCodeService;
    /**
     *居民取药码
     * @return
     */
    @RequestMapping(value = "/dispensaryCode/getResidentQRCode",method = RequestMethod.GET)
    @ResponseBody
    //@ObserverRequired
    public String getResidentQRCode(){
        Calendar cal = Calendar.getInstance();
        String year = String.valueOf(cal.get(Calendar.YEAR));
        int temp = cal.get(Calendar.MONTH)+1;
        String month = cal.get(Calendar.MONTH)+1<10?"0"+temp:""+temp;
        String day = ""+cal.get(Calendar.DAY_OF_MONTH);
        String ymd = year+month+day;
        int temp2 = (int)((Math.random()*9+1)*100000);
        String code = ymd +temp2;
        return ymd;
    }
    /**
     *配送员取药码
     * @return
     */
    @RequestMapping(value = "/dispensaryCode/getDiliveryQRCode",method = RequestMethod.GET)
    @ResponseBody
    //@ObserverRequired
    public String getDiliveryQRCode(){
        Calendar cal = Calendar.getInstance();
        String year = String.valueOf(cal.get(Calendar.YEAR));
        int temp = cal.get(Calendar.MONTH)+1;
        String month = cal.get(Calendar.MONTH)+1<10?"0"+temp:""+temp;
        String day = ""+cal.get(Calendar.DAY_OF_MONTH);
        String ymd = year+month+day;
        int temp2 = (int)((Math.random()*9+1)*100000);
        String code = ymd +temp2;
        return ymd;
    }
    /**
     * 显示居民所有的取药码列表
     * @param status
     * @param timeType
     * @param page
     * @param pagesize
     * @return
     */
    @RequestMapping(value = "/dispensaryCode/list",method = RequestMethod.GET)
    @ResponseBody
    //@ObserverRequired
    public String list(
            //@RequestParam(value = "patientCode",required = true) String patientCode,
            @RequestParam(value = "status",required = false) Integer status,
            @RequestParam(value = "timeType",required = false) Integer timeType,
            @RequestParam(value = "page",required = true) Integer page,
            @RequestParam(value = "pagesize",required = true) Integer pagesize) {
        //getRepUID()
        JSONArray result = prescriptionDispensaryCodeService.findByStatusAndTime(timeType,"915cc456-5b1d-11e6-8344-fa163e8aee56",status,page,pagesize);
        System.out.println(result.toString());
        return result.toString();
    }
    /**
     * 判断该居民是否有待取的药的接口
     * @return
     */
    @RequestMapping(value = "/dispensaryCode/whetherHaveCode",method = RequestMethod.GET)
    @ResponseBody
    //@ObserverRequired
    public String whetherHaveCode(){
        JSONObject json = new JSONObject();
        String patientCode=getRepUID();
        int count = prescriptionDispensaryCodeService.dispensaryCodeCount(patientCode);
        if(count>0){
            json.put("data",true);
            return json.toString();
        }
        json.put("data",false);
        return json.toString();
    }
}