insert into dbo.mesolduslugacomplex (
mesolduslugacomplex_id,uslugacomplex_id,mes_id,sex_id,mesagegroup_id,diag_id,diag_nid,diag_oid,
mesolduslugacomplex_isdiag,mesolduslugacomplex_begdt,pmuser_insid,pmuser_updid,mesolduslugacomplex_insdt,
mesolduslugacomplex_upddt,mesolduslugacomplex_duration,mesolduslugacomplex_durationto,drugtherapyscheme_id,
rehabscale_id,mesolduslugacomplex_sofascalepoints,mesolduslugacomplex_ivlhours,uslugacomplex_aid,
uslugacomplex_bid,mesolduslugacomplex_fracfrom,mesolduslugacomplex_fracto,mesdop_id
)
select
    nextval('mesolduslugacomplex_mesolduslugacomplex_id_seq') as mesolduslugacomplex_id,
    uslugacomplex_id,mes_id,sex_id,mesagegroup_id,diag_id,diag_nid,diag_oid,mesolduslugacomplex_isdiag,mesolduslugacomplex_begdt,
    1 as pmuser_insid,1 as pmuser_updid,now() as mesolduslugacomplex_insdt,now() as mesolduslugacomplex_upddt,
    mesolduslugacomplex_duration,mesolduslugacomplex_durationto,drugtherapyscheme_id,rehabscale_id,mesolduslugacomplex_sofascalepoints,
    mesolduslugacomplex_ivlhours,uslugacomplex_aid,uslugacomplex_bid,mesolduslugacomplex_fracfrom,mesolduslugacomplex_fracto,mesdop_id
from tmp.mesolduslugacomplex_170122
