update SterilizationRecord 
 set sterilizationResult='合格'
 where status='灭菌完成'
 and sterilizationResult is null
 and id in(
	select ti.sterilizationRecord_id from TousseDefinition td 
	join TousseInstance ti on ti.tousseDefinition_id=td.id 
	where ti.sterilizationRecord_id=SterilizationRecord.id and td.includeImplant=0
 ) and (biologyResult='合格' and (physicsResult is null or physicsResult<>'不合格') and (chemistryResult is null or chemistryResult<>'不合格'));
 update SterilizationRecord 
 set sterilizationResult='合格'
 where status='灭菌完成'
 and sterilizationResult is null and id in(
 select ti.sterilizationRecord_id from TousseDefinition td 
 join TousseInstance ti on ti.tousseDefinition_id=td.id 
 where ti.sterilizationRecord_id=SterilizationRecord.id and td.includeImplant=1) and 
 (biologyResult='合格' and  (physicsResult is null or physicsResult<>'不合格') and (chemistryResult is null or chemistryResult<>'不合格')
 or
 (biologyResult is null or biologyResult='' or biologyResult ='无' ) and (physicsResult is null or physicsResult<>'不合格') and (chemistryResult is null or chemistryResult<>'不合格')
 );
update SterilizationRecord 
 set sterilizationResult='不合格' where status='灭菌完成' and sterilizationResult is null
 and ((id in(select ti.sterilizationRecord_id from TousseDefinition td 
 join TousseInstance ti on ti.tousseDefinition_id=td.id 
 where ti.sterilizationRecord_id=SterilizationRecord.id and td.includeImplant=0) and (
 (biologyResult='合格' and (physicsResult='合格' or chemistryResult='合格') ) or biologyResult='不合格'
 or ((biologyResult is null or biologyResult='无') and (physicsResult='不合格' or chemistryResult='不合格')  ))) or (
 id in(select ti.sterilizationRecord_id from TousseDefinition td 
 join TousseInstance ti on ti.tousseDefinition_id=td.id 
 where ti.sterilizationRecord_id=SterilizationRecord.id and td.includeImplant=1)
 and 
 (biologyResult='合格' and (physicsResult='不合格' or chemistryResult='不合格') or
 biologyResult='不合格'
 or
 (biologyResult is null or biologyResult ='无') and (physicsResult='不合格' or chemistryResult='不合格')
 )));