 -- =============================================
-- Script Template
-- =============================================

SET NOCOUNT ON;
SET XACT_ABORT ON;
GO

BEGIN TRANSACTION;
MERGE INTO [process_type] AS DEST
USING (
VALUES
(N'1',N'provider_registration_process', N'Provider registration process',1)
,(N'2',N'patient_registration_process', N'Patient registration process',1)
,(N'3',N'chronic_medicine_auth', N'Chronic Medicine Authorisation Process',1)
,(N'4',N'provider_registration_process_non_network', N'Provider registration process non-network ',1)

) AS SRC ([proc_type_id], [proc_type_name], [proc_type_description], [active])
ON (DEST.[proc_type_id] = SRC.[proc_type_id])
WHEN MATCHED THEN
  UPDATE SET
  [proc_type_id] = SRC.[proc_type_id]
  ,[proc_type_name] = SRC.[proc_type_name]
  ,[proc_type_description] = SRC.[proc_type_description]
  ,[active] = SRC.[active] 

  --[proc_type_id] INT NOT NULL  IDENTITY, 
  --  [proc_type_name] NVARCHAR(50) NOT NULL, 
  --  [proc_type_description] NVARCHAR(MAX) NULL, 
  --  [active] BIT NOT NULL DEFAULT 1, 

WHEN NOT MATCHED THEN
  INSERT ([proc_type_id], [proc_type_name],[proc_type_description], [active])
  VALUES (SRC.[proc_type_id], SRC.[proc_type_name], SRC.[proc_type_description], SRC.[active]);

  
COMMIT;
RAISERROR (N'Process Type: Insert [process_type] Reference Data: .....Done!', 10, 1) WITH NOWAIT;
GO
