SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_CompletePatient]') and xtype = N'P')
drop procedure [dbo].[sp_CompletePatient]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[akuz].[sp_CompletePatient]') and xtype = N'P')
drop procedure [akuz].[sp_CompletePatient]
GO

-- =============================================
-- Author:		Ramil M. Enaliev
-- Create date: 2011/05/17
-- Description:	Процедура заполнения вспомогательных полей пациента.
-- =============================================
CREATE PROCEDURE [akuz].[sp_CompletePatient]
	@PatientID uniqueidentifier -- Идентификатор PATIENT
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	
	update t
	    set t.[OmsPolicyMapped] = [dbo].[fn_GetOmsPolicy](t.PatientID, null)
	from  [AKUZ].[T_PATIENT] t
	where t.PatientID = @PatientID
END
GO

