| 
					
				 | 
			
			
				@@ -33,11 +33,12 @@ public interface SiSettleApplyDao { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "#{inputComment},getdate(),0,#{type},#{settleDatetime},0,#{acctUsedFlag},#{deathFlag},#{sortNo})") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     void insertSettleApply(SiSettleApply apply); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Select("select a.pat_no,a.times,a.ledger_sn,a.status,a.type,c.sex as gender,rtrim(c.name) as name,b.med_type, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "wardName=(select rtrim(name) from zd_unit_code with(nolock) where code=c.ward),a.death_flag,a.sort_no " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Select("select a.*,c.sex as gender,rtrim(c.name) as name,b.med_type, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            "handleStaffName=(select rtrim(d.name) from a_employee_mi d where d.code=a.handle_staff)," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            "wardName=(select rtrim(name) from zd_unit_code with(nolock) where code=c.ward) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "from t_si_settle_apply a with(nolock), t_si_pat_info b with(nolock), zy_actpatient c with(nolock) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "where a.settled=0 and a.pat_no=b.pat_no and a.times=b.times " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "and a.ledger_sn=b.ledger_sn and a.pat_no=c.inpatient_no") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            "where a.settled=0 and a.pat_no=b.pat_no and a.times=b.times and a.ledger_sn=b.ledger_sn and a.pat_no=c.inpatient_no " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            "and sort_no=(select max(sort_no) from t_si_settle_apply c where c.pat_no=a.pat_no and c.times=a.times and c.ledger_sn=a.ledger_sn and c.type=a.type)") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     List<SiSettleApply> selectUnhandledApplies(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Select("select a.pat_no,a.times,a.ledger_sn,a.input_staff,a.input_comment,a.input_datetime,a.status,a.handle_staff,a.acct_used_flag, " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -68,4 +69,8 @@ public interface SiSettleApplyDao { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "handle_comment=#{handleComment},handle_datetime=getdate() where pat_no=#{patNo} " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             "and times=#{times} and ledger_sn=#{ledgerSn} and type=#{type} and sort_no=#{sortNo}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     void handleApply(SiSettleApply apply); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Select("select * from t_si_settle_apply where pat_no=#{patNo} and times=#{times} and " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            "ledger_sn=#{ledgerSn} and type=#{type} order by sort_no") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    List<SiSettleApply> selectApplyHistories(SiSettleApply apply); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |