|  | @ -112,6 +112,8 @@ public class XzzxEntranceService{
 | 
	
		
			
				|  |  |     private BaseDoctorDao baseDoctorDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BasePatientDao basePatientDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PrescriptionCheckDao prescriptionCheckDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -128,8 +130,10 @@ public class XzzxEntranceService{
 | 
	
		
			
				|  |  |     public static String checkInfosUrl="http://192.168.102.243:8040/service/api/check.do?tag=1";
 | 
	
		
			
				|  |  |     //保存天际处方接口地址
 | 
	
		
			
				|  |  |     public static String saveTianJiPrescription = "http://192.168.102.243:8040/service/api/checkFromXmlToJson.do?tag=2";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     //作废处方地址
 | 
	
		
			
				|  |  |     public static String deleteTianJiPrescription = "http://10.1.3.105:8221/drugs/@code@?source=dcdt_web&show_navbar=true";
 | 
	
		
			
				|  |  |     //药品说明书地址http://192.168.102.243:8221/drugs/@code@?source=dcdt_web&show_navbar=true
 | 
	
		
			
				|  |  |     public static String drugUseInfoTianJi = "http://192.168.102.243:8221/drugs/@code@?source=dcdt_web&show_navbar=true";
 | 
	
		
			
				|  |  |     public String getSelectUrl(){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<WlyyHospitalSysDictDO> list =  wlyyHospitalSysDictDao.findByDictName("xzzxWebSelectService");
 | 
	
	
		
			
				|  | @ -1339,7 +1343,7 @@ public class XzzxEntranceService{
 | 
	
		
			
				|  |  |     /*
 | 
	
		
			
				|  |  |      *合理用药审核接口入参
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String checkPrescriptionInfoParam(JSONObject patientAndDoctor,List<WlyyPrescriptionInfoDO> infos){
 | 
	
		
			
				|  |  |     public String checkPrescriptionInfoParam(JSONObject patientAndDoctor,List<WlyyPrescriptionInfoDO> infos,boolean isDelete){
 | 
	
		
			
				|  |  |         String checkDoctor="<Doctor POSITION=\""+patientAndDoctor.getString("POSITION")+
 | 
	
		
			
				|  |  |                 "\" NAME=\""+patientAndDoctor.getString("DOCTOR_NAME")+
 | 
	
		
			
				|  |  |                 "\" DEPT_CODE=\""+patientAndDoctor.getString("DEPT_CODE")+
 | 
	
	
		
			
				|  | @ -1354,30 +1358,35 @@ public class XzzxEntranceService{
 | 
	
		
			
				|  |  |         String checkDiagnosises = "<Diagnosises DIAGNOSISES=\""+patientAndDoctor.getString("diagnosises")+"\" >\n" +
 | 
	
		
			
				|  |  |                 "</Diagnosises>\n";
 | 
	
		
			
				|  |  |         StringBuffer stringBuffer = new StringBuffer();
 | 
	
		
			
				|  |  |         for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO:infos){
 | 
	
		
			
				|  |  |             int i = 1;
 | 
	
		
			
				|  |  |             stringBuffer.append("<Advice REPEAT=\"1\" DRUG_LO_NAME=\""+wlyyPrescriptionInfoDO.getDrugName()+
 | 
	
		
			
				|  |  |                     "\" DRUG_LO_ID=\""+wlyyPrescriptionInfoDO.getHisCode()+
 | 
	
		
			
				|  |  |                     "\" ADMINISTRATION=\""+wlyyPrescriptionInfoDO.getSupplyName()+
 | 
	
		
			
				|  |  |                     "\" DOSAGE=\""+wlyyPrescriptionInfoDO.getDosage()+
 | 
	
		
			
				|  |  |                     "\" DOSAGE_UNIT=\""+wlyyPrescriptionInfoDO.getUnitName()+
 | 
	
		
			
				|  |  |                     "\" FREQ_COUNT=\""+wlyyPrescriptionInfoDO.getUsageCode()+
 | 
	
		
			
				|  |  |                     "\" FREQ_INTERVAL=\"\" FREQ_INTERVAL_UNIT=\"\" START_DAY=\""+patientAndDoctor.getString("CREATE_DATE")+"\" END_DAY=\"\" DEPT_CODE=\""+patientAndDoctor.getString("DEPT_CODE")+
 | 
	
		
			
				|  |  |                     "\" DOCTOR_NAME=\""+patientAndDoctor.getString("DOCTOR_NAME")+
 | 
	
		
			
				|  |  |                     "\" ORDER_NO=\""+i+
 | 
	
		
			
				|  |  |                     "\" ORDER_SUB_NO=\""+1+"\" AUTHORITY_LEVELS=\"\" ALERT_LEVELS=\"\" TITLE=\""+patientAndDoctor.getString("POSITION") +
 | 
	
		
			
				|  |  |                     "\" GROUP_ID=\""+wlyyPrescriptionInfoDO.getFrequency()+"\" USER_ID=\""+patientAndDoctor.getString("doctorId")+
 | 
	
		
			
				|  |  |                     "\" PRES_ID=\""+patientAndDoctor.getString("PATIENT_PRES_ID")+
 | 
	
		
			
				|  |  |                     "\" PRES_DATE=\""+patientAndDoctor.getString("CREATE_DATE")+
 | 
	
		
			
				|  |  |                     "\" PRES_SEQ_ID=\""+patientAndDoctor.getString("PATIENT_PRES_ID")+
 | 
	
		
			
				|  |  |                     "\" PK_ORDER_NO=\"\" COURSE=\""+wlyyPrescriptionInfoDO.getDays()+
 | 
	
		
			
				|  |  |                     "\" PKG_COUNT=\""+wlyyPrescriptionInfoDO.getPackQuantity()+
 | 
	
		
			
				|  |  |                     "\" PKG_UNIT=\""+wlyyPrescriptionInfoDO.getPackUnitName()+"\" BAK_01=\"\" BAK_02=\"\" BAK_03=\""+wlyyPrescriptionInfoDO.getUnitName()+
 | 
	
		
			
				|  |  |                     "\" BAK_04=\""+wlyyPrescriptionInfoDO.getSpecification()+
 | 
	
		
			
				|  |  |                     "\" BAK_05=\""+wlyyPrescriptionInfoDO.getDrugPlace()+"\"  />");
 | 
	
		
			
				|  |  |             i++;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String checkInfos = "<Advices>"+stringBuffer.toString()+"</Advices>";
 | 
	
		
			
				|  |  |         if(null!=infos&&infos.size()>0){
 | 
	
		
			
				|  |  |             for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO:infos){
 | 
	
		
			
				|  |  |                 int i = 1;
 | 
	
		
			
				|  |  |                 stringBuffer.append("<Advice REPEAT=\"1\" DRUG_LO_NAME=\""+wlyyPrescriptionInfoDO.getDrugName()+
 | 
	
		
			
				|  |  |                         "\" DRUG_LO_ID=\""+wlyyPrescriptionInfoDO.getHisCode()+
 | 
	
		
			
				|  |  |                         "\" ADMINISTRATION=\""+wlyyPrescriptionInfoDO.getSupplyName()+
 | 
	
		
			
				|  |  |                         "\" DOSAGE=\""+wlyyPrescriptionInfoDO.getDosage()+
 | 
	
		
			
				|  |  |                         "\" DOSAGE_UNIT=\""+wlyyPrescriptionInfoDO.getUnitName()+
 | 
	
		
			
				|  |  |                         "\" FREQ_COUNT=\""+wlyyPrescriptionInfoDO.getUsageCode()+
 | 
	
		
			
				|  |  |                         "\" FREQ_INTERVAL=\"\" FREQ_INTERVAL_UNIT=\"\" START_DAY=\""+patientAndDoctor.getString("CREATE_DATE")+"\" END_DAY=\"\" DEPT_CODE=\""+patientAndDoctor.getString("DEPT_CODE")+
 | 
	
		
			
				|  |  |                         "\" DOCTOR_NAME=\""+patientAndDoctor.getString("DOCTOR_NAME")+
 | 
	
		
			
				|  |  |                         "\" ORDER_NO=\""+i+
 | 
	
		
			
				|  |  |                         "\" ORDER_SUB_NO=\""+1+"\" AUTHORITY_LEVELS=\"\" ALERT_LEVELS=\"\" TITLE=\""+patientAndDoctor.getString("POSITION") +
 | 
	
		
			
				|  |  |                         "\" GROUP_ID=\""+wlyyPrescriptionInfoDO.getFrequency()+"\" USER_ID=\""+patientAndDoctor.getString("doctorId")+
 | 
	
		
			
				|  |  |                         "\" PRES_ID=\""+patientAndDoctor.getString("PATIENT_PRES_ID")+
 | 
	
		
			
				|  |  |                         "\" PRES_DATE=\""+patientAndDoctor.getString("CREATE_DATE")+
 | 
	
		
			
				|  |  |                         "\" PRES_SEQ_ID=\""+patientAndDoctor.getString("PATIENT_PRES_ID")+
 | 
	
		
			
				|  |  |                         "\" PK_ORDER_NO=\"\" COURSE=\""+wlyyPrescriptionInfoDO.getDays()+
 | 
	
		
			
				|  |  |                         "\" PKG_COUNT=\""+wlyyPrescriptionInfoDO.getPackQuantity()+
 | 
	
		
			
				|  |  |                         "\" PKG_UNIT=\""+wlyyPrescriptionInfoDO.getPackUnitName()+"\" BAK_01=\"\" BAK_02=\"\" BAK_03=\""+wlyyPrescriptionInfoDO.getUnitName()+
 | 
	
		
			
				|  |  |                         "\" BAK_04=\""+wlyyPrescriptionInfoDO.getSpecification()+
 | 
	
		
			
				|  |  |                         "\" BAK_05=\""+wlyyPrescriptionInfoDO.getDrugPlace()+"\"  />");
 | 
	
		
			
				|  |  |                 i++;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String checkInfos = "<Advices></Advices>";
 | 
	
		
			
				|  |  |         if (!isDelete){
 | 
	
		
			
				|  |  |             checkInfos= "<Advices>"+stringBuffer.toString()+"</Advices>";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String postBody = "<CheckInput TAG=\"2\" INPATIENT=\"否\">"+checkDoctor+checkPatient+checkDiagnosises+checkInfos+"</CheckInput>";
 | 
	
		
			
				|  |  |         return postBody;
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -1385,7 +1394,7 @@ public class XzzxEntranceService{
 | 
	
		
			
				|  |  |      *合理用药审核接口
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String checkPrescription(JSONObject patientAndDoctor,List<WlyyPrescriptionInfoDO> infos) throws Exception{
 | 
	
		
			
				|  |  |         String postBody = checkPrescriptionInfoParam(patientAndDoctor,infos);
 | 
	
		
			
				|  |  |         String postBody = checkPrescriptionInfoParam(patientAndDoctor,infos,false);
 | 
	
		
			
				|  |  |         logger.info("发送的报文参数:"+postBody);
 | 
	
		
			
				|  |  |         String res =  httpClientUtil.sendPost(checkInfosUrl,postBody);
 | 
	
		
			
				|  |  |         logger.info("返回的报文参数:"+res);
 | 
	
	
		
			
				|  | @ -1397,6 +1406,38 @@ public class XzzxEntranceService{
 | 
	
		
			
				|  |  |         wlyyHttpLogDO.setName("checkPrescriptionInEntrance");
 | 
	
		
			
				|  |  |         return  res;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     /*
 | 
	
		
			
				|  |  |      *合理用药保存接口
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String saveCheckPrescription(JSONObject patientAndDoctor,List<WlyyPrescriptionInfoDO> infos) throws Exception{
 | 
	
		
			
				|  |  |         String postBody = checkPrescriptionInfoParam(patientAndDoctor,infos,false);
 | 
	
		
			
				|  |  |         logger.info("保存处方的报文参数:"+postBody);
 | 
	
		
			
				|  |  |         String res =  httpClientUtil.sendPost(saveTianJiPrescription,postBody);
 | 
	
		
			
				|  |  |         logger.info("保存处方的报文参数:"+res);
 | 
	
		
			
				|  |  |         WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
 | 
	
		
			
				|  |  |         wlyyHttpLogDO.setDoctor(patientAndDoctor.getString("doctorId"));
 | 
	
		
			
				|  |  |         wlyyHttpLogDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         wlyyHttpLogDO.setRequest(postBody);
 | 
	
		
			
				|  |  |         wlyyHttpLogDO.setResponse(res);
 | 
	
		
			
				|  |  |         wlyyHttpLogDO.setName("checkPrescriptionInEntrance");
 | 
	
		
			
				|  |  |         return  res;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     /*
 | 
	
		
			
				|  |  |      *合理用药作废接口
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String deleteCheckPrescription(JSONObject patientAndDoctor,List<WlyyPrescriptionInfoDO> infos) throws Exception{
 | 
	
		
			
				|  |  |         String postBody = checkPrescriptionInfoParam(patientAndDoctor,infos,true);
 | 
	
		
			
				|  |  |         logger.info("作废的报文参数:"+postBody);
 | 
	
		
			
				|  |  |         String res =  httpClientUtil.sendPost(deleteTianJiPrescription,postBody);
 | 
	
		
			
				|  |  |         logger.info("作废的报文参数:"+res);
 | 
	
		
			
				|  |  |         WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
 | 
	
		
			
				|  |  |         wlyyHttpLogDO.setDoctor(patientAndDoctor.getString("doctorId"));
 | 
	
		
			
				|  |  |         wlyyHttpLogDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         wlyyHttpLogDO.setRequest(postBody);
 | 
	
		
			
				|  |  |         wlyyHttpLogDO.setResponse(res);
 | 
	
		
			
				|  |  |         wlyyHttpLogDO.setName("checkPrescriptionInEntrance");
 | 
	
		
			
				|  |  |         return  res;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> transXmlCommen(String xml){
 | 
	
		
			
				|  |  |         Document doc = null;
 | 
	
		
			
				|  |  |         List<Map<String,Object>> returnMap= new ArrayList<>();
 | 
	
	
		
			
				|  | @ -2906,45 +2947,26 @@ public Map checkSyncHis(String IoFlag,String PayCardNo,String NullahNumber,Strin
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     //组装审药参数并发送到entrance
 | 
	
		
			
				|  |  |     public String checkInputInfo(String prescriptionId,String payType,String doctor,String patient,List<WlyyPrescriptionDiagnosisDO> diagnosisDOS,List<WlyyPrescriptionInfoDO> infos) throws Exception{
 | 
	
		
			
				|  |  |         JSONObject jsonObject = new JSONObject();
 | 
	
		
			
				|  |  |         JSONObject jsonObject = initEntranceParam(payType,doctor,patient,diagnosisDOS);
 | 
	
		
			
				|  |  |         String tjPrescriptionId = "";
 | 
	
		
			
				|  |  |         WlyyPrescriptionCheckDO wlyyPrescriptionCheckDO;
 | 
	
		
			
				|  |  |         //如果重新审核药品 一定要把返回的orderNo的值拿到赋值到prescriptionId里
 | 
	
		
			
				|  |  |         if (StringUtils.isNotEmpty(prescriptionId)){
 | 
	
		
			
				|  |  |             tjPrescriptionId = prescriptionId;
 | 
	
		
			
				|  |  |             jsonObject.put("PATIENT_PRES_ID",tjPrescriptionId);
 | 
	
		
			
				|  |  |             wlyyPrescriptionCheckDO = prescriptionCheckDao.findOne(tjPrescriptionId);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             wlyyPrescriptionCheckDO = new WlyyPrescriptionCheckDO();
 | 
	
		
			
				|  |  |             tjPrescriptionId = UUID.randomUUID().toString();
 | 
	
		
			
				|  |  |             wlyyPrescriptionCheckDO.setId(tjPrescriptionId);
 | 
	
		
			
				|  |  |             jsonObject.put("PATIENT_PRES_ID",tjPrescriptionId);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //先查询处方获得支付方式
 | 
	
		
			
				|  |  |         DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(doctor);
 | 
	
		
			
				|  |  |         BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doctor);
 | 
	
		
			
				|  |  |         jsonObject.put("DOCTOR_NAME", baseDoctorDO.getName());
 | 
	
		
			
				|  |  |         jsonObject.put("DEPT_CODE", baseDoctorDO.getVisitDept());
 | 
	
		
			
				|  |  |         jsonObject.put("DEPT_NAME", baseDoctorDO.getVisitDeptName());
 | 
	
		
			
				|  |  |         if (null != doctorMappingDO && null != baseDoctorDO) {
 | 
	
		
			
				|  |  |             jsonObject.put("DOCTOR_ID", doctorMappingDO.getMappingCode());
 | 
	
		
			
				|  |  |             jsonObject.put("POSITION", baseDoctorDO.getJobTitleName());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
 | 
	
		
			
				|  |  |         BasePatientDO basePatientDO = patientDao.findById(patient);
 | 
	
		
			
				|  |  |         jsonObject.put("PATIENT_NAME", basePatientDO.getName());
 | 
	
		
			
				|  |  |         SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
 | 
	
		
			
				|  |  |         if (null != patientMappingDO && null != basePatientDO) {
 | 
	
		
			
				|  |  |             jsonObject.put("PATIENT_ID", patientMappingDO.getMappingCode());
 | 
	
		
			
				|  |  |             jsonObject.put("GENDER", basePatientDO.getSex()==1?"男":"女");
 | 
	
		
			
				|  |  |             jsonObject.put("BIRTH", sdf.format(basePatientDO.getBirthday()));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         wlyyPrescriptionCheckDO.setCreateUser(doctor);
 | 
	
		
			
				|  |  |         wlyyPrescriptionCheckDO.setCreateUserName(null==jsonObject.get("DOCTOR_NAME")?"":jsonObject.get("DOCTOR_NAME").toString());
 | 
	
		
			
				|  |  |         wlyyPrescriptionCheckDO.setDept(null==jsonObject.get("DEPT_CODE")?"":jsonObject.get("DEPT_CODE").toString());
 | 
	
		
			
				|  |  |         wlyyPrescriptionCheckDO.setDeptName(null==jsonObject.get("DEPT_NAME")?"":jsonObject.get("DEPT_NAME").toString());
 | 
	
		
			
				|  |  |         if (null!=infos&&infos.size()>0) {
 | 
	
		
			
				|  |  |             jsonObject.put("PATIENT_PRES_ID", tjPrescriptionId);
 | 
	
		
			
				|  |  |             jsonObject.put("FEE_TYPE", "1".equalsIgnoreCase(payType) ? "医保" : "自费");
 | 
	
		
			
				|  |  |             jsonObject.put("CREATE_DATE", sdf.format(new Date()));
 | 
	
		
			
				|  |  |             //组装诊断参数
 | 
	
		
			
				|  |  |             if (null != diagnosisDOS && diagnosisDOS.size() > 0) {
 | 
	
		
			
				|  |  |                 List diagnosises = new ArrayList();
 | 
	
		
			
				|  |  |                 for (WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO : diagnosisDOS) {
 | 
	
		
			
				|  |  |                     diagnosises.add(wlyyPrescriptionDiagnosisDO.getName());
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 jsonObject.put("diagnosises", StringUtils.strip(diagnosises.toString(),"[]"));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String response = "";
 | 
	
		
			
				|  |  |             String returnJson = "";
 | 
	
		
			
				|  |  |             JSONArray array = new JSONArray();
 | 
	
	
		
			
				|  | @ -2966,10 +2988,27 @@ public Map checkSyncHis(String IoFlag,String PayCardNo,String NullahNumber,Strin
 | 
	
		
			
				|  |  |                 System.out.println("obj:"+obj);
 | 
	
		
			
				|  |  |                 if (StringUtils.isNotBlank(obj)) {
 | 
	
		
			
				|  |  |                     List<Map<String,Object>> returnList = transXmlCommen(obj);
 | 
	
		
			
				|  |  |                     for (Map<String,Object> saveMap:returnList){
 | 
	
		
			
				|  |  |                         if (null!=saveMap.get("checkInfoMapList")){
 | 
	
		
			
				|  |  |                             String  checkInfo = saveMap.get("checkInfoMapList").toString();
 | 
	
		
			
				|  |  |                              JSONArray jsonArray=JSONArray.parseArray(checkInfo);
 | 
	
		
			
				|  |  |                              for(int i=0;i<jsonArray.size();i++){
 | 
	
		
			
				|  |  |                                  JSONObject jsonObject1 = JSONObject.parseObject(jsonArray.get(i).toString());
 | 
	
		
			
				|  |  |                                  //存在强制阻断即认为处方审核未通过不允许保存处方
 | 
	
		
			
				|  |  |                                  if(null!=jsonObject1.get("WARNING_LEVEL")&&"强制阻断".equalsIgnoreCase(jsonObject1.get("WARNING_LEVEL").toString())){
 | 
	
		
			
				|  |  |                                      wlyyPrescriptionCheckDO.setStatus(1);
 | 
	
		
			
				|  |  |                                      break;
 | 
	
		
			
				|  |  |                                  }
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |                         }else {
 | 
	
		
			
				|  |  |                             wlyyPrescriptionCheckDO.setStatus(2);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     Map<String,Object> checkIdMap = new HashMap<>();
 | 
	
		
			
				|  |  |                     checkIdMap.put("prescriptionOnly",tjPrescriptionId);
 | 
	
		
			
				|  |  |                     returnList.add(checkIdMap);
 | 
	
		
			
				|  |  |                     returnJson = JSONArray.toJSONString(returnList);
 | 
	
		
			
				|  |  |                     wlyyPrescriptionCheckDO.setReason(returnJson);
 | 
	
		
			
				|  |  |                     logger.info("返回到互联网医院的解析后的结果:"+returnJson);
 | 
	
		
			
				|  |  |                     wlyyHttpLogDO.setDoctor(doctor);
 | 
	
		
			
				|  |  |                     wlyyHttpLogDO.setCreateTime(new Date());
 | 
	
	
		
			
				|  | @ -2978,6 +3017,7 @@ public Map checkSyncHis(String IoFlag,String PayCardNo,String NullahNumber,Strin
 | 
	
		
			
				|  |  |                     wlyyHttpLogDO.setName("checkPrescription");
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     returnJson = "审方返回接口为空请检查参数是否正确";
 | 
	
		
			
				|  |  |                     wlyyPrescriptionCheckDO.setStatus(1);
 | 
	
		
			
				|  |  |                     logger.info(returnJson);
 | 
	
		
			
				|  |  |                     wlyyHttpLogDO.setCode("error");
 | 
	
		
			
				|  |  |                     wlyyHttpLogDO.setDoctor(doctor);
 | 
	
	
		
			
				|  | @ -2988,6 +3028,7 @@ public Map checkSyncHis(String IoFlag,String PayCardNo,String NullahNumber,Strin
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 returnJson = "entranceUrl接口调用失败";
 | 
	
		
			
				|  |  |                 wlyyPrescriptionCheckDO.setStatus(1);
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setCode("error");
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setDoctor(doctor);
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setCreateTime(new Date());
 | 
	
	
		
			
				|  | @ -2996,13 +3037,178 @@ public Map checkSyncHis(String IoFlag,String PayCardNo,String NullahNumber,Strin
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setName("checkPrescription");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             wlyyHttpLogDao.save(wlyyHttpLogDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             wlyyPrescriptionCheckDO.setStatus(1);
 | 
	
		
			
				|  |  |             prescriptionCheckDao.save(wlyyPrescriptionCheckDO);
 | 
	
		
			
				|  |  |             wlyyPrescriptionCheckDO.setReason(returnJson);
 | 
	
		
			
				|  |  |             return returnJson;
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             return "药品信息为空";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     //组装审药参数并发送到entrance保存处方
 | 
	
		
			
				|  |  |     public String saveCheckInputInfo(String prescriptionId,String payType,String doctor,String patient,List<WlyyPrescriptionDiagnosisDO> diagnosisDOS,List<WlyyPrescriptionInfoDO> infos) throws Exception{
 | 
	
		
			
				|  |  |         JSONObject jsonObject = initEntranceParam(payType,doctor,patient,diagnosisDOS);
 | 
	
		
			
				|  |  |         String tjPrescriptionId = "";
 | 
	
		
			
				|  |  |         WlyyPrescriptionCheckDO wlyyPrescriptionCheckDO = new WlyyPrescriptionCheckDO();
 | 
	
		
			
				|  |  |         //如果重新审核药品 一定要把返回的orderNo的值拿到赋值到prescriptionId里
 | 
	
		
			
				|  |  |         if (StringUtils.isNotEmpty(prescriptionId)) {
 | 
	
		
			
				|  |  |             tjPrescriptionId = prescriptionId;
 | 
	
		
			
				|  |  |             jsonObject.put("PATIENT_PRES_ID",tjPrescriptionId);
 | 
	
		
			
				|  |  |             wlyyPrescriptionCheckDO = prescriptionCheckDao.findOne(prescriptionId);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (null!=infos&&infos.size()>0) {
 | 
	
		
			
				|  |  |             String response = "";
 | 
	
		
			
				|  |  |             String returnJson = "";
 | 
	
		
			
				|  |  |             JSONArray array = new JSONArray();
 | 
	
		
			
				|  |  |             for (WlyyPrescriptionInfoDO infoDO:infos){
 | 
	
		
			
				|  |  |                 array.add(infoDO);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String url = entranceUrl + "saveCheckPrescription";
 | 
	
		
			
				|  |  |             Map<String,String> map = new HashedMap();
 | 
	
		
			
				|  |  |             map.put("infos",array.toJSONString());
 | 
	
		
			
				|  |  |             map.put("patientAndDoctor",jsonObject.toString());
 | 
	
		
			
				|  |  |             response = httpClientUtil.httpPost(url, map);
 | 
	
		
			
				|  |  |             logger.info("请求saveCheckPrescription参数:"+map.toString());
 | 
	
		
			
				|  |  |             logger.info("saveCheckPrescription返回结果:" + response);
 | 
	
		
			
				|  |  |             JSONObject object = JSONObject.parseObject(response);
 | 
	
		
			
				|  |  |             WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
 | 
	
		
			
				|  |  |             if (object.getInteger("status") == 200) {
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setCode("200");
 | 
	
		
			
				|  |  |                 String obj = object.getString("obj");
 | 
	
		
			
				|  |  |                 System.out.println("obj:"+obj);
 | 
	
		
			
				|  |  |                 if (StringUtils.isNotBlank(obj)) {
 | 
	
		
			
				|  |  |                     List<Map<String,Object>> returnList = transXmlCommen(obj);
 | 
	
		
			
				|  |  |                     returnJson = JSONArray.toJSONString(returnList);
 | 
	
		
			
				|  |  |                     wlyyPrescriptionCheckDO.setStatus(9);
 | 
	
		
			
				|  |  |                     logger.info("返回到互联网医院的解析后的结果:"+returnJson);
 | 
	
		
			
				|  |  |                     wlyyHttpLogDO.setDoctor(doctor);
 | 
	
		
			
				|  |  |                     wlyyHttpLogDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                     wlyyHttpLogDO.setRequest(infos + jsonObject.toString());
 | 
	
		
			
				|  |  |                     wlyyHttpLogDO.setResponse(returnJson);
 | 
	
		
			
				|  |  |                     wlyyHttpLogDO.setName("saveCheckPrescription");
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     returnJson = "保存成功";
 | 
	
		
			
				|  |  |                     wlyyPrescriptionCheckDO.setStatus(10);
 | 
	
		
			
				|  |  |                     logger.info(returnJson);
 | 
	
		
			
				|  |  |                     wlyyHttpLogDO.setCode("success");
 | 
	
		
			
				|  |  |                     wlyyHttpLogDO.setDoctor(doctor);
 | 
	
		
			
				|  |  |                     wlyyHttpLogDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                     wlyyHttpLogDO.setRequest(infos + jsonObject.toString());
 | 
	
		
			
				|  |  |                     wlyyHttpLogDO.setResponse(returnJson);
 | 
	
		
			
				|  |  |                     wlyyHttpLogDO.setName("saveCheckPrescription");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 returnJson = "entranceUrl接口调用失败";
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setCode("error");
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setDoctor(doctor);
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setRequest(infos + jsonObject.toString());
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setResponse(returnJson);
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setName("saveCheckPrescription");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             wlyyHttpLogDao.save(wlyyHttpLogDO);
 | 
	
		
			
				|  |  |             return returnJson;
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             return "药品信息为空";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     //作废处方
 | 
	
		
			
				|  |  |     public String deleteCheckInputInfo(String prescriptionId,String payType,String doctor,String patient,List<WlyyPrescriptionDiagnosisDO> diagnosisDOS) throws Exception{
 | 
	
		
			
				|  |  |         JSONObject jsonObject = initEntranceParam(payType,doctor,patient,diagnosisDOS);
 | 
	
		
			
				|  |  |         String tjPrescriptionId = "";
 | 
	
		
			
				|  |  |         WlyyPrescriptionCheckDO wlyyPrescriptionCheckDO = new WlyyPrescriptionCheckDO();
 | 
	
		
			
				|  |  |         //如果重新审核药品 一定要把返回的orderNo的值拿到赋值到prescriptionId里
 | 
	
		
			
				|  |  |         if (StringUtils.isNotEmpty(prescriptionId)){
 | 
	
		
			
				|  |  |             tjPrescriptionId = prescriptionId;
 | 
	
		
			
				|  |  |             wlyyPrescriptionCheckDO = prescriptionCheckDao.findOne(tjPrescriptionId);
 | 
	
		
			
				|  |  |             jsonObject.put("PATIENT_PRES_ID",tjPrescriptionId);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String response = "";
 | 
	
		
			
				|  |  |         String returnJson = "";
 | 
	
		
			
				|  |  |         String url = entranceUrl + "deleteCheckPrescription";
 | 
	
		
			
				|  |  |         Map<String,String> map = new HashedMap();
 | 
	
		
			
				|  |  |         map.put("infos","");
 | 
	
		
			
				|  |  |         map.put("patientAndDoctor",jsonObject.toString());
 | 
	
		
			
				|  |  |         response = httpClientUtil.httpPost(url, map);
 | 
	
		
			
				|  |  |         logger.info("请求deleteCheckPrescription参数:"+map.toString());
 | 
	
		
			
				|  |  |         logger.info("deleteCheckPrescription返回结果:" + response);
 | 
	
		
			
				|  |  |         JSONObject object = JSONObject.parseObject(response);
 | 
	
		
			
				|  |  |         WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
 | 
	
		
			
				|  |  |         if (object.getInteger("status") == 200) {
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setCode("200");
 | 
	
		
			
				|  |  |             String obj = object.getString("obj");
 | 
	
		
			
				|  |  |             System.out.println("obj:"+obj);
 | 
	
		
			
				|  |  |             if (StringUtils.isNotBlank(obj)) {
 | 
	
		
			
				|  |  |                 List<Map<String,Object>> returnList = transXmlCommen(obj);
 | 
	
		
			
				|  |  |                 wlyyPrescriptionCheckDO.setStatus(11);
 | 
	
		
			
				|  |  |                 returnJson = JSONArray.toJSONString(returnList);
 | 
	
		
			
				|  |  |                 logger.info("返回到互联网医院的解析后的结果:"+returnJson);
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setDoctor(doctor);
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setRequest(map.toString());
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setResponse(returnJson);
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setName("saveCheckPrescription");
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 returnJson = "删除成功";
 | 
	
		
			
				|  |  |                 logger.info(returnJson);
 | 
	
		
			
				|  |  |                 wlyyPrescriptionCheckDO.setStatus(12);
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setCode("删除成功");
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setDoctor(doctor);
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setRequest(map.toString());
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setResponse(returnJson);
 | 
	
		
			
				|  |  |                 wlyyHttpLogDO.setName("deleteCheckPrescription");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             returnJson = "entranceUrl接口调用失败";
 | 
	
		
			
				|  |  |             wlyyPrescriptionCheckDO.setStatus(11);
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setCode("error");
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setDoctor(doctor);
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setRequest(map.toString());
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setResponse(returnJson);
 | 
	
		
			
				|  |  |             wlyyHttpLogDO.setName("deleteCheckPrescription");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         wlyyHttpLogDao.save(wlyyHttpLogDO);
 | 
	
		
			
				|  |  |         prescriptionCheckDao.save(wlyyPrescriptionCheckDO);
 | 
	
		
			
				|  |  |         wlyyPrescriptionCheckDO.setReason(returnJson);
 | 
	
		
			
				|  |  |         return returnJson;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     //初始化医患和诊断参数
 | 
	
		
			
				|  |  |     public JSONObject initEntranceParam(String payType,String doctor,String patient,List<WlyyPrescriptionDiagnosisDO> diagnosisDOS){
 | 
	
		
			
				|  |  |         JSONObject jsonObject = new JSONObject();
 | 
	
		
			
				|  |  |         //先查询处方获得支付方式
 | 
	
		
			
				|  |  |         DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(doctor);
 | 
	
		
			
				|  |  |         BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doctor);
 | 
	
		
			
				|  |  |         if (null != doctorMappingDO && null != baseDoctorDO) {
 | 
	
		
			
				|  |  |             jsonObject.put("DOCTOR_ID", doctorMappingDO.getMappingCode());
 | 
	
		
			
				|  |  |             jsonObject.put("POSITION", baseDoctorDO.getJobTitleName());
 | 
	
		
			
				|  |  |             jsonObject.put("DOCTOR_NAME", baseDoctorDO.getName());
 | 
	
		
			
				|  |  |             jsonObject.put("DEPT_CODE", baseDoctorDO.getVisitDept());
 | 
	
		
			
				|  |  |             jsonObject.put("DEPT_NAME", baseDoctorDO.getVisitDeptName());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
 | 
	
		
			
				|  |  |         BasePatientDO basePatientDO = patientDao.findById(patient);
 | 
	
		
			
				|  |  |         jsonObject.put("PATIENT_NAME", basePatientDO.getName());
 | 
	
		
			
				|  |  |         SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
 | 
	
		
			
				|  |  |         if (null != patientMappingDO && null != basePatientDO) {
 | 
	
		
			
				|  |  |             jsonObject.put("PATIENT_ID", patientMappingDO.getMappingCode());
 | 
	
		
			
				|  |  |             jsonObject.put("GENDER", basePatientDO.getSex()==1?"男":"女");
 | 
	
		
			
				|  |  |             jsonObject.put("BIRTH", sdf.format(basePatientDO.getBirthday()));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         jsonObject.put("FEE_TYPE", "1".equalsIgnoreCase(payType) ? "医保" : "自费");
 | 
	
		
			
				|  |  |         jsonObject.put("CREATE_DATE", sdf.format(new Date()));
 | 
	
		
			
				|  |  |         //组装诊断参数
 | 
	
		
			
				|  |  |         if (null != diagnosisDOS && diagnosisDOS.size() > 0) {
 | 
	
		
			
				|  |  |             List diagnosises = new ArrayList();
 | 
	
		
			
				|  |  |             for (WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO : diagnosisDOS) {
 | 
	
		
			
				|  |  |                 diagnosises.add(wlyyPrescriptionDiagnosisDO.getName());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             jsonObject.put("diagnosises", StringUtils.strip(diagnosises.toString(),"[]"));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return jsonObject;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 |