瀏覽代碼

第三医院版本开发

wangzhinan 1 年之前
父節點
當前提交
02d041dc5a

+ 197 - 112
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/DsyyPrescriptionService.java

@ -89,7 +89,7 @@ public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
    //请求内网服务
    public static String entranceUrl = "http://192.168.101.2:10024/dsyy/";
    private final static String updateUrl="http://127.0.0.1:10023/dsyy/updateBySql";
    private final static String updateUrl="http://192.168.101.2:10023/dsyy/updateBySql";
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
@ -1006,6 +1006,53 @@ public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
        return null;
    }
    /**
     * 处方签名
     * @param prescriptionId
     * @return
     * @throws Exception
     */
    public String SOF_SignDataWithExtraInfo(String prescriptionId) throws Exception {
        String url = entranceUrl +"SOF_SignDataWithExtraInfo";
        String result = "";
        Map<String,Object> params = new HashedMap();
        params.put("prescriptionId",prescriptionId);
        HttpResponse response = HttpUtils.doPost(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            result = rs.getString("obj");
        }
        return result;
    }
    /**
     * 病历签名
     * @param prescriptionId
     * @return
     * @throws Exception
     */
    public String SOF_SignDataWithExtraInfoEmr(String prescriptionId) throws Exception {
        String url = entranceUrl +"SOF_SignDataWithExtraInfoEmr";
        String result = "";
        Map<String,Object> params = new HashedMap();
        params.put("prescriptionId",prescriptionId);
        HttpResponse response = HttpUtils.doPost(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            result = rs.getString("obj");
        }
        return result;
    }
    /**
     * 查询ca用户信息
     * @param idcard
@ -1029,154 +1076,192 @@ public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
    }
    /**
     * 数据哈希计算接口
     *
     * @param contentJson
     * 电子病历保存
     * @param prescriptionId
     * @return
     * @throws Exception
     */
    public JSONObject computeDigestForAlg(String contentJson) throws Exception {
        String url = entranceUrl +"computeDigestForAlg";
        JSONObject object = new JSONObject();
    public String dzblSave(String prescriptionId) throws Exception {
        String url = entranceUrl +"dzblSave";
        String result = "";
        Map<String,Object> params = new HashedMap();
        params.put("content",contentJson);
        params.put("prescriptionId",prescriptionId);
        HttpResponse response = HttpUtils.doPost(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            object = rs.getJSONObject("message");
            if (StringUtils.isNoneBlank(rs.getString("obj"))){
                JSONObject jsonObject = JSONObject.parseObject(rs.getString("obj"));
                if (jsonObject.getString("RESULT_CODE").equalsIgnoreCase("true")){
                    logger.info("病历保存成功"+rs.toJSONString());
                }
            }
            result = rs.getString("obj");
        }
        return object;
        logger.info("病历保存日志=="+rs.toJSONString());
        return result;
    }
    /**
     * 数据签名接口
     * @param templateId 模板ID签名数据摘要数据类型
     * @param urId 签名流水ID
     * @param patientName 患者姓名
     * @param patientAge 患者年龄
     * @param patientSex 患者性别
     * @param patientCardType  证件类型
     * @param recipeTime 开具时间
     * @param hashValue Hash原文(从签名指纹接口结果中得到的)
     * @param hashType Hash算法(从签名指纹接口结果中得到的)
     * 查询病历文书
     *
     * @param patientId
     * @param eventNo
     * @return
     * @throws Exception
     */
    public JSONObject synRecipeInfo(String templateId,String urId,String patientName,String patientAge,
                                    String patientSex,String patientCardType,String recipeTime,
                                    String hashValue,String hashType,String openId,String patientCard) throws Exception {
        String url = entranceUrl +"synRecipeInfo";
        JSONObject object = new JSONObject();
    public JSONArray selectHistoryEmrFromEntrance(String patientId,String eventNo) throws Exception {
       JSONArray array =dsyyEntranceService.selectHistoryEmrFromEntrance(patientId,eventNo);
       JSONArray jsonArray = new JSONArray();
       for (int i=0;i<array.size();i++){
           JSONObject object = array.getJSONObject(i);
           String PATIENT = object.getString("PATIENT");
           String OPID = object.getString("OPID");
           String res = selectHistoryEmrRecord(PATIENT,OPID);
           if (StringUtils.isNoneBlank(res)){
               jsonArray.add(object);
           }
       }
        return jsonArray;
    }
    /**
     * 查询历次就诊门诊病历文书
     * @param patientId 病人id
     * @param eventNo 就诊次数
     * @return
     */
    public String selectHistoryEmrRecord(String patientId,String eventNo) throws Exception {
        String url = entranceUrl +"selectEmrInfoId";
        String object = "";
        Map<String,Object> params = new HashedMap();
        params.put("templateId",templateId);
        params.put("urId",urId);
        params.put("patientName",patientName);
        params.put("patientAge",patientAge);
        params.put("patientSex",patientSex);
        params.put("patientCardType",patientCardType);
        params.put("recipeTime",recipeTime);
        params.put("hashValue",hashValue);
        params.put("hashType",hashType);
        params.put("openId",openId);
        params.put("patientCard",patientCard);
        params.put("patientId",patientId);
        params.put("visitNo",eventNo);
        HttpResponse response = HttpUtils.doPost(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            object = rs.getJSONObject("message");
            object = rs.getString("obj");
        }
        return object;
    }
    //=====================合理用药内网调用接口=======================
    /**
     * 处方签名
     * @param prescriptionDO
     * 合理用药审核
     *
     *
     * @param outpatient
     * @param prescriptionOnly
     * @param payType
     * @param doctor
     * @param patient
     * @param diagnosisDOS
     * @param infos
     * @return
     * @throws Exception
     */
    public String SOF_SignDataWithExtraInfo(WlyyPrescriptionDO prescriptionDO) throws Exception {
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId()).orElse(null);
        List<WlyyPrescriptionInfoDO> infoDOS = prescriptionInfoDao.findByPrescriptionId(prescriptionDO.getId(), 1);
        List<WlyyPrescriptionDiagnosisDO> diagnosisDOS = prescriptionDiagnosisDao.findByPrescriptionId(prescriptionDO.getId(),1);
        JSONObject object = new JSONObject();
        String baseSign="";
        object.put("infos",infoDOS);
        object.put("registerSn",outpatientDO.getRegisterNo());
        object.put("diagnosiss",diagnosisDOS);
        JSONObject jsonObject = computeDigestForAlg(object.toJSONString());
        String hashValue = null;
        String hashType = null;
        if (jsonObject.getString("status").equalsIgnoreCase("0")){
            JSONObject data = jsonObject.getJSONObject("data");
            hashValue= data.getString("hashValue");
            hashType = data.getString("hashType");
        }
        BasePatientDO patientDO = patientDao.findById(outpatientDO.getPatient()).orElse(null);
        BaseDoctorDO doctorDO = doctorDao.findByIdAndDel(outpatientDO.getDoctor());
        if (patientDO!=null&&doctorDO!=null){
            String patientName = patientDO.getName();
            Integer patientAge = IdCardUtil.getAgeForIdcard(patientDO.getIdcard());
            String patientSex = IdCardUtil.getSexForIdcard(patientDO.getIdcard());
            String recipeTime = DateUtil.dateToStrLong(prescriptionDO.getCreateTime());
            String openId = doctorDO.getOpenid();
            String idcard = patientDO.getIdcard();
            if (hashType!=null&&hashValue!=null){
                JSONObject object1 = synRecipeInfo("hash_004",getCode(),patientName,patientAge.toString(),patientSex,"SF",recipeTime,hashValue,hashType,openId,idcard);
                if (object1.getString("status").equalsIgnoreCase("0")){
                    logger.info("西药处方签名成功"+object1);
                    JSONObject jsonObject1 = JSONObject.parseObject(object1.getString("data"));
                    if (jsonObject1!=null){
                        baseSign=jsonObject1.getString("stamp");
                    }
                }
            }
    public String dsyyCheckInfo(String outpatient,String prescriptionOnly,String payType,String doctor,String patient,String diagnosisDOS, String infos) throws Exception {
        String url = entranceUrl +"dsyyCheckInfo";
        String jsonObject = "";
        Map<String,Object> params = new HashedMap();
        params.put("outpatient",outpatient);
        params.put("prescriptionOnly",prescriptionOnly);
        params.put("payType",payType);
        params.put("doctor",doctor);
        params.put("patient",patient);
        params.put("diagnosisDOS",diagnosisDOS);
        params.put("infos",infos);
        logger.info("params=="+params);
        HttpResponse response = HttpUtils.doPost(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        if(rs.getInteger("status")==200){
            jsonObject = rs.getString("message");
        }
        return baseSign;
        return jsonObject;
    }
    /**
     * 病历签名
     * @param prescriptionDO
     * 处方在医生站系统成功保存后调用
     *
     *
     * @param outpatient
     * @param prescriptionOnly
     * @param payType
     * @param doctor
     * @param patient
     * @param diagnosisDOS
     * @param infos
     * @return
     * @throws Exception
     */
    public void SOF_SignDataWithExtraInfoEmr(WlyyPrescriptionDO prescriptionDO) throws Exception {
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId()).orElse(null);
        WlyyPrescriptionEmrDO prescriptionEmrDO = prescriptionEmrDao.findEmrByPrescriptionId(prescriptionDO.getId());
        JSONObject object = new JSONObject();
        object.put("emr",prescriptionEmrDO);
        object.put("registerSn",outpatientDO.getRegisterNo());
        object.put("doctorName",outpatientDO.getDoctorName());
        object.put("patientName",outpatientDO.getPatientName());
        JSONObject jsonObject = computeDigestForAlg(object.toJSONString());
        String hashValue = null;
        String hashType = null;
        if (jsonObject.getString("status").equalsIgnoreCase("0")){
            JSONObject data = jsonObject.getJSONObject("data");
            hashValue= data.getString("hashValue");
            hashType = data.getString("hashType");
    public String dsyySaveCheckInfo(String outpatient,String prescriptionOnly,String payType,String doctor,String patient,String diagnosisDOS, String infos) throws Exception {
        String url = entranceUrl +"dsyySaveCheckInfo";
        String jsonObject = "";
        Map<String,Object> params = new HashedMap();
        params.put("outpatient",outpatient);
        params.put("prescriptionOnly",prescriptionOnly);
        params.put("payType",payType);
        params.put("doctor",doctor);
        params.put("patient",patient);
        params.put("diagnosisDOS",diagnosisDOS);
        params.put("infos",infos);
        logger.info("params=="+params);
        HttpResponse response = HttpUtils.doPost(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        if(rs.getInteger("status")==200){
            jsonObject = rs.getString("message");
        }
        return jsonObject;
    }
        BasePatientDO patientDO = patientDao.findById(outpatientDO.getPatient()).orElse(null);
        BaseDoctorDO doctorDO = doctorDao.findByIdAndDel(outpatientDO.getDoctor());
        if (patientDO!=null&&doctorDO!=null){
            String patientName = patientDO.getName();
            Integer patientAge = IdCardUtil.getAgeForIdcard(patientDO.getIdcard());
            String patientSex = IdCardUtil.getSexForIdcard(patientDO.getIdcard());
            String recipeTime = DateUtil.dateToStrLong(prescriptionDO.getCreateTime());
            String openId = doctorDO.getOpenid();
            String idcard = patientDO.getIdcard();
            if (hashType!=null&&hashValue!=null){
                JSONObject object1 = synRecipeInfo("hash_002",getCode(),patientName,patientAge.toString(),patientSex,"SF",recipeTime,hashValue,hashType,openId,idcard);
                if (object1.getString("status").equalsIgnoreCase("0")){
                    logger.info("门诊病历签名成功"+object1);
                }
            }
    /**
     * 处方保存成功后,发送给审方系统进行人工审方
     *
     *
     * @param outpatient
     * @param prescriptionOnly
     * @param payType
     * @param doctor
     * @param patient
     * @param diagnosisDOS
     * @param infos
     * @return
     * @throws Exception
     */
    public String dsyyValidCheckInfo(String outpatient,String prescriptionOnly,String payType,String doctor,String patient,String diagnosisDOS, String infos) throws Exception {
        String url = entranceUrl +"dsyyValidCheckInfo";
        String jsonObject = "";
        Map<String,Object> params = new HashedMap();
        params.put("outpatient",outpatient);
        params.put("prescriptionOnly",prescriptionOnly);
        params.put("payType",payType);
        params.put("doctor",doctor);
        params.put("patient",patient);
        params.put("diagnosisDOS",diagnosisDOS);
        params.put("infos",infos);
        logger.info("params=="+params);
        HttpResponse response = HttpUtils.doPost(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        if(rs.getInteger("status")==200){
            jsonObject = rs.getString("message");
        }
        return jsonObject;
    }
    //========================调用内网服务结束===================
@ -1903,8 +1988,8 @@ public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
                //结算更新
                System.out.println("sql=="+sql);
                String res = updateUrl(sql);
                logger.info("结算成功更新日志:"+res);
            }
            Map<String,Object> params = new HashedMap();
            String operatorId = "HLWYY";
            String operatorName = "互联网医院";
            String termNo = "DSYYHLWYY";

+ 13 - 17
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -346,6 +346,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    private ServiceItemPlanDao serviceItemPlanDao;
    @Autowired
    private WlyyBusinessService wlyyBusinessService;
    @Autowired
    private DsyyEntranceService dsyyEntranceService;
    public static String entranceUrl = "http://172.16.100.240:10023/xzzx/";
@ -10485,28 +10487,22 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                            throw new Exception(object.getString("msg"));
                        }
                    }
                    logger.info("进入处方签名");
                   /* try {
                        String baseSign=dsyyPrescriptionService.SOF_SignDataWithExtraInfo(wlyyPrescriptionDO);
                    logger.info("进入处方签名开始");
                    try {
                        String baseSign=dsyyPrescriptionService.SOF_SignDataWithExtraInfo(wlyyPrescriptionDO.getId());
                        logger.info("进入处方签名结束"+baseSign);
                    }catch (Exception e){
                        e.printStackTrace();
                    }*/
                /*    logger.info("进入处方签名");
                    }
                    //电子病例签名
                    String baseSign=hcyyEntranceService.initiateDataSign(wlyyPrescriptionDO.getId(),2,ip);
                    //同步电子病历
                    WlyyPrescriptionEmrDO prescriptionEmrDO = prescriptionEmrDao.findEmrByPrescriptionId(prescriptionId);
                    String baseSign=dsyyPrescriptionService.SOF_SignDataWithExtraInfoEmr(wlyyPrescriptionDO.getId());
                    try {
                        if (prescriptionEmrDO != null) {
                            logger.info("电子病历同步");
                            hcyyPrescriptionService.saveEmrToEntrance(prescriptionId,baseSign);
                            logger.info("电子病历同步");
                            logger.info("电子病历签名");
                            hcyyEntranceService.initiateDataSign(wlyyPrescriptionDO.getId(),1,ip);
                        }
                        logger.info("ca签名后病历保存开始“"+baseSign);
                        String res= dsyyPrescriptionService.dzblSave(wlyyPrescriptionDO.getId());
                        logger.info("ca签名后病历保存结束“"+res);
                    }catch (Exception e){
                        e.printStackTrace();
                    }*/
                    }
                    try {
                        if (object!=null){
                            if (object.getString("code").equalsIgnoreCase("0")){
@ -14681,7 +14677,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                }
            }
            if (ylzMedicalRelationDO != null && ylzMedicalRelationDO.getStatus() == 1) {
                com.alibaba.fastjson.JSONObject object2 = hcyyPrescriptionService.selectCardInfo(outpatientDO.getCardNo());
                com.alibaba.fastjson.JSONObject object2 = dsyyEntranceService.selectCardInfo(outpatientDO.getCardNo());
                Double cardFee = object2.getDouble("ZHYE");
                //医保已结算直接返回数据
                List<YlzMedicalMxDO> mxDOList = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());

文件差異過大導致無法顯示
+ 194 - 254
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/DsyyEntranceService.java


+ 196 - 2
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -28,6 +28,7 @@ import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.DsyyPrescriptionService;
import com.yihu.jw.hospital.prescription.service.PrescriptionLogService;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.hospital.prescription.service.entrance.DsyyEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
@ -156,7 +157,8 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
    private YlzMedicailRelationDao ylzMedicailRelationDao;
    @Autowired
    private DsyyPrescriptionService dsyyPrescriptionService;
    @Autowired
    private DsyyEntranceService dsyyEntranceService;
@ -1665,6 +1667,198 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        return businessOrderDO;
    }
    /**
     * 预交金处方支付
     * @param code
     * @param depositType
     * @param wechatId
     * @return
     * @throws Exception
     */
    public String ylzRechargePreDs(String code,String depositType,String wechatId,String cardType,String cardNo,boolean demoFlag) throws Exception {
        try {
            String response = null;
            WxWechatDO wxWechatDO = wechatDao.findById(wechatId).get();
            if(wxWechatDO==null){
                throw new Exception("can't find wechat:the wxId is "+wechatId);
            }
            WlyyHospitalSysDictDO hospitalSysDictDO =hospitalSysDictDao.findById("YLZ_NOTIFY_URL").get();
            WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(code).get();
            YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(code);
            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(ylzMedicalRelationDO.getId());
            BigDecimal b1 = new BigDecimal(ylzMedicalRelationDO.getBcwkje());//总金额
            BigDecimal b2 = new BigDecimal(ylzMedicalRelationDO.getPersonAccount());//个人账户
            BigDecimal b3 = new BigDecimal(ylzMedicalRelationDO.getMedicalPrice());//医保总金额
            Double fee = b1.subtract(b2).subtract(b3).doubleValue();
            if (businessOrderDO!=null){
                BasePatientDO patientDO = patientDao.findById(businessOrderDO.getPatient()).get();
                String idcard = "";
                if (patientDO!=null){
                    idcard = patientDO.getIdcard();
                }
                logger.info("开始1"+idcard);
                String openId = "";
                JSONObject object1 = dsyyEntranceService.selectCardInfo(cardNo);
                Double cardFee = object1.getDouble("ZHYE");
                BigDecimal b = new BigDecimal(String.valueOf(cardFee));
                BigDecimal c = new BigDecimal(String.valueOf(fee));
                if (b.compareTo(c) == 1){
                    return "无需线上支付";
                }
                BigDecimal balance = c.subtract(b);
                if (balance.doubleValue()<=0){
                    return "无需线上支付";
                }
                businessOrderDO.setPayPrice(balance.doubleValue());
                businessOrderDO.setPayType(4);
                businessOrderDO.setHistoryOrder(businessOrderDO.getOrderNo());
                businessOrderDO.setOrderNo("HLWYY"+System.currentTimeMillis()+(int)(Math.random()*900)+100);
                businessOrderDO.setDepositType(depositType);
                businessOrderDao.save(businessOrderDO);
                List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wechatId,wlyyOutpatientDO.getConsumer());
                if (patientWechatDos!=null&&patientWechatDos.size()!=0){
                    BasePatientWechatDo patientWechatDo = patientWechatDos.get(0);
                    openId = patientWechatDo.getOpenid();
                }else {
                    throw new Exception("请关注“海沧医院”公众号,点击互联网医院-在线诊室进行结算!");
                }
                String price = businessOrderDO.getPayPrice().toString();
                String notifyUrl = hospitalSysDictDO.getDictCode();
                String operatorId =null;
                String operatorName = null;
                if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                    operatorId = "123456";
                    operatorName =businessOrderDO.getPatientName();
                }else if(wechatId.equalsIgnoreCase("xm_xzzx_wx")){
                    operatorId = "hlwyy";
                    operatorName = "互联网医院";
                }else if(wechatId.equalsIgnoreCase("xm_hcyy_wx")){
                    operatorId = "hlwyy";
                    operatorName = "互联网医院";
                }
                response = ylzPayService.recharge(operatorId,operatorName,cardType,"01",cardNo,idcard,depositType,price,businessOrderDO.getOrderNo(),openId,patientDO.getName(),notifyUrl);
                if (depositType.equalsIgnoreCase("WX_QR")){
                    JSONObject object = JSONObject.parseObject(response);
                    if (object!=null){
                        JSONObject jsonObject = object.getJSONObject("param");
                        if (object.getString("respCode").equalsIgnoreCase("000000")){
                            InputStream qrcode = QrcodeUtil.createQrcode(jsonObject.getString("qrcode"),300,"jpg");
                            ByteToInputStream byteToInputStream = new ByteToInputStream();
                            String QRCodeImg = byteToInputStream.getBase64FromInputStream(qrcode);
                            jsonObject.put("qrcodeUrl","data:image/png;base64,"+ QRCodeImg);
                            String traceNo = jsonObject.getString("traceNo");
                            businessOrderDO.setTraceNo(traceNo);
                            businessOrderDao.save(businessOrderDO);
                        }
                        response = object.toJSONString();
                    }
                }else {
                    JSONObject object = JSONObject.parseObject(response);
                    if (object!=null){
                        JSONObject jsonObject = object.getJSONObject("param");
                        if (object.getString("respCode").equalsIgnoreCase("000000")){
                            String traceNo = jsonObject.getString("traceNo");
                            businessOrderDO.setTraceNo(traceNo);
                            businessOrderDao.save(businessOrderDO);
                        }
                    }
                }
            }else {
                businessOrderDO = new BusinessOrderDO();
                BasePatientDO patientDO = patientDao.findById(wlyyOutpatientDO.getPatient()).get();
                String idcard = "";
                if (patientDO!=null){
                    idcard = patientDO.getIdcard();
                }
                logger.info("开始2"+idcard);
                String openId = "";
                JSONObject object1 = dsyyEntranceService.selectCardInfo(cardNo);
                Double cardFee = object1.getDouble("ZHYE");
                BigDecimal b = new BigDecimal(String.valueOf(cardFee));
                BigDecimal c = new BigDecimal(String.valueOf(fee));
                if (b.compareTo(c) == 1){
                    return "无需线上支付";
                }
                BigDecimal balance = c.subtract(b);
                if (balance.doubleValue()<=0){
                    return "无需线上支付";
                }
                businessOrderDO.setPayPrice(balance.doubleValue());
                businessOrderDO.setPayType(4);
                businessOrderDO.setOrderNo("HLWYY"+System.currentTimeMillis()+(int)(Math.random()*900)+100);
                businessOrderDO.setDepositType(depositType);
                businessOrderDO.setRelationCode(ylzMedicalRelationDO.getId());
                businessOrderDO.setRelationName("费用结算");
                businessOrderDO.setPatientName(patientDO.getName());
                businessOrderDO.setPatient(patientDO.getId());
                businessOrderDO.setDoctor(wlyyOutpatientDO.getDoctor());
                businessOrderDO.setOrderCategory("6");
                businessOrderDO.setOrderType(6);
                businessOrderDO.setStatus(0);
                businessOrderDO.setDescription("费用结算");
                businessOrderDO.setCreateTime(new Date());
                businessOrderDO.setUpdateTime(new Date());
                businessOrderDao.save(businessOrderDO);
                List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wechatId,businessOrderDO.getPatient());
                if (patientWechatDos!=null&&patientWechatDos.size()!=0){
                    BasePatientWechatDo patientWechatDo = patientWechatDos.get(0);
                    openId = patientWechatDo.getOpenid();
                }
                String price = businessOrderDO.getPayPrice().toString();
                String notifyUrl = hospitalSysDictDO.getDictCode();
                String operatorId =null;
                String operatorName = null;
                if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                    operatorId = "123456";
                    operatorName =businessOrderDO.getPatientName();
                }else if(wechatId.equalsIgnoreCase("xm_xzzx_wx")){
                    operatorId = "hlwyy";
                    operatorName = "互联网医院";
                }else if(wechatId.equalsIgnoreCase("xm_hcyy_wx")){
                    operatorId = "hlwyy";
                    operatorName = "互联网医院";
                }
                response = ylzPayService.recharge(operatorId,operatorName,cardType,"01",cardNo,idcard,depositType,price,businessOrderDO.getOrderNo(),openId,patientDO.getName(),notifyUrl);
                if (depositType.equalsIgnoreCase("WX_QR")){
                    JSONObject object = JSONObject.parseObject(response);
                    if (object!=null){
                        JSONObject jsonObject = object.getJSONObject("param");
                        if (object.getString("respCode").equalsIgnoreCase("000000")){
                            InputStream qrcode = QrcodeUtil.createQrcode(jsonObject.getString("qrcode"),300,"jpg");
                            ByteToInputStream byteToInputStream = new ByteToInputStream();
                            String QRCodeImg = byteToInputStream.getBase64FromInputStream(qrcode);
                            jsonObject.put("qrcodeUrl","data:image/png;base64,"+ QRCodeImg);
                            String traceNo = jsonObject.getString("traceNo");
                            businessOrderDO.setTraceNo(traceNo);
                            businessOrderDao.save(businessOrderDO);
                        }
                        response = object.toJSONString();
                    }
                }else {
                    JSONObject object = JSONObject.parseObject(response);
                    if (object!=null){
                        JSONObject jsonObject = object.getJSONObject("param");
                        if (object.getString("respCode").equalsIgnoreCase("000000")){
                            String traceNo = jsonObject.getString("traceNo");
                            businessOrderDO.setTraceNo(traceNo);
                            businessOrderDao.save(businessOrderDO);
                        }
                    }
                }
            }
            return response;
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
    /**
     *无需支付
@ -1998,7 +2192,7 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        if(wxWechatDO==null){
            throw new Exception("can't find wechat:the wxId is "+wechatId);
        }
        WlyyHospitalSysDictDO hospitalSysDictDO =hospitalSysDictDao.findById("YLZ_NOTIFY_URL").orElse(null);
        WlyyHospitalSysDictDO hospitalSysDictDO =hospitalSysDictDao.findById("YLZ_NOTIFY_URL").get();
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(code).orElse(null);
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(code);
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(ylzMedicalRelationDO.getId());

+ 11 - 0
common/common-util/src/main/java/com/yihu/jw/util/http/HttpClientUtil.java

@ -425,6 +425,17 @@ public class HttpClientUtil {
        return ret;
    }
    public  String postBodyText(String url, String params) {
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("text/plain; charset=UTF-8");
        headers.setContentType(type);
        headers.add("Accept", MediaType.TEXT_PLAIN_VALUE.toString());
        org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params, headers);
        String ret = restTemplate.postForObject(url, formEntity, String.class);
        return ret;
    }
    public  static String postBodyStatic(String url, com.alibaba.fastjson.JSONObject params) {
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();

+ 135 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/DsyyController.java

@ -2,6 +2,7 @@ package com.yihu.jw.entrance.controller;
import com.alibaba.fastjson.JSONArray;
import com.yihu.jw.entity.hospital.prescription.WlyyInspectionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDiagnosisDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
import com.yihu.jw.hospital.prescription.service.entrance.DsyyEntranceService;
import com.yihu.jw.order.pay.ylz.YlzPayService;
@ -554,6 +555,16 @@ public class DsyyController extends EnvelopRestEndpoint {
        return success("请求成功",dsyyEntranceService.dzblSave(prescriptionId));
    }
    @PostMapping(value = "/selectEmrInfoId")
    @ApiOperation(value = "病历查询")
    public ObjEnvelop selectEmrInfoId(@ApiParam(name = "patientId", value = "患者id", required = false)
                               @RequestParam(value = "patientId",required = false)String patientId,
                                     @ApiParam(name = "visitNo", value = "就诊次数", required = false)
                                     @RequestParam(value = "visitNo",required = false)String visitNo) throws Exception {
        return success("请求成功",dsyyEntranceService.selectEmrInfoId(patientId,visitNo));
    }
    @PostMapping(value = "/SOF_SignDataWithExtraInfo")
    @ApiOperation(value = "处方签名")
    public ObjEnvelop SOF_SignDataWithExtraInfo(@ApiParam(name = "prescriptionId", value = "处方id", required = false)
@ -638,4 +649,128 @@ public class DsyyController extends EnvelopRestEndpoint {
    }
    /**
     * 合理用药审核
     * @param patient 病人id
     * @param doctor 医生id
     * @param diagnosisDOS 诊断json
     * @param infos  药品json
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/dsyyCheckInfo")
    @ApiOperation(value = "合理用药审核")
    public Envelop dsyyCheckInfo(
            @ApiParam(name = "outpatient", value = "就诊表id")
            @RequestParam(value = "outpatient", defaultValue = "") String outpatient,
            @ApiParam(name = "prescriptionOnly", value = "处方唯一标识")
            @RequestParam(value = "prescriptionOnly", defaultValue = "") String prescriptionOnly,
            @ApiParam(name = "payType", value = "付款方式0自费;1医保")
            @RequestParam(value = "payType", defaultValue = "") String payType,
            @ApiParam(name = "doctor", value = "医生id")
            @RequestParam(value = "doctor", defaultValue = "") String doctor,
            @ApiParam(name = "patient", value = "病人id")
            @RequestParam(value = "patient", defaultValue = "") String patient,
            @ApiParam(name = "diagnosisDOS", value = "诊断json")
            @RequestParam(value = "diagnosisDOS", defaultValue = "") String diagnosisDOS,
            @ApiParam(name = "infos", value = "药品json")
            @RequestParam(value = "infos", defaultValue = "") String infos) throws Exception {
        JSONArray druginfos = JSONArray.parseArray(infos);
        List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = new ArrayList<>();
        for (int i = 0; i < druginfos.size(); i++) {
            WlyyPrescriptionInfoDO wlyyPrescriptionInfo = toEntity(druginfos.get(i).toString(), WlyyPrescriptionInfoDO.class);
            wlyyPrescriptionInfoDOS.add(wlyyPrescriptionInfo);
        }
        JSONArray diagnosis = JSONArray.parseArray(diagnosisDOS);
        List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOS = new ArrayList<>();
        for (int i = 0; i < diagnosis.size(); i++) {
            WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO = toEntity(diagnosis.get(i).toString(), WlyyPrescriptionDiagnosisDO.class);
            wlyyPrescriptionDiagnosisDOS.add(wlyyPrescriptionDiagnosisDO);
        }
        return success(dsyyEntranceService.checkPrescriptions(outpatient,prescriptionOnly,payType,patient,doctor,wlyyPrescriptionInfoDOS,wlyyPrescriptionDiagnosisDOS));
    }
    /**
     * 处方在医生站系统成功保存后调用
     * @param patient 病人id
     * @param doctor 医生id
     * @param diagnosisDOS 诊断json
     * @param infos  药品json
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/dsyySaveCheckInfo")
    @ApiOperation(value = "处方在医生站系统成功保存后调用")
    public Envelop dsyySaveCheckInfo(
            @ApiParam(name = "outpatient", value = "就诊表id")
            @RequestParam(value = "outpatient", defaultValue = "") String outpatient,
            @ApiParam(name = "prescriptionOnly", value = "处方唯一标识")
            @RequestParam(value = "prescriptionOnly", defaultValue = "") String prescriptionOnly,
            @ApiParam(name = "payType", value = "付款方式0自费;1医保")
            @RequestParam(value = "payType", defaultValue = "") String payType,
            @ApiParam(name = "doctor", value = "医生id")
            @RequestParam(value = "doctor", defaultValue = "") String doctor,
            @ApiParam(name = "patient", value = "病人id")
            @RequestParam(value = "patient", defaultValue = "") String patient,
            @ApiParam(name = "diagnosisDOS", value = "诊断json")
            @RequestParam(value = "diagnosisDOS", defaultValue = "") String diagnosisDOS,
            @ApiParam(name = "infos", value = "药品json")
            @RequestParam(value = "infos", defaultValue = "") String infos) throws Exception {
        JSONArray druginfos = JSONArray.parseArray(infos);
        List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = new ArrayList<>();
        for (int i = 0; i < druginfos.size(); i++) {
            WlyyPrescriptionInfoDO wlyyPrescriptionInfo = toEntity(druginfos.get(i).toString(), WlyyPrescriptionInfoDO.class);
            wlyyPrescriptionInfoDOS.add(wlyyPrescriptionInfo);
        }
        JSONArray diagnosis = JSONArray.parseArray(diagnosisDOS);
        List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOS = new ArrayList<>();
        for (int i = 0; i < diagnosis.size(); i++) {
            WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO = toEntity(diagnosis.get(i).toString(), WlyyPrescriptionDiagnosisDO.class);
            wlyyPrescriptionDiagnosisDOS.add(wlyyPrescriptionDiagnosisDO);
        }
        return success(dsyyEntranceService.saveCheck(outpatient,prescriptionOnly,payType,patient,doctor,wlyyPrescriptionInfoDOS,wlyyPrescriptionDiagnosisDOS));
    }
    /**
     * 处方保存成功后,发送给审方系统进行人工审方
     * @param patient 病人id
     * @param doctor 医生id
     * @param diagnosisDOS 诊断json
     * @param infos  药品json
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/dsyyValidCheckInfo")
    @ApiOperation(value = "人工审方")
    public Envelop dsyyValidCheckInfo(
            @ApiParam(name = "outpatient", value = "就诊表id")
            @RequestParam(value = "outpatient", defaultValue = "") String outpatient,
            @ApiParam(name = "prescriptionOnly", value = "处方唯一标识")
            @RequestParam(value = "prescriptionOnly", defaultValue = "") String prescriptionOnly,
            @ApiParam(name = "payType", value = "付款方式0自费;1医保")
            @RequestParam(value = "payType", defaultValue = "") String payType,
            @ApiParam(name = "doctor", value = "医生id")
            @RequestParam(value = "doctor", defaultValue = "") String doctor,
            @ApiParam(name = "patient", value = "病人id")
            @RequestParam(value = "patient", defaultValue = "") String patient,
            @ApiParam(name = "diagnosisDOS", value = "诊断json")
            @RequestParam(value = "diagnosisDOS", defaultValue = "") String diagnosisDOS,
            @ApiParam(name = "infos", value = "药品json")
            @RequestParam(value = "infos", defaultValue = "") String infos) throws Exception {
        JSONArray druginfos = JSONArray.parseArray(infos);
        List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = new ArrayList<>();
        for (int i = 0; i < druginfos.size(); i++) {
            WlyyPrescriptionInfoDO wlyyPrescriptionInfo = toEntity(druginfos.get(i).toString(), WlyyPrescriptionInfoDO.class);
            wlyyPrescriptionInfoDOS.add(wlyyPrescriptionInfo);
        }
        JSONArray diagnosis = JSONArray.parseArray(diagnosisDOS);
        List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOS = new ArrayList<>();
        for (int i = 0; i < diagnosis.size(); i++) {
            WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO = toEntity(diagnosis.get(i).toString(), WlyyPrescriptionDiagnosisDO.class);
            wlyyPrescriptionDiagnosisDOS.add(wlyyPrescriptionDiagnosisDO);
        }
        return success(dsyyEntranceService.validCheck(outpatient,prescriptionOnly,payType,patient,doctor,wlyyPrescriptionInfoDOS,wlyyPrescriptionDiagnosisDOS));
    }
}

+ 80 - 15
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/DsyyPrescriptionCotroller.java

@ -85,9 +85,9 @@ public class DsyyPrescriptionCotroller extends EnvelopRestEndpoint {
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/hcyyCheckInfo")
    @PostMapping(value = "/dsyyCheckInfo")
    @ApiOperation(value = "合理用药审核")
    public Envelop hcyyCheckInfo(
    public Envelop dsyyCheckInfo(
            @ApiParam(name = "outpatient", value = "就诊表id")
            @RequestParam(value = "outpatient", defaultValue = "") String outpatient,
            @ApiParam(name = "prescriptionOnly", value = "处方唯一标识")
@ -102,20 +102,85 @@ public class DsyyPrescriptionCotroller extends EnvelopRestEndpoint {
            @RequestParam(value = "diagnosisDOS", defaultValue = "") String diagnosisDOS,
            @ApiParam(name = "infos", value = "药品json")
            @RequestParam(value = "infos", defaultValue = "") String infos) throws Exception {
        JSONArray druginfos = JSONArray.parseArray(infos);
        List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = new ArrayList<>();
        for (int i = 0; i < druginfos.size(); i++) {
            WlyyPrescriptionInfoDO wlyyPrescriptionInfo = toEntity(druginfos.get(i).toString(), WlyyPrescriptionInfoDO.class);
            wlyyPrescriptionInfoDOS.add(wlyyPrescriptionInfo);
        }
        JSONArray diagnosis = JSONArray.parseArray(diagnosisDOS);
        List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOS = new ArrayList<>();
        for (int i = 0; i < diagnosis.size(); i++) {
            WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO = toEntity(diagnosis.get(i).toString(), WlyyPrescriptionDiagnosisDO.class);
            wlyyPrescriptionDiagnosisDOS.add(wlyyPrescriptionDiagnosisDO);
        }
        return success(dsyyEntranceService.checkPrescriptions(outpatient,prescriptionOnly,payType,patient,doctor,wlyyPrescriptionInfoDOS,wlyyPrescriptionDiagnosisDOS));
        return success(dsyyPrescriptionService.dsyyCheckInfo(outpatient,prescriptionOnly,payType,doctor,patient,diagnosisDOS,infos));
    }
    /**
     * 处方在医生站系统成功保存后调用
     * @param patient 病人id
     * @param doctor 医生id
     * @param diagnosisDOS 诊断json
     * @param infos  药品json
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/dsyySaveCheckInfo")
    @ApiOperation(value = "处方在医生站系统成功保存后调用")
    public Envelop dsyySaveCheckInfo(
            @ApiParam(name = "outpatient", value = "就诊表id")
            @RequestParam(value = "outpatient", defaultValue = "") String outpatient,
            @ApiParam(name = "prescriptionOnly", value = "处方唯一标识")
            @RequestParam(value = "prescriptionOnly", defaultValue = "") String prescriptionOnly,
            @ApiParam(name = "payType", value = "付款方式0自费;1医保")
            @RequestParam(value = "payType", defaultValue = "") String payType,
            @ApiParam(name = "doctor", value = "医生id")
            @RequestParam(value = "doctor", defaultValue = "") String doctor,
            @ApiParam(name = "patient", value = "病人id")
            @RequestParam(value = "patient", defaultValue = "") String patient,
            @ApiParam(name = "diagnosisDOS", value = "诊断json")
            @RequestParam(value = "diagnosisDOS", defaultValue = "") String diagnosisDOS,
            @ApiParam(name = "infos", value = "药品json")
            @RequestParam(value = "infos", defaultValue = "") String infos) throws Exception {
        return success(dsyyPrescriptionService.dsyySaveCheckInfo(outpatient,prescriptionOnly,payType,doctor,patient,diagnosisDOS,infos));
    }
    /**
     * 处方保存成功后,发送给审方系统进行人工审方
     * @param patient 病人id
     * @param doctor 医生id
     * @param diagnosisDOS 诊断json
     * @param infos  药品json
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/dsyyValidCheckInfo")
    @ApiOperation(value = "人工审方")
    public Envelop dsyyValidCheckInfo(
            @ApiParam(name = "outpatient", value = "就诊表id")
            @RequestParam(value = "outpatient", defaultValue = "") String outpatient,
            @ApiParam(name = "prescriptionOnly", value = "处方唯一标识")
            @RequestParam(value = "prescriptionOnly", defaultValue = "") String prescriptionOnly,
            @ApiParam(name = "payType", value = "付款方式0自费;1医保")
            @RequestParam(value = "payType", defaultValue = "") String payType,
            @ApiParam(name = "doctor", value = "医生id")
            @RequestParam(value = "doctor", defaultValue = "") String doctor,
            @ApiParam(name = "patient", value = "病人id")
            @RequestParam(value = "patient", defaultValue = "") String patient,
            @ApiParam(name = "diagnosisDOS", value = "诊断json")
            @RequestParam(value = "diagnosisDOS", defaultValue = "") String diagnosisDOS,
            @ApiParam(name = "infos", value = "药品json")
            @RequestParam(value = "infos", defaultValue = "") String infos) throws Exception {
        return success(dsyyPrescriptionService.dsyyValidCheckInfo(outpatient,prescriptionOnly,payType,doctor,patient,diagnosisDOS,infos));
    }
    /**
     * 处方保存成功后,发送给审方系统进行人工审方
     * @param patient 病人id
     * @param doctor 医生id
     * @param diagnosisDOS 诊断json
     * @param infos  药品json
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/sfToHis")
    @ApiOperation(value = "物流通知his摆药")
    public Envelop sfToHis(
            @ApiParam(name = "outpatientId", value = "就诊表id")
            @RequestParam(value = "outpatientId", defaultValue = "") String outpatientId,
            @ApiParam(name = "realorder", value = "处方号")
            @RequestParam(value = "realorder", defaultValue = "") String realorder) throws Exception {
        return success(dsyyPrescriptionService.sfToHis(outpatientId,realorder));
    }
}

+ 11 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -2175,7 +2175,12 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "cardNo", value = "cardNo", required = true)
            @RequestParam(required = true) String cardNo) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok", businessOrderService.ylzRechargePre(relationCode, depositType, wxId, cardType, cardNo, demoFlag));
            if (wxId.equalsIgnoreCase("xm_dsyy_wx")){
                return ObjEnvelop.getSuccess("ok", businessOrderService.ylzRechargePreDs(relationCode, depositType, wxId, cardType, cardNo, demoFlag));
            }else {
                return ObjEnvelop.getSuccess("ok", businessOrderService.ylzRechargePre(relationCode, depositType, wxId, cardType, cardNo, demoFlag));
            }
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
@ -2696,6 +2701,8 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                return ObjEnvelop.getSuccess("ok", xzzxEntranceService.selectHistoryEmrFromEntrance(patient, null));
            } else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
                return ObjEnvelop.getSuccess("ok", hcyyPrescriptionService.selectHistoryEmrFromEntrance(patient, null));
            }  else if (wxId.equalsIgnoreCase("xm_dsyy_wx")) {
                return ObjEnvelop.getSuccess("ok", dsyyPrescriptionService.selectHistoryEmrFromEntrance(patient, null));
            } else {
                return ObjEnvelop.getSuccess("ok", prescriptionService.outpatient(patient, doctorId));
            }
@ -2730,7 +2737,9 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                return ObjEnvelop.getSuccess("ok", xzzxEntranceService.selectBrowseSingleEMR(opid));
            }else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
                return ObjEnvelop.getSuccess("ok", hcyyPrescriptionService.selectBrowseSingleEMR(opid));
            }  else {
            } else if (wxId.equalsIgnoreCase("xm_dsyy_wx")) {
                return ObjEnvelop.getSuccess("ok", dsyyPrescriptionService.selectHistoryEmrRecord(opid,recSn));
            } else {
                return ObjEnvelop.getSuccess("ok", prescriptionService.getPatInfoDataXml(opid, recSn));
            }
        } catch (Exception e) {