| 
					
				 | 
			
			
				@ -3792,6 +3792,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " LEFT JOIN wlyy_charge_dict g ON t.jyzx_charge_type = g.charge_type\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "WHERE t.id = '"+doctorDO.getId()+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            chargeDictDOLists =  hibenateUtils.createSQLQuery(sqlCharge); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //System.out.println(chargeDictDOLists.get(1)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            rs.put("chargeTypeList",chargeDictDOLists); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //机构科室信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findByDoctorCode(doctorDO.getId()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -5096,7 +5097,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @query_status 0:图文复诊候诊 1:图文复诊抢单列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @dept 部门 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String, Object>> findWaitingRoomOutpatientByDoctor(String doctor, Integer type, Integer query_status, String dept,String sex,String keyword,String ageGroup) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String, Object>> findWaitingRoomOutpatientByDoctor(String doctor, Integer type, Integer query_status, String dept,String sex,String keyword,String ageGroup,String patient) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "room.outpatient_id AS \"id\"," + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -5177,6 +5178,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }if(StringUtils.isNoneBlank(keyword)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND outpatient.patient_name like '%" + keyword + "%' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNoneBlank(patient)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND (outpatient.patient= '" + patient + "' or outpatient.consumer ='"+patient+"') "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNoneBlank(ageGroup)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String[] age = ageGroup.split(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Calendar nowBegin = Calendar.getInstance(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -9864,13 +9868,20 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param size 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PageEnvelop findPatientAllPrescription(String keyName, String status, Integer page, Integer size,String patient,String isSelectDrug) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public PageEnvelop findPatientAllPrescription(String keyName, String status, Integer page, Integer size,String patient,String isSelectDrug,boolean consumerflag) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO patientDO = basePatientDao.findById(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (patientDO==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return PageEnvelop.getError("找不到该患者",-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        StringBuffer sql = new StringBuffer(" SELECT DISTINCT b.*, c.oneself_pickup_flg,f.job_title_code,f.job_title_name  FROM (SELECT a.* FROM wlyy_prescription a left join wlyy_outpatient o ON o.id=a.outpatient_id  WHERE o.consumer = '"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        StringBuffer countSql = new StringBuffer("select COUNT(DISTINCT b.id) count FROM (SELECT a.* FROM wlyy_prescription a left join wlyy_outpatient o ON o.id=a.outpatient_id  WHERE o.consumer = '"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        /*if (consumerflag){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql.append(" WHERE o.consumer = '"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            countSql.append(" WHERE o.consumer = '"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql.append(" WHERE o.patient = '"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            countSql.append(" WHERE o.patient = '"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql.append(patient).append("') b  LEFT JOIN wlyy_prescription_expressage c ON c.outpatient_id = b.outpatient_id LEFT JOIN base_doctor f ON b.doctor=f.id  "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        countSql.append(patient).append("') b  LEFT JOIN wlyy_prescription_expressage c ON c.outpatient_id = b.outpatient_id LEFT JOIN base_doctor f ON b.doctor=f.id  "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(isSelectDrug)){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -9917,14 +9928,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " b.doctor_name LIKE '%" + keyName + "%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " OR b.dept_name LIKE'%" + keyName + "%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " OR b.hospital_name LIKE '%" + keyName + "%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " OR d.drug_name LIKE '%" + keyName + "%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " OR m.drug_name LIKE '%" + keyName + "%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " OR b.real_order LIKE '%" + keyName + "%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    ")"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            countSql.append(" and (" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " b.doctor_name LIKE '%" + keyName + "%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " OR b.dept_name LIKE'%" + keyName + "%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " OR b.hospital_name LIKE '%" + keyName + "%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " OR d.drug_name LIKE '%" + keyName + "%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " OR m.drug_name LIKE '%" + keyName + "%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " OR b.real_order LIKE '%" + keyName + "%' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    ")"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -10308,13 +10319,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       return envelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    //应声开具处方管理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public MixEnvelop prescriptionManage(String keyWord,String doctorId,String startTime,String endTime,String checkStatus,Integer page,Integer pageSize){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public MixEnvelop prescriptionManage(String keyWord,String doctorId,String startTime,String endTime,String checkStatus,String status,Integer page,Integer pageSize){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = " select p.create_time as \"createTime\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.patient_name as \"patientName\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.idcard as \"idcard\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " o.card_no as \"cardNo\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.check_status as \"checkStatus\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.id as \"id\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.status as \"status\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " p.check_reason as \"checkReason\" " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " from wlyy_prescription p left join wlyy_outpatient o on p.outpatient_id  = o.id" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " where  1=1 "; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -10327,6 +10339,16 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" and p.check_status != 4"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(status)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if ("0".equalsIgnoreCase(status)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql+=" and p.status = 20"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else if ("-4".equalsIgnoreCase(status)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql+=" and p.status = -4"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql+=" and p.status > 20"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(doctorId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" and p.doctor = '"+doctorId+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -10425,6 +10447,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if("xm_zsyy_wx".equalsIgnoreCase(wechatId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                /*prescriptionDao.updateCheckStatus(prescriptionId,2,reason,20);*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                logger.info("作废处方开始" + prescriptionDO.getCheckStatus()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                WlyyOutpatientDO outpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(outpatientDO.getDoctor(), outpatientDO.getHospital()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<WlyyPrescriptionInfoDO> infoDOS = prescriptionInfoDao.findByPrescriptionId(prescriptionId, 1); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -10456,19 +10479,26 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    net.sf.json.JSONObject jsonObject = entranceService.BS10112(jsonData.toJSONString(), demoFlag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    wlyyHttpLogDO.setResponse(jsonObject.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return "删除失败"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return "作废失败"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                wlyyHttpLogDO.setRequest(jsonData.toJSONString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                wlyyHttpLogDO.setName("作废处方"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                wlyyHttpLogDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                wlyyHttpLogDO.setCode(outpatientDO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                wlyyHttpLogDao.save(wlyyHttpLogDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionDO.setStatus(-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionDO.setCheckStatus(4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionDO.setCheckReason("已删除"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionDO.setStatus(-4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionDO.setDisableTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionDO.setCheckStatus(5); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionDO.setCheckReason("已作废"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionDao.save(prescriptionDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return "删除成功"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return "已作废"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return "删除失败"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return "作废失败"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 |