|  | @ -13,6 +13,7 @@ import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.doctor.WlyyDoctorWorkTimeDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.doctor.WlyyPatientRegisterTimeDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.prescription.*;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.consult.dao.DoctorClinicRoomConsultDao;
 | 
	
	
		
			
				|  | @ -21,6 +22,7 @@ import com.yihu.jw.hospital.dict.WlyyChargeDictDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.doctor.dao.DoctorWorkTimeDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.doctor.dao.PatientRegisterTimeDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.mapping.service.DoctorMappingService;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.mapping.service.PatientMappingService;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.dao.*;
 | 
	
	
		
			
				|  | @ -105,6 +107,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |     private DoctorWorkTimeDao doctorWorkTimeDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PatientRegisterTimeDao patientRegisterTimeDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private WlyyHttpLogDao wlyyHttpLogDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Value("${demo.flag}")
 | 
	
		
			
				|  |  |     private boolean demoFlag;
 | 
	
	
		
			
				|  | @ -258,6 +262,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         //居民详情
 | 
	
		
			
				|  |  |         BasePatientDO basePatientDO = basePatientDao.findById(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |         rs.put("patientName",basePatientDO.getName());
 | 
	
		
			
				|  |  |         rs.put("photo",basePatientDO.getPhoto());
 | 
	
		
			
				|  |  |         rs.put("patientId",basePatientDO.getId());
 | 
	
		
			
				|  |  |         rs.put("idCard",basePatientDO.getIdcard());
 | 
	
		
			
				|  |  |         rs.put("sex", basePatientDO.getSex());
 | 
	
	
		
			
				|  | @ -310,6 +315,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             rs.put("expressageLogs",null);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //预约记录
 | 
	
		
			
				|  |  |         List<WlyyPatientRegisterTimeDO> timeDOs = patientRegisterTimeDao.findByOutpatientId(outpatientId);
 | 
	
		
			
				|  |  |         if(timeDOs!=null&&timeDOs.size()>0){
 | 
	
		
			
				|  |  |             rs.put("register",timeDOs.get(0));
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             rs.put("register",null);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return rs;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -522,6 +535,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |     public Boolean createRoom(WlyyOutpatientDO outpatientDO,Date reservationTime){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         WlyyHospitalWaitingRoomDO waitingRoom = new WlyyHospitalWaitingRoomDO();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         waitingRoom.setDept(outpatientDO.getDept());
 | 
	
		
			
				|  |  |         waitingRoom.setDeptName(outpatientDO.getDeptName());
 | 
	
		
			
				|  |  |         waitingRoom.setHospital(outpatientDO.getHospital());
 | 
	
		
			
				|  |  |         waitingRoom.setHospitalName(outpatientDO.getHospitalName());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         waitingRoom.setConsultType(1);
 | 
	
		
			
				|  |  |         waitingRoom.setPatientId(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |         waitingRoom.setPatientName(outpatientDO.getPatientName());
 | 
	
	
		
			
				|  | @ -753,6 +772,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         if(doctorMappingDO==null){
 | 
	
		
			
				|  |  |             throw new RuntimeException("未找到医生映射信息");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         net.sf.json.JSONObject rs = entranceService.BS10111(outpatientDO.getCardNo(),doctorMappingDO.getMappingCode(),outpatientDO.getDept(),null,outpatientDO.getWinNo(),demoFlag);
 | 
	
		
			
				|  |  |         String rsCode = (String)rs.get("@RESULT");
 | 
	
		
			
				|  |  |         if("0".equals(rsCode)){
 | 
	
	
		
			
				|  | @ -762,7 +782,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             String conNo = (String)rs.get("@times");
 | 
	
		
			
				|  |  |             outpatientDO.setCardNo(conNo);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //保存日志
 | 
	
		
			
				|  |  |         WlyyHttpLogDO log = new WlyyHttpLogDO();
 | 
	
		
			
				|  |  |         log.setCode("registerOutPatient");
 | 
	
		
			
				|  |  |         log.setName("挂号");
 | 
	
		
			
				|  |  |         log.setPatient(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |         log.setDoctor(doctor);
 | 
	
		
			
				|  |  |         log.setResponse(rs.toString());
 | 
	
		
			
				|  |  |         log.setRequest("outPatientId="+outPatientId+"&doctor="+doctor);
 | 
	
		
			
				|  |  |         log.setStatus(rsCode);
 | 
	
		
			
				|  |  |         log.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         wlyyHttpLogDao.save(log);
 | 
	
		
			
				|  |  |         return rs;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -923,8 +953,22 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 
 | 
	
		
			
				|  |  |                 //调用his开方接口
 | 
	
		
			
				|  |  |                 net.sf.json.JSONObject jsonObject = entranceService.BS10112(jsonData.toJSONString(),demoFlag);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 //判断返回结果
 | 
	
		
			
				|  |  |                 String rs = jsonObject.getString("@RESULT");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 //保存日志
 | 
	
		
			
				|  |  |                 WlyyHttpLogDO log = new WlyyHttpLogDO();
 | 
	
		
			
				|  |  |                 log.setCode("makeDiagnosis");
 | 
	
		
			
				|  |  |                 log.setName("下诊断");
 | 
	
		
			
				|  |  |                 log.setPatient(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |                 log.setDoctor(outpatientDO.getDoctor());
 | 
	
		
			
				|  |  |                 log.setResponse(jsonObject.toString());
 | 
	
		
			
				|  |  |                 log.setRequest(jsonData.toJSONString());
 | 
	
		
			
				|  |  |                 log.setStatus(rs);
 | 
	
		
			
				|  |  |                 log.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                 wlyyHttpLogDao.save(log);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 if("0".equals(rs)){
 | 
	
		
			
				|  |  |                     String admNo = jsonObject.getString("@ADM_NO");
 | 
	
		
			
				|  |  |                     String realOrder = jsonObject.getString("@real_order");
 | 
	
	
		
			
				|  | @ -1420,6 +1464,98 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |     public List<WlyyHospitalSysDictDO> findCancelReasonList(){
 | 
	
		
			
				|  |  |         return sysDictDao.findByDictName("PatientCancel");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 獲取快速咨詢時間
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> findFastRegisterDate(){
 | 
	
		
			
				|  |  |         int days = 7;
 | 
	
		
			
				|  |  |         String AMStartTime ="8:00";
 | 
	
		
			
				|  |  |         String AMEndTime ="12:00";
 | 
	
		
			
				|  |  |         String PMStartTime ="14:00";
 | 
	
		
			
				|  |  |         String PMEndTime ="17:00";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //设置上午过号时间
 | 
	
		
			
				|  |  |         Calendar scTime = Calendar.getInstance();
 | 
	
		
			
				|  |  |         scTime.setTime(new Date());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Calendar ecTime = Calendar.getInstance();
 | 
	
		
			
				|  |  |         ecTime.setTime(new Date());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<Map<String,Object>> times = new ArrayList<>();
 | 
	
		
			
				|  |  |         for(int i=0;i<days;i++){
 | 
	
		
			
				|  |  |             //設置上午時段
 | 
	
		
			
				|  |  |             Map<String,Object> time = new HashedMap();
 | 
	
		
			
				|  |  |             time.put("timeType","1");
 | 
	
		
			
				|  |  |             time.put("date",DateUtil.dateToStr(scTime.getTime(),"yyyy-MM-dd"));
 | 
	
		
			
				|  |  |             time.put("weekDay",scTime.get(Calendar.DAY_OF_WEEK));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String ts[] = AMStartTime.split(":");
 | 
	
		
			
				|  |  |             scTime.set(scTime.get(Calendar.YEAR),scTime.get(Calendar.MONTH),scTime.get(Calendar.DAY_OF_MONTH),Integer.parseInt(ts[0]),Integer.parseInt(ts[1]),00);
 | 
	
		
			
				|  |  |             time.put("startTime",DateUtil.dateToStr(scTime.getTime(),"yyyy-MM-dd HH:mm:ss"));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String ts2[] = AMEndTime.split(":");
 | 
	
		
			
				|  |  |             scTime.set(scTime.get(Calendar.YEAR),scTime.get(Calendar.MONTH),scTime.get(Calendar.DAY_OF_MONTH),Integer.parseInt(ts2[0]),Integer.parseInt(ts2[1]),00);
 | 
	
		
			
				|  |  |             time.put("endTime",DateUtil.dateToStr(scTime.getTime(),"yyyy-MM-dd HH:mm:ss"));
 | 
	
		
			
				|  |  |             times.add(time);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //設置下午時段
 | 
	
		
			
				|  |  |             Map<String,Object> time2 = new HashedMap();
 | 
	
		
			
				|  |  |             time2.put("timeType","2");
 | 
	
		
			
				|  |  |             time2.put("date",DateUtil.dateToStr(scTime.getTime(),"yyyy-MM-dd"));
 | 
	
		
			
				|  |  |             time2.put("weekDay",scTime.get(Calendar.DAY_OF_WEEK));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String pts[] = PMStartTime.split(":");
 | 
	
		
			
				|  |  |             scTime.set(scTime.get(Calendar.YEAR),scTime.get(Calendar.MONTH),scTime.get(Calendar.DAY_OF_MONTH),Integer.parseInt(pts[0]),Integer.parseInt(pts[1]),00);
 | 
	
		
			
				|  |  |             time2.put("startTime",DateUtil.dateToStr(scTime.getTime(),"yyyy-MM-dd HH:mm:ss"));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String pts2[] = PMEndTime.split(":");
 | 
	
		
			
				|  |  |             scTime.set(scTime.get(Calendar.YEAR),scTime.get(Calendar.MONTH),scTime.get(Calendar.DAY_OF_MONTH),Integer.parseInt(pts2[0]),Integer.parseInt(pts2[1]),00);
 | 
	
		
			
				|  |  |             time2.put("endTime",DateUtil.dateToStr(scTime.getTime(),"yyyy-MM-dd HH:mm:ss"));
 | 
	
		
			
				|  |  |             times.add(time2);
 | 
	
		
			
				|  |  |             //生成下一天
 | 
	
		
			
				|  |  |             scTime.add(Calendar.DAY_OF_MONTH,1);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(DateUtil.strToDate(DateUtil.getTimeShort(),DateUtil.HH_MM).after(DateUtil.strToDate(AMEndTime,DateUtil.HH_MM))) {
 | 
	
		
			
				|  |  |             times.remove(0);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(DateUtil.strToDate(DateUtil.getTimeShort(),DateUtil.HH_MM).after(DateUtil.strToDate(PMEndTime,DateUtil.HH_MM))) {
 | 
	
		
			
				|  |  |             times.remove(0);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return times;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取快速咨询时间分段
 | 
	
		
			
				|  |  |      * @param startTime
 | 
	
		
			
				|  |  |      * @param endTime
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> findByTimeSlot(String startTime,String endTime){
 | 
	
		
			
				|  |  |         int interval = 30;
 | 
	
		
			
				|  |  |         List<Map<String,Object>> times = new ArrayList<>();
 | 
	
		
			
				|  |  |         //设置上午过号时间
 | 
	
		
			
				|  |  |         Calendar scTime = Calendar.getInstance();
 | 
	
		
			
				|  |  |         scTime.setTime(DateUtil.stringToDate(startTime,"yyyy-MM-dd HH:mm:ss"));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Calendar ecTime = Calendar.getInstance();
 | 
	
		
			
				|  |  |         ecTime.setTime(DateUtil.stringToDate(endTime,"yyyy-MM-dd HH:mm:ss"));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         while (scTime.getTime().before(ecTime.getTime())){
 | 
	
		
			
				|  |  |             if(new Date().before(scTime.getTime())){
 | 
	
		
			
				|  |  |                 Map<String,Object> time = new HashedMap();
 | 
	
		
			
				|  |  |                 time.put("startTime",DateUtil.dateToStr(scTime.getTime(),"yyyy-MM-dd HH:mm:ss"));
 | 
	
		
			
				|  |  |                 scTime.add(Calendar.MINUTE,interval);
 | 
	
		
			
				|  |  |                 time.put("endTime",DateUtil.dateToStr(scTime.getTime(),"yyyy-MM-dd HH:mm:ss"));
 | 
	
		
			
				|  |  |                 times.add(time);
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 scTime.add(Calendar.MINUTE,interval);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return times;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 根据疾病名称,热门部门查询医生
 |