--do $$
--begin
--	if exists 
--	(
--		select * from pg_proc p
--		where p.proname = 'sp_rds_choicehospitalizationxml'
--	)
--	then
--		drop function public.sp_rds_choicehospitalizationxml(text, xml, bit, uuid, int);
--	end if;
--end;
--$$ language plpgsql;
---- =============================================
---- Author:		Vitacore (с)
---- Create date: 2014-11-07
---- Description:	Выгрузка информации о госпитализации
---- =============================================
--CREATE or Replace Function public.sp_RDS_ChoiceHospitalizationXml
--(
--	"LpuCode" text = null,
--	"Xml" xml = null,
--	"IsNew" bit = '1',
--	"ID" UUID = null,
--	"HospType" int = 0
--)
--RETURNS Void As 
--$$
--Begin
--	IF "HospType" = 3
--	then
--		perform public.sp_RDS_PregnantHospitalizationXml("LpuCode","ID","IsNew");
--	END if;
--	if	exists (select * from akuz.T_MOVEMENT mov where mov.MovementID = "ID" and mov.Mkb is not null)
--	then
--		perform public.sp_RDS_HospitalisationXml("LpuCode","Xml","IsNew","ID");
--	END if;
--End;
--$$ Language plpgsql;