-- Name: xnat_smsessiondata; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_smsessiondata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    smsessiondata_info integer
);


ALTER TABLE public.xnat_smsessiondata OWNER TO xnat;

--
-- Name: xnat_smsessiondata_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_smsessiondata_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xnat_smsessiondata_meta_data OWNER TO xnat;

--
-- Name: xnat_smsessiondata_projects; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.xnat_smsessiondata_projects AS
 SELECT expt.id,
    ((('<'::text || (expt.project)::text) || '>'::text) || public.xs_a_concat(((',<'::text || (shared.project)::text) || '>'::text))) AS projects
   FROM ((public.xnat_experimentdata expt
     LEFT JOIN public.xnat_experimentdata_share shared ON (((expt.id)::text = (shared.sharing_share_xnat_experimentda_id)::text)))
     LEFT JOIN public.xdat_meta_element xme ON ((expt.extension = xme.xdat_meta_element_id)))
  WHERE ((xme.element_name)::text = 'xnat:smSessionData'::text)
  GROUP BY expt.id, expt.project;


ALTER TABLE public.xnat_smsessiondata_projects OWNER TO xnat;

--
-- Name: displayfields_xnat_smsessiondata; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.displayfields_xnat_smsessiondata AS
 SELECT search.xnat_subjectassessordata19 AS subject_id,
    search.xnat_smsessiondata0 AS expt_id,
    '/@WEBAPP/images/r.gif'::text AS rpt,
    search.xnat_experimentdata22 AS date,
    (COALESCE((floor(((((search.xnat_experimentdata22 - search.xnat_demographicdata_xnat_demographicdata1))::real / (365)::double precision))::numeric))::double precision, floor((date_part('year'::text, search.xnat_experimentdata22) - (search.xnat_demographicdata_xnat_demographicdata2)::double precision))))::numeric AS age,
    search.xnat_smsessiondata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata38, search.xnat_smsessiondata0) AS label,
    search.table5_login AS insert_user,
    search.xnat_smsessiondata_meta_data976 AS insert_date,
    search.xnat_experimentdata32 AS project,
    search.xnat_smsessiondata_meta_data973 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_smsessiondata0) search_1.xnat_smsessiondata0,
            search_1.xnat_smsessiondata_meta_data973,
            search_1.xnat_subjectassessordata19,
            search_1.xnat_experimentdata22,
            search_1.xnat_experimentdata38,
            search_1.table5_login,
            search_1.xnat_smsessiondata_meta_data976,
            search_1.xnat_experimentdata32,
            search_1.xnat_demographicdata_demograp_xnat_demographicdata0,
            search_1.xnat_demographicdata_at_demographicdata_meta_data47,
            search_1.xnat_demographicdata_xnat_demographicdata1,
            search_1.xnat_demographicdata_xnat_demographicdata2,
            search_1.xnat_smsessiondata_projects_projects
           FROM ( SELECT table2.id AS xnat_smsessiondata0,
                    table4.status AS xnat_smsessiondata_meta_data973,
                    table1.subject_id AS xnat_subjectassessordata19,
                    table2.date AS xnat_experimentdata22,
                    table2.label AS xnat_experimentdata38,
                    table5.login AS table5_login,
                    table4.insert_date AS xnat_smsessiondata_meta_data976,
                    table2.project AS xnat_experimentdata32,
                    xnat_demographicdata.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                    xnat_demographicdata.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                    xnat_demographicdata.xnat_demographicdata1 AS xnat_demographicdata_xnat_demographicdata1,
                    xnat_demographicdata.xnat_demographicdata2 AS xnat_demographicdata_xnat_demographicdata2,
                    xnat_smsessiondata_projects.projects AS xnat_smsessiondata_projects_projects
                   FROM ((((((((public.xnat_smsessiondata xnat_smsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_smsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))
                     LEFT JOIN public.xnat_smsessiondata_meta_data table4 ON ((xnat_smsessiondata.smsessiondata_info = table4.meta_data_id)))
                     LEFT JOIN public.xdat_user table5 ON ((table4.insert_user_xdat_user_id = table5.xdat_user_id)))
                     LEFT JOIN public.xnat_smsessiondata_projects xnat_smsessiondata_projects ON (((table2.id)::text = (xnat_smsessiondata_projects.id)::text)))
                     LEFT JOIN ( SELECT search_2.xnat_subjectdata3,
                            search_2.xnat_subjectdata_meta_data328,
                            search_2.xnat_demographicdata_demograp_xnat_demographicdata0,
                            search_2.xnat_demographicdata_at_demographicdata_meta_data47,
                            search_2.xnat_demographicdata_xnat_abstractdemographicdata27,
                            search_2.xnat_smsessiondata_sordata_ex_xnat_smsessiondata0,
                            search_2.xnat_smsessiondata_sordata__xnat_experimentdata22,
                            search_2.xnat_smsessiondata_sor_xnat_subjectassessordata19,
                            date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47)) AS xnat_subjectdata_xnat_demographicdata_diff
                           FROM ( SELECT xnat_subjectdata.id AS xnat_subjectdata3,
                                    table1_1.insert_date AS xnat_subjectdata_meta_data328,
                                    xnat_demographicdata_1.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                                    xnat_demographicdata_1.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                                    xnat_demographicdata_1.xnat_abstractdemographicdata27 AS xnat_demographicdata_xnat_abstractdemographicdata27,
                                    xnat_smsessiondata_1.xnat_smsessiondata0 AS xnat_smsessiondata_sordata_ex_xnat_smsessiondata0,
                                    xnat_smsessiondata_1.xnat_experimentdata22 AS xnat_smsessiondata_sordata__xnat_experimentdata22,
                                    xnat_smsessiondata_1.xnat_subjectassessordata19 AS xnat_smsessiondata_sor_xnat_subjectassessordata19
                                   FROM ((((public.xnat_subjectdata xnat_subjectdata
                                     LEFT JOIN public.xnat_subjectdata_meta_data table1_1 ON ((xnat_subjectdata.subjectdata_info = table1_1.meta_data_id)))
                                     LEFT JOIN ( SELECT xnat_subjectdata_1.id AS xnat_subjectdata3,
    table1_2.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata91,
    table2_1.insert_date AS xnat_subjectdata_meta_data328
   FROM ((public.xnat_subjectdata xnat_subjectdata_1
     LEFT JOIN public.xnat_abstractdemographicdata table1_2 ON ((xnat_subjectdata_1.demographics_xnat_abstractdemographicdata_id = table1_2.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_subjectdata_meta_data table2_1 ON ((xnat_subjectdata_1.subjectdata_info = table2_1.meta_data_id)))) map_xnat_demographicdata ON (((xnat_subjectdata.id)::text = (map_xnat_demographicdata.xnat_subjectdata3)::text)))
                                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
    table2_1.insert_date AS xnat_demographicdata_meta_data47,
    table0_1.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata27
   FROM ((public.xnat_demographicdata xnat_demographicdata_2
     LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_2.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_2.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata_1 ON ((map_xnat_demographicdata.xnat_abstractdemographicdata91 = xnat_demographicdata_1.xnat_abstractdemographicdata27)))
                                     LEFT JOIN ( SELECT table2_1.id AS xnat_smsessiondata0,
    table2_1.date AS xnat_experimentdata22,
    table1_2.subject_id AS xnat_subjectassessordata19
   FROM (((public.xnat_smsessiondata xnat_smsessiondata_2
     LEFT JOIN public.xnat_imagesessiondata table0_1 ON (((xnat_smsessiondata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_subjectassessordata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))
     LEFT JOIN public.xnat_experimentdata table2_1 ON (((table1_2.id)::text = (table2_1.id)::text)))) xnat_smsessiondata_1 ON (((xnat_subjectdata.id)::text = (xnat_smsessiondata_1.xnat_subjectassessordata19)::text)))) search_2
                          ORDER BY search_2.xnat_subjectdata3, (date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47))), search_2.xnat_smsessiondata_sordata__xnat_experimentdata22 DESC) map_xnat_subjectdata_xnat_demographicdata ON (((table2.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_smsessiondata_sordata_ex_xnat_smsessiondata0)::text)))
                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
                            table2_1.insert_date AS xnat_demographicdata_meta_data47,
                            xnat_demographicdata_1.dob AS xnat_demographicdata1,
                            xnat_demographicdata_1.yob AS xnat_demographicdata2
                           FROM ((public.xnat_demographicdata xnat_demographicdata_1
                             LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_1.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
                             LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_1.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata ON ((map_xnat_subjectdata_xnat_demographicdata.xnat_demographicdata_demograp_xnat_demographicdata0 = xnat_demographicdata.xnat_demographicdata0)))) search_1
          ORDER BY search_1.xnat_smsessiondata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_smsessiondata0
           FROM ( SELECT table2.id AS xnat_smsessiondata0,
                    table2.date AS xnat_experimentdata22
                   FROM (((public.xnat_smsessiondata xnat_smsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_smsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))) where_clause_1) where_clause ON (((where_clause.xnat_smsessiondata0)::text = (search.xnat_smsessiondata0)::text)))
  ORDER BY search.xnat_subjectassessordata19;


ALTER TABLE public.displayfields_xnat_smsessiondata OWNER TO xnat;

--
-- Name: xnat_srscandata; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_srscandata (
    xnat_imagescandata_id integer DEFAULT 0 NOT NULL,
    srscandata_info integer
);


ALTER TABLE public.xnat_srscandata OWNER TO xnat;

--
-- Name: xnat_srscandata_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_srscandata_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xnat_srscandata_meta_data OWNER TO xnat;

--
-- Name: displayfields_xnat_srscandata; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.displayfields_xnat_srscandata AS
 SELECT search.xnat_imagescandata2 AS image_session_id,
    search.xnat_imagescandata3 AS note,
    search.xnat_imagescandata4 AS quality,
    search.xnat_imagescandata5 AS condition,
    search.xnat_imagescandata6 AS series_description,
    search.xnat_imagescandata8 AS documentation,
    search.xnat_imagescandata9 AS scanner,
    search.xnat_imagescandata10 AS scanner_manufacturer,
    search.xnat_imagescandata11 AS scanner_model,
    search.xnat_imagescandata13 AS modality,
    search.xnat_imagescandata14 AS frames,
    search.xnat_imagescandata15 AS operator,
    search.xnat_imagescandata17 AS starttime,
    search.xnat_imagescandata19 AS id,
    search.xnat_imagescandata20 AS type,
    search.xnat_imagescandata21 AS uid,
    search.xnat_imagescandata22 AS project,
    search.xnat_srscandata_meta_data121 AS insert_date,
    search.table4_login AS insert_user,
    search.xnat_srscandata_meta_data118 AS quarantine_status
   FROM (( SELECT DISTINCT table0.xnat_imagescandata_id AS xnat_srscandata0,
            table2.status AS xnat_srscandata_meta_data118,
            table0.image_session_id AS xnat_imagescandata2,
            table0.note AS xnat_imagescandata3,
            table0.quality AS xnat_imagescandata4,
            table0.condition AS xnat_imagescandata5,
            table0.series_description AS xnat_imagescandata6,
            table0.documentation AS xnat_imagescandata8,
            table0.scanner AS xnat_imagescandata9,
            table0.scanner_manufacturer AS xnat_imagescandata10,
            table0.scanner_model AS xnat_imagescandata11,
            table0.modality AS xnat_imagescandata13,
            table0.frames AS xnat_imagescandata14,
            table0.operator AS xnat_imagescandata15,
            table0.starttime AS xnat_imagescandata17,
            table0.id AS xnat_imagescandata19,
            table0.type AS xnat_imagescandata20,
            table0.uid AS xnat_imagescandata21,
            table0.project AS xnat_imagescandata22,
            table2.insert_date AS xnat_srscandata_meta_data121,
            table4.login AS table4_login
           FROM (((public.xnat_srscandata xnat_srscandata
             LEFT JOIN public.xnat_imagescandata table0 ON ((xnat_srscandata.xnat_imagescandata_id = table0.xnat_imagescandata_id)))
             LEFT JOIN public.xnat_srscandata_meta_data table2 ON ((xnat_srscandata.srscandata_info = table2.meta_data_id)))
             LEFT JOIN public.xdat_user table4 ON ((table2.insert_user_xdat_user_id = table4.xdat_user_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_srscandata0
           FROM ( SELECT table0.xnat_imagescandata_id AS xnat_srscandata0,
                    table2.insert_date AS xnat_srscandata_meta_data121
                   FROM ((public.xnat_srscandata xnat_srscandata
                     LEFT JOIN public.xnat_imagescandata table0 ON ((xnat_srscandata.xnat_imagescandata_id = table0.xnat_imagescandata_id)))
                     LEFT JOIN public.xnat_srscandata_meta_data table2 ON ((xnat_srscandata.srscandata_info = table2.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.xnat_srscandata0 = search.xnat_srscandata0)))
  ORDER BY search.xnat_imagescandata2;


ALTER TABLE public.displayfields_xnat_srscandata OWNER TO xnat;

--
-- Name: xnat_srsessiondata; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_srsessiondata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    srsessiondata_info integer
);


ALTER TABLE public.xnat_srsessiondata OWNER TO xnat;

--
-- Name: xnat_srsessiondata_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_srsessiondata_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xnat_srsessiondata_meta_data OWNER TO xnat;

--
-- Name: xnat_srsessiondata_projects; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.xnat_srsessiondata_projects AS
 SELECT expt.id,
    ((('<'::text || (expt.project)::text) || '>'::text) || public.xs_a_concat(((',<'::text || (shared.project)::text) || '>'::text))) AS projects
   FROM ((public.xnat_experimentdata expt
     LEFT JOIN public.xnat_experimentdata_share shared ON (((expt.id)::text = (shared.sharing_share_xnat_experimentda_id)::text)))
     LEFT JOIN public.xdat_meta_element xme ON ((expt.extension = xme.xdat_meta_element_id)))
  WHERE ((xme.element_name)::text = 'xnat:srSessionData'::text)
  GROUP BY expt.id, expt.project;


ALTER TABLE public.xnat_srsessiondata_projects OWNER TO xnat;

--
-- Name: displayfields_xnat_srsessiondata; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.displayfields_xnat_srsessiondata AS
 SELECT search.xnat_subjectassessordata19 AS subject_id,
    search.xnat_srsessiondata0 AS expt_id,
    '/@WEBAPP/images/r.gif'::text AS rpt,
    search.xnat_experimentdata22 AS date,
    (COALESCE((floor(((((search.xnat_experimentdata22 - search.xnat_demographicdata_xnat_demographicdata1))::real / (365)::double precision))::numeric))::double precision, floor((date_part('year'::text, search.xnat_experimentdata22) - (search.xnat_demographicdata_xnat_demographicdata2)::double precision))))::numeric AS age,
    search.xnat_srsessiondata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata38, search.xnat_srsessiondata0) AS label,
    search.table5_login AS insert_user,
    search.xnat_srsessiondata_meta_data976 AS insert_date,
    search.xnat_experimentdata32 AS project,
    search.xnat_srsessiondata_meta_data973 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_srsessiondata0) search_1.xnat_srsessiondata0,
            search_1.xnat_srsessiondata_meta_data973,
            search_1.xnat_subjectassessordata19,
            search_1.xnat_experimentdata22,
            search_1.xnat_experimentdata38,
            search_1.table5_login,
            search_1.xnat_srsessiondata_meta_data976,
            search_1.xnat_experimentdata32,
            search_1.xnat_demographicdata_demograp_xnat_demographicdata0,
            search_1.xnat_demographicdata_at_demographicdata_meta_data47,
            search_1.xnat_demographicdata_xnat_demographicdata1,
            search_1.xnat_demographicdata_xnat_demographicdata2,
            search_1.xnat_srsessiondata_projects_projects
           FROM ( SELECT table2.id AS xnat_srsessiondata0,
                    table4.status AS xnat_srsessiondata_meta_data973,
                    table1.subject_id AS xnat_subjectassessordata19,
                    table2.date AS xnat_experimentdata22,
                    table2.label AS xnat_experimentdata38,
                    table5.login AS table5_login,
                    table4.insert_date AS xnat_srsessiondata_meta_data976,
                    table2.project AS xnat_experimentdata32,
                    xnat_demographicdata.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                    xnat_demographicdata.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                    xnat_demographicdata.xnat_demographicdata1 AS xnat_demographicdata_xnat_demographicdata1,
                    xnat_demographicdata.xnat_demographicdata2 AS xnat_demographicdata_xnat_demographicdata2,
                    xnat_srsessiondata_projects.projects AS xnat_srsessiondata_projects_projects
                   FROM ((((((((public.xnat_srsessiondata xnat_srsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_srsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))
                     LEFT JOIN public.xnat_srsessiondata_meta_data table4 ON ((xnat_srsessiondata.srsessiondata_info = table4.meta_data_id)))
                     LEFT JOIN public.xdat_user table5 ON ((table4.insert_user_xdat_user_id = table5.xdat_user_id)))
                     LEFT JOIN public.xnat_srsessiondata_projects xnat_srsessiondata_projects ON (((table2.id)::text = (xnat_srsessiondata_projects.id)::text)))
                     LEFT JOIN ( SELECT search_2.xnat_subjectdata3,
                            search_2.xnat_subjectdata_meta_data328,
                            search_2.xnat_srsessiondata_sordata_ex_xnat_srsessiondata0,
                            search_2.xnat_srsessiondata_sordata__xnat_experimentdata22,
                            search_2.xnat_srsessiondata_sor_xnat_subjectassessordata19,
                            search_2.xnat_demographicdata_demograp_xnat_demographicdata0,
                            search_2.xnat_demographicdata_at_demographicdata_meta_data47,
                            search_2.xnat_demographicdata_xnat_abstractdemographicdata27,
                            date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47)) AS xnat_subjectdata_xnat_demographicdata_diff
                           FROM ( SELECT xnat_subjectdata.id AS xnat_subjectdata3,
                                    table1_1.insert_date AS xnat_subjectdata_meta_data328,
                                    xnat_srsessiondata_1.xnat_srsessiondata0 AS xnat_srsessiondata_sordata_ex_xnat_srsessiondata0,
                                    xnat_srsessiondata_1.xnat_experimentdata22 AS xnat_srsessiondata_sordata__xnat_experimentdata22,
                                    xnat_srsessiondata_1.xnat_subjectassessordata19 AS xnat_srsessiondata_sor_xnat_subjectassessordata19,
                                    xnat_demographicdata_1.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                                    xnat_demographicdata_1.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                                    xnat_demographicdata_1.xnat_abstractdemographicdata27 AS xnat_demographicdata_xnat_abstractdemographicdata27
                                   FROM ((((public.xnat_subjectdata xnat_subjectdata
                                     LEFT JOIN public.xnat_subjectdata_meta_data table1_1 ON ((xnat_subjectdata.subjectdata_info = table1_1.meta_data_id)))
                                     LEFT JOIN ( SELECT table2_1.id AS xnat_srsessiondata0,
    table2_1.date AS xnat_experimentdata22,
    table1_2.subject_id AS xnat_subjectassessordata19
   FROM (((public.xnat_srsessiondata xnat_srsessiondata_2
     LEFT JOIN public.xnat_imagesessiondata table0_1 ON (((xnat_srsessiondata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_subjectassessordata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))
     LEFT JOIN public.xnat_experimentdata table2_1 ON (((table1_2.id)::text = (table2_1.id)::text)))) xnat_srsessiondata_1 ON (((xnat_subjectdata.id)::text = (xnat_srsessiondata_1.xnat_subjectassessordata19)::text)))
                                     LEFT JOIN ( SELECT xnat_subjectdata_1.id AS xnat_subjectdata3,
    table1_2.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata91,
    table2_1.insert_date AS xnat_subjectdata_meta_data328
   FROM ((public.xnat_subjectdata xnat_subjectdata_1
     LEFT JOIN public.xnat_abstractdemographicdata table1_2 ON ((xnat_subjectdata_1.demographics_xnat_abstractdemographicdata_id = table1_2.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_subjectdata_meta_data table2_1 ON ((xnat_subjectdata_1.subjectdata_info = table2_1.meta_data_id)))) map_xnat_demographicdata ON (((xnat_subjectdata.id)::text = (map_xnat_demographicdata.xnat_subjectdata3)::text)))
                                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
    table2_1.insert_date AS xnat_demographicdata_meta_data47,
    table0_1.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata27
   FROM ((public.xnat_demographicdata xnat_demographicdata_2
     LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_2.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_2.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata_1 ON ((map_xnat_demographicdata.xnat_abstractdemographicdata91 = xnat_demographicdata_1.xnat_abstractdemographicdata27)))) search_2
                          ORDER BY search_2.xnat_subjectdata3, search_2.xnat_srsessiondata_sordata__xnat_experimentdata22 DESC, (date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47)))) map_xnat_subjectdata_xnat_demographicdata ON (((table2.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_srsessiondata_sordata_ex_xnat_srsessiondata0)::text)))
                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
                            table2_1.insert_date AS xnat_demographicdata_meta_data47,
                            xnat_demographicdata_1.dob AS xnat_demographicdata1,
                            xnat_demographicdata_1.yob AS xnat_demographicdata2
                           FROM ((public.xnat_demographicdata xnat_demographicdata_1
                             LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_1.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
                             LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_1.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata ON ((map_xnat_subjectdata_xnat_demographicdata.xnat_demographicdata_demograp_xnat_demographicdata0 = xnat_demographicdata.xnat_demographicdata0)))) search_1
          ORDER BY search_1.xnat_srsessiondata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_srsessiondata0
           FROM ( SELECT table2.id AS xnat_srsessiondata0,
                    table2.date AS xnat_experimentdata22
                   FROM (((public.xnat_srsessiondata xnat_srsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_srsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))) where_clause_1) where_clause ON (((where_clause.xnat_srsessiondata0)::text = (search.xnat_srsessiondata0)::text)))
  ORDER BY search.xnat_subjectassessordata19;


ALTER TABLE public.displayfields_xnat_srsessiondata OWNER TO xnat;

--
-- Name: xnat_projectparticipant; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_projectparticipant (
    label character varying(255),
    project character varying(255),
    subject_id character varying(255),
    _group character varying(255),
    projectparticipant_info integer,
    xnat_projectparticipant_id integer NOT NULL
);


ALTER TABLE public.xnat_projectparticipant OWNER TO xnat;

--
-- Name: sub_projects; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.sub_projects AS
 SELECT sub.id,
    (((',<'::text || (sub.project)::text) || '>'::text) || public.xs_a_concat(((',<'::text || (shared.project)::text) || '>'::text))) AS projects
   FROM (public.xnat_subjectdata sub
     LEFT JOIN public.xnat_projectparticipant shared ON (((sub.id)::text = (shared.subject_id)::text)))
  GROUP BY sub.id, sub.project;


ALTER TABLE public.sub_projects OWNER TO xnat;

--
-- Name: subject_ids; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.subject_ids AS
 SELECT sub.id AS subject_id,
    (((sub.label)::text || ', '::text) || btrim(public.xs_a_concat(((pp.label)::text || ', '::text)), ', '::text)) AS addids
   FROM (public.xnat_subjectdata sub
     LEFT JOIN public.xnat_projectparticipant pp ON (((sub.id)::text = (pp.subject_id)::text)))
  WHERE (pp.subject_id IS NOT NULL)
  GROUP BY sub.id, sub.label;


ALTER TABLE public.subject_ids OWNER TO xnat;

--
-- Name: displayfields_xnat_subjectdata; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.displayfields_xnat_subjectdata AS
 SELECT search.xnat_subjectdata3 AS subject_id,
    search.xnat_subjectdata3 AS subjectid,
    search.xnat_subjectdata_meta_data328 AS insert_date,
    search.table2_login AS insert_user,
    search.xnat_demographicdata_xnat_demographicdata4 AS gender,
        CASE search.xnat_demographicdata_xnat_demographicdata4
            WHEN 'male'::text THEN 'M'::text
            WHEN 'female'::text THEN 'F'::text
            ELSE 'U'::text
        END AS gender_text,
    search.xnat_demographicdata_xnat_demographicdata5 AS handedness,
        CASE lower((search.xnat_demographicdata_xnat_demographicdata5)::text)
            WHEN 'left'::text THEN 'L'::text
            WHEN 'right'::text THEN 'R'::text
            WHEN 'ambidextrous'::text THEN 'A'::text
            WHEN 'r'::text THEN 'R'::text
            WHEN 'l'::text THEN 'L'::text
            WHEN 'a'::text THEN 'A'::text
            ELSE NULL::text
        END AS handedness_text,
    (floor(COALESCE((search.xnat_demographicdata_xnat_demographicdata2)::double precision, date_part('year'::text, search.xnat_demographicdata_xnat_demographicdata1))))::integer AS dob,
    search.xnat_demographicdata_xnat_demographicdata8 AS educ,
    search.xnat_demographicdata_xnat_demographicdata6 AS ses,
    search.xnat_mrsessiondata_count AS mr_count,
    search.xnat_investigatordata69 AS invest_csv,
    search.sub_projects_projects AS projects,
    search.xnat_subjectdata4 AS project,
    search.xnat_subjectdata5 AS sub_group,
    COALESCE(search.xnat_subjectdata6, search.xnat_subjectdata3) AS subject_label,
    search.xnat_projectparticipant10 AS shared_label,
    search.subject_ids_addids AS add_ids,
    search.xnat_demographicdata_xnat_demographicdata10 AS race,
    search.xnat_demographicdata_xnat_demographicdata16 AS ethnicity,
    search.xnat_subjectdata_meta_data325 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_subjectdata3) search_1.xnat_subjectdata3,
            search_1.xnat_subjectdata_meta_data325,
            search_1.xnat_subjectdata_meta_data328,
            search_1.table2_login,
            search_1.xnat_investigatordata69,
            search_1.xnat_subjectdata4,
            search_1.xnat_subjectdata5,
            search_1.xnat_subjectdata6,
            search_1.xnat_projectparticipant10,
            search_1.xnat_demographicdata_demograp_xnat_demographicdata0,
            search_1.xnat_demographicdata_at_demographicdata_meta_data47,
            search_1.xnat_demographicdata_xnat_demographicdata4,
            search_1.xnat_demographicdata_xnat_demographicdata5,
            search_1.xnat_demographicdata_xnat_demographicdata2,
            search_1.xnat_demographicdata_xnat_demographicdata1,
            search_1.xnat_demographicdata_xnat_demographicdata8,
            search_1.xnat_demographicdata_xnat_demographicdata6,
            search_1.xnat_demographicdata_xnat_demographicdata10,
            search_1.xnat_demographicdata_xnat_demographicdata16,
            search_1.xnat_demographicdata_xnat_abstractdemographicdata27,
            search_1.xnat_mrsessiondata_count,
            search_1.sub_projects_projects,
            search_1.subject_ids_addids,
            date_part('milliseconds'::text, (search_1.xnat_subjectdata_meta_data328 - search_1.xnat_demographicdata_at_demographicdata_meta_data47)) AS xnat_subjectdata_xnat_demographicdata_diff
           FROM ( SELECT xnat_subjectdata.id AS xnat_subjectdata3,
                    table1.status AS xnat_subjectdata_meta_data325,
                    table1.insert_date AS xnat_subjectdata_meta_data328,
                    table2.login AS table2_login,
                    table3.lastname AS xnat_investigatordata69,
                    xnat_subjectdata.project AS xnat_subjectdata4,
                    xnat_subjectdata._group AS xnat_subjectdata5,
                    xnat_subjectdata.label AS xnat_subjectdata6,
                    table4.label AS xnat_projectparticipant10,
                    xnat_demographicdata.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                    xnat_demographicdata.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                    xnat_demographicdata.xnat_demographicdata4 AS xnat_demographicdata_xnat_demographicdata4,
                    xnat_demographicdata.xnat_demographicdata5 AS xnat_demographicdata_xnat_demographicdata5,
                    xnat_demographicdata.xnat_demographicdata2 AS xnat_demographicdata_xnat_demographicdata2,
                    xnat_demographicdata.xnat_demographicdata1 AS xnat_demographicdata_xnat_demographicdata1,
                    xnat_demographicdata.xnat_demographicdata8 AS xnat_demographicdata_xnat_demographicdata8,
                    xnat_demographicdata.xnat_demographicdata6 AS xnat_demographicdata_xnat_demographicdata6,
                    xnat_demographicdata.xnat_demographicdata10 AS xnat_demographicdata_xnat_demographicdata10,
                    xnat_demographicdata.xnat_demographicdata16 AS xnat_demographicdata_xnat_demographicdata16,
                    xnat_demographicdata.xnat_abstractdemographicdata27 AS xnat_demographicdata_xnat_abstractdemographicdata27,
                    xnat_mrsessiondata_count.xnat_mrsessiondata_count,
                    sub_projects.projects AS sub_projects_projects,
                    subject_ids.addids AS subject_ids_addids
                   FROM (((((((((public.xnat_subjectdata xnat_subjectdata
                     LEFT JOIN public.xnat_subjectdata_meta_data table1 ON ((xnat_subjectdata.subjectdata_info = table1.meta_data_id)))
                     LEFT JOIN public.xdat_user table2 ON ((table1.insert_user_xdat_user_id = table2.xdat_user_id)))
                     LEFT JOIN public.xnat_investigatordata table3 ON ((xnat_subjectdata.investigator_xnat_investigatordata_id = table3.xnat_investigatordata_id)))
                     LEFT JOIN public.xnat_projectparticipant table4 ON (((xnat_subjectdata.id)::text = (table4.subject_id)::text)))
                     LEFT JOIN ( SELECT xnat_mrsessiondata_count_1.xnat_subjectassessordata23,
                            count(*) AS xnat_mrsessiondata_count
                           FROM ( SELECT table2_1.id AS xnat_mrsessiondata0,
                                    table1_1.subject_id AS xnat_subjectassessordata23,
                                    table2_1.date AS xnat_experimentdata26
                                   FROM (((( SELECT search_2.id,
    search_2.coil,
    search_2.fieldstrength,
    search_2.marker,
    search_2.stabilization,
    search_2.mrsessiondata_info
   FROM (( SELECT DISTINCT ON (security_1.xnat_mrsessiondata0) security_1.xnat_mrsessiondata0,
      security_1.xnat_mrsessiondata_meta_data977
     FROM ( SELECT table2_2.id AS xnat_mrsessiondata0,
        table4_1.status AS xnat_mrsessiondata_meta_data977
       FROM ((((public.xnat_mrsessiondata xnat_mrsessiondata_1
         LEFT JOIN public.xnat_imagesessiondata table0_1 ON (((xnat_mrsessiondata_1.id)::text = (table0_1.id)::text)))
         LEFT JOIN public.xnat_subjectassessordata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))
         LEFT JOIN public.xnat_experimentdata table2_2 ON (((table1_2.id)::text = (table2_2.id)::text)))
         LEFT JOIN public.xnat_mrsessiondata_meta_data table4_1 ON ((xnat_mrsessiondata_1.mrsessiondata_info = table4_1.meta_data_id)))) security_1
    WHERE ((((security_1.xnat_mrsessiondata_meta_data977)::text = 'active'::text) OR ((security_1.xnat_mrsessiondata_meta_data977)::text = 'locked'::text) OR ((security_1.xnat_mrsessiondata_meta_data977)::text = 'quarantine'::text)) AND (((security_1.xnat_mrsessiondata_meta_data977)::text = 'active'::text) OR ((security_1.xnat_mrsessiondata_meta_data977)::text = 'locked'::text) OR ((security_1.xnat_mrsessiondata_meta_data977)::text = 'quarantine'::text)) AND (((security_1.xnat_mrsessiondata_meta_data977)::text = 'active'::text) OR ((security_1.xnat_mrsessiondata_meta_data977)::text = 'locked'::text) OR ((security_1.xnat_mrsessiondata_meta_data977)::text = 'quarantine'::text)))) security
     LEFT JOIN public.xnat_mrsessiondata search_2 ON (((security.xnat_mrsessiondata0)::text = (search_2.id)::text)))) xnat_mrsessiondata
                                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_mrsessiondata.id)::text = (table0.id)::text)))
                                     LEFT JOIN public.xnat_subjectassessordata table1_1 ON (((table0.id)::text = (table1_1.id)::text)))
                                     LEFT JOIN public.xnat_experimentdata table2_1 ON (((table1_1.id)::text = (table2_1.id)::text)))) xnat_mrsessiondata_count_1
                          GROUP BY xnat_mrsessiondata_count_1.xnat_subjectassessordata23) xnat_mrsessiondata_count ON (((xnat_subjectdata.id)::text = (xnat_mrsessiondata_count.xnat_subjectassessordata23)::text)))
                     LEFT JOIN public.sub_projects sub_projects ON (((xnat_subjectdata.id)::text = (sub_projects.id)::text)))
                     LEFT JOIN public.subject_ids subject_ids ON (((xnat_subjectdata.id)::text = (subject_ids.subject_id)::text)))
                     LEFT JOIN ( SELECT xnat_subjectdata_1.id AS xnat_subjectdata3,
                            table1_1.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata91,
                            table2_1.insert_date AS xnat_subjectdata_meta_data328
                           FROM ((public.xnat_subjectdata xnat_subjectdata_1
                             LEFT JOIN public.xnat_abstractdemographicdata table1_1 ON ((xnat_subjectdata_1.demographics_xnat_abstractdemographicdata_id = table1_1.xnat_abstractdemographicdata_id)))
                             LEFT JOIN public.xnat_subjectdata_meta_data table2_1 ON ((xnat_subjectdata_1.subjectdata_info = table2_1.meta_data_id)))) map_xnat_demographicdata ON (((xnat_subjectdata.id)::text = (map_xnat_demographicdata.xnat_subjectdata3)::text)))
                     LEFT JOIN ( SELECT table0.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
                            table2_1.insert_date AS xnat_demographicdata_meta_data47,
                            xnat_demographicdata_1.gender AS xnat_demographicdata4,
                            xnat_demographicdata_1.handedness AS xnat_demographicdata5,
                            xnat_demographicdata_1.yob AS xnat_demographicdata2,
                            xnat_demographicdata_1.dob AS xnat_demographicdata1,
                            xnat_demographicdata_1.education AS xnat_demographicdata8,
                            xnat_demographicdata_1.ses AS xnat_demographicdata6,
                            xnat_demographicdata_1.race AS xnat_demographicdata10,
                            xnat_demographicdata_1.ethnicity AS xnat_demographicdata16,
                            table0.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata27
                           FROM ((public.xnat_demographicdata xnat_demographicdata_1
                             LEFT JOIN public.xnat_abstractdemographicdata table0 ON ((xnat_demographicdata_1.xnat_abstractdemographicdata_id = table0.xnat_abstractdemographicdata_id)))
                             LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_1.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata ON ((map_xnat_demographicdata.xnat_abstractdemographicdata91 = xnat_demographicdata.xnat_abstractdemographicdata27)))) search_1
          ORDER BY search_1.xnat_subjectdata3, (date_part('milliseconds'::text, (search_1.xnat_subjectdata_meta_data328 - search_1.xnat_demographicdata_at_demographicdata_meta_data47)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_subjectdata3
           FROM ( SELECT xnat_subjectdata.id AS xnat_subjectdata3,
                    table1.insert_date AS xnat_subjectdata_meta_data328
                   FROM (public.xnat_subjectdata xnat_subjectdata
                     LEFT JOIN public.xnat_subjectdata_meta_data table1 ON ((xnat_subjectdata.subjectdata_info = table1.meta_data_id)))) where_clause_1) where_clause ON (((where_clause.xnat_subjectdata3)::text = (search.xnat_subjectdata3)::text)))
  ORDER BY search.xnat_subjectdata3;


ALTER TABLE public.displayfields_xnat_subjectdata OWNER TO xnat;

--
-- Name: xnat_subjectvariablesdata; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_subjectvariablesdata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    subjectvariablesdata_info integer
);


ALTER TABLE public.xnat_subjectvariablesdata OWNER TO xnat;

--
-- Name: xnat_subjectvariablesdata_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_subjectvariablesdata_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xnat_subjectvariablesdata_meta_data OWNER TO xnat;

--
-- Name: xnat_subjectvariablesdata_projects; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.xnat_subjectvariablesdata_projects AS
 SELECT expt.id,
    ((('<'::text || (expt.project)::text) || '>'::text) || public.xs_a_concat(((',<'::text || (shared.project)::text) || '>'::text))) AS projects
   FROM ((public.xnat_experimentdata expt
     LEFT JOIN public.xnat_experimentdata_share shared ON (((expt.id)::text = (shared.sharing_share_xnat_experimentda_id)::text)))
     LEFT JOIN public.xdat_meta_element xme ON ((expt.extension = xme.xdat_meta_element_id)))
  WHERE ((xme.element_name)::text = 'xnat:subjectVariablesData'::text)
  GROUP BY expt.id, expt.project;


ALTER TABLE public.xnat_subjectvariablesdata_projects OWNER TO xnat;

--
-- Name: displayfields_xnat_subjectvariablesdata; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.displayfields_xnat_subjectvariablesdata AS
 SELECT search.xnat_subjectassessordata3 AS subject_id,
    search.xnat_subjectvariablesdata0 AS expt_id,
    '/@WEBAPP/images/r.gif'::text AS rpt,
    search.xnat_experimentdata6 AS date,
    (COALESCE((floor(((((search.xnat_experimentdata6 - search.xnat_demographicdata_xnat_demographicdata1))::real / (365)::double precision))::numeric))::double precision, floor((date_part('year'::text, search.xnat_experimentdata6) - (search.xnat_demographicdata_xnat_demographicdata2)::double precision))))::numeric AS age,
    search.xnat_subjectvariablesdata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata22, search.xnat_subjectvariablesdata0) AS label,
    search.table4_login AS insert_user,
    search.xnat_subjectvariablesdata_meta_data190 AS insert_date,
    search.xnat_experimentdata16 AS project,
    search.xnat_subjectvariablesdata_meta_data187 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_subjectvariablesdata0) search_1.xnat_subjectvariablesdata0,
            search_1.xnat_subjectvariablesdata_meta_data187,
            search_1.xnat_subjectassessordata3,
            search_1.xnat_experimentdata6,
            search_1.xnat_experimentdata22,
            search_1.table4_login,
            search_1.xnat_subjectvariablesdata_meta_data190,
            search_1.xnat_experimentdata16,
            search_1.xnat_demographicdata_demograp_xnat_demographicdata0,
            search_1.xnat_demographicdata_at_demographicdata_meta_data47,
            search_1.xnat_demographicdata_xnat_demographicdata1,
            search_1.xnat_demographicdata_xnat_demographicdata2,
            search_1.xnat_subjectvariablesdata_projects_projects
           FROM ( SELECT table1.id AS xnat_subjectvariablesdata0,
                    table3.status AS xnat_subjectvariablesdata_meta_data187,
                    table0.subject_id AS xnat_subjectassessordata3,
                    table1.date AS xnat_experimentdata6,
                    table1.label AS xnat_experimentdata22,
                    table4.login AS table4_login,
                    table3.insert_date AS xnat_subjectvariablesdata_meta_data190,
                    table1.project AS xnat_experimentdata16,
                    xnat_demographicdata.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                    xnat_demographicdata.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                    xnat_demographicdata.xnat_demographicdata1 AS xnat_demographicdata_xnat_demographicdata1,
                    xnat_demographicdata.xnat_demographicdata2 AS xnat_demographicdata_xnat_demographicdata2,
                    xnat_subjectvariablesdata_projects.projects AS xnat_subjectvariablesdata_projects_projects
                   FROM (((((((public.xnat_subjectvariablesdata xnat_subjectvariablesdata
                     LEFT JOIN public.xnat_subjectassessordata table0 ON (((xnat_subjectvariablesdata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_subjectvariablesdata_meta_data table3 ON ((xnat_subjectvariablesdata.subjectvariablesdata_info = table3.meta_data_id)))
                     LEFT JOIN public.xdat_user table4 ON ((table3.insert_user_xdat_user_id = table4.xdat_user_id)))
                     LEFT JOIN public.xnat_subjectvariablesdata_projects xnat_subjectvariablesdata_projects ON (((table1.id)::text = (xnat_subjectvariablesdata_projects.id)::text)))
                     LEFT JOIN ( SELECT search_2.xnat_subjectdata3,
                            search_2.xnat_subjectdata_meta_data328,
                            search_2.xnat_demographicdata_demograp_xnat_demographicdata0,
                            search_2.xnat_demographicdata_at_demographicdata_meta_data47,
                            search_2.xnat_demographicdata_xnat_abstractdemographicdata27,
                            search_2.xnat_subjectvariablesdata_tda_xnat_subjectvariablesdata0,
                            search_2.xnat_subjectvariablesdata_tdata_ext_xnat_experimentdata6,
                            search_2.xnat_subjectvariablesdata_ectv_xnat_subjectassessordata3,
                            date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47)) AS xnat_subjectdata_xnat_demographicdata_diff
                           FROM ( SELECT xnat_subjectdata.id AS xnat_subjectdata3,
                                    table1_1.insert_date AS xnat_subjectdata_meta_data328,
                                    xnat_demographicdata_1.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                                    xnat_demographicdata_1.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                                    xnat_demographicdata_1.xnat_abstractdemographicdata27 AS xnat_demographicdata_xnat_abstractdemographicdata27,
                                    xnat_subjectvariablesdata_1.xnat_subjectvariablesdata0 AS xnat_subjectvariablesdata_tda_xnat_subjectvariablesdata0,
                                    xnat_subjectvariablesdata_1.xnat_experimentdata6 AS xnat_subjectvariablesdata_tdata_ext_xnat_experimentdata6,
                                    xnat_subjectvariablesdata_1.xnat_subjectassessordata3 AS xnat_subjectvariablesdata_ectv_xnat_subjectassessordata3
                                   FROM ((((public.xnat_subjectdata xnat_subjectdata
                                     LEFT JOIN public.xnat_subjectdata_meta_data table1_1 ON ((xnat_subjectdata.subjectdata_info = table1_1.meta_data_id)))
                                     LEFT JOIN ( SELECT xnat_subjectdata_1.id AS xnat_subjectdata3,
    table1_2.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata91,
    table2.insert_date AS xnat_subjectdata_meta_data328
   FROM ((public.xnat_subjectdata xnat_subjectdata_1
     LEFT JOIN public.xnat_abstractdemographicdata table1_2 ON ((xnat_subjectdata_1.demographics_xnat_abstractdemographicdata_id = table1_2.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_subjectdata_meta_data table2 ON ((xnat_subjectdata_1.subjectdata_info = table2.meta_data_id)))) map_xnat_demographicdata ON (((xnat_subjectdata.id)::text = (map_xnat_demographicdata.xnat_subjectdata3)::text)))
                                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
    table2.insert_date AS xnat_demographicdata_meta_data47,
    table0_1.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata27
   FROM ((public.xnat_demographicdata xnat_demographicdata_2
     LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_2.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_demographicdata_meta_data table2 ON ((xnat_demographicdata_2.demographicdata_info = table2.meta_data_id)))) xnat_demographicdata_1 ON ((map_xnat_demographicdata.xnat_abstractdemographicdata91 = xnat_demographicdata_1.xnat_abstractdemographicdata27)))
                                     LEFT JOIN ( SELECT table1_2.id AS xnat_subjectvariablesdata0,
    table1_2.date AS xnat_experimentdata6,
    table0_1.subject_id AS xnat_subjectassessordata3
   FROM ((public.xnat_subjectvariablesdata xnat_subjectvariablesdata_2
     LEFT JOIN public.xnat_subjectassessordata table0_1 ON (((xnat_subjectvariablesdata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_experimentdata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))) xnat_subjectvariablesdata_1 ON (((xnat_subjectdata.id)::text = (xnat_subjectvariablesdata_1.xnat_subjectassessordata3)::text)))) search_2
                          ORDER BY search_2.xnat_subjectdata3, (date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47))), search_2.xnat_subjectvariablesdata_tdata_ext_xnat_experimentdata6 DESC) map_xnat_subjectdata_xnat_demographicdata ON (((table1.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_subjectvariablesdata_tda_xnat_subjectvariablesdata0)::text)))
                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
                            table2.insert_date AS xnat_demographicdata_meta_data47,
                            xnat_demographicdata_1.dob AS xnat_demographicdata1,
                            xnat_demographicdata_1.yob AS xnat_demographicdata2
                           FROM ((public.xnat_demographicdata xnat_demographicdata_1
                             LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_1.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
                             LEFT JOIN public.xnat_demographicdata_meta_data table2 ON ((xnat_demographicdata_1.demographicdata_info = table2.meta_data_id)))) xnat_demographicdata ON ((map_xnat_subjectdata_xnat_demographicdata.xnat_demographicdata_demograp_xnat_demographicdata0 = xnat_demographicdata.xnat_demographicdata0)))) search_1
          ORDER BY search_1.xnat_subjectvariablesdata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_subjectvariablesdata0
           FROM ( SELECT table1.id AS xnat_subjectvariablesdata0,
                    table1.date AS xnat_experimentdata6
                   FROM ((public.xnat_subjectvariablesdata xnat_subjectvariablesdata
                     LEFT JOIN public.xnat_subjectassessordata table0 ON (((xnat_subjectvariablesdata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table1 ON (((table0.id)::text = (table1.id)::text)))) where_clause_1) where_clause ON (((where_clause.xnat_subjectvariablesdata0)::text = (search.xnat_subjectvariablesdata0)::text)))
  ORDER BY search.xnat_subjectassessordata3;


ALTER TABLE public.displayfields_xnat_subjectvariablesdata OWNER TO xnat;

--
-- Name: xnat_usscandata; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_usscandata (
    xnat_imagescandata_id integer DEFAULT 0 NOT NULL,
    usscandata_info integer
);


ALTER TABLE public.xnat_usscandata OWNER TO xnat;

--
-- Name: xnat_usscandata_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_usscandata_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xnat_usscandata_meta_data OWNER TO xnat;

--
-- Name: displayfields_xnat_usscandata; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.displayfields_xnat_usscandata AS
 SELECT search.xnat_imagescandata2 AS image_session_id,
    search.xnat_imagescandata3 AS note,
    search.xnat_imagescandata4 AS quality,
    search.xnat_imagescandata5 AS condition,
    search.xnat_imagescandata6 AS series_description,
    search.xnat_imagescandata8 AS documentation,
    search.xnat_imagescandata9 AS scanner,
    search.xnat_imagescandata10 AS scanner_manufacturer,
    search.xnat_imagescandata11 AS scanner_model,
    search.xnat_imagescandata13 AS modality,
    search.xnat_imagescandata14 AS frames,
    search.xnat_imagescandata15 AS operator,
    search.xnat_imagescandata17 AS starttime,
    search.xnat_imagescandata19 AS id,
    search.xnat_imagescandata20 AS type,
    search.xnat_imagescandata21 AS uid,
    search.xnat_imagescandata22 AS project,
    search.xnat_usscandata_meta_data121 AS insert_date,
    search.table4_login AS insert_user,
    search.xnat_usscandata_meta_data118 AS quarantine_status
   FROM (( SELECT DISTINCT table0.xnat_imagescandata_id AS xnat_usscandata0,
            table2.status AS xnat_usscandata_meta_data118,
            table0.image_session_id AS xnat_imagescandata2,
            table0.note AS xnat_imagescandata3,
            table0.quality AS xnat_imagescandata4,
            table0.condition AS xnat_imagescandata5,
            table0.series_description AS xnat_imagescandata6,
            table0.documentation AS xnat_imagescandata8,
            table0.scanner AS xnat_imagescandata9,
            table0.scanner_manufacturer AS xnat_imagescandata10,
            table0.scanner_model AS xnat_imagescandata11,
            table0.modality AS xnat_imagescandata13,
            table0.frames AS xnat_imagescandata14,
            table0.operator AS xnat_imagescandata15,
            table0.starttime AS xnat_imagescandata17,
            table0.id AS xnat_imagescandata19,
            table0.type AS xnat_imagescandata20,
            table0.uid AS xnat_imagescandata21,
            table0.project AS xnat_imagescandata22,
            table2.insert_date AS xnat_usscandata_meta_data121,
            table4.login AS table4_login
           FROM (((public.xnat_usscandata xnat_usscandata
             LEFT JOIN public.xnat_imagescandata table0 ON ((xnat_usscandata.xnat_imagescandata_id = table0.xnat_imagescandata_id)))
             LEFT JOIN public.xnat_usscandata_meta_data table2 ON ((xnat_usscandata.usscandata_info = table2.meta_data_id)))
             LEFT JOIN public.xdat_user table4 ON ((table2.insert_user_xdat_user_id = table4.xdat_user_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_usscandata0
           FROM ( SELECT table0.xnat_imagescandata_id AS xnat_usscandata0,
                    table2.insert_date AS xnat_usscandata_meta_data121
                   FROM ((public.xnat_usscandata xnat_usscandata
                     LEFT JOIN public.xnat_imagescandata table0 ON ((xnat_usscandata.xnat_imagescandata_id = table0.xnat_imagescandata_id)))
                     LEFT JOIN public.xnat_usscandata_meta_data table2 ON ((xnat_usscandata.usscandata_info = table2.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.xnat_usscandata0 = search.xnat_usscandata0)))
  ORDER BY search.xnat_imagescandata2;


ALTER TABLE public.displayfields_xnat_usscandata OWNER TO xnat;

--
-- Name: xnat_ussessiondata; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_ussessiondata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    ussessiondata_info integer
);


ALTER TABLE public.xnat_ussessiondata OWNER TO xnat;

--
-- Name: xnat_ussessiondata_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_ussessiondata_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xnat_ussessiondata_meta_data OWNER TO xnat;

--
-- Name: xnat_ussessiondata_projects; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.xnat_ussessiondata_projects AS
 SELECT expt.id,
    ((('<'::text || (expt.project)::text) || '>'::text) || public.xs_a_concat(((',<'::text || (shared.project)::text) || '>'::text))) AS projects
   FROM ((public.xnat_experimentdata expt
     LEFT JOIN public.xnat_experimentdata_share shared ON (((expt.id)::text = (shared.sharing_share_xnat_experimentda_id)::text)))
     LEFT JOIN public.xdat_meta_element xme ON ((expt.extension = xme.xdat_meta_element_id)))
  WHERE ((xme.element_name)::text = 'xnat:usSessionData'::text)
  GROUP BY expt.id, expt.project;


ALTER TABLE public.xnat_ussessiondata_projects OWNER TO xnat;

--
-- Name: displayfields_xnat_ussessiondata; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.displayfields_xnat_ussessiondata AS
 SELECT search.xnat_subjectassessordata19 AS subject_id,
    search.xnat_ussessiondata0 AS expt_id,
    '/@WEBAPP/images/r.gif'::text AS rpt,
    search.xnat_experimentdata22 AS date,
    (COALESCE((floor(((((search.xnat_experimentdata22 - search.xnat_demographicdata_xnat_demographicdata1))::real / (365)::double precision))::numeric))::double precision, floor((date_part('year'::text, search.xnat_experimentdata22) - (search.xnat_demographicdata_xnat_demographicdata2)::double precision))))::numeric AS age,
    search.xnat_ussessiondata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata38, search.xnat_ussessiondata0) AS label,
    search.table5_login AS insert_user,
    search.xnat_ussessiondata_meta_data976 AS insert_date,
    search.xnat_experimentdata32 AS project,
    search.xnat_ussessiondata_meta_data973 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_ussessiondata0) search_1.xnat_ussessiondata0,
            search_1.xnat_ussessiondata_meta_data973,
            search_1.xnat_subjectassessordata19,
            search_1.xnat_experimentdata22,
            search_1.xnat_experimentdata38,
            search_1.table5_login,
            search_1.xnat_ussessiondata_meta_data976,
            search_1.xnat_experimentdata32,
            search_1.xnat_demographicdata_demograp_xnat_demographicdata0,
            search_1.xnat_demographicdata_at_demographicdata_meta_data47,
            search_1.xnat_demographicdata_xnat_demographicdata1,
            search_1.xnat_demographicdata_xnat_demographicdata2,
            search_1.xnat_ussessiondata_projects_projects
           FROM ( SELECT table2.id AS xnat_ussessiondata0,
                    table4.status AS xnat_ussessiondata_meta_data973,
                    table1.subject_id AS xnat_subjectassessordata19,
                    table2.date AS xnat_experimentdata22,
                    table2.label AS xnat_experimentdata38,
                    table5.login AS table5_login,
                    table4.insert_date AS xnat_ussessiondata_meta_data976,
                    table2.project AS xnat_experimentdata32,
                    xnat_demographicdata.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                    xnat_demographicdata.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                    xnat_demographicdata.xnat_demographicdata1 AS xnat_demographicdata_xnat_demographicdata1,
                    xnat_demographicdata.xnat_demographicdata2 AS xnat_demographicdata_xnat_demographicdata2,
                    xnat_ussessiondata_projects.projects AS xnat_ussessiondata_projects_projects
                   FROM ((((((((public.xnat_ussessiondata xnat_ussessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_ussessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))
                     LEFT JOIN public.xnat_ussessiondata_meta_data table4 ON ((xnat_ussessiondata.ussessiondata_info = table4.meta_data_id)))
                     LEFT JOIN public.xdat_user table5 ON ((table4.insert_user_xdat_user_id = table5.xdat_user_id)))
                     LEFT JOIN public.xnat_ussessiondata_projects xnat_ussessiondata_projects ON (((table2.id)::text = (xnat_ussessiondata_projects.id)::text)))
                     LEFT JOIN ( SELECT search_2.xnat_subjectdata3,
                            search_2.xnat_subjectdata_meta_data328,
                            search_2.xnat_demographicdata_demograp_xnat_demographicdata0,
                            search_2.xnat_demographicdata_at_demographicdata_meta_data47,
                            search_2.xnat_demographicdata_xnat_abstractdemographicdata27,
                            search_2.xnat_ussessiondata_sordata_ex_xnat_ussessiondata0,
                            search_2.xnat_ussessiondata_sordata__xnat_experimentdata22,
                            search_2.xnat_ussessiondata_sor_xnat_subjectassessordata19,
                            date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47)) AS xnat_subjectdata_xnat_demographicdata_diff
                           FROM ( SELECT xnat_subjectdata.id AS xnat_subjectdata3,
                                    table1_1.insert_date AS xnat_subjectdata_meta_data328,
                                    xnat_demographicdata_1.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                                    xnat_demographicdata_1.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                                    xnat_demographicdata_1.xnat_abstractdemographicdata27 AS xnat_demographicdata_xnat_abstractdemographicdata27,
                                    xnat_ussessiondata_1.xnat_ussessiondata0 AS xnat_ussessiondata_sordata_ex_xnat_ussessiondata0,
                                    xnat_ussessiondata_1.xnat_experimentdata22 AS xnat_ussessiondata_sordata__xnat_experimentdata22,
                                    xnat_ussessiondata_1.xnat_subjectassessordata19 AS xnat_ussessiondata_sor_xnat_subjectassessordata19
                                   FROM ((((public.xnat_subjectdata xnat_subjectdata
                                     LEFT JOIN public.xnat_subjectdata_meta_data table1_1 ON ((xnat_subjectdata.subjectdata_info = table1_1.meta_data_id)))
                                     LEFT JOIN ( SELECT xnat_subjectdata_1.id AS xnat_subjectdata3,
    table1_2.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata91,
    table2_1.insert_date AS xnat_subjectdata_meta_data328
   FROM ((public.xnat_subjectdata xnat_subjectdata_1
     LEFT JOIN public.xnat_abstractdemographicdata table1_2 ON ((xnat_subjectdata_1.demographics_xnat_abstractdemographicdata_id = table1_2.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_subjectdata_meta_data table2_1 ON ((xnat_subjectdata_1.subjectdata_info = table2_1.meta_data_id)))) map_xnat_demographicdata ON (((xnat_subjectdata.id)::text = (map_xnat_demographicdata.xnat_subjectdata3)::text)))
                                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
    table2_1.insert_date AS xnat_demographicdata_meta_data47,
    table0_1.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata27
   FROM ((public.xnat_demographicdata xnat_demographicdata_2
     LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_2.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_2.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata_1 ON ((map_xnat_demographicdata.xnat_abstractdemographicdata91 = xnat_demographicdata_1.xnat_abstractdemographicdata27)))
                                     LEFT JOIN ( SELECT table2_1.id AS xnat_ussessiondata0,
    table2_1.date AS xnat_experimentdata22,
    table1_2.subject_id AS xnat_subjectassessordata19
   FROM (((public.xnat_ussessiondata xnat_ussessiondata_2
     LEFT JOIN public.xnat_imagesessiondata table0_1 ON (((xnat_ussessiondata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_subjectassessordata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))
     LEFT JOIN public.xnat_experimentdata table2_1 ON (((table1_2.id)::text = (table2_1.id)::text)))) xnat_ussessiondata_1 ON (((xnat_subjectdata.id)::text = (xnat_ussessiondata_1.xnat_subjectassessordata19)::text)))) search_2
                          ORDER BY search_2.xnat_subjectdata3, (date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47))), search_2.xnat_ussessiondata_sordata__xnat_experimentdata22 DESC) map_xnat_subjectdata_xnat_demographicdata ON (((table2.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_ussessiondata_sordata_ex_xnat_ussessiondata0)::text)))
                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
                            table2_1.insert_date AS xnat_demographicdata_meta_data47,
                            xnat_demographicdata_1.dob AS xnat_demographicdata1,
                            xnat_demographicdata_1.yob AS xnat_demographicdata2
                           FROM ((public.xnat_demographicdata xnat_demographicdata_1
                             LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_1.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
                             LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_1.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata ON ((map_xnat_subjectdata_xnat_demographicdata.xnat_demographicdata_demograp_xnat_demographicdata0 = xnat_demographicdata.xnat_demographicdata0)))) search_1
          ORDER BY search_1.xnat_ussessiondata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_ussessiondata0
           FROM ( SELECT table2.id AS xnat_ussessiondata0,
                    table2.date AS xnat_experimentdata22
                   FROM (((public.xnat_ussessiondata xnat_ussessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_ussessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))) where_clause_1) where_clause ON (((where_clause.xnat_ussessiondata0)::text = (search.xnat_ussessiondata0)::text)))
  ORDER BY search.xnat_subjectassessordata19;


ALTER TABLE public.displayfields_xnat_ussessiondata OWNER TO xnat;

--
-- Name: xnat_voiceaudioscandata; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_voiceaudioscandata (
    xnat_imagescandata_id integer DEFAULT 0 NOT NULL,
    voiceaudioscandata_info integer
);


ALTER TABLE public.xnat_voiceaudioscandata OWNER TO xnat;

--
-- Name: xnat_voiceaudioscandata_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_voiceaudioscandata_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xnat_voiceaudioscandata_meta_data OWNER TO xnat;

--
-- Name: displayfields_xnat_voiceaudioscandata; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.displayfields_xnat_voiceaudioscandata AS
 SELECT search.xnat_imagescandata2 AS image_session_id,
    search.xnat_imagescandata3 AS note,
    search.xnat_imagescandata4 AS quality,
    search.xnat_imagescandata5 AS condition,
    search.xnat_imagescandata6 AS series_description,
    search.xnat_imagescandata8 AS documentation,
    search.xnat_imagescandata9 AS scanner,
    search.xnat_imagescandata10 AS scanner_manufacturer,
    search.xnat_imagescandata11 AS scanner_model,
    search.xnat_imagescandata13 AS modality,
    search.xnat_imagescandata14 AS frames,
    search.xnat_imagescandata15 AS operator,
    search.xnat_imagescandata17 AS starttime,
    search.xnat_imagescandata19 AS id,
    search.xnat_imagescandata20 AS type,
    search.xnat_imagescandata21 AS uid,
    search.xnat_imagescandata22 AS project,
    search.xnat_voiceaudioscandata_meta_data121 AS insert_date,
    search.table4_login AS insert_user,
    search.xnat_voiceaudioscandata_meta_data118 AS quarantine_status
   FROM (( SELECT DISTINCT table0.xnat_imagescandata_id AS xnat_voiceaudioscandata0,
            table2.status AS xnat_voiceaudioscandata_meta_data118,
            table0.image_session_id AS xnat_imagescandata2,
            table0.note AS xnat_imagescandata3,
            table0.quality AS xnat_imagescandata4,
            table0.condition AS xnat_imagescandata5,
            table0.series_description AS xnat_imagescandata6,
            table0.documentation AS xnat_imagescandata8,
            table0.scanner AS xnat_imagescandata9,
            table0.scanner_manufacturer AS xnat_imagescandata10,
            table0.scanner_model AS xnat_imagescandata11,
            table0.modality AS xnat_imagescandata13,
            table0.frames AS xnat_imagescandata14,
            table0.operator AS xnat_imagescandata15,
            table0.starttime AS xnat_imagescandata17,
            table0.id AS xnat_imagescandata19,
            table0.type AS xnat_imagescandata20,
            table0.uid AS xnat_imagescandata21,
            table0.project AS xnat_imagescandata22,
            table2.insert_date AS xnat_voiceaudioscandata_meta_data121,
            table4.login AS table4_login
           FROM (((public.xnat_voiceaudioscandata xnat_voiceaudioscandata
             LEFT JOIN public.xnat_imagescandata table0 ON ((xnat_voiceaudioscandata.xnat_imagescandata_id = table0.xnat_imagescandata_id)))
             LEFT JOIN public.xnat_voiceaudioscandata_meta_data table2 ON ((xnat_voiceaudioscandata.voiceaudioscandata_info = table2.meta_data_id)))
             LEFT JOIN public.xdat_user table4 ON ((table2.insert_user_xdat_user_id = table4.xdat_user_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_voiceaudioscandata0
           FROM ( SELECT table0.xnat_imagescandata_id AS xnat_voiceaudioscandata0,
                    table2.insert_date AS xnat_voiceaudioscandata_meta_data121
                   FROM ((public.xnat_voiceaudioscandata xnat_voiceaudioscandata
                     LEFT JOIN public.xnat_imagescandata table0 ON ((xnat_voiceaudioscandata.xnat_imagescandata_id = table0.xnat_imagescandata_id)))
                     LEFT JOIN public.xnat_voiceaudioscandata_meta_data table2 ON ((xnat_voiceaudioscandata.voiceaudioscandata_info = table2.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.xnat_voiceaudioscandata0 = search.xnat_voiceaudioscandata0)))
  ORDER BY search.xnat_imagescandata2;


ALTER TABLE public.displayfields_xnat_voiceaudioscandata OWNER TO xnat;

--
-- Name: xnat_xa3dscandata; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_xa3dscandata (
    xnat_imagescandata_id integer DEFAULT 0 NOT NULL,
    xa3dscandata_info integer
);


ALTER TABLE public.xnat_xa3dscandata OWNER TO xnat;

--
-- Name: xnat_xa3dscandata_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_xa3dscandata_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xnat_xa3dscandata_meta_data OWNER TO xnat;

--
-- Name: displayfields_xnat_xa3dscandata; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.displayfields_xnat_xa3dscandata AS
 SELECT search.xnat_imagescandata2 AS image_session_id,
    search.xnat_imagescandata3 AS note,
    search.xnat_imagescandata4 AS quality,
    search.xnat_imagescandata5 AS condition,
    search.xnat_imagescandata6 AS series_description,
    search.xnat_imagescandata8 AS documentation,
    search.xnat_imagescandata9 AS scanner,
    search.xnat_imagescandata10 AS scanner_manufacturer,
    search.xnat_imagescandata11 AS scanner_model,
    search.xnat_imagescandata13 AS modality,
    search.xnat_imagescandata14 AS frames,
    search.xnat_imagescandata15 AS operator,
    search.xnat_imagescandata17 AS starttime,
    search.xnat_imagescandata19 AS id,
    search.xnat_imagescandata20 AS type,
    search.xnat_imagescandata21 AS uid,
    search.xnat_imagescandata22 AS project,
    search.xnat_xa3dscandata_meta_data121 AS insert_date,
    search.table4_login AS insert_user,
    search.xnat_xa3dscandata_meta_data118 AS quarantine_status
   FROM (( SELECT DISTINCT table0.xnat_imagescandata_id AS xnat_xa3dscandata0,
            table2.status AS xnat_xa3dscandata_meta_data118,
            table0.image_session_id AS xnat_imagescandata2,
            table0.note AS xnat_imagescandata3,
            table0.quality AS xnat_imagescandata4,
            table0.condition AS xnat_imagescandata5,
            table0.series_description AS xnat_imagescandata6,
            table0.documentation AS xnat_imagescandata8,
            table0.scanner AS xnat_imagescandata9,
            table0.scanner_manufacturer AS xnat_imagescandata10,
            table0.scanner_model AS xnat_imagescandata11,
            table0.modality AS xnat_imagescandata13,
            table0.frames AS xnat_imagescandata14,
            table0.operator AS xnat_imagescandata15,
            table0.starttime AS xnat_imagescandata17,
            table0.id AS xnat_imagescandata19,
            table0.type AS xnat_imagescandata20,
            table0.uid AS xnat_imagescandata21,
            table0.project AS xnat_imagescandata22,
            table2.insert_date AS xnat_xa3dscandata_meta_data121,
            table4.login AS table4_login
           FROM (((public.xnat_xa3dscandata xnat_xa3dscandata
             LEFT JOIN public.xnat_imagescandata table0 ON ((xnat_xa3dscandata.xnat_imagescandata_id = table0.xnat_imagescandata_id)))
             LEFT JOIN public.xnat_xa3dscandata_meta_data table2 ON ((xnat_xa3dscandata.xa3dscandata_info = table2.meta_data_id)))
             LEFT JOIN public.xdat_user table4 ON ((table2.insert_user_xdat_user_id = table4.xdat_user_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_xa3dscandata0
           FROM ( SELECT table0.xnat_imagescandata_id AS xnat_xa3dscandata0,
                    table2.insert_date AS xnat_xa3dscandata_meta_data121
                   FROM ((public.xnat_xa3dscandata xnat_xa3dscandata
                     LEFT JOIN public.xnat_imagescandata table0 ON ((xnat_xa3dscandata.xnat_imagescandata_id = table0.xnat_imagescandata_id)))
                     LEFT JOIN public.xnat_xa3dscandata_meta_data table2 ON ((xnat_xa3dscandata.xa3dscandata_info = table2.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.xnat_xa3dscandata0 = search.xnat_xa3dscandata0)))
  ORDER BY search.xnat_imagescandata2;


ALTER TABLE public.displayfields_xnat_xa3dscandata OWNER TO xnat;

--
-- Name: xnat_xa3dsessiondata; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_xa3dsessiondata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    xa3dsessiondata_info integer
);


ALTER TABLE public.xnat_xa3dsessiondata OWNER TO xnat;

--
-- Name: xnat_xa3dsessiondata_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_xa3dsessiondata_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xnat_xa3dsessiondata_meta_data OWNER TO xnat;

--
-- Name: xnat_xa3dsessiondata_projects; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.xnat_xa3dsessiondata_projects AS
 SELECT expt.id,
    ((('<'::text || (expt.project)::text) || '>'::text) || public.xs_a_concat(((',<'::text || (shared.project)::text) || '>'::text))) AS projects
   FROM ((public.xnat_experimentdata expt
     LEFT JOIN public.xnat_experimentdata_share shared ON (((expt.id)::text = (shared.sharing_share_xnat_experimentda_id)::text)))
     LEFT JOIN public.xdat_meta_element xme ON ((expt.extension = xme.xdat_meta_element_id)))
  WHERE ((xme.element_name)::text = 'xnat:xa3DSessionData'::text)
  GROUP BY expt.id, expt.project;


ALTER TABLE public.xnat_xa3dsessiondata_projects OWNER TO xnat;

--
-- Name: displayfields_xnat_xa3dsessiondata; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.displayfields_xnat_xa3dsessiondata AS
 SELECT search.xnat_subjectassessordata19 AS subject_id,
    search.xnat_xa3dsessiondata0 AS expt_id,
    '/@WEBAPP/images/r.gif'::text AS rpt,
    search.xnat_experimentdata22 AS date,
    (COALESCE((floor(((((search.xnat_experimentdata22 - search.xnat_demographicdata_xnat_demographicdata1))::real / (365)::double precision))::numeric))::double precision, floor((date_part('year'::text, search.xnat_experimentdata22) - (search.xnat_demographicdata_xnat_demographicdata2)::double precision))))::numeric AS age,
    search.xnat_xa3dsessiondata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata38, search.xnat_xa3dsessiondata0) AS label,
    search.table5_login AS insert_user,
    search.xnat_xa3dsessiondata_meta_data976 AS insert_date,
    search.xnat_experimentdata32 AS project,
    search.xnat_xa3dsessiondata_meta_data973 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_xa3dsessiondata0) search_1.xnat_xa3dsessiondata0,
            search_1.xnat_xa3dsessiondata_meta_data973,
            search_1.xnat_subjectassessordata19,
            search_1.xnat_experimentdata22,
            search_1.xnat_experimentdata38,
            search_1.table5_login,
            search_1.xnat_xa3dsessiondata_meta_data976,
            search_1.xnat_experimentdata32,
            search_1.xnat_demographicdata_demograp_xnat_demographicdata0,
            search_1.xnat_demographicdata_at_demographicdata_meta_data47,
            search_1.xnat_demographicdata_xnat_demographicdata1,
            search_1.xnat_demographicdata_xnat_demographicdata2,
            search_1.xnat_xa3dsessiondata_projects_projects
           FROM ( SELECT table2.id AS xnat_xa3dsessiondata0,
                    table4.status AS xnat_xa3dsessiondata_meta_data973,
                    table1.subject_id AS xnat_subjectassessordata19,
                    table2.date AS xnat_experimentdata22,
                    table2.label AS xnat_experimentdata38,
                    table5.login AS table5_login,
                    table4.insert_date AS xnat_xa3dsessiondata_meta_data976,
                    table2.project AS xnat_experimentdata32,
                    xnat_demographicdata.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                    xnat_demographicdata.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                    xnat_demographicdata.xnat_demographicdata1 AS xnat_demographicdata_xnat_demographicdata1,
                    xnat_demographicdata.xnat_demographicdata2 AS xnat_demographicdata_xnat_demographicdata2,
                    xnat_xa3dsessiondata_projects.projects AS xnat_xa3dsessiondata_projects_projects
                   FROM ((((((((public.xnat_xa3dsessiondata xnat_xa3dsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_xa3dsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))
                     LEFT JOIN public.xnat_xa3dsessiondata_meta_data table4 ON ((xnat_xa3dsessiondata.xa3dsessiondata_info = table4.meta_data_id)))
                     LEFT JOIN public.xdat_user table5 ON ((table4.insert_user_xdat_user_id = table5.xdat_user_id)))
                     LEFT JOIN public.xnat_xa3dsessiondata_projects xnat_xa3dsessiondata_projects ON (((table2.id)::text = (xnat_xa3dsessiondata_projects.id)::text)))
                     LEFT JOIN ( SELECT search_2.xnat_subjectdata3,
                            search_2.xnat_subjectdata_meta_data328,
                            search_2.xnat_xa3dsessiondata_sordata__xnat_xa3dsessiondata0,
                            search_2.xnat_xa3dsessiondata_sordata__xnat_experimentdata22,
                            search_2.xnat_xa3dsessiondata_sor_xnat_subjectassessordata19,
                            search_2.xnat_demographicdata_demograp_xnat_demographicdata0,
                            search_2.xnat_demographicdata_at_demographicdata_meta_data47,
                            search_2.xnat_demographicdata_xnat_abstractdemographicdata27,
                            date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47)) AS xnat_subjectdata_xnat_demographicdata_diff
                           FROM ( SELECT xnat_subjectdata.id AS xnat_subjectdata3,
                                    table1_1.insert_date AS xnat_subjectdata_meta_data328,
                                    xnat_xa3dsessiondata_1.xnat_xa3dsessiondata0 AS xnat_xa3dsessiondata_sordata__xnat_xa3dsessiondata0,
                                    xnat_xa3dsessiondata_1.xnat_experimentdata22 AS xnat_xa3dsessiondata_sordata__xnat_experimentdata22,
                                    xnat_xa3dsessiondata_1.xnat_subjectassessordata19 AS xnat_xa3dsessiondata_sor_xnat_subjectassessordata19,
                                    xnat_demographicdata_1.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                                    xnat_demographicdata_1.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                                    xnat_demographicdata_1.xnat_abstractdemographicdata27 AS xnat_demographicdata_xnat_abstractdemographicdata27
                                   FROM ((((public.xnat_subjectdata xnat_subjectdata
                                     LEFT JOIN public.xnat_subjectdata_meta_data table1_1 ON ((xnat_subjectdata.subjectdata_info = table1_1.meta_data_id)))
                                     LEFT JOIN ( SELECT table2_1.id AS xnat_xa3dsessiondata0,
    table2_1.date AS xnat_experimentdata22,
    table1_2.subject_id AS xnat_subjectassessordata19
   FROM (((public.xnat_xa3dsessiondata xnat_xa3dsessiondata_2
     LEFT JOIN public.xnat_imagesessiondata table0_1 ON (((xnat_xa3dsessiondata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_subjectassessordata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))
     LEFT JOIN public.xnat_experimentdata table2_1 ON (((table1_2.id)::text = (table2_1.id)::text)))) xnat_xa3dsessiondata_1 ON (((xnat_subjectdata.id)::text = (xnat_xa3dsessiondata_1.xnat_subjectassessordata19)::text)))
                                     LEFT JOIN ( SELECT xnat_subjectdata_1.id AS xnat_subjectdata3,
    table1_2.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata91,
    table2_1.insert_date AS xnat_subjectdata_meta_data328
   FROM ((public.xnat_subjectdata xnat_subjectdata_1
     LEFT JOIN public.xnat_abstractdemographicdata table1_2 ON ((xnat_subjectdata_1.demographics_xnat_abstractdemographicdata_id = table1_2.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_subjectdata_meta_data table2_1 ON ((xnat_subjectdata_1.subjectdata_info = table2_1.meta_data_id)))) map_xnat_demographicdata ON (((xnat_subjectdata.id)::text = (map_xnat_demographicdata.xnat_subjectdata3)::text)))
                                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
    table2_1.insert_date AS xnat_demographicdata_meta_data47,
    table0_1.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata27
   FROM ((public.xnat_demographicdata xnat_demographicdata_2
     LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_2.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_2.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata_1 ON ((map_xnat_demographicdata.xnat_abstractdemographicdata91 = xnat_demographicdata_1.xnat_abstractdemographicdata27)))) search_2
                          ORDER BY search_2.xnat_subjectdata3, search_2.xnat_xa3dsessiondata_sordata__xnat_experimentdata22 DESC, (date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47)))) map_xnat_subjectdata_xnat_demographicdata ON (((table2.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_xa3dsessiondata_sordata__xnat_xa3dsessiondata0)::text)))
                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
                            table2_1.insert_date AS xnat_demographicdata_meta_data47,
                            xnat_demographicdata_1.dob AS xnat_demographicdata1,
                            xnat_demographicdata_1.yob AS xnat_demographicdata2
                           FROM ((public.xnat_demographicdata xnat_demographicdata_1
                             LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_1.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
                             LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_1.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata ON ((map_xnat_subjectdata_xnat_demographicdata.xnat_demographicdata_demograp_xnat_demographicdata0 = xnat_demographicdata.xnat_demographicdata0)))) search_1
          ORDER BY search_1.xnat_xa3dsessiondata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_xa3dsessiondata0
           FROM ( SELECT table2.id AS xnat_xa3dsessiondata0,
                    table2.date AS xnat_experimentdata22
                   FROM (((public.xnat_xa3dsessiondata xnat_xa3dsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_xa3dsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))) where_clause_1) where_clause ON (((where_clause.xnat_xa3dsessiondata0)::text = (search.xnat_xa3dsessiondata0)::text)))
  ORDER BY search.xnat_subjectassessordata19;


ALTER TABLE public.displayfields_xnat_xa3dsessiondata OWNER TO xnat;

--
-- Name: xnat_xascandata; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_xascandata (
    xnat_imagescandata_id integer DEFAULT 0 NOT NULL,
    parameters_pixelres_units character varying(255),
    parameters_pixelres_x integer,
    parameters_pixelres_y integer,
    parameters_orientation character varying(255),
    parameters_fov_x integer,
    parameters_fov_y integer,
    parameters_imagetype character varying(255),
    parameters_options character varying(255),
    parameters_derivation character varying(255),
    parameters_contrastbolus_xnat_contrastbolus_id integer,
    xascandata_info integer
);


ALTER TABLE public.xnat_xascandata OWNER TO xnat;

--
-- Name: xnat_xascandata_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_xascandata_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xnat_xascandata_meta_data OWNER TO xnat;

--
-- Name: displayfields_xnat_xascandata; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.displayfields_xnat_xascandata AS
 SELECT search.xnat_imagescandata12 AS image_session_id,
    search.xnat_imagescandata13 AS note,
    search.xnat_imagescandata14 AS quality,
    search.xnat_imagescandata15 AS condition,
    search.xnat_imagescandata16 AS series_description,
    search.xnat_imagescandata18 AS documentation,
    search.xnat_imagescandata19 AS scanner,
    search.xnat_imagescandata20 AS scanner_manufacturer,
    search.xnat_imagescandata21 AS scanner_model,
    search.xnat_imagescandata23 AS modality,
    search.xnat_imagescandata24 AS frames,
    search.xnat_imagescandata25 AS operator,
    search.xnat_imagescandata27 AS starttime,
    search.xnat_imagescandata29 AS id,
    search.xnat_imagescandata30 AS type,
    search.xnat_imagescandata31 AS uid,
    search.xnat_imagescandata32 AS project,
    search.xnat_xascandata_meta_data153 AS insert_date,
    search.table4_login AS insert_user,
    search.xnat_xascandata1 AS parameters_pixelres_units,
    search.xnat_xascandata2 AS parameters_pixelres_x,
    search.xnat_xascandata3 AS parameters_pixelres_y,
    search.xnat_xascandata4 AS parameters_orientation,
    search.xnat_xascandata5 AS parameters_fov_x,
    search.xnat_xascandata6 AS parameters_fov_y,
    search.xnat_xascandata7 AS parameters_imagetype,
    search.xnat_xascandata8 AS parameters_options,
    search.xnat_xascandata9 AS parameters_derivation,
    search.xnat_xascandata_meta_data150 AS quarantine_status
   FROM (( SELECT DISTINCT table0.xnat_imagescandata_id AS xnat_xascandata0,
            table2.status AS xnat_xascandata_meta_data150,
            table0.image_session_id AS xnat_imagescandata12,
            table0.note AS xnat_imagescandata13,
            table0.quality AS xnat_imagescandata14,
            table0.condition AS xnat_imagescandata15,
            table0.series_description AS xnat_imagescandata16,
            table0.documentation AS xnat_imagescandata18,
            table0.scanner AS xnat_imagescandata19,
            table0.scanner_manufacturer AS xnat_imagescandata20,
            table0.scanner_model AS xnat_imagescandata21,
            table0.modality AS xnat_imagescandata23,
            table0.frames AS xnat_imagescandata24,
            table0.operator AS xnat_imagescandata25,
            table0.starttime AS xnat_imagescandata27,
            table0.id AS xnat_imagescandata29,
            table0.type AS xnat_imagescandata30,
            table0.uid AS xnat_imagescandata31,
            table0.project AS xnat_imagescandata32,
            table2.insert_date AS xnat_xascandata_meta_data153,
            table4.login AS table4_login,
            xnat_xascandata.parameters_pixelres_units AS xnat_xascandata1,
            xnat_xascandata.parameters_pixelres_x AS xnat_xascandata2,
            xnat_xascandata.parameters_pixelres_y AS xnat_xascandata3,
            xnat_xascandata.parameters_orientation AS xnat_xascandata4,
            xnat_xascandata.parameters_fov_x AS xnat_xascandata5,
            xnat_xascandata.parameters_fov_y AS xnat_xascandata6,
            xnat_xascandata.parameters_imagetype AS xnat_xascandata7,
            xnat_xascandata.parameters_options AS xnat_xascandata8,
            xnat_xascandata.parameters_derivation AS xnat_xascandata9
           FROM (((public.xnat_xascandata xnat_xascandata
             LEFT JOIN public.xnat_imagescandata table0 ON ((xnat_xascandata.xnat_imagescandata_id = table0.xnat_imagescandata_id)))
             LEFT JOIN public.xnat_xascandata_meta_data table2 ON ((xnat_xascandata.xascandata_info = table2.meta_data_id)))
             LEFT JOIN public.xdat_user table4 ON ((table2.insert_user_xdat_user_id = table4.xdat_user_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_xascandata0
           FROM ( SELECT table0.xnat_imagescandata_id AS xnat_xascandata0,
                    table2.insert_date AS xnat_xascandata_meta_data153
                   FROM ((public.xnat_xascandata xnat_xascandata
                     LEFT JOIN public.xnat_imagescandata table0 ON ((xnat_xascandata.xnat_imagescandata_id = table0.xnat_imagescandata_id)))
                     LEFT JOIN public.xnat_xascandata_meta_data table2 ON ((xnat_xascandata.xascandata_info = table2.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.xnat_xascandata0 = search.xnat_xascandata0)))
  ORDER BY search.xnat_imagescandata12;


ALTER TABLE public.displayfields_xnat_xascandata OWNER TO xnat;

--
-- Name: xnat_xasessiondata; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_xasessiondata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    xasessiondata_info integer
);


ALTER TABLE public.xnat_xasessiondata OWNER TO xnat;

--
-- Name: xnat_xasessiondata_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_xasessiondata_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xnat_xasessiondata_meta_data OWNER TO xnat;

--
-- Name: xnat_xasessiondata_projects; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.xnat_xasessiondata_projects AS
 SELECT expt.id,
    ((('<'::text || (expt.project)::text) || '>'::text) || public.xs_a_concat(((',<'::text || (shared.project)::text) || '>'::text))) AS projects
   FROM ((public.xnat_experimentdata expt
     LEFT JOIN public.xnat_experimentdata_share shared ON (((expt.id)::text = (shared.sharing_share_xnat_experimentda_id)::text)))
     LEFT JOIN public.xdat_meta_element xme ON ((expt.extension = xme.xdat_meta_element_id)))
  WHERE ((xme.element_name)::text = 'xnat:xaSessionData'::text)
  GROUP BY expt.id, expt.project;


ALTER TABLE public.xnat_xasessiondata_projects OWNER TO xnat;

--
-- Name: displayfields_xnat_xasessiondata; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.displayfields_xnat_xasessiondata AS
 SELECT search.xnat_subjectassessordata19 AS subject_id,
    search.xnat_xasessiondata0 AS expt_id,
    '/@WEBAPP/images/r.gif'::text AS rpt,
    search.xnat_experimentdata22 AS date,
    (COALESCE((floor(((((search.xnat_experimentdata22 - search.xnat_demographicdata_xnat_demographicdata1))::real / (365)::double precision))::numeric))::double precision, floor((date_part('year'::text, search.xnat_experimentdata22) - (search.xnat_demographicdata_xnat_demographicdata2)::double precision))))::numeric AS age,
    search.xnat_xasessiondata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata38, search.xnat_xasessiondata0) AS label,
    search.table5_login AS insert_user,
    search.xnat_xasessiondata_meta_data976 AS insert_date,
    search.xnat_experimentdata32 AS project,
    search.xnat_xasessiondata_meta_data973 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_xasessiondata0) search_1.xnat_xasessiondata0,
            search_1.xnat_xasessiondata_meta_data973,
            search_1.xnat_subjectassessordata19,
            search_1.xnat_experimentdata22,
            search_1.xnat_experimentdata38,
            search_1.table5_login,
            search_1.xnat_xasessiondata_meta_data976,
            search_1.xnat_experimentdata32,
            search_1.xnat_demographicdata_demograp_xnat_demographicdata0,
            search_1.xnat_demographicdata_at_demographicdata_meta_data47,
            search_1.xnat_demographicdata_xnat_demographicdata1,
            search_1.xnat_demographicdata_xnat_demographicdata2,
            search_1.xnat_xasessiondata_projects_projects
           FROM ( SELECT table2.id AS xnat_xasessiondata0,
                    table4.status AS xnat_xasessiondata_meta_data973,
                    table1.subject_id AS xnat_subjectassessordata19,
                    table2.date AS xnat_experimentdata22,
                    table2.label AS xnat_experimentdata38,
                    table5.login AS table5_login,
                    table4.insert_date AS xnat_xasessiondata_meta_data976,
                    table2.project AS xnat_experimentdata32,
                    xnat_demographicdata.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                    xnat_demographicdata.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                    xnat_demographicdata.xnat_demographicdata1 AS xnat_demographicdata_xnat_demographicdata1,
                    xnat_demographicdata.xnat_demographicdata2 AS xnat_demographicdata_xnat_demographicdata2,
                    xnat_xasessiondata_projects.projects AS xnat_xasessiondata_projects_projects
                   FROM ((((((((public.xnat_xasessiondata xnat_xasessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_xasessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))
                     LEFT JOIN public.xnat_xasessiondata_meta_data table4 ON ((xnat_xasessiondata.xasessiondata_info = table4.meta_data_id)))
                     LEFT JOIN public.xdat_user table5 ON ((table4.insert_user_xdat_user_id = table5.xdat_user_id)))
                     LEFT JOIN public.xnat_xasessiondata_projects xnat_xasessiondata_projects ON (((table2.id)::text = (xnat_xasessiondata_projects.id)::text)))
                     LEFT JOIN ( SELECT search_2.xnat_subjectdata3,
                            search_2.xnat_subjectdata_meta_data328,
                            search_2.xnat_xasessiondata_sordata_ex_xnat_xasessiondata0,
                            search_2.xnat_xasessiondata_sordata__xnat_experimentdata22,
                            search_2.xnat_xasessiondata_sor_xnat_subjectassessordata19,
                            search_2.xnat_demographicdata_demograp_xnat_demographicdata0,
                            search_2.xnat_demographicdata_at_demographicdata_meta_data47,
                            search_2.xnat_demographicdata_xnat_abstractdemographicdata27,
                            date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47)) AS xnat_subjectdata_xnat_demographicdata_diff
                           FROM ( SELECT xnat_subjectdata.id AS xnat_subjectdata3,
                                    table1_1.insert_date AS xnat_subjectdata_meta_data328,
                                    xnat_xasessiondata_1.xnat_xasessiondata0 AS xnat_xasessiondata_sordata_ex_xnat_xasessiondata0,
                                    xnat_xasessiondata_1.xnat_experimentdata22 AS xnat_xasessiondata_sordata__xnat_experimentdata22,
                                    xnat_xasessiondata_1.xnat_subjectassessordata19 AS xnat_xasessiondata_sor_xnat_subjectassessordata19,
                                    xnat_demographicdata_1.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                                    xnat_demographicdata_1.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                                    xnat_demographicdata_1.xnat_abstractdemographicdata27 AS xnat_demographicdata_xnat_abstractdemographicdata27
                                   FROM ((((public.xnat_subjectdata xnat_subjectdata
                                     LEFT JOIN public.xnat_subjectdata_meta_data table1_1 ON ((xnat_subjectdata.subjectdata_info = table1_1.meta_data_id)))
                                     LEFT JOIN ( SELECT table2_1.id AS xnat_xasessiondata0,
    table2_1.date AS xnat_experimentdata22,
    table1_2.subject_id AS xnat_subjectassessordata19
   FROM (((public.xnat_xasessiondata xnat_xasessiondata_2
     LEFT JOIN public.xnat_imagesessiondata table0_1 ON (((xnat_xasessiondata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_subjectassessordata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))
     LEFT JOIN public.xnat_experimentdata table2_1 ON (((table1_2.id)::text = (table2_1.id)::text)))) xnat_xasessiondata_1 ON (((xnat_subjectdata.id)::text = (xnat_xasessiondata_1.xnat_subjectassessordata19)::text)))
                                     LEFT JOIN ( SELECT xnat_subjectdata_1.id AS xnat_subjectdata3,
    table1_2.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata91,
    table2_1.insert_date AS xnat_subjectdata_meta_data328
   FROM ((public.xnat_subjectdata xnat_subjectdata_1
     LEFT JOIN public.xnat_abstractdemographicdata table1_2 ON ((xnat_subjectdata_1.demographics_xnat_abstractdemographicdata_id = table1_2.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_subjectdata_meta_data table2_1 ON ((xnat_subjectdata_1.subjectdata_info = table2_1.meta_data_id)))) map_xnat_demographicdata ON (((xnat_subjectdata.id)::text = (map_xnat_demographicdata.xnat_subjectdata3)::text)))
                                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
    table2_1.insert_date AS xnat_demographicdata_meta_data47,
    table0_1.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata27
   FROM ((public.xnat_demographicdata xnat_demographicdata_2
     LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_2.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_2.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata_1 ON ((map_xnat_demographicdata.xnat_abstractdemographicdata91 = xnat_demographicdata_1.xnat_abstractdemographicdata27)))) search_2
                          ORDER BY search_2.xnat_subjectdata3, search_2.xnat_xasessiondata_sordata__xnat_experimentdata22 DESC, (date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47)))) map_xnat_subjectdata_xnat_demographicdata ON (((table2.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_xasessiondata_sordata_ex_xnat_xasessiondata0)::text)))
                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
                            table2_1.insert_date AS xnat_demographicdata_meta_data47,
                            xnat_demographicdata_1.dob AS xnat_demographicdata1,
                            xnat_demographicdata_1.yob AS xnat_demographicdata2
                           FROM ((public.xnat_demographicdata xnat_demographicdata_1
                             LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_1.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
                             LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_1.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata ON ((map_xnat_subjectdata_xnat_demographicdata.xnat_demographicdata_demograp_xnat_demographicdata0 = xnat_demographicdata.xnat_demographicdata0)))) search_1
          ORDER BY search_1.xnat_xasessiondata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_xasessiondata0
           FROM ( SELECT table2.id AS xnat_xasessiondata0,
                    table2.date AS xnat_experimentdata22
                   FROM (((public.xnat_xasessiondata xnat_xasessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_xasessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))) where_clause_1) where_clause ON (((where_clause.xnat_xasessiondata0)::text = (search.xnat_xasessiondata0)::text)))
  ORDER BY search.xnat_subjectassessordata19;


ALTER TABLE public.displayfields_xnat_xasessiondata OWNER TO xnat;

--
-- Name: xnat_xcscandata; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_xcscandata (
    xnat_imagescandata_id integer DEFAULT 0 NOT NULL,
    xcscandata_info integer
);


ALTER TABLE public.xnat_xcscandata OWNER TO xnat;

--
-- Name: xnat_xcscandata_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_xcscandata_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xnat_xcscandata_meta_data OWNER TO xnat;

--
-- Name: displayfields_xnat_xcscandata; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.displayfields_xnat_xcscandata AS
 SELECT search.xnat_imagescandata2 AS image_session_id,
    search.xnat_imagescandata3 AS note,
    search.xnat_imagescandata4 AS quality,
    search.xnat_imagescandata5 AS condition,
    search.xnat_imagescandata6 AS series_description,
    search.xnat_imagescandata8 AS documentation,
    search.xnat_imagescandata9 AS scanner,
    search.xnat_imagescandata10 AS scanner_manufacturer,
    search.xnat_imagescandata11 AS scanner_model,
    search.xnat_imagescandata13 AS modality,
    search.xnat_imagescandata14 AS frames,
    search.xnat_imagescandata15 AS operator,
    search.xnat_imagescandata17 AS starttime,
    search.xnat_imagescandata19 AS id,
    search.xnat_imagescandata20 AS type,
    search.xnat_imagescandata21 AS uid,
    search.xnat_imagescandata22 AS project,
    search.xnat_xcscandata_meta_data121 AS insert_date,
    search.table4_login AS insert_user,
    search.xnat_xcscandata_meta_data118 AS quarantine_status
   FROM (( SELECT DISTINCT table0.xnat_imagescandata_id AS xnat_xcscandata0,
            table2.status AS xnat_xcscandata_meta_data118,
            table0.image_session_id AS xnat_imagescandata2,
            table0.note AS xnat_imagescandata3,
            table0.quality AS xnat_imagescandata4,
            table0.condition AS xnat_imagescandata5,
            table0.series_description AS xnat_imagescandata6,
            table0.documentation AS xnat_imagescandata8,
            table0.scanner AS xnat_imagescandata9,
            table0.scanner_manufacturer AS xnat_imagescandata10,
            table0.scanner_model AS xnat_imagescandata11,
            table0.modality AS xnat_imagescandata13,
            table0.frames AS xnat_imagescandata14,
            table0.operator AS xnat_imagescandata15,
            table0.starttime AS xnat_imagescandata17,
            table0.id AS xnat_imagescandata19,
            table0.type AS xnat_imagescandata20,
            table0.uid AS xnat_imagescandata21,
            table0.project AS xnat_imagescandata22,
            table2.insert_date AS xnat_xcscandata_meta_data121,
            table4.login AS table4_login
           FROM (((public.xnat_xcscandata xnat_xcscandata
             LEFT JOIN public.xnat_imagescandata table0 ON ((xnat_xcscandata.xnat_imagescandata_id = table0.xnat_imagescandata_id)))
             LEFT JOIN public.xnat_xcscandata_meta_data table2 ON ((xnat_xcscandata.xcscandata_info = table2.meta_data_id)))
             LEFT JOIN public.xdat_user table4 ON ((table2.insert_user_xdat_user_id = table4.xdat_user_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_xcscandata0
           FROM ( SELECT table0.xnat_imagescandata_id AS xnat_xcscandata0,
                    table2.insert_date AS xnat_xcscandata_meta_data121
                   FROM ((public.xnat_xcscandata xnat_xcscandata
                     LEFT JOIN public.xnat_imagescandata table0 ON ((xnat_xcscandata.xnat_imagescandata_id = table0.xnat_imagescandata_id)))
                     LEFT JOIN public.xnat_xcscandata_meta_data table2 ON ((xnat_xcscandata.xcscandata_info = table2.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.xnat_xcscandata0 = search.xnat_xcscandata0)))
  ORDER BY search.xnat_imagescandata2;


ALTER TABLE public.displayfields_xnat_xcscandata OWNER TO xnat;

--
-- Name: xnat_xcsessiondata; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_xcsessiondata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    xcsessiondata_info integer
);


ALTER TABLE public.xnat_xcsessiondata OWNER TO xnat;

--
-- Name: xnat_xcsessiondata_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_xcsessiondata_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xnat_xcsessiondata_meta_data OWNER TO xnat;

--
-- Name: xnat_xcsessiondata_projects; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.xnat_xcsessiondata_projects AS
 SELECT expt.id,
    ((('<'::text || (expt.project)::text) || '>'::text) || public.xs_a_concat(((',<'::text || (shared.project)::text) || '>'::text))) AS projects
   FROM ((public.xnat_experimentdata expt
     LEFT JOIN public.xnat_experimentdata_share shared ON (((expt.id)::text = (shared.sharing_share_xnat_experimentda_id)::text)))
     LEFT JOIN public.xdat_meta_element xme ON ((expt.extension = xme.xdat_meta_element_id)))
  WHERE ((xme.element_name)::text = 'xnat:xcSessionData'::text)
  GROUP BY expt.id, expt.project;


ALTER TABLE public.xnat_xcsessiondata_projects OWNER TO xnat;

--
-- Name: displayfields_xnat_xcsessiondata; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.displayfields_xnat_xcsessiondata AS
 SELECT search.xnat_subjectassessordata19 AS subject_id,
    search.xnat_xcsessiondata0 AS expt_id,
    '/@WEBAPP/images/r.gif'::text AS rpt,
    search.xnat_experimentdata22 AS date,
    (COALESCE((floor(((((search.xnat_experimentdata22 - search.xnat_demographicdata_xnat_demographicdata1))::real / (365)::double precision))::numeric))::double precision, floor((date_part('year'::text, search.xnat_experimentdata22) - (search.xnat_demographicdata_xnat_demographicdata2)::double precision))))::numeric AS age,
    search.xnat_xcsessiondata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata38, search.xnat_xcsessiondata0) AS label,
    search.table5_login AS insert_user,
    search.xnat_xcsessiondata_meta_data976 AS insert_date,
    search.xnat_experimentdata32 AS project,
    search.xnat_xcsessiondata_meta_data973 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_xcsessiondata0) search_1.xnat_xcsessiondata0,
            search_1.xnat_xcsessiondata_meta_data973,
            search_1.xnat_subjectassessordata19,
            search_1.xnat_experimentdata22,
            search_1.xnat_experimentdata38,
            search_1.table5_login,
            search_1.xnat_xcsessiondata_meta_data976,
            search_1.xnat_experimentdata32,
            search_1.xnat_demographicdata_demograp_xnat_demographicdata0,
            search_1.xnat_demographicdata_at_demographicdata_meta_data47,
            search_1.xnat_demographicdata_xnat_demographicdata1,
            search_1.xnat_demographicdata_xnat_demographicdata2,
            search_1.xnat_xcsessiondata_projects_projects
           FROM ( SELECT table2.id AS xnat_xcsessiondata0,
                    table4.status AS xnat_xcsessiondata_meta_data973,
                    table1.subject_id AS xnat_subjectassessordata19,
                    table2.date AS xnat_experimentdata22,
                    table2.label AS xnat_experimentdata38,
                    table5.login AS table5_login,
                    table4.insert_date AS xnat_xcsessiondata_meta_data976,
                    table2.project AS xnat_experimentdata32,
                    xnat_demographicdata.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                    xnat_demographicdata.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                    xnat_demographicdata.xnat_demographicdata1 AS xnat_demographicdata_xnat_demographicdata1,
                    xnat_demographicdata.xnat_demographicdata2 AS xnat_demographicdata_xnat_demographicdata2,
                    xnat_xcsessiondata_projects.projects AS xnat_xcsessiondata_projects_projects
                   FROM ((((((((public.xnat_xcsessiondata xnat_xcsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_xcsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))
                     LEFT JOIN public.xnat_xcsessiondata_meta_data table4 ON ((xnat_xcsessiondata.xcsessiondata_info = table4.meta_data_id)))
                     LEFT JOIN public.xdat_user table5 ON ((table4.insert_user_xdat_user_id = table5.xdat_user_id)))
                     LEFT JOIN public.xnat_xcsessiondata_projects xnat_xcsessiondata_projects ON (((table2.id)::text = (xnat_xcsessiondata_projects.id)::text)))
                     LEFT JOIN ( SELECT search_2.xnat_subjectdata3,
                            search_2.xnat_subjectdata_meta_data328,
                            search_2.xnat_demographicdata_demograp_xnat_demographicdata0,
                            search_2.xnat_demographicdata_at_demographicdata_meta_data47,
                            search_2.xnat_demographicdata_xnat_abstractdemographicdata27,
                            search_2.xnat_xcsessiondata_sordata_ex_xnat_xcsessiondata0,
                            search_2.xnat_xcsessiondata_sordata__xnat_experimentdata22,
                            search_2.xnat_xcsessiondata_sor_xnat_subjectassessordata19,
                            date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47)) AS xnat_subjectdata_xnat_demographicdata_diff
                           FROM ( SELECT xnat_subjectdata.id AS xnat_subjectdata3,
                                    table1_1.insert_date AS xnat_subjectdata_meta_data328,
                                    xnat_demographicdata_1.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                                    xnat_demographicdata_1.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                                    xnat_demographicdata_1.xnat_abstractdemographicdata27 AS xnat_demographicdata_xnat_abstractdemographicdata27,
                                    xnat_xcsessiondata_1.xnat_xcsessiondata0 AS xnat_xcsessiondata_sordata_ex_xnat_xcsessiondata0,
                                    xnat_xcsessiondata_1.xnat_experimentdata22 AS xnat_xcsessiondata_sordata__xnat_experimentdata22,
                                    xnat_xcsessiondata_1.xnat_subjectassessordata19 AS xnat_xcsessiondata_sor_xnat_subjectassessordata19
                                   FROM ((((public.xnat_subjectdata xnat_subjectdata
                                     LEFT JOIN public.xnat_subjectdata_meta_data table1_1 ON ((xnat_subjectdata.subjectdata_info = table1_1.meta_data_id)))
                                     LEFT JOIN ( SELECT xnat_subjectdata_1.id AS xnat_subjectdata3,
    table1_2.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata91,
    table2_1.insert_date AS xnat_subjectdata_meta_data328
   FROM ((public.xnat_subjectdata xnat_subjectdata_1
     LEFT JOIN public.xnat_abstractdemographicdata table1_2 ON ((xnat_subjectdata_1.demographics_xnat_abstractdemographicdata_id = table1_2.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_subjectdata_meta_data table2_1 ON ((xnat_subjectdata_1.subjectdata_info = table2_1.meta_data_id)))) map_xnat_demographicdata ON (((xnat_subjectdata.id)::text = (map_xnat_demographicdata.xnat_subjectdata3)::text)))
                                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
    table2_1.insert_date AS xnat_demographicdata_meta_data47,
    table0_1.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata27
   FROM ((public.xnat_demographicdata xnat_demographicdata_2
     LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_2.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_2.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata_1 ON ((map_xnat_demographicdata.xnat_abstractdemographicdata91 = xnat_demographicdata_1.xnat_abstractdemographicdata27)))
                                     LEFT JOIN ( SELECT table2_1.id AS xnat_xcsessiondata0,
    table2_1.date AS xnat_experimentdata22,
    table1_2.subject_id AS xnat_subjectassessordata19
   FROM (((public.xnat_xcsessiondata xnat_xcsessiondata_2
     LEFT JOIN public.xnat_imagesessiondata table0_1 ON (((xnat_xcsessiondata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_subjectassessordata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))
     LEFT JOIN public.xnat_experimentdata table2_1 ON (((table1_2.id)::text = (table2_1.id)::text)))) xnat_xcsessiondata_1 ON (((xnat_subjectdata.id)::text = (xnat_xcsessiondata_1.xnat_subjectassessordata19)::text)))) search_2
                          ORDER BY search_2.xnat_subjectdata3, (date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47))), search_2.xnat_xcsessiondata_sordata__xnat_experimentdata22 DESC) map_xnat_subjectdata_xnat_demographicdata ON (((table2.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_xcsessiondata_sordata_ex_xnat_xcsessiondata0)::text)))
                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
                            table2_1.insert_date AS xnat_demographicdata_meta_data47,
                            xnat_demographicdata_1.dob AS xnat_demographicdata1,
                            xnat_demographicdata_1.yob AS xnat_demographicdata2
                           FROM ((public.xnat_demographicdata xnat_demographicdata_1
                             LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_1.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
                             LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_1.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata ON ((map_xnat_subjectdata_xnat_demographicdata.xnat_demographicdata_demograp_xnat_demographicdata0 = xnat_demographicdata.xnat_demographicdata0)))) search_1
          ORDER BY search_1.xnat_xcsessiondata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_xcsessiondata0
           FROM ( SELECT table2.id AS xnat_xcsessiondata0,
                    table2.date AS xnat_experimentdata22
                   FROM (((public.xnat_xcsessiondata xnat_xcsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_xcsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))) where_clause_1) where_clause ON (((where_clause.xnat_xcsessiondata0)::text = (search.xnat_xcsessiondata0)::text)))
  ORDER BY search.xnat_subjectassessordata19;


ALTER TABLE public.displayfields_xnat_xcsessiondata OWNER TO xnat;

--
-- Name: xnat_xcvscandata; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_xcvscandata (
    xnat_imagescandata_id integer DEFAULT 0 NOT NULL,
    xcvscandata_info integer
);


ALTER TABLE public.xnat_xcvscandata OWNER TO xnat;

--
-- Name: xnat_xcvscandata_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_xcvscandata_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xnat_xcvscandata_meta_data OWNER TO xnat;

--
-- Name: displayfields_xnat_xcvscandata; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.displayfields_xnat_xcvscandata AS
 SELECT search.xnat_imagescandata2 AS image_session_id,
    search.xnat_imagescandata3 AS note,
    search.xnat_imagescandata4 AS quality,
    search.xnat_imagescandata5 AS condition,
    search.xnat_imagescandata6 AS series_description,
    search.xnat_imagescandata8 AS documentation,
    search.xnat_imagescandata9 AS scanner,
    search.xnat_imagescandata10 AS scanner_manufacturer,
    search.xnat_imagescandata11 AS scanner_model,
    search.xnat_imagescandata13 AS modality,
    search.xnat_imagescandata14 AS frames,
    search.xnat_imagescandata15 AS operator,
    search.xnat_imagescandata17 AS starttime,
    search.xnat_imagescandata19 AS id,
    search.xnat_imagescandata20 AS type,
    search.xnat_imagescandata21 AS uid,
    search.xnat_imagescandata22 AS project,
    search.xnat_xcvscandata_meta_data121 AS insert_date,
    search.table4_login AS insert_user,
    search.xnat_xcvscandata_meta_data118 AS quarantine_status
   FROM (( SELECT DISTINCT table0.xnat_imagescandata_id AS xnat_xcvscandata0,
            table2.status AS xnat_xcvscandata_meta_data118,
            table0.image_session_id AS xnat_imagescandata2,
            table0.note AS xnat_imagescandata3,
            table0.quality AS xnat_imagescandata4,
            table0.condition AS xnat_imagescandata5,
            table0.series_description AS xnat_imagescandata6,
            table0.documentation AS xnat_imagescandata8,
            table0.scanner AS xnat_imagescandata9,
            table0.scanner_manufacturer AS xnat_imagescandata10,
            table0.scanner_model AS xnat_imagescandata11,
            table0.modality AS xnat_imagescandata13,
            table0.frames AS xnat_imagescandata14,
            table0.operator AS xnat_imagescandata15,
            table0.starttime AS xnat_imagescandata17,
            table0.id AS xnat_imagescandata19,
            table0.type AS xnat_imagescandata20,
            table0.uid AS xnat_imagescandata21,
            table0.project AS xnat_imagescandata22,
            table2.insert_date AS xnat_xcvscandata_meta_data121,
            table4.login AS table4_login
           FROM (((public.xnat_xcvscandata xnat_xcvscandata
             LEFT JOIN public.xnat_imagescandata table0 ON ((xnat_xcvscandata.xnat_imagescandata_id = table0.xnat_imagescandata_id)))
             LEFT JOIN public.xnat_xcvscandata_meta_data table2 ON ((xnat_xcvscandata.xcvscandata_info = table2.meta_data_id)))
             LEFT JOIN public.xdat_user table4 ON ((table2.insert_user_xdat_user_id = table4.xdat_user_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_xcvscandata0
           FROM ( SELECT table0.xnat_imagescandata_id AS xnat_xcvscandata0,
                    table2.insert_date AS xnat_xcvscandata_meta_data121
                   FROM ((public.xnat_xcvscandata xnat_xcvscandata
                     LEFT JOIN public.xnat_imagescandata table0 ON ((xnat_xcvscandata.xnat_imagescandata_id = table0.xnat_imagescandata_id)))
                     LEFT JOIN public.xnat_xcvscandata_meta_data table2 ON ((xnat_xcvscandata.xcvscandata_info = table2.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.xnat_xcvscandata0 = search.xnat_xcvscandata0)))
  ORDER BY search.xnat_imagescandata2;


ALTER TABLE public.displayfields_xnat_xcvscandata OWNER TO xnat;

--
-- Name: xnat_xcvsessiondata; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_xcvsessiondata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    xcvsessiondata_info integer
);


ALTER TABLE public.xnat_xcvsessiondata OWNER TO xnat;

--
-- Name: xnat_xcvsessiondata_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xnat_xcvsessiondata_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xnat_xcvsessiondata_meta_data OWNER TO xnat;

--
-- Name: xnat_xcvsessiondata_projects; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.xnat_xcvsessiondata_projects AS
 SELECT expt.id,
    ((('<'::text || (expt.project)::text) || '>'::text) || public.xs_a_concat(((',<'::text || (shared.project)::text) || '>'::text))) AS projects
   FROM ((public.xnat_experimentdata expt
     LEFT JOIN public.xnat_experimentdata_share shared ON (((expt.id)::text = (shared.sharing_share_xnat_experimentda_id)::text)))
     LEFT JOIN public.xdat_meta_element xme ON ((expt.extension = xme.xdat_meta_element_id)))
  WHERE ((xme.element_name)::text = 'xnat:xcvSessionData'::text)
  GROUP BY expt.id, expt.project;


ALTER TABLE public.xnat_xcvsessiondata_projects OWNER TO xnat;

--
-- Name: displayfields_xnat_xcvsessiondata; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.displayfields_xnat_xcvsessiondata AS
 SELECT search.xnat_subjectassessordata19 AS subject_id,
    search.xnat_xcvsessiondata0 AS expt_id,
    '/@WEBAPP/images/r.gif'::text AS rpt,
    search.xnat_experimentdata22 AS date,
    (COALESCE((floor(((((search.xnat_experimentdata22 - search.xnat_demographicdata_xnat_demographicdata1))::real / (365)::double precision))::numeric))::double precision, floor((date_part('year'::text, search.xnat_experimentdata22) - (search.xnat_demographicdata_xnat_demographicdata2)::double precision))))::numeric AS age,
    search.xnat_xcvsessiondata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata38, search.xnat_xcvsessiondata0) AS label,
    search.table5_login AS insert_user,
    search.xnat_xcvsessiondata_meta_data976 AS insert_date,
    search.xnat_experimentdata32 AS project,
    search.xnat_xcvsessiondata_meta_data973 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_xcvsessiondata0) search_1.xnat_xcvsessiondata0,
            search_1.xnat_xcvsessiondata_meta_data973,
            search_1.xnat_subjectassessordata19,
            search_1.xnat_experimentdata22,
            search_1.xnat_experimentdata38,
            search_1.table5_login,
            search_1.xnat_xcvsessiondata_meta_data976,
            search_1.xnat_experimentdata32,
            search_1.xnat_demographicdata_demograp_xnat_demographicdata0,
            search_1.xnat_demographicdata_at_demographicdata_meta_data47,
            search_1.xnat_demographicdata_xnat_demographicdata1,
            search_1.xnat_demographicdata_xnat_demographicdata2,
            search_1.xnat_xcvsessiondata_projects_projects
           FROM ( SELECT table2.id AS xnat_xcvsessiondata0,
                    table4.status AS xnat_xcvsessiondata_meta_data973,
                    table1.subject_id AS xnat_subjectassessordata19,
                    table2.date AS xnat_experimentdata22,
                    table2.label AS xnat_experimentdata38,
                    table5.login AS table5_login,
                    table4.insert_date AS xnat_xcvsessiondata_meta_data976,
                    table2.project AS xnat_experimentdata32,
                    xnat_demographicdata.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                    xnat_demographicdata.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                    xnat_demographicdata.xnat_demographicdata1 AS xnat_demographicdata_xnat_demographicdata1,
                    xnat_demographicdata.xnat_demographicdata2 AS xnat_demographicdata_xnat_demographicdata2,
                    xnat_xcvsessiondata_projects.projects AS xnat_xcvsessiondata_projects_projects
                   FROM ((((((((public.xnat_xcvsessiondata xnat_xcvsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_xcvsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))
                     LEFT JOIN public.xnat_xcvsessiondata_meta_data table4 ON ((xnat_xcvsessiondata.xcvsessiondata_info = table4.meta_data_id)))
                     LEFT JOIN public.xdat_user table5 ON ((table4.insert_user_xdat_user_id = table5.xdat_user_id)))
                     LEFT JOIN public.xnat_xcvsessiondata_projects xnat_xcvsessiondata_projects ON (((table2.id)::text = (xnat_xcvsessiondata_projects.id)::text)))
                     LEFT JOIN ( SELECT search_2.xnat_subjectdata3,
                            search_2.xnat_subjectdata_meta_data328,
                            search_2.xnat_demographicdata_demograp_xnat_demographicdata0,
                            search_2.xnat_demographicdata_at_demographicdata_meta_data47,
                            search_2.xnat_demographicdata_xnat_abstractdemographicdata27,
                            search_2.xnat_xcvsessiondata_sordata_e_xnat_xcvsessiondata0,
                            search_2.xnat_xcvsessiondata_sordata__xnat_experimentdata22,
                            search_2.xnat_xcvsessiondata_sor_xnat_subjectassessordata19,
                            date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47)) AS xnat_subjectdata_xnat_demographicdata_diff
                           FROM ( SELECT xnat_subjectdata.id AS xnat_subjectdata3,
                                    table1_1.insert_date AS xnat_subjectdata_meta_data328,
                                    xnat_demographicdata_1.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                                    xnat_demographicdata_1.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                                    xnat_demographicdata_1.xnat_abstractdemographicdata27 AS xnat_demographicdata_xnat_abstractdemographicdata27,
                                    xnat_xcvsessiondata_1.xnat_xcvsessiondata0 AS xnat_xcvsessiondata_sordata_e_xnat_xcvsessiondata0,
                                    xnat_xcvsessiondata_1.xnat_experimentdata22 AS xnat_xcvsessiondata_sordata__xnat_experimentdata22,
                                    xnat_xcvsessiondata_1.xnat_subjectassessordata19 AS xnat_xcvsessiondata_sor_xnat_subjectassessordata19
                                   FROM ((((public.xnat_subjectdata xnat_subjectdata
                                     LEFT JOIN public.xnat_subjectdata_meta_data table1_1 ON ((xnat_subjectdata.subjectdata_info = table1_1.meta_data_id)))
                                     LEFT JOIN ( SELECT xnat_subjectdata_1.id AS xnat_subjectdata3,
    table1_2.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata91,
    table2_1.insert_date AS xnat_subjectdata_meta_data328
   FROM ((public.xnat_subjectdata xnat_subjectdata_1
     LEFT JOIN public.xnat_abstractdemographicdata table1_2 ON ((xnat_subjectdata_1.demographics_xnat_abstractdemographicdata_id = table1_2.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_subjectdata_meta_data table2_1 ON ((xnat_subjectdata_1.subjectdata_info = table2_1.meta_data_id)))) map_xnat_demographicdata ON (((xnat_subjectdata.id)::text = (map_xnat_demographicdata.xnat_subjectdata3)::text)))
                                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
    table2_1.insert_date AS xnat_demographicdata_meta_data47,
    table0_1.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata27
   FROM ((public.xnat_demographicdata xnat_demographicdata_2
     LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_2.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_2.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata_1 ON ((map_xnat_demographicdata.xnat_abstractdemographicdata91 = xnat_demographicdata_1.xnat_abstractdemographicdata27)))
                                     LEFT JOIN ( SELECT table2_1.id AS xnat_xcvsessiondata0,
    table2_1.date AS xnat_experimentdata22,
    table1_2.subject_id AS xnat_subjectassessordata19
   FROM (((public.xnat_xcvsessiondata xnat_xcvsessiondata_2
     LEFT JOIN public.xnat_imagesessiondata table0_1 ON (((xnat_xcvsessiondata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_subjectassessordata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))
     LEFT JOIN public.xnat_experimentdata table2_1 ON (((table1_2.id)::text = (table2_1.id)::text)))) xnat_xcvsessiondata_1 ON (((xnat_subjectdata.id)::text = (xnat_xcvsessiondata_1.xnat_subjectassessordata19)::text)))) search_2
                          ORDER BY search_2.xnat_subjectdata3, (date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47))), search_2.xnat_xcvsessiondata_sordata__xnat_experimentdata22 DESC) map_xnat_subjectdata_xnat_demographicdata ON (((table2.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_xcvsessiondata_sordata_e_xnat_xcvsessiondata0)::text)))
                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
                            table2_1.insert_date AS xnat_demographicdata_meta_data47,
                            xnat_demographicdata_1.dob AS xnat_demographicdata1,
                            xnat_demographicdata_1.yob AS xnat_demographicdata2
                           FROM ((public.xnat_demographicdata xnat_demographicdata_1
                             LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_1.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
                             LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_1.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata ON ((map_xnat_subjectdata_xnat_demographicdata.xnat_demographicdata_demograp_xnat_demographicdata0 = xnat_demographicdata.xnat_demographicdata0)))) search_1
          ORDER BY search_1.xnat_xcvsessiondata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_xcvsessiondata0
           FROM ( SELECT table2.id AS xnat_xcvsessiondata0,
                    table2.date AS xnat_experimentdata22
                   FROM (((public.xnat_xcvsessiondata xnat_xcvsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_xcvsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))) where_clause_1) where_clause ON (((where_clause.xnat_xcvsessiondata0)::text = (search.xnat_xcvsessiondata0)::text)))
  ORDER BY search.xnat_subjectassessordata19;


ALTER TABLE public.displayfields_xnat_xcvsessiondata OWNER TO xnat;

--
-- Name: hibernate_sequence; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.hibernate_sequence
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.hibernate_sequence OWNER TO xnat;


--
-- Name: img_assessor_in_resource; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.img_assessor_in_resource (
    xnat_imageassessordata_id character varying NOT NULL,
    xnat_abstractresource_xnat_abstractresource_id integer NOT NULL,
    img_assessor_in_resource_id integer NOT NULL
);


ALTER TABLE public.img_assessor_in_resource OWNER TO xnat;


--
-- Name: img_assessor_in_resource_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.img_assessor_in_resource_history (
    xnat_imageassessordata_id character varying,
    xnat_abstractresource_xnat_abstractresource_id integer,
    img_assessor_in_resource_id integer,
    history_id integer NOT NULL
);


ALTER TABLE public.img_assessor_in_resource_history OWNER TO xnat;

--
-- Name: img_assessor_in_resource_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.img_assessor_in_resource_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.img_assessor_in_resource_history_history_id_seq OWNER TO xnat;

--
-- Name: img_assessor_in_resource_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.img_assessor_in_resource_history_history_id_seq OWNED BY public.img_assessor_in_resource_history.history_id;


--
-- Name: img_assessor_in_resource_img_assessor_in_resource_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.img_assessor_in_resource_img_assessor_in_resource_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.img_assessor_in_resource_img_assessor_in_resource_id_seq OWNER TO xnat;

--
-- Name: img_assessor_in_resource_img_assessor_in_resource_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.img_assessor_in_resource_img_assessor_in_resource_id_seq OWNED BY public.img_assessor_in_resource.img_assessor_in_resource_id;



--
-- Name: img_assessor_out_resource; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.img_assessor_out_resource (
    xnat_imageassessordata_id character varying NOT NULL,
    xnat_abstractresource_xnat_abstractresource_id integer NOT NULL,
    img_assessor_out_resource_id integer NOT NULL
);


ALTER TABLE public.img_assessor_out_resource OWNER TO xnat;


--
-- Name: img_assessor_out_resource_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.img_assessor_out_resource_history (
    xnat_imageassessordata_id character varying,
    xnat_abstractresource_xnat_abstractresource_id integer,
    img_assessor_out_resource_id integer,
    history_id integer NOT NULL
);


ALTER TABLE public.img_assessor_out_resource_history OWNER TO xnat;

--
-- Name: img_assessor_out_resource_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.img_assessor_out_resource_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.img_assessor_out_resource_history_history_id_seq OWNER TO xnat;

--
-- Name: img_assessor_out_resource_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.img_assessor_out_resource_history_history_id_seq OWNED BY public.img_assessor_out_resource_history.history_id;


--
-- Name: img_assessor_out_resource_img_assessor_out_resource_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.img_assessor_out_resource_img_assessor_out_resource_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.img_assessor_out_resource_img_assessor_out_resource_id_seq OWNER TO xnat;

--
-- Name: img_assessor_out_resource_img_assessor_out_resource_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.img_assessor_out_resource_img_assessor_out_resource_id_seq OWNED BY public.img_assessor_out_resource.img_assessor_out_resource_id;


--
-- Name: pipe_pipelinedetails; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.pipe_pipelinedetails (
    path character varying(255) DEFAULT ''::character varying NOT NULL,
    description text,
    customwebpage character varying(255),
    appliesto character varying(255) DEFAULT ''::character varying NOT NULL,
    pipelinedetails_info integer,
    pipe_pipelinerepository_pipe_pipelinerepository_id integer
);


ALTER TABLE public.pipe_pipelinedetails OWNER TO xnat;

--
-- Name: pipe_pipelinedetails_element; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.pipe_pipelinedetails_element (
    element character varying(255),
    pipelinedetails_element_info integer,
    pipe_pipelinedetails_element_id integer NOT NULL,
    generateselements_element_pipe__path character varying(255)
);


ALTER TABLE public.pipe_pipelinedetails_element OWNER TO xnat;

--
-- Name: pipe_pipelinedetails_element_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.pipe_pipelinedetails_element_history (
    change_user integer,
    generateselements_element_pipe__path character varying(255),
    previous_change_date timestamp without time zone,
    pipelinedetails_element_info integer,
    element character varying(255),
    history_id integer NOT NULL,
    pipe_pipelinedetails_element_id integer,
    xft_version integer,
    change_date timestamp without time zone,
    new_row_pipe_pipelinedetails_element_id integer
);


ALTER TABLE public.pipe_pipelinedetails_element_history OWNER TO xnat;

--
-- Name: pipe_pipelinedetails_element_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.pipe_pipelinedetails_element_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.pipe_pipelinedetails_element_history_history_id_seq OWNER TO xnat;

--
-- Name: pipe_pipelinedetails_element_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.pipe_pipelinedetails_element_history_history_id_seq OWNED BY public.pipe_pipelinedetails_element_history.history_id;


--
-- Name: pipe_pipelinedetails_element_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.pipe_pipelinedetails_element_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.pipe_pipelinedetails_element_meta_data OWNER TO xnat;

--
-- Name: pipe_pipelinedetails_element_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.pipe_pipelinedetails_element_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.pipe_pipelinedetails_element_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: pipe_pipelinedetails_element_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.pipe_pipelinedetails_element_meta_data_meta_data_id_seq OWNED BY public.pipe_pipelinedetails_element_meta_data.meta_data_id;


--
-- Name: pipe_pipelinedetails_element_pipe_pipelinedetails_element_i_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.pipe_pipelinedetails_element_pipe_pipelinedetails_element_i_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.pipe_pipelinedetails_element_pipe_pipelinedetails_element_i_seq OWNER TO xnat;

--
-- Name: pipe_pipelinedetails_element_pipe_pipelinedetails_element_i_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.pipe_pipelinedetails_element_pipe_pipelinedetails_element_i_seq OWNED BY public.pipe_pipelinedetails_element.pipe_pipelinedetails_element_id;


--
-- Name: pipe_pipelinedetails_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.pipe_pipelinedetails_history (
    change_user integer,
    pipelinedetails_info integer,
    customwebpage character varying(255),
    appliesto character varying(255),
    previous_change_date timestamp without time zone,
    pipe_pipelinerepository_pipe_pipelinerepository_id integer,
    history_id integer NOT NULL,
    description text,
    xft_version integer,
    change_date timestamp without time zone,
    path character varying(255),
    new_row_path character varying(255)
);


ALTER TABLE public.pipe_pipelinedetails_history OWNER TO xnat;

--
-- Name: pipe_pipelinedetails_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.pipe_pipelinedetails_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.pipe_pipelinedetails_history_history_id_seq OWNER TO xnat;

--
-- Name: pipe_pipelinedetails_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.pipe_pipelinedetails_history_history_id_seq OWNED BY public.pipe_pipelinedetails_history.history_id;


--
-- Name: pipe_pipelinedetails_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.pipe_pipelinedetails_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.pipe_pipelinedetails_meta_data OWNER TO xnat;

--
-- Name: pipe_pipelinedetails_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.pipe_pipelinedetails_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.pipe_pipelinedetails_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: pipe_pipelinedetails_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.pipe_pipelinedetails_meta_data_meta_data_id_seq OWNED BY public.pipe_pipelinedetails_meta_data.meta_data_id;


--
-- Name: pipe_pipelinedetails_parameter; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.pipe_pipelinedetails_parameter (
    name character varying(255),
    values_schemalink character varying(255),
    values_csvvalues character varying(255),
    description text,
    pipelinedetails_parameter_info integer,
    pipe_pipelinedetails_parameter_id integer NOT NULL,
    parameters_parameter_pipe_pipel_path character varying(255)
);


ALTER TABLE public.pipe_pipelinedetails_parameter OWNER TO xnat;

--
-- Name: pipe_pipelinedetails_paramete_pipe_pipelinedetails_paramete_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.pipe_pipelinedetails_paramete_pipe_pipelinedetails_paramete_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.pipe_pipelinedetails_paramete_pipe_pipelinedetails_paramete_seq OWNER TO xnat;

--
-- Name: pipe_pipelinedetails_paramete_pipe_pipelinedetails_paramete_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.pipe_pipelinedetails_paramete_pipe_pipelinedetails_paramete_seq OWNED BY public.pipe_pipelinedetails_parameter.pipe_pipelinedetails_parameter_id;


--
-- Name: pipe_pipelinedetails_parameter_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.pipe_pipelinedetails_parameter_history (
    pipelinedetails_parameter_info integer,
    change_user integer,
    name character varying(255),
    values_schemalink character varying(255),
    previous_change_date timestamp without time zone,
    parameters_parameter_pipe_pipel_path character varying(255),
    pipe_pipelinedetails_parameter_id integer,
    history_id integer NOT NULL,
    description text,
    values_csvvalues character varying(255),
    xft_version integer,
    change_date timestamp without time zone,
    new_row_pipe_pipelinedetails_parameter_id integer
);


ALTER TABLE public.pipe_pipelinedetails_parameter_history OWNER TO xnat;

--
-- Name: pipe_pipelinedetails_parameter_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.pipe_pipelinedetails_parameter_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.pipe_pipelinedetails_parameter_history_history_id_seq OWNER TO xnat;

--
-- Name: pipe_pipelinedetails_parameter_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.pipe_pipelinedetails_parameter_history_history_id_seq OWNED BY public.pipe_pipelinedetails_parameter_history.history_id;


--
-- Name: pipe_pipelinedetails_parameter_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.pipe_pipelinedetails_parameter_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.pipe_pipelinedetails_parameter_meta_data OWNER TO xnat;

--
-- Name: pipe_pipelinedetails_parameter_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.pipe_pipelinedetails_parameter_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.pipe_pipelinedetails_parameter_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: pipe_pipelinedetails_parameter_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.pipe_pipelinedetails_parameter_meta_data_meta_data_id_seq OWNED BY public.pipe_pipelinedetails_parameter_meta_data.meta_data_id;


--
-- Name: pipe_pipelinerepository; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.pipe_pipelinerepository (
    pipelinerepository_info integer,
    pipe_pipelinerepository_id integer NOT NULL
);


ALTER TABLE public.pipe_pipelinerepository OWNER TO xnat;

--
-- Name: pipe_pipelinerepository_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.pipe_pipelinerepository_history (
    pipelinerepository_info integer,
    xft_version integer,
    change_user integer,
    pipe_pipelinerepository_id integer,
    change_date timestamp without time zone,
    previous_change_date timestamp without time zone,
    history_id integer NOT NULL,
    new_row_pipe_pipelinerepository_id integer
);


ALTER TABLE public.pipe_pipelinerepository_history OWNER TO xnat;

--
-- Name: pipe_pipelinerepository_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.pipe_pipelinerepository_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.pipe_pipelinerepository_history_history_id_seq OWNER TO xnat;

--
-- Name: pipe_pipelinerepository_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.pipe_pipelinerepository_history_history_id_seq OWNED BY public.pipe_pipelinerepository_history.history_id;


--
-- Name: pipe_pipelinerepository_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.pipe_pipelinerepository_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.pipe_pipelinerepository_meta_data OWNER TO xnat;

--
-- Name: pipe_pipelinerepository_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.pipe_pipelinerepository_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.pipe_pipelinerepository_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: pipe_pipelinerepository_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.pipe_pipelinerepository_meta_data_meta_data_id_seq OWNED BY public.pipe_pipelinerepository_meta_data.meta_data_id;


--
-- Name: pipe_pipelinerepository_pipe_pipelinerepository_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.pipe_pipelinerepository_pipe_pipelinerepository_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.pipe_pipelinerepository_pipe_pipelinerepository_id_seq OWNER TO xnat;

--
-- Name: pipe_pipelinerepository_pipe_pipelinerepository_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.pipe_pipelinerepository_pipe_pipelinerepository_id_seq OWNED BY public.pipe_pipelinerepository.pipe_pipelinerepository_id;


--
-- Name: proj_expt_counts; Type: VIEW; Schema: public; Owner: xnat
--

CREATE VIEW public.proj_expt_counts AS
 SELECT "grouping".project,
    "grouping".element_name,
    count("grouping".id) AS proj_expt_count
   FROM ( SELECT expt.project,
            expt.id,
            xme.element_name
           FROM (public.xnat_experimentdata expt
             LEFT JOIN public.xdat_meta_element xme ON ((expt.extension = xme.xdat_meta_element_id)))
        UNION
         SELECT ep.project,
            ep.label,
            xme.element_name
           FROM ((public.xnat_experimentdata_share ep
             LEFT JOIN public.xnat_experimentdata expt ON (((ep.sharing_share_xnat_experimentda_id)::text = (expt.id)::text)))
             LEFT JOIN public.xdat_meta_element xme ON ((expt.extension = xme.xdat_meta_element_id)))) "grouping"
  GROUP BY "grouping".project, "grouping".element_name;


ALTER TABLE public.proj_expt_counts OWNER TO xnat;

--
-- Name: prov_process_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.prov_process_history (
    xft_version integer,
    change_user integer,
    change_date timestamp without time zone,
    previous_change_date timestamp without time zone,
    history_id integer NOT NULL,
    process_info integer,
    prov_process_id integer,
    new_row_prov_process_id integer
);


ALTER TABLE public.prov_process_history OWNER TO xnat;

--
-- Name: prov_process_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.prov_process_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.prov_process_history_history_id_seq OWNER TO xnat;

--
-- Name: prov_process_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.prov_process_history_history_id_seq OWNED BY public.prov_process_history.history_id;


--
-- Name: prov_process_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.prov_process_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.prov_process_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: prov_process_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.prov_process_meta_data_meta_data_id_seq OWNED BY public.prov_process_meta_data.meta_data_id;


--
-- Name: prov_process_prov_process_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.prov_process_prov_process_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.prov_process_prov_process_id_seq OWNER TO xnat;

--
-- Name: prov_process_prov_process_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.prov_process_prov_process_id_seq OWNED BY public.prov_process.prov_process_id;


--
-- Name: prov_processstep; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.prov_processstep (
    program text,
    program_version character varying(255),
    program_arguments text,
    "timestamp" timestamp without time zone DEFAULT now() NOT NULL,
    cvs text,
    user_name character varying(255),
    machine character varying(255),
    platform character varying(255),
    platform_version character varying(255),
    compiler character varying(255),
    compiler_version character varying(255),
    processstep_info integer,
    prov_processstep_id integer NOT NULL,
    prov_process_prov_process_id integer
);


ALTER TABLE public.prov_processstep OWNER TO xnat;

--
-- Name: prov_processstep_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.prov_processstep_history (
    "timestamp" timestamp without time zone,
    machine character varying(255),
    program_version character varying(255),
    user_name character varying(255),
    program text,
    compiler_version character varying(255),
    change_date timestamp without time zone,
    program_arguments text,
    cvs text,
    change_user integer,
    xft_version integer,
    compiler character varying(255),
    history_id integer NOT NULL,
    processstep_info integer,
    prov_process_prov_process_id integer,
    previous_change_date timestamp without time zone,
    prov_processstep_id integer,
    platform_version character varying(255),
    platform character varying(255),
    new_row_prov_processstep_id integer
);


ALTER TABLE public.prov_processstep_history OWNER TO xnat;

--
-- Name: prov_processstep_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.prov_processstep_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.prov_processstep_history_history_id_seq OWNER TO xnat;

--
-- Name: prov_processstep_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.prov_processstep_history_history_id_seq OWNED BY public.prov_processstep_history.history_id;


--
-- Name: prov_processstep_library; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.prov_processstep_library (
    library character varying(255),
    version character varying(255),
    processstep_library_info integer,
    prov_processstep_library_id integer NOT NULL,
    prov_processstep_prov_processstep_id integer
);


ALTER TABLE public.prov_processstep_library OWNER TO xnat;

--
-- Name: prov_processstep_library_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.prov_processstep_library_history (
    processstep_library_info integer,
    change_user integer,
    prov_processstep_library_id integer,
    previous_change_date timestamp without time zone,
    prov_processstep_prov_processstep_id integer,
    version character varying(255),
    history_id integer NOT NULL,
    library character varying(255),
    xft_version integer,
    change_date timestamp without time zone,
    new_row_prov_processstep_library_id integer
);


ALTER TABLE public.prov_processstep_library_history OWNER TO xnat;

--
-- Name: prov_processstep_library_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.prov_processstep_library_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.prov_processstep_library_history_history_id_seq OWNER TO xnat;

--
-- Name: prov_processstep_library_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.prov_processstep_library_history_history_id_seq OWNED BY public.prov_processstep_library_history.history_id;


--
-- Name: prov_processstep_library_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.prov_processstep_library_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.prov_processstep_library_meta_data OWNER TO xnat;

--
-- Name: prov_processstep_library_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.prov_processstep_library_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.prov_processstep_library_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: prov_processstep_library_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.prov_processstep_library_meta_data_meta_data_id_seq OWNED BY public.prov_processstep_library_meta_data.meta_data_id;


--
-- Name: prov_processstep_library_prov_processstep_library_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.prov_processstep_library_prov_processstep_library_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.prov_processstep_library_prov_processstep_library_id_seq OWNER TO xnat;

--
-- Name: prov_processstep_library_prov_processstep_library_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.prov_processstep_library_prov_processstep_library_id_seq OWNED BY public.prov_processstep_library.prov_processstep_library_id;


--
-- Name: prov_processstep_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.prov_processstep_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.prov_processstep_meta_data OWNER TO xnat;

--
-- Name: prov_processstep_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.prov_processstep_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.prov_processstep_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: prov_processstep_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.prov_processstep_meta_data_meta_data_id_seq OWNED BY public.prov_processstep_meta_data.meta_data_id;


--
-- Name: prov_processstep_prov_processstep_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.prov_processstep_prov_processstep_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.prov_processstep_prov_processstep_id_seq OWNER TO xnat;

--
-- Name: prov_processstep_prov_processstep_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.prov_processstep_prov_processstep_id_seq OWNED BY public.prov_processstep.prov_processstep_id;



--
-- Name: recon_in_resource; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.recon_in_resource (
    xnat_reconstructedimagedata_xnat_reconstructedimagedata_id integer NOT NULL,
    xnat_abstractresource_xnat_abstractresource_id integer NOT NULL,
    recon_in_resource_id integer NOT NULL
);


ALTER TABLE public.recon_in_resource OWNER TO xnat;


--
-- Name: recon_in_resource_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.recon_in_resource_history (
    xnat_reconstructedimagedata_xnat_reconstructedimagedata_id integer,
    xnat_abstractresource_xnat_abstractresource_id integer,
    recon_in_resource_id integer,
    history_id integer NOT NULL
);


ALTER TABLE public.recon_in_resource_history OWNER TO xnat;

--
-- Name: recon_in_resource_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.recon_in_resource_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.recon_in_resource_history_history_id_seq OWNER TO xnat;

--
-- Name: recon_in_resource_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.recon_in_resource_history_history_id_seq OWNED BY public.recon_in_resource_history.history_id;


--
-- Name: recon_in_resource_recon_in_resource_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.recon_in_resource_recon_in_resource_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.recon_in_resource_recon_in_resource_id_seq OWNER TO xnat;

--
-- Name: recon_in_resource_recon_in_resource_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.recon_in_resource_recon_in_resource_id_seq OWNED BY public.recon_in_resource.recon_in_resource_id;



--
-- Name: recon_out_resource; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.recon_out_resource (
    xnat_reconstructedimagedata_xnat_reconstructedimagedata_id integer NOT NULL,
    xnat_abstractresource_xnat_abstractresource_id integer NOT NULL,
    recon_out_resource_id integer NOT NULL
);


ALTER TABLE public.recon_out_resource OWNER TO xnat;


--
-- Name: recon_out_resource_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.recon_out_resource_history (
    xnat_reconstructedimagedata_xnat_reconstructedimagedata_id integer,
    xnat_abstractresource_xnat_abstractresource_id integer,
    recon_out_resource_id integer,
    history_id integer NOT NULL
);


ALTER TABLE public.recon_out_resource_history OWNER TO xnat;

--
-- Name: recon_out_resource_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.recon_out_resource_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.recon_out_resource_history_history_id_seq OWNER TO xnat;

--
-- Name: recon_out_resource_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.recon_out_resource_history_history_id_seq OWNED BY public.recon_out_resource_history.history_id;


--
-- Name: recon_out_resource_recon_out_resource_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.recon_out_resource_recon_out_resource_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.recon_out_resource_recon_out_resource_id_seq OWNER TO xnat;

--
-- Name: recon_out_resource_recon_out_resource_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.recon_out_resource_recon_out_resource_id_seq OWNED BY public.recon_out_resource.recon_out_resource_id;


--
-- Name: scr_screeningassessment_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.scr_screeningassessment_history (
    change_user integer,
    screeningassessment_info integer,
    id character varying(255),
    previous_change_date timestamp without time zone,
    comments text,
    history_id integer NOT NULL,
    pass character varying(255),
    rater character varying(255),
    xft_version integer,
    change_date timestamp without time zone,
    new_row_id character varying(255)
);


ALTER TABLE public.scr_screeningassessment_history OWNER TO xnat;

--
-- Name: scr_screeningassessment_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.scr_screeningassessment_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.scr_screeningassessment_history_history_id_seq OWNER TO xnat;

--
-- Name: scr_screeningassessment_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.scr_screeningassessment_history_history_id_seq OWNED BY public.scr_screeningassessment_history.history_id;


--
-- Name: scr_screeningassessment_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.scr_screeningassessment_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.scr_screeningassessment_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: scr_screeningassessment_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.scr_screeningassessment_meta_data_meta_data_id_seq OWNED BY public.scr_screeningassessment_meta_data.meta_data_id;


--
-- Name: scr_screeningscandata; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.scr_screeningscandata (
    imagescan_id character varying(255),
    comments text,
    pass character varying(255),
    screeningscandata_info integer,
    scr_screeningscandata_id integer NOT NULL,
    scans_scan_scr_screeningassessm_id character varying(255)
);


ALTER TABLE public.scr_screeningscandata OWNER TO xnat;

--
-- Name: scr_screeningscandata_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.scr_screeningscandata_history (
    change_user integer,
    imagescan_id character varying(255),
    previous_change_date timestamp without time zone,
    comments text,
    scans_scan_scr_screeningassessm_id character varying(255),
    history_id integer NOT NULL,
    scr_screeningscandata_id integer,
    pass character varying(255),
    xft_version integer,
    screeningscandata_info integer,
    change_date timestamp without time zone,
    new_row_scr_screeningscandata_id integer
);


ALTER TABLE public.scr_screeningscandata_history OWNER TO xnat;

--
-- Name: scr_screeningscandata_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.scr_screeningscandata_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.scr_screeningscandata_history_history_id_seq OWNER TO xnat;

--
-- Name: scr_screeningscandata_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.scr_screeningscandata_history_history_id_seq OWNED BY public.scr_screeningscandata_history.history_id;


--
-- Name: scr_screeningscandata_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.scr_screeningscandata_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.scr_screeningscandata_meta_data OWNER TO xnat;

--
-- Name: scr_screeningscandata_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.scr_screeningscandata_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.scr_screeningscandata_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: scr_screeningscandata_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.scr_screeningscandata_meta_data_meta_data_id_seq OWNED BY public.scr_screeningscandata_meta_data.meta_data_id;


--
-- Name: scr_screeningscandata_scr_screeningscandata_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.scr_screeningscandata_scr_screeningscandata_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.scr_screeningscandata_scr_screeningscandata_id_seq OWNER TO xnat;

--
-- Name: scr_screeningscandata_scr_screeningscandata_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.scr_screeningscandata_scr_screeningscandata_id_seq OWNED BY public.scr_screeningscandata.scr_screeningscandata_id;


--
-- Name: val_additionalval; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.val_additionalval (
    additionalval_info integer,
    val_additionalval_id integer NOT NULL
);


ALTER TABLE public.val_additionalval OWNER TO xnat;

--
-- Name: val_additionalval_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.val_additionalval_history (
    xft_version integer,
    additionalval_info integer,
    change_user integer,
    change_date timestamp without time zone,
    previous_change_date timestamp without time zone,
    history_id integer NOT NULL,
    val_additionalval_id integer,
    new_row_val_additionalval_id integer
);


ALTER TABLE public.val_additionalval_history OWNER TO xnat;

--
-- Name: val_additionalval_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.val_additionalval_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.val_additionalval_history_history_id_seq OWNER TO xnat;

--
-- Name: val_additionalval_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.val_additionalval_history_history_id_seq OWNED BY public.val_additionalval_history.history_id;


--
-- Name: val_additionalval_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.val_additionalval_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.val_additionalval_meta_data OWNER TO xnat;

--
-- Name: val_additionalval_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.val_additionalval_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.val_additionalval_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: val_additionalval_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.val_additionalval_meta_data_meta_data_id_seq OWNED BY public.val_additionalval_meta_data.meta_data_id;


--
-- Name: val_additionalval_val_additionalval_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.val_additionalval_val_additionalval_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.val_additionalval_val_additionalval_id_seq OWNER TO xnat;

--
-- Name: val_additionalval_val_additionalval_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.val_additionalval_val_additionalval_id_seq OWNED BY public.val_additionalval.val_additionalval_id;


--
-- Name: val_protocoldata_comment; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.val_protocoldata_comment (
    comment character varying(255),
    username character varying(255),
    datetime timestamp without time zone DEFAULT now() NOT NULL,
    protocoldata_comment_info integer,
    val_protocoldata_comment_id integer NOT NULL,
    check_comments_comment_val_prot_id character varying(255)
);


ALTER TABLE public.val_protocoldata_comment OWNER TO xnat;

--
-- Name: val_protocoldata_comment_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.val_protocoldata_comment_history (
    change_user integer,
    check_comments_comment_val_prot_id character varying(255),
    previous_change_date timestamp without time zone,
    username character varying(255),
    comment character varying(255),
    val_protocoldata_comment_id integer,
    datetime timestamp without time zone,
    history_id integer NOT NULL,
    protocoldata_comment_info integer,
    xft_version integer,
    change_date timestamp without time zone,
    new_row_val_protocoldata_comment_id integer
);


ALTER TABLE public.val_protocoldata_comment_history OWNER TO xnat;

--
-- Name: val_protocoldata_comment_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.val_protocoldata_comment_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.val_protocoldata_comment_history_history_id_seq OWNER TO xnat;

--
-- Name: val_protocoldata_comment_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.val_protocoldata_comment_history_history_id_seq OWNED BY public.val_protocoldata_comment_history.history_id;


--
-- Name: val_protocoldata_comment_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.val_protocoldata_comment_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.val_protocoldata_comment_meta_data OWNER TO xnat;

--
-- Name: val_protocoldata_comment_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.val_protocoldata_comment_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.val_protocoldata_comment_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: val_protocoldata_comment_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.val_protocoldata_comment_meta_data_meta_data_id_seq OWNED BY public.val_protocoldata_comment_meta_data.meta_data_id;


--
-- Name: val_protocoldata_comment_val_protocoldata_comment_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.val_protocoldata_comment_val_protocoldata_comment_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.val_protocoldata_comment_val_protocoldata_comment_id_seq OWNER TO xnat;

--
-- Name: val_protocoldata_comment_val_protocoldata_comment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.val_protocoldata_comment_val_protocoldata_comment_id_seq OWNED BY public.val_protocoldata_comment.val_protocoldata_comment_id;


--
-- Name: val_protocoldata_condition; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.val_protocoldata_condition (
    verified text,
    diagnosis text,
    id character varying(255),
    status character varying(255),
    xmlpath character varying(255),
    protocoldata_condition_info integer,
    val_protocoldata_condition_id integer NOT NULL,
    check_conditions_condition_val__id character varying(255)
);


ALTER TABLE public.val_protocoldata_condition OWNER TO xnat;

--
-- Name: val_protocoldata_condition_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.val_protocoldata_condition_history (
    change_user integer,
    id character varying(255),
    check_conditions_condition_val__id character varying(255),
    xmlpath character varying(255),
    verified text,
    previous_change_date timestamp without time zone,
    status character varying(255),
    diagnosis text,
    history_id integer NOT NULL,
    protocoldata_condition_info integer,
    xft_version integer,
    val_protocoldata_condition_id integer,
    change_date timestamp without time zone,
    new_row_val_protocoldata_condition_id integer
);


ALTER TABLE public.val_protocoldata_condition_history OWNER TO xnat;

--
-- Name: val_protocoldata_condition_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.val_protocoldata_condition_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.val_protocoldata_condition_history_history_id_seq OWNER TO xnat;

--
-- Name: val_protocoldata_condition_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.val_protocoldata_condition_history_history_id_seq OWNED BY public.val_protocoldata_condition_history.history_id;


--
-- Name: val_protocoldata_condition_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.val_protocoldata_condition_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.val_protocoldata_condition_meta_data OWNER TO xnat;

--
-- Name: val_protocoldata_condition_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.val_protocoldata_condition_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.val_protocoldata_condition_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: val_protocoldata_condition_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.val_protocoldata_condition_meta_data_meta_data_id_seq OWNED BY public.val_protocoldata_condition_meta_data.meta_data_id;


--
-- Name: val_protocoldata_condition_val_protocoldata_condition_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.val_protocoldata_condition_val_protocoldata_condition_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.val_protocoldata_condition_val_protocoldata_condition_id_seq OWNER TO xnat;

--
-- Name: val_protocoldata_condition_val_protocoldata_condition_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.val_protocoldata_condition_val_protocoldata_condition_id_seq OWNED BY public.val_protocoldata_condition.val_protocoldata_condition_id;


--
-- Name: val_protocoldata_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.val_protocoldata_history (
    change_user integer,
    id character varying(255),
    protocoldata_info integer,
    previous_change_date timestamp without time zone,
    check_status character varying(255),
    history_id integer NOT NULL,
    check_additionalval_val_additionalval_id integer,
    xft_version integer,
    change_date timestamp without time zone,
    new_row_id character varying(255)
);


ALTER TABLE public.val_protocoldata_history OWNER TO xnat;

--
-- Name: val_protocoldata_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.val_protocoldata_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.val_protocoldata_history_history_id_seq OWNER TO xnat;

--
-- Name: val_protocoldata_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.val_protocoldata_history_history_id_seq OWNED BY public.val_protocoldata_history.history_id;


--
-- Name: val_protocoldata_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.val_protocoldata_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.val_protocoldata_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: val_protocoldata_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.val_protocoldata_meta_data_meta_data_id_seq OWNED BY public.val_protocoldata_meta_data.meta_data_id;


--
-- Name: val_protocoldata_scan_check; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.val_protocoldata_scan_check (
    additionalval_val_additionalval_id integer,
    scan_id character varying(255) DEFAULT ''::character varying NOT NULL,
    status character varying(255) DEFAULT ''::character varying NOT NULL,
    protocoldata_scan_check_info integer,
    val_protocoldata_scan_check_id integer NOT NULL,
    scans_scan_check_val_protocolda_id character varying(255)
);


ALTER TABLE public.val_protocoldata_scan_check OWNER TO xnat;

--
-- Name: val_protocoldata_scan_check_condition; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.val_protocoldata_scan_check_condition (
    verified text,
    diagnosis text,
    id character varying(255),
    status character varying(255),
    xmlpath character varying(255),
    protocoldata_scan_check_condition_info integer,
    val_protocoldata_scan_check_condition_id integer NOT NULL,
    conditions_condition_val_protoc_val_protocoldata_scan_check_id integer
);


ALTER TABLE public.val_protocoldata_scan_check_condition OWNER TO xnat;

--
-- Name: val_protocoldata_scan_check_c_val_protocoldata_scan_check__seq1; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.val_protocoldata_scan_check_c_val_protocoldata_scan_check__seq1
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.val_protocoldata_scan_check_c_val_protocoldata_scan_check__seq1 OWNER TO xnat;

--
-- Name: val_protocoldata_scan_check_c_val_protocoldata_scan_check__seq1; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.val_protocoldata_scan_check_c_val_protocoldata_scan_check__seq1 OWNED BY public.val_protocoldata_scan_check_condition.val_protocoldata_scan_check_condition_id;


--
-- Name: val_protocoldata_scan_check_comment; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.val_protocoldata_scan_check_comment (
    comment character varying(255),
    username character varying(255),
    datetime timestamp without time zone DEFAULT now() NOT NULL,
    protocoldata_scan_check_comment_info integer,
    val_protocoldata_scan_check_comment_id integer NOT NULL,
    comments_comment_val_protocolda_val_protocoldata_scan_check_id integer
);


ALTER TABLE public.val_protocoldata_scan_check_comment OWNER TO xnat;

--
-- Name: val_protocoldata_scan_check_c_val_protocoldata_scan_check_c_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.val_protocoldata_scan_check_c_val_protocoldata_scan_check_c_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.val_protocoldata_scan_check_c_val_protocoldata_scan_check_c_seq OWNER TO xnat;

--
-- Name: val_protocoldata_scan_check_c_val_protocoldata_scan_check_c_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.val_protocoldata_scan_check_c_val_protocoldata_scan_check_c_seq OWNED BY public.val_protocoldata_scan_check_comment.val_protocoldata_scan_check_comment_id;


--
-- Name: val_protocoldata_scan_check_comment_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.val_protocoldata_scan_check_comment_history (
    change_user integer,
    previous_change_date timestamp without time zone,
    val_protocoldata_scan_check_comment_id integer,
    username character varying(255),
    comment character varying(255),
    datetime timestamp without time zone,
    history_id integer NOT NULL,
    xft_version integer,
    comments_comment_val_protocolda_val_protocoldata_scan_check_id integer,
    protocoldata_scan_check_comment_info integer,
    change_date timestamp without time zone,
    new_row_val_protocoldata_scan_check_comment_id integer
);


ALTER TABLE public.val_protocoldata_scan_check_comment_history OWNER TO xnat;

--
-- Name: val_protocoldata_scan_check_comment_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.val_protocoldata_scan_check_comment_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.val_protocoldata_scan_check_comment_history_history_id_seq OWNER TO xnat;

--
-- Name: val_protocoldata_scan_check_comment_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.val_protocoldata_scan_check_comment_history_history_id_seq OWNED BY public.val_protocoldata_scan_check_comment_history.history_id;


--
-- Name: val_protocoldata_scan_check_comment_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.val_protocoldata_scan_check_comment_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.val_protocoldata_scan_check_comment_meta_data OWNER TO xnat;

--
-- Name: val_protocoldata_scan_check_comment_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.val_protocoldata_scan_check_comment_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.val_protocoldata_scan_check_comment_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: val_protocoldata_scan_check_comment_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.val_protocoldata_scan_check_comment_meta_data_meta_data_id_seq OWNED BY public.val_protocoldata_scan_check_comment_meta_data.meta_data_id;


--
-- Name: val_protocoldata_scan_check_condition_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.val_protocoldata_scan_check_condition_history (
    change_user integer,
    conditions_condition_val_protoc_val_protocoldata_scan_check_id integer,
    protocoldata_scan_check_condition_info integer,
    id character varying(255),
    xmlpath character varying(255),
    verified text,
    previous_change_date timestamp without time zone,
    status character varying(255),
    val_protocoldata_scan_check_condition_id integer,
    diagnosis text,
    history_id integer NOT NULL,
    xft_version integer,
    change_date timestamp without time zone,
    new_row_val_protocoldata_scan_check_condition_id integer
);


ALTER TABLE public.val_protocoldata_scan_check_condition_history OWNER TO xnat;

--
-- Name: val_protocoldata_scan_check_condition_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.val_protocoldata_scan_check_condition_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.val_protocoldata_scan_check_condition_history_history_id_seq OWNER TO xnat;

--
-- Name: val_protocoldata_scan_check_condition_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.val_protocoldata_scan_check_condition_history_history_id_seq OWNED BY public.val_protocoldata_scan_check_condition_history.history_id;


--
-- Name: val_protocoldata_scan_check_condition_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.val_protocoldata_scan_check_condition_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.val_protocoldata_scan_check_condition_meta_data OWNER TO xnat;

--
-- Name: val_protocoldata_scan_check_condition_meta_dat_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.val_protocoldata_scan_check_condition_meta_dat_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.val_protocoldata_scan_check_condition_meta_dat_meta_data_id_seq OWNER TO xnat;

--
-- Name: val_protocoldata_scan_check_condition_meta_dat_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.val_protocoldata_scan_check_condition_meta_dat_meta_data_id_seq OWNED BY public.val_protocoldata_scan_check_condition_meta_data.meta_data_id;


--
-- Name: val_protocoldata_scan_check_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.val_protocoldata_scan_check_history (
    val_protocoldata_scan_check_id integer,
    protocoldata_scan_check_info integer,
    change_user integer,
    scans_scan_check_val_protocolda_id character varying(255),
    scan_id character varying(255),
    previous_change_date timestamp without time zone,
    status character varying(255),
    additionalval_val_additionalval_id integer,
    history_id integer NOT NULL,
    xft_version integer,
    change_date timestamp without time zone,
    new_row_val_protocoldata_scan_check_id integer
);


ALTER TABLE public.val_protocoldata_scan_check_history OWNER TO xnat;

--
-- Name: val_protocoldata_scan_check_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.val_protocoldata_scan_check_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.val_protocoldata_scan_check_history_history_id_seq OWNER TO xnat;

--
-- Name: val_protocoldata_scan_check_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.val_protocoldata_scan_check_history_history_id_seq OWNED BY public.val_protocoldata_scan_check_history.history_id;


--
-- Name: val_protocoldata_scan_check_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.val_protocoldata_scan_check_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.val_protocoldata_scan_check_meta_data OWNER TO xnat;

--
-- Name: val_protocoldata_scan_check_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.val_protocoldata_scan_check_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.val_protocoldata_scan_check_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: val_protocoldata_scan_check_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.val_protocoldata_scan_check_meta_data_meta_data_id_seq OWNED BY public.val_protocoldata_scan_check_meta_data.meta_data_id;


--
-- Name: val_protocoldata_scan_check_val_protocoldata_scan_check_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.val_protocoldata_scan_check_val_protocoldata_scan_check_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.val_protocoldata_scan_check_val_protocoldata_scan_check_id_seq OWNER TO xnat;

--
-- Name: val_protocoldata_scan_check_val_protocoldata_scan_check_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.val_protocoldata_scan_check_val_protocoldata_scan_check_id_seq OWNED BY public.val_protocoldata_scan_check.val_protocoldata_scan_check_id;


--
-- Name: wrk_abstractexecutionenvironment; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.wrk_abstractexecutionenvironment (
    extension integer,
    abstractexecutionenvironment_info integer,
    wrk_abstractexecutionenvironment_id integer NOT NULL
);


ALTER TABLE public.wrk_abstractexecutionenvironment OWNER TO xnat;

--
-- Name: wrk_abstractexecutionenvironm_wrk_abstractexecutionenvironm_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.wrk_abstractexecutionenvironm_wrk_abstractexecutionenvironm_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.wrk_abstractexecutionenvironm_wrk_abstractexecutionenvironm_seq OWNER TO xnat;

--
-- Name: wrk_abstractexecutionenvironm_wrk_abstractexecutionenvironm_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.wrk_abstractexecutionenvironm_wrk_abstractexecutionenvironm_seq OWNED BY public.wrk_abstractexecutionenvironment.wrk_abstractexecutionenvironment_id;


--
-- Name: wrk_abstractexecutionenvironment_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.wrk_abstractexecutionenvironment_history (
    wrk_abstractexecutionenvironment_id integer,
    change_user integer,
    previous_change_date timestamp without time zone,
    abstractexecutionenvironment_info integer,
    history_id integer NOT NULL,
    change_date timestamp without time zone,
    xft_version integer,
    extension integer,
    new_row_wrk_abstractexecutionenvironment_id integer
);


ALTER TABLE public.wrk_abstractexecutionenvironment_history OWNER TO xnat;

--
-- Name: wrk_abstractexecutionenvironment_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.wrk_abstractexecutionenvironment_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.wrk_abstractexecutionenvironment_history_history_id_seq OWNER TO xnat;

--
-- Name: wrk_abstractexecutionenvironment_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.wrk_abstractexecutionenvironment_history_history_id_seq OWNED BY public.wrk_abstractexecutionenvironment_history.history_id;


--
-- Name: wrk_abstractexecutionenvironment_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.wrk_abstractexecutionenvironment_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.wrk_abstractexecutionenvironment_meta_data OWNER TO xnat;

--
-- Name: wrk_abstractexecutionenvironment_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.wrk_abstractexecutionenvironment_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.wrk_abstractexecutionenvironment_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: wrk_abstractexecutionenvironment_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.wrk_abstractexecutionenvironment_meta_data_meta_data_id_seq OWNED BY public.wrk_abstractexecutionenvironment_meta_data.meta_data_id;


--
-- Name: wrk_workflowdata_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.wrk_workflowdata_history (
    externalid character varying(255),
    next_step_id character varying(255),
    type character varying(255),
    data_type character varying(255),
    src character varying(255),
    comments text,
    wrk_workflowdata_id integer,
    launch_time timestamp without time zone,
    change_date timestamp without time zone,
    change_user integer,
    xft_version integer,
    id character varying(255),
    percentagecomplete character varying(255),
    history_id integer NOT NULL,
    step_description character varying(255),
    status character varying(255),
    category character varying(255),
    create_user character varying(255),
    description character varying(255),
    previous_change_date timestamp without time zone,
    jobid character varying(255),
    justification text,
    current_step_launch_time timestamp without time zone,
    details text,
    executionenvironment_wrk_abstractexecutionenvironment_id integer,
    workflowdata_info integer,
    pipeline_name character varying(255),
    current_step_id character varying(255),
    new_row_wrk_workflowdata_id integer
);


ALTER TABLE public.wrk_workflowdata_history OWNER TO xnat;

--
-- Name: wrk_workflowdata_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.wrk_workflowdata_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.wrk_workflowdata_history_history_id_seq OWNER TO xnat;

--
-- Name: wrk_workflowdata_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.wrk_workflowdata_history_history_id_seq OWNED BY public.wrk_workflowdata_history.history_id;


--
-- Name: wrk_workflowdata_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.wrk_workflowdata_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.wrk_workflowdata_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: wrk_workflowdata_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.wrk_workflowdata_meta_data_meta_data_id_seq OWNED BY public.wrk_workflowdata_meta_data.meta_data_id;


--
-- Name: wrk_workflowdata_wrk_workflowdata_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.wrk_workflowdata_wrk_workflowdata_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.wrk_workflowdata_wrk_workflowdata_id_seq OWNER TO xnat;

--
-- Name: wrk_workflowdata_wrk_workflowdata_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.wrk_workflowdata_wrk_workflowdata_id_seq OWNED BY public.wrk_workflowdata.wrk_workflowdata_id;


--
-- Name: wrk_xnatexecutionenvironment; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.wrk_xnatexecutionenvironment (
    wrk_abstractexecutionenvironment_id integer DEFAULT 0 NOT NULL,
    pipeline character varying(255),
    xnatuser character varying(255),
    host character varying(255),
    startat character varying(255),
    datatype character varying(255),
    id character varying(255),
    supressnotification integer DEFAULT 0 NOT NULL,
    log character varying(255),
    catalogpath character varying(255),
    parameterfile_xml text,
    parameterfile_path text,
    xnatexecutionenvironment_info integer
);


ALTER TABLE public.wrk_xnatexecutionenvironment OWNER TO xnat;

--
-- Name: wrk_xnatexecutionenvironment_notify; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.wrk_xnatexecutionenvironment_notify (
    notify character varying(255),
    xnatexecutionenvironment_notify_info integer,
    wrk_xnatexecutionenvironment_notify_id integer NOT NULL,
    wrk_xnatexecutionenvironment_wrk_abstractexecutionenvironmen integer
);


ALTER TABLE public.wrk_xnatexecutionenvironment_notify OWNER TO xnat;

--
-- Name: wrk_xnatexecutionenvironment__wrk_xnatexecutionenvironment__seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.wrk_xnatexecutionenvironment__wrk_xnatexecutionenvironment__seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.wrk_xnatexecutionenvironment__wrk_xnatexecutionenvironment__seq OWNER TO xnat;

--
-- Name: wrk_xnatexecutionenvironment__wrk_xnatexecutionenvironment__seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.wrk_xnatexecutionenvironment__wrk_xnatexecutionenvironment__seq OWNED BY public.wrk_xnatexecutionenvironment_notify.wrk_xnatexecutionenvironment_notify_id;


--
-- Name: wrk_xnatexecutionenvironment_parameter; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.wrk_xnatexecutionenvironment_parameter (
    parameter text,
    name character varying(255) DEFAULT ''::character varying NOT NULL,
    xnatexecutionenvironment_parameter_info integer,
    wrk_xnatexecutionenvironment_parameter_id integer NOT NULL,
    parameters_parameter_wrk_xnatex_wrk_abstractexecutionenvironmen integer
);


ALTER TABLE public.wrk_xnatexecutionenvironment_parameter OWNER TO xnat;

--
-- Name: wrk_xnatexecutionenvironment__wrk_xnatexecutionenvironment_seq1; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.wrk_xnatexecutionenvironment__wrk_xnatexecutionenvironment_seq1
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.wrk_xnatexecutionenvironment__wrk_xnatexecutionenvironment_seq1 OWNER TO xnat;

--
-- Name: wrk_xnatexecutionenvironment__wrk_xnatexecutionenvironment_seq1; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.wrk_xnatexecutionenvironment__wrk_xnatexecutionenvironment_seq1 OWNED BY public.wrk_xnatexecutionenvironment_parameter.wrk_xnatexecutionenvironment_parameter_id;


--
-- Name: wrk_xnatexecutionenvironment_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.wrk_xnatexecutionenvironment_history (
    supressnotification integer,
    parameterfile_xml text,
    log character varying(255),
    startat character varying(255),
    xnatexecutionenvironment_info integer,
    change_date timestamp without time zone,
    datatype character varying(255),
    change_user integer,
    xft_version integer,
    host character varying(255),
    id character varying(255),
    parameterfile_path text,
    history_id integer NOT NULL,
    pipeline character varying(255),
    xnatuser character varying(255),
    previous_change_date timestamp without time zone,
    catalogpath character varying(255),
    wrk_abstractexecutionenvironment_id integer,
    new_row_wrk_abstractexecutionenvironment_id integer
);


ALTER TABLE public.wrk_xnatexecutionenvironment_history OWNER TO xnat;

--
-- Name: wrk_xnatexecutionenvironment_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.wrk_xnatexecutionenvironment_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.wrk_xnatexecutionenvironment_history_history_id_seq OWNER TO xnat;

--
-- Name: wrk_xnatexecutionenvironment_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.wrk_xnatexecutionenvironment_history_history_id_seq OWNED BY public.wrk_xnatexecutionenvironment_history.history_id;


--
-- Name: wrk_xnatexecutionenvironment_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.wrk_xnatexecutionenvironment_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.wrk_xnatexecutionenvironment_meta_data OWNER TO xnat;

--
-- Name: wrk_xnatexecutionenvironment_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.wrk_xnatexecutionenvironment_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.wrk_xnatexecutionenvironment_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: wrk_xnatexecutionenvironment_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.wrk_xnatexecutionenvironment_meta_data_meta_data_id_seq OWNED BY public.wrk_xnatexecutionenvironment_meta_data.meta_data_id;


--
-- Name: wrk_xnatexecutionenvironment_notify_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.wrk_xnatexecutionenvironment_notify_history (
    change_user integer,
    xnatexecutionenvironment_notify_info integer,
    wrk_xnatexecutionenvironment_notify_id integer,
    previous_change_date timestamp without time zone,
    history_id integer NOT NULL,
    wrk_xnatexecutionenvironment_wrk_abstractexecutionenvironmen integer,
    notify character varying(255),
    xft_version integer,
    change_date timestamp without time zone,
    new_row_wrk_xnatexecutionenvironment_notify_id integer
);


ALTER TABLE public.wrk_xnatexecutionenvironment_notify_history OWNER TO xnat;

--
-- Name: wrk_xnatexecutionenvironment_notify_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.wrk_xnatexecutionenvironment_notify_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.wrk_xnatexecutionenvironment_notify_history_history_id_seq OWNER TO xnat;

--
-- Name: wrk_xnatexecutionenvironment_notify_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.wrk_xnatexecutionenvironment_notify_history_history_id_seq OWNED BY public.wrk_xnatexecutionenvironment_notify_history.history_id;


--
-- Name: wrk_xnatexecutionenvironment_notify_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.wrk_xnatexecutionenvironment_notify_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.wrk_xnatexecutionenvironment_notify_meta_data OWNER TO xnat;

--
-- Name: wrk_xnatexecutionenvironment_notify_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.wrk_xnatexecutionenvironment_notify_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.wrk_xnatexecutionenvironment_notify_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: wrk_xnatexecutionenvironment_notify_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.wrk_xnatexecutionenvironment_notify_meta_data_meta_data_id_seq OWNED BY public.wrk_xnatexecutionenvironment_notify_meta_data.meta_data_id;


--
-- Name: wrk_xnatexecutionenvironment_parameter_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.wrk_xnatexecutionenvironment_parameter_history (
    change_user integer,
    name character varying(255),
    previous_change_date timestamp without time zone,
    wrk_xnatexecutionenvironment_parameter_id integer,
    xnatexecutionenvironment_parameter_info integer,
    history_id integer NOT NULL,
    parameters_parameter_wrk_xnatex_wrk_abstractexecutionenvironmen integer,
    parameter text,
    xft_version integer,
    change_date timestamp without time zone,
    new_row_wrk_xnatexecutionenvironment_parameter_id integer
);


ALTER TABLE public.wrk_xnatexecutionenvironment_parameter_history OWNER TO xnat;

--
-- Name: wrk_xnatexecutionenvironment_parameter_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.wrk_xnatexecutionenvironment_parameter_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.wrk_xnatexecutionenvironment_parameter_history_history_id_seq OWNER TO xnat;

--
-- Name: wrk_xnatexecutionenvironment_parameter_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.wrk_xnatexecutionenvironment_parameter_history_history_id_seq OWNED BY public.wrk_xnatexecutionenvironment_parameter_history.history_id;


--
-- Name: wrk_xnatexecutionenvironment_parameter_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.wrk_xnatexecutionenvironment_parameter_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.wrk_xnatexecutionenvironment_parameter_meta_data OWNER TO xnat;

--
-- Name: wrk_xnatexecutionenvironment_parameter_meta_da_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.wrk_xnatexecutionenvironment_parameter_meta_da_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.wrk_xnatexecutionenvironment_parameter_meta_da_meta_data_id_seq OWNER TO xnat;

--
-- Name: wrk_xnatexecutionenvironment_parameter_meta_da_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.wrk_xnatexecutionenvironment_parameter_meta_da_meta_data_id_seq OWNED BY public.wrk_xnatexecutionenvironment_parameter_meta_data.meta_data_id;


--
-- Name: xdat_a_xdat_action_type_allow_xdat_a_xdat_action_type_allow_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_a_xdat_action_type_allow_xdat_a_xdat_action_type_allow_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_a_xdat_action_type_allow_xdat_a_xdat_action_type_allow_seq OWNER TO xnat;

--
-- Name: xdat_a_xdat_action_type_allow_xdat_a_xdat_action_type_allow_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_a_xdat_action_type_allow_xdat_a_xdat_action_type_allow_seq OWNED BY public.xdat_a_xdat_action_type_allowe_xdat_role_type.xdat_a_xdat_action_type_allowe_xdat_role_type_id;


--
-- Name: xdat_a_xdat_action_type_allowe_xdat_role_type_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_a_xdat_action_type_allowe_xdat_role_type_history (
    xdat_role_type_role_name character varying,
    xdat_action_type_action_name character varying,
    xdat_a_xdat_action_type_allowe_xdat_role_type_id integer,
    history_id integer NOT NULL
);


ALTER TABLE public.xdat_a_xdat_action_type_allowe_xdat_role_type_history OWNER TO xnat;

--
-- Name: xdat_a_xdat_action_type_allowe_xdat_role_type_hi_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_a_xdat_action_type_allowe_xdat_role_type_hi_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_a_xdat_action_type_allowe_xdat_role_type_hi_history_id_seq OWNER TO xnat;

--
-- Name: xdat_a_xdat_action_type_allowe_xdat_role_type_hi_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_a_xdat_action_type_allowe_xdat_role_type_hi_history_id_seq OWNED BY public.xdat_a_xdat_action_type_allowe_xdat_role_type_history.history_id;


--
-- Name: xdat_access_log; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_access_log (
    login character varying(255),
    access_date timestamp without time zone,
    ip character varying(255),
    method character varying(255),
    access_log_info integer,
    xdat_access_log_id integer NOT NULL
);


ALTER TABLE public.xdat_access_log OWNER TO xnat;

--
-- Name: xdat_access_log_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_access_log_history (
    method character varying(255),
    change_user integer,
    previous_change_date timestamp without time zone,
    ip character varying(255),
    access_date timestamp without time zone,
    history_id integer NOT NULL,
    xdat_access_log_id integer,
    login character varying(255),
    access_log_info integer,
    xft_version integer,
    change_date timestamp without time zone,
    new_row_xdat_access_log_id integer
);


ALTER TABLE public.xdat_access_log_history OWNER TO xnat;

--
-- Name: xdat_access_log_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_access_log_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_access_log_history_history_id_seq OWNER TO xnat;

--
-- Name: xdat_access_log_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_access_log_history_history_id_seq OWNED BY public.xdat_access_log_history.history_id;


--
-- Name: xdat_access_log_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_access_log_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xdat_access_log_meta_data OWNER TO xnat;

--
-- Name: xdat_access_log_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_access_log_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_access_log_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: xdat_access_log_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_access_log_meta_data_meta_data_id_seq OWNED BY public.xdat_access_log_meta_data.meta_data_id;


--
-- Name: xdat_access_log_xdat_access_log_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_access_log_xdat_access_log_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_access_log_xdat_access_log_id_seq OWNER TO xnat;

--
-- Name: xdat_access_log_xdat_access_log_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_access_log_xdat_access_log_id_seq OWNED BY public.xdat_access_log.xdat_access_log_id;


--
-- Name: xdat_action_type; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_action_type (
    action_name character varying(255) DEFAULT ''::character varying NOT NULL,
    display_name character varying(255),
    sequence integer,
    action_type_info integer,
    actions_action_xdat_security_xdat_security_id integer
);


ALTER TABLE public.xdat_action_type OWNER TO xnat;

--
-- Name: xdat_action_type_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_action_type_history (
    change_user integer,
    sequence integer,
    previous_change_date timestamp without time zone,
    action_name character varying(255),
    action_type_info integer,
    history_id integer NOT NULL,
    display_name character varying(255),
    xft_version integer,
    actions_action_xdat_security_xdat_security_id integer,
    change_date timestamp without time zone,
    new_row_action_name character varying(255)
);


ALTER TABLE public.xdat_action_type_history OWNER TO xnat;

--
-- Name: xdat_action_type_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_action_type_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_action_type_history_history_id_seq OWNER TO xnat;

--
-- Name: xdat_action_type_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_action_type_history_history_id_seq OWNED BY public.xdat_action_type_history.history_id;


--
-- Name: xdat_action_type_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_action_type_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xdat_action_type_meta_data OWNER TO xnat;

--
-- Name: xdat_action_type_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_action_type_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_action_type_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: xdat_action_type_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_action_type_meta_data_meta_data_id_seq OWNED BY public.xdat_action_type_meta_data.meta_data_id;


--
-- Name: xdat_change_info; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_change_info (
    change_user integer,
    comment character varying(255),
    change_date timestamp without time zone,
    event_id integer,
    xdat_change_info_id bigint NOT NULL,
    change_info_info integer
);


ALTER TABLE public.xdat_change_info OWNER TO xnat;

--
-- Name: xdat_change_info_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_change_info_history (
    change_user integer,
    previous_change_date timestamp without time zone,
    change_info_info integer,
    comment character varying(255),
    history_id integer NOT NULL,
    xdat_change_info_id bigint,
    event_id integer,
    xft_version integer,
    change_date timestamp without time zone,
    new_row_xdat_change_info_id bigint
);


ALTER TABLE public.xdat_change_info_history OWNER TO xnat;

--
-- Name: xdat_change_info_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_change_info_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_change_info_history_history_id_seq OWNER TO xnat;

--
-- Name: xdat_change_info_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_change_info_history_history_id_seq OWNED BY public.xdat_change_info_history.history_id;


--
-- Name: xdat_change_info_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_change_info_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xdat_change_info_meta_data OWNER TO xnat;

--
-- Name: xdat_change_info_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_change_info_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_change_info_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: xdat_change_info_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_change_info_meta_data_meta_data_id_seq OWNED BY public.xdat_change_info_meta_data.meta_data_id;


--
-- Name: xdat_change_info_xdat_change_info_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_change_info_xdat_change_info_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_change_info_xdat_change_info_id_seq OWNER TO xnat;

--
-- Name: xdat_change_info_xdat_change_info_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_change_info_xdat_change_info_id_seq OWNED BY public.xdat_change_info.xdat_change_info_id;


--
-- Name: xdat_criteria; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_criteria (
    schema_field character varying(255),
    comparison_type character varying(255),
    custom_search character varying(255),
    value character varying(255),
    override_value_formatting integer,
    criteria_info integer,
    xdat_criteria_id integer NOT NULL,
    xdat_criteria_set_xdat_criteria_set_id integer
);


ALTER TABLE public.xdat_criteria OWNER TO xnat;

--
-- Name: xdat_criteria_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_criteria_history (
    change_user integer,
    override_value_formatting integer,
    schema_field character varying(255),
    comparison_type character varying(255),
    previous_change_date timestamp without time zone,
    xdat_criteria_set_xdat_criteria_set_id integer,
    history_id integer NOT NULL,
    value character varying(255),
    criteria_info integer,
    xft_version integer,
    xdat_criteria_id integer,
    custom_search character varying(255),
    change_date timestamp without time zone,
    new_row_xdat_criteria_id integer
);


ALTER TABLE public.xdat_criteria_history OWNER TO xnat;

--
-- Name: xdat_criteria_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_criteria_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_criteria_history_history_id_seq OWNER TO xnat;

--
-- Name: xdat_criteria_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_criteria_history_history_id_seq OWNED BY public.xdat_criteria_history.history_id;


--
-- Name: xdat_criteria_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_criteria_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xdat_criteria_meta_data OWNER TO xnat;

--
-- Name: xdat_criteria_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_criteria_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_criteria_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: xdat_criteria_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_criteria_meta_data_meta_data_id_seq OWNED BY public.xdat_criteria_meta_data.meta_data_id;


--
-- Name: xdat_criteria_set; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_criteria_set (
    child_set_xdat_criteria_set_id integer,
    method character varying(255) DEFAULT ''::character varying NOT NULL,
    criteria_set_info integer,
    xdat_criteria_set_id integer NOT NULL,
    xdat_stored_search_id character varying(255)
);


ALTER TABLE public.xdat_criteria_set OWNER TO xnat;

--
-- Name: xdat_criteria_set_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_criteria_set_history (
    method character varying(255),
    xdat_stored_search_id character varying(255),
    change_user integer,
    previous_change_date timestamp without time zone,
    xdat_criteria_set_id integer,
    criteria_set_info integer,
    history_id integer NOT NULL,
    xft_version integer,
    change_date timestamp without time zone,
    new_row_xdat_criteria_set_id integer
);


ALTER TABLE public.xdat_criteria_set_history OWNER TO xnat;

--
-- Name: xdat_criteria_set_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_criteria_set_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_criteria_set_history_history_id_seq OWNER TO xnat;

--
-- Name: xdat_criteria_set_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_criteria_set_history_history_id_seq OWNED BY public.xdat_criteria_set_history.history_id;


--
-- Name: xdat_criteria_set_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_criteria_set_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xdat_criteria_set_meta_data OWNER TO xnat;

--
-- Name: xdat_criteria_set_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_criteria_set_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_criteria_set_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: xdat_criteria_set_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_criteria_set_meta_data_meta_data_id_seq OWNED BY public.xdat_criteria_set_meta_data.meta_data_id;


--
-- Name: xdat_criteria_set_xdat_criteria_set_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_criteria_set_xdat_criteria_set_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_criteria_set_xdat_criteria_set_id_seq OWNER TO xnat;

--
-- Name: xdat_criteria_set_xdat_criteria_set_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_criteria_set_xdat_criteria_set_id_seq OWNED BY public.xdat_criteria_set.xdat_criteria_set_id;


--
-- Name: xdat_criteria_xdat_criteria_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_criteria_xdat_criteria_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_criteria_xdat_criteria_id_seq OWNER TO xnat;

--
-- Name: xdat_criteria_xdat_criteria_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_criteria_xdat_criteria_id_seq OWNED BY public.xdat_criteria.xdat_criteria_id;


--
-- Name: xdat_element_access_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_element_access_history (
    secondary_password_encrypt integer,
    change_user integer,
    secondary_password character varying(255),
    previous_change_date timestamp without time zone,
    element_access_info integer,
    xdat_usergroup_xdat_usergroup_id integer,
    xdat_user_xdat_user_id integer,
    element_name character varying(255),
    history_id integer NOT NULL,
    xdat_element_access_id integer,
    xft_version integer,
    change_date timestamp without time zone,
    new_row_xdat_element_access_id integer
);


ALTER TABLE public.xdat_element_access_history OWNER TO xnat;

--
-- Name: xdat_element_access_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_element_access_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_element_access_history_history_id_seq OWNER TO xnat;

--
-- Name: xdat_element_access_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_element_access_history_history_id_seq OWNED BY public.xdat_element_access_history.history_id;


--
-- Name: xdat_element_access_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_element_access_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xdat_element_access_meta_data OWNER TO xnat;

--
-- Name: xdat_element_access_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_element_access_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_element_access_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: xdat_element_access_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_element_access_meta_data_meta_data_id_seq OWNED BY public.xdat_element_access_meta_data.meta_data_id;


--
-- Name: xdat_element_access_secure_ip; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_element_access_secure_ip (
    secure_ip character varying(255),
    element_access_secure_ip_info integer,
    xdat_element_access_secure_ip_id integer NOT NULL,
    xdat_element_access_xdat_element_access_id integer
);


ALTER TABLE public.xdat_element_access_secure_ip OWNER TO xnat;

--
-- Name: xdat_element_access_secure_ip_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_element_access_secure_ip_history (
    change_user integer,
    secure_ip character varying(255),
    xdat_element_access_xdat_element_access_id integer,
    previous_change_date timestamp without time zone,
    element_access_secure_ip_info integer,
    history_id integer NOT NULL,
    xdat_element_access_secure_ip_id integer,
    xft_version integer,
    change_date timestamp without time zone,
    new_row_xdat_element_access_secure_ip_id integer
);


ALTER TABLE public.xdat_element_access_secure_ip_history OWNER TO xnat;

--
-- Name: xdat_element_access_secure_ip_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_element_access_secure_ip_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_element_access_secure_ip_history_history_id_seq OWNER TO xnat;

--
-- Name: xdat_element_access_secure_ip_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_element_access_secure_ip_history_history_id_seq OWNED BY public.xdat_element_access_secure_ip_history.history_id;


--
-- Name: xdat_element_access_secure_ip_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_element_access_secure_ip_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xdat_element_access_secure_ip_meta_data OWNER TO xnat;

--
-- Name: xdat_element_access_secure_ip_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_element_access_secure_ip_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_element_access_secure_ip_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: xdat_element_access_secure_ip_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_element_access_secure_ip_meta_data_meta_data_id_seq OWNED BY public.xdat_element_access_secure_ip_meta_data.meta_data_id;


--
-- Name: xdat_element_access_secure_ip_xdat_element_access_secure_ip_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_element_access_secure_ip_xdat_element_access_secure_ip_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_element_access_secure_ip_xdat_element_access_secure_ip_seq OWNER TO xnat;

--
-- Name: xdat_element_access_secure_ip_xdat_element_access_secure_ip_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_element_access_secure_ip_xdat_element_access_secure_ip_seq OWNED BY public.xdat_element_access_secure_ip.xdat_element_access_secure_ip_id;


--
-- Name: xdat_element_access_xdat_element_access_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_element_access_xdat_element_access_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_element_access_xdat_element_access_id_seq OWNER TO xnat;

--
-- Name: xdat_element_access_xdat_element_access_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_element_access_xdat_element_access_id_seq OWNED BY public.xdat_element_access.xdat_element_access_id;


--
-- Name: xdat_element_action_type; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_element_action_type (
    element_action_name character varying(255) DEFAULT ''::character varying NOT NULL,
    display_name character varying(255) DEFAULT ''::character varying NOT NULL,
    sequence integer,
    image character varying(255),
    popup character varying(255),
    secureaccess character varying(255),
    securefeature character varying(255),
    parameterstring character varying(255),
    "grouping" character varying(255),
    element_action_type_info integer,
    xdat_element_action_type_id integer NOT NULL,
    element_actions_element_action__element_name character varying(255)
);


ALTER TABLE public.xdat_element_action_type OWNER TO xnat;

--
-- Name: xdat_element_action_type_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_element_action_type_history (
    popup character varying(255),
    securefeature character varying(255),
    parameterstring character varying(255),
    element_actions_element_action__element_name character varying(255),
    change_date timestamp without time zone,
    sequence integer,
    element_action_type_info integer,
    change_user integer,
    xft_version integer,
    image character varying(255),
    secureaccess character varying(255),
    history_id integer NOT NULL,
    xdat_element_action_type_id integer,
    previous_change_date timestamp without time zone,
    "grouping" character varying(255),
    display_name character varying(255),
    element_action_name character varying(255),
    new_row_xdat_element_action_type_id integer
);


ALTER TABLE public.xdat_element_action_type_history OWNER TO xnat;

--
-- Name: xdat_element_action_type_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_element_action_type_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_element_action_type_history_history_id_seq OWNER TO xnat;

--
-- Name: xdat_element_action_type_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_element_action_type_history_history_id_seq OWNED BY public.xdat_element_action_type_history.history_id;


--
-- Name: xdat_element_action_type_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_element_action_type_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xdat_element_action_type_meta_data OWNER TO xnat;

--
-- Name: xdat_element_action_type_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_element_action_type_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_element_action_type_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: xdat_element_action_type_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_element_action_type_meta_data_meta_data_id_seq OWNED BY public.xdat_element_action_type_meta_data.meta_data_id;


--
-- Name: xdat_element_action_type_xdat_element_action_type_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_element_action_type_xdat_element_action_type_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_element_action_type_xdat_element_action_type_id_seq OWNER TO xnat;

--
-- Name: xdat_element_action_type_xdat_element_action_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_element_action_type_xdat_element_action_type_id_seq OWNED BY public.xdat_element_action_type.xdat_element_action_type_id;


--
-- Name: xdat_element_security_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_element_security_history (
    code character varying(255),
    secure_ip integer,
    secondary_password integer,
    secure_delete integer,
    searchable integer,
    change_date timestamp without time zone,
    sequence integer,
    singular character varying(255),
    quarantine integer,
    change_user integer,
    xft_version integer,
    element_name character varying(255),
    secure integer,
    plural character varying(255),
    secure_edit integer,
    history_id integer NOT NULL,
    browse integer,
    category character varying(255),
    secure_read integer,
    previous_change_date timestamp without time zone,
    accessible integer,
    element_security_info integer,
    secure_create integer,
    element_security_set_element_se_xdat_security_id integer,
    usage character varying(255),
    pre_load integer,
    new_row_element_name character varying(255)
);


ALTER TABLE public.xdat_element_security_history OWNER TO xnat;

--
-- Name: xdat_element_security_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_element_security_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_element_security_history_history_id_seq OWNER TO xnat;

--
-- Name: xdat_element_security_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_element_security_history_history_id_seq OWNED BY public.xdat_element_security_history.history_id;


--
-- Name: xdat_element_security_listing_action; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_element_security_listing_action (
    element_action_name character varying(255) DEFAULT ''::character varying NOT NULL,
    display_name character varying(255) DEFAULT ''::character varying NOT NULL,
    sequence integer,
    image character varying(255),
    popup character varying(255),
    secureaccess character varying(255),
    securefeature character varying(255),
    parameterstring character varying(255),
    element_security_listing_action_info integer,
    xdat_element_security_listing_action_id integer NOT NULL,
    listing_actions_listing_action__element_name character varying(255)
);


ALTER TABLE public.xdat_element_security_listing_action OWNER TO xnat;

--
-- Name: xdat_element_security_listing_action_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_element_security_listing_action_history (
    xdat_element_security_listing_action_id integer,
    popup character varying(255),
    change_user integer,
    element_action_name character varying(255),
    secureaccess character varying(255),
    image character varying(255),
    sequence integer,
    previous_change_date timestamp without time zone,
    element_security_listing_action_info integer,
    parameterstring character varying(255),
    securefeature character varying(255),
    history_id integer NOT NULL,
    display_name character varying(255),
    xft_version integer,
    change_date timestamp without time zone,
    listing_actions_listing_action__element_name character varying(255),
    new_row_xdat_element_security_listing_action_id integer
);


ALTER TABLE public.xdat_element_security_listing_action_history OWNER TO xnat;

--
-- Name: xdat_element_security_listing_action_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_element_security_listing_action_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_element_security_listing_action_history_history_id_seq OWNER TO xnat;

--
-- Name: xdat_element_security_listing_action_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_element_security_listing_action_history_history_id_seq OWNED BY public.xdat_element_security_listing_action_history.history_id;


--
-- Name: xdat_element_security_listing_action_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_element_security_listing_action_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xdat_element_security_listing_action_meta_data OWNER TO xnat;

--
-- Name: xdat_element_security_listing_action_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_element_security_listing_action_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_element_security_listing_action_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: xdat_element_security_listing_action_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_element_security_listing_action_meta_data_meta_data_id_seq OWNED BY public.xdat_element_security_listing_action_meta_data.meta_data_id;


--
-- Name: xdat_element_security_listing_xdat_element_security_listing_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_element_security_listing_xdat_element_security_listing_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_element_security_listing_xdat_element_security_listing_seq OWNER TO xnat;

--
-- Name: xdat_element_security_listing_xdat_element_security_listing_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_element_security_listing_xdat_element_security_listing_seq OWNED BY public.xdat_element_security_listing_action.xdat_element_security_listing_action_id;


--
-- Name: xdat_element_security_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_element_security_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_element_security_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: xdat_element_security_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_element_security_meta_data_meta_data_id_seq OWNED BY public.xdat_element_security_meta_data.meta_data_id;


--
-- Name: xdat_field_mapping_history; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_field_mapping_history (
    change_user integer,
    comparison_type character varying(255),
    xdat_field_mapping_set_xdat_field_mapping_set_id integer,
    previous_change_date timestamp without time zone,
    create_element integer,
    active_element integer,
    xdat_field_mapping_id integer,
    delete_element integer,
    history_id integer NOT NULL,
    field_mapping_info integer,
    field character varying(255),
    edit_element integer,
    read_element integer,
    xft_version integer,
    change_date timestamp without time zone,
    field_value character varying(255),
    new_row_xdat_field_mapping_id integer
);


ALTER TABLE public.xdat_field_mapping_history OWNER TO xnat;

--
-- Name: xdat_field_mapping_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_field_mapping_history_history_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_field_mapping_history_history_id_seq OWNER TO xnat;

--
-- Name: xdat_field_mapping_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_field_mapping_history_history_id_seq OWNED BY public.xdat_field_mapping_history.history_id;


--
-- Name: xdat_field_mapping_meta_data; Type: TABLE; Schema: public; Owner: xnat
--

CREATE TABLE public.xdat_field_mapping_meta_data (
    xft_version character varying(255),
    last_modified timestamp without time zone,
    status character varying(255),
    activation_date timestamp without time zone,
    row_last_modified timestamp without time zone,
    insert_date timestamp without time zone,
    activation_user_xdat_user_id integer,
    insert_user_xdat_user_id integer,
    origin character varying(255),
    modified integer,
    shareable integer,
    meta_data_id integer NOT NULL
);


ALTER TABLE public.xdat_field_mapping_meta_data OWNER TO xnat;

--
-- Name: xdat_field_mapping_meta_data_meta_data_id_seq; Type: SEQUENCE; Schema: public; Owner: xnat
--

CREATE SEQUENCE public.xdat_field_mapping_meta_data_meta_data_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.xdat_field_mapping_meta_data_meta_data_id_seq OWNER TO xnat;

--
-- Name: xdat_field_mapping_meta_data_meta_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: xnat
--

ALTER SEQUENCE public.xdat_field_mapping_meta_data_meta_data_id_seq OWNED BY public.xdat_field_mapping_meta_data.meta_data_id;


--
