Browse Source

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

trick9191 7 years ago
parent
commit
28ba40f592

+ 21 - 2
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/common/util/CommonUtil.java

@ -65,7 +65,8 @@ public class CommonUtil {
    }
    /**
     * double*100转int
     * double转字符串,在转int
     * double*100转int 有bug 34.3会会变成3429
     * @param d
     * @return
     */
@ -73,7 +74,25 @@ public class CommonUtil {
        if(d==null){
            return 0;
        }
        return new Double(d*100).intValue();
        String currency = String.valueOf(d);
        int index = currency.indexOf(".");
        int length = currency.length();
        Integer amLong = 0;
        if(index == -1){
            amLong = Integer.valueOf(currency+"00");
        }else if(length - index >= 3){
            amLong = Integer.valueOf((currency.substring(0, index+3)).replace(".", ""));
            if(length-index>3){
                if(Integer.valueOf(currency.substring(index+3,index+4))>=5){
                    amLong++;
                }
            }
        }else if(length - index == 2){
            amLong = Integer.valueOf((currency.substring(0, index+2)).replace(".", "")+0);
        }else{
            amLong = Integer.valueOf((currency.substring(0, index+1)).replace(".", "")+"00");
        }
        return amLong;
    }
    /**

+ 21 - 15
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java

@ -25,10 +25,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * 长处方接口
@ -118,10 +115,10 @@ public class PrescriptionService extends ZysoftBaseService{
                    //调整续方的药品信息
                    JSONArray prescription_detail = pre.getJSONArray("PRESCRIPTION_DETAIL");
                    List<PrescriptionInfo> infoList = new ArrayList<>();
                    for(int i =0;i<prescription_detail.size();i++){
                        JSONObject info = prescription_detail.getJSONObject(i);
                        String infoCode = info.getString("SUB_NO");
                        PrescriptionInfo prescriptionInfo = prescriptionInfoDao.findByCode(infoCode);
                        PrescriptionInfo prescriptionInfo = new PrescriptionInfo();
                        prescriptionInfo.setRemark(info.getString("REMARK"));
                        prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));
                        prescriptionInfo.setDirection(info.getString("USAGE_NAME"));//药品用法
@ -130,9 +127,9 @@ public class PrescriptionService extends ZysoftBaseService{
                        prescriptionInfo.setDrugRate(info.getString("FREQUENCY"));//吃药频率 FREQUENCY
                        prescriptionInfo.setDrugRateName(info.getString("FREQUENCY_NAME"));
                        prescriptionInfo.setDrugFormat(info.getString("ITEM_SPEC"));//药品规格
                        prescriptionInfo.setPrice(info.getInteger("ITEM_PRICE"));//药品单价
                        prescriptionInfo.setPrice(CommonUtil.doubleToInt(info.getDouble("ITEM_PRICE")));//药品单价
                        prescriptionInfo.setNum(info.getInteger("ITEM_QUANTITY"));//药品数目
                        prescriptionInfo.setJwSubCode("");//智业子处方号
                        prescriptionInfo.setJwSubCode(info.getString("SUB_NO"));//智业子处方号
                        prescriptionInfo.setDrugNumUnit(info.getString("ITEM_UNIT"));//数量单位编码
                        prescriptionInfo.setDrugNumUnitName(info.getString("ITEM_UNIT_NAME"));//数量单位名称
                        prescriptionInfo.setCost(CommonUtil.doubleToInt(info.getDouble("COST")));//金额
@ -147,13 +144,20 @@ public class PrescriptionService extends ZysoftBaseService{
                        prescriptionInfo.setPhysicAmount(info.getString("PHYSIC_AMOUNT"));//用药总量
                        prescriptionInfo.setPhysicAmountUnit(info.getString("PHYSIC_AMOUNT_UNIT"));//总量单位编码
                        prescriptionInfo.setPhysicAmountUnitName(info.getString("PHYSIC_AMOUNT_UNIT_NAME"));//总量单位名称
                        prescriptionInfo.setPhysicInjectPlace("");//注射地点编码
                        prescriptionInfo.setPhysicInjectPlaceName("");//注射地点名称
                        prescriptionInfo.setPhysicInjectPlace(info.getString("PHYSIC_INJECT_PLACE"));//注射地点编码
                        prescriptionInfo.setPhysicInjectPlaceName(info.getString("PHYSIC_INJECT_PLACE_NAME"));//注射地点名称
                        prescriptionInfo.setPhysicSkinTest(info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
                        prescriptionInfo.setPhysicSkinTestName(info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
                        prescriptionInfoDao.save(prescriptionInfo);
                        prescriptionInfo.setPrescriptionCode(prescription.getCode());
                        infoList.add(prescriptionInfo);
                    }
                    //删除所有药品
                    StringBuffer sql = new StringBuffer("UPDATE wlyy_prescription_info SET del = 0 WHERE prescription_code = '" + prescription.getCode() + "'");
                    jdbcTemplate.execute(sql.toString());
                    //保存新的药品
                    prescriptionInfoDao.save(infoList);
                    // redis 的发布 {tilte:redisAddPrescription   state: 1 ,//1:成功,2.失败 mes:'开方成功' prescription : "0001" //续方CODE  }
                    JSONObject message = new JSONObject();
                    message.put("title","adjustPrescription");
@ -284,9 +288,9 @@ public class PrescriptionService extends ZysoftBaseService{
                message.put("prescription",prescription.getCode());
                message.put("mes","success");
//                redisTemplate.convertAndSend(channelTopic,message.toString());
                redisTemplate.watch(channelTopic);
//                redisTemplate.watch(channelTopic);
                redisTemplate.opsForList().leftPush(channelTopic,message.toString());
                redisTemplate.unwatch();
//                redisTemplate.unwatch();
            }
        }catch (JSONException ex){
@ -560,7 +564,8 @@ public class PrescriptionService extends ZysoftBaseService{
            json.put("DIAGNOSE_SUB_CODE",prescriptionDiagnosisList.get(1).getCode());//"DIAGNOSE_CODE": "次诊断编码",
        }
        if(prescription.getCaCertData()!=null){
            json.put("ORIGINAL_DATA",prescription.getStrOriginalData());//原文
//            json.put("ORIGINAL_DATA",prescription.getStrOriginalData());//原文
            json.put("ORIGINAL_DATA",null);
            json.put("ORIGINAL_DATA_MD5",prescription.getOriginalDataAbstract());//原文的MD5摘要
            json.put("CA_SIGN_DATA",prescription.getCaMessage());//签名值
            json.put("CA_CERTMAIN_DATA",prescription.getCaCertData());//签名证书主体数据
@ -787,7 +792,8 @@ public class PrescriptionService extends ZysoftBaseService{
        JSONObject json = new JSONObject();
        json.put("recipeNo",prescription.getRecipeNo());// "recipeNo": "医嘱号",
        if(prescription.getCaCertData()!=null){
            json.put("ORIGINAL_DATA",prescription.getStrOriginalData());//原文
//            json.put("ORIGINAL_DATA",prescription.getStrOriginalData());//原文
            json.put("ORIGINAL_DATA",null);
            json.put("ORIGINAL_DATA_MD5",prescription.getOriginalDataAbstract());//原文的MD5摘要
            json.put("CA_SIGN_DATA",prescription.getCaMessage());//签名值
            json.put("CA_CERTMAIN_DATA",prescription.getCaCertData());//签名证书主体数据

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/adapter/PresModeAdapter.java

@ -177,7 +177,7 @@ public class PresModeAdapter {
                            prescriptionInfo.setDrugRate(info.getString("FREQUENCY"));//吃药频率 FREQUENCY
                            prescriptionInfo.setDrugRateName(info.getString("FREQUENCY_NAME"));
                            prescriptionInfo.setDrugFormat(info.getString("ITEM_SPEC"));//药品规格
                            prescriptionInfo.setPrice(info.getInteger("ITEM_PRICE"));//药品单价
                            prescriptionInfo.setPrice(CommonUtil.doubleToInt(info.getDouble("ITEM_PRICE")));//药品单价
                            prescriptionInfo.setNum(info.getInteger("ITEM_QUANTITY"));//药品数目
                            prescriptionInfo.setJwSubCode(info.getString("RECIPE_SUB_NO"));//智业子处方号
                            prescriptionInfo.setDrugNumUnit(info.getString("ITEM_UNIT"));//数量单位编码
@ -278,7 +278,7 @@ public class PresModeAdapter {
                    prescriptionInfo.put("drugRate",info.getString("FREQUENCY"));//吃药频率 FREQUENCY
                    prescriptionInfo.put("drugRateName",info.getString("FREQUENCY_NAME"));
                    prescriptionInfo.put("drugFormat",info.getString("ITEM_SPEC"));//药品规格
                    prescriptionInfo.put("price",info.getInteger("ITEM_PRICE"));//药品单价
                    prescriptionInfo.put("price",info.getDouble("ITEM_PRICE"));//药品单价
                    prescriptionInfo.put("num",info.getInteger("ITEM_QUANTITY"));//药品数目
                    prescriptionInfo.put("jwSubCode",info.getString("RECIPE_SUB_NO"));//智业子处方号
                    prescriptionInfo.put("drugNumUnit",info.getString("ITEM_UNIT"));//数量单位编码

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -1131,7 +1131,7 @@ public class ConsultTeamService extends ConsultService {
            prescriptionInfo.setDrugName(info.getString("drugName"));//药品名称
            prescriptionInfo.setDrugRate(info.getString("drugRate"));//吃药频率
            prescriptionInfo.setDrugFormat(info.getString("drugFormat"));//药品规格
            prescriptionInfo.setNum(CommonUtil.doubleToInt(info.getDouble("num")));//药品数目
            prescriptionInfo.setNum(info.getInteger("num"));//药品数目
            prescriptionInfo.setPrice(CommonUtil.doubleToInt(info.getDouble("price")));//药品单价
            prescriptionInfo.setIsRefrigerate(0);//是否冷藏 1是 0否
            prescriptionInfo.setJwSubCode(info.getString("jwSubCode"));//智业子处方号

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

@ -4,11 +4,19 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionReviewed;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionReviewedDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ImUtill;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
/**
 * 线下调整处方
@ -23,16 +31,28 @@ public class PrescriptionAdjustService extends BaseService {
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PrescriptionLogService prescriptionLogService;
    @Autowired
    private PrescriptionService prescriptionService;
    @Autowired
    private MessageDao messageDao;
    @Autowired
    private PrescriptionReviewedDao prescriptionReviewedDao;
    @Autowired
    private PrescriptionInfoService prescriptionInfoService;
    @Autowired
    private ImUtill imUtill;
    /**
     * 线下调整处方
     * @param code
     */
    public void adjustPrescription(String code){
    @Transactional
    public JSONObject adjustPrescription(String code){
        JSONObject re = new JSONObject();
        Prescription prescription = prescriptionDao.findByCode(code);
        if(prescription.getStatus()== PrescriptionLog.PrescriptionLogStatus.revieweding.getValue()){
        if(prescription.getStatus()== PrescriptionLog.PrescriptionLogStatus.revieweding.getValue()||
                prescription.getStatus()== PrescriptionLog.PrescriptionLogStatus.change_error.getValue()){
            //待审核状态才可以线下调整处方
            String response = jwPrescriptionService.saveRecipe(code,prescription.getJwGisterTypeCode(),prescription.getJwDeptCode());
            JSONObject json = JSONObject.parseObject(response);
            if(json.getInteger("status")==200){
@ -49,27 +69,107 @@ public class PrescriptionAdjustService extends BaseService {
                        prescription.setRecipeNo(recipeNo);
                        prescriptionDao.save(prescription);
                        //发送Im消息
                        JSONObject content = new JSONObject();
                        content.put("title", "我已经审核您" + DateUtil.dateToStr(prescription.getCreateTime(), "yyyy-MM-dd") + "发起的续方申请");
                        content.put("result", "审核通过");
                        content.put("reason", "");
                        content.put("url", "");
                        imUtill.sendTopicIM(prescription.getDoctor(), prescription.getDoctorName(), prescription.getConsult(), "15", content.toString(), null);
                        //添加日志
                        prescriptionLogService.addLog(prescription,PrescriptionLog.PrescriptionLogType.zy.getValue(),1,2);
                        re.put("status",200);
                    }else {
                        //请求失败
                        prescriptionLogService.addLog(prescription,PrescriptionLog.PrescriptionLogType.zy.getValue(),0,2);
                        JSONArray byRefParaData = data.getJSONArray("byRefParaData");
                        re.put("status",-1);
                        re.put("msg",byRefParaData.getJSONObject(0).getString("errorMsg"));
                    }
                }else {
                    //调整请求失败
                    prescriptionLogService.addLog(prescription,PrescriptionLog.PrescriptionLogType.zy.getValue(),0,2);
                    re.put("status",-1);
                    re.put("msg",data.getString("MESSAGE"));
                }
            }else{
                //请求报错
                prescriptionLogService.addLog(prescription,PrescriptionLog.PrescriptionLogType.zy.getValue(),0,2);
                re.put("status",-1);
                re.put("msg","请求调整失败");
            }
        }else {
            re.put("status",-1);
            re.put("msg","只有待审核和调整失败的续方可以转线下调整");
        }
        return  re;
    }
    /**
     * 上传ca认证信息
     * @param code
     */
    public JSONObject uploadCaDigital(String code){
        JSONObject re = new JSONObject();
        Prescription prescription = prescriptionDao.findByCode(code);
        if(prescription.getStatus()==PrescriptionLog.PrescriptionLogStatus.change_success.getValue()){
            String response = jwPrescriptionService.affirmCARecipe(code);
            JSONObject json = JSONObject.parseObject(response);
            if(json.getInteger("status")==200){
                JSONObject data = json.getJSONObject("data");
                String zyCode = data.getString("CODE");
                if("1".equals(zyCode)){
                    JSONArray returnData = data.getJSONArray("returnData");
                    if(returnData.size()>0){
                        JSONObject pre = returnData.getJSONArray(0).getJSONObject(0);
                        //认证成功-审核完成
                        prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.wait_pay.getValue());
                        //设置审核通过
                        PrescriptionReviewed reviewed = prescriptionReviewedDao.findByPrescriptionCode(code);
                        reviewed.setStatus(1);
                        reviewed.setReviewedTime(new Date());
                        prescriptionDao.save(prescription);
                        //审核通过模板消息
                        prescriptionInfoService.sendRMess(prescription.getCode(), 1);
        }
                        //修改系统的续方消息的审核状态
                        messageDao.updatePreScriptionMessage(prescription.getConsult(), "1", 6);
                        //获取智业待结算接口,更新药品金额
                        prescriptionService.getPerscriptionInfoCostFromPayInfo(prescription.getCode());
                        //添加日志
                        prescriptionLogService.addLog(prescription,PrescriptionLog.PrescriptionLogType.zy.getValue(),1,2);
                        re.put("status",200);
                    }else {
                        //请求失败
                        prescriptionLogService.addLog(prescription,PrescriptionLog.PrescriptionLogType.zy.getValue(),0,2);
                        JSONArray byRefParaData = data.getJSONArray("byRefParaData");
                        re.put("status",-1);
                        re.put("msg",byRefParaData.getJSONObject(0).getString("errorMsg"));
                    }
                }else {
                    //调整请求失败
                    prescriptionLogService.addLog(prescription,PrescriptionLog.PrescriptionLogType.zy.getValue(),0,2);
                    re.put("status",-1);
                    re.put("msg",data.getString("MESSAGE"));
                }
            }else{
                //请求报错
                prescriptionLogService.addLog(prescription,PrescriptionLog.PrescriptionLogType.zy.getValue(),0,2);
                re.put("status",-1);
                re.put("msg","请求调整失败");
            }
        }else {
            re.put("status",-1);
            re.put("msg","只有调整成功的续方才可上传ca认证信息");
        }
        return  re;
    }
}

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

@ -400,6 +400,15 @@ public class PrescriptionInfoService extends BaseService {
                //获取智业待结算接口,更新药品金额
                prescriptionService.getPerscriptionInfoCostFromPayInfo(p.getCode());
                //发送Im消息
                JSONObject content = new JSONObject();
                content.put("title", "我已经审核您" + DateUtil.dateToStr(p.getCreateTime(), "yyyy-MM-dd") + "发起的续方申请");
                content.put("result", "审核通过");
                content.put("reason", "");
                content.put("url", "");
                imUtill.sendTopicIM(p.getDoctor(), p.getDoctorName(), p.getConsult(), "15", content.toString(), null);
                return 1;
            } else {
                p.setStatus(PrescriptionLog.PrescriptionLogStatus.add_error.getValue());

+ 37 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionAdjustController.java

@ -1,13 +1,16 @@
package com.yihu.wlyy.web.doctor.prescription;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.service.app.prescription.PrescriptionAdjustService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
 * Created by yeshijie on 2017/8/17.
@ -24,8 +27,39 @@ public class PrescriptionAdjustController extends BaseController {
    @Autowired
    private PrescriptionAdjustService prescriptionAdjustService;
    @RequestMapping(value = "adjustPrescription",method = RequestMethod.POST)
    @ObserverRequired
    @ApiOperation("线下调整处方")
    public String adjustPrescription(@ApiParam(name = "code", value = "续方code", defaultValue = "10")
                                     @RequestParam(value = "code", required = true) String code){
        try{
            JSONObject json = prescriptionAdjustService.adjustPrescription(code);
            if(json.getInteger("status")==-1){
                return error(-1,json.getString("msg"));
            }
            return write(200,"请求调整成功");
        }catch (Exception e){
            error(e);
            return error(-1,"调整失败");
        }
    }
    @RequestMapping(value = "uploadCaDigital",method = RequestMethod.POST)
    @ObserverRequired
    @ApiOperation("上传基位ca认证信息")
    public String uploadCaDigital(@ApiParam(name = "code", value = "续方code", defaultValue = "10")
                                  @RequestParam(value = "code", required = true) String code){
        try{
            JSONObject json = prescriptionAdjustService.uploadCaDigital(code);
            if(json.getInteger("status")==-1){
                return error(-1,json.getString("msg"));
            }
            return write(200,"请求调整成功");
        }catch (Exception e){
            error(e);
            return error(-1,"调整失败");
        }
    }