trick9191 пре 7 година
родитељ
комит
388c31e20e

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

@ -1,19 +1,27 @@
package com.yihu.wlyy.service.app.prescription;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.repository.prescription.PrescriptionLogDao;
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.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * Created by Trick on 2017/7/25.
@ -25,6 +33,16 @@ public class PrescriptionInfoService extends BaseService {
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private SystemDictDao systemDictDao;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private PrescriptionLogDao prescriptionLogDao;
    /**
     * 获取处方下的详细药品
     * @param prescriptionCode
@ -48,4 +66,104 @@ public class PrescriptionInfoService extends BaseService {
        return rs;
    }
    /**
     * 1:查询处方;2我的续方;3:续方记录
     * @param type
     * @return
     */
    public JSONArray getPrescriptionInfos(String type,String state,String startDate,String endDate,String diagnosisCode,String patient){
        if(StringUtils.isNotBlank(type)){
            if("1".equals(type)){
                //基卫接口
            }else{
                StringBuffer sqlBuffer = new StringBuffer("SELECT p.code,p.create_time AS date,p.status,p.hospital_name As hospital FROM wlyy_prescription p " +
                        "WHERE p.status =? AND p.create_time >=? AND p.create_time <=? AND p.patient=?");
                //本地库
                List<Map<String,Object>> rs =jdbcTemplate.queryForList(sqlBuffer.toString(),
                        new Object[]{state,startDate+" 00:00:00",endDate+" 23:59:59",patient});
                return new JSONArray(rs);
            }
        }
        return new JSONArray();
    }
    /**
     * 获取续方信息
     * @param code
     * @return
     */
    public JSONObject getContinuedPrescription(String code){
        Prescription prescription = prescriptionDao.findByCode(code);
        List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
        JSONObject rs = new JSONObject();
        rs.put("prescription",prescription);
        rs.put("prescriptionInfos",prescriptionInfos);
        if(prescription!=null&&StringUtils.isNotBlank(prescription.getDoctor())){
            rs.put("doctor",doctorDao.findByCode(prescription.getDoctor()));
        }else{
            rs.put("doctor","");
        }
        return rs;
    }
    /**
     * 获取处方详情
     * @param code
     * @return
     */
    public JSONObject getPrescription(String code){
        return null;
    }
    public JSONObject  getPrescriptionProcess(String code){
        Prescription prescription = prescriptionDao.findByCode(code);
        List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
        JSONObject rs = new JSONObject();
        rs.put("prescription",prescription);
        rs.put("prescriptionInfos",prescriptionInfos);
        if(prescription!=null&&StringUtils.isNotBlank(prescription.getPatient())){
            Patient p = patientDao.findByCode(prescription.getPatient());
            rs.put("patient",p);
        }else{
            rs.put("patient","");
        }
        return rs;
    }
    /**
     * 取消续方
     * @param code
     * @return
     */
    public int cancelPrescriotion(String code){
        Prescription p = prescriptionDao.findByCode(code);
        p.setStatus(-2);
        prescriptionDao.save(p);
        //患者操作日志
        PrescriptionLog log = new PrescriptionLog();
        log.setCode(getCode());
        log.setStatus(-2);
        log.setType(-1);
        log.setCreateTime(new Date());
        log.setPrescriptionCode(p.getCode());
        log.setUserCode(p.getPatient());
        log.setUserName(p.getPatientName());
        log.setHospitalName(p.getHospitalName());
        log.setHospital(p.getHospital());
        log.setUserType(1);
        log.setFlag(1);
        log.setRemark("患者取消");
        prescriptionLogDao.save(log);
        //同步智业接口
        upLoadPrescriotionState();
        return 1;
    }
    public void upLoadPrescriotionState(){
    }
}

+ 30 - 6
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionInfoController.java

@ -32,10 +32,13 @@ public class PatientPrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/getPrescriptionInfos")
    @ResponseBody
    @ApiOperation(value = "获取长处方信息列表")
    public String getPrescriptionInfos(@RequestParam(required = true)@ApiParam(name="type",value="1:查询处方;2我的续方;3:续方记录")String type){
    public String getPrescriptionInfos(@RequestParam(required = true)@ApiParam(name="type",value="1:查询处方;2我的续方;3:续方记录")String type,
                                       @RequestParam(required = true)@ApiParam(name="state",value="状态")String state,
                                       @RequestParam(required = true)@ApiParam(name="diagnosisCode",value="诊断结果")String diagnosisCode,
                                       @RequestParam(required = true)@ApiParam(name="startDate",value="开始时间")String startDate,
                                       @RequestParam(required = true)@ApiParam(name="endDate",value="结束时间")String endDate){
        try {
            return write(200, "查询成功!", "data", "");
            return write(200, "查询成功!", "data", prescriptionInfoService.getPrescriptionInfos(type,state,startDate,endDate,diagnosisCode,getRepUID()));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -48,7 +51,7 @@ public class PatientPrescriptionInfoController extends BaseController {
    public String getPrescription(@RequestParam(required = true)@ApiParam(name="code",value="处方CODE")String code){
        try {
            return write(200, "查询成功!", "data", "");
            return write(200, "查询成功!", "data", prescriptionInfoService.getPrescription(code));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -60,15 +63,36 @@ public class PatientPrescriptionInfoController extends BaseController {
    @ApiOperation(value = "获取续方详细信息")
    public String getContinuedPrescription(@RequestParam(required = true)@ApiParam(name="code",value="续方CODE")String code){
        try {
            return write(200, "查询成功!", "data", "");
            return write(200, "查询成功!", "data", prescriptionInfoService.getContinuedPrescription(code));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/getPrescriptionProcess")
    @ResponseBody
    @ApiOperation(value = "获取续方记录详细信息")
    public String getPrescriptionProcess(@RequestParam(required = true)@ApiParam(name="code",value="续方CODE")String code){
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.getPrescriptionProcess(code));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/cancelPrescriotion")
    @ResponseBody
    @ApiOperation(value = "取消续方")
    public String cancelPrescriotion(@RequestParam(required = true)@ApiParam(name="code",value="续方CODE")String code){
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.cancelPrescriotion(code));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
}