USE $(DATA_BASE_NAME);
GO

/****** Object:  Table [hib].[request]    Script Date: 2/18/2016 9:09:14 AM ******/
DROP TABLE [hib].[request]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [hib].[request](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[version] [int] NULL,
	[createdby] [varchar](32) NOT NULL,
	[createdon] [datetime] NOT NULL,
	[updatedby] [varchar](32) NULL,
	[updatedon] [datetime] NULL,
	[irbnumber] [varchar](256) NULL,
	[irbexpiration] [date] NULL,
	[expectedIRBSubmissionDate] [date] NULL,
	[headid] [int] NULL,
	[previousid] [int] NULL,
	[currentflag] [bit] NOT NULL DEFAULT ((1)),
	[name] [varchar](1024) NULL,
	[description] [varchar](256) NULL,
	[activityid] [int] NOT NULL,
	[amendment] [bit] NOT NULL DEFAULT ((0)),
	[datasetstartdate] [date] NULL,
	[datasetenddate] [date] NULL,
	[hipaaconsent] [bit] NOT NULL DEFAULT ((0)),
	[hipaawaiver] [bit] NOT NULL DEFAULT ((0)),
	[type] [varchar](255) NOT NULL,
	[requestorid] [int] NOT NULL,
	[trackingnumber] [varchar](32) NULL,
	[submittedon] [date] NULL,
	[primarysiteid] [int] NULL,
	[reviewid] [int] NULL,
	[datasourcelocation] [varchar](64) NULL,
	[datamart] [bit] NULL DEFAULT ((0)),
	[localserver] [bit] NULL DEFAULT ((0)),
	[localserverlocation] [varchar](128) NULL,
	[workflowid] [int] NULL,
	[workflowstate] [int] NULL,
	[workflowmask] [bigint] NULL,
	[state] [int] NOT NULL DEFAULT ((0)),
	[requesttype] [int] NOT NULL DEFAULT ((1)),
	[programoffice] [varchar](1024) NULL,
	[justification] [varchar](max) NULL,
	[localserveraddress] [varchar](128) NULL,
	[localserverbuilding] [varchar](128) NULL,
	[localserverroomnumber] [varchar](128) NULL,
	[realssnflag] [bit] NOT NULL DEFAULT ((0)),
	[scrambledssnflag] [bit] NOT NULL DEFAULT ((0)),
	[phidataflag] [bit] NOT NULL DEFAULT ((0)),
	[transferredexternal] [bit] NOT NULL DEFAULT ((0)),
	[externaldestination] [varchar](128) NULL,
	[externalstreet] [varchar](128) NULL,
	[externalcity] [varchar](128) NULL,
	[externalstate] [varchar](20) NULL,
	[externalzipcode] [varchar](20) NULL,
	
PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [DefFG]
) ON [DefFG] TEXTIMAGE_ON [DefFG]

GO

SET ANSI_PADDING OFF
GO