| 
					
				 | 
			
			
				@ -1,6 +1,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.jw.hospital.prescription.service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSON; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSONPObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.fasterxml.jackson.databind.ObjectMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.dict.dao.DictDeptDescDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.dict.dao.DictHospitalDeptDao; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -9344,7 +9345,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String idcard = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (natAppointmentDO != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            idcard = natAppointmentDO.getCardNo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            idcard = natAppointmentDO.getMedicare(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (!StringUtils.isNoneBlank(idcard)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("就诊卡不存在!"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -10494,12 +10495,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        jsondate.put("address4",streetName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        jsondate.put("address5",2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        jsondate.put("area",address); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        jsondate.put("winNo",6); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        jsondate.put("target",2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        jsondate.put("quantity",1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> map = findRandomDoctor(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        net.sf.json.JSONObject rs = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (map!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //先进行核算检测预约 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String result = entranceService.BS10144("3150000","0001",natTime,mediaCard,name,patientId,mobile,demoFlag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String result = entranceService.BS10144("3150000","0001",natTime,mediaCard,name,cardNo,mobile,demoFlag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.info("核酸检测预约结束"+result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Boolean flag = false; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -10531,7 +10534,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            returnMap.put("msg","已经挂号的数据有误"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            returnMap.put("status","-1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            return map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            returnMap.put("id",baseNatAppointmentDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            return returnMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        rs = entranceService.BS10111(mediaCard, map.get("doctorMappingCode").toString(), map.get("deptCode").toString(), "31", "6", demoFlag); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -10616,7 +10620,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            returnMap.put("msg","请求挂号失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            returnMap.put("status","-1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            return map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            returnMap.put("id",baseNatAppointmentDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            return returnMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        baseNatAppointmentDO.setDoctorId(map.get("doctorMappingCode").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -10629,7 +10634,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                com.alibaba.fastjson.JSONArray array = new com.alibaba.fastjson.JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                array.add(jsondate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject jsonObject  = entranceService.BS10112(array.toString(),flag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject jsonObject  = entranceService.BS10112(array.toString(),demoFlag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //判断返回结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String prers = jsonObject.getString("@RESULT"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //保存日志 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -10650,7 +10655,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String recipeTime = DateUtil.dateToStr(new Date(), "yyyyMMddHHmmss"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String applyDepaName = map.get("deptCode").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String voucherNo = jsonObject.getString("@xtgzh") ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String voucherNo = jsonObject.getString("@xtgzh0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String applyDoctorName = map.get("doctorName").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        BasePatientDO patientDO = basePatientDao.findById(patientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String userName = null; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -10666,22 +10671,23 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        logger.info("cardNo:" + cardNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        JSONObject jsonObject1 =entranceService.BS15054(patientMappingDO.getMappingCode(),realOrder,demoFlag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        /*JSONObject jsonObject1 =entranceService.BS15054(patientMappingDO.getMappingCode(),realOrder,demoFlag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        net.sf.json.JSONObject res = jsonObject1.getJSONObject("resquest"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        logger.info("获取待结算数据 res: " + res.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String rsCode = res.getString("@RESULT"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String free= 0+""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if ("0".equals(rsCode)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String rsCode = res.getString("@RESULT");*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String free= 80+""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        /*if ("0".equals(rsCode)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            free = res.getString("@total_charge"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        ylzPayService.msgPush("01", cardNo, "01", patientDO.getMobile(), "00", userNo, userName, idcard, voucherNo, applyDepaName, applyDoctorName, recipeTime, free, "1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        ylzPayService.msgPush("01", mediaCard, "01", patientDO.getMobile(), "00", userNo, userName, idcard, voucherNo, applyDepaName, applyDoctorName, recipeTime, free, "1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        /*//成功后发送模板消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        sendNatWxTemplat(name,cardNo,mobile,natTime,realOrder,"natAppointmentRemind");*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        returnMap.put("msg","核酸检测开方失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        returnMap.put("status","-1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        return map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        returnMap.put("id",baseNatAppointmentDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        return returnMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    e.printStackTrace(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -10689,10 +10695,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            returnMap.put("msg","预约成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            returnMap.put("status","200"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            returnMap.put("id",baseNatAppointmentDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return returnMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public MixEnvelop getNatRecords(String patientId,Integer page ,Integer pageSize){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "select t.name as \"name\"," + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -10749,12 +10756,24 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patientCode = patientMappingService.findHisPatNoByIdCard(patientDO.getIdcard()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                BaseNatAppointmentDO baseNatAppointmentDO = baseNatAppointmentDao.findOne(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (null!=baseNatAppointmentDO){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    res = entranceService.BS10145(baseNatAppointmentDO.getDept(),baseNatAppointmentDO.getDoctorId(),DateUtil.dateToStr(baseNatAppointmentDO.getAppointmentTime(),"yyyy-MM-dd hh:mm:ss"),baseNatAppointmentDO.getMedicare(),baseNatAppointmentDO.getName(),patientCode,baseNatAppointmentDO.getMobile(),demoFlag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    baseNatAppointmentDO.setIsSuccess("-1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    baseNatAppointmentDO.setCancelReson("患者本人取消"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    baseNatAppointmentDO.setCancelTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    baseNatAppointmentDO.setCancelBy(patientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    baseNatAppointmentDao.save(baseNatAppointmentDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    res = entranceService.BS10145("3150000","0001",DateUtil.dateToStr(baseNatAppointmentDO.getAppointmentTime(),"yyyy-MM-dd hh:mm:ss"),baseNatAppointmentDO.getMedicare(),baseNatAppointmentDO.getName(),baseNatAppointmentDO.getCardNo(),baseNatAppointmentDO.getMobile(),demoFlag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    logger.info("核酸检测预约取消"+res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Boolean flag = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (jsonObject!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        com.alibaba.fastjson.JSONObject object = jsonObject.getJSONObject("MsgInfo"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String Msg = object.getString("Msg"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (Msg.contains("Error")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            throw new Exception(Msg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            baseNatAppointmentDO.setIsSuccess("-1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            baseNatAppointmentDO.setCancelReson("患者本人取消"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            baseNatAppointmentDO.setCancelTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            baseNatAppointmentDO.setCancelBy(patientId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            baseNatAppointmentDao.save(baseNatAppointmentDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } catch (Exception e) { 
			 |