| 
					
				 | 
			
			
				@ -90,6 +90,12 @@ public class PrescriptionInfoService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionExpressageService expressageService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionService prescriptionService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionReasonDictDao prescriptionReasonDictDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionReviewedReasonDao prescriptionReviewedReasonDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionAdjustReasonDao prescriptionAdjustReasonDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -153,13 +159,13 @@ public class PrescriptionInfoService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param type 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public com.alibaba.fastjson.JSONArray getPrescriptionInfos(String type, String diagnosisCode, String startDate, String endDate, String patient, String isRenewal, Integer page, Integer size) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public com.alibaba.fastjson.JSONArray getPrescriptionInfos(String type,String recipeNo, String diagnosisCode, String startDate, String endDate, String patient, String isRenewal, Integer page, Integer size) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(type)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if ("1".equals(type)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Patient p = patientDao.findByCode(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String rp = jwPrescriptionService.getRecipeList(p.getSsc(), null, startDate, endDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String rp = jwPrescriptionService.getLastRecipe(p.getSsc(), recipeNo, startDate, endDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                com.alibaba.fastjson.JSONArray pres = presModeAdapter.modeToPrescription(rp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(pres==null||pres.size()==0){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -567,7 +573,7 @@ public class PrescriptionInfoService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            pre_sql.append(" AND pr.patient = ?"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            params.add(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        pre_sql.append(" GROUP BY pr.code ORDER BY pr.min_drug_day-TIMESTAMPDIFF(DAY, pr.pres_create_time, NOW()) ASC"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        pre_sql.append(" GROUP BY pr.code ORDER BY pr.min_drug_day-TIMESTAMPDIFF(DAY, pr.pres_create_time, NOW()),pr.create_time ASC"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (page != null && page > 0 && size != null && size > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            pre_sql.append(" LIMIT " + (page - 1) * size + "," + size); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -608,7 +614,7 @@ public class PrescriptionInfoService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return rs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public int reviewPrescription(String code, String reason, String state, String dept, String registerFee, String rateTypeCode) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public int reviewPrescription(String code, String reason,String reasonCode, String state, String dept, String registerFee, String rateTypeCode) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(state)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Prescription p = prescriptionDao.findByCode(code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //更新审核记录 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -628,6 +634,8 @@ public class PrescriptionInfoService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                reviewed.setReason(reason); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                reviewed.setReviewedTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                reviewed.setStatus(PrescriptionReviewed.PrescriptionReviewedStatus.reviewed_fail.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //保存审核不通过原因 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                saveReviewedReason(reasonCode,reviewed.getCode(),code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //修改系统的续方消息的审核状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                messageDao.updatePreScriptionMessage(p.getConsult(), "2", 6); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -669,7 +677,7 @@ public class PrescriptionInfoService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public int updatePresInfo(String code, String infos, String diagnosis, String reason) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public int updatePresInfo(String code, String infos, String diagnosis, String reason,String reasonCode) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(code) && StringUtils.isNotBlank(infos)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //同步智业接口 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            upload(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -741,11 +749,48 @@ public class PrescriptionInfoService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionAdjust.setPrescriptionCode(code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionAdjustDao.save(prescriptionAdjust); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //保存原因 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            saveAjustReason(reasonCode,prescriptionAdjust,code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void saveAjustReason(String reasonCode,PrescriptionAdjust prescriptionAdjust,String code){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(reasonCode)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String reasoncodes[] = reasonCode.split(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(int i=0;i<reasoncodes.length;i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                PrescriptionReasonDict  dict =  prescriptionReasonDictDao.findByTypeAndCode(0,reasoncodes[i]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                PrescriptionAdjustReason prescriptionAdjustReason = new PrescriptionAdjustReason(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                prescriptionAdjustReason.setCode(getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                prescriptionAdjustReason.setPrescriptionCode(code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                prescriptionAdjustReason.setAdjustCode(prescriptionAdjust.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                prescriptionAdjustReason.setReasonCode(reasoncodes[i]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                prescriptionAdjustReason.setReasonValue(dict.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                prescriptionAdjustReason.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                prescriptionAdjustReasonDao.save(prescriptionAdjustReason); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void saveReviewedReason(String reasonCode,String reviewedCode ,String code){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(reasonCode)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String reasoncodes[] = reasonCode.split(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(int i=0;i<reasoncodes.length;i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                PrescriptionReasonDict  dict =  prescriptionReasonDictDao.findByTypeAndCode(0,reasoncodes[i]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                PrescriptionReviewedReason prescriptionReviewedReason = new PrescriptionReviewedReason(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                prescriptionReviewedReason.setCode(getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                prescriptionReviewedReason.setPrescriptionCode(code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                prescriptionReviewedReason.setReviewedCode(reviewedCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                prescriptionReviewedReason.setReasonCode(reasoncodes[i]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                prescriptionReviewedReason.setReasonValue(dict.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                prescriptionReviewedReason.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                prescriptionReviewedReasonDao.save(prescriptionReviewedReason); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String upload() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1237,6 +1282,7 @@ public class PrescriptionInfoService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param doctor 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public com.alibaba.fastjson.JSONArray getPrescriptionTemp(String doctor) throws Exception { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1319,4 +1365,10 @@ public class PrescriptionInfoService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql.toString(),new Object[]{code}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return rs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<PrescriptionReasonDict> getReasonByType(Integer type){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<PrescriptionReasonDict> list =  prescriptionReasonDictDao.findByTypeOrderBySortAsc(type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |