
select *,"Pol_count" as "Pol_Count"
from rpt.p_pan_evnvizitpl_pg(
cast($1 as int8), 
cast($2 as int8), 
cast($3 as int8), 
cast($4 as int8), 
cast($5 as int8), 
cast($6 as int8), 
cast($7 as int8), 
cast($8 as int8), 
cast($9 as int8), 
cast($10 as int8), 
cast($11 as int8), 
cast(to_timestamp($12,'dd.mm.yyyy') as timestamp), 
cast(to_timestamp($13,'dd.mm.yyyy') as timestamp), 
cast($14 as int8),
rpt.getdiagcodebyid_pg(cast($15 as int8)), 
rpt.getdiagcodebyid_pg(cast($16 as int8))
)
