update AKUZ.T_STATE_OF_TOOTH set GeneralCondition = (case when GeneralCondition = 7 then 1 else 7 end) where GeneralCondition > 6;

update AKUZ.T_STATE_OF_TOOTH set Part1 = (case when Part1 = 6 then 7
											   when	Part1 = 7 then 1
											   when	Part1 = 8 then 1
											   when	Part1 = 9 then 1
											   when	Part1 = 10 then 1
											   when	Part1 = 11 then 1 
											   when	Part1 = 12 then 1 
											   when	Part1 = 13 then 8 
											   when	Part1 = 14 then 9 
											   when	Part1 = 15 then 10 
											   when	Part1 = 16 then 11 
											   when	Part1 = 17 then 6 
											   end)  
where Part1 > 5;
update AKUZ.T_STATE_OF_TOOTH set Part2 = (case when Part2 = 6 then 7
											   when	Part2 = 7 then 1
											   when	Part2 = 8 then 1
											   when	Part2 = 9 then 1
											   when	Part2 = 10 then 1
											   when	Part2 = 11 then 1 
											   when	Part2 = 12 then 1 
											   when	Part2 = 13 then 8 
											   when	Part2 = 14 then 9 
											   when	Part2 = 15 then 10 
											   when	Part2 = 16 then 11 
											   when	Part2 = 17 then 6 
											   end)  
where Part2 > 5;
update AKUZ.T_STATE_OF_TOOTH set Part3 = (case when Part3 = 6 then 7
											   when	Part3 = 7 then 1
											   when	Part3 = 8 then 1
											   when	Part3 = 9 then 1
											   when	Part3 = 10 then 1
											   when	Part3 = 11 then 1 
											   when	Part3 = 12 then 1 
											   when	Part3 = 13 then 8 
											   when	Part3 = 14 then 9 
											   when	Part3 = 15 then 10 
											   when	Part3 = 16 then 11 
											   when	Part3 = 17 then 6 
											   end)  
where Part3 > 5;
update AKUZ.T_STATE_OF_TOOTH set Part4 = (case when Part4 = 6 then 7
											   when	Part4 = 7 then 1
											   when	Part4 = 8 then 1
											   when	Part4 = 9 then 1
											   when	Part4 = 10 then 1
											   when	Part4 = 11 then 1 
											   when	Part4 = 12 then 1 
											   when	Part4 = 13 then 8 
											   when	Part4 = 14 then 9 
											   when	Part4 = 15 then 10 
											   when	Part4 = 16 then 11 
											   when	Part4 = 17 then 6 
											   end)  
where Part4 > 5;
update AKUZ.T_STATE_OF_TOOTH set Part5 = (case when Part5 = 6 then 7
											   when	Part5 = 7 then 1
											   when	Part5 = 8 then 1
											   when	Part5 = 9 then 1
											   when	Part5 = 10 then 1
											   when	Part5 = 11 then 1 
											   when	Part5 = 12 then 1 
											   when	Part5 = 13 then 8 
											   when	Part5 = 14 then 9 
											   when	Part5 = 15 then 10 
											   when	Part5 = 16 then 11 
											   when	Part5 = 17 then 6 
											   end)  
where Part5 > 5;

delete from AKUZ.T_TOOTH_TEMPLATE_LINK_MEDICAL_SERVICE;
delete from AKUZ.T_TOOTH_TEMPLATE;