select * from rpt.book_stick_pg( 
cast($1 as int8), 
cast($2 as int4), 
dbo.GetDiagCodeByID(cast( $3 as int8)),  
dbo.GetDiagCodeByID(cast( $4 as int8)), 
cast($5 as int4), 
cast(to_timestamp($6, 'dd.mm.yyyy') as timestamp), 
cast(to_timestamp($7, 'dd.mm.yyyy') as timestamp) 
) order by 19, 1 
