|  | @ -672,7 +672,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Boolean cancelPrescription(String prescriptionId) {
 | 
	
		
			
				|  |  |     public Boolean cancelPrescription(String prescriptionId){
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionId);
 | 
	
		
			
				|  |  |         prescriptionDO.setStatus(-2);
 | 
	
		
			
				|  |  |         return true;
 | 
	
	
		
			
				|  | @ -680,18 +680,18 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * @param admNo     门诊唯一号
 | 
	
		
			
				|  |  |      *@param admNo 门诊唯一号
 | 
	
		
			
				|  |  |      * @param realOrder 处方号
 | 
	
		
			
				|  |  |      * @param status    处方状态 1审方失败,2审核完成,3结算完成
 | 
	
		
			
				|  |  |      *  @param status 处方状态 1审方失败,2审核完成,3结算完成
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Map<String, Object> updatePrescriptionByHisStatu(String admNo, String realOrder, String status) throws Exception {
 | 
	
		
			
				|  |  |         Map<String, Object> rs = new HashedMap();
 | 
	
		
			
				|  |  |     public Map<String,Object> updatePrescriptionByHisStatu(String admNo,String realOrder,String status)throws Exception {
 | 
	
		
			
				|  |  |         Map<String,Object> rs = new HashedMap();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String sql = "";
 | 
	
		
			
				|  |  |         //status 处方流程状态 ,13  开方失败/调整中,20 诊断完成/开方成功/待支付,已完成:100 已完成
 | 
	
		
			
				|  |  |         //pay_status`:处方结算状态,0为未结算,1为结算成功,默认为0',
 | 
	
		
			
				|  |  |         String outPatientSql = "";
 | 
	
		
			
				|  |  |         String outPatientSql="";
 | 
	
		
			
				|  |  |         if ("1".equals(status)) {
 | 
	
		
			
				|  |  |             sql = "UPDATE base.wlyy_prescription p SET p.`status`='13' WHERE p.adm_no='" + admNo + "' AND p.real_order='" + realOrder + "' ";
 | 
	
		
			
				|  |  |             WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findByRealOrder(realOrder);
 | 
	
	
		
			
				|  | @ -701,7 +701,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             //开方成功时候,先用处方号获取本地处方状态是否为开方失败,如果是则需要更新本地的处方
 | 
	
		
			
				|  |  |             sql = "UPDATE base.wlyy_prescription p SET p.`status`='20' WHERE p.adm_no='" + admNo + "' AND p.real_order='" + realOrder + "' ";
 | 
	
		
			
				|  |  |             //变更门诊状态
 | 
	
		
			
				|  |  |             outPatientSql = "UPDATE base.wlyy_outpatient p SET p.`status`='2' WHERE p.adm_no='" + admNo + "'";
 | 
	
		
			
				|  |  |             outPatientSql="UPDATE base.wlyy_outpatient p SET p.`status`='2' WHERE p.adm_no='" + admNo + "'";
 | 
	
		
			
				|  |  |             jdbcTemplate.execute(outPatientSql);
 | 
	
		
			
				|  |  |             jdbcTemplate.execute(sql);
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -715,7 +715,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 wlyyPrescriptionDO.setPayStatus(1);
 | 
	
		
			
				|  |  |                 wlyyPrescriptionDO.setStatus(100);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 prescriptionLogService.addPrescriptionLog(wlyyPrescriptionDO.getId(), 100, 2, outpatientDO.getDoctor(), outpatientDO.getDoctorName(), "", new Date());
 | 
	
		
			
				|  |  |                 prescriptionLogService.addPrescriptionLog(wlyyPrescriptionDO.getId(),100,2,outpatientDO.getDoctor(),outpatientDO.getDoctorName(),"",new Date());
 | 
	
		
			
				|  |  |                 prescriptionDao.save(wlyyPrescriptionDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             } else {
 | 
	
	
		
			
				|  | @ -723,30 +723,30 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 wlyyPrescriptionDO.setPayStatus(1);
 | 
	
		
			
				|  |  |                 wlyyPrescriptionDO.setStatus(32);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 try {
 | 
	
		
			
				|  |  |                     WlyyPrescriptionVO vo = findOriginPrescription(outpatientDO.getRegisterNo(), outpatientDO.getPatient(), admNo, realOrder, demoFlag);
 | 
	
		
			
				|  |  |                 try{
 | 
	
		
			
				|  |  |                     WlyyPrescriptionVO vo = findOriginPrescription(outpatientDO.getRegisterNo(),outpatientDO.getPatient(),admNo,realOrder,demoFlag);
 | 
	
		
			
				|  |  |                     wlyyPrescriptionDO.setDispUser(vo.getDispUser());
 | 
	
		
			
				|  |  |                     wlyyPrescriptionDO.setDispUserName(vo.getDispUserName());
 | 
	
		
			
				|  |  |                     wlyyPrescriptionDO.setDispDate(new Date());
 | 
	
		
			
				|  |  |                     prescriptionLogService.addPrescriptionLog(wlyyPrescriptionDO.getId(), 32, 2, vo.getDispUser(), vo.getDispUserName(), "", new Date());
 | 
	
		
			
				|  |  |                 } catch (Exception e) {
 | 
	
		
			
				|  |  |                     logger.error("获取处方信息异常" + e.toString());
 | 
	
		
			
				|  |  |                     prescriptionLogService.addPrescriptionLog(wlyyPrescriptionDO.getId(),32,2,vo.getDispUser(),vo.getDispUserName(),"",new Date());
 | 
	
		
			
				|  |  |                 }catch (Exception e){
 | 
	
		
			
				|  |  |                     logger.error("获取处方信息异常"+e.toString());
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 prescriptionDao.save(wlyyPrescriptionDO);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //发送取药系统消息
 | 
	
		
			
				|  |  |             SystemMessageDO systemMessageDO = sendPatientGetDrugMes(outpatientDO, wlyyPrescriptionDO);
 | 
	
		
			
				|  |  |             SystemMessageDO systemMessageDO = sendPatientGetDrugMes(outpatientDO,wlyyPrescriptionDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             rs.put("mes", systemMessageDO);
 | 
	
		
			
				|  |  |             rs.put("mes",systemMessageDO);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         rs.put("flag", true);
 | 
	
		
			
				|  |  |         rs.put("flag",true);
 | 
	
		
			
				|  |  |         return rs;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public SystemMessageDO sendPatientGetDrugMes(WlyyOutpatientDO outpatient, WlyyPrescriptionDO prescriptionDO) {
 | 
	
		
			
				|  |  |     public SystemMessageDO sendPatientGetDrugMes(WlyyOutpatientDO outpatient,WlyyPrescriptionDO prescriptionDO){
 | 
	
		
			
				|  |  |         SystemMessageDO systemMessageDO = new SystemMessageDO();
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |         try{
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             systemMessageDO.setTitle("患者取药");
 | 
	
		
			
				|  |  |             systemMessageDO.setType("7");
 | 
	
	
		
			
				|  | @ -758,38 +758,37 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             systemMessageDO.setRelationCode(outpatient.getId());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             JSONObject data = new JSONObject();
 | 
	
		
			
				|  |  |             data.put("name", outpatient.getPatientName());
 | 
	
		
			
				|  |  |             data.put("age", IdCardUtil.getAgeForIdcard(outpatient.getIdcard()));
 | 
	
		
			
				|  |  |             data.put("gender", IdCardUtil.getSexForIdcard_new(outpatient.getIdcard()));
 | 
	
		
			
				|  |  |             data.put("recipeType", prescriptionDO.getDispensaryType());
 | 
	
		
			
				|  |  |             data.put("message", "患者已完成取药");
 | 
	
		
			
				|  |  |             data.put("name",outpatient.getPatientName());
 | 
	
		
			
				|  |  |             data.put("age",IdCardUtil.getAgeForIdcard(outpatient.getIdcard()));
 | 
	
		
			
				|  |  |             data.put("gender",IdCardUtil.getSexForIdcard_new(outpatient.getIdcard()));
 | 
	
		
			
				|  |  |             data.put("recipeType",prescriptionDO.getDispensaryType());
 | 
	
		
			
				|  |  |             data.put("message","患者已完成取药");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             systemMessageDO.setData(data.toString());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             systemMessageService.saveMessage(systemMessageDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             logger.error("sendPatientGetDrugMes :" + e.toString());
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             logger.error("sendPatientGetDrugMes :"+e.toString());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return systemMessageDO;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取卡记录
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param patient
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONArray findPatientCard(String patient) throws Exception {
 | 
	
		
			
				|  |  |     public JSONArray findPatientCard(String patient)throws Exception{
 | 
	
		
			
				|  |  |         BasePatientDO patientDO = basePatientDao.findById(patient);
 | 
	
		
			
				|  |  |         JSONArray res = entranceService.BS15018(patientDO.getIdcard(), null, demoFlag);
 | 
	
		
			
				|  |  |         JSONArray res = entranceService.BS15018(patientDO.getIdcard(),null,demoFlag);
 | 
	
		
			
				|  |  |         JSONArray rs = new JSONArray();
 | 
	
		
			
				|  |  |         if (res != null) {
 | 
	
		
			
				|  |  |             for (int i = 0; i < res.size(); i++) {
 | 
	
		
			
				|  |  |         if(res !=null){
 | 
	
		
			
				|  |  |             for (int i =0;i<res.size();i++){
 | 
	
		
			
				|  |  |                 JSONObject card = res.getJSONObject(i);
 | 
	
		
			
				|  |  |                 String cardStat = card.getString("CARD_STAT");
 | 
	
		
			
				|  |  |                 if ("激活".equals(cardStat)) {
 | 
	
		
			
				|  |  |                 if("激活".equals(cardStat)){
 | 
	
		
			
				|  |  |                     rs.add(card);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
	
		
			
				|  | @ -798,54 +797,53 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Map<String, Object> checkOutpatient(String patient) throws Exception {
 | 
	
		
			
				|  |  |     public Map<String,Object> checkOutpatient(String patient)throws Exception{
 | 
	
		
			
				|  |  |         //-1卡余额不足,,-2 存在未结束的诊断热 1成功
 | 
	
		
			
				|  |  |         Map<String, Object> rs = new HashedMap();
 | 
	
		
			
				|  |  |         Map<String,Object> rs = new HashedMap();
 | 
	
		
			
				|  |  |         //1.余额判断改到前端判断
 | 
	
		
			
				|  |  |         //net.sf.json.JSONObject json = entranceService.qutpatientBalance(cardNo,demoFlag);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //2.判断是否有未结束的
 | 
	
		
			
				|  |  |         List<WlyyOutpatientDO> list = outpatientDao.findByPatientList(patient);
 | 
	
		
			
				|  |  |         if (list != null && list.size() > 0) {
 | 
	
		
			
				|  |  |             rs.put("outpatient", list.get(0));
 | 
	
		
			
				|  |  |             rs.put("code", -2);
 | 
	
		
			
				|  |  |             rs.put("mes", "存在未结束的诊断");
 | 
	
		
			
				|  |  |         if(list!=null&&list.size()>0){
 | 
	
		
			
				|  |  |             rs.put("outpatient",list.get(0));
 | 
	
		
			
				|  |  |             rs.put("code",-2);
 | 
	
		
			
				|  |  |             rs.put("mes","存在未结束的诊断");
 | 
	
		
			
				|  |  |             return rs;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         rs.put("code", 1);
 | 
	
		
			
				|  |  |         rs.put("mes", "验证通过");
 | 
	
		
			
				|  |  |         rs.put("code",1);
 | 
	
		
			
				|  |  |         rs.put("mes","验证通过");
 | 
	
		
			
				|  |  |         return rs;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取所有医院列表
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<BaseOrgVO> findAllHospital(Integer level, String keyWord) {
 | 
	
		
			
				|  |  |     public List<BaseOrgVO> findAllHospital(Integer level,String keyWord){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneEmpty(keyWord)) {
 | 
	
		
			
				|  |  |             keyWord = "%" + keyWord + "%";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (level != null) {
 | 
	
		
			
				|  |  |                 List<BaseOrgDO> list = baseOrgDao.findByLevelAndName(level, "1", keyWord);
 | 
	
		
			
				|  |  |             if(level!=null){
 | 
	
		
			
				|  |  |                 List<BaseOrgDO> list = baseOrgDao.findByLevelAndName(level,"1",keyWord);
 | 
	
		
			
				|  |  |                 List<BaseOrgVO> rs = new ArrayList<>();
 | 
	
		
			
				|  |  |                 return convertToModels(list, rs, BaseOrgVO.class);
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 List<BaseOrgDO> list = baseOrgDao.findByDelAndName("1", keyWord);
 | 
	
		
			
				|  |  |                 return convertToModels(list,rs,BaseOrgVO.class);
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 List<BaseOrgDO> list = baseOrgDao.findByDelAndName("1",keyWord);
 | 
	
		
			
				|  |  |                 List<BaseOrgVO> rs = new ArrayList<>();
 | 
	
		
			
				|  |  |                 return convertToModels(list, rs, BaseOrgVO.class);
 | 
	
		
			
				|  |  |                 return convertToModels(list,rs,BaseOrgVO.class);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (level != null) {
 | 
	
		
			
				|  |  |                 List<BaseOrgDO> list = baseOrgDao.findByLevelAndDel(level, "1");
 | 
	
		
			
				|  |  |             if(level!=null){
 | 
	
		
			
				|  |  |                 List<BaseOrgDO> list = baseOrgDao.findByLevelAndDel(level,"1");
 | 
	
		
			
				|  |  |                 List<BaseOrgVO> rs = new ArrayList<>();
 | 
	
		
			
				|  |  |                 return convertToModels(list, rs, BaseOrgVO.class);
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 return convertToModels(list,rs,BaseOrgVO.class);
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 List<BaseOrgDO> list = baseOrgDao.findByDel("1");
 | 
	
		
			
				|  |  |                 List<BaseOrgVO> rs = new ArrayList<>();
 | 
	
		
			
				|  |  |                 return convertToModels(list, rs, BaseOrgVO.class);
 | 
	
		
			
				|  |  |                 return convertToModels(list,rs,BaseOrgVO.class);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -885,8 +883,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      * @param dept
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String, Object>> findDoctorByHospitalAndDept(String orgCode, String dept, String chargeType, String doctorCode, String outpatientType, String startDate, String endDate, String key, String consultStatus) {
 | 
	
		
			
				|  |  |         String sql = "SELECT " +
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> findDoctorByHospitalAndDept(String orgCode,String dept,String chargeType,String doctorCode,String outpatientType,String startDate,String endDate,String key,String consultStatus){
 | 
	
		
			
				|  |  |         String sql ="SELECT " +
 | 
	
		
			
				|  |  |                 " d.id, " +
 | 
	
		
			
				|  |  |                 " d.photo, " +
 | 
	
		
			
				|  |  |                 " d.`name`, " +
 |