select * 
from rpt.pan_Diag_Desease_f12_pg( 
cast($1 as bigint), 
cast($2 as varchar), 
cast($3 as bigint), 
cast($4 as bigint), 
cast($5 as bigint), 
cast($6 as bigint), 
cast($7 as bigint), 
cast($8 as bigint), 
left(dbo.GetDiagCodeByID(cast($9 as bigint)), 3), 
right(dbo.GetDiagCodeByID(cast($10 as bigint)), 3) || '.9', 
cast($11 as bigint), 
cast($12 as bigint), 
cast($13 as bigint), 
cast( to_timestamp($14,'dd.mm.yyyy') as timestamp),
cast( to_timestamp($15,'dd.mm.yyyy') as timestamp),
cast($16 as bigint), 
cast($17 as bigint), 
cast($18 as bigint), 
cast($19 as bigint), 
cast($20 as bigint), 
cast($21 as bigint)) 
order by rnum  
