Forráskód Böngészése

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

chenweida 7 éve
szülő
commit
4c31b25e3f

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

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.prescription;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by chenweida on 2017/7/27.
 */
public interface PrescriptionDao extends PagingAndSortingRepository<Prescription, Long>, JpaSpecificationExecutor<Prescription> {
    @Query("from Prescription p where p.code=?1")
    Prescription findByCode(String prescriptionCode);
}

+ 15 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionExpressageDao.java

@ -0,0 +1,15 @@
package com.yihu.wlyy.repository.prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionPay;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/7/27.
 */
public interface PrescriptionExpressageDao extends PagingAndSortingRepository<PrescriptionExpressage, Long>, JpaSpecificationExecutor<PrescriptionExpressage> {
    @Query("from PrescriptionExpressage p where p.prescriptionCode=?1")
    PrescriptionExpressage findByPrescriptionPay(String prescriptionCode);
}

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

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by chenweida on 2017/7/27.
 */
public interface PrescriptionInfoDao extends PagingAndSortingRepository<PrescriptionInfo, Long>, JpaSpecificationExecutor<PrescriptionInfo> {
    @Query("from PrescriptionInfo p where p.prescriptionCode=?1")
    List<PrescriptionInfo> findByPrescriptionCode(String prescriptionCode);
}

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

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionPay;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by chenweida on 2017/7/27.
 */
public interface PrescriptionPayDao extends PagingAndSortingRepository<PrescriptionPay, Long>, JpaSpecificationExecutor<PrescriptionPay> {
    @Query("from PrescriptionPay p where p.prescriptionCode=?1 ")
    PrescriptionPay findByPrescriptionPay(String prescriptionCode);
}

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

@ -0,0 +1,26 @@
package com.yihu.wlyy.service.app.prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionPay;
import com.yihu.wlyy.repository.prescription.PrescriptionExpressageDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * Created by chenweida on 2017/7/27.
 * 订单相关
 */
@Service
public class PrescriptionExpressageService {
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    /**
     *  获取处方配送信息信息
     * @param prescriptionCode 处方code
     * @return
     */
    public PrescriptionExpressage findByPrescriptionCode(String prescriptionCode) {
        return prescriptionExpressageDao.findByPrescriptionPay(prescriptionCode);
    }
}

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

@ -1,14 +1,29 @@
package com.yihu.wlyy.service.app.prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
 * Created by Trick on 2017/7/25.
 */
@Service
@Transactional
public class PrescriptionInfoService extends BaseService {
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    /**
     * 获取处方下的详细药品
     * @param prescriptionCode
     * @return
     */
    public List<PrescriptionInfo> getPrescriptionInfo(String prescriptionCode) {
        return prescriptionInfoDao.findByPrescriptionCode(prescriptionCode);
    }
}

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

@ -0,0 +1,29 @@
package com.yihu.wlyy.service.app.prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionPay;
import com.yihu.wlyy.repository.prescription.PrescriptionLogDao;
import com.yihu.wlyy.repository.prescription.PrescriptionPayDao;
import com.yihu.wlyy.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * Created by chenweida on 2017/7/27.
 * 处方支付相关
 */
@Service
public class PrescriptionPayService extends BaseService {
    @Autowired
    private PrescriptionPayDao prescriptionPayDao;
    /**
     *  获取处方支付信息
     * @param prescriptionCode 处方code
     * @return
     */
    public PrescriptionPay findByPrescriptionCode(String prescriptionCode) {
        return prescriptionPayDao.findByPrescriptionPay(prescriptionCode);
    }
}

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

@ -1,6 +1,9 @@
package com.yihu.wlyy.service.app.prescription;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionPay;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionLogDao;
import com.yihu.wlyy.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
@ -13,5 +16,15 @@ import java.util.List;
 */
@Service
public class PrescriptionService extends BaseService {
    @Autowired
    private PrescriptionDao prescriptionDao;
    /**
     *  获取处方信息
     * @param prescriptionCode 处方code
     * @return
     */
    public Prescription findByCode(String prescriptionCode) {
        return prescriptionDao.findByCode(prescriptionCode);
    }
}

+ 79 - 33
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionController.java

@ -1,10 +1,13 @@
package com.yihu.wlyy.web.patient.prescription;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.patient.prescription.*;
import com.yihu.wlyy.service.app.medicines.MedicalRecordsService;
import com.yihu.wlyy.service.app.prescription.PrescriptionDispensaryCodeService;
import com.yihu.wlyy.service.app.prescription.*;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -20,7 +23,6 @@ import java.util.Random;
/**
 * Created by Administrator on 2017/7/21.
 *
 */
@RestController("patientPrescriptionLogController")
@ -30,50 +32,61 @@ public class PatientPrescriptionController extends BaseController {
    @Autowired
    private PrescriptionDispensaryCodeService prescriptionDispensaryCodeService;
    @Autowired
    private PrescriptionService prescriptionService;
    @Autowired
    private PrescriptionInfoService prescriptionInfoService;
    @Autowired
    private PrescriptionPayService prescriptionPayService;
    @Autowired
    private PrescriptionExpressageService prescriptionExpressageService;
    /**
     *居民取药码
     * 居民取药码
     *
     * @return
     */
    @RequestMapping(value = "/dispensaryCode/getResidentQRCode",method = RequestMethod.GET)
    @RequestMapping(value = "/dispensaryCode/getResidentQRCode", method = RequestMethod.GET)
    @ResponseBody
    //@ObserverRequired
    public String getResidentQRCode(){
    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;
        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)
    @RequestMapping(value = "/dispensaryCode/getDiliveryQRCode", method = RequestMethod.GET)
    @ResponseBody
    //@ObserverRequired
    public String getDiliveryQRCode(){
    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 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 randomNum = randomString("0123456789",6);
        String code = ymd +randomNum;
        String randomNum = randomString("0123456789", 6);
        String code = ymd + randomNum;
        return ymd;
    }
    public  String randomString(String base, int length) {
    public String randomString(String base, int length) {
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
@ -85,43 +98,76 @@ public class PatientPrescriptionController extends BaseController {
    /**
     * 显示居民所有的取药码列表
     *
     * @param status
     * @param timeType
     * @param page
     * @param pagesize
     * @return
     */
    @RequestMapping(value = "/dispensaryCode/list",method = RequestMethod.GET)
    @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) {
            @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);
        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)
    @RequestMapping(value = "/dispensaryCode/whetherHaveCode", method = RequestMethod.GET)
    @ResponseBody
    //@ObserverRequired
    public String whetherHaveCode(){
    public String whetherHaveCode() {
        JSONObject json = new JSONObject();
        String patientCode=getRepUID();
        String patientCode = getRepUID();
        int count = prescriptionDispensaryCodeService.dispensaryCodeCount(patientCode);
        if(count>0){
            json.put("data",true);
        if (count > 0) {
            json.put("data", true);
            return json.toString();
        }
        json.put("data",false);
        json.put("data", false);
        return json.toString();
    }
    /**
     * 订单跟踪 包含处方药品信息 订单记录  支付记录
     * 根据处方code获取处方流程
     *
     * @param prescriptionCode
     * @return
     */
    @RequestMapping(value = "/prescriptionFollow", method = RequestMethod.GET)
    @ApiOperation(value = "获取处方订单详情")
    public String addReply(
            @RequestParam(required = true) @ApiParam(value = "处方code", name = "prescriptionCode") String prescriptionCode) {
        try {
            JSONObject jo = new JSONObject();
            //获取处方信息
            Prescription prescription = prescriptionService.findByCode(prescriptionCode);
            //获取处方药品信息
            List<PrescriptionInfo> prescriptionInfos = prescriptionInfoService.getPrescriptionInfo(prescriptionCode);
            //获取付款信息
            PrescriptionPay prescriptionPay = prescriptionPayService.findByPrescriptionCode(prescriptionCode);
            //获取配送信息
            PrescriptionExpressage prescriptionExpressage = prescriptionExpressageService.findByPrescriptionCode(prescriptionCode);
            jo.put("prescriptionInfos", prescriptionInfos);
            jo.put("prescriptionPay", prescriptionPay);
            jo.put("prescriptionExpressage", prescriptionExpressage);
            jo.put("prescriptionStatus", prescription.getStatus());
            return write(200,"查询成功","data",jo);
        } catch (Exception e) {
            return error(-1, "获取失败");
        }
    }
}