-- =============================================
-- Author:  Ramil M. Enaliev
-- Create date: 2011/05/17
-- Description: Процедура заполнения вспомогательных полей пациента.
-- =============================================
DROP PROCEDURE IF EXISTS sp_completepatient;
CREATE PROCEDURE sp_completepatient("PatientID" uuid)
AS
$BODY$
Begin
	update akuz.T_PATIENT t
	set PolicyOmsNumber = (select p.Number from akuz.T_POLICY p where p.PolicyID = fn_GetOmsPolicy(t.PatientID, null))
	where t.PatientID = "PatientID";
End;
$BODY$
  LANGUAGE plpgsql;