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

SET NOCOUNT ON;
SET XACT_ABORT ON;
GO

BEGIN TRANSACTION;
MERGE INTO [process_step] AS DEST
USING (
VALUES
(N'1', N'Provider Details', N'Enter health care provider details.',N'Provider',1,1,1,1,0)
,(N'2', N'Provider Address', N'This address will be used for contacting the practice owner / contracting person for contract related communication.',N'ProviderAddress',2,1,1,0,0)
,(N'3', N'Practice Details', N'Enter the practice details.',N'Practice',3,1,1,0,0)
,(N'4', N'Practice Address', N'This address will be used for administration related communications eg. billing queries, remittances etc.',N'PracticeAddress',4,1,1,0,0)
,(N'5', N'Practice Unit', N'This address of the place and contact details of the units that patients visit..',N'PracticeUnit',5,1,1,0,0)
,(N'6', N'Banking Details', N'Banking details for practice.',N'PracticeBanking',6,1,1,0,0)
,(N'7', N'Business Details', N'Business Details.',N'PracticeCompany',7,1,1,0,0)
,(N'8', N'Send Registration Request', N'Send registration request.',N'ProviderRegistration',8,1,1,0,1)
,(N'9', N'Registration Complete', N'Registration complete.',N'ProviderRegistration',9,1,1,0,0)
,(N'10', N'Patient Personal Details', N'Enter patient details.',N'Patient',1,2,1,1,0)
,(N'11', N'Patient Funder', N'Enter patient funder details.',N'PatientFunder',2,2,1,0,0)
,(N'12', N'Patient Address', N'Enter patient address details.',N'PatientAddress',3,2,1,0,0)
,(N'13', N'Auth Details', N'Enter auth details.',N'AuthMain',1,3,1,1,0)
,(N'14', N'Auth Diagnosis', N'Enter auth diagnosis details.',N'AuthDiagnosis',2,3,1,0,0)
,(N'15', N'Auth Product', N'Enter auth product details',N'AuthProduct',3,3,1,0,0)
,(N'16', N'Send Auth Request to Scheme', N'Send auth request to scheme',N'AuthNotes',4,3,1,0,1)
,(N'17', N'Provider Details', N'Enter health care provider details.',N'Provider',1,4,1,1,0)
,(N'18', N'Provider Address', N'This address will be used for contacting the practice owner / contracting person for contract related communication.',N'ProviderAddress',2,4,1,0,0)
,(N'19', N'Practice Details', N'Enter the practice details.',N'Practice',3,4,1,0,0)
,(N'20', N'Practice Address', N'This address will be used for administration related communications eg. billing queries, remittances etc.',N'PracticeAddress',4,4,1,0,0)
,(N'21', N'Practice Unit', N'This address of the place and contact details of the units that patients visit..',N'PracticeUnit',5,4,1,0,0)
,(N'22', N'Business Details', N'Business Details.',N'PracticeCompany',6,4,1,0,0)
,(N'23', N'Send Registration Request', N'Send registration request.',N'ProviderRegistration',7,4,1,0,1)
,(N'24', N'Registration Complete', N'Registration complete.',N'ProviderRegistration',8,4,1,0,0)


) AS SRC ([proc_step_id], [proc_step_title], [proc_step_description], [proc_step_action], [proc_step_number], [proc_type_id], [active], [proc_step_edit_enabled], [proc_lock])
ON (DEST.[proc_step_id] = SRC.[proc_step_id])
WHEN MATCHED THEN
  UPDATE SET
  [proc_step_id] = SRC.[proc_step_id]
  ,[proc_step_title] = SRC.[proc_step_title]
  ,[proc_step_description] = SRC.[proc_step_description]
  ,[proc_step_action] = SRC.[proc_step_action]
  ,[proc_step_number] = SRC.[proc_step_number]
  ,[proc_type_id] = SRC.[proc_type_id]
  ,[active] = SRC.[active] 
  ,[proc_step_edit_enabled] = SRC.[proc_step_edit_enabled]
  ,[proc_lock] = SRC.[proc_lock]

WHEN NOT MATCHED THEN
  INSERT ([proc_step_id], [proc_step_title],[proc_step_description], [proc_step_action], [proc_step_number], [proc_type_id], [active],[proc_step_edit_enabled] ,[proc_lock] )
  VALUES (SRC.[proc_step_id], SRC.[proc_step_title], SRC.[proc_step_description], SRC.[proc_step_action], SRC.[proc_step_number], SRC.[proc_type_id], SRC.[active], SRC.[proc_step_edit_enabled], SRC.[proc_lock] );
  
COMMIT;
RAISERROR (N'Process Steps: Insert [process_step] Reference Data: .....Done!', 10, 1) WITH NOWAIT;
GO
