wangzhinan 1 год назад
Родитель
Сommit
3e4bd99fad
17 измененных файлов с 3994 добавлено и 134 удалено
  1. 2451 0
      business/base-service/src/main/java/com/yihu/jw/healthCare/service/HealthCareNewService.java
  2. 126 75
      business/base-service/src/main/java/com/yihu/jw/healthCare/service/HealthCareService.java
  3. 94 0
      business/base-service/src/main/java/com/yihu/jw/healthCare/utils/Pkcs7Encoder.java
  4. 14 0
      business/base-service/src/main/java/com/yihu/jw/healthCare/utils/SM4Context.java
  5. 354 0
      business/base-service/src/main/java/com/yihu/jw/healthCare/utils/SM4New.java
  6. 162 0
      business/base-service/src/main/java/com/yihu/jw/healthCare/utils/SM4Util.java
  7. 292 0
      business/base-service/src/main/java/com/yihu/jw/healthCare/utils/YibaoJiaMi.java
  8. 3 0
      business/base-service/src/main/java/com/yihu/jw/hospital/family/dao/WlyyPatientFamilyMemberDao.java
  9. 3 0
      business/base-service/src/main/java/com/yihu/jw/hospital/healthCare/YlzMedicailRelationDao.java
  10. 16 0
      business/base-service/src/main/java/com/yihu/jw/hospital/healthCare/YlzMedicailRelationInvoiceDao.java
  11. 13 0
      business/base-service/src/main/java/com/yihu/jw/hospital/healthCare/YlzMedicailRelationRefundDao.java
  12. 16 0
      business/base-service/src/main/java/com/yihu/jw/hospital/healthCare/YlzMedicalUserInfoDao.java
  13. 38 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/healthCare/YlzMedicalRelationDO.java
  14. 77 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/healthCare/YlzMedicalRelationInvoiceDO.java
  15. 60 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/healthCare/YlzMedicalRelationRefundDO.java
  16. 83 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/healthCare/YlzMedicalUserInfoDO.java
  17. 192 59
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/healthCare/HealthCareEndPoint.java

+ 2451 - 0
business/base-service/src/main/java/com/yihu/jw/healthCare/service/HealthCareNewService.java

@ -0,0 +1,2451 @@
package com.yihu.jw.healthCare.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.family.WlyyPatientFamilyMemberDO;
import com.yihu.jw.entity.hospital.healthCare.*;
import com.yihu.jw.entity.hospital.httplog.YlzHttpLogDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.healthCare.utils.AES;
import com.yihu.jw.healthCare.utils.SafeUtil;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.family.dao.WlyyPatientFamilyMemberDao;
import com.yihu.jw.hospital.healthCare.*;
import com.yihu.jw.hospital.httplog.dao.YlzHttpLogDao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.common.QrcodeUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.encrypt.MD5;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.idcard.IdCardUtil;
import com.yihu.jw.utils.ByteToInputStream;
import net.sf.json.util.JSONTokener;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import javax.transaction.Transactional;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
 * 新版医保对接
 * Created by wangzhinan 20211002
 */
@Service
@Transactional
public class HealthCareNewService {
    private Logger logger = LoggerFactory.getLogger(HealthCareNewService.class);
    @Autowired
    private WlyyHospitalSysDictDao hospitalSysDictDao;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private OutpatientDao outpatientDao;
    @Autowired
    private DoctorMappingDao doctorMappingDao;
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private YlzHttpLogDao ylzHttpLogDao;
    @Autowired
    private PatientMappingDao patientMappingDao;
    @Autowired
    private YlzMedicalPrescriptionUploadDao ylzMedicalPrescriptionUploadDao;
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private YlzMedicailRelationDao ylzMedicailRelationDao;
    @Autowired
    private YlzMedicailBillDao ylzMedicailBillDao;
    @Autowired
    private YlzMedicailIcdDao ylzMedicailIcdDao;
    @Autowired
    private YlzMedicailMxDao ylzMedicailMxDao;
    @Autowired
    private XzzxEntranceService xzzxEntranceService;
    @Autowired
    private EntranceService entranceService;
    @Autowired
    private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
    @Autowired
    private YlzMedicailRelationRefundDao ylzMedicailRelationRefundDao;
    @Autowired
    private YlzMedicalUserInfoDao ylzMedicalUserInfoDao;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private WlyyPatientFamilyMemberDao familyMemberDao;
    private String ylzConfigUrl;
    private String ylzConfigAppid;
    private String ylzConfigAppSecret;
    private String ylzConfigEncryptKey;
    private String ylzConfigSignKey;
    private String ylzConfigOrgCode;
    public static String entranceHealthCareUrl = "http://127.0.0.1:10023/healthCare/";
    public void initConfig() throws Exception{
        logger.info("初始话参数!");
        List<WlyyHospitalSysDictDO> hospitalSysDictDOS = hospitalSysDictDao.findByDictName("ylzConfig");
        if (hospitalSysDictDOS==null||hospitalSysDictDOS.size()==0){
            throw new Exception("尚未添加配置参数");
        }else {
            for (WlyyHospitalSysDictDO hospitalSysDictDO:hospitalSysDictDOS){
                if (hospitalSysDictDO.getId().equalsIgnoreCase("ylzConfigUrl")){
                    ylzConfigUrl = hospitalSysDictDO.getDictValue();
                }
                if (hospitalSysDictDO.getId().equalsIgnoreCase("ylzConfigAppid")){
                    ylzConfigAppid = hospitalSysDictDO.getDictValue();
                }
                if (hospitalSysDictDO.getId().equalsIgnoreCase("ylzConfigAppSecret")){
                    ylzConfigAppSecret = hospitalSysDictDO.getDictValue();
                }
                if (hospitalSysDictDO.getId().equalsIgnoreCase("ylzConfigEncryptKey")){
                    ylzConfigEncryptKey = hospitalSysDictDO.getDictValue();
                }
                if (hospitalSysDictDO.getId().equalsIgnoreCase("ylzConfigSignKey")){
                    ylzConfigSignKey = hospitalSysDictDO.getDictValue();
                }
                if (hospitalSysDictDO.getId().equalsIgnoreCase("ylzConfigOrgCode")){
                    ylzConfigOrgCode = hospitalSysDictDO.getDictValue();
                }
            }
        }
    }
    /**
     * 医保统一调用接口
     * @param data
     * @param funid
     * @param name
     * @return
     * @throws Exception
     */
    @org.springframework.transaction.annotation.Transactional(propagation= Propagation.NOT_SUPPORTED)
    public String requestYlz(JSONObject data,String funid,String name) throws Exception {
        String obj="";
        try {
            YlzHttpLogDO ylzHttpLogDO = new YlzHttpLogDO();
            initConfig();
            WlyyHospitalSysDictDO systemDict =  hospitalSysDictDao.findOneByDictNameAndDictCode("ylzConfig","testFlag");
            if (null!=systemDict&&"1".equalsIgnoreCase(systemDict.getDictValue())){//测试环境
                //N00.00.00.01接口外其他的接口在服务号前加个T就是测试
                funid ="N00.00.00.01".equalsIgnoreCase(funid)?funid:"T"+funid;
                System.out.println("funid="+funid);
            }
            JSONObject object = new JSONObject();
            object.put("sign_type","md5");
            object.put("appid",ylzConfigAppid);
            String accessToken = getYlzToken();
            if (accessToken==null){
                throw new Exception("token无效");
            }
            object.put("access_token",accessToken);
            object.put("funid",funid);
            data.put("appid",ylzConfigAppid);
            data.put("org_code",ylzConfigOrgCode);
            object.put("data",data);
            String signResult = SafeUtil.sign(object.toJSONString(),ylzConfigSignKey);
            obj = SafeUtil.encrypt(signResult,ylzConfigEncryptKey);
            JSONObject jsonObject = JSONObject.parseObject(obj);
          /*  obj = YibaoJiaMi.encryptData(object,ylzConfigSignKey,ylzConfigEncryptKey);
            JSONObject jsonObject = JSONObject.parseObject(obj);*/
            logger.info("请求前funid=="+funid+"data="+data.toJSONString());
            String response = httpClientUtil.postBody(ylzConfigUrl,jsonObject);
            ylzHttpLogDO.setResponseEncrpty(response);
            if (response!=null&&response!=""){
                JSONObject result = JSONObject.parseObject(response);
                if (result.getString("flag").equalsIgnoreCase("1")){
                    String dataResult = result.getString("encrypt_data");
                    result.remove("encrypt_data");
                    if (dataResult!=null&&dataResult!=""){
                        String decryptResult = AES.aesDecrypt(dataResult,ylzConfigEncryptKey);
                        JSONObject dataObject = JSONObject.parseObject(decryptResult);
                 /*       String decryptResult = YibaoJiaMi.decrypt(dataResult,ylzConfigEncryptKey);
                        JSONObject dataObject = JSONObject.parseObject(decryptResult);*/
                        result.put("encrypt_data",dataObject);
                        response = result.toJSONString();
                    }
                }
            }
            ylzHttpLogDO.setCode(funid);
            ylzHttpLogDO.setName(name);
            ylzHttpLogDO.setRequest(data.toJSONString());
            ylzHttpLogDO.setRequestEncrpty(obj);
            ylzHttpLogDO.setResponse(response);
            ylzHttpLogDO.setCreateTime(new Date());
            ylzHttpLogDao.save(ylzHttpLogDO);
            return response;
        }catch (Exception e){
            e.printStackTrace();
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            String error = sw.toString();
            YlzHttpLogDO ylzHttpLogDO = new YlzHttpLogDO();
            ylzHttpLogDO.setCode(funid);
            ylzHttpLogDO.setName(name);
            ylzHttpLogDO.setRequest(data.toJSONString());
            ylzHttpLogDO.setRequestEncrpty(obj);
            ylzHttpLogDO.setResponse(error);
            ylzHttpLogDO.setCreateTime(new Date());
            ylzHttpLogDao.save(ylzHttpLogDO);
            return null;
        }
    }
    /**
     * 获取token
     * @return
     * @throws Exception
     */
    /**
     * 2.3.1	医师身份验证(处方权,多点执业等)
     */
    public String doctorAuthentication(String doctorId){
        try {
            BaseDoctorDO doctorDO = doctorDao.findById(doctorId).get();
            if (doctorDO == null){
                throw new Exception("医生不存在");
            }
            List<BaseDoctorHospitalDO> doctorHospitalDOS = doctorHospitalDao.findByDoctorCode(doctorId);
            if(doctorHospitalDOS.size()<=0){
                throw new Exception("未找到医生科室编码");
            }
            BaseDoctorHospitalDO doctorHospitalDO = doctorHospitalDOS.get(0);
            JSONObject data = new JSONObject();
            data.put("his_dept_code",doctorHospitalDO.getDeptCode());//his内部科室编码
            data.put("his_dept_name",doctorHospitalDO.getDeptName());//his内部科室名称
//        data.put("dept_code","");//医保科室编码	String	N
//        data.put("dept_name","");//医保科室名称	String	N
            data.put("medical_mode","10");//医疗就诊方式	10	门(急)诊
            data.put("name",doctorDO.getName());//医师姓名
            data.put("idcard",doctorDO.getIdcard());//医师证件号
            data.put("cert_type","01");//医师证件类型
            String result = requestYlz(data,"N20.17.02.01","医师身份验证");
            if(result == null){
                throw new Exception("医保请求失败");
            }
            logger.info("医师身份验证:"+result);
            JSONObject object = JSONObject.parseObject(result);
            if (object.getString("flag").equalsIgnoreCase("1")){
                JSONObject encryptData = object.getJSONObject("encrypt_data");
                return encryptData.getString("is_prescribe");
            }else {
                return "0";
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return "0";
    }
    /**
     * 2.3.2	医师人脸签到表单地址
     * @param doctorId
     * @throws Exception
     */
    public String doctorFaceCheckInAddress(String doctorId)throws Exception{
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigFaceReturnUrl").get();
        if(hospitalSysDictDO == null){
            throw new Exception("未配置回调地址");
        }
        BaseDoctorDO doctorDO = doctorDao.findById(doctorId).get();
        if (doctorDO == null){
            throw new Exception("医生不存在");
        }
        JSONObject data = new JSONObject();
        data.put("name",doctorDO.getName());//医师姓名
        data.put("idcard",doctorDO.getIdcard());//医师证件号
        data.put("cert_type","01");//医师证件类型
        data.put("redirect_url",hospitalSysDictDO.getDictValue());//回调地址
        String result = requestYlz(data,"N20.17.02.02","医师人脸签到表单地址");
        if(result == null){
            throw new Exception("医保请求失败");
        }
        logger.info("医师人脸签到表单地址:"+result);
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            return encryptData.toJSONString();
        }
        return result;
    }
    /**
     * 2.3.3	获取医师人脸签到数据
     */
    public String doctorFaceCheckInData(String doctorId)throws Exception{
        BaseDoctorDO doctorDO = doctorDao.findById(doctorId).get();
        if (doctorDO == null){
            throw new Exception("医生不存在");
        }
        JSONObject data = new JSONObject();
        data.put("name",doctorDO.getName());//医师姓名
        data.put("idcard",doctorDO.getIdcard());//医师证件号
        data.put("cert_type","01");//医师证件类型
        String result = requestYlz(data,"N20.17.02.05","获取医师人脸签到数据");
        if(result == null){
            throw new Exception("医保请求失败");
        }
        logger.info("获取医师人脸签到数据:"+result);
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            return encryptData.toJSONString();
        }
        return result;
    }
    /**
     * 2.3.4	医师人脸签到微信小程序二维码(N20.17.02.06)
     * @param doctorId
     * @throws Exception
     */
    public String doctorFaceCheckInAddressBase64(String doctorId)throws Exception{
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigFaceReturnUrl").get();
        if(hospitalSysDictDO == null){
            throw new Exception("未配置回调地址");
        }
        BaseDoctorDO doctorDO = doctorDao.findById(doctorId).get();
        if (doctorDO == null){
            throw new Exception("医生不存在");
        }
        JSONObject data = new JSONObject();
        data.put("name",doctorDO.getName());//医师姓名
        data.put("idcard",doctorDO.getIdcard());//医师证件号
        data.put("cert_type","01");//医师证件类型
        data.put("redirect_url",hospitalSysDictDO.getDictValue());//回调地址
        String result = requestYlz(data,"N20.17.02.06","2.3.3\t获取医师人脸签到数据");
        if(result == null){
            throw new Exception("医保请求失败");
        }
        logger.info("医师人脸签到表单地址:"+result);
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            return encryptData.toJSONString();
        }
        return result;
    }
    /**
     * 2.4.1 事前提醒
     */
    public String advanceWarning(String prescriptionId){
        try {
            WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findById(prescriptionId).get();
            if (wlyyPrescriptionDO == null){
                throw new Exception("续方信息不存在");
            }
            WlyyOutpatientDO outpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId()).get();
            if (outpatientDO == null){
                throw new Exception("门诊信息不存在");
            }
            WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigOrgCode").get();
            if(hospitalSysDictDO == null){
                throw new Exception("未配置网点编号");
            }
            String icCardNo = outpatientDO.getCardNo();
            String his_serial = outpatientDO.getRegisterNo();
            String org_code = hospitalSysDictDO.getDictCode();
            JSONObject data;
            //获取his处方信息
            String infoResponse = xzzxEntranceService.presUpload(icCardNo,his_serial,org_code);
            JSONObject infoObject = JSONObject.parseObject(infoResponse);
            if("0".equals(infoObject.getString("ret_code"))){
                data = infoObject;
            }else {
                throw new Exception("获取his处方信息失败:"+infoObject.getString("ret_mess"));
            }
            data.remove("ret_code");
            data.remove("ret_mess");
            data.remove("log_no");
            data.put("ticket_no",outpatientDO.getXtgzh());//	单据流水号
            String result = requestYlz(data,"N20.17.03.03","事前提醒");
            if(result == null){
                throw new Exception("医保请求失败");
            }
            logger.info("事前提醒:"+result);
            JSONObject object = JSONObject.parseObject(result);
            if (object.getString("flag").equalsIgnoreCase("1")){
                JSONObject encryptData = object.getJSONObject("encrypt_data");
                return encryptData.toJSONString();
            }
            return result;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    /**
     * 2.4.2	医师开方上传
     */
    public String doctorPrescriptionUpload(String prescriptionId,String wxId) throws Exception{
        WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findById(prescriptionId).get();
        if (wlyyPrescriptionDO == null){
            throw new Exception("续方信息不存在");
        }
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId()).get();
        if (outpatientDO == null){
            throw new Exception("门诊信息不存在");
        }
        BaseDoctorDO baseDoctorDO = doctorDao.findById(outpatientDO.getDoctor()).get();
        DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(outpatientDO.getDoctor());
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigOrgCode").get();
        if(hospitalSysDictDO == null){
            throw new Exception("未配置网点编号");
        }
        String icCardNo = outpatientDO.getCardNo();
        String his_serial = outpatientDO.getRegisterNo();
        String org_code = hospitalSysDictDO.getDictCode();
        JSONObject data = new JSONObject();
        if (StringUtils.isNoneBlank(wxId)){
            if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
                //获取his处方信息
                JSONObject infoObject= xzzxEntranceService.presUploadToEntrance(icCardNo,his_serial,org_code);
                JSONObject info = infoObject.getJSONArray("data").getJSONObject(0);
                if("0".equals(info.getString("ret_code"))){
                    data = info;
                }else {
                    throw new Exception("获取his处方信息失败:"+infoObject.getString("ret_mess"));
                }
                data.remove("ret_code");
                data.remove("ret_mess");
                data.remove("log_no");
                data.put("order_id",prescriptionId);
            }else if(wxId.equalsIgnoreCase("xm_zsyy_wx")){
                net.sf.json.JSONArray result = entranceService.BS10108(outpatientDO.getCardNo(),outpatientDO.getIdcard(),null,null,null,null,his_serial,false);
                if (result!=null&&result.size()!=0){
                    net.sf.json.JSONObject object = result.getJSONObject(0);
                    net.sf.json.JSONObject jsonObject = object.getJSONObject("retInfo");
                    net.sf.json.JSONObject msgInfoJson = object.getJSONObject("msgInfo");
                    if (jsonObject.getString("retCode").equalsIgnoreCase("00")){
                        if (msgInfoJson!=null){
                            net.sf.json.JSONObject resultJSON = msgInfoJson.getJSONObject("receipt");
                            if (resultJSON!=null){
                                data.put("name",resultJSON.getString("xming0"));
                                data.put("cert_type","01");
                                data.put("region_code","3502");
                                data.put("order_id",resultJSON.getString("xtgzh0"));
                                data.put("medical_mode","10");
                                data.put("prescription_code",resultJSON.getString("xtgzh0"));
                                data.put("idcard",resultJSON.getString("id0000"));
                                data.put("cert_type","01");
                                data.put("sex",resultJSON.getString("brnl00"));
                                data.put("birth", IdCardUtil.getBirthdayForIdcardStr(resultJSON.getString("id0000")));
                                data.put("phone",outpatientDO.getMobile());
                                data.put("medical_type","11");
                                data.put("medical_type_name","普通门诊");
                                data.put("medical_time",DateUtil.dateToStrLong(outpatientDO.getCreateTime()));
                                data.put("disease_code",outpatientDO.getIcd10());
                                data.put("dept_code",outpatientDO.getDept());
                                data.put("dept_name",outpatientDO.getDeptName());
                                data.put("doctor_idcard",baseDoctorDO.getIdcard());
                                data.put("doctor_code",doctorMappingDO.getMappingCode());
                                data.put("doctor_name",baseDoctorDO.getName());
                                data.put("prescription_date",DateUtil.dateToStrLong(wlyyPrescriptionDO.getCreateTime()));
                                data.put("prescription_counts",resultJSON.getString("cfxms0"));
                                data.put("prescription_source",0);
                                List<WlyyPrescriptionDiagnosisDO> diagnosisDOList = prescriptionDiagnosisDao.findByPrescriptionId(prescriptionId,1);
                                JSONArray diagnosisArray = new JSONArray();
                                for (WlyyPrescriptionDiagnosisDO diagnosisDO:diagnosisDOList){
                                    JSONObject diagnosisObj = new JSONObject();
                                    diagnosisObj.put("disease_code_icd10",diagnosisDO.getCode());
                                    diagnosisObj.put("disease_name_icd10",diagnosisDO.getName());
                                    diagnosisObj.put("disease_type","01");
                                    diagnosisObj.put("disease_order","01");
                                    diagnosisArray.add(diagnosisObj);
                                }
                                data.put("zdlist",diagnosisArray);
                                JSONArray infoList = new JSONArray();
                                Object json = new JSONTokener(resultJSON.getString("mxlists")).nextValue();
                                if(json instanceof JSONObject){
                                    JSONObject mxListJSON = (JSONObject)json;
                                    JSONObject mxlistObj = mxListJSON.getJSONObject("mxlist");
                                    JSONObject infoJson = new JSONObject();
                                    infoJson.put("his_item_name",mxlistObj.getString("xmmc00"));
                                    infoJson.put("his_item_code",mxlistObj.getString("xmbh00"));
                                    infoJson.put("item_name",mxlistObj.getString("xmmc00"));
                                    infoJson.put("item_code",mxlistObj.getString("xmbh00"));
                                    infoJson.put("his_drug_no",mxlistObj.getString("xmbh00"));
                                    infoJson.put("his_detail_sn",mxlistObj.getString("cfhao0"));
                                    infoJson.put("invoice_type","01");
                                    infoJson.put("specification_type",mxlistObj.getString("xmgg00"));
                                    infoJson.put("dosage_form",mxlistObj.getString("jx0000"));
                                    infoJson.put("charge_unit",mxlistObj.getString("xmdw00"));
                                    infoJson.put("price",mxlistObj.getString("xmdj00"));
                                    infoJson.put("amount",mxlistObj.getString("xmsl00"));
                                    infoJson.put("total_money",mxlistObj.getString("xmje00"));
                                    infoJson.put("single_dose",mxlistObj.getString("dcyydw"));
                                    infoJson.put("use_frequency",mxlistObj.getString("yppl00"));
                                    infoJson.put("medical_way",mxlistObj.getString("gytj00"));
                                    infoJson.put("prescription_date",mxlistObj.getString("jzrq"));
                                    infoJson.put("medication_days",mxlistObj.getString("ylts00"));
                                    infoJson.put("his_dept_code",outpatientDO.getDept());
                                    infoJson.put("his_dept_name",outpatientDO.getDeptName());
                                    infoJson.put("limit_type",mxlistObj.getString("sfybxm"));
                                    infoList.add(infoJson);
                                }else if (json instanceof JSONArray){
                                    JSONArray mxListArray = (JSONArray)json;
                                    for (int j=0;j<mxListArray.size();j++){
                                        JSONObject mxlistObj = mxListArray.getJSONObject(j);
                                        JSONObject infoJson = new JSONObject();
                                        infoJson.put("his_item_name",mxlistObj.getString("xmmc00"));
                                        infoJson.put("his_item_code",mxlistObj.getString("xmbh00"));
                                        infoJson.put("item_name",mxlistObj.getString("xmmc00"));
                                        infoJson.put("item_code",mxlistObj.getString("xmbh00"));
                                        infoJson.put("his_drug_no",mxlistObj.getString("xmbh00"));
                                        infoJson.put("his_detail_sn",mxlistObj.getString("cfhao0"));
                                        infoJson.put("invoice_type","01");
                                        infoJson.put("specification_type",mxlistObj.getString("xmgg00"));
                                        infoJson.put("dosage_form",mxlistObj.getString("jx0000"));
                                        infoJson.put("charge_unit",mxlistObj.getString("xmdw00"));
                                        infoJson.put("price",mxlistObj.getString("xmdj00"));
                                        infoJson.put("amount",mxlistObj.getString("xmsl00"));
                                        infoJson.put("total_money",mxlistObj.getString("xmje00"));
                                        infoJson.put("single_dose",mxlistObj.getString("dcyydw"));
                                        infoJson.put("use_frequency",mxlistObj.getString("yppl00"));
                                        infoJson.put("medical_way",mxlistObj.getString("gytj00"));
                                        infoJson.put("prescription_date",mxlistObj.getString("jzrq"));
                                        infoJson.put("medication_days",mxlistObj.getString("ylts00"));
                                        infoJson.put("his_dept_code",outpatientDO.getDept());
                                        infoJson.put("his_dept_name",outpatientDO.getDeptName());
                                        infoJson.put("limit_type",mxlistObj.getString("sfybxm"));
                                        infoList.add(infoJson);
                                    }
                                }
                                data.put("mxlist",infoList);
                            }
                        }
                    }
                }
            }
        }
        YlzMedicalPrescriptionUploadDO uploadDO = new YlzMedicalPrescriptionUploadDO();
        uploadDO.setOrgCode(org_code);
        uploadDO.setIcCardNo(icCardNo);
        uploadDO.setHisSerial(his_serial);
        uploadDO.setOutpatientId(wlyyPrescriptionDO.getOutpatientId());
        uploadDO.setPrescriptionId(prescriptionId);
        uploadDO.setRegionCode(data.getString("region_code"));
        uploadDO.setName(data.getString("name"));
        uploadDO.setIdcard(outpatientDO.getIdcard());
        uploadDO.setCertType(data.getString("cert_type"));
        uploadDO.setDataSource("53");//53移动支付
        uploadDO.setInsuranceSerial(data.getString("insurance_serial"));
        String result = requestYlz(data,"N20.17.03.01","医师开方上传");
        if(result == null){
            throw new Exception("医保请求失败");
        }
        logger.info("医师开方上传:"+result);
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            uploadDO.setTransactionNo(encryptData.getString("transaction_no"));
            ylzMedicalPrescriptionUploadDao.save(uploadDO);
            return encryptData.toJSONString();
        }
        return result;
    }
    /**
     * 2.4.2	医师开方上传
     *
     * @param prescriptionId
     * @return
     * @throws Exception
     */
    public String doctorPrescriptionUploadEntrance(String prescriptionId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"doctorPrescriptionUpload?prescriptionId="+prescriptionId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.4.3	医师开方上传取消(N20.17.03.06)
     */
    public String doctorPrescriptionUploadCancle(String prescriptionId,String cancelReason)throws Exception{
        YlzMedicalPrescriptionUploadDO uploadDO = ylzMedicalPrescriptionUploadDao.findByPrescriptionId(prescriptionId);
        if(uploadDO == null){
            throw new Exception("未找到开发上传记录");
        }
        JSONObject data = new JSONObject();
        data.put("transaction_no",uploadDO.getTransactionNo());//处方上传流水号  	String	Y
        data.put("insurance_serial",uploadDO.getInsuranceSerial());//医保流水号
        data.put("cancel_reason",cancelReason);//作废原因
        data.put("region_code",uploadDO.getRegionCode());//参保地区划代码
        data.put("idcard",uploadDO.getIdcard());//证件号码
        data.put("name",uploadDO.getName());//姓名
        data.put("cert_type",uploadDO.getCertType());//证件类型
        data.put("data_source",uploadDO.getDataSource());//数据来源	String	Y	参见编码附件
        String result = requestYlz(data,"N20.17.03.06","医师开方上传取消");
        if(result == null){
            throw new Exception("医保请求失败");
        }
        logger.info("医师开方上传取消:"+result);
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            return encryptData.toJSONString();
        }
        return result;
    }
    /**
     * 2.4.3	医师开方上传取消(N20.17.03.06)
     *
     * @param prescriptionId
     * @return
     * @throws Exception
     */
    public String doctorPrescriptionUploadCancleEntrance(String prescriptionId,String cancelReason) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"doctorPrescriptionUploadCancle?prescriptionId="+prescriptionId+"&cancelReason"+cancelReason;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.6.1	电子处方订单接收(N20.17.05.02)
     */
    public String electronicPrescriptionReceiving(String outpatientId)throws Exception{
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).get();
        if (outpatientDO == null){
            throw new Exception("门诊信息不存在");
        }
        List<WlyyPrescriptionExpressageDO> expressageDOList = prescriptionExpressageDao.findByOutpatientId(outpatientId);
        if(expressageDOList.size()==0){
            throw new Exception("收获信息不存在");
        }
        BasePatientDO patientDO = patientDao.findById(outpatientDO.getPatient()).get();
        if(patientDO==null){
            throw new Exception("居民信息不存在");
        }
        WlyyPrescriptionExpressageDO expressageDO = expressageDOList.get(0);
        logger.info("电子处方订单接收:1");
        List<YlzMedicalRelationDO> ylzMedicalRelationDOList = ylzMedicailRelationDao.findByOutpatientStatus(outpatientId);
        for (YlzMedicalRelationDO ylzMedicalRelationDO:ylzMedicalRelationDOList){
            logger.info("电子处方订单接收:2");
            JSONObject data = new JSONObject();
            data.put("order_time",DateUtil.dateToStrLong(expressageDO.getCreateTime()));//订单时间
            List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByRealOrderList(ylzMedicalRelationDO.getLogNo());
            if(wlyyPrescriptionDOS.size()==0){
                throw new Exception("处方信息不存在");
            }
            data.put("order_code",ylzMedicalRelationDO.getLogNo());//订单号
            WlyyPrescriptionDO wlyyPrescriptionDO = wlyyPrescriptionDOS.get(0);
            data.put("prescription_code",wlyyPrescriptionDO.getRealOrder());//医院处方编号
            data.put("channel","1");//1、微信公众号,2、app,3、web
            data.put("insurance_ticket_no",ylzMedicalRelationDO.getBillSerial());//医保收费单据号	String	N	订单结算后的收费单据号
            String order_state = "";
            if (wlyyPrescriptionDO.getStatus()==30){
                order_state = "1";
            }else if (wlyyPrescriptionDO.getStatus()==31){
                order_state = "2";
            }else if (wlyyPrescriptionDO.getStatus()==100){
                order_state = "3";
            }
            logger.info("电子处方订单接收:3"+order_state);
            data.put("order_state",order_state);//订单状态    --1待发货、2配送中、3已签收、4已取消	String	Y
            data.put("order_addr_detail",expressageDO.getProvinceName()+expressageDO.getCityName()+expressageDO.getTownName()+expressageDO.getStreetName()+expressageDO.getAddress());//订单详细地址
            data.put("order_owner",expressageDO.getName());
            data.put("order_owner_idcard",patientDO.getIdcard());
            data.put("order_owner_phone",patientDO.getMobile());
            Map<String,String> map = LatitudeUtils.getGeocoderLatitude(expressageDO.getProvinceName()+expressageDO.getCityName()+expressageDO.getTownName()+expressageDO.getStreetName()+expressageDO.getAddress());
            data.put("addr_lat",map.get("lat"));//收货地址纬度
            data.put("addr_lng",map.get("lng"));//收货地址经度
            if(expressageDO.getOneselfPickupFlg()==1){
                //自取
                data.put("delivery_way","2");//1.网订配送,2.网订自取
                data.put("qrcode_check_time","");//扫码校验时间
                data.put("receiving_time","");//药品签收时间
            }else {
                //非自取
                data.put("delivery_way","1");//配送方式 1.网订配送,2.网订自取
                data.put("delivery_number",expressageDO.getMailno());//配送单号
                data.put("delivery_org","顺丰");//配送单位
                data.put("delivery_take_time",DateUtil.dateToStrLong(wlyyPrescriptionDO.getPayTime()));//配送接单时间
                data.put("delivery_name","顺丰");//配送人姓名
                data.put("delivery_id_card","顺丰");//配送人身份证
//            data.put("delivery_phone","");//配送人联系电话 N
                data.put("getmedical_time",DateUtil.dateToStrLong(wlyyPrescriptionDO.getPayTime()));//骑手取药记录
                data.put("delivery_money","");//配送费
            }
//        apothecary_name	药师姓名	String	N
//        apothecary_id_card	药师身份证	String	N
//        apothecary_audit	药师审核时间	String	N
            data.put("money",ylzMedicalRelationDO.getTotalAmount());//商品金额
            data.put("settlement_time",DateUtil.dateToStrLong(ylzMedicalRelationDO.getPayDate()));//结算时间
            data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
            data.put("delivery_time",DateUtil.dateToStrLong(wlyyPrescriptionDO.getPayTime()));//发单时间
            data.put("elec_prescription_code",wlyyPrescriptionDO.getId());//平台处方编号
            data.put("prescription_code",wlyyPrescriptionDO.getRealOrder());//医院处方编号
//        data.put("insurance_serial",outpatientDO.getInsuranceSerial());//医保门诊流水号
            data.put("his_serial",ylzMedicalRelationDO.getHisSerial());//门诊业务流水号
            JSONArray array = new JSONArray();
            List<YlzMedicalMxDO> ylzMedicalMxDOS = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());
            for (YlzMedicalMxDO ylzMedicalMxDO:ylzMedicalMxDOS){
                JSONObject object = new JSONObject();
                object.put("order_id",ylzMedicalRelationDO.getLogNo());
                object.put("settlement_no",ylzMedicalRelationDO.getHisBillSerial());
                object.put("item_name",ylzMedicalMxDO.getItemName());
                object.put("item_code",ylzMedicalMxDO.getItemCode());
                array.add(object);
            }
            data.put("MXLIST",array);
//        mxlist	药品明细	MXLIST	N
//        MXLIST
//        order_id	订单号	String	Y
//        settlement_no	医保结算单据号	String	Y
//        item_name	医保项目名称	String	Y
//        item_code	医保项目编码	String	Y
//        supervision_code	药品电子监管码	String	N	非必填
            String result = requestYlz(data,"N20.17.05.02","电子处方订单接收");
            if(result == null){
                throw new Exception("医保请求失败");
            }
            logger.info("电子处方订单接收:"+result);
            JSONObject object = JSONObject.parseObject(result);
            if (object.getString("flag").equalsIgnoreCase("1")){
                JSONObject encryptData = object.getJSONObject("encrypt_data");
                logger.info("encryptData=="+encryptData);
            }
        }
        return "上传成功";
    }
    /**
     *2.6.2	电子处方订单取消(N20.17.05.03)
     */
    public String electronicPrescriptionCancle(String outpatientId)throws Exception{
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).get();
        if (outpatientDO == null){
            throw new Exception("门诊信息不存在");
        }
        JSONObject data = new JSONObject();
        data.put("order_code","");//订单号
        data.put("order_time",DateUtil.dateToStrLong(outpatientDO.getCreateTime()));//订单时间
        List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByOutPatientIdList(outpatientId);
        if(wlyyPrescriptionDOS.size()==0){
            throw new Exception("处方信息不存在");
        }
        data.put("prescription_code",wlyyPrescriptionDOS.get(0).getRealOrder());//医院处方编号
        data.put("channel","1");//1、微信公众号,2、app,3、web
//        data.put("insurance_ticket_no","");//医保收费单据号	String	N	订单结算后的收费单据号
        data.put("order_state","");//订单状态    --1待发货、2配送中、3已签收、4已取消	String	Y
        data.put("cancel_time","");//订单取消时间  取消时必填
        data.put("cancel_reason","");//取消原因
        String result = requestYlz(data,"N20.17.05.03","电子处方订单取消");
        if(result == null){
            throw new Exception("医保请求失败");
        }
        logger.info("电子处方订单取消:"+result);
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            return encryptData.toJSONString();
        }
        return result;
    }
    /**
     * 2.6.3 获取处方流转平台药师审方结果(N20.17.05.04)
     */
    public String pharmacistReviewResults(String outpatientId)throws Exception{
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).get();
        if (outpatientDO == null){
            throw new Exception("门诊信息不存在");
        }
        JSONObject data = new JSONObject();
//        data.put("order_code","");//订单号
        List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByOutPatientIdList(outpatientId);
        if(wlyyPrescriptionDOS.size()==0){
            throw new Exception("处方信息不存在");
        }
        data.put("prescription_code",wlyyPrescriptionDOS.get(0).getRealOrder());//医院处方编号
        String result = requestYlz(data,"N20.17.05.04","获取处方流转平台药师审方结果");
        if(result == null){
            throw new Exception("医保请求失败");
        }
        logger.info("获取处方流转平台药师审方结果:"+result);
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            return encryptData.toJSONString();
        }
        return result;
    }
    /**
     * 2.2.1	门诊提醒(N21.08.09.01)
     */
    public String outpatientReminder(String outpatientId,String doctorCode)throws Exception{
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).get();
        if (outpatientDO == null){
            throw new Exception("门诊信息不存在");
        }
        JSONObject data = new JSONObject();
//        data.put("order_code","");//订单号
        List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByOutPatientIdList(outpatientId);
        if(wlyyPrescriptionDOS.size()==0){
            throw new Exception("处方信息不存在");
        }
        data.put("card_no",outpatientDO.getCardNo());//社保卡号
        List<BaseDoctorHospitalDO> doctorHospitalDOS = doctorHospitalDao.findByDoctorCode(outpatientDO.getDoctor());
        if(doctorHospitalDOS.size()<=0){
            throw new Exception("未找到医生科室编码");
        }
        BaseDoctorHospitalDO doctorHospitalDO = doctorHospitalDOS.get(0);
        data.put("medical_dept_code",doctorHospitalDO.getDeptCode());//科室编码(使用医院科室编号)
        data.put("medical_dept_name",doctorHospitalDO.getDeptName());//科室名称
        data.put("doctor_code",doctorCode);//医师编号(使用医保医生编号)
        data.put("doctor_name",outpatientDO.getDoctorName());//医师姓名
        String result = requestYlz(data,"N21.08.09.01","门诊提醒");
        if(result == null){
            throw new Exception("医保请求失败");
        }
        logger.info("门诊提醒:"+result);
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            return encryptData.toJSONString();
        }
        return result;
    }
    /**
     * 2.2.2	门诊事中提醒(N21.08.09.02)
     */
    public String outpatientEventReminder(String outpatientId,String doctorCode)throws Exception{
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).get();
        if (outpatientDO == null){
            throw new Exception("门诊信息不存在");
        }
        JSONObject data = new JSONObject();
//        data.put("order_code","");//订单号
        data.put("card_no",outpatientDO.getCardNo());//社保卡号
        data.put("visit_no",outpatientDO.getRegisterNo());//门诊挂号号
        data.put("visit_type","1");//就诊类型	String	Y	(1住院、2门诊)
        data.put("medicine_type","");//医疗类别	String	Y
        List<BaseDoctorHospitalDO> doctorHospitalDOS = doctorHospitalDao.findByDoctorCode(outpatientDO.getDoctor());
        if(doctorHospitalDOS.size()<=0){
            throw new Exception("未找到医生科室编码");
        }
        BaseDoctorHospitalDO doctorHospitalDO = doctorHospitalDOS.get(0);
        data.put("medical_dept_code",doctorHospitalDO.getDeptCode());//科室编码(使用医院科室编号)
        data.put("medical_dept_name",doctorHospitalDO.getDeptName());//科室名称
        data.put("doctor_code",doctorCode);//医师编号(使用医保医生编号)
        data.put("doctor_name",outpatientDO.getDoctorName());//医师姓名
        data.put("doctor_advice_no","");// 	处方流水号(医院内部唯一号)	String	Y
        //医嘱
        JSONArray advice_details = new JSONArray();
        List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByOutPatientIdList(outpatientId);
        if(wlyyPrescriptionDOS.size()==0){
            throw new Exception("处方信息不存在");
        }
        for (WlyyPrescriptionDO wlyyPrescriptionDO:wlyyPrescriptionDOS){
            List<WlyyPrescriptionInfoDO> prescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(wlyyPrescriptionDO.getId(),1);
            for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO:prescriptionInfoDOS){
                JSONObject infoObj = new JSONObject();
                infoObj.put("project_code","");//项目编码	String	Y	(使用医保三目录项目编码),正常情况必填,特殊情况,如生化全套等没有医保编码,可放空。
                infoObj.put("hospital_code","");//院内项目编码
                infoObj.put("project_name","");//项目名称
                infoObj.put("recipe_no",wlyyPrescriptionDO.getRealOrder());//处方号
                infoObj.put("invoice_project","");//发票项目编码	String	Y	(使用医保发票项目编码)
                infoObj.put("medical_specification",wlyyPrescriptionInfoDO.getSpecification());//规格型号
                infoObj.put("dose_form",wlyyPrescriptionInfoDO.getDosage());//剂型
                infoObj.put("charge_unit","");//单位
                infoObj.put("price",wlyyPrescriptionInfoDO.getPackRetprice());//单价
                infoObj.put("dose_unit",wlyyPrescriptionInfoDO.getPackRetprice());//单价
                infoObj.put("medical_number",wlyyPrescriptionInfoDO.getQuantity());//数量
                infoObj.put("amount",wlyyPrescriptionInfoDO.getPackRetprice()*Integer.parseInt(wlyyPrescriptionInfoDO.getQuantity()));//金额
                infoObj.put("single_dose_number","");//每次用量
                infoObj.put("single_dose_unit","");//每次用量
                infoObj.put("use_frequency",wlyyPrescriptionInfoDO.getUsageName());//使用频次
                infoObj.put("deliver_way","");//具体给药途径详见附录三的编码
                infoObj.put("use_day",wlyyPrescriptionInfoDO.getDays());//用药天数
/*                dose_form	剂型, 	String	Y	具体可使用剂型详见附录五的编码
                medical_specification	规格	String	Y
                price	单价	String	Y	必须使用数值型,如”12.5”
                medical_number	数量	String	Y	必须使用数值型,如”10”
                dose_unit	单价 String	Y
                amount	金额	String	Y	必须使用数值型,如”50.5”
                use_day	用药天数	String	Y	(项目为药品时非空),医嘱服用该药品天数,必须使用数值型,如”15”
                single_dose_number	单次用药量	String	Y	(项目为药品时非空),配合下一个字段的单位,如 50 mg,必须使用数值型,如”50”
                single_dose_unit	单次用药量剂量单位	String	Y	(项目为药品时非空),具体可使用剂量单位详见附录四的编码
                take_medical_number	取药总量(	String	Y	项目为药品时非空),配合下一个字段的单位,如 500 mg,必须使用数值型,如”500”
                take_medical_unit	取药总量剂量单位	String	Y	(项目为药品时非空),具体可使用剂量单位附录四的编码
                dose_day	药量天数	String	Y	(项目为药品时非空),依据医嘱服药要求,所配药品患者可以服用的天数,必须使用数值型,如”5”
                deliver_way	给药途径	String	Y	具体给药途径详见附录三的编码
                take_frequence	服用频次	String	Y
                具体可用服用频次详见附录二的编码*/
                advice_details.add(infoObj);
            }
        }
        data.put("advice_details",advice_details);
        //诊断
        JSONArray diagnoses = new JSONArray();
        String icd10 = outpatientDO.getIcd10();
        String icd10Name = outpatientDO.getIcd10Name();
        String icd[] = icd10.split(",");
        String icdName[] = icd10Name.split(",");
        for (int i=0;i<icd.length;i++){
            JSONObject icdObj = new JSONObject();
            icdObj.put("disease_code_icd10",icd[i]);//诊断或症状编码
            icdObj.put("disease_name_icd10",icdName[i]);//诊断或症状名称
            diagnoses.add(icdObj);
        }
        data.put("diagnoses",diagnoses);
        String result = requestYlz(data,"N21.08.09.02","门诊事中提醒");
        if(result == null){
            throw new Exception("医保请求失败");
        }
        logger.info("门诊事中提醒:"+result);
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            return encryptData.toJSONString();
        }
        return result;
    }
    public String getYlzToken() throws Exception {
        YlzHttpLogDO ylzHttpLogDO = new YlzHttpLogDO();
        String token = null;
        initConfig();
        String funid = "N00.00.00.01";
        JSONObject data = new JSONObject();
        data.put("appid",ylzConfigAppid);
        data.put("appsecret",ylzConfigAppSecret);
        data.put("grant_type","client_credentials");
        JSONObject object = new JSONObject();
        object.put("sign_type","md5");
        object.put("appid",ylzConfigAppid);
       /* String stringSignTemp ="appid="+ylzConfigAppid+"&appsecret="+ylzConfigAppSecret+"&data="+data+"&funid="+funid+"&sign_type=md5&key="+ylzConfigSignKey;
        String sign = MD5.md5(stringSignTemp).toUpperCase();*/
        object.put("data",data);
        object.put("funid",funid);
        String signResult = SafeUtil.sign(object.toJSONString(),ylzConfigSignKey);
        String obj = SafeUtil.encrypt(signResult,ylzConfigEncryptKey);
        JSONObject jsonObject = JSONObject.parseObject(obj);
        logger.info("请求前funid=="+funid+"data="+data);
        String response = httpClientUtil.postBody(ylzConfigUrl,jsonObject);
        ylzHttpLogDO.setResponseEncrpty(response);
        logger.info("请求后response=="+response);
        if (response!=null&&response!=""){
            JSONObject result = JSONObject.parseObject(response);
            if (result.getString("flag").equalsIgnoreCase("1")){
                String dataResult = result.getString("encrypt_data");
                result.remove("encrypt_data");
                if (dataResult!=null&&dataResult!=""){
                    String decryptResult = AES.aesDecrypt(dataResult,ylzConfigEncryptKey);
                    JSONObject dataObject = JSONObject.parseObject(decryptResult);
                    result.put("encrypt_data",dataObject);
                    response = result.toString();
                    token = dataObject.getString("access_token");
                }
            }
        }
        ylzHttpLogDO.setCode(funid);
        ylzHttpLogDO.setName("获取AccessToken");
        ylzHttpLogDO.setRequest(data.toJSONString());
        ylzHttpLogDO.setRequestEncrpty(obj);
        ylzHttpLogDO.setResponse(response);
        ylzHttpLogDO.setCreateTime(new Date());
        ylzHttpLogDao.save(ylzHttpLogDO);
        
        return token;
    }
    /**
     * 2.2.1渠道应用是否已授权(N20.17.01.01)
     *
     * @param patient
     * @return
     * @throws Exception
     */
    public String authorized(String patient) throws Exception{
        String funid = "N20.17.01.01";
        BasePatientDO patientDO = patientDao.findById(patient).get();
        if (patientDO==null){
            throw new Exception("患者信息不存在");
        }
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        if (patientMappingDO==null){
            throw new Exception("患者his信息不存在");
        }
        JSONObject data = new JSONObject();
        data.put("service_id","350203");
        data.put("name",patientDO.getName());
        data.put("idcard",patientDO.getIdcard());
        data.put("cert_type","01");//TODO
        data.put("phone",patientDO.getMobile());
        data.put("user_id",patientMappingDO.getMappingCode());
        String result = requestYlz(data,funid,"渠道应用是否已授权");
        return result;
    }
    /**
     * 2.2.1渠道应用是否已授权(N20.17.01.01)
     *
     * @param patient
     * @return
     * @throws Exception
     */
    public String authorizedToEntrace(String patient) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"authorized?patient="+patient;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.2.2医保在线服务授权表单(H5表单/小程序)(N20.17.01.02)
     *
     * @param patient
     * @return
     * @throws Exception
     */
    public String medicareOnline(String patient) throws Exception{
        String funid = "N20.17.01.02";
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigRedirectUrl").get();
        if (hospitalSysDictDO==null){
            throw new Exception("回调地址为空!");
        }
        BasePatientDO patientDO = patientDao.findById(patient).get();
        if (patientDO==null){
            throw new Exception("患者信息不存在");
        }
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        if (patientMappingDO==null){
            throw new Exception("患者his信息不存在");
        }
        JSONObject data = new JSONObject();
        data.put("service_id","350203");
        data.put("name",patientDO.getName());
        data.put("idcard",patientDO.getIdcard());
        data.put("cert_type","01");//TODO
        data.put("phone",patientDO.getMobile());
        data.put("user_id",patientMappingDO.getMappingCode());
        data.put("redirect_url",hospitalSysDictDO.getDictValue());
        String result = requestYlz(data,funid,"医保在线服务授权表单");
        return result;
    }
    /**
     * 2.2.2医保在线服务授权表单(H5表单/小程序)(N20.17.01.02)
     *
     * @param patient
     * @return
     * @throws Exception
     */
    public String medicareOnlineToEntrance(String patient) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"medicareOnline?patient="+patient;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.2.3医保在线服务授权表单(H5表单/小程序)(N20.17.01.03)
     *
     * @param patient
     * @return
     * @throws Exception
     */
    public String medicareOnlineBase64(String patient) throws Exception{
        String funid = "N20.17.01.03";
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigRedirectUrl").get();
        if (hospitalSysDictDO==null){
            throw new Exception("回调地址为空!");
        }
        BasePatientDO patientDO = patientDao.findById(patient).get();
        if (patientDO==null){
            throw new Exception("患者信息不存在");
        }
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        if (patientMappingDO==null){
            throw new Exception("患者his信息不存在");
        }
        JSONObject data = new JSONObject();
        data.put("service_id","350203");
        data.put("name",patientDO.getName());
        data.put("idcard",patientDO.getIdcard());
        data.put("cert_type","01");//TODO
        data.put("phone",patientDO.getMobile());
        data.put("user_id",patientMappingDO.getMappingCode());
        data.put("redirect_url",hospitalSysDictDO.getDictValue());
        String result = requestYlz(data,funid,"医保在线服务授权表单");
        return result;
    }
    /**
     * 2.2.3医保在线服务授权表单(H5表单/小程序)(N20.17.01.03)
     *
     * @param patient
     * @return
     * @throws Exception
     */
    public String medicareOnlineBase64ToEntrance(String patient) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"medicareOnline?patient="+patient;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.5.1医保挂号(N20.17.04.01)
     *
     * 返回值
     *
     * @param outpatientId 系统id
     * @return
     * @throws Exception
     */
    public String register(String outpatientId) throws Exception{
        String funid = "N20.17.04.01";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("上传医保挂号失败:结算信息为空!");
        }
        JSONObject data = new JSONObject();
        data.put("region_code",ylzMedicalRelationDO.getRegionCode());//参保地区划代码
        data.put("idcard",ylzMedicalRelationDO.getIdcard());//证件号码
        data.put("name",ylzMedicalRelationDO.getName());//姓名
        data.put("cert_type",ylzMedicalRelationDO.getCertType());//证件类型
        data.put("medical_mode",ylzMedicalRelationDO.getMedicalMode());//医疗就诊方式
        data.put("medical_type",ylzMedicalRelationDO.getMedicalType());//医疗类别
        data.put("his_serial",ylzMedicalRelationDO.getHisSerial());//his流水号
        data.put("his_dept_code",ylzMedicalRelationDO.getHisDeptCode());//his内部科室编码
        data.put("his_dept_name",ylzMedicalRelationDO.getHisDeptName());//his内部科室名称
        data.put("emergency_sign",ylzMedicalRelationDO.getEmergencySign());//急诊标志0 否,1 是
        data.put("trauma_sign",ylzMedicalRelationDO.getTraumaSign());//外伤标志0 否,1 是
        data.put("date", DateUtil.dateToStrFormatLong(ylzMedicalRelationDO.getDate()));//实际门诊/入院日期 若为空,默认取系统时间
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).get();
        if (outpatientDO!=null){
            BaseDoctorDO doctorDO = doctorDao.findById(outpatientDO.getDoctor()).get();
            if (doctorDO!=null){
                data.put("atddr_no",doctorDO.getAtddrNo());
                data.put("dr_name",doctorDO.getName());
            }
        }
        String result = requestYlz(data,funid,"医保挂号");
        if (result==null){
            throw new Exception("上传医保挂号失败!");
        }
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            String insuranceSerial = encryptData.getString("insurance_serial");
            ylzMedicalRelationDO.setInsuranceSerial(insuranceSerial);
            ylzMedicalRelationDO.setInsuranceType(encryptData.getString("insurance_type"));
            ylzMedicalRelationDO.setInsuranceTypeName(encryptData.getString("insurance_type_name"));
            ylzMedicailRelationDao.save(ylzMedicalRelationDO);
            logger.info("医保挂号流水号保存成功");
        }
        return result;
    }
    /**
     * 2.5.1医保挂号(N20.17.04.01)
     *
     * 返回值
     *
     * @param outpatientId 门诊id
     * @return
     * @throws Exception
     */
    public String registerToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"register?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.5.2医保挂号冲销(N20.17.04.02)
     *
     * 返回值
     *
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String registerBack(String outpatientId) throws Exception{
        String funid = "N20.17.04.02";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("医保挂号冲销失败:结算信息为空!");
        }
        JSONObject data = new JSONObject();
        data.put("region_code",ylzMedicalRelationDO.getRegionCode());//参保地区划代码
        data.put("idcard",ylzMedicalRelationDO.getIdcard());//证件号码
        data.put("name",ylzMedicalRelationDO.getName());//姓名
        data.put("cert_type",ylzMedicalRelationDO.getCertType());//证件类型
        data.put("medical_mode",ylzMedicalRelationDO.getMedicalMode());//医疗就诊方式
        data.put("medical_type",ylzMedicalRelationDO.getMedicalType());//医疗类别
        data.put("his_serial",ylzMedicalRelationDO.getHisSerial());//his流水号
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//医保流水号
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        String result = requestYlz(data,funid,"医保挂号冲销");
        if (result==null){
            throw new Exception("上传医保挂号冲销失败!");
        }
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            String invalidSerial = encryptData.getString("refund_serial");
            logger.info("医保挂号冲销流水号保存成功");
        }
        YlzMedicalRelationRefundDO ylzMedicalRelationRefundDO = new YlzMedicalRelationRefundDO();
        ylzMedicalRelationRefundDO.setCode(funid);
        ylzMedicalRelationRefundDO.setName("医保挂号冲销");
        ylzMedicalRelationRefundDO.setRequest(data.toJSONString());
        ylzMedicalRelationRefundDO.setResponse(result);
        ylzMedicalRelationRefundDO.setYlzMedicalRelationId(ylzMedicalRelationDO.getId());
        ylzMedicalRelationRefundDO.setCreateTime(new Date());
        ylzMedicailRelationRefundDao.save(ylzMedicalRelationRefundDO);
        return result;
    }
    /**
     * 2.5.2医保挂号冲销(N20.17.04.02)
     *
     * 返回值
     *
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String registerBackToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"registerBack?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.5.3医保费用明细上传(N20.17.04.03)
     *
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String feeDetailUpload(String outpatientId) throws Exception{
        String funid = "N20.17.04.03";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("医保费用明细上传:结算信息为空!");
        }
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).get();
        BaseDoctorDO doctorDO = new BaseDoctorDO();
        if (outpatientDO!=null){
            doctorDO = doctorDao.findById(outpatientDO.getDoctor()).get();
        }
        JSONObject data = new JSONObject();
        data.put("region_code",ylzMedicalRelationDO.getRegionCode());//参保地区划代码
        data.put("name",ylzMedicalRelationDO.getName());//姓名
        data.put("idcard",ylzMedicalRelationDO.getIdcard());//证件号码
        data.put("cert_type",ylzMedicalRelationDO.getCertType());//证件类型 TODO
        data.put("medical_mode",ylzMedicalRelationDO.getMedicalMode());//医疗就诊方式
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//医保流水号
        data.put("his_serial",ylzMedicalRelationDO.getHisSerial());//his流水号
        data.put("item_count",ylzMedicalRelationDO.getItemCount());//明细项目数量
        data.put("total_amount",ylzMedicalRelationDO.getTotalAmount());//医疗费总金额
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        List<YlzMedicalIcdDO> ylzMedicalIcdDOList = ylzMedicailIcdDao.findByMedicalId(ylzMedicalRelationDO.getId());
        if (ylzMedicalIcdDOList==null){
            throw new Exception("医保费用明细上传:诊断结算信息为空!");
        }
        JSONArray icdArray = new JSONArray();
        for (YlzMedicalIcdDO ylzMI:ylzMedicalIcdDOList){
            JSONObject icdObj = new JSONObject();
            icdObj.put("disease_code_icd10",ylzMI.getDiseaseCodeIcd10());//诊断或症状编码
            icdObj.put("disease_name_icd10",ylzMI.getDiseaseNameIcd10());//诊断或症状名称
            icdObj.put("disease_type",ylzMI.getDiseaseType());//诊断或症状类型
            icdObj.put("disease_order",ylzMI.getDiseaseOrder());//诊断或症状序号
            icdArray.add(icdObj);
        }
        data.put("zdlist",icdArray);
        List<YlzMedicalMxDO> ylzMedicalMxDOS = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());
        if (ylzMedicalIcdDOList==null){
            throw new Exception("医保费用明细上传:诊断结算信息为空!");
        }
        JSONArray infoArray = new JSONArray();
        for (YlzMedicalMxDO ylzMedicalMxDO:ylzMedicalMxDOS){
                JSONObject infoObj = new JSONObject();
                infoObj.put("prescription_code",ylzMedicalMxDO.getPrescriptionCode());//医院处方编号
                infoObj.put("his_detail_sn",ylzMedicalMxDO.getHisDetailSn());//his处方明细流水号
                infoObj.put("item_name",ylzMedicalMxDO.getItemName());//医保项目名称
                infoObj.put("item_code",ylzMedicalMxDO.getItemCode());//医保项目编码
                infoObj.put("specification_type",ylzMedicalMxDO.getSpecificationType());//规格型号
                infoObj.put("dosage_form",ylzMedicalMxDO.getDosageForm());//剂型
                infoObj.put("charge_unit",ylzMedicalMxDO.getChargeUnit());//单位
                infoObj.put("price",ylzMedicalMxDO.getPrice());//单价
                infoObj.put("amount",ylzMedicalMxDO.getAmount());//数量
                infoObj.put("total_money",ylzMedicalMxDO.getTotalMoney());//金额
                infoObj.put("prescription_date", DateUtil.dateToStrLong(ylzMedicalMxDO.getPrescriptionDate()));//处方日期
                infoObj.put("his_dept_code",ylzMedicalMxDO.getHisDeptCode());//his内部科室编码
                infoObj.put("his_dept_name",ylzMedicalMxDO.getHisDeptName());//his内部科室名称
                infoObj.put("medical_per_name",ylzMedicalMxDO.getMedicalPerName());//医疗服务人员姓名
                infoObj.put("medical_per_id",doctorDO.getAtddrNo());//医疗服务人员证件号码
                infoObj.put("limit_type",ylzMedicalMxDO.getLimitType());//限制范围类别
                infoObj.put("actg_date",DateUtil.dateToStr(ylzMedicalMxDO.getActgDate(),DateUtil.YYYYMMDD));//记帐日期
                infoObj.put("his_item_name",ylzMedicalMxDO.getHisItemName());//HIS院内项目名称
                infoObj.put("his_item_code",ylzMedicalMxDO.getHisItemCode());//HIS院内项目编码
                infoObj.put("clerk_days",DateUtil.dateToStrLong(ylzMedicalMxDO.getClerkDays()));//记帐日期
                infoObj.put("people_type",ylzMedicalMxDO.getPeopleType());//医保服务人员类别
                infoArray.add(infoObj);
        }
        data.put("mxlist",infoArray);
        String result = requestYlz(data,funid,"医保费用明细上传");
        if (result==null){
            throw new Exception("医保费用明细上传失败!");
        }
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            String detailSerial = encryptData.getString("detail_serial");
            ylzMedicalRelationDO.setDetailSerial(detailSerial);
            ylzMedicailRelationDao.save(ylzMedicalRelationDO);
            logger.info("医保费用明细上传保存成功");
        }else {
            throw new Exception(object.getString("cause"));
        }
        return result;
    }
    /**
     * 2.5.3医保费用明细上传(N20.17.04.03)
     *
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String feeDetailUploadToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"feeDetailUpload?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.5.4医保费用明细上传冲销(N20.17.04.04)
     *
     * 返回值
     *
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String feeDetailRefund(String outpatientId,String remark) throws Exception{
        String funid = "N20.17.04.04";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("医保费用明细上传:结算信息为空!");
        }
        JSONObject data = new JSONObject();
        data.put("region_code",ylzMedicalRelationDO.getRegionCode());//参保地区划代码
        data.put("idcard",ylzMedicalRelationDO.getIdcard());//证件号码
        data.put("name",ylzMedicalRelationDO.getName());//姓名
        data.put("medical_mode",ylzMedicalRelationDO.getMedicalMode());//医疗就诊方式
        data.put("medical_type",ylzMedicalRelationDO.getMedicalType());//医疗类别
        data.put("detail_serial",ylzMedicalRelationDO.getDetailSerial());//医保明细流水号
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//医保流水号
        data.put("invalidation_reason",remark);//作废原因
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        String result = requestYlz(data,funid,"医保费用明细上传冲销");
        if (result==null){
            throw new Exception("医保费用明细上传冲销失败!");
        }
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            logger.info("医保费用明细上传冲销保存成功");
        }
        YlzMedicalRelationRefundDO ylzMedicalRelationRefundDO = new YlzMedicalRelationRefundDO();
        ylzMedicalRelationRefundDO.setCode(funid);
        ylzMedicalRelationRefundDO.setName("医保费用明细上传冲销");
        ylzMedicalRelationRefundDO.setRequest(data.toJSONString());
        ylzMedicalRelationRefundDO.setResponse(result);
        ylzMedicalRelationRefundDO.setYlzMedicalRelationId(ylzMedicalRelationDO.getId());
        ylzMedicalRelationRefundDO.setCreateTime(new Date());
        ylzMedicailRelationRefundDao.save(ylzMedicalRelationRefundDO);
        return result;
    }
    /**
     * 2.5.4医保费用明细上传冲销(N20.17.04.04)
     *
     * 返回值
     *
     * @param outpatientId 门诊id
     * @return
     * @throws Exception
     */
    public String feeDetailRefundToEntrance(String outpatientId,String remark) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"feeDetailRefund?outpatientId="+outpatientId+"&remark="+remark;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.5.5医保预结算服务(N20.17.04.05)
     *
     * 返回值
     *
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public YlzMedicalRelationDO preSettlement(String outpatientId) throws Exception{
        String funid = "N20.17.04.05";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("医保费用明细上传:结算信息为空!");
        }
        JSONObject data = new JSONObject();
        data.put("region_code",ylzMedicalRelationDO.getRegionCode());//参保地区划代码
        data.put("idcard",ylzMedicalRelationDO.getIdcard());//证件号码
        data.put("name",ylzMedicalRelationDO.getName());//姓名
        data.put("cert_type",ylzMedicalRelationDO.getCertType());//证件类型
        data.put("medical_mode",ylzMedicalRelationDO.getMedicalMode());//医疗就诊方式
        data.put("medical_type",ylzMedicalRelationDO.getMedicalType());//医疗类别
        data.put("his_bill_serial",ylzMedicalRelationDO.getHisBillSerial());//his收费单据流水号
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//医保流水号
        data.put("settlement_sign",0);//结算标识
        data.put("date",DateUtil.dateToStrFormatShort(ylzMedicalRelationDO.getDate()));//实际就诊日期
        data.put("leave_method","09");//离院方式
        data.put("pre_count",ylzMedicalRelationDO.getPreCount());//处方项目数
        data.put("total_amount",ylzMedicalRelationDO.getTotalAmount());//医疗费总金额
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        data.put("his_serial",ylzMedicalRelationDO.getHisSerial());//his流水号
        data.put("doctor_level",ylzMedicalRelationDO.getDoctorLevel());//医师诊查费等级
        data.put("trt_fee_level",ylzMedicalRelationDO.getDoctorLevel());//医师诊查费等级
        data.put("dept_code",ylzMedicalRelationDO.getDeptCode());//科室编码
        data.put("disease_code",ylzMedicalRelationDO.getDiseaseCode());//病种编码
        data.put("charge_qty",1);//本次收费次数
        JSONArray array = new JSONArray();
        JSONObject object = new JSONObject();
        object.put("detail_serial",ylzMedicalRelationDO.getDetailSerial());
        array.add(object);
        data.put("cflist",array);
        String result = requestYlz(data,funid,"医保预结算服务");
        if (result==null){
            throw new Exception("医保预结算服务失败!");
        }else {
            JSONObject resObj = JSONObject.parseObject(result);
            if (resObj.getString("flag").equalsIgnoreCase("1")){
                JSONObject jsonObject = resObj.getJSONObject("encrypt_data");
                ylzMedicalRelationDO.setAccountBalance(jsonObject.getString("account_balance"));
                ylzMedicalRelationDO.setBillSerial(jsonObject.getString("bill_serial"));
                ylzMedicalRelationDO.setPersonalCode(jsonObject.getString("personal_code"));
                ylzMedicalRelationDO.setSex(jsonObject.getString("sex"));
                ylzMedicalRelationDO.setSexMc(jsonObject.getString("sex_mc"));
                ylzMedicalRelationDO.setPersonCash(jsonObject.getString("person_cash"));
                ylzMedicalRelationDO.setPersonAccount(jsonObject.getString("person_account"));
                ylzMedicalRelationDO.setFundPrice(jsonObject.getString("fund_price"));
                ylzMedicalRelationDO.setJkzhPay(jsonObject.getString("own_jkzh_pay"));
                ylzMedicalRelationDO.setOwnPay(jsonObject.getString("own_pay"));
                ylzMedicalRelationDO.setHospitalizationQty(jsonObject.getString("hospitalization_times"));
                ylzMedicalRelationDO.setPayDate(DateUtil.strToDate(jsonObject.getString("pay_date")+jsonObject.getString("pay_time")));
                ylzMedicalRelationDO.setInvoiceJj(jsonObject.getString("invoice_jj"));
                ylzMedicalRelationDO.setInvoiceXj(jsonObject.getString("invoice_xj"));
                ylzMedicalRelationDO.setInvoiceZh(jsonObject.getString("invoice_zh"));
                ylzMedicalRelationDO.setDiseaseCode(jsonObject.getString("disease_code"));
                ylzMedicalRelationDO.setTreatmentType(jsonObject.getString("treatment_type"));
                ylzMedicalRelationDO.setTreatmentTypeName(jsonObject.getString("treatment_type_name"));
                ylzMedicalRelationDO.setAllopatryType(jsonObject.getString("allopatry_type"));
                ylzMedicalRelationDO.setAllopatryTypeName(jsonObject.getString("allopatry_type_name"));
                ylzMedicalRelationDO.setAdministrativeArea(jsonObject.getString("administrative_area"));
                ylzMedicalRelationDO.setPayStandard(jsonObject.getString("pay_standard"));
                ylzMedicalRelationDO.setTcjjPay(jsonObject.getString("tcjj_pay"));
                ylzMedicalRelationDO.setSbjjPay(jsonObject.getString("sbjj_pay"));
                ylzMedicalRelationDO.setGwyPay(jsonObject.getString("gwy_pay"));
                ylzMedicalRelationDO.setJzfpPay(jsonObject.getString("jzfp_pay"));
                ylzMedicalRelationDO.setYljzPay(jsonObject.getString("yljz_pay"));
                ylzMedicalRelationDO.setOtherPay(jsonObject.getString("other_pay"));
                ylzMedicalRelationDO.setEnterpriseSupplement(jsonObject.getString("enterprise_supplement"));
                ylzMedicalRelationDO.setJtgjPay(jsonObject.getString("jtgj_pay"));
                ylzMedicalRelationDO.setCollector(jsonObject.getString("collector"));
                ylzMedicalRelationDO.setClrOptins(jsonObject.getString("CLR_OPTINS"));
                ylzMedicalRelationDO.setClrWay(jsonObject.getString("CLR_WAY"));
                ylzMedicalRelationDO.setClrType(jsonObject.getString("CLR_TYPE"));
                BigDecimal b1 = new BigDecimal(ylzMedicalRelationDO.getTcjjPay());
                BigDecimal b2 = new BigDecimal(ylzMedicalRelationDO.getSbjjPay());
                BigDecimal b3 = new BigDecimal(ylzMedicalRelationDO.getGwyPay());
                BigDecimal b4 = new BigDecimal(ylzMedicalRelationDO.getJzfpPay());
                BigDecimal b5 = new BigDecimal(ylzMedicalRelationDO.getYljzPay());
                BigDecimal b6 = new BigDecimal(ylzMedicalRelationDO.getOtherPay());
                BigDecimal b7 = new BigDecimal(ylzMedicalRelationDO.getEnterpriseSupplement());
                Double price = b1.add(b2).add(b3).add(b4).add(b5).add(b6).add(b7).doubleValue();
                /*Double price= Double.parseDouble(ylzMedicalRelationDO.getTcjjPay())+Double.parseDouble(ylzMedicalRelationDO.getSbjjPay())+
                        Double.parseDouble(ylzMedicalRelationDO.getGwyPay())+
                        Double.parseDouble(ylzMedicalRelationDO.getJzfpPay())+Double.parseDouble(ylzMedicalRelationDO.getYljzPay())+
                        Double.parseDouble(ylzMedicalRelationDO.getOtherPay())+Double.parseDouble(ylzMedicalRelationDO.getEnterpriseSupplement());*/
                ylzMedicalRelationDO.setMedicalPrice(price+"");
                logger.info("meidicalPrice====="+price);
                ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                JSONArray jsonArray = jsonObject.getJSONArray("fplist");
                for (int i=0;i<jsonArray.size();i++){
                    JSONObject jsonObject1 = jsonArray.getJSONObject(i);
                    YlzMedicalBillDO ylzMb = new YlzMedicalBillDO();
                    ylzMb.setMedicalId(ylzMedicalRelationDO.getId());
                    ylzMb.setInvoicePay(jsonObject1.getString("invoice_pay"));
                    ylzMb.setInvoiceType(jsonObject1.getString("invoice_type"));
                    ylzMb.setInvoiceTypeName(jsonObject1.getString("invoice_type_name"));
                    ylzMb.setProjectPay(jsonObject1.getString("project_pay"));
                    ylzMb.setOwnPay(jsonObject1.getString("own_pay"));
                    ylzMb.setSpecialPay(jsonObject1.getString("special_pay"));
                    ylzMb.setUninsurancePay(jsonObject1.getString("uninsurance_pay"));
                    ylzMb.setCreateTime(new Date());
                    ylzMedicailBillDao.save(ylzMb);
                }
            }else {
                throw new Exception(object.getString("cause"));
            }
        }
        List<YlzMedicalIcdDO> icdDOList = ylzMedicailIcdDao.findByMedicalId(ylzMedicalRelationDO.getId());
        List<YlzMedicalMxDO> mxDOList = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());
        ylzMedicalRelationDO.setYlzMedicalIcdDOList(icdDOList);
        ylzMedicalRelationDO.setYlzMedicalMxDOList(mxDOList);
        return ylzMedicalRelationDO;
    }
    /**
     * 2.5.5医保预结算服务(N20.17.04.05)
     *
     * 返回值
     *
     * @param outpatientId 门诊id
     * @return
     * @throws Exception
     */
    public YlzMedicalRelationDO preSettlementToEntrance(String outpatientId) throws Exception{
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("医保费用明细上传:结算信息为空!");
        }
        List<YlzMedicalIcdDO> icdDOList = ylzMedicailIcdDao.findByMedicalId(ylzMedicalRelationDO.getId());;
        if (icdDOList!=null){
            ylzMedicalRelationDO.setYlzMedicalIcdDOList(icdDOList);
        }
        List<YlzMedicalMxDO> mxDOList = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());;
        if (mxDOList!=null){
            ylzMedicalRelationDO.setYlzMedicalMxDOList(mxDOList);
        }
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"preSettlement?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
            JSONObject jsonObject1 = JSONObject.parseObject(result);
            if (jsonObject1.getString("flag").equalsIgnoreCase("1")){
                JSONObject encryptData = jsonObject1.getJSONObject("encrypt_data");
                String billSerial = encryptData.getString("bill_serial");
                ylzMedicalRelationDO.setInsuranceSerial(encryptData.getString("insurance_serial"));
                ylzMedicalRelationDO.setBillSerial(encryptData.getString("bill_serial"));
                ylzMedicalRelationDO.setHisBillSerial(encryptData.getString("his_bill_serial"));
                ylzMedicalRelationDO.setSexMc(encryptData.getString("sex_mc"));
                ylzMedicalRelationDO.setPersonCash(encryptData.getString("person_cash"));
                ylzMedicalRelationDO.setPersonAccount(encryptData.getString("person_account"));
                ylzMedicalRelationDO.setFundPrice(encryptData.getString("fund_price"));
                ylzMedicalRelationDO.setJkzhPay(encryptData.getString("jkzh_pay"));
                ylzMedicalRelationDO.setOwnPay(encryptData.getString("own_pay"));
                ylzMedicalRelationDO.setAccountBalance(encryptData.getString("account_balance"));
                ylzMedicalRelationDO.setHospitalizationQty(encryptData.getString("hospitalization_qty"));
                ylzMedicalRelationDO.setPayDate(DateUtil.strToDateLong(encryptData.getString("pay_date")));
                ylzMedicalRelationDO.setInvoiceJj(encryptData.getString("invoice_jj"));
                ylzMedicalRelationDO.setInvoiceXj(encryptData.getString("invoice_xj"));
                ylzMedicalRelationDO.setInvoiceZh(encryptData.getString("invoice_zh"));
                ylzMedicalRelationDO.setCreateTime(new Date());
                ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                JSONArray jsonArray = encryptData.getJSONArray("fplist");
                for (int i=0;i<jsonArray.size();i++){
                    JSONObject jsonObject = jsonArray.getJSONObject(i);
                    YlzMedicalBillDO ylzMb = new YlzMedicalBillDO();
                    ylzMb.setMedicalId(ylzMedicalRelationDO.getId());
                    ylzMb.setInvoicePay(jsonObject.getString("invoice_pay"));
                    ylzMb.setInvoiceType(jsonObject.getString("invoice_type"));
                    ylzMb.setInvoiceTypeName(jsonObject.getString("invoice_type_name"));
                    ylzMb.setProjectPay(jsonObject.getString("project_pay"));
                    ylzMb.setOwnPay(jsonObject.getString("own_pay"));
                    ylzMb.setSpecialPay(jsonObject.getString("special_pay"));
                    ylzMb.setUninsurancePay(jsonObject.getString("uninsurance_pay"));
                    ylzMb.setCreateTime(new Date());
                    ylzMedicailBillDao.save(ylzMb);
                }
                logger.info("医保预结算服务保存成功");
            }
        }else {
            return null;
        }
        return ylzMedicalRelationDO;
    }
    /**
     * 2.5.6医保结算冲销服务(N20.17.04.06)
     *
     * 返回值
     *
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String preSettlementRefundToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"feeDetailRefund?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.5.6医保结算冲销服务(N20.17.04.06)
     *
     * 返回值
     *
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String preSettlementRefund(String outpatientId) throws Exception{
        String funid = "N20.17.04.06";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("医保结算冲销上传:结算信息为空!");
        }
        JSONObject data = new JSONObject();
        data.put("region_code",ylzMedicalRelationDO.getRegionCode());//参保地区划代码
        data.put("idcard",ylzMedicalRelationDO.getIdcard());//证件号码
        data.put("name",ylzMedicalRelationDO.getName());//姓名
        data.put("cert_type",ylzMedicalRelationDO.getCertType());//证件类型
        data.put("medical_mode",ylzMedicalRelationDO.getMedicalMode());//医疗就诊方式
        data.put("bill_serial",ylzMedicalRelationDO.getBillSerial());//医保收费流水号
        data.put("his_bill_serial",ylzMedicalRelationDO.getHisSettleNo());//his收费单据流水号
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//医保流水号
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        data.put("refund_serial",ylzMedicalRelationDO.getHisSerial());//医院退费操作流水号
        String result = requestYlz(data,funid,"医保结算冲销服务");
        if (result==null){
            throw new Exception("医保结算冲销服务失败!");
        }
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            logger.info("医保结算冲销服务保存成功");
        }
        YlzMedicalRelationRefundDO ylzMedicalRelationRefundDO = new YlzMedicalRelationRefundDO();
        ylzMedicalRelationRefundDO.setCode(funid);
        ylzMedicalRelationRefundDO.setName("医保结算冲销服务");
        ylzMedicalRelationRefundDO.setRequest(data.toJSONString());
        ylzMedicalRelationRefundDO.setResponse(result);
        ylzMedicalRelationRefundDO.setYlzMedicalRelationId(ylzMedicalRelationDO.getId());
        ylzMedicalRelationRefundDO.setCreateTime(new Date());
        ylzMedicailRelationRefundDao.save(ylzMedicalRelationRefundDO);
        return result;
    }
    /**
     * 2.5.7获取医保结算页面地址(N20.17.04.07)
     *
     * 返回值
     *
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String getSettlementResultUrl(String outpatientId) throws Exception{
        String funid = "N20.17.04.07";
        JSONObject data = new JSONObject();
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("获取医保结算页面地址:结算信息为空!");
        }
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("ResultRedirectUrl").get();
        if (wlyyHospitalSysDictDO==null){
            throw new Exception("获取医保结算页面地址失败:回调地址为空");
        }
        data.put("region_code",ylzMedicalRelationDO.getRegionCode());//参保地区划代码
        data.put("name",ylzMedicalRelationDO.getName());//姓名
        data.put("idcard",ylzMedicalRelationDO.getIdcard());//证件号码
        data.put("cert_type",ylzMedicalRelationDO.getCertType());//证件类型
        data.put("medical_mode",ylzMedicalRelationDO.getMedicalMode());//医疗就诊方式
        data.put("medical_type",ylzMedicalRelationDO.getMedicalType());//医疗类别
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//
        data.put("his_bill_serial",ylzMedicalRelationDO.getHisBillSerial());//his收费单据流水号
        data.put("date",DateUtil.dateToStrFormatShort(ylzMedicalRelationDO.getDate()));//实际就诊日期
        data.put("leave_method","09");//离院方式
        data.put("pre_count",ylzMedicalRelationDO.getPreCount());//处方项目数
        data.put("total_amount",ylzMedicalRelationDO.getTotalAmount());//医疗费总金额
        data.put("person_cash",ylzMedicalRelationDO.getPersonCash());//个人现金支付金额(实付现金)
        data.put("person_account",ylzMedicalRelationDO.getPersonAccount());//个人账户支付金额
        data.put("fund_price",ylzMedicalRelationDO.getMedicalPrice());//基金支付总额
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        data.put("his_serial",ylzMedicalRelationDO.getHisSerial());//his流水号
        data.put("doctor_level",ylzMedicalRelationDO.getDoctorLevel());//医师诊查费等级
        data.put("redirect_url",wlyyHospitalSysDictDO.getDictValue());//回调地址
        data.put("disease_code",ylzMedicalRelationDO.getDiseaseCode());//病种编码
        JSONArray array = new JSONArray();
        JSONObject object = new JSONObject();
        object.put("detail_serial",ylzMedicalRelationDO.getDetailSerial());
        array.add(object);
        data.put("cflist",array);
        String result = requestYlz(data,funid,"获取医保结算页面地址");
        if (result==null){
            throw new Exception("获取医保结算页面地址失败!");
        }else {
            JSONObject resObj = JSONObject.parseObject(result);
            if (resObj.getString("flag").equalsIgnoreCase("1")){
                JSONObject jsonObject = resObj.getJSONObject("encrypt_data");
                String link_url = jsonObject.getString("link_url");
                String str1=link_url.substring(0, link_url.indexOf("="));
                String str2=link_url.substring(str1.length()+1, link_url.length());
                ylzMedicalRelationDO.setPageCode(str2);
                ylzMedicailRelationDao.save(ylzMedicalRelationDO);
            }
        }
        return result;
    }
    /**
     * 2.5.7获取医保结算页面地址(N20.17.04.07)
     *
     * 返回值
     *
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String getSettlementResultUrlToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"getSettlementResultUrl?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.5.8获取医保结算页面地址(N20.17.04.08)
     *
     * 返回值
     *
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String getSettlementResultUrlBase64(String outpatientId) throws Exception{
        String funid = "N20.17.04.08";
        JSONObject data = new JSONObject();
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("获取医保结算页面地址:结算信息为空!");
        }
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("ResultRedirectUrl").get();
        if (wlyyHospitalSysDictDO==null){
            throw new Exception("获取医保结算页面地址失败:回调地址为空");
        }
        data.put("region_code",ylzMedicalRelationDO.getRegionCode());//参保地区划代码
        data.put("name",ylzMedicalRelationDO.getName());//姓名
        data.put("idcard",ylzMedicalRelationDO.getIdcard());//证件号码
        data.put("cert_type",ylzMedicalRelationDO.getCertType());//证件类型
        data.put("medical_mode",ylzMedicalRelationDO.getMedicalMode());//医疗就诊方式
        data.put("medical_type",ylzMedicalRelationDO.getMedicalType());//医疗类别
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//
        data.put("his_bill_serial",ylzMedicalRelationDO.getHisBillSerial());//his收费单据流水号
        data.put("date",DateUtil.dateToStrFormatShort(ylzMedicalRelationDO.getDate()));//实际就诊日期
        data.put("leave_method","09");//离院方式
        data.put("pre_count",ylzMedicalRelationDO.getPreCount());//处方项目数
        data.put("total_amount",ylzMedicalRelationDO.getTotalAmount());//医疗费总金额
        data.put("person_cash",ylzMedicalRelationDO.getPersonCash());//个人现金支付金额(实付现金)
        data.put("person_account",ylzMedicalRelationDO.getPersonAccount());//个人账户支付金额
        data.put("fund_price",ylzMedicalRelationDO.getMedicalPrice());//基金支付总额
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        data.put("his_serial",ylzMedicalRelationDO.getHisSerial());//his流水号
        data.put("doctor_level",ylzMedicalRelationDO.getDoctorLevel());//医师诊查费等级
        data.put("redirect_url",wlyyHospitalSysDictDO.getDictValue());//回调地址
        String result = requestYlz(data,funid,"获取医保结算页面地址");
        if (result==null){
            throw new Exception("获取医保结算页面地址失败!");
        }
        return result;
    }
    /**
     * 2.5.8获取医保结算页面地址(N20.17.04.08)
     *
     * 返回值
     *
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String getSettlementResultUrlBase64ToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"getSettlementResultUrlBase64?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.5.8获取医保结算结果(N20.17.04.08)
     *
     * 返回值
     *
     * @param code
     * @return
     * @throws Exception
     */
    public String getSettlementResult(String code) throws Exception{
        String funid = "N20.17.04.08";
        JSONObject data = new JSONObject();
        data.put("code",code);//
        String result = requestYlz(data,funid,"获取医保结算结果");
        if (result==null){
            throw new Exception("获取医保结算结果失败!");
        }
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject jsonObject = object.getJSONObject("encrypt_data");
            String insuranceSerial = jsonObject.getString("insurance_serial");
            String billSerial = jsonObject.getString("bill_serial");
            String personCash = jsonObject.getString("person_cash");
            YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByInsuranceSerial(insuranceSerial);
            JSONObject outybsfJson = new JSONObject();
            JSONObject ybdata = new JSONObject();
            ybdata.put("respond_time",jsonObject.getString("date"));
            ybdata.put("inf_refmsgid",jsonObject.getString("personal_code"));
            ybdata.put("appname","hlwyy");
            ybdata.put("infcode",0);
            ybdata.put("refmsg_time",jsonObject.getString("date"));
            JSONObject output = new JSONObject();
            JSONArray setldetailArray = new JSONArray();
            JSONObject setldetailObj =new JSONObject();
            setldetailObj.put("fund_pay_type_name",jsonObject.getString("treatment_type_name"));
            setldetailObj.put("fund_payamt",jsonObject.getString("account_balance"));
            setldetailObj.put("fund_pay_type",jsonObject.getString("treatment_type"));
            setldetailObj.put("inscp_scp_amt",jsonObject.getString("pay_standard"));
            setldetailArray.add(setldetailObj);
            output.put("setldetail",setldetailArray);
            JSONObject setlinfoObj = new JSONObject();
            setlinfoObj.put("hifp_pay",jsonObject.getString("tcjj_pay"));
            setlinfoObj.put("clr_way",jsonObject.getString("clr_way"));
            setlinfoObj.put("mdtrt_id",jsonObject.getString("insurance_serial"));
            setlinfoObj.put("maf_pay",jsonObject.getString("yljz_pay"));
            setlinfoObj.put("fulamt_ownpay_amt",jsonObject.getString("person_cash"));
            setlinfoObj.put("acct_pay",jsonObject.getString("person_account"));
            setlinfoObj.put("clr_type",jsonObject.getString("clr_type"));
            setlinfoObj.put("fund_pay_sumamt",jsonObject.getString("fund_amount"));
            setlinfoObj.put("certno",jsonObject.getString("idcard"));
            setlinfoObj.put("setl_time",DateUtil.dateToStrLong(DateUtil.strToDate(jsonObject.getString("pay_date")+jsonObject.getString("pay_time"))));
            setlinfoObj.put("clr_optins",jsonObject.getString("clr_optins"));
            setlinfoObj.put("setl_id",jsonObject.getString("bill_serial"));
            setlinfoObj.put("acct_mulaid_pay",jsonObject.getString("jtgj_pay"));
            setlinfoObj.put("psn_type",jsonObject.getString("treatment_type"));
            setlinfoObj.put("hifdm_pay",0);
            setlinfoObj.put("hifmi_pay",0);
            setlinfoObj.put("psn_cert_type",jsonObject.getString("cert_type"));
            setlinfoObj.put("oth_pay",jsonObject.getString("other_pay"));
            setlinfoObj.put("cvlserv_flag","");
            setlinfoObj.put("age","");
            setlinfoObj.put("psn_part_amt",jsonObject.getString("person_cash"));
            setlinfoObj.put("psn_name",jsonObject.getString("sex_mc"));
            setlinfoObj.put("med_type",ylzMedicalRelationDO.getMedicalType());
            setlinfoObj.put("medins_setl_id",billSerial);
            setlinfoObj.put("act_pay_dedc",jsonObject.getString("pay_standard"));
            setlinfoObj.put("gend",jsonObject.getString("sex_mc"));
            setlinfoObj.put("cvlserv_pay",jsonObject.getString("gwy_pay"));
            setlinfoObj.put("hifes_pay",jsonObject.getString("enterprise_supplement"));
            setlinfoObj.put("balc",jsonObject.getString("account_balance"));
            setlinfoObj.put("mdtrt_cert_type",jsonObject.getString("medical_mode"));
            setlinfoObj.put("preselfpay_amt",0);
            setlinfoObj.put("psn_no",jsonObject.getString("personal_code"));
            setlinfoObj.put("psn_cash_pay",jsonObject.getString("person_cash"));
            setlinfoObj.put("insutype",ylzMedicalRelationDO.getInsuranceType());
            setlinfoObj.put("medfee_sumamt",ylzMedicalRelationDO.getTotalAmount());
            JSONObject expContent = new JSONObject();
            JSONArray fplistArray = jsonObject.getJSONArray("fplist");
            JSONArray fpArray = new JSONArray();
            for (int i=0;i<fplistArray.size();i++){
                JSONObject fplist = fplistArray.getJSONObject(i);
                JSONObject fplistObJ = new JSONObject();
                fplistObJ.put("itemSumamt",Double.parseDouble(fplist.getString("project_pay")));
                fplistObJ.put("itemClaaAmt",Double.parseDouble(fplist.getString("invoice_pay")));
                fplistObJ.put("itemClabAmt",Double.parseDouble(fplist.getString("special_pay")));
                fplistObJ.put("itemOthAmt",Double.parseDouble(fplist.getString("uninsurance_pay")));
                fplistObJ.put("itemOwnpayAmt",Double.parseDouble(fplist.getString("own_pay")));
                fplistObJ.put("medChrgitmName",fplist.getString("type_name"));
                fplistObJ.put("medChrgitmType",fplist.getString("type"));
                fpArray.add(fplistObJ);
            }
            expContent.put("fplist",fpArray);
            setlinfoObj.put("exp_content",expContent.toJSONString());
            output.put("setlinfo",setlinfoObj);
            ybdata.put("output",output);
            outybsfJson.put("data",ybdata);
            ylzMedicalRelationDO.setClrType(jsonObject.getString("clr_type"));
            ylzMedicalRelationDO.setClrWay(jsonObject.getString("clr_way"));
            ylzMedicalRelationDO.setClrOptins(jsonObject.getString("clr_optins"));
            ylzMedicalRelationDO.setOutJson(outybsfJson.toJSONString());
            if (ylzMedicalRelationDO!=null){
                if (!ylzMedicalRelationDO.getPersonCash().equalsIgnoreCase(personCash)){
                    throw new Exception("医保结算金额不一致!");
                }else {
                    ylzMedicalRelationDO.setStatus(1);
                    ylzMedicalRelationDO.setBillSerial(billSerial);
                    ylzMedicalRelationDO.setPayDate(DateUtil.strToDate(jsonObject.getString("pay_date")+jsonObject.getString("pay_time")));
                    ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                }
            }
        }
        return result;
    }
    /**
     * 2.5.8获取医保结算结果(N20.17.04.08)
     *
     * 返回值
     *
     * @param code
     * @return
     * @throws Exception
     */
    public String getSettlementResultToEntrance(String code) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"getSettlementResultUrl?code="+code;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.7.1上传用户病史病情及医学报告(N20.17.06.01)
     *
     * 返回值
     *
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String uploadMedicalHistory(String outpatientId) throws Exception{
        String funid = "N20.17.06.01";
        JSONObject data = new JSONObject();
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId).get();
        if (wlyyOutpatientDO==null){
            throw new Exception("医保上传户病史病情及医学报告失败!门诊为空");
        }
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(wlyyOutpatientDO.getRegisterNo());
        if (ylzMedicalRelationDO==null){
            throw new Exception("获取医保结算页面地址:结算信息为空!");
        }
        data.put("region_code","350200");//参保地区划代码
        data.put("idcard",wlyyOutpatientDO.getId());//身份证号
        data.put("name",wlyyOutpatientDO.getPatientName());//姓名
        data.put("cert_type","01");//证件类型
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//医保流水号
        data.put("blood_type",wlyyOutpatientDO.getBloodType());//血型
        data.put("allergy",wlyyOutpatientDO.getAllergy());//过敏史
        data.put("diagnosis",wlyyOutpatientDO.getIcd10Name());//病理诊断
        data.put("describe",wlyyOutpatientDO.getDescription());//病情描述
        data.put("difficult_cases","无");//疑难病例
        data.put("file_list_count",0);//医学报告附件数量
        data.put("data_source","53");//数据来源
        String result = requestYlz(data,funid,"上传用户病史病情及医学报告");
        if (result==null){
            throw new Exception("上传用户病史病情及医学报告失败!");
        }
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            wlyyOutpatientDO.setInsuranceMedHistserial(encryptData.getString("insurance_med_hist_serial"));
            logger.info("上传用户病史病情及医学报告保存成功");
        }
        return result;
    }
    /**
     * 2.7.1上传用户病史病情及医学报告(N20.17.06.01)
     *
     * 返回值
     *
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String uploadMedicalHistoryToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"uploadMedicalHistory?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.7.2作废用户病史病情及医学报告(N20.17.06.06)
     *
     * 返回值
     *
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String refundMedicalHistory(String outpatientId,String remark) throws Exception{
        String funid = "N20.17.06.06";
        JSONObject data = new JSONObject();
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId).get();
        if (wlyyOutpatientDO==null){
            throw new Exception("医保上传户病史病情及医学报告失败!门诊为空");
        }
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(wlyyOutpatientDO.getRegisterNo());
        if (ylzMedicalRelationDO==null){
            throw new Exception("获取医保结算页面地址:结算信息为空!");
        }
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//医保流水号
        data.put("insurance_med_hist_serial",wlyyOutpatientDO.getInsuranceMedHistserial());//医保病史上传流水号
        data.put("invalid_reason",remark);//作废原因
        data.put("data_source","53");//数据来源
        String result = requestYlz(data,funid,"作废用户病史病情及医学报告");
        if (result==null){
            throw new Exception("作废用户病史病情及医学报告失败!");
        }
        return result;
    }
    /**
     * 2.7.2作废用户病史病情及医学报告(N20.17.06.06)
     *
     * 返回值
     *
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String refundMedicalHistoryToEntrance(String outpatientId,String remark) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"refundMedicalHistory?outpatientId="+outpatientId+"&remark="+remark;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    /**
     * 2.7.3获取问诊过程数据(N20.17.06.02)
     *
     * 返回值
     *
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String uploadIcdProcess(String outpatientId) throws Exception{
        String funid = "N20.17.06.02";
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId).get();
        if (wlyyOutpatientDO==null){
            throw new Exception("获取问诊过程数据失败!门诊为空");
        }
        BaseDoctorDO doctorDO = doctorDao.findById(wlyyOutpatientDO.getDoctor()).get();
        if (doctorDO==null){
            throw new Exception("获取问诊过程数据失败!医生信息为空");
        }
        JSONObject data = new JSONObject();
        data.put("region_code","350200");//参保地区划代码
        data.put("idcard",wlyyOutpatientDO.getIdcard());//身份证号
        data.put("name",wlyyOutpatientDO.getPatientName());//姓名
        data.put("cert_type","01");//证件类型
        data.put("service_serial_id",wlyyOutpatientDO.getRegisterNo());//问诊流水号
        data.put("doctor_id_card",doctorDO.getIdcard());//医师身份证
        data.put("doctor_name",wlyyOutpatientDO.getDoctorName());//医师姓名
        /*data.put("file_list_count","");//附件总数
        data.put("filelist","");//附件列表
        data.put("file_bytes","");//二进制字节流
        data.put("file_name","");//文件名
        data.put("order_num",0);//顺序号*/
        String result = requestYlz(data,funid,"获取问诊过程数据");
        if (result==null){
            throw new Exception("获取问诊过程数据失败!");
        }
        return result;
    }
    /**
     * 2.7.3获取问诊过程数据(N20.17.06.02)
     *
     * 返回值
     *
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String uploadIcdProcessToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"uploadIcdProcess?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
        if (object.getInteger("status")==200){
            result = object.getString("obj");
        }
        return result;
    }
    public Boolean isHospitalFlag(){
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("medicalFlag").get();
        if (hospitalSysDictDO!=null){
            if (hospitalSysDictDO.getDictValue().equalsIgnoreCase("1")){
                return true;
            }else {
                return false;
            }
        }else {
            return false;
        }
    }
    /**
     * 获取用户信息(N03.00.05.16)
     *
     * 返回值
     *
     * @param code 用户信息临时串
     * @return
     * @throws Exception
     */
    public String getUserInfo(String code) throws Exception{
        String funid = "N03.00.05.16";
        JSONObject data = new JSONObject();
        data.put("code",code);//用户信息临时串
        logger.info("data"+data.toJSONString());
        String result = requestYlz(data,funid,"获取用户信息");
        if (result==null){
            throw new Exception("获取用户信息失败");
        }
        return result;
    }
    /**
     * 获取医保二维码
     *
     * @return
     * @throws UnsupportedEncodingException
     */
    public Map<String,Object> getYbImage() throws UnsupportedEncodingException {
        String no = UUID.randomUUID().toString().substring(0,30);
        YlzMedicalUserInfoDO ylzMedicalUserInfoDO = new YlzMedicalUserInfoDO();
        ylzMedicalUserInfoDO.setNo(no);
        String redirectUrl = "https://hlwyy.xmhcyy.com/hcyy/ims-wx/#/login?no="+no;
        String url = "https://service.ylbz.xm.gov.cn/xmyb/web-ixm/app/#/ecAuth?redirectUrl="+ URLEncoder.encode(redirectUrl, "UTF-8");
        ylzMedicalUserInfoDO.setUrl(url);
        ylzMedicalUserInfoDO.setCreateTime(new Date());
        ylzMedicalUserInfoDao.save(ylzMedicalUserInfoDO);
        ByteToInputStream byteToInputStream = new ByteToInputStream();
        InputStream qrcode = QrcodeUtil.createQrcode(url,300,"jpg");
        String QRCodeImg = byteToInputStream.getBase64FromInputStream(qrcode);
        Map<String,Object> map = new HashedMap();
        map.put("QRCodeImg","data:image/png;base64,"+ QRCodeImg);
        map.put("out_authorize_no",no);
        return map;
    }
    /**
     *
     * @param no
     * @param token
     * @return
     * @throws Exception
     */
    public YlzMedicalUserInfoDO updateUserInfo(String no,String token) throws Exception {
        YlzMedicalUserInfoDO ylzMedicalUserInfoDO = ylzMedicalUserInfoDao.findByNo(no);
        String result = getUserInfo(token);
        ylzMedicalUserInfoDO.setToken(token);
        ylzMedicalUserInfoDO.setJson(result);
        ylzMedicalUserInfoDO = ylzMedicalUserInfoDao.save(ylzMedicalUserInfoDO);
        JSONObject object = JSONObject.parseObject(result);
        logger.info(object.toJSONString());
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject data = object.getJSONObject("encrypt_data");
            String idcard = data.getString("idcard");
            String name = data.getString("name");
            String cardno = data.getString("cardno");
            String sex = data.getString("sex");
            ylzMedicalUserInfoDO.setIdcard(idcard);
            ylzMedicalUserInfoDO.setName(name);
            BasePatientDO patientDO =  basePatientDao.findByIdcardAndDel(idcard,"1");
            if(StringUtils.isNotBlank(idcard)&&patientDO == null){
                BasePatientDO patient = new BasePatientDO();
                String salt = UUID.randomUUID().toString().substring(0,5);
                String pw = null;
                pw = idcard.substring(idcard.length()-6);
                patient.setIdcard(idcard);
                patient.setName(name);
                patient.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                patient.setSalt(salt);
                patient.setDel("1");
                patient.setEnabled(1);
                patient.setLocked(0);
                patient.setSex(Integer.parseInt(IdCardUtil.getSexForIdcard_new(idcard)));
                patient.setCreateTime(new Date());
                patient.setUpdateTime(new Date());
                patient.setBirthday(DateUtil.strToDate(IdCardUtil.getBirthdayForIdcardStr(idcard),"yyyyMMdd"));
                patientDO = basePatientDao.save(patient);
                WlyyPatientFamilyMemberDO basePatientFamilyMemberDO = familyMemberDao.findFamilyMemberByPatientAndRelationCode(patientDO.getId(),"7");
                if (basePatientFamilyMemberDO==null){
                    basePatientFamilyMemberDO = new WlyyPatientFamilyMemberDO();
                    basePatientFamilyMemberDO.setPatient(patientDO.getId());
                    basePatientFamilyMemberDO.setFamilyRelation("7");
                    basePatientFamilyMemberDO.setFamilyRelationName("自己");
                    basePatientFamilyMemberDO.setCardType("身份证");
                    basePatientFamilyMemberDO.setCardNo(patientDO.getIdcard());
                    basePatientFamilyMemberDO.setCreateTime(new Date());
                    basePatientFamilyMemberDO.setUpdateTime(new Date());
                    basePatientFamilyMemberDO.setIsAuthorize(1);
                    basePatientFamilyMemberDO.setIsDel(1);
                    basePatientFamilyMemberDO.setFamilyMember(patientDO.getId());
                    familyMemberDao.save(basePatientFamilyMemberDO);
                }
            }else {
                basePatientDao.save(patientDO);
                WlyyPatientFamilyMemberDO basePatientFamilyMemberDO = familyMemberDao.findFamilyMemberByPatientAndRelationCode(patientDO.getId(), "7");
                if (basePatientFamilyMemberDO == null) {
                    basePatientFamilyMemberDO = new WlyyPatientFamilyMemberDO();
                    basePatientFamilyMemberDO.setPatient(patientDO.getId());
                    basePatientFamilyMemberDO.setFamilyRelation("7");
                    basePatientFamilyMemberDO.setFamilyRelationName("自己");
                    basePatientFamilyMemberDO.setCardType("身份证");
                    basePatientFamilyMemberDO.setCardNo(patientDO.getIdcard());
                    basePatientFamilyMemberDO.setCreateTime(new Date());
                    basePatientFamilyMemberDO.setUpdateTime(new Date());
                    basePatientFamilyMemberDO.setIsAuthorize(1);
                    basePatientFamilyMemberDO.setIsDel(1);
                    basePatientFamilyMemberDO.setFamilyMember(patientDO.getId());
                    familyMemberDao.save(basePatientFamilyMemberDO);
                }
            }
            logger.info("获取用户信息成功");
        }
        return ylzMedicalUserInfoDO;
    }
    /**
     * 验证医保凭证是否授权
     * @param authorizeNo
     * @return
     */
    public Map<String,Object> checkOauthQRCode(String authorizeNo) {
        YlzMedicalUserInfoDO ylzMedicalUserInfoDO = ylzMedicalUserInfoDao.findByNo(authorizeNo);
        Map<String, Object> rsMap = new HashedMap();
        if (ylzMedicalUserInfoDO != null) {
            if (StringUtils.isNoneBlank(ylzMedicalUserInfoDO.getToken())) {
                rsMap.put("sCode", "succ");
                rsMap.put("sMes", "success");
            }else {
                rsMap.put("sCode", "ing");
                rsMap.put("sMes", "正在授权");
            }
        } else {
            rsMap.put("sCode", "ing");
            rsMap.put("sMes", "正在授权");
        }
        return rsMap;
    }
}

+ 126 - 75
business/base-service/src/main/java/com/yihu/jw/healthCare/service/HealthCareService.java

@ -3,6 +3,7 @@ package com.yihu.jw.healthCare.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.sun.corba.se.spi.ior.IdentifiableFactory;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
@ -12,14 +13,13 @@ import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.healthCare.*;
import com.yihu.jw.entity.hospital.httplog.YlzHttpLogDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.healthCare.utils.AES;
import com.yihu.jw.healthCare.utils.SafeUtil;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.healthCare.*;
import com.yihu.jw.hospital.httplog.dao.YlzHttpLogDao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
@ -27,7 +27,10 @@ import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.ylzinfo.ehc.common.utils.DateUtils;
import net.sf.json.util.JSONTokener;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -36,6 +39,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -88,6 +93,8 @@ public class HealthCareService {
    private EntranceService entranceService;
    @Autowired
    private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
    @Autowired
    private YlzMedicailRelationRefundDao ylzMedicailRelationRefundDao;
    private String ylzConfigUrl;
    private String ylzConfigAppid;
@ -190,7 +197,7 @@ public class HealthCareService {
     */
    public String doctorAuthentication(String doctorId){
        try {
            BaseDoctorDO doctorDO = doctorDao.findById(doctorId).orElse(null);
            BaseDoctorDO doctorDO = doctorDao.findById(doctorId).get();
            if (doctorDO == null){
                throw new Exception("医生不存在");
            }
@ -233,11 +240,11 @@ public class HealthCareService {
     * @throws Exception
     */
    public String doctorFaceCheckInAddress(String doctorId)throws Exception{
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigFaceReturnUrl").orElse(null);
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigFaceReturnUrl").get();
        if(hospitalSysDictDO == null){
            throw new Exception("未配置回调地址");
        }
        BaseDoctorDO doctorDO = doctorDao.findById(doctorId).orElse(null);
        BaseDoctorDO doctorDO = doctorDao.findById(doctorId).get();
        if (doctorDO == null){
            throw new Exception("医生不存在");
        }
@ -263,7 +270,7 @@ public class HealthCareService {
     * 2.3.3	获取医师人脸签到数据
     */
    public String doctorFaceCheckInData(String doctorId)throws Exception{
        BaseDoctorDO doctorDO = doctorDao.findById(doctorId).orElse(null);
        BaseDoctorDO doctorDO = doctorDao.findById(doctorId).get();
        if (doctorDO == null){
            throw new Exception("医生不存在");
        }
@ -290,11 +297,11 @@ public class HealthCareService {
     * @throws Exception
     */
    public String doctorFaceCheckInAddressBase64(String doctorId)throws Exception{
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigFaceReturnUrl").orElse(null);
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigFaceReturnUrl").get();
        if(hospitalSysDictDO == null){
            throw new Exception("未配置回调地址");
        }
        BaseDoctorDO doctorDO = doctorDao.findById(doctorId).orElse(null);
        BaseDoctorDO doctorDO = doctorDao.findById(doctorId).get();
        if (doctorDO == null){
            throw new Exception("医生不存在");
        }
@ -321,15 +328,15 @@ public class HealthCareService {
     */
    public String advanceWarning(String prescriptionId){
        try {
            WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findById(prescriptionId).orElse(null);
            WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findById(prescriptionId).get();
            if (wlyyPrescriptionDO == null){
                throw new Exception("续方信息不存在");
            }
            WlyyOutpatientDO outpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId()).orElse(null);
            WlyyOutpatientDO outpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId()).get();
            if (outpatientDO == null){
                throw new Exception("门诊信息不存在");
            }
            WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigOrgCode").orElse(null);
            WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigOrgCode").get();
            if(hospitalSysDictDO == null){
                throw new Exception("未配置网点编号");
            }
@ -375,22 +382,22 @@ public class HealthCareService {
     * 2.4.2	医师开方上传
     */
    public String doctorPrescriptionUpload(String prescriptionId,String wxId) throws Exception{
        WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findById(prescriptionId).orElse(null);
        WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findById(prescriptionId).get();
        if (wlyyPrescriptionDO == null){
            throw new Exception("续方信息不存在");
        }
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId()).orElse(null);
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId()).get();
        if (outpatientDO == null){
            throw new Exception("门诊信息不存在");
        }
        BaseDoctorDO baseDoctorDO = doctorDao.findByIdAndDel(outpatientDO.getDoctor());
        BaseDoctorDO baseDoctorDO = doctorDao.findById(outpatientDO.getDoctor()).get();
        DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(outpatientDO.getDoctor());
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigOrgCode").orElse(null);
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigOrgCode").get();
        if(hospitalSysDictDO == null){
            throw new Exception("未配置网点编号");
        }
@ -630,7 +637,7 @@ public class HealthCareService {
     * 2.6.1	电子处方订单接收(N20.17.05.02)
     */
    public String electronicPrescriptionReceiving(String outpatientId)throws Exception{
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).orElse(null);
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).get();
        if (outpatientDO == null){
            throw new Exception("门诊信息不存在");
        }
@ -638,7 +645,7 @@ public class HealthCareService {
        if(expressageDOList.size()==0){
            throw new Exception("收获信息不存在");
        }
        BasePatientDO patientDO = patientDao.findById(outpatientDO.getPatient()).orElse(null);
        BasePatientDO patientDO = patientDao.findById(outpatientDO.getPatient()).get();
        if(patientDO==null){
            throw new Exception("居民信息不存在");
        }
@ -744,7 +751,7 @@ public class HealthCareService {
     *2.6.2	电子处方订单取消(N20.17.05.03)
     */
    public String electronicPrescriptionCancle(String outpatientId)throws Exception{
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).orElse(null);
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).get();
        if (outpatientDO == null){
            throw new Exception("门诊信息不存在");
        }
@ -780,7 +787,7 @@ public class HealthCareService {
     * 2.6.3 获取处方流转平台药师审方结果(N20.17.05.04)
     */
    public String pharmacistReviewResults(String outpatientId)throws Exception{
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).orElse(null);
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).get();
        if (outpatientDO == null){
            throw new Exception("门诊信息不存在");
        }
@ -809,7 +816,7 @@ public class HealthCareService {
     * 2.2.1	门诊提醒(N21.08.09.01)
     */
    public String outpatientReminder(String outpatientId,String doctorCode)throws Exception{
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).orElse(null);
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).get();
        if (outpatientDO == null){
            throw new Exception("门诊信息不存在");
        }
@ -849,7 +856,7 @@ public class HealthCareService {
     * 2.2.2	门诊事中提醒(N21.08.09.02)
     */
    public String outpatientEventReminder(String outpatientId,String doctorCode)throws Exception{
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).orElse(null);
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).get();
        if (outpatientDO == null){
            throw new Exception("门诊信息不存在");
        }
@ -997,7 +1004,7 @@ public class HealthCareService {
        ylzHttpLogDO.setResponse(response);
        ylzHttpLogDO.setCreateTime(new Date());
        ylzHttpLogDao.save(ylzHttpLogDO);
        
        return token;
    }
@ -1011,7 +1018,7 @@ public class HealthCareService {
     */
    public String authorized(String patient) throws Exception{
        String funid = "N20.17.01.01";
        BasePatientDO patientDO = patientDao.findById(patient).orElse(null);
        BasePatientDO patientDO = patientDao.findById(patient).get();
        if (patientDO==null){
            throw new Exception("患者信息不存在");
        }
@ -1060,11 +1067,11 @@ public class HealthCareService {
     */
    public String medicareOnline(String patient) throws Exception{
        String funid = "N20.17.01.02";
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigRedirectUrl").orElse(null);
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigRedirectUrl").get();
        if (hospitalSysDictDO==null){
            throw new Exception("回调地址为空!");
        }
        BasePatientDO patientDO = patientDao.findById(patient).orElse(null);
        BasePatientDO patientDO = patientDao.findById(patient).get();
        if (patientDO==null){
            throw new Exception("患者信息不存在");
        }
@ -1114,11 +1121,11 @@ public class HealthCareService {
     */
    public String medicareOnlineBase64(String patient) throws Exception{
        String funid = "N20.17.01.03";
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigRedirectUrl").orElse(null);
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigRedirectUrl").get();
        if (hospitalSysDictDO==null){
            throw new Exception("回调地址为空!");
        }
        BasePatientDO patientDO = patientDao.findById(patient).orElse(null);
        BasePatientDO patientDO = patientDao.findById(patient).get();
        if (patientDO==null){
            throw new Exception("患者信息不存在");
        }
@ -1167,9 +1174,9 @@ public class HealthCareService {
     * @return
     * @throws Exception
     */
    public String register(String outpatientId) throws Exception{
    public String register(String outpatientId,String logNo) throws Exception{
        String funid = "N20.17.04.01";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByLogNoAndOutpatientId(logNo,outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("上传医保挂号失败:结算信息为空!");
        }
@ -1187,9 +1194,9 @@ public class HealthCareService {
        data.put("trauma_sign",ylzMedicalRelationDO.getTraumaSign());//外伤标志0 否,1 是
        data.put("date", DateUtil.dateToStrFormatLong(ylzMedicalRelationDO.getDate()));//实际门诊/入院日期 若为空,默认取系统时间
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).orElse(null);
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).get();
        if (outpatientDO!=null){
            BaseDoctorDO doctorDO = doctorDao.findByIdAndDel(outpatientDO.getDoctor());
            BaseDoctorDO doctorDO = doctorDao.findById(outpatientDO.getDoctor()).get();
            if (doctorDO!=null){
                data.put("atddr_no",doctorDO.getAtddrNo());
                data.put("dr_name",doctorDO.getName());
@ -1269,6 +1276,14 @@ public class HealthCareService {
            String invalidSerial = encryptData.getString("refund_serial");
            logger.info("医保挂号冲销流水号保存成功");
        }
        YlzMedicalRelationRefundDO ylzMedicalRelationRefundDO = new YlzMedicalRelationRefundDO();
        ylzMedicalRelationRefundDO.setCode(funid);
        ylzMedicalRelationRefundDO.setName("医保挂号冲销");
        ylzMedicalRelationRefundDO.setRequest(data.toJSONString());
        ylzMedicalRelationRefundDO.setResponse(result);
        ylzMedicalRelationRefundDO.setYlzMedicalRelationId(ylzMedicalRelationDO.getId());
        ylzMedicalRelationRefundDO.setCreateTime(new Date());
        ylzMedicailRelationRefundDao.save(ylzMedicalRelationRefundDO);
        return result;
    }
@ -1302,9 +1317,9 @@ public class HealthCareService {
     * @return
     * @throws Exception
     */
    public String feeDetailUpload(String outpatientId) throws Exception{
    public String feeDetailUpload(String outpatientId,String logNo) throws Exception{
        String funid = "N20.17.04.03";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByLogNoAndOutpatientId(logNo,outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("医保费用明细上传:结算信息为空!");
        }
@ -1339,29 +1354,29 @@ public class HealthCareService {
        }
        JSONArray infoArray = new JSONArray();
        for (YlzMedicalMxDO ylzMedicalMxDO:ylzMedicalMxDOS){
                JSONObject infoObj = new JSONObject();
                infoObj.put("prescription_code",ylzMedicalMxDO.getPrescriptionCode());//医院处方编号
                infoObj.put("his_detail_sn",ylzMedicalMxDO.getHisDetailSn());//his处方明细流水号
                infoObj.put("item_name",ylzMedicalMxDO.getItemName());//医保项目名称
                infoObj.put("item_code",ylzMedicalMxDO.getItemCode());//医保项目编码
                infoObj.put("specification_type",ylzMedicalMxDO.getSpecificationType());//规格型号
                infoObj.put("dosage_form",ylzMedicalMxDO.getDosageForm());//剂型
                infoObj.put("charge_unit",ylzMedicalMxDO.getChargeUnit());//单位
                infoObj.put("price",ylzMedicalMxDO.getPrice());//单价
                infoObj.put("amount",ylzMedicalMxDO.getAmount());//数量
                infoObj.put("total_money",ylzMedicalMxDO.getTotalMoney());//金额
                infoObj.put("prescription_date", DateUtil.dateToStrLong(ylzMedicalMxDO.getPrescriptionDate()));//处方日期
                infoObj.put("his_dept_code",ylzMedicalMxDO.getHisDeptCode());//his内部科室编码
                infoObj.put("his_dept_name",ylzMedicalMxDO.getHisDeptName());//his内部科室名称
                infoObj.put("medical_per_name",ylzMedicalMxDO.getMedicalPerName());//医疗服务人员姓名
                infoObj.put("medical_per_id",ylzMedicalMxDO.getMedicalPerId());//医疗服务人员证件号码
                infoObj.put("limit_type",ylzMedicalMxDO.getLimitType());//限制范围类别
                infoObj.put("actg_date",DateUtil.dateToStr(ylzMedicalMxDO.getActgDate(),DateUtil.YYYYMMDD));//记帐日期
                infoObj.put("his_item_name",ylzMedicalMxDO.getHisItemName());//HIS院内项目名称
                infoObj.put("his_item_code",ylzMedicalMxDO.getHisItemCode());//HIS院内项目编码
                infoObj.put("clerk_days",DateUtil.dateToStrLong(ylzMedicalMxDO.getClerkDays()));//记帐日期
                infoObj.put("people_type",ylzMedicalMxDO.getPeopleType());//医保服务人员类别
                infoArray.add(infoObj);
            JSONObject infoObj = new JSONObject();
            infoObj.put("prescription_code",ylzMedicalMxDO.getPrescriptionCode());//医院处方编号
            infoObj.put("his_detail_sn",ylzMedicalMxDO.getHisDetailSn());//his处方明细流水号
            infoObj.put("item_name",ylzMedicalMxDO.getItemName());//医保项目名称
            infoObj.put("item_code",ylzMedicalMxDO.getItemCode());//医保项目编码
            infoObj.put("specification_type",ylzMedicalMxDO.getSpecificationType());//规格型号
            infoObj.put("dosage_form",ylzMedicalMxDO.getDosageForm());//剂型
            infoObj.put("charge_unit",ylzMedicalMxDO.getChargeUnit());//单位
            infoObj.put("price",ylzMedicalMxDO.getPrice());//单价
            infoObj.put("amount",ylzMedicalMxDO.getAmount());//数量
            infoObj.put("total_money",ylzMedicalMxDO.getTotalMoney());//金额
            infoObj.put("prescription_date", DateUtil.dateToStrLong(ylzMedicalMxDO.getPrescriptionDate()));//处方日期
            infoObj.put("his_dept_code",ylzMedicalMxDO.getHisDeptCode());//his内部科室编码
            infoObj.put("his_dept_name",ylzMedicalMxDO.getHisDeptName());//his内部科室名称
            infoObj.put("medical_per_name",ylzMedicalMxDO.getMedicalPerName());//医疗服务人员姓名
            infoObj.put("medical_per_id",ylzMedicalMxDO.getMedicalPerId());//医疗服务人员证件号码
            infoObj.put("limit_type",ylzMedicalMxDO.getLimitType());//限制范围类别
            infoObj.put("actg_date",DateUtil.dateToStr(ylzMedicalMxDO.getActgDate(),DateUtil.YYYYMMDD));//记帐日期
            infoObj.put("his_item_name",ylzMedicalMxDO.getHisItemName());//HIS院内项目名称
            infoObj.put("his_item_code",ylzMedicalMxDO.getHisItemCode());//HIS院内项目编码
            infoObj.put("clerk_days",DateUtil.dateToStrLong(ylzMedicalMxDO.getClerkDays()));//记帐日期
            infoObj.put("people_type",ylzMedicalMxDO.getPeopleType());//医保服务人员类别
            infoArray.add(infoObj);
        }
        data.put("mxlist",infoArray);
        String result = requestYlz(data,funid,"医保费用明细上传");
@ -1432,6 +1447,14 @@ public class HealthCareService {
        if (object.getString("flag").equalsIgnoreCase("1")){
            logger.info("医保费用明细上传冲销保存成功");
        }
        YlzMedicalRelationRefundDO ylzMedicalRelationRefundDO = new YlzMedicalRelationRefundDO();
        ylzMedicalRelationRefundDO.setCode(funid);
        ylzMedicalRelationRefundDO.setName("医保费用明细上传冲销");
        ylzMedicalRelationRefundDO.setRequest(data.toJSONString());
        ylzMedicalRelationRefundDO.setResponse(result);
        ylzMedicalRelationRefundDO.setYlzMedicalRelationId(ylzMedicalRelationDO.getId());
        ylzMedicalRelationRefundDO.setCreateTime(new Date());
        ylzMedicailRelationRefundDao.save(ylzMedicalRelationRefundDO);
        return result;
    }
@ -1468,9 +1491,9 @@ public class HealthCareService {
     * @return
     * @throws Exception
     */
    public YlzMedicalRelationDO preSettlement(String outpatientId) throws Exception{
    public YlzMedicalRelationDO preSettlement(String outpatientId,String logNo) throws Exception{
        String funid = "N20.17.04.05";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByLogNoAndOutpatientId(logNo,outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("医保费用明细上传:结算信息为空!");
        }
@ -1493,6 +1516,7 @@ public class HealthCareService {
        data.put("doctor_level",ylzMedicalRelationDO.getDoctorLevel());//医师诊查费等级
        data.put("trt_fee_level",ylzMedicalRelationDO.getDoctorLevel());//医师诊查费等级
        data.put("dept_code",ylzMedicalRelationDO.getDeptCode());//科室编码
        data.put("disease_code",ylzMedicalRelationDO.getDiseaseCode());//病种编码
        data.put("charge_qty",1);//本次收费次数
        JSONArray array = new JSONArray();
        JSONObject object = new JSONObject();
@ -1538,10 +1562,19 @@ public class HealthCareService {
                ylzMedicalRelationDO.setEnterpriseSupplement(jsonObject.getString("enterprise_supplement"));
                ylzMedicalRelationDO.setJtgjPay(jsonObject.getString("jtgj_pay"));
                ylzMedicalRelationDO.setCollector(jsonObject.getString("collector"));
                Double price= Double.parseDouble(ylzMedicalRelationDO.getTcjjPay())+Double.parseDouble(ylzMedicalRelationDO.getSbjjPay())+
                BigDecimal b1 = new BigDecimal(ylzMedicalRelationDO.getTcjjPay());
                BigDecimal b2 = new BigDecimal(ylzMedicalRelationDO.getSbjjPay());
                BigDecimal b3 = new BigDecimal(ylzMedicalRelationDO.getGwyPay());
                BigDecimal b4 = new BigDecimal(ylzMedicalRelationDO.getJzfpPay());
                BigDecimal b5 = new BigDecimal(ylzMedicalRelationDO.getYljzPay());
                BigDecimal b6 = new BigDecimal(ylzMedicalRelationDO.getOtherPay());
                BigDecimal b7 = new BigDecimal(ylzMedicalRelationDO.getEnterpriseSupplement());
                Double price = b1.add(b2).add(b3).add(b4).add(b5).add(b6).add(b7).doubleValue();
                /*Double price= Double.parseDouble(ylzMedicalRelationDO.getTcjjPay())+Double.parseDouble(ylzMedicalRelationDO.getSbjjPay())+
                        Double.parseDouble(ylzMedicalRelationDO.getGwyPay())+
                        Double.parseDouble(ylzMedicalRelationDO.getJzfpPay())+Double.parseDouble(ylzMedicalRelationDO.getYljzPay())+
                        Double.parseDouble(ylzMedicalRelationDO.getOtherPay())+Double.parseDouble(ylzMedicalRelationDO.getEnterpriseSupplement());
                        Double.parseDouble(ylzMedicalRelationDO.getOtherPay())+Double.parseDouble(ylzMedicalRelationDO.getEnterpriseSupplement());*/
                ylzMedicalRelationDO.setMedicalPrice(price+"");
                logger.info("meidicalPrice====="+price);
                ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
@ -1700,6 +1733,14 @@ public class HealthCareService {
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            logger.info("医保结算冲销服务保存成功");
        }
        YlzMedicalRelationRefundDO ylzMedicalRelationRefundDO = new YlzMedicalRelationRefundDO();
        ylzMedicalRelationRefundDO.setCode(funid);
        ylzMedicalRelationRefundDO.setName("医保结算冲销服务");
        ylzMedicalRelationRefundDO.setRequest(data.toJSONString());
        ylzMedicalRelationRefundDO.setResponse(result);
        ylzMedicalRelationRefundDO.setYlzMedicalRelationId(ylzMedicalRelationDO.getId());
        ylzMedicalRelationRefundDO.setCreateTime(new Date());
        ylzMedicailRelationRefundDao.save(ylzMedicalRelationRefundDO);
        return result;
    }
@ -1712,14 +1753,14 @@ public class HealthCareService {
     * @return
     * @throws Exception
     */
    public String getSettlementResultUrl(String outpatientId) throws Exception{
    public String getSettlementResultUrl(String outpatientId,String logNo) throws Exception{
        String funid = "N20.17.04.07";
        JSONObject data = new JSONObject();
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByLogNoAndOutpatientId(logNo,outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("获取医保结算页面地址:结算信息为空!");
        }
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("ResultRedirectUrl").orElse(null);
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("ResultRedirectUrl").get();
        if (wlyyHospitalSysDictDO==null){
            throw new Exception("获取医保结算页面地址失败:回调地址为空");
        }
@ -1742,6 +1783,7 @@ public class HealthCareService {
        data.put("his_serial",ylzMedicalRelationDO.getHisSerial());//his流水号
        data.put("doctor_level",ylzMedicalRelationDO.getDoctorLevel());//医师诊查费等级
        data.put("redirect_url",wlyyHospitalSysDictDO.getDictValue());//回调地址
        data.put("disease_code",ylzMedicalRelationDO.getDiseaseCode());//病种编码
        JSONArray array = new JSONArray();
        JSONObject object = new JSONObject();
        object.put("detail_serial",ylzMedicalRelationDO.getDetailSerial());
@ -1798,14 +1840,14 @@ public class HealthCareService {
     * @return
     * @throws Exception
     */
    public String getSettlementResultUrlBase64(String outpatientId) throws Exception{
    public String getSettlementResultUrlBase64(String outpatientId,String logNo) throws Exception{
        String funid = "N20.17.04.08";
        JSONObject data = new JSONObject();
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByLogNoAndOutpatientId(logNo,outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("获取医保结算页面地址:结算信息为空!");
        }
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("ResultRedirectUrl").orElse(null);
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("ResultRedirectUrl").get();
        if (wlyyHospitalSysDictDO==null){
            throw new Exception("获取医保结算页面地址失败:回调地址为空");
        }
@ -1883,12 +1925,21 @@ public class HealthCareService {
            JSONObject jsonObject = object.getJSONObject("encrypt_data");
            String insuranceSerial = jsonObject.getString("insurance_serial");
            String billSerial = jsonObject.getString("bill_serial");
            String personCash = jsonObject.getString("person_cash");
            String valiFlag = jsonObject.getString("vali_flag");
            YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByInsuranceSerial(insuranceSerial);
            if (ylzMedicalRelationDO!=null){
                ylzMedicalRelationDO.setStatus(1);
                ylzMedicalRelationDO.setBillSerial(billSerial);
                ylzMedicalRelationDO.setPayDate(DateUtil.strToDate(jsonObject.getString("pay_date")+jsonObject.getString("pay_time")));
                ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                if (!ylzMedicalRelationDO.getPersonCash().equalsIgnoreCase(personCash)){
                    throw new Exception("医保结算金额不一致!");
                }else {
                    if (valiFlag.equalsIgnoreCase("1")){
                        ylzMedicalRelationDO.setStatus(1);
                        ylzMedicalRelationDO.setBillSerial(billSerial);
                        ylzMedicalRelationDO.setPayDate(DateUtil.strToDate(jsonObject.getString("pay_date")+jsonObject.getString("pay_time")));
                        ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                    }
                }
            }
        }
        return result;
@ -1928,7 +1979,7 @@ public class HealthCareService {
    public String uploadMedicalHistory(String outpatientId) throws Exception{
        String funid = "N20.17.06.01";
        JSONObject data = new JSONObject();
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId).orElse(null);
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId).get();
        if (wlyyOutpatientDO==null){
            throw new Exception("医保上传户病史病情及医学报告失败!门诊为空");
        }
@ -1997,7 +2048,7 @@ public class HealthCareService {
    public String refundMedicalHistory(String outpatientId,String remark) throws Exception{
        String funid = "N20.17.06.06";
        JSONObject data = new JSONObject();
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId).orElse(null);
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId).get();
        if (wlyyOutpatientDO==null){
            throw new Exception("医保上传户病史病情及医学报告失败!门诊为空");
        }
@ -2050,11 +2101,11 @@ public class HealthCareService {
     */
    public String uploadIcdProcess(String outpatientId) throws Exception{
        String funid = "N20.17.06.02";
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId).orElse(null);
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId).get();
        if (wlyyOutpatientDO==null){
            throw new Exception("获取问诊过程数据失败!门诊为空");
        }
        BaseDoctorDO doctorDO = doctorDao.findByIdAndDel(wlyyOutpatientDO.getDoctor());
        BaseDoctorDO doctorDO = doctorDao.findById(wlyyOutpatientDO.getDoctor()).get();
        if (doctorDO==null){
            throw new Exception("获取问诊过程数据失败!医生信息为空");
        }
@ -2102,7 +2153,7 @@ public class HealthCareService {
    }
    public Boolean isHospitalFlag(){
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("medicalFlag").orElse(null);
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("medicalFlag").get();
        if (hospitalSysDictDO!=null){
            if (hospitalSysDictDO.getDictValue().equalsIgnoreCase("1")){
                return true;

+ 94 - 0
business/base-service/src/main/java/com/yihu/jw/healthCare/utils/Pkcs7Encoder.java

@ -0,0 +1,94 @@
package com.yihu.jw.healthCare.utils;//
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.util.Arrays;
import sun.misc.BASE64Encoder;
import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Security;
public class Pkcs7Encoder {
    static final String KEY_ALGORITHM = "AES";
    static final String algorithmStr = "AES/CBC/PKCS7Padding";
    private static Key key;
    static byte[] iv = new byte[]{48, 49, 48, 50, 48, 51, 48, 52, 48, 53, 48, 54, 48, 55, 48, 56};
    public Pkcs7Encoder() {
    }
    private static Cipher init(byte[] keyBytes) {
        Cipher cipher = null;
        int base = 16;
        if (keyBytes.length % base != 0) {
            int groups = keyBytes.length / base + (keyBytes.length % base != 0 ? 1 : 0);
            byte[] temp = new byte[groups * base];
            Arrays.fill(temp, (byte)0);
            System.arraycopy(keyBytes, 0, temp, 0, keyBytes.length);
            keyBytes = temp;
        }
        Security.addProvider(new BouncyCastleProvider());
        key = new SecretKeySpec(keyBytes, "AES");
        try {
            cipher = Cipher.getInstance("AES/CBC/PKCS7Padding", "BC");
        } catch (NoSuchAlgorithmException var5) {
            var5.printStackTrace();
        } catch (NoSuchPaddingException var6) {
            var6.printStackTrace();
        } catch (NoSuchProviderException var7) {
            var7.printStackTrace();
        }
        return cipher;
    }
    public static byte[] encrypt(byte[] content, byte[] keyBytes) {
        byte[] encryptedText = encryptOfDiyIV(content, keyBytes, iv);
        return encryptedText;
    }
    public static byte[] decrypt(byte[] encryptedData, byte[] keyBytes) {
        byte[] encryptedText = decryptOfDiyIV(encryptedData, keyBytes, iv);
        return encryptedText;
    }
    public static byte[] encryptOfDiyIV(byte[] content, byte[] keyBytes, byte[] ivs) {
        byte[] encryptedText = null;
        Cipher cipher = init(keyBytes);
        System.out.println("IV:" + new String(ivs));
        try {
            cipher.init(1, key, new IvParameterSpec(ivs));
            encryptedText = cipher.doFinal(content);
        } catch (Exception var6) {
            var6.printStackTrace();
        }
        return encryptedText;
    }
    public static byte[] decryptOfDiyIV(byte[] encryptedData, byte[] keyBytes, byte[] ivs) {
        byte[] encryptedText = null;
        Cipher cipher = init(keyBytes);
        System.out.println("IV:" + new String(ivs));
        try {
            cipher.init(2, key, new IvParameterSpec(ivs));
            encryptedText = cipher.doFinal(encryptedData);
        } catch (Exception var6) {
            var6.printStackTrace();
        }
        return encryptedText;
    }
    public static String base64Encode(byte[] bytes) {
        return (new BASE64Encoder()).encode(bytes);
    }
}

+ 14 - 0
business/base-service/src/main/java/com/yihu/jw/healthCare/utils/SM4Context.java

@ -0,0 +1,14 @@
package com.yihu.jw.healthCare.utils;//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
public class SM4Context {
    public int mode = 1;
    public long[] sk = new long[32];
    public boolean isPadding = true;
    public SM4Context() {
    }
}

Разница между файлами не показана из-за своего большого размера
+ 354 - 0
business/base-service/src/main/java/com/yihu/jw/healthCare/utils/SM4New.java


+ 162 - 0
business/base-service/src/main/java/com/yihu/jw/healthCare/utils/SM4Util.java

@ -0,0 +1,162 @@
package com.yihu.jw.healthCare.utils;//
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class SM4Util {
    public static final String BM = "UTF-8";
    private String secretKey = "";
    private String iv = "1234567890ABCDEF";
    private final static char[] hexArray = "0123456789ABCDEF".toCharArray();
    public SM4Util() {
    }
    public SM4Util(String secretKey) {
        this.secretKey = secretKey;
    }
    public SM4Util(String secretKey, String iv) {
        this.secretKey = secretKey;
        this.iv = iv;
    }
    public String encryptDataECB(String plainText) throws Exception {
        return this.encryptDataECB(plainText.getBytes("UTF-8"));
    }
    public String encryptDataECB(byte[] content) throws Exception {
        SM4Context ctx = new SM4Context();
        ctx.isPadding = true;
        ctx.mode = 1;
        SM4New sm4 = new SM4New();
        byte[] keyBytes = getKey(this.secretKey);
        sm4.sm4_setkey_enc(ctx, keyBytes);
        byte[] encrypted = sm4.sm4_crypt_ecb(ctx, content);
        String cipherText = byteArrToHex(encrypted);
        if (cipherText != null && cipherText.trim().length() > 0) {
            Pattern p = Pattern.compile("\\s*|\t|\r|\n");
            Matcher m = p.matcher(cipherText);
            cipherText = m.replaceAll("");
        }
        return cipherText.toUpperCase();
    }
    public String decryptDataECB(String encData) throws Exception {
        return new String(this.decryptDataECB(hexToByte(encData)));
    }
    public byte[] decryptDataECB(byte[] content) throws Exception {
        SM4Context ctx = new SM4Context();
        ctx.isPadding = true;
        ctx.mode = 0;
        SM4New sm4 = new SM4New();
        byte[] keyBytes = getKey(this.secretKey);
        sm4.sm4_setkey_dec(ctx, keyBytes);
        byte[] decrypted = sm4.sm4_crypt_ecb(ctx, content);
        return decrypted;
    }
    private static byte[] getKey(String strKey) throws Exception {
        byte[] arrBTmp = strKey.getBytes("UTF-8");
        byte[] arrB = new byte[16];
        for(int i = 0; i < arrBTmp.length && i < arrB.length; ++i) {
            arrB[i] = arrBTmp[i];
        }
        return arrB;
    }
    public String encryptDataCBC(String content) throws Exception {
        String encData = this.encryptDataCBC(content.getBytes("UTF-8"));
        return encData;
    }
    public String encryptDataCBC(byte[] content) throws Exception {
        SM4Context ctx = new SM4Context();
        ctx.isPadding = true;
        ctx.mode = 1;
        byte[] ivBytes = this.iv.getBytes("UTF-8");
        byte[] keyBytes = getKey(this.secretKey);
        SM4New sm4 = new SM4New();
        sm4.sm4_setkey_enc(ctx, keyBytes);
        byte[] encrypted = sm4.sm4_crypt_cbc(ctx, ivBytes, content);
        String cipherText = byteArrToHex(encrypted);
        if (cipherText != null && cipherText.trim().length() > 0) {
            Pattern p = Pattern.compile("\\s*|\t|\r|\n");
            Matcher m = p.matcher(cipherText);
            cipherText = m.replaceAll("");
        }
        return cipherText.toUpperCase();
    }
    public String decryptDataCBC(String content) throws Exception {
        String data = this.decryptDataCBC(hexToByte(content));
        return data;
    }
    public String decryptDataCBC(byte[] content) throws Exception {
        SM4Context ctx = new SM4Context();
        ctx.isPadding = true;
        ctx.mode = 0;
        byte[] ivBytes = this.iv.getBytes("UTF-8");
        byte[] keyBytes = getKey(this.secretKey);
        SM4New sm4 = new SM4New();
        sm4.sm4_setkey_dec(ctx, keyBytes);
        byte[] decrypted = sm4.sm4_crypt_cbc(ctx, ivBytes, content);
        return new String(decrypted, "UTF-8");
    }
    public static String byteToHex(byte[] b) {
        if (b == null) {
            throw new IllegalArgumentException("Argument b ( byte array ) is null! ");
        } else {
            String hs = "";
            String stmp = "";
            for(int n = 0; n < b.length; ++n) {
                stmp = Integer.toHexString(b[n] & 255);
                if (stmp.length() == 1) {
                    hs = hs + "0" + stmp;
                } else {
                    hs = hs + stmp;
                }
            }
            return hs.toUpperCase();
        }
    }
    public static byte[] hexToByte(String hex) throws IllegalArgumentException {
        if (hex.length() % 2 != 0) {
            throw new IllegalArgumentException();
        } else {
            char[] arr = hex.toCharArray();
            byte[] b = new byte[hex.length() / 2];
            int i = 0;
            int j = 0;
            for(int l = hex.length(); i < l; ++j) {
                String swap = "" + arr[i++] + arr[i];
                int byteint = Integer.parseInt(swap, 16) & 255;
                b[j] = (new Integer(byteint)).byteValue();
                ++i;
            }
            return b;
        }
    }
    public static String byteArrToHex(byte... bytes) {
        char[] hexChars = new char[bytes.length * 2];
        for (int j = 0; j < bytes.length; j++) {
            int v = bytes[j] & 0xFF;
            hexChars[j * 2] = hexArray[v >>> 4];
            hexChars[j * 2 + 1] = hexArray[v & 0x0F];
        }
        return new String(hexChars);
    }
}

+ 292 - 0
business/base-service/src/main/java/com/yihu/jw/healthCare/utils/YibaoJiaMi.java

@ -0,0 +1,292 @@
package com.yihu.jw.healthCare.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
/**
 * Created by Bing on 2022/12/16.
 */
public class YibaoJiaMi {
    public static String signType = "MD5";//MD5,SM3
    public static String encryptType = "PKCS7";//AES,SM4ECB,PKCS7
    public static String encryptDataSign(JSONObject plainJson,String signKey,String encryptKey){
        plainJson.put("chs_fjs_encrypt_type", encryptType);
        plainJson.put("chs_fjs_sign_type", signType);
        //签名
        {
            plainJson.remove("chs_fjs_sign");
            String signTemp = getSortSignTemp(plainJson, signKey);
            String sign = sign(signTemp, signType);
            plainJson.put("chs_fjs_sign", sign);
        }
        //加密
        {
            String context = plainJson.toJSONString();
            if (isNotBlank(context)) {
                String encryptData = encrypt(context, encryptKey, encryptType);
                plainJson.remove("data");
                plainJson.put("chs_fjs_encdata", encryptData);
            }
        }
        System.out.println("最终请求报文:" + plainJson.toJSONString());
        return plainJson.toJSONString();
    }
    public static String encryptData(JSONObject plainJson,String signKey,String encryptKey){
        plainJson.put("encrypt_type", encryptType);
        plainJson.put("sign_type", signType);
        //签名
        {
            plainJson.remove("sign");
            String signTemp = getSortSignTemp(plainJson, signKey);
            String sign = sign(signTemp, signType);
            plainJson.put("sign", sign);
        }
        //加密
        {
            String context = plainJson.getString("data");
            if (isNotBlank(context)) {
                String encryptData = encrypt(context, encryptKey, encryptType);
                plainJson.remove("data");
                plainJson.put("encrypt_data", encryptData);
            }
        }
        System.out.println("最终请求报文:" + plainJson.toJSONString());
        return plainJson.toJSONString();
    }
    public static void main(String[] args) {
        String ylzConfigAppid = "cloudxmjw";
        String ylzConfigAppSecret = "f0ce9e957371bef58735de4abe1fa274";
        String ylzConfigSignKey = "2156B331D45F53B02BFF05C3942E60D8";
        String ylzConfigEncryptKey = "3716B331D45F53B02BFF05C3942E60D8";
        JSONObject object = new JSONObject();
        JSONObject data = new JSONObject();
        String funid = "N00.00.00.01";
        data.put("appid", ylzConfigAppid);
        data.put("appsecret", ylzConfigAppSecret);
        data.put("grant_type","client_credentials");
        object.put("sign_type","md5");
        object.put("chs_fjs_appid", ylzConfigAppid);
        object.put("data",data);
        object.put("chs_fjs_funid",funid);
        String ss = encryptData(object,ylzConfigSignKey,ylzConfigEncryptKey);
        System.out.println(ss);
        System.out.println();
    }
    /**
     * 获取待签名字符串
     *
     * @param json
     * @return
     */
    public static String getSortSignTemp(JSONObject json, String key) {
        System.out.println("需要签名的报文:" + json.toJSONString());
        String signTemp = "";
        String jsonStr = JSONObject.toJSONString(json, SerializerFeature.MapSortField);
        LinkedHashMap m = JSON.parseObject(jsonStr, LinkedHashMap.class);
        Iterator<Map.Entry> iterator = m.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry entry = iterator.next();
            String strVal = "";
            if (entry.getValue() instanceof Map) {
                strVal = JSONObject.toJSONString(entry.getValue(), SerializerFeature.MapSortField);
            } else {
                if (null == entry.getValue()) {
                    strVal = "";
                } else {
                    strVal = String.valueOf(entry.getValue());
                }
            }
            signTemp += entry.getKey() + "=" + strVal + "&";
        }
        signTemp=signTemp.substring(0,signTemp.length()-1);
        signTemp = signTemp + "&key=" + key;
        System.out.println("待签名字符串:" + signTemp);
        return signTemp;
    }
    public static String sign(String signTemp, String signType) {
        switch (signType) {
            case "MD5":
                return signByMd5(signTemp);
            default:
                return null;
        }
    }
    public static String signByMd5(String signTemp) {
        System.out.println("签名类型:MD5");
        String sign = md5(signTemp, "utf-8").toUpperCase();//计算signStr的MD5值,并对结果转为大写
        System.out.println("签名结果:" + sign);
        return sign;
    }
    /**
     * MD5
     *
     * @param str
     * @param charset
     * @return
     */
    public static String md5(String str, String charset) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(str.getBytes(charset));
            byte[] b = md.digest();
            StringBuffer buf = new StringBuffer("");
            for (int offset = 0; offset < b.length; ++offset) {
                int i = b[offset];
                if (i < 0) {
                    i += 256;
                }
                if (i < 16) {
                    buf.append("0");
                }
                buf.append(Integer.toHexString(i));
            }
            str = buf.toString();
        } catch (Exception var7) {
            var7.printStackTrace();
        }
        return str;
    }
    public static String encrypt(String context, String key, String encryptType) {
        try {
            switch (encryptType) {
                case "PKCS7":
                    return encryptByPKCS7(context, key);
                case "SM4ECB":
                    return encryptBySM4ECB(context, key);
                case "AES":
                    return AES.aesEncrypt(context, key);
                default:
                    return null;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    public static String encryptByPKCS7(String context, String key) {
        System.out.println("加密模式:PKCS7");
        System.out.println("加密前:" + context);
        String encode = null;
        try {
            BASE64Encoder base64Encoder=new BASE64Encoder();
            encode=base64Encoder.encode(Pkcs7Encoder.encrypt(context.getBytes("UTF-8"), key.getBytes()));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        System.out.println("加密结果:" + encode);
        return encode;
    }
    /**
     * SM4ECB加密
     *
     * @param context
     * @param key
     * @return
     */
    public static String encryptBySM4ECB(String context, String key) {
        SM4Util sm4 = new SM4Util(key, "");
        System.out.println("加密模式:SM4ECB");
        System.out.println("加密前:" + context);
        String cipherText = null;
        try {
            cipherText = sm4.encryptDataECB(context);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("加密结果:" + cipherText);
        return cipherText;
    }
    public static String decrypt(String encryptData, String key) {
        try {
            switch (encryptType) {
                case "PKCS7":
                    return decryptByPKCS7(encryptData, key);
                case "SM4ECB":
                    return decryptBySM4ECB(encryptData, key);
                case "AES":
                    return  AES.aesDecrypt(encryptData, key);
                default:
                    return null;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    public static String decryptBySM4ECB(String encryptData, String key) {
        SM4Util sm4 = new SM4Util(key, "");
        System.out.println("解密模式:SM4ECB");
        System.out.println("解密前:" + encryptData);
        String cipherText = null;
        try {
            cipherText = sm4.decryptDataECB(encryptData);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("解密结果:" + cipherText);
        return cipherText;
    }
    public static String decryptByPKCS7(String context, String key) {
        try {
            BASE64Decoder base64Decoder=new BASE64Decoder();
            String aes7Str = new String(Pkcs7Encoder.decrypt(base64Decoder.decodeBuffer(context), key.getBytes()), "UTF-8");
            return aes7Str;
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
    public static boolean isNotBlank(String str) {
        return !isBlank(str);
    }
    public static boolean isBlank(String str) {
        int strLen;
        if (str != null && (strLen = str.length()) != 0) {
            for(int i = 0; i < strLen; ++i) {
                if (!Character.isWhitespace(str.charAt(i))) {
                    return false;
                }
            }
            return true;
        } else {
            return true;
        }
    }
}

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/family/dao/WlyyPatientFamilyMemberDao.java

@ -28,4 +28,7 @@ public interface WlyyPatientFamilyMemberDao extends JpaRepository<WlyyPatientFam
     * @return
     */
    WlyyPatientFamilyMemberDO findByPatientAndFamilyMember(String patient,String member);
    @Query("from WlyyPatientFamilyMemberDO t where t.patient = ?1 and t.familyRelation =?2 and t.isDel = 1 ")
    WlyyPatientFamilyMemberDO findFamilyMemberByPatientAndRelationCode(String patient,String familyRelation);
}

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/healthCare/YlzMedicailRelationDao.java

@ -27,4 +27,7 @@ public interface YlzMedicailRelationDao extends JpaRepository<YlzMedicalRelation
    @Query("from YlzMedicalRelationDO a where a.insuranceSerial = ?1 ")
    YlzMedicalRelationDO findByInsuranceSerial(String insuranceSerial);
    @Query("from YlzMedicalRelationDO a where a.logNo = ?1 and a.relationCode = ?2 ")
    YlzMedicalRelationDO findByLogNoAndOutpatientId(String logNo,String outpatientId);
}

+ 16 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/healthCare/YlzMedicailRelationInvoiceDao.java

@ -0,0 +1,16 @@
package com.yihu.jw.hospital.healthCare;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalRelationInvoiceDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by wangzhinan 20211003
 */
public interface YlzMedicailRelationInvoiceDao extends PagingAndSortingRepository<YlzMedicalRelationInvoiceDO, String>, JpaSpecificationExecutor<YlzMedicalRelationInvoiceDO> {
    @Query("from YlzMedicalRelationInvoiceDO a where a.medicalId = ?1 ")
    YlzMedicalRelationInvoiceDO findByMedicalId(String medicalId);
}

+ 13 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/healthCare/YlzMedicailRelationRefundDao.java

@ -0,0 +1,13 @@
package com.yihu.jw.hospital.healthCare;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalRelationRefundDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by wangzhinan 20211003
 * 医保冲销记录
 */
public interface YlzMedicailRelationRefundDao extends PagingAndSortingRepository<YlzMedicalRelationRefundDO, String>, JpaSpecificationExecutor<YlzMedicalRelationRefundDO> {
}

+ 16 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/healthCare/YlzMedicalUserInfoDao.java

@ -0,0 +1,16 @@
package com.yihu.jw.hospital.healthCare;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalUserInfoDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by wangzhinan 20211003
 */
public interface YlzMedicalUserInfoDao extends PagingAndSortingRepository<YlzMedicalUserInfoDO, String>, JpaSpecificationExecutor<YlzMedicalUserInfoDO> {
    @Query("from YlzMedicalUserInfoDO a where a.no = ?1 ")
    YlzMedicalUserInfoDO findByNo(String no);
}

+ 38 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/healthCare/YlzMedicalRelationDO.java

@ -94,6 +94,44 @@ public class YlzMedicalRelationDO extends UuidIdentityEntity {
    private Date settleDate;//his结算时间
    private String bcwkje;//本次未扣费用
    private String clrOptins;//清算经办机构
    private String clrWay;//清算方式
    private String clrType;//清算类别
    private String outJson;//海沧his需要
    public String getClrOptins() {
        return clrOptins;
    }
    public void setClrOptins(String clrOptins) {
        this.clrOptins = clrOptins;
    }
    public String getClrWay() {
        return clrWay;
    }
    public void setClrWay(String clrWay) {
        this.clrWay = clrWay;
    }
    public String getClrType() {
        return clrType;
    }
    public void setClrType(String clrType) {
        this.clrType = clrType;
    }
    public String getOutJson() {
        return outJson;
    }
    public void setOutJson(String outJson) {
        this.outJson = outJson;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name="settle_date")
    public Date getSettleDate() {

+ 77 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/healthCare/YlzMedicalRelationInvoiceDO.java

@ -0,0 +1,77 @@
package com.yihu.jw.entity.hospital.healthCare;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by wangzhinan on 20211003
 */
@Entity
@Table(name = "base_ylz_relaiton_invoice")
public class YlzMedicalRelationInvoiceDO extends UuidIdentityEntityWithOperator {
    private String medicalId;
    private String invoiceSerialNum;//发票流水号
    private String invoiceCode;//发票代码
    private String invoiceNo;//发票号码
    private String invoicePdf;//发票pdf
    private Integer status;//0开具失败1开具成功2作废
    private String result;//发票查询结果
    public String getMedicalId() {
        return medicalId;
    }
    public void setMedicalId(String medicalId) {
        this.medicalId = medicalId;
    }
    public String getInvoiceSerialNum() {
        return invoiceSerialNum;
    }
    public void setInvoiceSerialNum(String invoiceSerialNum) {
        this.invoiceSerialNum = invoiceSerialNum;
    }
    public String getInvoiceCode() {
        return invoiceCode;
    }
    public void setInvoiceCode(String invoiceCode) {
        this.invoiceCode = invoiceCode;
    }
    public String getInvoiceNo() {
        return invoiceNo;
    }
    public void setInvoiceNo(String invoiceNo) {
        this.invoiceNo = invoiceNo;
    }
    public String getInvoicePdf() {
        return invoicePdf;
    }
    public void setInvoicePdf(String invoicePdf) {
        this.invoicePdf = invoicePdf;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getResult() {
        return result;
    }
    public void setResult(String result) {
        this.result = result;
    }
}

+ 60 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/healthCare/YlzMedicalRelationRefundDO.java

@ -0,0 +1,60 @@
package com.yihu.jw.entity.hospital.healthCare;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by wangzhinan on 20211003
 */
@Entity
@Table(name = "base_ylz_medical_refund")
public class YlzMedicalRelationRefundDO extends UuidIdentityEntityWithCreateTime {
    String ylzMedicalRelationId;//医保结算系统id
    String code;//医保结算冲销接口编码
    String name;//医保结算冲销接口名称
    String request;//请求参数
    String response;//返回参数
    public String getYlzMedicalRelationId() {
        return ylzMedicalRelationId;
    }
    public void setYlzMedicalRelationId(String ylzMedicalRelationId) {
        this.ylzMedicalRelationId = ylzMedicalRelationId;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getRequest() {
        return request;
    }
    public void setRequest(String request) {
        this.request = request;
    }
    public String getResponse() {
        return response;
    }
    public void setResponse(String response) {
        this.response = response;
    }
}

+ 83 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/healthCare/YlzMedicalUserInfoDO.java

@ -0,0 +1,83 @@
package com.yihu.jw.entity.hospital.healthCare;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by wangzhinan on 20211003
 * 医保发票打印
 */
@Entity
@Table(name = "base_ylz_medical_userinfo")
public class YlzMedicalUserInfoDO extends UuidIdentityEntityWithCreateTime {
    private String url;//医保二维码url
    private String no;//认证编码
    private String token;//医保跳转返回token
    private String json;//用户信息json
    private Date createTime;//创建时间
    private String idcard;//身份证
    private String name;//姓名
    public String getNo() {
        return no;
    }
    public void setNo(String no) {
        this.no = no;
    }
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public String getToken() {
        return token;
    }
    public void setToken(String token) {
        this.token = token;
    }
    public String getJson() {
        return json;
    }
    public void setJson(String json) {
        this.json = json;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}

+ 192 - 59
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/healthCare/HealthCareEndPoint.java

@ -1,6 +1,7 @@
package com.yihu.jw.hospital.endpoint.healthCare;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.healthCare.service.HealthCareNewService;
import com.yihu.jw.healthCare.service.HealthCareService;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
@ -30,6 +31,8 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @Autowired
    private HealthCareService healthCareService;
    @Autowired
    private HealthCareNewService healthCareNewService;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Value("${wechat.id}")
    private String wechatId;
@ -49,8 +52,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.doctorAuthentication(doctorId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.doctorAuthentication(doctorId));
            }
        }catch (Exception e){
@ -62,7 +67,7 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @GetMapping(value = "doctorFaceCheckInAddress")
    @ApiOperation(value = "医师人脸签到表单地址", notes = "医师人脸签到表单地址")
    public ObjEnvelop doctorFaceCheckInAddress(@ApiParam(name = "doctorId", value = "医生id", required = true)
                                           @RequestParam(value = "doctorId",required = true) String doctorId){
                                               @RequestParam(value = "doctorId",required = true) String doctorId){
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")){
                String url = entranceHealthCareUrl + "doctorFaceCheckInAddress?doctorId="+doctorId;
@ -73,8 +78,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.doctorFaceCheckInAddress(doctorId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.doctorFaceCheckInAddress(doctorId));
            }
        }catch (Exception e){
            e.printStackTrace();
@ -85,7 +92,7 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @GetMapping(value = "doctorFaceCheckInAddressBase64")
    @ApiOperation(value = "医师人脸签到微信小程序二维码", notes = "医师人脸签到微信小程序二维码")
    public ObjEnvelop doctorFaceCheckInAddressBase64(@ApiParam(name = "doctorId", value = "医生id", required = true)
                                               @RequestParam(value = "doctorId",required = true) String doctorId){
                                                     @RequestParam(value = "doctorId",required = true) String doctorId){
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")){
                String url = entranceHealthCareUrl + "doctorFaceCheckInAddressBase64?doctorId="+doctorId;
@ -96,8 +103,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.doctorFaceCheckInAddressBase64(doctorId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.doctorFaceCheckInAddressBase64(doctorId));
            }
        }catch (Exception e){
            e.printStackTrace();
@ -108,7 +117,7 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @GetMapping(value = "doctorFaceCheckInData")
    @ApiOperation(value = "获取医师人脸签到数据", notes = "获取医师人脸签到数据")
    public ObjEnvelop doctorFaceCheckInData(@ApiParam(name = "doctorId", value = "医生id", required = true)
                                               @RequestParam(value = "doctorId",required = true) String doctorId){
                                            @RequestParam(value = "doctorId",required = true) String doctorId){
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")){
                String url = entranceHealthCareUrl + "doctorFaceCheckInData?doctorId="+doctorId;
@ -119,8 +128,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.doctorFaceCheckInData(doctorId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.doctorFaceCheckInData(doctorId));
            }
        }catch (Exception e){
@ -132,7 +143,7 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @GetMapping(value = "advanceWarning")
    @ApiOperation(value = "事前提醒", notes = "事前提醒")
    public ObjEnvelop advanceWarning(@ApiParam(name = "outpatientId", value = "门诊id", required = true)
                                            @RequestParam(value = "outpatientId",required = true) String outpatientId){
                                     @RequestParam(value = "outpatientId",required = true) String outpatientId){
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "advanceWarning?outpatientId="+outpatientId;
@ -143,8 +154,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.advanceWarning(outpatientId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.advanceWarning(outpatientId));
            }
        }catch (Exception e){
            e.printStackTrace();
@ -155,7 +168,7 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @GetMapping(value = "doctorPrescriptionUpload")
    @ApiOperation(value = "医师开方上传", notes = "医师开方上传")
    public ObjEnvelop doctorPrescriptionUpload(@ApiParam(name = "prescriptionId", value = "处方id", required = true)
                                     @RequestParam(value = "prescriptionId",required = true) String prescriptionId){
                                               @RequestParam(value = "prescriptionId",required = true) String prescriptionId){
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "doctorPrescriptionUpload?outpatientId="+prescriptionId;
@ -166,8 +179,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.doctorPrescriptionUpload(prescriptionId,wechatId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.doctorPrescriptionUpload(prescriptionId,wechatId));
            }
        }catch (Exception e){
            e.printStackTrace();
@ -178,9 +193,9 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @GetMapping(value = "doctorPrescriptionUploadCancle")
    @ApiOperation(value = "医师开方上传取消", notes = "医师开方上传取消")
    public ObjEnvelop doctorPrescriptionUploadCancle(@ApiParam(name = "prescriptionId", value = "处方id", required = true)
                                               @RequestParam(value = "prescriptionId",required = true) String prescriptionId,
                                               @ApiParam(name = "cancelReason",value="取消原因",required = true)
                                               @RequestParam(value = "cancelReason",required = true) String cancelReason){
                                                     @RequestParam(value = "prescriptionId",required = true) String prescriptionId,
                                                     @ApiParam(name = "cancelReason",value="取消原因",required = true)
                                                     @RequestParam(value = "cancelReason",required = true) String cancelReason){
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "doctorPrescriptionUploadCancle?prescriptionId="+prescriptionId+"&cancelReason="+cancelReason;
@ -191,8 +206,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.doctorPrescriptionUploadCancle(prescriptionId,cancelReason));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.doctorPrescriptionUploadCancle(prescriptionId,cancelReason));
            }
        }catch (Exception e){
            e.printStackTrace();
@ -203,7 +220,7 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @GetMapping(value = "electronicPrescriptionReceiving")
    @ApiOperation(value = "电子处方订单接收", notes = "电子处方订单接收")
    public ObjEnvelop electronicPrescriptionReceiving(@ApiParam(name = "outpatientId", value = "门诊id", required = true)
                                                     @RequestParam(value = "outpatientId",required = true) String outpatientId)throws Exception{
                                                      @RequestParam(value = "outpatientId",required = true) String outpatientId)throws Exception{
        if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
            String url = entranceHealthCareUrl + "electronicPrescriptionReceiving?outpatientId="+outpatientId;
            String infoResponse = httpClientUtil.get(url,"GBK");
@ -213,15 +230,17 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
            }else {
                return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
            }
        }else {
        }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
            return ObjEnvelop.getSuccess("ok",healthCareService.electronicPrescriptionReceiving(outpatientId));
        }else {
            return ObjEnvelop.getSuccess("ok",healthCareNewService.electronicPrescriptionReceiving(outpatientId));
        }
    }
    @GetMapping(value = "electronicPrescriptionCancle")
    @ApiOperation(value = "电子处方订单取消", notes = "电子处方订单取消")
    public ObjEnvelop electronicPrescriptionCancle(@ApiParam(name = "outpatientId", value = "门诊id", required = true)
                                                      @RequestParam(value = "outpatientId",required = true) String outpatientId)throws Exception{
                                                   @RequestParam(value = "outpatientId",required = true) String outpatientId)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "electronicPrescriptionCancle?outpatientId="+outpatientId;
@ -232,8 +251,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.electronicPrescriptionCancle(outpatientId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.electronicPrescriptionCancle(outpatientId));
            }
        }catch (Exception e){
@ -245,7 +266,7 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @GetMapping(value = "pharmacistReviewResults")
    @ApiOperation(value = "获取处方流转平台药师审方结果", notes = "获取处方流转平台药师审方结果")
    public ObjEnvelop pharmacistReviewResults(@ApiParam(name = "outpatientId", value = "门诊id", required = true)
                                                      @RequestParam(value = "outpatientId",required = true) String outpatientId)throws Exception{
                                              @RequestParam(value = "outpatientId",required = true) String outpatientId)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "pharmacistReviewResults?outpatientId="+outpatientId;
@ -256,8 +277,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.pharmacistReviewResults(outpatientId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.pharmacistReviewResults(outpatientId));
            }
        }catch (Exception e){
@ -269,9 +292,9 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @GetMapping(value = "outpatientReminder")
    @ApiOperation(value = "门诊提醒", notes = "门诊提醒")
    public ObjEnvelop outpatientReminder(@ApiParam(name = "outpatientId", value = "处方id", required = true)
                                                     @RequestParam(value = "outpatientId",required = true) String outpatientId,
                                                     @ApiParam(name = "doctorCode",value="医保医生code",required = true)
                                                     @RequestParam(value = "doctorCode",required = true) String doctorCode)throws Exception{
                                         @RequestParam(value = "outpatientId",required = true) String outpatientId,
                                         @ApiParam(name = "doctorCode",value="医保医生code",required = true)
                                         @RequestParam(value = "doctorCode",required = true) String doctorCode)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "outpatientReminder?outpatientId="+outpatientId+"&doctorCode="+doctorCode;
@ -282,8 +305,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.outpatientReminder(outpatientId,doctorCode));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.outpatientReminder(outpatientId,doctorCode));
            }
        }catch (Exception e){
@ -296,9 +321,9 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @GetMapping(value = "outpatientEventReminder")
    @ApiOperation(value = "门诊事中提醒", notes = "门诊事中提醒")
    public ObjEnvelop outpatientEventReminder(@ApiParam(name = "outpatientId", value = "处方id", required = true)
                                                     @RequestParam(value = "outpatientId",required = true) String outpatientId,
                                                     @ApiParam(name = "doctorCode",value="医保医生code",required = true)
                                                     @RequestParam(value = "doctorCode",required = true) String doctorCode)throws Exception{
                                              @RequestParam(value = "outpatientId",required = true) String outpatientId,
                                              @ApiParam(name = "doctorCode",value="医保医生code",required = true)
                                              @RequestParam(value = "doctorCode",required = true) String doctorCode)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "outpatientEventReminder?outpatientId="+outpatientId+"&doctorCode="+doctorCode;
@ -309,8 +334,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.outpatientEventReminder(outpatientId,doctorCode));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.outpatientEventReminder(outpatientId,doctorCode));
            }
        }catch (Exception e){
@ -332,8 +359,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.getYlzToken());
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.getYlzToken());
            }
        }catch (Exception e){
@ -346,7 +375,7 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @PostMapping(value = "/authorized")
    @ApiOperation(value = "渠道应用是否已授权", notes = "渠道应用是否已授权")
    public ObjEnvelop authorized(@ApiParam(name = "patient", value = "患者id", required = true)
                                     @RequestParam(value = "patient", required = true)String patient)throws Exception{
                                 @RequestParam(value = "patient", required = true)String patient)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "authorized?patient="+patient;
@ -357,10 +386,13 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.authorized(patient));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.authorized(patient));
            }
        }catch (Exception e){
            e.printStackTrace();
            return failedObjEnvelopException(e);
@ -370,7 +402,7 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @PostMapping(value = "/medicareOnline")
    @ApiOperation(value = "医保在线服务授权表单(H5表单/小程序)(N20.17.01.02)", notes = "医保在线服务授权表单(H5表单/小程序)(N20.17.01.02)")
    public ObjEnvelop medicareOnline(@ApiParam(name = "patient", value = "患者id", required = true)
                                 @RequestParam(value = "patient", required = true)String patient)throws Exception{
                                     @RequestParam(value = "patient", required = true)String patient)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "medicareOnline?patient="+patient;
@ -381,8 +413,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.medicareOnline(patient));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.medicareOnline(patient));
            }
        }catch (Exception e){
@ -394,7 +428,7 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @PostMapping(value = "/medicareOnlineBase64")
    @ApiOperation(value = "医保在线服务授权表单(H5表单/小程序)(N20.17.01.03)", notes = "医保在线服务授权表单(H5表单/小程序)(N20.17.01.03)")
    public ObjEnvelop medicareOnlineBase64(@ApiParam(name = "patient", value = "患者id", required = true)
                                     @RequestParam(value = "patient", required = true)String patient)throws Exception{
                                           @RequestParam(value = "patient", required = true)String patient)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "medicareOnlineBase64?patient="+patient;
@ -405,8 +439,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.medicareOnlineBase64(patient));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.medicareOnlineBase64(patient));
            }
        }catch (Exception e){
            e.printStackTrace();
@ -417,7 +453,9 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @PostMapping(value = "/register")
    @ApiOperation(value = "2.5.1医保挂号(N20.17.04.01)", notes = "2.5.1医保挂号(N20.17.04.01)")
    public ObjEnvelop register(@ApiParam(name = "outpatientId", value = "门诊id", required = true)
                                     @RequestParam(value = "outpatientId", required = true)String outpatientId)throws Exception{
                               @RequestParam(value = "outpatientId", required = true)String outpatientId,
                               @ApiParam(name = "logNo", value = "流水号", required = false)
                               @RequestParam(value = "logNo", required = false)String logNo)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "register?outpatientId="+outpatientId;
@ -428,8 +466,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareService.register(outpatientId));
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.register(outpatientId,logNo));
            }else{
                return ObjEnvelop.getSuccess("ok",healthCareNewService.register(outpatientId));
            }
        }catch (Exception e){
@ -441,7 +481,7 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @PostMapping(value = "/registerBack")
    @ApiOperation(value = " 2.5.2医保挂号冲销(N20.17.04.02)", notes = " 2.5.2医保挂号冲销(N20.17.04.02)")
    public ObjEnvelop registerBack(@ApiParam(name = "outpatientId", value = "门诊id", required = true)
                               @RequestParam(value = "outpatientId", required = true)String outpatientId)throws Exception{
                                   @RequestParam(value = "outpatientId", required = true)String outpatientId)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "registerBack?outpatientId="+outpatientId;
@ -452,8 +492,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.registerBack(outpatientId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.registerBack(outpatientId));
            }
        }catch (Exception e){
            e.printStackTrace();
@ -464,7 +506,9 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @PostMapping(value = "/feeDetailUpload")
    @ApiOperation(value = " 2.5.3医保费用明细上传(N20.17.04.03)", notes = " 2.5.3医保费用明细上传(N20.17.04.03)")
    public ObjEnvelop feeDetailUpload(@ApiParam(name = "outpatientId", value = "门诊id", required = true)
                                   @RequestParam(value = "outpatientId", required = true)String outpatientId)throws Exception{
                                      @RequestParam(value = "outpatientId", required = true)String outpatientId,
                                      @ApiParam(name = "logNo", value = "流水号", required = false)
                                      @RequestParam(value = "logNo", required = false)String logNo)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "feeDetailUpload?outpatientId="+outpatientId;
@ -475,8 +519,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.feeDetailUpload(outpatientId,logNo));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareService.feeDetailUpload(outpatientId));
                return ObjEnvelop.getSuccess("ok",healthCareNewService.feeDetailUpload(outpatientId));
            }
        }catch (Exception e){
@ -490,7 +536,7 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    public ObjEnvelop feeDetailRefund(@ApiParam(name = "outpatientId", value = "门诊id", required = true)
                                      @RequestParam(value = "outpatientId", required = false)String outpatientId,
                                      @ApiParam(name = "remark", value = "作废原因", required = false)
                                          @RequestParam(value = "remark", required = true)String remark)throws Exception{
                                      @RequestParam(value = "remark", required = true)String remark)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "feeDetailRefund?outpatientId="+outpatientId+"&remark="+remark;
@ -501,8 +547,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
                return ObjEnvelop.getSuccess("ok",healthCareService.feeDetailRefund(outpatientId,remark));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.feeDetailRefund(outpatientId,remark));
            }
        }catch (Exception e){
@ -514,7 +562,9 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @PostMapping(value = "/preSettlement")
    @ApiOperation(value = " 2.5.5医保预结算服务(N20.17.04.05)", notes = " 2.5.5医保预结算服务(N20.17.04.05)")
    public ObjEnvelop preSettlement(@ApiParam(name = "outpatientId", value = "门诊id", required = true)
                                      @RequestParam(value = "outpatientId", required = false)String outpatientId)throws Exception{
                                    @RequestParam(value = "outpatientId", required = false)String outpatientId,
                                    @ApiParam(name = "logNo", value = "流水号", required = false)
                                    @RequestParam(value = "logNo", required = false)String logNo)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "preSettlement?outpatientId="+outpatientId;
@ -525,8 +575,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.preSettlement(outpatientId,logNo));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareService.preSettlement(outpatientId));
                return ObjEnvelop.getSuccess("ok",healthCareNewService.preSettlement(outpatientId));
            }
        }catch (Exception e){
@ -538,7 +590,7 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @PostMapping(value = "/preSettlementRefund")
    @ApiOperation(value = " 2.5.6医保结算冲销服务(N20.17.04.06)", notes = " 2.5.6医保结算冲销服务(N20.17.04.06)")
    public ObjEnvelop preSettlementRefund(@ApiParam(name = "outpatientId", value = "门诊id", required = true)
                                    @RequestParam(value = "outpatientId", required = false)String outpatientId)throws Exception{
                                          @RequestParam(value = "outpatientId", required = false)String outpatientId)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "preSettlementRefund?outpatientId="+outpatientId;
@ -549,8 +601,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
                return ObjEnvelop.getSuccess("ok",healthCareService.preSettlementRefund(outpatientId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.preSettlementRefund(outpatientId));
            }
        }catch (Exception e){
@ -562,7 +616,9 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @PostMapping(value = "/getSettlementResultUrl")
    @ApiOperation(value = " 2.5.7获取医保结算页面地址(N20.17.04.07)", notes = " 2.5.7获取医保结算页面地址(N20.17.04.07)")
    public ObjEnvelop getSettlementResultUrl(@ApiParam(name = "outpatientId", value = "门诊id", required = true)
                                          @RequestParam(value = "outpatientId", required = false)String outpatientId)throws Exception{
                                             @RequestParam(value = "outpatientId", required = false)String outpatientId,
                                             @ApiParam(name = "logNo", value = "流水号", required = false)
                                             @RequestParam(value = "logNo", required = false)String logNo)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "getSettlementResultUrl?outpatientId="+outpatientId;
@ -573,8 +629,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
                return ObjEnvelop.getSuccess("ok",healthCareService.getSettlementResultUrl(outpatientId,logNo));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareService.getSettlementResultUrl(outpatientId));
                return ObjEnvelop.getSuccess("ok",healthCareNewService.getSettlementResultUrl(outpatientId));
            }
        }catch (Exception e){
@ -586,7 +644,7 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @PostMapping(value = "/getSettlementResult")
    @ApiOperation(value = " 2.5.8获取医保结算结果(N20.17.04.08)", notes = " 2.5.8获取医保结算结果(N20.17.04.08)")
    public ObjEnvelop getSettlementResult(@ApiParam(name = "code", value = "结果回参", required = true)
                                             @RequestParam(value = "code", required = false)String code)throws Exception{
                                          @RequestParam(value = "code", required = false)String code)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "getSettlementResult?code="+code;
@ -597,8 +655,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.getSettlementResult(code));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.getSettlementResult(code));
            }
        }catch (Exception e){
@ -610,7 +670,7 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @PostMapping(value = "/uploadMedicalHistory")
    @ApiOperation(value = " 2.7.1上传用户病史病情及医学报告(N20.17.06.01)", notes = " 2.7.1上传用户病史病情及医学报告(N20.17.06.01)")
    public ObjEnvelop uploadMedicalHistory(@ApiParam(name = "outpatientId", value = "门诊id", required = true)
                                          @RequestParam(value = "outpatientId", required = false)String outpatientId)throws Exception{
                                           @RequestParam(value = "outpatientId", required = false)String outpatientId)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "uploadMedicalHistory?outpatientId="+outpatientId;
@ -621,8 +681,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.uploadMedicalHistory(outpatientId));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.uploadMedicalHistory(outpatientId));
            }
        }catch (Exception e){
@ -634,7 +696,7 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @PostMapping(value = "/refundMedicalHistory")
    @ApiOperation(value = " 2.7.2作废用户病史病情及医学报告(N20.17.06.06)", notes = " 2.7.2作废用户病史病情及医学报告(N20.17.06.06)")
    public ObjEnvelop refundMedicalHistory(@ApiParam(name = "outpatientId", value = "门诊id", required = false)
                                          @RequestParam(value = "outpatientId", required = false)String outpatientId,
                                           @RequestParam(value = "outpatientId", required = false)String outpatientId,
                                           @ApiParam(name = "remark", value = "作废原因", required = false)
                                           @RequestParam(value = "remark", required = false)String remark)throws Exception{
        try {
@ -647,8 +709,10 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
                return ObjEnvelop.getSuccess("ok",healthCareService.refundMedicalHistory(outpatientId,remark));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.refundMedicalHistory(outpatientId,remark));
            }
        }catch (Exception e){
@ -660,7 +724,7 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @PostMapping(value = "/uploadIcdProcess")
    @ApiOperation(value = " 2.7.3获取问诊过程数据(N20.17.06.02)", notes = " 2.7.3获取问诊过程数据(N20.17.06.02)")
    public ObjEnvelop uploadIcdProcess(@ApiParam(name = "outpatientId", value = "门诊id", required = false)
                                           @RequestParam(value = "outpatientId", required = false)String outpatientId)throws Exception{
                                       @RequestParam(value = "outpatientId", required = false)String outpatientId)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "uploadIcdProcess?outpatientId="+outpatientId;
@ -671,10 +735,79 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
            }else {
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                return ObjEnvelop.getSuccess("ok",healthCareService.uploadIcdProcess(outpatientId));
            }else{
                return ObjEnvelop.getSuccess("ok",healthCareNewService.uploadIcdProcess(outpatientId));
            }
        }catch (Exception e){
            e.printStackTrace();
            return failedObjEnvelopException(e);
        }
    }
    @PostMapping(value = "/getUserInfo")
    @ApiOperation(value = " 4.2.1获取用户信息(N03.00.05.16)", notes = " 4.2.1获取用户信息(N03.00.05.16)")
    public ObjEnvelop getUserInfo(@ApiParam(name = "code", value = "用户信息临时串", required = false)
                                  @RequestParam(value = "code", required = false)String code)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_hcyy_wx")) {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.getUserInfo(code));
            }else{
                return null;
            }
        }catch (Exception e){
            e.printStackTrace();
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = "/getOauthQRCodeImg")
    @ApiOperation(value = "获取医保授权二维码", notes = "获取医保授权二维码")
    public ObjEnvelop getOauthQRCodeImg()throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_hcyy_wx")) {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.getYbImage());
            }else{
                return null;
            }
        }catch (Exception e){
            e.printStackTrace();
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = "/updateUserInfo")
    @ApiOperation(value = "更新医保用户信息", notes = "更新医保用户信息")
    public ObjEnvelop updateUserInfo(@ApiParam(name = "no", value = "唯一编码", required = false)
                                     @RequestParam(value = "no", required = false)String no,
                                     @ApiParam(name = "token", value = "用户信息临时串", required = false)
                                     @RequestParam(value = "token", required = false)String token)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_hcyy_wx")) {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.updateUserInfo(no,token));
            }else{
                return null;
            }
        }catch (Exception e){
            e.printStackTrace();
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = "/checkOauthQRCode")
    @ApiOperation(value = "验证医保凭证是否授权", notes = "验证医保凭证是否授权")
    public ObjEnvelop checkOauthQRCode(@ApiParam(name = "authorizeNo", value = "唯一编码", required = false)
                                       @RequestParam(value = "authorizeNo", required = false)String authorizeNo)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_hcyy_wx")) {
                return ObjEnvelop.getSuccess("ok",healthCareNewService.checkOauthQRCode(authorizeNo));
            }else{
                return null;
            }
        }catch (Exception e){
            e.printStackTrace();
            return failedObjEnvelopException(e);