-- Name: update_ls_xnat_xcsessiondata(character varying, integer); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.update_ls_xnat_xcsessiondata(character varying, integer) RETURNS character varying
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
    begin

       --DELETE CACHE
      declare
        current_cache RECORD;
      BEGIN
        FOR current_cache IN SELECT oid FROM xs_item_cache WHERE elementname='xnat:xcSessionData' AND ids=CAST($1 AS text)
        LOOP
         DELETE FROM xs_item_cache WHERE oid=current_cache.oid;
        END LOOP;
      END;

       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_xcSessionData.*, meta.meta_data_id FROM xnat_xcSessionData LEFT JOIN xnat_xcSessionData_meta_data meta ON xnat_xcSessionData.xcSessionData_info=meta.meta_data_id WHERE  id=$1
      LOOP
         UPDATE xnat_xcSessionData_meta_data SET last_modified=NOW(), modified=1 WHERE meta_data_id=current_row.meta_data_id;
      END LOOP;

      --UPDATE PARENTS;

        -- PROCESS EXTENSION
        PERFORM update_ls_ext_xnat_imageSessionData( $1, $2);
	
	RETURN 'DONE';
    end;
$_$;


ALTER FUNCTION public.update_ls_xnat_xcsessiondata(character varying, integer) OWNER TO xnat;

--
-- Name: update_ls_xnat_xcvscandata(integer, integer); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.update_ls_xnat_xcvscandata(integer, integer) RETURNS character varying
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
    begin

       --DELETE CACHE
      declare
        current_cache RECORD;
      BEGIN
        FOR current_cache IN SELECT oid FROM xs_item_cache WHERE elementname='xnat:xcvScanData' AND ids=CAST($1 AS text)
        LOOP
         DELETE FROM xs_item_cache WHERE oid=current_cache.oid;
        END LOOP;
      END;

       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_xcvScanData.*, meta.meta_data_id FROM xnat_xcvScanData LEFT JOIN xnat_xcvScanData_meta_data meta ON xnat_xcvScanData.xcvScanData_info=meta.meta_data_id WHERE  xnat_imagescandata_id=$1
      LOOP
         UPDATE xnat_xcvScanData_meta_data SET last_modified=NOW(), modified=1 WHERE meta_data_id=current_row.meta_data_id;
      END LOOP;

      --UPDATE PARENTS;

        -- PROCESS EXTENSION
        PERFORM update_ls_ext_xnat_imageScanData( $1, $2);
	
	RETURN 'DONE';
    end;
$_$;


ALTER FUNCTION public.update_ls_xnat_xcvscandata(integer, integer) OWNER TO xnat;

--
-- Name: update_ls_xnat_xcvsessiondata(character varying, integer); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.update_ls_xnat_xcvsessiondata(character varying, integer) RETURNS character varying
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
    begin

       --DELETE CACHE
      declare
        current_cache RECORD;
      BEGIN
        FOR current_cache IN SELECT oid FROM xs_item_cache WHERE elementname='xnat:xcvSessionData' AND ids=CAST($1 AS text)
        LOOP
         DELETE FROM xs_item_cache WHERE oid=current_cache.oid;
        END LOOP;
      END;

       --UPDATE LOCAL ROW
      FOR current_row IN SELECT xnat_xcvSessionData.*, meta.meta_data_id FROM xnat_xcvSessionData LEFT JOIN xnat_xcvSessionData_meta_data meta ON xnat_xcvSessionData.xcvSessionData_info=meta.meta_data_id WHERE  id=$1
      LOOP
         UPDATE xnat_xcvSessionData_meta_data SET last_modified=NOW(), modified=1 WHERE meta_data_id=current_row.meta_data_id;
      END LOOP;

      --UPDATE PARENTS;

        -- PROCESS EXTENSION
        PERFORM update_ls_ext_xnat_imageSessionData( $1, $2);
	
	RETURN 'DONE';
    end;
$_$;


ALTER FUNCTION public.update_ls_xnat_xcvsessiondata(character varying, integer) OWNER TO xnat;

--
-- Name: viewcount(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.viewcount() RETURNS bigint
    LANGUAGE plpgsql
    AS $$ DECLARE   my_record RECORD;  counter int8;
BEGIN  FOR my_record IN SELECT * FROM (SELECT COUNT (c.relname) AS view_count FROM pg_catalog.pg_class AS c 
LEFT JOIN pg_catalog.pg_namespace AS n ON n.oid = c.relnamespace WHERE     c.relkind IN ('v') AND n.nspname 
NOT IN ('pg_catalog', 'pg_toast') AND pg_catalog.pg_table_is_visible(c.oid) LIMIT 1) AS COUNT_TABLE  LOOP   counter := my_record.view_count;  
END LOOP;  RETURN (counter); END; $$;


ALTER FUNCTION public.viewcount() OWNER TO xnat;

--
-- Name: xdat_search_create(character varying, character varying); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.xdat_search_create(character varying, character varying) RETURNS character varying
    LANGUAGE plpgsql
    AS $_$
    declare
        search_query_name alias for $1;
        search_query alias for $2;
	entry xdat_searches%ROWTYPE;
    begin
	SELECT * INTO entry FROM xdat_searches WHERE search_name = search_query_name;

	    IF FOUND THEN
		RAISE NOTICE 'Search Table % exists.',
		  search_query_name;
		UPDATE xdat_searches SET last_access=NOW() WHERE search_name = search_query_name;
	    ELSE
		RAISE NOTICE 'Creating Search Table %.',
		  search_query_name;
		EXECUTE 'CREATE TABLE ' || search_query_name || ' AS ' || search_query;
		INSERT INTO xdat_searches (search_name) VALUES (search_query_name);
     EXECUTE 'GRANT ALL ON TABLE ' || search_query_name || ' TO public';
	    END IF;

	PERFORM xdat_search_drop_unused();

	RETURN 'DONE';
    end;
$_$;


ALTER FUNCTION public.xdat_search_create(character varying, character varying) OWNER TO xnat;

--
-- Name: xdat_search_create(character varying, character varying, character varying); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.xdat_search_create(character varying, character varying, character varying) RETURNS character varying
    LANGUAGE plpgsql
    AS $_$
    declare
        search_query_name alias for $1;
        search_query alias for $2;
        search_owner alias for $3;
	entry xdat_searches%ROWTYPE;
    begin
	SELECT * INTO entry FROM xdat_searches WHERE search_name = search_query_name;

	    IF FOUND THEN
		RAISE NOTICE 'Search Table % exists.',
		  search_query_name;
		UPDATE xdat_searches SET last_access=NOW() WHERE search_name = search_query_name;
	    ELSE
		RAISE NOTICE 'Creating Search Table %.',
		  search_query_name;
		EXECUTE 'CREATE TABLE ' || search_query_name || ' AS ' || search_query;
		INSERT INTO xdat_searches (search_name,owner) VALUES (search_query_name,search_owner);
	    END IF;

	PERFORM xdat_search_drop_unused(search_owner);

	RETURN 'DONE';
    end;
$_$;


ALTER FUNCTION public.xdat_search_create(character varying, character varying, character varying) OWNER TO xnat;

--
-- Name: xdat_search_drop(character varying); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.xdat_search_drop(character varying) RETURNS character varying
    LANGUAGE plpgsql
    AS $_$
    declare
        search_query_name alias for $1;
    begin
	EXECUTE 'DROP TABLE ' || search_query_name;
	DELETE FROM xdat_searches WHERE search_name = search_query_name;
	
	RETURN 'DONE';
    end;
$_$;


ALTER FUNCTION public.xdat_search_drop(character varying) OWNER TO xnat;

--
-- Name: xdat_search_drop_unused(); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.xdat_search_drop_unused() RETURNS character varying
    LANGUAGE plpgsql
    AS $$
    declare
	entry xdat_searches%ROWTYPE;
    begin
	FOR entry IN SELECT * FROM xdat_searches WHERE last_access + INTERVAL '1 hour' / int '2' < NOW()
	LOOP
		PERFORM xdat_search_drop(entry.search_name);

		RAISE NOTICE 'Dropped Expired Search Table %. (Last Access: %)',
		  entry.search_name,entry.last_access;
	END LOOP;

	RETURN 'DONE';
    end;
$$;


ALTER FUNCTION public.xdat_search_drop_unused() OWNER TO xnat;

--
-- Name: xdat_search_drop_unused(character varying); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.xdat_search_drop_unused(character varying) RETURNS character varying
    LANGUAGE plpgsql
    AS $_$
    declare
	entry xdat_searches%ROWTYPE;
        search_owner alias for $1;
    begin
	FOR entry IN SELECT * FROM xdat_searches WHERE owner=search_owner AND last_access + INTERVAL '1 hour' / int '2' < NOW()
	LOOP
		PERFORM xdat_search_drop(entry.search_name);

		RAISE NOTICE 'Dropped Expired Search Table %. (Last Access: %)',
		  entry.search_name,entry.last_access;
	END LOOP;

	RETURN 'DONE';
    end;
$_$;


ALTER FUNCTION public.xdat_search_drop_unused(character varying) OWNER TO xnat;

--
-- Name: xs_concat(text, text); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.xs_concat(text, text) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    DECLARE
       t text;
    begin
       IF(character_length($1) > 0) THEN
          t = $1 ||', '|| $2;
       ELSE
          t = $2;
       END IF;
       RETURN t;
    END;
$_$;


ALTER FUNCTION public.xs_concat(text, text) OWNER TO xnat;

--
-- Name: xs_lastposition(text, text); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.xs_lastposition(text, text) RETURNS integer
    LANGUAGE plpgsql
    AS $_$     DECLARE        t text;        i int4:=0;     begin        t = $2;        WHILE(POSITION($1 in t)!=0) LOOP             i = i + POSITION($1 in t);             t = substring(t from (POSITION($1 in t) + 1));        END LOOP;        RETURN i;     END; $_$;


ALTER FUNCTION public.xs_lastposition(text, text) OWNER TO xnat;

--
-- Name: xs_a_concat(text); Type: AGGREGATE; Schema: public; Owner: xnat
--

CREATE AGGREGATE public.xs_a_concat(text) (
    SFUNC = textcat,
    STYPE = text,
    INITCOND = ''
);


ALTER AGGREGATE public.xs_a_concat(text) OWNER TO xnat;



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

CREATE TABLE public.activemq_acks (
    container character varying(250) NOT NULL,
    sub_dest character varying(250),
    client_id character varying(250) NOT NULL,
    sub_name character varying(250) NOT NULL,
    selector character varying(250),
    last_acked_id bigint,
    priority bigint DEFAULT 5 NOT NULL,
    xid bytea
);


ALTER TABLE public.activemq_acks OWNER TO xnat;

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

CREATE TABLE public.activemq_lock (
    id bigint NOT NULL,
    "time" bigint,
    broker_name character varying(250)
);


ALTER TABLE public.activemq_lock OWNER TO xnat;

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

CREATE TABLE public.activemq_msgs (
    id bigint NOT NULL,
    container character varying(250),
    msgid_prod character varying(250),
    msgid_seq bigint,
    expiration bigint,
    msg bytea,
    priority bigint,
    xid bytea
);


ALTER TABLE public.activemq_msgs OWNER TO xnat;

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

CREATE TABLE public.analytics (
    id integer NOT NULL,
    entry_date timestamp without time zone,
    entry_level character varying(10),
    entry_location character varying(512),
    entry_type character varying(32),
    entry_subtype character varying(32),
    duration bigint,
    message text
);


ALTER TABLE public.analytics OWNER TO xnat;

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

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


ALTER TABLE public.analytics_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.analytics_id_seq OWNED BY public.analytics.id;



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

CREATE TABLE public.arc_archivespecification (
    globalpaths_arc_pathinfo_id integer DEFAULT 0 NOT NULL,
    emailspecifications_new_user_registration integer,
    emailspecifications_pipeline integer,
    emailspecifications_project_access integer,
    emailspecifications_transfer integer,
    emailspecifications_page_email integer,
    dcm_dcm_host character varying(255),
    dcm_dcm_port character varying(255),
    dcm_dcm_ae character varying(255),
    dcm_http_url character varying(255),
    dcm_applet_link integer,
    site_id character varying(255) DEFAULT ''::character varying NOT NULL,
    site_admin_email character varying(255),
    site_url character varying(255),
    smtp_host character varying(255),
    require_login integer,
    enable_new_registrations integer,
    enable_csrf_token integer,
    quarantine_code integer,
    prearchive_code integer,
    archivespecification_info integer,
    arc_archivespecification_id integer NOT NULL
);


ALTER TABLE public.arc_archivespecification OWNER TO xnat;

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

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


ALTER TABLE public.arc_archivespecification_arc_archivespecification_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_archivespecification_arc_archivespecification_id_seq OWNED BY public.arc_archivespecification.arc_archivespecification_id;


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

CREATE TABLE public.arc_archivespecification_history (
    site_admin_email character varying(255),
    require_login integer,
    smtp_host character varying(255),
    dcm_http_url character varying(255),
    dcm_applet_link integer,
    emailspecifications_project_access integer,
    dcm_dcm_ae character varying(255),
    globalpaths_arc_pathinfo_id integer,
    arc_archivespecification_id integer,
    enable_new_registrations integer,
    change_date timestamp without time zone,
    quarantine_code integer,
    change_user integer,
    xft_version integer,
    prearchive_code integer,
    dcm_dcm_port character varying(255),
    site_url character varying(255),
    history_id integer NOT NULL,
    emailspecifications_pipeline integer,
    dcm_dcm_host character varying(255),
    enable_csrf_token integer,
    emailspecifications_page_email integer,
    site_id character varying(255),
    previous_change_date timestamp without time zone,
    emailspecifications_transfer integer,
    emailspecifications_new_user_registration integer,
    archivespecification_info integer,
    new_row_arc_archivespecification_id integer
);


ALTER TABLE public.arc_archivespecification_history OWNER TO xnat;

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

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


ALTER TABLE public.arc_archivespecification_history_history_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_archivespecification_history_history_id_seq OWNED BY public.arc_archivespecification_history.history_id;


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

CREATE TABLE public.arc_archivespecification_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.arc_archivespecification_meta_data OWNER TO xnat;

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

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


ALTER TABLE public.arc_archivespecification_meta_data_meta_data_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_archivespecification_meta_data_meta_data_id_seq OWNED BY public.arc_archivespecification_meta_data.meta_data_id;


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

CREATE TABLE public.arc_archivespecification_notification_type (
    notification_type character varying(255),
    email_addresses character varying(255),
    archivespecification_notification_type_info integer,
    arc_archivespecification_notification_type_id integer NOT NULL,
    notification_types_notification_arc_archivespecification_id integer
);


ALTER TABLE public.arc_archivespecification_notification_type OWNER TO xnat;

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

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


ALTER TABLE public.arc_archivespecification_noti_arc_archivespecification_noti_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_archivespecification_noti_arc_archivespecification_noti_seq OWNED BY public.arc_archivespecification_notification_type.arc_archivespecification_notification_type_id;


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

CREATE TABLE public.arc_archivespecification_notification_type_history (
    change_user integer,
    arc_archivespecification_notification_type_id integer,
    archivespecification_notification_type_info integer,
    notification_types_notification_arc_archivespecification_id integer,
    previous_change_date timestamp without time zone,
    email_addresses character varying(255),
    history_id integer NOT NULL,
    notification_type character varying(255),
    xft_version integer,
    change_date timestamp without time zone,
    new_row_arc_archivespecification_notification_type_id integer
);


ALTER TABLE public.arc_archivespecification_notification_type_history OWNER TO xnat;

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

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


ALTER TABLE public.arc_archivespecification_notification_type_histo_history_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_archivespecification_notification_type_histo_history_id_seq OWNED BY public.arc_archivespecification_notification_type_history.history_id;


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

CREATE TABLE public.arc_archivespecification_notification_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.arc_archivespecification_notification_type_meta_data OWNER TO xnat;

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

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


ALTER TABLE public.arc_archivespecification_notification_type_met_meta_data_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_archivespecification_notification_type_met_meta_data_id_seq OWNED BY public.arc_archivespecification_notification_type_meta_data.meta_data_id;


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

CREATE TABLE public.arc_fieldspecification (
    fieldspecification text,
    name text,
    fieldspecification_info integer,
    arc_fieldspecification_id integer NOT NULL,
    fieldspecifications_fieldspecif_arc_archivespecification_id integer,
    fieldspecifications_fieldspecif_arc_project_id integer
);


ALTER TABLE public.arc_fieldspecification OWNER TO xnat;

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

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


ALTER TABLE public.arc_fieldspecification_arc_fieldspecification_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_fieldspecification_arc_fieldspecification_id_seq OWNED BY public.arc_fieldspecification.arc_fieldspecification_id;


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

CREATE TABLE public.arc_fieldspecification_history (
    fieldspecification text,
    fieldspecification_info integer,
    change_user integer,
    name text,
    previous_change_date timestamp without time zone,
    fieldspecifications_fieldspecif_arc_project_id integer,
    fieldspecifications_fieldspecif_arc_archivespecification_id integer,
    history_id integer NOT NULL,
    xft_version integer,
    change_date timestamp without time zone,
    arc_fieldspecification_id integer,
    new_row_arc_fieldspecification_id integer
);


ALTER TABLE public.arc_fieldspecification_history OWNER TO xnat;

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

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


ALTER TABLE public.arc_fieldspecification_history_history_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_fieldspecification_history_history_id_seq OWNED BY public.arc_fieldspecification_history.history_id;


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

CREATE TABLE public.arc_fieldspecification_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.arc_fieldspecification_meta_data OWNER TO xnat;

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

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


ALTER TABLE public.arc_fieldspecification_meta_data_meta_data_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_fieldspecification_meta_data_meta_data_id_seq OWNED BY public.arc_fieldspecification_meta_data.meta_data_id;


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

CREATE TABLE public.arc_pathinfo (
    archivepath character varying(255),
    prearchivepath character varying(255),
    cachepath character varying(255),
    buildpath character varying(255),
    ftppath character varying(255),
    pipelinepath character varying(255),
    pathinfo_info integer,
    arc_pathinfo_id integer NOT NULL
);


ALTER TABLE public.arc_pathinfo OWNER TO xnat;

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

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


ALTER TABLE public.arc_pathinfo_arc_pathinfo_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_pathinfo_arc_pathinfo_id_seq OWNED BY public.arc_pathinfo.arc_pathinfo_id;


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

CREATE TABLE public.arc_pathinfo_history (
    change_user integer,
    ftppath character varying(255),
    cachepath character varying(255),
    previous_change_date timestamp without time zone,
    arc_pathinfo_id integer,
    prearchivepath character varying(255),
    history_id integer NOT NULL,
    buildpath character varying(255),
    xft_version integer,
    change_date timestamp without time zone,
    pathinfo_info integer,
    pipelinepath character varying(255),
    archivepath character varying(255),
    new_row_arc_pathinfo_id integer
);


ALTER TABLE public.arc_pathinfo_history OWNER TO xnat;

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

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


ALTER TABLE public.arc_pathinfo_history_history_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_pathinfo_history_history_id_seq OWNED BY public.arc_pathinfo_history.history_id;


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

CREATE TABLE public.arc_pathinfo_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.arc_pathinfo_meta_data OWNER TO xnat;

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

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


ALTER TABLE public.arc_pathinfo_meta_data_meta_data_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_pathinfo_meta_data_meta_data_id_seq OWNED BY public.arc_pathinfo_meta_data.meta_data_id;


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

CREATE TABLE public.arc_pipelinedata (
    displaytext character varying(255),
    name character varying(255),
    location character varying(255),
    description character varying(255),
    customwebpage character varying(255),
    extension integer,
    pipelinedata_info integer,
    arc_pipelinedata_id integer NOT NULL
);


ALTER TABLE public.arc_pipelinedata OWNER TO xnat;

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

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


ALTER TABLE public.arc_pipelinedata_arc_pipelinedata_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_pipelinedata_arc_pipelinedata_id_seq OWNED BY public.arc_pipelinedata.arc_pipelinedata_id;


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

CREATE TABLE public.arc_pipelinedata_history (
    change_user integer,
    name character varying(255),
    customwebpage character varying(255),
    displaytext character varying(255),
    previous_change_date timestamp without time zone,
    pipelinedata_info integer,
    history_id integer NOT NULL,
    arc_pipelinedata_id integer,
    location character varying(255),
    description character varying(255),
    xft_version integer,
    change_date timestamp without time zone,
    extension integer,
    new_row_arc_pipelinedata_id integer
);


ALTER TABLE public.arc_pipelinedata_history OWNER TO xnat;

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

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


ALTER TABLE public.arc_pipelinedata_history_history_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_pipelinedata_history_history_id_seq OWNED BY public.arc_pipelinedata_history.history_id;


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

CREATE TABLE public.arc_pipelinedata_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.arc_pipelinedata_meta_data OWNER TO xnat;

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

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


ALTER TABLE public.arc_pipelinedata_meta_data_meta_data_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_pipelinedata_meta_data_meta_data_id_seq OWNED BY public.arc_pipelinedata_meta_data.meta_data_id;


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

CREATE TABLE public.arc_pipelineparameterdata (
    schemalink character varying(255),
    csvvalues character varying(255),
    csvvalues_selected character varying(255),
    description text,
    name character varying(255) DEFAULT ''::character varying NOT NULL,
    multiplevalues integer,
    editable integer,
    batchparam integer,
    pipelineparameterdata_info integer,
    arc_pipelineparameterdata_id integer NOT NULL,
    parameters_parameter_arc_pipeli_arc_pipelinedata_id integer
);


ALTER TABLE public.arc_pipelineparameterdata OWNER TO xnat;

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

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


ALTER TABLE public.arc_pipelineparameterdata_arc_pipelineparameterdata_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_pipelineparameterdata_arc_pipelineparameterdata_id_seq OWNED BY public.arc_pipelineparameterdata.arc_pipelineparameterdata_id;


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

CREATE TABLE public.arc_pipelineparameterdata_history (
    name character varying(255),
    change_user integer,
    pipelineparameterdata_info integer,
    csvvalues character varying(255),
    batchparam integer,
    parameters_parameter_arc_pipeli_arc_pipelinedata_id integer,
    editable integer,
    previous_change_date timestamp without time zone,
    arc_pipelineparameterdata_id integer,
    multiplevalues integer,
    history_id integer NOT NULL,
    description text,
    schemalink character varying(255),
    csvvalues_selected character varying(255),
    xft_version integer,
    change_date timestamp without time zone,
    new_row_arc_pipelineparameterdata_id integer
);


ALTER TABLE public.arc_pipelineparameterdata_history OWNER TO xnat;

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

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


ALTER TABLE public.arc_pipelineparameterdata_history_history_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_pipelineparameterdata_history_history_id_seq OWNED BY public.arc_pipelineparameterdata_history.history_id;


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

CREATE TABLE public.arc_pipelineparameterdata_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.arc_pipelineparameterdata_meta_data OWNER TO xnat;

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

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


ALTER TABLE public.arc_pipelineparameterdata_meta_data_meta_data_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_pipelineparameterdata_meta_data_meta_data_id_seq OWNED BY public.arc_pipelineparameterdata_meta_data.meta_data_id;


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

CREATE TABLE public.arc_project (
    paths_arc_pathinfo_id integer,
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    current_arc character varying(255),
    quarantine_code integer,
    prearchive_code integer,
    project_info integer,
    arc_project_id integer NOT NULL,
    projects_project_arc_archivespe_arc_archivespecification_id integer
);


ALTER TABLE public.arc_project OWNER TO xnat;

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

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


ALTER TABLE public.arc_project_arc_project_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_project_arc_project_id_seq OWNED BY public.arc_project.arc_project_id;


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

CREATE TABLE public.arc_project_descendant (
    xsitype character varying(255) DEFAULT ''::character varying NOT NULL,
    project_descendant_info integer,
    arc_project_descendant_id integer NOT NULL,
    pipelines_descendants_descendan_arc_project_id integer
);


ALTER TABLE public.arc_project_descendant OWNER TO xnat;

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

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


ALTER TABLE public.arc_project_descendant_arc_project_descendant_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_project_descendant_arc_project_descendant_id_seq OWNED BY public.arc_project_descendant.arc_project_descendant_id;


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

CREATE TABLE public.arc_project_descendant_history (
    xsitype character varying(255),
    change_user integer,
    previous_change_date timestamp without time zone,
    project_descendant_info integer,
    history_id integer NOT NULL,
    arc_project_descendant_id integer,
    xft_version integer,
    pipelines_descendants_descendan_arc_project_id integer,
    change_date timestamp without time zone,
    new_row_arc_project_descendant_id integer
);


ALTER TABLE public.arc_project_descendant_history OWNER TO xnat;

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

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


ALTER TABLE public.arc_project_descendant_history_history_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_project_descendant_history_history_id_seq OWNED BY public.arc_project_descendant_history.history_id;


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

CREATE TABLE public.arc_project_descendant_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.arc_project_descendant_meta_data OWNER TO xnat;

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

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


ALTER TABLE public.arc_project_descendant_meta_data_meta_data_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_project_descendant_meta_data_meta_data_id_seq OWNED BY public.arc_project_descendant_meta_data.meta_data_id;


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

CREATE TABLE public.arc_project_descendant_pipeline (
    arc_pipelinedata_id integer DEFAULT 0 NOT NULL,
    stepid character varying(255) DEFAULT ''::character varying NOT NULL,
    dependent integer,
    project_descendant_pipeline_info integer,
    arc_project_descendant_arc_project_descendant_id integer
);


ALTER TABLE public.arc_project_descendant_pipeline OWNER TO xnat;

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

CREATE TABLE public.arc_project_descendant_pipeline_history (
    change_user integer,
    stepid character varying(255),
    previous_change_date timestamp without time zone,
    arc_project_descendant_arc_project_descendant_id integer,
    project_descendant_pipeline_info integer,
    history_id integer NOT NULL,
    arc_pipelinedata_id integer,
    dependent integer,
    xft_version integer,
    change_date timestamp without time zone,
    new_row_arc_pipelinedata_id integer
);


ALTER TABLE public.arc_project_descendant_pipeline_history OWNER TO xnat;

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

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


ALTER TABLE public.arc_project_descendant_pipeline_history_history_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_project_descendant_pipeline_history_history_id_seq OWNED BY public.arc_project_descendant_pipeline_history.history_id;


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

CREATE TABLE public.arc_project_descendant_pipeline_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.arc_project_descendant_pipeline_meta_data OWNER TO xnat;

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

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


ALTER TABLE public.arc_project_descendant_pipeline_meta_data_meta_data_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_project_descendant_pipeline_meta_data_meta_data_id_seq OWNED BY public.arc_project_descendant_pipeline_meta_data.meta_data_id;


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

CREATE TABLE public.arc_project_history (
    projects_project_arc_archivespe_arc_archivespecification_id integer,
    arc_project_id integer,
    change_user integer,
    id character varying(255),
    quarantine_code integer,
    paths_arc_pathinfo_id integer,
    previous_change_date timestamp without time zone,
    prearchive_code integer,
    history_id integer NOT NULL,
    current_arc character varying(255),
    project_info integer,
    xft_version integer,
    change_date timestamp without time zone,
    new_row_arc_project_id integer
);


ALTER TABLE public.arc_project_history OWNER TO xnat;

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

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


ALTER TABLE public.arc_project_history_history_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_project_history_history_id_seq OWNED BY public.arc_project_history.history_id;


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

CREATE TABLE public.arc_project_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.arc_project_meta_data OWNER TO xnat;

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

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


ALTER TABLE public.arc_project_meta_data_meta_data_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_project_meta_data_meta_data_id_seq OWNED BY public.arc_project_meta_data.meta_data_id;


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

CREATE TABLE public.arc_project_pipeline (
    arc_pipelinedata_id integer DEFAULT 0 NOT NULL,
    stepid character varying(255) DEFAULT ''::character varying NOT NULL,
    dependent integer,
    project_pipeline_info integer,
    pipelines_pipeline_arc_project_arc_project_id integer
);


ALTER TABLE public.arc_project_pipeline OWNER TO xnat;

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

CREATE TABLE public.arc_project_pipeline_history (
    project_pipeline_info integer,
    change_user integer,
    pipelines_pipeline_arc_project_arc_project_id integer,
    stepid character varying(255),
    previous_change_date timestamp without time zone,
    history_id integer NOT NULL,
    arc_pipelinedata_id integer,
    dependent integer,
    xft_version integer,
    change_date timestamp without time zone,
    new_row_arc_pipelinedata_id integer
);


ALTER TABLE public.arc_project_pipeline_history OWNER TO xnat;

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

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


ALTER TABLE public.arc_project_pipeline_history_history_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_project_pipeline_history_history_id_seq OWNED BY public.arc_project_pipeline_history.history_id;


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

CREATE TABLE public.arc_project_pipeline_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.arc_project_pipeline_meta_data OWNER TO xnat;

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

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


ALTER TABLE public.arc_project_pipeline_meta_data_meta_data_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_project_pipeline_meta_data_meta_data_id_seq OWNED BY public.arc_project_pipeline_meta_data.meta_data_id;


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

CREATE TABLE public.arc_property (
    property text,
    name text,
    property_info integer,
    arc_property_id integer NOT NULL,
    properties_property_arc_project_arc_project_id integer
);


ALTER TABLE public.arc_property OWNER TO xnat;

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

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


ALTER TABLE public.arc_property_arc_property_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_property_arc_property_id_seq OWNED BY public.arc_property.arc_property_id;


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

CREATE TABLE public.arc_property_history (
    change_user integer,
    name text,
    arc_property_id integer,
    previous_change_date timestamp without time zone,
    history_id integer NOT NULL,
    property_info integer,
    properties_property_arc_project_arc_project_id integer,
    property text,
    xft_version integer,
    change_date timestamp without time zone,
    new_row_arc_property_id integer
);


ALTER TABLE public.arc_property_history OWNER TO xnat;

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

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


ALTER TABLE public.arc_property_history_history_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_property_history_history_id_seq OWNED BY public.arc_property_history.history_id;


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

CREATE TABLE public.arc_property_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.arc_property_meta_data OWNER TO xnat;

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

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


ALTER TABLE public.arc_property_meta_data_meta_data_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.arc_property_meta_data_meta_data_id_seq OWNED BY public.arc_property_meta_data.meta_data_id;


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

CREATE TABLE public.cat_catalog (
    sets_entryset_cat_catalog_id integer,
    id character varying(255),
    name character varying(255),
    description character varying(255),
    extension integer,
    catalog_info integer,
    cat_catalog_id integer NOT NULL
);


ALTER TABLE public.cat_catalog OWNER TO xnat;

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

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


ALTER TABLE public.cat_catalog_cat_catalog_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_catalog_cat_catalog_id_seq OWNED BY public.cat_catalog.cat_catalog_id;


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

CREATE TABLE public.cat_catalog_history (
    change_user integer,
    name character varying(255),
    id character varying(255),
    catalog_info integer,
    previous_change_date timestamp without time zone,
    history_id integer NOT NULL,
    cat_catalog_id integer,
    description character varying(255),
    xft_version integer,
    change_date timestamp without time zone,
    extension integer,
    new_row_cat_catalog_id integer
);


ALTER TABLE public.cat_catalog_history OWNER TO xnat;

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

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


ALTER TABLE public.cat_catalog_history_history_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_catalog_history_history_id_seq OWNED BY public.cat_catalog_history.history_id;


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

CREATE TABLE public.cat_catalog_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.cat_catalog_meta_data OWNER TO xnat;

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

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


ALTER TABLE public.cat_catalog_meta_data_meta_data_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_catalog_meta_data_meta_data_id_seq OWNED BY public.cat_catalog_meta_data.meta_data_id;


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

CREATE TABLE public.cat_catalog_metafield (
    metafield character varying(255),
    name character varying(255),
    catalog_metafield_info integer,
    cat_catalog_metafield_id integer NOT NULL,
    metafields_metafield_cat_catalo_cat_catalog_id integer
);


ALTER TABLE public.cat_catalog_metafield OWNER TO xnat;

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

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


ALTER TABLE public.cat_catalog_metafield_cat_catalog_metafield_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_catalog_metafield_cat_catalog_metafield_id_seq OWNED BY public.cat_catalog_metafield.cat_catalog_metafield_id;


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

CREATE TABLE public.cat_catalog_metafield_history (
    cat_catalog_metafield_id integer,
    change_user integer,
    name character varying(255),
    previous_change_date timestamp without time zone,
    catalog_metafield_info integer,
    metafield character varying(255),
    metafields_metafield_cat_catalo_cat_catalog_id integer,
    history_id integer NOT NULL,
    xft_version integer,
    change_date timestamp without time zone,
    new_row_cat_catalog_metafield_id integer
);


ALTER TABLE public.cat_catalog_metafield_history OWNER TO xnat;

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

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


ALTER TABLE public.cat_catalog_metafield_history_history_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_catalog_metafield_history_history_id_seq OWNED BY public.cat_catalog_metafield_history.history_id;


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

CREATE TABLE public.cat_catalog_metafield_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.cat_catalog_metafield_meta_data OWNER TO xnat;

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

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


ALTER TABLE public.cat_catalog_metafield_meta_data_meta_data_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_catalog_metafield_meta_data_meta_data_id_seq OWNED BY public.cat_catalog_metafield_meta_data.meta_data_id;


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

CREATE TABLE public.cat_catalog_tag (
    tag character varying(255),
    catalog_tag_info integer,
    cat_catalog_tag_id integer NOT NULL,
    tags_tag_cat_catalog_cat_catalog_id integer
);


ALTER TABLE public.cat_catalog_tag OWNER TO xnat;

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

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


ALTER TABLE public.cat_catalog_tag_cat_catalog_tag_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_catalog_tag_cat_catalog_tag_id_seq OWNED BY public.cat_catalog_tag.cat_catalog_tag_id;


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

CREATE TABLE public.cat_catalog_tag_history (
    change_user integer,
    catalog_tag_info integer,
    previous_change_date timestamp without time zone,
    history_id integer NOT NULL,
    cat_catalog_tag_id integer,
    xft_version integer,
    tags_tag_cat_catalog_cat_catalog_id integer,
    change_date timestamp without time zone,
    tag character varying(255),
    new_row_cat_catalog_tag_id integer
);


ALTER TABLE public.cat_catalog_tag_history OWNER TO xnat;

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

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


ALTER TABLE public.cat_catalog_tag_history_history_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_catalog_tag_history_history_id_seq OWNED BY public.cat_catalog_tag_history.history_id;


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

CREATE TABLE public.cat_catalog_tag_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.cat_catalog_tag_meta_data OWNER TO xnat;

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

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


ALTER TABLE public.cat_catalog_tag_meta_data_meta_data_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_catalog_tag_meta_data_meta_data_id_seq OWNED BY public.cat_catalog_tag_meta_data.meta_data_id;


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

CREATE TABLE public.cat_dcmcatalog (
    cat_catalog_id integer DEFAULT 0 NOT NULL,
    dimensions_x integer,
    dimensions_y integer,
    dimensions_z integer,
    dimensions_volumes integer,
    voxelres_x double precision,
    voxelres_y double precision,
    voxelres_z double precision,
    voxelres_units character varying(255),
    orientation character varying(255),
    uid character varying(255),
    dcmcatalog_info integer
);


ALTER TABLE public.cat_dcmcatalog OWNER TO xnat;

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

CREATE TABLE public.cat_dcmcatalog_history (
    voxelres_z double precision,
    voxelres_y double precision,
    voxelres_x double precision,
    orientation character varying(255),
    voxelres_units character varying(255),
    uid character varying(255),
    change_date timestamp without time zone,
    change_user integer,
    xft_version integer,
    history_id integer NOT NULL,
    dimensions_z integer,
    dimensions_y integer,
    dimensions_x integer,
    dimensions_volumes integer,
    cat_catalog_id integer,
    previous_change_date timestamp without time zone,
    dcmcatalog_info integer,
    new_row_cat_catalog_id integer
);


ALTER TABLE public.cat_dcmcatalog_history OWNER TO xnat;

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

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


ALTER TABLE public.cat_dcmcatalog_history_history_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_dcmcatalog_history_history_id_seq OWNED BY public.cat_dcmcatalog_history.history_id;


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

CREATE TABLE public.cat_dcmcatalog_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.cat_dcmcatalog_meta_data OWNER TO xnat;

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

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


ALTER TABLE public.cat_dcmcatalog_meta_data_meta_data_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_dcmcatalog_meta_data_meta_data_id_seq OWNED BY public.cat_dcmcatalog_meta_data.meta_data_id;


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

CREATE TABLE public.cat_dcmentry (
    cat_entry_id integer DEFAULT 0 NOT NULL,
    uid character varying(255),
    instancenumber integer,
    dcmentry_info integer
);


ALTER TABLE public.cat_dcmentry OWNER TO xnat;

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

CREATE TABLE public.cat_dcmentry_history (
    change_user integer,
    previous_change_date timestamp without time zone,
    dcmentry_info integer,
    cat_entry_id integer,
    uid character varying(255),
    history_id integer NOT NULL,
    instancenumber integer,
    xft_version integer,
    change_date timestamp without time zone,
    new_row_cat_entry_id integer
);


ALTER TABLE public.cat_dcmentry_history OWNER TO xnat;

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

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


ALTER TABLE public.cat_dcmentry_history_history_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_dcmentry_history_history_id_seq OWNED BY public.cat_dcmentry_history.history_id;


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

CREATE TABLE public.cat_dcmentry_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.cat_dcmentry_meta_data OWNER TO xnat;

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

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


ALTER TABLE public.cat_dcmentry_meta_data_meta_data_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_dcmentry_meta_data_meta_data_id_seq OWNED BY public.cat_dcmentry_meta_data.meta_data_id;


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

CREATE TABLE public.cat_entry (
    uri character varying(255) DEFAULT ''::character varying NOT NULL,
    id character varying(255),
    name character varying(255),
    description character varying(255),
    format character varying(255),
    content character varying(255),
    cachepath character varying(255),
    createdtime timestamp without time zone,
    createdby character varying(255),
    createdeventid integer,
    modifiedtime timestamp without time zone,
    modifiedby character varying(255),
    modifiedeventid integer,
    digest character varying(255),
    extension integer,
    entry_info integer,
    cat_entry_id integer NOT NULL,
    entries_entry_cat_catalog_cat_catalog_id integer
);


ALTER TABLE public.cat_entry OWNER TO xnat;

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

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


ALTER TABLE public.cat_entry_cat_entry_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_entry_cat_entry_id_seq OWNED BY public.cat_entry.cat_entry_id;


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

CREATE TABLE public.cat_entry_history (
    cat_entry_id integer,
    entry_info integer,
    createdtime timestamp without time zone,
    uri character varying(255),
    cachepath character varying(255),
    change_date timestamp without time zone,
    modifiedtime timestamp without time zone,
    createdeventid integer,
    change_user integer,
    xft_version integer,
    modifiedby character varying(255),
    createdby character varying(255),
    entries_entry_cat_catalog_cat_catalog_id integer,
    id character varying(255),
    history_id integer NOT NULL,
    content character varying(255),
    description character varying(255),
    previous_change_date timestamp without time zone,
    format character varying(255),
    digest character varying(255),
    modifiedeventid integer,
    name character varying(255),
    extension integer,
    new_row_cat_entry_id integer
);


ALTER TABLE public.cat_entry_history OWNER TO xnat;

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

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


ALTER TABLE public.cat_entry_history_history_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_entry_history_history_id_seq OWNED BY public.cat_entry_history.history_id;


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

CREATE TABLE public.cat_entry_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.cat_entry_meta_data OWNER TO xnat;

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

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


ALTER TABLE public.cat_entry_meta_data_meta_data_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_entry_meta_data_meta_data_id_seq OWNED BY public.cat_entry_meta_data.meta_data_id;


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

CREATE TABLE public.cat_entry_metafield (
    metafield character varying(255),
    name character varying(255),
    entry_metafield_info integer,
    cat_entry_metafield_id integer NOT NULL,
    metafields_metafield_cat_entry_cat_entry_id integer
);


ALTER TABLE public.cat_entry_metafield OWNER TO xnat;

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

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


ALTER TABLE public.cat_entry_metafield_cat_entry_metafield_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_entry_metafield_cat_entry_metafield_id_seq OWNED BY public.cat_entry_metafield.cat_entry_metafield_id;


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

CREATE TABLE public.cat_entry_metafield_history (
    change_user integer,
    name character varying(255),
    metafields_metafield_cat_entry_cat_entry_id integer,
    previous_change_date timestamp without time zone,
    cat_entry_metafield_id integer,
    metafield character varying(255),
    entry_metafield_info integer,
    history_id integer NOT NULL,
    xft_version integer,
    change_date timestamp without time zone,
    new_row_cat_entry_metafield_id integer
);


ALTER TABLE public.cat_entry_metafield_history OWNER TO xnat;

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

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


ALTER TABLE public.cat_entry_metafield_history_history_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_entry_metafield_history_history_id_seq OWNED BY public.cat_entry_metafield_history.history_id;


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

CREATE TABLE public.cat_entry_metafield_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.cat_entry_metafield_meta_data OWNER TO xnat;

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

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


ALTER TABLE public.cat_entry_metafield_meta_data_meta_data_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_entry_metafield_meta_data_meta_data_id_seq OWNED BY public.cat_entry_metafield_meta_data.meta_data_id;


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

CREATE TABLE public.cat_entry_tag (
    tag character varying(255),
    entry_tag_info integer,
    cat_entry_tag_id integer NOT NULL,
    tags_tag_cat_entry_cat_entry_id integer
);


ALTER TABLE public.cat_entry_tag OWNER TO xnat;

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

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


ALTER TABLE public.cat_entry_tag_cat_entry_tag_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_entry_tag_cat_entry_tag_id_seq OWNED BY public.cat_entry_tag.cat_entry_tag_id;


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

CREATE TABLE public.cat_entry_tag_history (
    change_user integer,
    previous_change_date timestamp without time zone,
    cat_entry_tag_id integer,
    tags_tag_cat_entry_cat_entry_id integer,
    entry_tag_info integer,
    history_id integer NOT NULL,
    xft_version integer,
    change_date timestamp without time zone,
    tag character varying(255),
    new_row_cat_entry_tag_id integer
);


ALTER TABLE public.cat_entry_tag_history OWNER TO xnat;

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

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


ALTER TABLE public.cat_entry_tag_history_history_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_entry_tag_history_history_id_seq OWNED BY public.cat_entry_tag_history.history_id;


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

CREATE TABLE public.cat_entry_tag_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.cat_entry_tag_meta_data OWNER TO xnat;

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

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


ALTER TABLE public.cat_entry_tag_meta_data_meta_data_id_seq OWNER TO xnat;

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

ALTER SEQUENCE public.cat_entry_tag_meta_data_meta_data_id_seq OWNED BY public.cat_entry_tag_meta_data.meta_data_id;


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

CREATE TABLE public.xdat_element_access (
    secondary_password character varying(255),
    secondary_password_encrypt integer,
    element_name character varying(255) DEFAULT ''::character varying NOT NULL,
    element_access_info integer,
    xdat_element_access_id integer NOT NULL,
    xdat_user_xdat_user_id integer,
    xdat_usergroup_xdat_usergroup_id integer
);


ALTER TABLE public.xdat_element_access OWNER TO xnat;

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

CREATE TABLE public.xdat_field_mapping (
    field character varying(255) DEFAULT ''::character varying NOT NULL,
    field_value character varying(255) DEFAULT ''::character varying NOT NULL,
    create_element integer,
    read_element integer,
    edit_element integer,
    delete_element integer,
    active_element integer,
    comparison_type character varying(255),
    field_mapping_info integer,
    xdat_field_mapping_id integer NOT NULL,
    xdat_field_mapping_set_xdat_field_mapping_set_id integer
);


ALTER TABLE public.xdat_field_mapping OWNER TO xnat;

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

CREATE TABLE public.xdat_field_mapping_set (
    sub_set_xdat_field_mapping_set_id integer,
    method character varying(255),
    field_mapping_set_info integer,
    xdat_field_mapping_set_id integer NOT NULL,
    permissions_allow_set_xdat_elem_xdat_element_access_id integer
);


ALTER TABLE public.xdat_field_mapping_set OWNER TO xnat;

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

CREATE TABLE public.xdat_user (
    login character varying(255),
    firstname character varying(255),
    lastname character varying(255),
    email character varying(255),
    primary_password character varying(255),
    primary_password_encrypt integer,
    quarantine_path character varying(255),
    enabled integer,
    verified integer,
    salt character varying(255),
    user_info integer,
    xdat_user_id integer NOT NULL,
    users_user_xdat_security_xdat_security_id integer
);


ALTER TABLE public.xdat_user OWNER TO xnat;

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

CREATE TABLE public.xdat_usergroup (
    id character varying(255),
    displayname character varying(255),
    tag character varying(255),
    usergroup_info integer,
    xdat_usergroup_id integer NOT NULL,
    groups_group_xdat_security_xdat_security_id integer
);


ALTER TABLE public.xdat_usergroup OWNER TO xnat;

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

CREATE VIEW public.data_type_views_element_access AS
 SELECT COALESCE(g.id, (('user:'::text || (u.login)::text))::character varying) AS entity,
    a.element_name,
    m.field_value,
    m.field,
    m.active_element,
    m.read_element,
    m.edit_element,
    m.create_element,
    m.delete_element,
    m.comparison_type,
    s.method,
    a.xdat_element_access_id,
    s.xdat_field_mapping_set_id,
    m.xdat_field_mapping_id
   FROM ((((public.xdat_element_access a
     LEFT JOIN public.xdat_user u ON ((a.xdat_user_xdat_user_id = u.xdat_user_id)))
     LEFT JOIN public.xdat_usergroup g ON ((a.xdat_usergroup_xdat_usergroup_id = g.xdat_usergroup_id)))
     LEFT JOIN public.xdat_field_mapping_set s ON ((a.xdat_element_access_id = s.permissions_allow_set_xdat_elem_xdat_element_access_id)))
     LEFT JOIN public.xdat_field_mapping m ON ((s.xdat_field_mapping_set_id = m.xdat_field_mapping_set_xdat_field_mapping_set_id)));


ALTER TABLE public.data_type_views_element_access OWNER TO xnat;

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

CREATE VIEW public.data_type_views_mismatched_mapping_elements AS
 SELECT m.xdat_field_mapping_id AS id
   FROM ((public.xdat_field_mapping m
     LEFT JOIN public.xdat_field_mapping_set s ON ((m.xdat_field_mapping_set_xdat_field_mapping_set_id = s.xdat_field_mapping_set_id)))
     LEFT JOIN public.xdat_element_access a ON ((s.permissions_allow_set_xdat_elem_xdat_element_access_id = a.xdat_element_access_id)))
  WHERE ((m.field)::text !~~ ((a.element_name)::text || '%'::text));


ALTER TABLE public.data_type_views_mismatched_mapping_elements OWNER TO xnat;

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

CREATE TABLE public.xdat_primary_security_field (
    primary_security_field character varying(255),
    primary_security_field_info integer,
    xdat_primary_security_field_id integer NOT NULL,
    primary_security_fields_primary_element_name character varying(255)
);


ALTER TABLE public.xdat_primary_security_field OWNER TO xnat;

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

CREATE VIEW public.data_type_views_missing_mapping_elements AS
 WITH public_project_access_mappings AS (
         SELECT data_type_views_element_access.field_value,
            data_type_views_element_access.element_name,
            data_type_views_element_access.field,
            data_type_views_element_access.xdat_field_mapping_set_id
           FROM public.data_type_views_element_access
          WHERE (((data_type_views_element_access.element_name)::text <> 'xnat:projectData'::text) AND ((data_type_views_element_access.entity)::text = 'user:guest'::text))
        )
 SELECT f.primary_security_field AS field,
    m.field_value,
    m.xdat_field_mapping_set_id
   FROM (public.xdat_primary_security_field f
     LEFT JOIN public_project_access_mappings m ON (((f.primary_security_fields_primary_element_name)::text = (m.element_name)::text)))
  WHERE (((f.primary_security_fields_primary_element_name)::text <> 'xnat:projectData'::text) AND ((m.field_value IS NULL) OR (NOT (((f.primary_security_fields_primary_element_name)::text, (f.primary_security_field)::text) IN ( SELECT m.element_name,
            public_project_access_mappings.field
           FROM public_project_access_mappings)))));


ALTER TABLE public.data_type_views_missing_mapping_elements OWNER TO xnat;

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

CREATE VIEW public.data_type_views_orphaned_field_sets AS
 SELECT s.xdat_field_mapping_set_id AS id
   FROM ((public.xdat_element_access a
     LEFT JOIN public.xdat_field_mapping_set s ON ((a.xdat_element_access_id = s.permissions_allow_set_xdat_elem_xdat_element_access_id)))
     LEFT JOIN public.xdat_field_mapping m ON ((s.xdat_field_mapping_set_id = m.xdat_field_mapping_set_xdat_field_mapping_set_id)))
  WHERE ((s.xdat_field_mapping_set_id IS NOT NULL) AND (m.xdat_field_mapping_id IS NULL));


ALTER TABLE public.data_type_views_orphaned_field_sets OWNER TO xnat;

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

CREATE VIEW public.displayfields_cat_catalog AS
 SELECT search.cat_catalog_meta_data112 AS insert_date,
    search.table2_login AS insert_user,
    search.cat_catalog1 AS id,
    search.cat_catalog2 AS name,
    search.cat_catalog3 AS description,
    search.cat_catalog_meta_data109 AS quarantine_status
   FROM (( SELECT DISTINCT cat_catalog.cat_catalog_id AS cat_catalog6,
            table1.status AS cat_catalog_meta_data109,
            table1.insert_date AS cat_catalog_meta_data112,
            table2.login AS table2_login,
            cat_catalog.id AS cat_catalog1,
            cat_catalog.name AS cat_catalog2,
            cat_catalog.description AS cat_catalog3
           FROM ((public.cat_catalog cat_catalog
             LEFT JOIN public.cat_catalog_meta_data table1 ON ((cat_catalog.catalog_info = table1.meta_data_id)))
             LEFT JOIN public.xdat_user table2 ON ((table1.insert_user_xdat_user_id = table2.xdat_user_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.cat_catalog6
           FROM ( SELECT cat_catalog.cat_catalog_id AS cat_catalog6,
                    table1.insert_date AS cat_catalog_meta_data112
                   FROM (public.cat_catalog cat_catalog
                     LEFT JOIN public.cat_catalog_meta_data table1 ON ((cat_catalog.catalog_info = table1.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.cat_catalog6 = search.cat_catalog6)))
  ORDER BY search.cat_catalog_meta_data112;


ALTER TABLE public.displayfields_cat_catalog OWNER TO xnat;

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

CREATE VIEW public.displayfields_cat_dcmcatalog AS
 SELECT search.cat_catalog13 AS id,
    search.cat_catalog14 AS name,
    search.cat_catalog15 AS description,
    search.cat_dcmcatalog_meta_data136 AS insert_date,
    search.table3_login AS insert_user,
    search.cat_dcmcatalog1 AS dimensions_x,
    search.cat_dcmcatalog2 AS dimensions_y,
    search.cat_dcmcatalog3 AS dimensions_z,
    search.cat_dcmcatalog4 AS dimensions_volumes,
    search.cat_dcmcatalog5 AS voxelres_x,
    search.cat_dcmcatalog6 AS voxelres_y,
    search.cat_dcmcatalog7 AS voxelres_z,
    search.cat_dcmcatalog8 AS voxelres_units,
    search.cat_dcmcatalog9 AS orientation,
    search.cat_dcmcatalog10 AS uid,
    search.cat_dcmcatalog_meta_data133 AS quarantine_status
   FROM (( SELECT DISTINCT table0.cat_catalog_id AS cat_dcmcatalog0,
            table2.status AS cat_dcmcatalog_meta_data133,
            table0.id AS cat_catalog13,
            table0.name AS cat_catalog14,
            table0.description AS cat_catalog15,
            table2.insert_date AS cat_dcmcatalog_meta_data136,
            table3.login AS table3_login,
            cat_dcmcatalog.dimensions_x AS cat_dcmcatalog1,
            cat_dcmcatalog.dimensions_y AS cat_dcmcatalog2,
            cat_dcmcatalog.dimensions_z AS cat_dcmcatalog3,
            cat_dcmcatalog.dimensions_volumes AS cat_dcmcatalog4,
            cat_dcmcatalog.voxelres_x AS cat_dcmcatalog5,
            cat_dcmcatalog.voxelres_y AS cat_dcmcatalog6,
            cat_dcmcatalog.voxelres_z AS cat_dcmcatalog7,
            cat_dcmcatalog.voxelres_units AS cat_dcmcatalog8,
            cat_dcmcatalog.orientation AS cat_dcmcatalog9,
            cat_dcmcatalog.uid AS cat_dcmcatalog10
           FROM (((public.cat_dcmcatalog cat_dcmcatalog
             LEFT JOIN public.cat_catalog table0 ON ((cat_dcmcatalog.cat_catalog_id = table0.cat_catalog_id)))
             LEFT JOIN public.cat_dcmcatalog_meta_data table2 ON ((cat_dcmcatalog.dcmcatalog_info = table2.meta_data_id)))
             LEFT JOIN public.xdat_user table3 ON ((table2.insert_user_xdat_user_id = table3.xdat_user_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.cat_dcmcatalog0
           FROM ( SELECT table0.cat_catalog_id AS cat_dcmcatalog0,
                    table2.insert_date AS cat_dcmcatalog_meta_data136
                   FROM ((public.cat_dcmcatalog cat_dcmcatalog
                     LEFT JOIN public.cat_catalog table0 ON ((cat_dcmcatalog.cat_catalog_id = table0.cat_catalog_id)))
                     LEFT JOIN public.cat_dcmcatalog_meta_data table2 ON ((cat_dcmcatalog.dcmcatalog_info = table2.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.cat_dcmcatalog0 = search.cat_dcmcatalog0)))
  ORDER BY search.cat_catalog13;


ALTER TABLE public.displayfields_cat_dcmcatalog OWNER TO xnat;

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

CREATE VIEW public.displayfields_cat_entry AS
 SELECT search.cat_entry_meta_data58 AS insert_date,
    search.table2_login AS insert_user,
    search.cat_entry0 AS uri,
    search.cat_entry1 AS id,
    search.cat_entry2 AS name,
    search.cat_entry3 AS description,
    search.cat_entry4 AS format,
    search.cat_entry5 AS content,
    search.cat_entry6 AS cachepath,
    search.cat_entry7 AS createdtime,
    search.cat_entry8 AS createdby,
    search.cat_entry9 AS createdeventid,
    search.cat_entry10 AS modifiedtime,
    search.cat_entry11 AS modifiedby,
    search.cat_entry12 AS modifiedeventid,
    search.cat_entry13 AS digest,
    search.cat_entry_meta_data55 AS quarantine_status
   FROM (( SELECT DISTINCT cat_entry.cat_entry_id AS cat_entry16,
            table1.status AS cat_entry_meta_data55,
            table1.insert_date AS cat_entry_meta_data58,
            table2.login AS table2_login,
            cat_entry.uri AS cat_entry0,
            cat_entry.id AS cat_entry1,
            cat_entry.name AS cat_entry2,
            cat_entry.description AS cat_entry3,
            cat_entry.format AS cat_entry4,
            cat_entry.content AS cat_entry5,
            cat_entry.cachepath AS cat_entry6,
            cat_entry.createdtime AS cat_entry7,
            cat_entry.createdby AS cat_entry8,
            cat_entry.createdeventid AS cat_entry9,
            cat_entry.modifiedtime AS cat_entry10,
            cat_entry.modifiedby AS cat_entry11,
            cat_entry.modifiedeventid AS cat_entry12,
            cat_entry.digest AS cat_entry13
           FROM ((public.cat_entry cat_entry
             LEFT JOIN public.cat_entry_meta_data table1 ON ((cat_entry.entry_info = table1.meta_data_id)))
             LEFT JOIN public.xdat_user table2 ON ((table1.insert_user_xdat_user_id = table2.xdat_user_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.cat_entry16
           FROM ( SELECT cat_entry.cat_entry_id AS cat_entry16,
                    table1.insert_date AS cat_entry_meta_data58
                   FROM (public.cat_entry cat_entry
                     LEFT JOIN public.cat_entry_meta_data table1 ON ((cat_entry.entry_info = table1.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.cat_entry16 = search.cat_entry16)))
  ORDER BY search.cat_entry_meta_data58;


ALTER TABLE public.displayfields_cat_entry OWNER TO xnat;

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

CREATE TABLE public.prov_process (
    process_info integer,
    prov_process_id integer NOT NULL
);


ALTER TABLE public.prov_process OWNER TO xnat;

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

CREATE TABLE public.prov_process_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_process_meta_data OWNER TO xnat;

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

CREATE VIEW public.displayfields_prov_process AS
 SELECT search.prov_process_meta_data50 AS insert_date,
    search.table2_login AS insert_user,
    search.prov_process_meta_data47 AS quarantine_status
   FROM (( SELECT DISTINCT prov_process.prov_process_id AS prov_process1,
            table1.status AS prov_process_meta_data47,
            table1.insert_date AS prov_process_meta_data50,
            table2.login AS table2_login
           FROM ((public.prov_process prov_process
             LEFT JOIN public.prov_process_meta_data table1 ON ((prov_process.process_info = table1.meta_data_id)))
             LEFT JOIN public.xdat_user table2 ON ((table1.insert_user_xdat_user_id = table2.xdat_user_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.prov_process1
           FROM ( SELECT prov_process.prov_process_id AS prov_process1,
                    table1.insert_date AS prov_process_meta_data50
                   FROM (public.prov_process prov_process
                     LEFT JOIN public.prov_process_meta_data table1 ON ((prov_process.process_info = table1.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.prov_process1 = search.prov_process1)))
  ORDER BY search.prov_process_meta_data50;


ALTER TABLE public.displayfields_prov_process OWNER TO xnat;

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

CREATE TABLE public.scr_screeningassessment (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    rater character varying(255),
    comments text,
    pass character varying(255),
    screeningassessment_info integer
);


ALTER TABLE public.scr_screeningassessment OWNER TO xnat;

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

CREATE TABLE public.scr_screeningassessment_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_screeningassessment_meta_data OWNER TO xnat;

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

CREATE TABLE public.xdat_meta_element (
    element_name character varying(250),
    xdat_meta_element_id integer NOT NULL
);


ALTER TABLE public.xdat_meta_element OWNER TO xnat;

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

CREATE TABLE public.xnat_experimentdata (
    date date,
    "time" time without time zone,
    duration character varying(255),
    delay integer,
    delay_ref_expt_id character varying(255),
    note text,
    investigator_xnat_investigatordata_id integer,
    validation_xnat_validationdata_id integer,
    acquisition_site character varying(255),
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    project character varying(255),
    visit_id character varying(255),
    visit character varying(255),
    version integer,
    original character varying(255),
    protocol character varying(255),
    label character varying(255),
    extension integer,
    experimentdata_info integer
);


ALTER TABLE public.xnat_experimentdata OWNER TO xnat;

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

CREATE TABLE public.xnat_experimentdata_share (
    share character varying(255),
    label character varying(255),
    project character varying(255),
    visit character varying(255),
    protocol character varying(255),
    experimentdata_share_info integer,
    xnat_experimentdata_share_id integer NOT NULL,
    sharing_share_xnat_experimentda_id character varying(255)
);


ALTER TABLE public.xnat_experimentdata_share OWNER TO xnat;

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

CREATE VIEW public.scr_screeningassessment_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 = 'scr:screeningAssessment'::text)
  GROUP BY expt.id, expt.project;


ALTER TABLE public.scr_screeningassessment_projects OWNER TO xnat;

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

CREATE TABLE public.xnat_deriveddata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    provenance_prov_process_id integer,
    deriveddata_info integer
);


ALTER TABLE public.xnat_deriveddata OWNER TO xnat;

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

CREATE TABLE public.xnat_imageassessordata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    imagesession_id character varying(255),
    imageassessordata_info integer
);


ALTER TABLE public.xnat_imageassessordata OWNER TO xnat;

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

CREATE VIEW public.displayfields_scr_screeningassessment AS
 SELECT search.scr_screeningassessment0 AS expt_id,
    '/@WEBAPP/images/r.gif'::text AS rpt,
    search.xnat_experimentdata11 AS date,
    search.scr_screeningassessment_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata27, search.scr_screeningassessment0) AS label,
    search.table5_login AS insert_user,
    search.scr_screeningassessment_meta_data363 AS insert_date,
    search.xnat_experimentdata21 AS project,
    search.scr_screeningassessment1 AS rater,
    search.scr_screeningassessment2 AS comments,
    search.scr_screeningassessment3 AS pass,
    search.scr_screeningassessment_meta_data360 AS quarantine_status
   FROM (( SELECT DISTINCT table2.id AS scr_screeningassessment0,
            table4.status AS scr_screeningassessment_meta_data360,
            table2.date AS xnat_experimentdata11,
            table2.label AS xnat_experimentdata27,
            table5.login AS table5_login,
            table4.insert_date AS scr_screeningassessment_meta_data363,
            table2.project AS xnat_experimentdata21,
            scr_screeningassessment.rater AS scr_screeningassessment1,
            scr_screeningassessment.comments AS scr_screeningassessment2,
            scr_screeningassessment.pass AS scr_screeningassessment3,
            scr_screeningassessment_projects.projects AS scr_screeningassessment_projects_projects
           FROM ((((((public.scr_screeningassessment scr_screeningassessment
             LEFT JOIN public.xnat_imageassessordata table0 ON (((scr_screeningassessment.id)::text = (table0.id)::text)))
             LEFT JOIN public.xnat_deriveddata table1 ON (((table0.id)::text = (table1.id)::text)))
             LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))
             LEFT JOIN public.scr_screeningassessment_meta_data table4 ON ((scr_screeningassessment.screeningassessment_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.scr_screeningassessment_projects scr_screeningassessment_projects ON (((table2.id)::text = (scr_screeningassessment_projects.id)::text)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.scr_screeningassessment0
           FROM ( SELECT table2.id AS scr_screeningassessment0,
                    table2.date AS xnat_experimentdata11
                   FROM (((public.scr_screeningassessment scr_screeningassessment
                     LEFT JOIN public.xnat_imageassessordata table0 ON (((scr_screeningassessment.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_deriveddata 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.scr_screeningassessment0)::text = (search.scr_screeningassessment0)::text)))
  ORDER BY search.scr_screeningassessment0;


ALTER TABLE public.displayfields_scr_screeningassessment OWNER TO xnat;

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

CREATE TABLE public.val_protocoldata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    check_additionalval_val_additionalval_id integer,
    check_status character varying(255) DEFAULT ''::character varying NOT NULL,
    protocoldata_info integer
);


ALTER TABLE public.val_protocoldata OWNER TO xnat;

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

CREATE TABLE public.val_protocoldata_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_meta_data OWNER TO xnat;

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

CREATE VIEW public.val_protocoldata_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 = 'val:protocolData'::text)
  GROUP BY expt.id, expt.project;


ALTER TABLE public.val_protocoldata_projects OWNER TO xnat;

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

CREATE VIEW public.displayfields_val_protocoldata AS
 SELECT search.val_protocoldata0 AS expt_id,
    '/@WEBAPP/images/r.gif'::text AS rpt,
    search.xnat_experimentdata10 AS date,
    search.val_protocoldata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata26, search.val_protocoldata0) AS label,
    search.table5_login AS insert_user,
    search.val_protocoldata_meta_data466 AS insert_date,
    search.xnat_experimentdata20 AS project,
    search.val_protocoldata2 AS check_status,
    search.val_protocoldata_meta_data463 AS quarantine_status
   FROM (( SELECT DISTINCT table2.id AS val_protocoldata0,
            table4.status AS val_protocoldata_meta_data463,
            table2.date AS xnat_experimentdata10,
            table2.label AS xnat_experimentdata26,
            table5.login AS table5_login,
            table4.insert_date AS val_protocoldata_meta_data466,
            table2.project AS xnat_experimentdata20,
            val_protocoldata.check_status AS val_protocoldata2,
            val_protocoldata_projects.projects AS val_protocoldata_projects_projects
           FROM ((((((public.val_protocoldata val_protocoldata
             LEFT JOIN public.xnat_imageassessordata table0 ON (((val_protocoldata.id)::text = (table0.id)::text)))
             LEFT JOIN public.xnat_deriveddata table1 ON (((table0.id)::text = (table1.id)::text)))
             LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))
             LEFT JOIN public.val_protocoldata_meta_data table4 ON ((val_protocoldata.protocoldata_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.val_protocoldata_projects val_protocoldata_projects ON (((table2.id)::text = (val_protocoldata_projects.id)::text)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.val_protocoldata0
           FROM ( SELECT table2.id AS val_protocoldata0,
                    table2.date AS xnat_experimentdata10
                   FROM (((public.val_protocoldata val_protocoldata
                     LEFT JOIN public.xnat_imageassessordata table0 ON (((val_protocoldata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_deriveddata 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.val_protocoldata0)::text = (search.val_protocoldata0)::text)))
  ORDER BY search.val_protocoldata0;


ALTER TABLE public.displayfields_val_protocoldata OWNER TO xnat;

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

CREATE TABLE public.wrk_workflowdata (
    executionenvironment_wrk_abstractexecutionenvironment_id integer,
    comments text,
    details text,
    justification text,
    description character varying(255),
    src character varying(255),
    type character varying(255),
    category character varying(255),
    data_type character varying(255) DEFAULT ''::character varying NOT NULL,
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    externalid character varying(255),
    current_step_launch_time timestamp without time zone,
    current_step_id character varying(255),
    status character varying(255) DEFAULT ''::character varying NOT NULL,
    create_user character varying(255),
    pipeline_name character varying(255) DEFAULT ''::character varying NOT NULL,
    next_step_id character varying(255),
    step_description character varying(255),
    launch_time timestamp without time zone DEFAULT now() NOT NULL,
    percentagecomplete character varying(255),
    jobid character varying(255),
    workflowdata_info integer,
    wrk_workflowdata_id integer NOT NULL
);


ALTER TABLE public.wrk_workflowdata OWNER TO xnat;

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

CREATE VIEW public.session_label_view AS
 SELECT DISTINCT ex.label AS session_label,
    ex.project,
    wf.wrk_workflowdata_id AS workflow_id
   FROM (public.wrk_workflowdata wf
     LEFT JOIN public.xnat_experimentdata ex ON (((ex.id)::text = (wf.id)::text)));


ALTER TABLE public.session_label_view OWNER TO xnat;

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

CREATE TABLE public.xnat_subjectdata (
    investigator_xnat_investigatordata_id integer,
    demographics_xnat_abstractdemographicdata_id integer,
    metadata_xnat_abstractsubjectmetadata_id integer,
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    project character varying(255),
    _group character varying(255),
    label character varying(255),
    src character varying(255),
    initials character varying(255),
    subjectdata_info integer
);


ALTER TABLE public.xnat_subjectdata OWNER TO xnat;

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

CREATE VIEW public.subject_label_view AS
 SELECT DISTINCT sub.label AS subject_label,
    wf.wrk_workflowdata_id AS workflow_id
   FROM (public.wrk_workflowdata wf
     LEFT JOIN public.xnat_subjectdata sub ON (((sub.id)::text = (wf.id)::text)));


ALTER TABLE public.subject_label_view OWNER TO xnat;

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

CREATE TABLE public.wrk_workflowdata_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_workflowdata_meta_data OWNER TO xnat;

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

CREATE VIEW public.userfullname_view AS
 SELECT wrk.wrk_workflowdata_id AS workflow_id,
    u.login,
    u.firstname,
    u.lastname,
    (((u.firstname)::text || ' '::text) || (u.lastname)::text) AS userfullname,
    u.email
   FROM ((public.wrk_workflowdata wrk
     LEFT JOIN public.wrk_workflowdata_meta_data meta ON ((wrk.workflowdata_info = meta.meta_data_id)))
     LEFT JOIN public.xdat_user u ON ((meta.insert_user_xdat_user_id = u.xdat_user_id)));


ALTER TABLE public.userfullname_view OWNER TO xnat;

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

CREATE VIEW public.displayfields_wrk_workflowdata AS
 SELECT search.wrk_workflowdata8 AS data_type,
    search.wrk_workflowdata22 AS workflow_id,
    search.wrk_workflowdata9 AS id,
    search.wrk_workflowdata10 AS externalid,
    search.wrk_workflowdata11 AS current_step_launch_time,
    search.wrk_workflowdata12 AS current_step_id,
    (('<B>'::text ||
        CASE search.wrk_workflowdata13
            WHEN 'Complete'::text THEN '<FONT COLOR=green>Complete</FONT>'::text
            WHEN 'In Progress'::text THEN '<FONT COLOR=yellow>In Progress</FONT>'::text
            WHEN 'Running'::text THEN '<FONT COLOR=yellow>Running</FONT>'::text
            WHEN 'Queued'::text THEN '<FONT COLOR=orange>Queued</FONT>'::text
            WHEN 'Failed'::text THEN '<FONT COLOR=red>Failed</FONT>'::text
            ELSE (('<FONT COLOR=orange>'::text || (search.wrk_workflowdata13)::text) || '</FONT>'::text)
        END) || '</B>'::text) AS status,
    search.wrk_workflowdata15 AS pipeline_name,
    search.wrk_workflowdata16 AS next_step_id,
    search.wrk_workflowdata17 AS step_description,
    search.wrk_workflowdata18 AS launch_time,
    search.wrk_workflowdata19 AS percentagecomplete,
    search.wrk_workflowdata20 AS job_id,
    COALESCE(search.wrk_workflowdata_meta_data41, search.wrk_workflowdata_meta_data45) AS last_modified,
    search.session_label_view_session_label AS session_label,
    search.session_label_view_project AS project,
    search.subject_label_view_subject_label AS subject_label,
    search.userfullname_view_userfullname AS userfullname,
    search.userfullname_view_login AS userlogin,
    search.userfullname_view_email AS useremail,
    search.wrk_workflowdata_meta_data42 AS quarantine_status
   FROM (( SELECT DISTINCT wrk_workflowdata.wrk_workflowdata_id AS wrk_workflowdata22,
            table1.status AS wrk_workflowdata_meta_data42,
            wrk_workflowdata.data_type AS wrk_workflowdata8,
            wrk_workflowdata.id AS wrk_workflowdata9,
            wrk_workflowdata.externalid AS wrk_workflowdata10,
            wrk_workflowdata.current_step_launch_time AS wrk_workflowdata11,
            wrk_workflowdata.current_step_id AS wrk_workflowdata12,
            wrk_workflowdata.status AS wrk_workflowdata13,
            wrk_workflowdata.pipeline_name AS wrk_workflowdata15,
            wrk_workflowdata.next_step_id AS wrk_workflowdata16,
            wrk_workflowdata.step_description AS wrk_workflowdata17,
            wrk_workflowdata.launch_time AS wrk_workflowdata18,
            wrk_workflowdata.percentagecomplete AS wrk_workflowdata19,
            wrk_workflowdata.jobid AS wrk_workflowdata20,
            table1.insert_date AS wrk_workflowdata_meta_data45,
            table1.last_modified AS wrk_workflowdata_meta_data41,
            session_label_view.session_label AS session_label_view_session_label,
            session_label_view.project AS session_label_view_project,
            subject_label_view.subject_label AS subject_label_view_subject_label,
            userfullname_view.userfullname AS userfullname_view_userfullname,
            userfullname_view.login AS userfullname_view_login,
            userfullname_view.email AS userfullname_view_email
           FROM ((((public.wrk_workflowdata wrk_workflowdata
             LEFT JOIN public.wrk_workflowdata_meta_data table1 ON ((wrk_workflowdata.workflowdata_info = table1.meta_data_id)))
             LEFT JOIN public.session_label_view session_label_view ON ((wrk_workflowdata.wrk_workflowdata_id = session_label_view.workflow_id)))
             LEFT JOIN public.subject_label_view subject_label_view ON ((wrk_workflowdata.wrk_workflowdata_id = subject_label_view.workflow_id)))
             LEFT JOIN public.userfullname_view userfullname_view ON ((wrk_workflowdata.wrk_workflowdata_id = userfullname_view.workflow_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.wrk_workflowdata22
           FROM ( SELECT wrk_workflowdata.wrk_workflowdata_id AS wrk_workflowdata22,
                    table1.insert_date AS wrk_workflowdata_meta_data45
                   FROM (public.wrk_workflowdata wrk_workflowdata
                     LEFT JOIN public.wrk_workflowdata_meta_data table1 ON ((wrk_workflowdata.workflowdata_info = table1.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.wrk_workflowdata22 = search.wrk_workflowdata22)))
  ORDER BY search.wrk_workflowdata8;


ALTER TABLE public.displayfields_wrk_workflowdata OWNER TO xnat;

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

CREATE TABLE public.xdat_element_security (
    element_name character varying(255) DEFAULT ''::character varying NOT NULL,
    secondary_password integer,
    secure_ip integer,
    secure integer,
    browse integer,
    sequence integer,
    quarantine integer,
    pre_load integer,
    searchable integer,
    secure_read integer,
    secure_edit integer,
    secure_create integer,
    secure_delete integer,
    accessible integer,
    usage character varying(255),
    singular character varying(255),
    plural character varying(255),
    category character varying(255),
    code character varying(255),
    element_security_info integer,
    element_security_set_element_se_xdat_security_id integer
);


ALTER TABLE public.xdat_element_security OWNER TO xnat;

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

CREATE TABLE public.xdat_element_security_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_meta_data OWNER TO xnat;

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

CREATE VIEW public.displayfields_xdat_element_security AS
 SELECT search.xdat_element_security0 AS element_name,
        CASE search.xdat_element_security3
            WHEN 1 THEN '/@WEBAPP/images/cg.gif'::text
            WHEN 0 THEN '/@WEBAPP/images/cr.gif'::text
            ELSE NULL::text
        END AS secure,
        CASE search.xdat_element_security4
            WHEN 1 THEN '/@WEBAPP/images/cg.gif'::text
            WHEN 0 THEN '/@WEBAPP/images/cr.gif'::text
            ELSE NULL::text
        END AS browse,
    search.xdat_element_security5 AS sequence,
    search.xdat_element_security_meta_data86 AS quarantine_status
   FROM (( SELECT DISTINCT xdat_element_security.element_name AS xdat_element_security0,
            table1.status AS xdat_element_security_meta_data86,
            xdat_element_security.secure AS xdat_element_security3,
            xdat_element_security.browse AS xdat_element_security4,
            xdat_element_security.sequence AS xdat_element_security5,
            table1.insert_date AS xdat_element_security_meta_data89
           FROM (public.xdat_element_security xdat_element_security
             LEFT JOIN public.xdat_element_security_meta_data table1 ON ((xdat_element_security.element_security_info = table1.meta_data_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xdat_element_security0
           FROM ( SELECT xdat_element_security.element_name AS xdat_element_security0,
                    table1.insert_date AS xdat_element_security_meta_data89
                   FROM (public.xdat_element_security xdat_element_security
                     LEFT JOIN public.xdat_element_security_meta_data table1 ON ((xdat_element_security.element_security_info = table1.meta_data_id)))) where_clause_1) where_clause ON (((where_clause.xdat_element_security0)::text = (search.xdat_element_security0)::text)))
  ORDER BY search.xdat_element_security0;


ALTER TABLE public.displayfields_xdat_element_security OWNER TO xnat;

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

CREATE TABLE public.xdat_infoentry (
    date timestamp without time zone,
    title character varying(255),
    description text,
    link character varying(255),
    infoentry_info integer,
    xdat_infoentry_id integer NOT NULL
);


ALTER TABLE public.xdat_infoentry OWNER TO xnat;

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

CREATE TABLE public.xdat_infoentry_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_infoentry_meta_data OWNER TO xnat;

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

CREATE VIEW public.displayfields_xdat_infoentry AS
 SELECT search.xdat_infoentry_meta_data11 AS insert_date,
    search.table2_login AS insert_user,
    search.xdat_infoentry0 AS date,
    search.xdat_infoentry1 AS title,
    search.xdat_infoentry2 AS description,
    search.xdat_infoentry3 AS link,
    search.xdat_infoentry_meta_data8 AS quarantine_status
   FROM (( SELECT DISTINCT xdat_infoentry.xdat_infoentry_id AS xdat_infoentry5,
            table1.status AS xdat_infoentry_meta_data8,
            table1.insert_date AS xdat_infoentry_meta_data11,
            table2.login AS table2_login,
            xdat_infoentry.date AS xdat_infoentry0,
            xdat_infoentry.title AS xdat_infoentry1,
            xdat_infoentry.description AS xdat_infoentry2,
            xdat_infoentry.link AS xdat_infoentry3
           FROM ((public.xdat_infoentry xdat_infoentry
             LEFT JOIN public.xdat_infoentry_meta_data table1 ON ((xdat_infoentry.infoentry_info = table1.meta_data_id)))
             LEFT JOIN public.xdat_user table2 ON ((table1.insert_user_xdat_user_id = table2.xdat_user_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xdat_infoentry5
           FROM ( SELECT xdat_infoentry.xdat_infoentry_id AS xdat_infoentry5,
                    table1.insert_date AS xdat_infoentry_meta_data11
                   FROM (public.xdat_infoentry xdat_infoentry
                     LEFT JOIN public.xdat_infoentry_meta_data table1 ON ((xdat_infoentry.infoentry_info = table1.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.xdat_infoentry5 = search.xdat_infoentry5)))
  ORDER BY search.xdat_infoentry_meta_data11;


ALTER TABLE public.displayfields_xdat_infoentry OWNER TO xnat;

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

CREATE TABLE public.xdat_newsentry (
    date timestamp without time zone,
    title character varying(255),
    description text,
    link character varying(255),
    newsentry_info integer,
    xdat_newsentry_id integer NOT NULL
);


ALTER TABLE public.xdat_newsentry OWNER TO xnat;

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

CREATE TABLE public.xdat_newsentry_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_newsentry_meta_data OWNER TO xnat;

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

CREATE VIEW public.displayfields_xdat_newsentry AS
 SELECT search.xdat_newsentry_meta_data11 AS insert_date,
    search.table2_login AS insert_user,
    search.xdat_newsentry0 AS date,
    search.xdat_newsentry1 AS title,
    search.xdat_newsentry2 AS description,
    search.xdat_newsentry3 AS link,
    search.xdat_newsentry_meta_data8 AS quarantine_status
   FROM (( SELECT DISTINCT xdat_newsentry.xdat_newsentry_id AS xdat_newsentry5,
            table1.status AS xdat_newsentry_meta_data8,
            table1.insert_date AS xdat_newsentry_meta_data11,
            table2.login AS table2_login,
            xdat_newsentry.date AS xdat_newsentry0,
            xdat_newsentry.title AS xdat_newsentry1,
            xdat_newsentry.description AS xdat_newsentry2,
            xdat_newsentry.link AS xdat_newsentry3
           FROM ((public.xdat_newsentry xdat_newsentry
             LEFT JOIN public.xdat_newsentry_meta_data table1 ON ((xdat_newsentry.newsentry_info = table1.meta_data_id)))
             LEFT JOIN public.xdat_user table2 ON ((table1.insert_user_xdat_user_id = table2.xdat_user_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xdat_newsentry5
           FROM ( SELECT xdat_newsentry.xdat_newsentry_id AS xdat_newsentry5,
                    table1.insert_date AS xdat_newsentry_meta_data11
                   FROM (public.xdat_newsentry xdat_newsentry
                     LEFT JOIN public.xdat_newsentry_meta_data table1 ON ((xdat_newsentry.newsentry_info = table1.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.xdat_newsentry5 = search.xdat_newsentry5)))
  ORDER BY search.xdat_newsentry_meta_data11;


ALTER TABLE public.displayfields_xdat_newsentry OWNER TO xnat;


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

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


ALTER TABLE public.xdat_a_xdat_action_type_allowe_xdat_role_type OWNER TO xnat;


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

CREATE TABLE public.xdat_role_type (
    role_name character varying(255) DEFAULT ''::character varying NOT NULL,
    description character varying(255),
    sequence integer,
    role_type_info integer,
    roles_role_xdat_security_xdat_security_id integer
);


ALTER TABLE public.xdat_role_type OWNER TO xnat;

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

CREATE VIEW public.role_count AS
 SELECT role.role_name AS role1,
    count(map.xdat_a_xdat_action_type_allowe_xdat_role_type_id) AS action_count
   FROM (public.xdat_role_type role
     LEFT JOIN public.xdat_a_xdat_action_type_allowe_xdat_role_type map ON (((role.role_name)::text = (map.xdat_role_type_role_name)::text)))
  GROUP BY role.role_name;


ALTER TABLE public.role_count OWNER TO xnat;

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

CREATE TABLE public.xdat_role_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_role_type_meta_data OWNER TO xnat;

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

CREATE VIEW public.displayfields_xdat_role_type AS
 SELECT search.xdat_role_type0 AS role_name,
    '/@WEBAPP/images/r.gif'::text AS rpt,
        CASE search.xdat_role_type_meta_data24
            WHEN 'active'::text THEN '/@WEBAPP/images/cg.gif'::text
            ELSE '/@WEBAPP/images/cr.gif'::text
        END AS active,
    search.xdat_role_type1 AS description,
    search.role_count_action_count AS action_count,
    search.xdat_role_type2 AS seq,
    search.xdat_role_type_meta_data24 AS quarantine_status
   FROM (( SELECT DISTINCT xdat_role_type.role_name AS xdat_role_type0,
            table1.status AS xdat_role_type_meta_data24,
            xdat_role_type.description AS xdat_role_type1,
            xdat_role_type.sequence AS xdat_role_type2,
            table1.insert_date AS xdat_role_type_meta_data27,
            role_count.action_count AS role_count_action_count
           FROM ((public.xdat_role_type xdat_role_type
             LEFT JOIN public.xdat_role_type_meta_data table1 ON ((xdat_role_type.role_type_info = table1.meta_data_id)))
             LEFT JOIN public.role_count role_count ON (((xdat_role_type.role_name)::text = (role_count.role1)::text)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xdat_role_type0
           FROM ( SELECT xdat_role_type.role_name AS xdat_role_type0,
                    table1.insert_date AS xdat_role_type_meta_data27
                   FROM (public.xdat_role_type xdat_role_type
                     LEFT JOIN public.xdat_role_type_meta_data table1 ON ((xdat_role_type.role_type_info = table1.meta_data_id)))) where_clause_1) where_clause ON (((where_clause.xdat_role_type0)::text = (search.xdat_role_type0)::text)))
  ORDER BY search.xdat_role_type0;


ALTER TABLE public.displayfields_xdat_role_type OWNER TO xnat;

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

CREATE TABLE public.xdat_stored_search (
    root_element_name character varying(255),
    sort_by_element_name character varying(255),
    sort_by_field_id character varying(255),
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    description character varying(255),
    layeredsequence character varying(255),
    allow_diff_columns integer,
    secure integer,
    brief_description character varying(255),
    tag character varying(255),
    extension integer,
    stored_search_info integer
);


ALTER TABLE public.xdat_stored_search OWNER TO xnat;

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

CREATE TABLE public.xdat_stored_search_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_stored_search_meta_data OWNER TO xnat;

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

CREATE VIEW public.displayfields_xdat_stored_search AS
 SELECT search.xdat_stored_search0 AS root_element_name,
    search.xdat_stored_search1 AS sort_by_element_name,
    search.xdat_stored_search2 AS sort_by_field_id,
    search.xdat_stored_search5 AS layered_sequence,
    search.xdat_stored_search3 AS id,
    search.xdat_stored_search4 AS description,
    search.xdat_stored_search8 AS brief_description,
    search.xdat_stored_search_meta_data107 AS quarantine_status
   FROM (( SELECT DISTINCT xdat_stored_search.id AS xdat_stored_search3,
            table1.status AS xdat_stored_search_meta_data107,
            xdat_stored_search.root_element_name AS xdat_stored_search0,
            xdat_stored_search.sort_by_element_name AS xdat_stored_search1,
            xdat_stored_search.sort_by_field_id AS xdat_stored_search2,
            xdat_stored_search.layeredsequence AS xdat_stored_search5,
            xdat_stored_search.description AS xdat_stored_search4,
            xdat_stored_search.brief_description AS xdat_stored_search8,
            table1.insert_date AS xdat_stored_search_meta_data110
           FROM (public.xdat_stored_search xdat_stored_search
             LEFT JOIN public.xdat_stored_search_meta_data table1 ON ((xdat_stored_search.stored_search_info = table1.meta_data_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xdat_stored_search3
           FROM ( SELECT xdat_stored_search.id AS xdat_stored_search3,
                    table1.insert_date AS xdat_stored_search_meta_data110
                   FROM (public.xdat_stored_search xdat_stored_search
                     LEFT JOIN public.xdat_stored_search_meta_data table1 ON ((xdat_stored_search.stored_search_info = table1.meta_data_id)))) where_clause_1) where_clause ON (((where_clause.xdat_stored_search3)::text = (search.xdat_stored_search3)::text)))
  ORDER BY search.xdat_stored_search0;


ALTER TABLE public.displayfields_xdat_stored_search OWNER TO xnat;

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

CREATE TABLE public.xdat_user_login (
    login_date timestamp without time zone,
    logout_date timestamp without time zone,
    session_id character varying(255),
    ip_address character varying(255),
    user_xdat_user_id integer DEFAULT 0 NOT NULL,
    user_login_info integer,
    xdat_user_login_id integer NOT NULL
);


ALTER TABLE public.xdat_user_login OWNER TO xnat;

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

CREATE VIEW public.last_login AS
 SELECT DISTINCT ON (xdat_user_login.user_xdat_user_id) xdat_user_login.user_xdat_user_id AS user_id,
    xdat_user_login.login_date
   FROM public.xdat_user_login
  ORDER BY xdat_user_login.user_xdat_user_id, xdat_user_login.login_date DESC;


ALTER TABLE public.last_login OWNER TO xnat;

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

CREATE TABLE public.xdat_user_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_user_meta_data OWNER TO xnat;

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

CREATE VIEW public.displayfields_xdat_user AS
 SELECT search.xdat_user0 AS login,
    '/@WEBAPP/images/su.jpg'::text AS su,
    '/@WEBAPP/images/r.gif'::text AS rpt,
        CASE search.xdat_user_meta_data140
            WHEN 'active'::text THEN '/@WEBAPP/images/cg.gif'::text
            ELSE '/@WEBAPP/images/cr.gif'::text
        END AS active,
    search.xdat_user1 AS first,
    search.xdat_user2 AS last,
    (((search.xdat_user2)::text || ', '::text) || (search.xdat_user1)::text) AS first_last,
    search.xdat_user3 AS email,
    (search.last_login_login_date)::character varying AS last_login,
        CASE search.xdat_user7
            WHEN 1 THEN '/@WEBAPP/images/cg.gif'::text
            WHEN 0 THEN '/@WEBAPP/images/cr.gif'::text
            ELSE NULL::text
        END AS enabled,
    search.xdat_user_meta_data140 AS quarantine_status
   FROM (( SELECT DISTINCT xdat_user.xdat_user_id AS xdat_user11,
            table1.status AS xdat_user_meta_data140,
            xdat_user.login AS xdat_user0,
            xdat_user.firstname AS xdat_user1,
            xdat_user.lastname AS xdat_user2,
            xdat_user.email AS xdat_user3,
            xdat_user.enabled AS xdat_user7,
            table1.insert_date AS xdat_user_meta_data143,
            last_login.login_date AS last_login_login_date
           FROM ((public.xdat_user xdat_user
             LEFT JOIN public.xdat_user_meta_data table1 ON ((xdat_user.user_info = table1.meta_data_id)))
             LEFT JOIN public.last_login last_login ON ((xdat_user.xdat_user_id = last_login.user_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xdat_user11
           FROM ( SELECT xdat_user.xdat_user_id AS xdat_user11,
                    table1.insert_date AS xdat_user_meta_data143
                   FROM (public.xdat_user xdat_user
                     LEFT JOIN public.xdat_user_meta_data table1 ON ((xdat_user.user_info = table1.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.xdat_user11 = search.xdat_user11)))
  ORDER BY search.xdat_user0;


ALTER TABLE public.displayfields_xdat_user OWNER TO xnat;

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

CREATE TABLE public.xdat_usergroup_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_usergroup_meta_data OWNER TO xnat;

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

CREATE VIEW public.displayfields_xdat_usergroup AS
 SELECT search.xdat_usergroup0 AS id,
    search.xdat_usergroup1 AS display_name,
    search.xdat_usergroup_meta_data83 AS quarantine_status
   FROM (( SELECT DISTINCT xdat_usergroup.xdat_usergroup_id AS xdat_usergroup4,
            table1.status AS xdat_usergroup_meta_data83,
            xdat_usergroup.id AS xdat_usergroup0,
            xdat_usergroup.displayname AS xdat_usergroup1,
            table1.insert_date AS xdat_usergroup_meta_data86
           FROM (public.xdat_usergroup xdat_usergroup
             LEFT JOIN public.xdat_usergroup_meta_data table1 ON ((xdat_usergroup.usergroup_info = table1.meta_data_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xdat_usergroup4
           FROM ( SELECT xdat_usergroup.xdat_usergroup_id AS xdat_usergroup4,
                    table1.insert_date AS xdat_usergroup_meta_data86
                   FROM (public.xdat_usergroup xdat_usergroup
                     LEFT JOIN public.xdat_usergroup_meta_data table1 ON ((xdat_usergroup.usergroup_info = table1.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.xdat_usergroup4 = search.xdat_usergroup4)))
  ORDER BY search.xdat_usergroup0;


ALTER TABLE public.displayfields_xdat_usergroup OWNER TO xnat;

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

CREATE TABLE public.xnat_a_scidresearchdata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    administrator character varying(255),
    moodepisodes_currentmajordepressiveepisode integer,
    moodepisodes_pastmajordepressiveepisode integer,
    moodepisodes_currentmanicepisode integer,
    moodepisodes_pastmanicepisode integer,
    moodepisodes_currenthypomanicepisode integer,
    moodepisodes_pasthypomanicepisode integer,
    moodepisodes_currentdysthmicepisode integer,
    moodepisodes_currentmooddisorderduetomedicalcondition integer,
    moodepisodes_pastmooddisorderduetomedicalcondition integer,
    moodepisodes_currentsubstanceinducedmooddisorder integer,
    moodepisodes_pastsubstanceinducedmooddisorder integer,
    psychoticsymptoms_currentdelusions integer,
    psychoticsymptoms_pastdelusions integer,
    psychoticsymptoms_currenthallucinations integer,
    psychoticsymptoms_pasthallucinations integer,
    psychoticsymptoms_currentdisorganizedspeechbehavior integer,
    psychoticsymptoms_pastdisorganizedspeechbehavior integer,
    psychoticsymptoms_currentcatatonicbehavior integer,
    psychoticsymptoms_pastcatatonicbehavior integer,
    psychoticsymptoms_currentnegativesymptoms integer,
    psychoticsymptoms_pastnegativesymptoms integer,
    psychoticdisorders_currentschizophrenia integer,
    psychoticdisorders_pastschizophrenia integer,
    psychoticdisorders_currentparanoidtype integer,
    psychoticdisorders_pastparanoidtype integer,
    psychoticdisorders_currentcatatonictype integer,
    psychoticdisorders_pastcatatonictype integer,
    psychoticdisorders_currentdisorganizedtype integer,
    psychoticdisorders_pastdisorganizedtype integer,
    psychoticdisorders_currentundifferentiatedtype integer,
    psychoticdisorders_pastundifferentiatedtype integer,
    psychoticdisorders_currentresidualtype integer,
    psychoticdisorders_pastresidualtype integer,
    psychoticdisorders_currentschizophreniformdisorder integer,
    psychoticdisorders_pastschizophreniformdisorder integer,
    psychoticdisorders_currentschizoaffectivedisorder integer,
    psychoticdisorders_pastschizoaffectivedisorder integer,
    psychoticdisorders_currentdelusionaldisorder integer,
    psychoticdisorders_pastdelusionaldisorder integer,
    psychoticdisorders_currentbriefpsychoticdisorder integer,
    psychoticdisorders_pastbriefpsychoticdisorder integer,
    psychoticdisorders_currentpsychoticdisorderduetomedicalconditio integer,
    psychoticdisorders_pastpsychoticdisorderduetomedicalcondition integer,
    psychoticdisorders_currentsubstanceinducedpsychoticdisorder integer,
    psychoticdisorders_pastsubstanceinducedpsychoticdisorder integer,
    psychoticdisorders_currentpsychoticdisordernos integer,
    psychoticdisorders_pastpsychoticdisordernos integer,
    mooddisorders_currentbipolar1disorder integer,
    mooddisorders_pastbipolar1disorder integer,
    mooddisorders_currentbipolar2disorder integer,
    mooddisorders_pastbipolar2disorder integer,
    mooddisorders_currentotherbipolardisorder integer,
    mooddisorders_pastotherbipolardisorder integer,
    mooddisorders_currentmajordepressivedisorder integer,
    mooddisorders_pastmajordepressivedisorder integer,
    mooddisorders_currentdepressivedisordernos integer,
    mooddisorders_pastdepressivedisordernos integer,
    substanceusedisorders_currentalcoholdependence integer,
    substanceusedisorders_pastalcoholdependence integer,
    substanceusedisorders_currentalcoholabuse integer,
    substanceusedisorders_pastalcoholabuse integer,
    substanceusedisorders_currentamphetaminedependence integer,
    substanceusedisorders_pastamphetaminedependence integer,
    substanceusedisorders_currentamphetamineabuse integer,
    substanceusedisorders_pastamphetamineabuse integer,
    substanceusedisorders_currentcannabisdependence integer,
    substanceusedisorders_pastcannabisdependence integer,
    substanceusedisorders_currentcannabisabuse integer,
    substanceusedisorders_pastcannabisabuse integer,
    substanceusedisorders_currentcocainedependence integer,
    substanceusedisorders_pastcocainedependence integer,
    substanceusedisorders_currentcocaineabuse integer,
    substanceusedisorders_pastcocaineabuse integer,
    substanceusedisorders_currenthallucinogendependence integer,
    substanceusedisorders_pasthallucinogendependence integer,
    substanceusedisorders_currenthallucinogenabuse integer,
    substanceusedisorders_pasthallucinogenabuse integer,
    substanceusedisorders_currentopioiddependence integer,
    substanceusedisorders_pastopioiddependence integer,
    substanceusedisorders_currentopioidabuse integer,
    substanceusedisorders_pastopioidabuse integer,
    substanceusedisorders_currentphencyclidinedependence integer,
    substanceusedisorders_pastphencyclidinedependence integer,
    substanceusedisorders_currentphencyclidineabuse integer,
    substanceusedisorders_pastphencyclidineabuse integer,
    substanceusedisorders_currentsedativehypnoticanxiolyticdependen integer,
    substanceusedisorders_pastsedativehypnoticanxiolyticdependence integer,
    substanceusedisorders_currentsedativehypnoticanxiolyticabuse integer,
    substanceusedisorders_pastsedativehypnoticanxiolyticabuse integer,
    substanceusedisorders_currentpolysubstancedependence integer,
    substanceusedisorders_pastpolysubstancedependence integer,
    substanceusedisorders_currentotherorunknowndependence integer,
    substanceusedisorders_pastotherorunknowndependence integer,
    substanceusedisorders_currentotherorunknownabuse integer,
    substanceusedisorders_pastotherorunknownabuse integer,
    anxietydisorders_currentpanicwithagoraphobia integer,
    anxietydisorders_pastpanicwithagoraphobia integer,
    anxietydisorders_currentpanicwithoutagoraphobia integer,
    anxietydisorders_pastpanicwithoutagoraphobia integer,
    anxietydisorders_currentagoraphobiawithoutpanichx integer,
    anxietydisorders_pastagoraphobiawithoutpanichx integer,
    anxietydisorders_currentsocialphobia integer,
    anxietydisorders_pastsocialphobia integer,
    anxietydisorders_currentspecificphobia integer,
    anxietydisorders_pastspecificphobia integer,
    anxietydisorders_currentocd integer,
    anxietydisorders_pastocd integer,
    anxietydisorders_currentptsd integer,
    anxietydisorders_pastptsd integer,
    anxietydisorders_currentgeneralizedanxietydisorder integer,
    anxietydisorders_currentanxietyduetomedicalcondition integer,
    anxietydisorders_pastanxietyduetomedicalcondition integer,
    anxietydisorders_currentsubstanceinducedanxietydisorder integer,
    anxietydisorders_pastsubstanceinducedanxietydisorder integer,
    anxietydisorders_currentanxietydisordernos integer,
    anxietydisorders_pastanxietydisordernos integer,
    somatoformdisorders_somatizationdisorder integer,
    somatoformdisorders_undifferentiatedsomatformdisorder integer,
    somatoformdisorders_paindisorder integer,
    somatoformdisorders_hypochondriasis integer,
    somatoformdisorders_bodydysmorphicdisorder integer,
    eatingdisorders_currentanorexianervosa integer,
    eatingdisorders_pastanorexianervosa integer,
    eatingdisorders_currentbulimianervosa integer,
    eatingdisorders_pastbulimianervosa integer,
    eatingdisorders_currentbingeeatingdisorder integer,
    eatingdisorders_pastbingeeatingdisorder integer,
    adjustmentdisorder integer,
    optional_currentacutestressdisorder integer,
    optional_pastacutestressdisorder integer,
    optional_currentminordepressivedisorder integer,
    optional_pastminordepressivedisorder integer,
    optional_currentmixedanxietydepressivedisorder integer,
    optional_pastmixedanxietydepressivedisorder integer,
    optional_pastsympomaticdetails character varying(255),
    scidresearchdata_info integer
);


ALTER TABLE public.xnat_a_scidresearchdata OWNER TO xnat;

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

CREATE TABLE public.xnat_a_scidresearchdata_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_a_scidresearchdata_meta_data OWNER TO xnat;

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

CREATE VIEW public.xnat_a_scidresearchdata_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_a:scidResearchData'::text)
  GROUP BY expt.id, expt.project;


ALTER TABLE public.xnat_a_scidresearchdata_projects OWNER TO xnat;

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

CREATE TABLE public.xnat_abstractdemographicdata (
    extension integer,
    abstractdemographicdata_info integer,
    xnat_abstractdemographicdata_id integer NOT NULL
);


ALTER TABLE public.xnat_abstractdemographicdata OWNER TO xnat;

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

CREATE TABLE public.xnat_demographicdata (
    xnat_abstractdemographicdata_id integer DEFAULT 0 NOT NULL,
    dob date,
    yob integer,
    age integer,
    gender character varying(255),
    handedness character varying(255),
    ses integer,
    employment integer,
    education integer,
    educationdesc character varying(255),
    race character varying(255),
    race2 character varying(255),
    race3 character varying(255),
    race4 character varying(255),
    race5 character varying(255),
    race6 character varying(255),
    ethnicity character varying(255),
    weight double precision,
    weight_units character varying(255),
    height double precision,
    height_units character varying(255),
    gestational_age double precision,
    post_menstrual_age double precision,
    birth_weight double precision,
    demographicdata_info integer
);


ALTER TABLE public.xnat_demographicdata OWNER TO xnat;

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

CREATE TABLE public.xnat_demographicdata_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_demographicdata_meta_data OWNER TO xnat;

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

CREATE TABLE public.xnat_subjectassessordata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    subject_id character varying(255),
    age double precision,
    subjectassessordata_info integer
);


ALTER TABLE public.xnat_subjectassessordata OWNER TO xnat;

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

CREATE TABLE public.xnat_subjectdata_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_subjectdata_meta_data OWNER TO xnat;

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

CREATE VIEW public.displayfields_xnat_a_scidresearchdata AS
 SELECT search.xnat_subjectassessordata139 AS subject_id,
    search.xnat_a_scidresearchdata0 AS expt_id,
    '/@WEBAPP/images/r.gif'::text AS rpt,
    search.xnat_experimentdata142 AS date,
    (COALESCE((floor(((((search.xnat_experimentdata142 - search.xnat_demographicdata_xnat_demographicdata1))::real / (365)::double precision))::numeric))::double precision, floor((date_part('year'::text, search.xnat_experimentdata142) - (search.xnat_demographicdata_xnat_demographicdata2)::double precision))))::numeric AS age,
    search.xnat_a_scidresearchdata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata158, search.xnat_a_scidresearchdata0) AS label,
    search.table4_login AS insert_user,
    search.xnat_a_scidresearchdata_meta_data309 AS insert_date,
    search.xnat_experimentdata152 AS project,
    search.xnat_a_scidresearchdata1 AS administrator,
    search.xnat_a_scidresearchdata2 AS moodepisodes_currentmajordepressiveepisode,
    search.xnat_a_scidresearchdata3 AS moodepisodes_pastmajordepressiveepisode,
    search.xnat_a_scidresearchdata4 AS moodepisodes_currentmanicepisode,
    search.xnat_a_scidresearchdata5 AS moodepisodes_pastmanicepisode,
    search.xnat_a_scidresearchdata6 AS moodepisodes_currenthypomanicepisode,
    search.xnat_a_scidresearchdata7 AS moodepisodes_pasthypomanicepisode,
    search.xnat_a_scidresearchdata8 AS moodepisodes_currentdysthmicepisode,
    search.xnat_a_scidresearchdata9 AS moodepisodes_currentmooddisorderduetomedicalcondition,
    search.xnat_a_scidresearchdata10 AS moodepisodes_pastmooddisorderduetomedicalcondition,
    search.xnat_a_scidresearchdata11 AS moodepisodes_currentsubstanceinducedmooddisorder,
    search.xnat_a_scidresearchdata12 AS moodepisodes_pastsubstanceinducedmooddisorder,
    search.xnat_a_scidresearchdata13 AS psychoticsymptoms_currentdelusions,
    search.xnat_a_scidresearchdata14 AS psychoticsymptoms_pastdelusions,
    search.xnat_a_scidresearchdata15 AS psychoticsymptoms_currenthallucinations,
    search.xnat_a_scidresearchdata16 AS psychoticsymptoms_pasthallucinations,
    search.xnat_a_scidresearchdata17 AS psychoticsymptoms_currentdisorganizedspeechbehavior,
    search.xnat_a_scidresearchdata18 AS psychoticsymptoms_pastdisorganizedspeechbehavior,
    search.xnat_a_scidresearchdata19 AS psychoticsymptoms_currentcatatonicbehavior,
    search.xnat_a_scidresearchdata20 AS psychoticsymptoms_pastcatatonicbehavior,
    search.xnat_a_scidresearchdata21 AS psychoticsymptoms_currentnegativesymptoms,
    search.xnat_a_scidresearchdata22 AS psychoticsymptoms_pastnegativesymptoms,
    search.xnat_a_scidresearchdata23 AS psychoticdisorders_currentschizophrenia,
    search.xnat_a_scidresearchdata24 AS psychoticdisorders_pastschizophrenia,
    search.xnat_a_scidresearchdata25 AS psychoticdisorders_currentparanoidtype,
    search.xnat_a_scidresearchdata26 AS psychoticdisorders_pastparanoidtype,
    search.xnat_a_scidresearchdata27 AS psychoticdisorders_currentcatatonictype,
    search.xnat_a_scidresearchdata28 AS psychoticdisorders_pastcatatonictype,
    search.xnat_a_scidresearchdata29 AS psychoticdisorders_currentdisorganizedtype,
    search.xnat_a_scidresearchdata30 AS psychoticdisorders_pastdisorganizedtype,
    search.xnat_a_scidresearchdata31 AS psychoticdisorders_currentundifferentiatedtype,
    search.xnat_a_scidresearchdata32 AS psychoticdisorders_pastundifferentiatedtype,
    search.xnat_a_scidresearchdata33 AS psychoticdisorders_currentresidualtype,
    search.xnat_a_scidresearchdata34 AS psychoticdisorders_pastresidualtype,
    search.xnat_a_scidresearchdata35 AS psychoticdisorders_currentschizophreniformdisorder,
    search.xnat_a_scidresearchdata36 AS psychoticdisorders_pastschizophreniformdisorder,
    search.xnat_a_scidresearchdata37 AS psychoticdisorders_currentschizoaffectivedisorder,
    search.xnat_a_scidresearchdata38 AS psychoticdisorders_pastschizoaffectivedisorder,
    search.xnat_a_scidresearchdata39 AS psychoticdisorders_currentdelusionaldisorder,
    search.xnat_a_scidresearchdata40 AS psychoticdisorders_pastdelusionaldisorder,
    search.xnat_a_scidresearchdata41 AS psychoticdisorders_currentbriefpsychoticdisorder,
    search.xnat_a_scidresearchdata42 AS psychoticdisorders_pastbriefpsychoticdisorder,
    search.xnat_a_scidresearchdata43 AS psychoticdisorders_currentpsychoticdisorderduetomedicalconditio,
    search.xnat_a_scidresearchdata44 AS psychoticdisorders_pastpsychoticdisorderduetomedicalcondition,
    search.xnat_a_scidresearchdata45 AS psychoticdisorders_currentsubstanceinducedpsychoticdisorder,
    search.xnat_a_scidresearchdata46 AS psychoticdisorders_pastsubstanceinducedpsychoticdisorder,
    search.xnat_a_scidresearchdata47 AS psychoticdisorders_currentpsychoticdisordernos,
    search.xnat_a_scidresearchdata48 AS psychoticdisorders_pastpsychoticdisordernos,
    search.xnat_a_scidresearchdata49 AS mooddisorders_currentbipolar1disorder,
    search.xnat_a_scidresearchdata50 AS mooddisorders_pastbipolar1disorder,
    search.xnat_a_scidresearchdata51 AS mooddisorders_currentbipolar2disorder,
    search.xnat_a_scidresearchdata52 AS mooddisorders_pastbipolar2disorder,
    search.xnat_a_scidresearchdata53 AS mooddisorders_currentotherbipolardisorder,
    search.xnat_a_scidresearchdata54 AS mooddisorders_pastotherbipolardisorder,
    search.xnat_a_scidresearchdata55 AS mooddisorders_currentmajordepressivedisorder,
    search.xnat_a_scidresearchdata56 AS mooddisorders_pastmajordepressivedisorder,
    search.xnat_a_scidresearchdata57 AS mooddisorders_currentdepressivedisordernos,
    search.xnat_a_scidresearchdata58 AS mooddisorders_pastdepressivedisordernos,
    search.xnat_a_scidresearchdata59 AS substanceusedisorders_currentalcoholdependence,
    search.xnat_a_scidresearchdata60 AS substanceusedisorders_pastalcoholdependence,
    search.xnat_a_scidresearchdata61 AS substanceusedisorders_currentalcoholabuse,
    search.xnat_a_scidresearchdata62 AS substanceusedisorders_pastalcoholabuse,
    search.xnat_a_scidresearchdata63 AS substanceusedisorders_currentamphetaminedependence,
    search.xnat_a_scidresearchdata64 AS substanceusedisorders_pastamphetaminedependence,
    search.xnat_a_scidresearchdata65 AS substanceusedisorders_currentamphetamineabuse,
    search.xnat_a_scidresearchdata66 AS substanceusedisorders_pastamphetamineabuse,
    search.xnat_a_scidresearchdata67 AS substanceusedisorders_currentcannabisdependence,
    search.xnat_a_scidresearchdata68 AS substanceusedisorders_pastcannabisdependence,
    search.xnat_a_scidresearchdata69 AS substanceusedisorders_currentcannabisabuse,
    search.xnat_a_scidresearchdata70 AS substanceusedisorders_pastcannabisabuse,
    search.xnat_a_scidresearchdata71 AS substanceusedisorders_currentcocainedependence,
    search.xnat_a_scidresearchdata72 AS substanceusedisorders_pastcocainedependence,
    search.xnat_a_scidresearchdata73 AS substanceusedisorders_currentcocaineabuse,
    search.xnat_a_scidresearchdata74 AS substanceusedisorders_pastcocaineabuse,
    search.xnat_a_scidresearchdata75 AS substanceusedisorders_currenthallucinogendependence,
    search.xnat_a_scidresearchdata76 AS substanceusedisorders_pasthallucinogendependence,
    search.xnat_a_scidresearchdata77 AS substanceusedisorders_currenthallucinogenabuse,
    search.xnat_a_scidresearchdata78 AS substanceusedisorders_pasthallucinogenabuse,
    search.xnat_a_scidresearchdata79 AS substanceusedisorders_currentopioiddependence,
    search.xnat_a_scidresearchdata80 AS substanceusedisorders_pastopioiddependence,
    search.xnat_a_scidresearchdata81 AS substanceusedisorders_currentopioidabuse,
    search.xnat_a_scidresearchdata82 AS substanceusedisorders_pastopioidabuse,
    search.xnat_a_scidresearchdata83 AS substanceusedisorders_currentphencyclidinedependence,
    search.xnat_a_scidresearchdata84 AS substanceusedisorders_pastphencyclidinedependence,
    search.xnat_a_scidresearchdata85 AS substanceusedisorders_currentphencyclidineabuse,
    search.xnat_a_scidresearchdata86 AS substanceusedisorders_pastphencyclidineabuse,
    search.xnat_a_scidresearchdata87 AS substanceusedisorders_currentsedativehypnoticanxiolyticdependen,
    search.xnat_a_scidresearchdata88 AS substanceusedisorders_pastsedativehypnoticanxiolyticdependence,
    search.xnat_a_scidresearchdata89 AS substanceusedisorders_currentsedativehypnoticanxiolyticabuse,
    search.xnat_a_scidresearchdata90 AS substanceusedisorders_pastsedativehypnoticanxiolyticabuse,
    search.xnat_a_scidresearchdata91 AS substanceusedisorders_currentpolysubstancedependence,
    search.xnat_a_scidresearchdata92 AS substanceusedisorders_pastpolysubstancedependence,
    search.xnat_a_scidresearchdata93 AS substanceusedisorders_currentotherorunknowndependence,
    search.xnat_a_scidresearchdata94 AS substanceusedisorders_pastotherorunknowndependence,
    search.xnat_a_scidresearchdata95 AS substanceusedisorders_currentotherorunknownabuse,
    search.xnat_a_scidresearchdata96 AS substanceusedisorders_pastotherorunknownabuse,
    search.xnat_a_scidresearchdata97 AS anxietydisorders_currentpanicwithagoraphobia,
    search.xnat_a_scidresearchdata98 AS anxietydisorders_pastpanicwithagoraphobia,
    search.xnat_a_scidresearchdata99 AS anxietydisorders_currentpanicwithoutagoraphobia,
    search.xnat_a_scidresearchdata100 AS anxietydisorders_pastpanicwithoutagoraphobia,
    search.xnat_a_scidresearchdata101 AS anxietydisorders_currentagoraphobiawithoutpanichx,
    search.xnat_a_scidresearchdata102 AS anxietydisorders_pastagoraphobiawithoutpanichx,
    search.xnat_a_scidresearchdata103 AS anxietydisorders_currentsocialphobia,
    search.xnat_a_scidresearchdata104 AS anxietydisorders_pastsocialphobia,
    search.xnat_a_scidresearchdata105 AS anxietydisorders_currentspecificphobia,
    search.xnat_a_scidresearchdata106 AS anxietydisorders_pastspecificphobia,
    search.xnat_a_scidresearchdata107 AS anxietydisorders_currentocd,
    search.xnat_a_scidresearchdata108 AS anxietydisorders_pastocd,
    search.xnat_a_scidresearchdata109 AS anxietydisorders_currentptsd,
    search.xnat_a_scidresearchdata110 AS anxietydisorders_pastptsd,
    search.xnat_a_scidresearchdata111 AS anxietydisorders_currentgeneralizedanxietydisorder,
    search.xnat_a_scidresearchdata112 AS anxietydisorders_currentanxietyduetomedicalcondition,
    search.xnat_a_scidresearchdata113 AS anxietydisorders_pastanxietyduetomedicalcondition,
    search.xnat_a_scidresearchdata114 AS anxietydisorders_currentsubstanceinducedanxietydisorder,
    search.xnat_a_scidresearchdata115 AS anxietydisorders_pastsubstanceinducedanxietydisorder,
    search.xnat_a_scidresearchdata116 AS anxietydisorders_currentanxietydisordernos,
    search.xnat_a_scidresearchdata117 AS anxietydisorders_pastanxietydisordernos,
    search.xnat_a_scidresearchdata118 AS somatoformdisorders_somatizationdisorder,
    search.xnat_a_scidresearchdata119 AS somatoformdisorders_undifferentiatedsomatformdisorder,
    search.xnat_a_scidresearchdata120 AS somatoformdisorders_paindisorder,
    search.xnat_a_scidresearchdata121 AS somatoformdisorders_hypochondriasis,
    search.xnat_a_scidresearchdata122 AS somatoformdisorders_bodydysmorphicdisorder,
    search.xnat_a_scidresearchdata123 AS eatingdisorders_currentanorexianervosa,
    search.xnat_a_scidresearchdata124 AS eatingdisorders_pastanorexianervosa,
    search.xnat_a_scidresearchdata125 AS eatingdisorders_currentbulimianervosa,
    search.xnat_a_scidresearchdata126 AS eatingdisorders_pastbulimianervosa,
    search.xnat_a_scidresearchdata127 AS eatingdisorders_currentbingeeatingdisorder,
    search.xnat_a_scidresearchdata128 AS eatingdisorders_pastbingeeatingdisorder,
    search.xnat_a_scidresearchdata129 AS adjustmentdisorder,
    search.xnat_a_scidresearchdata130 AS optional_currentacutestressdisorder,
    search.xnat_a_scidresearchdata131 AS optional_pastacutestressdisorder,
    search.xnat_a_scidresearchdata132 AS optional_currentminordepressivedisorder,
    search.xnat_a_scidresearchdata133 AS optional_pastminordepressivedisorder,
    search.xnat_a_scidresearchdata134 AS optional_currentmixedanxietydepressivedisorder,
    search.xnat_a_scidresearchdata135 AS optional_pastmixedanxietydepressivedisorder,
    search.xnat_a_scidresearchdata136 AS optional_pastsympomaticdetails,
    search.xnat_a_scidresearchdata_meta_data306 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_a_scidresearchdata0) search_1.xnat_a_scidresearchdata0,
            search_1.xnat_a_scidresearchdata_meta_data306,
            search_1.xnat_subjectassessordata139,
            search_1.xnat_experimentdata142,
            search_1.xnat_experimentdata158,
            search_1.table4_login,
            search_1.xnat_a_scidresearchdata_meta_data309,
            search_1.xnat_experimentdata152,
            search_1.xnat_a_scidresearchdata1,
            search_1.xnat_a_scidresearchdata2,
            search_1.xnat_a_scidresearchdata3,
            search_1.xnat_a_scidresearchdata4,
            search_1.xnat_a_scidresearchdata5,
            search_1.xnat_a_scidresearchdata6,
            search_1.xnat_a_scidresearchdata7,
            search_1.xnat_a_scidresearchdata8,
            search_1.xnat_a_scidresearchdata9,
            search_1.xnat_a_scidresearchdata10,
            search_1.xnat_a_scidresearchdata11,
            search_1.xnat_a_scidresearchdata12,
            search_1.xnat_a_scidresearchdata13,
            search_1.xnat_a_scidresearchdata14,
            search_1.xnat_a_scidresearchdata15,
            search_1.xnat_a_scidresearchdata16,
            search_1.xnat_a_scidresearchdata17,
            search_1.xnat_a_scidresearchdata18,
            search_1.xnat_a_scidresearchdata19,
            search_1.xnat_a_scidresearchdata20,
            search_1.xnat_a_scidresearchdata21,
            search_1.xnat_a_scidresearchdata22,
            search_1.xnat_a_scidresearchdata23,
            search_1.xnat_a_scidresearchdata24,
            search_1.xnat_a_scidresearchdata25,
            search_1.xnat_a_scidresearchdata26,
            search_1.xnat_a_scidresearchdata27,
            search_1.xnat_a_scidresearchdata28,
            search_1.xnat_a_scidresearchdata29,
            search_1.xnat_a_scidresearchdata30,
            search_1.xnat_a_scidresearchdata31,
            search_1.xnat_a_scidresearchdata32,
            search_1.xnat_a_scidresearchdata33,
            search_1.xnat_a_scidresearchdata34,
            search_1.xnat_a_scidresearchdata35,
            search_1.xnat_a_scidresearchdata36,
            search_1.xnat_a_scidresearchdata37,
            search_1.xnat_a_scidresearchdata38,
            search_1.xnat_a_scidresearchdata39,
            search_1.xnat_a_scidresearchdata40,
            search_1.xnat_a_scidresearchdata41,
            search_1.xnat_a_scidresearchdata42,
            search_1.xnat_a_scidresearchdata43,
            search_1.xnat_a_scidresearchdata44,
            search_1.xnat_a_scidresearchdata45,
            search_1.xnat_a_scidresearchdata46,
            search_1.xnat_a_scidresearchdata47,
            search_1.xnat_a_scidresearchdata48,
            search_1.xnat_a_scidresearchdata49,
            search_1.xnat_a_scidresearchdata50,
            search_1.xnat_a_scidresearchdata51,
            search_1.xnat_a_scidresearchdata52,
            search_1.xnat_a_scidresearchdata53,
            search_1.xnat_a_scidresearchdata54,
            search_1.xnat_a_scidresearchdata55,
            search_1.xnat_a_scidresearchdata56,
            search_1.xnat_a_scidresearchdata57,
            search_1.xnat_a_scidresearchdata58,
            search_1.xnat_a_scidresearchdata59,
            search_1.xnat_a_scidresearchdata60,
            search_1.xnat_a_scidresearchdata61,
            search_1.xnat_a_scidresearchdata62,
            search_1.xnat_a_scidresearchdata63,
            search_1.xnat_a_scidresearchdata64,
            search_1.xnat_a_scidresearchdata65,
            search_1.xnat_a_scidresearchdata66,
            search_1.xnat_a_scidresearchdata67,
            search_1.xnat_a_scidresearchdata68,
            search_1.xnat_a_scidresearchdata69,
            search_1.xnat_a_scidresearchdata70,
            search_1.xnat_a_scidresearchdata71,
            search_1.xnat_a_scidresearchdata72,
            search_1.xnat_a_scidresearchdata73,
            search_1.xnat_a_scidresearchdata74,
            search_1.xnat_a_scidresearchdata75,
            search_1.xnat_a_scidresearchdata76,
            search_1.xnat_a_scidresearchdata77,
            search_1.xnat_a_scidresearchdata78,
            search_1.xnat_a_scidresearchdata79,
            search_1.xnat_a_scidresearchdata80,
            search_1.xnat_a_scidresearchdata81,
            search_1.xnat_a_scidresearchdata82,
            search_1.xnat_a_scidresearchdata83,
            search_1.xnat_a_scidresearchdata84,
            search_1.xnat_a_scidresearchdata85,
            search_1.xnat_a_scidresearchdata86,
            search_1.xnat_a_scidresearchdata87,
            search_1.xnat_a_scidresearchdata88,
            search_1.xnat_a_scidresearchdata89,
            search_1.xnat_a_scidresearchdata90,
            search_1.xnat_a_scidresearchdata91,
            search_1.xnat_a_scidresearchdata92,
            search_1.xnat_a_scidresearchdata93,
            search_1.xnat_a_scidresearchdata94,
            search_1.xnat_a_scidresearchdata95,
            search_1.xnat_a_scidresearchdata96,
            search_1.xnat_a_scidresearchdata97,
            search_1.xnat_a_scidresearchdata98,
            search_1.xnat_a_scidresearchdata99,
            search_1.xnat_a_scidresearchdata100,
            search_1.xnat_a_scidresearchdata101,
            search_1.xnat_a_scidresearchdata102,
            search_1.xnat_a_scidresearchdata103,
            search_1.xnat_a_scidresearchdata104,
            search_1.xnat_a_scidresearchdata105,
            search_1.xnat_a_scidresearchdata106,
            search_1.xnat_a_scidresearchdata107,
            search_1.xnat_a_scidresearchdata108,
            search_1.xnat_a_scidresearchdata109,
            search_1.xnat_a_scidresearchdata110,
            search_1.xnat_a_scidresearchdata111,
            search_1.xnat_a_scidresearchdata112,
            search_1.xnat_a_scidresearchdata113,
            search_1.xnat_a_scidresearchdata114,
            search_1.xnat_a_scidresearchdata115,
            search_1.xnat_a_scidresearchdata116,
            search_1.xnat_a_scidresearchdata117,
            search_1.xnat_a_scidresearchdata118,
            search_1.xnat_a_scidresearchdata119,
            search_1.xnat_a_scidresearchdata120,
            search_1.xnat_a_scidresearchdata121,
            search_1.xnat_a_scidresearchdata122,
            search_1.xnat_a_scidresearchdata123,
            search_1.xnat_a_scidresearchdata124,
            search_1.xnat_a_scidresearchdata125,
            search_1.xnat_a_scidresearchdata126,
            search_1.xnat_a_scidresearchdata127,
            search_1.xnat_a_scidresearchdata128,
            search_1.xnat_a_scidresearchdata129,
            search_1.xnat_a_scidresearchdata130,
            search_1.xnat_a_scidresearchdata131,
            search_1.xnat_a_scidresearchdata132,
            search_1.xnat_a_scidresearchdata133,
            search_1.xnat_a_scidresearchdata134,
            search_1.xnat_a_scidresearchdata135,
            search_1.xnat_a_scidresearchdata136,
            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_a_scidresearchdata_projects_projects
           FROM ( SELECT table1.id AS xnat_a_scidresearchdata0,
                    table3.status AS xnat_a_scidresearchdata_meta_data306,
                    table0.subject_id AS xnat_subjectassessordata139,
                    table1.date AS xnat_experimentdata142,
                    table1.label AS xnat_experimentdata158,
                    table4.login AS table4_login,
                    table3.insert_date AS xnat_a_scidresearchdata_meta_data309,
                    table1.project AS xnat_experimentdata152,
                    xnat_a_scidresearchdata.administrator AS xnat_a_scidresearchdata1,
                    xnat_a_scidresearchdata.moodepisodes_currentmajordepressiveepisode AS xnat_a_scidresearchdata2,
                    xnat_a_scidresearchdata.moodepisodes_pastmajordepressiveepisode AS xnat_a_scidresearchdata3,
                    xnat_a_scidresearchdata.moodepisodes_currentmanicepisode AS xnat_a_scidresearchdata4,
                    xnat_a_scidresearchdata.moodepisodes_pastmanicepisode AS xnat_a_scidresearchdata5,
                    xnat_a_scidresearchdata.moodepisodes_currenthypomanicepisode AS xnat_a_scidresearchdata6,
                    xnat_a_scidresearchdata.moodepisodes_pasthypomanicepisode AS xnat_a_scidresearchdata7,
                    xnat_a_scidresearchdata.moodepisodes_currentdysthmicepisode AS xnat_a_scidresearchdata8,
                    xnat_a_scidresearchdata.moodepisodes_currentmooddisorderduetomedicalcondition AS xnat_a_scidresearchdata9,
                    xnat_a_scidresearchdata.moodepisodes_pastmooddisorderduetomedicalcondition AS xnat_a_scidresearchdata10,
                    xnat_a_scidresearchdata.moodepisodes_currentsubstanceinducedmooddisorder AS xnat_a_scidresearchdata11,
                    xnat_a_scidresearchdata.moodepisodes_pastsubstanceinducedmooddisorder AS xnat_a_scidresearchdata12,
                    xnat_a_scidresearchdata.psychoticsymptoms_currentdelusions AS xnat_a_scidresearchdata13,
                    xnat_a_scidresearchdata.psychoticsymptoms_pastdelusions AS xnat_a_scidresearchdata14,
                    xnat_a_scidresearchdata.psychoticsymptoms_currenthallucinations AS xnat_a_scidresearchdata15,
                    xnat_a_scidresearchdata.psychoticsymptoms_pasthallucinations AS xnat_a_scidresearchdata16,
                    xnat_a_scidresearchdata.psychoticsymptoms_currentdisorganizedspeechbehavior AS xnat_a_scidresearchdata17,
                    xnat_a_scidresearchdata.psychoticsymptoms_pastdisorganizedspeechbehavior AS xnat_a_scidresearchdata18,
                    xnat_a_scidresearchdata.psychoticsymptoms_currentcatatonicbehavior AS xnat_a_scidresearchdata19,
                    xnat_a_scidresearchdata.psychoticsymptoms_pastcatatonicbehavior AS xnat_a_scidresearchdata20,
                    xnat_a_scidresearchdata.psychoticsymptoms_currentnegativesymptoms AS xnat_a_scidresearchdata21,
                    xnat_a_scidresearchdata.psychoticsymptoms_pastnegativesymptoms AS xnat_a_scidresearchdata22,
                    xnat_a_scidresearchdata.psychoticdisorders_currentschizophrenia AS xnat_a_scidresearchdata23,
                    xnat_a_scidresearchdata.psychoticdisorders_pastschizophrenia AS xnat_a_scidresearchdata24,
                    xnat_a_scidresearchdata.psychoticdisorders_currentparanoidtype AS xnat_a_scidresearchdata25,
                    xnat_a_scidresearchdata.psychoticdisorders_pastparanoidtype AS xnat_a_scidresearchdata26,
                    xnat_a_scidresearchdata.psychoticdisorders_currentcatatonictype AS xnat_a_scidresearchdata27,
                    xnat_a_scidresearchdata.psychoticdisorders_pastcatatonictype AS xnat_a_scidresearchdata28,
                    xnat_a_scidresearchdata.psychoticdisorders_currentdisorganizedtype AS xnat_a_scidresearchdata29,
                    xnat_a_scidresearchdata.psychoticdisorders_pastdisorganizedtype AS xnat_a_scidresearchdata30,
                    xnat_a_scidresearchdata.psychoticdisorders_currentundifferentiatedtype AS xnat_a_scidresearchdata31,
                    xnat_a_scidresearchdata.psychoticdisorders_pastundifferentiatedtype AS xnat_a_scidresearchdata32,
                    xnat_a_scidresearchdata.psychoticdisorders_currentresidualtype AS xnat_a_scidresearchdata33,
                    xnat_a_scidresearchdata.psychoticdisorders_pastresidualtype AS xnat_a_scidresearchdata34,
                    xnat_a_scidresearchdata.psychoticdisorders_currentschizophreniformdisorder AS xnat_a_scidresearchdata35,
                    xnat_a_scidresearchdata.psychoticdisorders_pastschizophreniformdisorder AS xnat_a_scidresearchdata36,
                    xnat_a_scidresearchdata.psychoticdisorders_currentschizoaffectivedisorder AS xnat_a_scidresearchdata37,
                    xnat_a_scidresearchdata.psychoticdisorders_pastschizoaffectivedisorder AS xnat_a_scidresearchdata38,
                    xnat_a_scidresearchdata.psychoticdisorders_currentdelusionaldisorder AS xnat_a_scidresearchdata39,
                    xnat_a_scidresearchdata.psychoticdisorders_pastdelusionaldisorder AS xnat_a_scidresearchdata40,
                    xnat_a_scidresearchdata.psychoticdisorders_currentbriefpsychoticdisorder AS xnat_a_scidresearchdata41,
                    xnat_a_scidresearchdata.psychoticdisorders_pastbriefpsychoticdisorder AS xnat_a_scidresearchdata42,
                    xnat_a_scidresearchdata.psychoticdisorders_currentpsychoticdisorderduetomedicalconditio AS xnat_a_scidresearchdata43,
                    xnat_a_scidresearchdata.psychoticdisorders_pastpsychoticdisorderduetomedicalcondition AS xnat_a_scidresearchdata44,
                    xnat_a_scidresearchdata.psychoticdisorders_currentsubstanceinducedpsychoticdisorder AS xnat_a_scidresearchdata45,
                    xnat_a_scidresearchdata.psychoticdisorders_pastsubstanceinducedpsychoticdisorder AS xnat_a_scidresearchdata46,
                    xnat_a_scidresearchdata.psychoticdisorders_currentpsychoticdisordernos AS xnat_a_scidresearchdata47,
                    xnat_a_scidresearchdata.psychoticdisorders_pastpsychoticdisordernos AS xnat_a_scidresearchdata48,
                    xnat_a_scidresearchdata.mooddisorders_currentbipolar1disorder AS xnat_a_scidresearchdata49,
                    xnat_a_scidresearchdata.mooddisorders_pastbipolar1disorder AS xnat_a_scidresearchdata50,
                    xnat_a_scidresearchdata.mooddisorders_currentbipolar2disorder AS xnat_a_scidresearchdata51,
                    xnat_a_scidresearchdata.mooddisorders_pastbipolar2disorder AS xnat_a_scidresearchdata52,
                    xnat_a_scidresearchdata.mooddisorders_currentotherbipolardisorder AS xnat_a_scidresearchdata53,
                    xnat_a_scidresearchdata.mooddisorders_pastotherbipolardisorder AS xnat_a_scidresearchdata54,
                    xnat_a_scidresearchdata.mooddisorders_currentmajordepressivedisorder AS xnat_a_scidresearchdata55,
                    xnat_a_scidresearchdata.mooddisorders_pastmajordepressivedisorder AS xnat_a_scidresearchdata56,
                    xnat_a_scidresearchdata.mooddisorders_currentdepressivedisordernos AS xnat_a_scidresearchdata57,
                    xnat_a_scidresearchdata.mooddisorders_pastdepressivedisordernos AS xnat_a_scidresearchdata58,
                    xnat_a_scidresearchdata.substanceusedisorders_currentalcoholdependence AS xnat_a_scidresearchdata59,
                    xnat_a_scidresearchdata.substanceusedisorders_pastalcoholdependence AS xnat_a_scidresearchdata60,
                    xnat_a_scidresearchdata.substanceusedisorders_currentalcoholabuse AS xnat_a_scidresearchdata61,
                    xnat_a_scidresearchdata.substanceusedisorders_pastalcoholabuse AS xnat_a_scidresearchdata62,
                    xnat_a_scidresearchdata.substanceusedisorders_currentamphetaminedependence AS xnat_a_scidresearchdata63,
                    xnat_a_scidresearchdata.substanceusedisorders_pastamphetaminedependence AS xnat_a_scidresearchdata64,
                    xnat_a_scidresearchdata.substanceusedisorders_currentamphetamineabuse AS xnat_a_scidresearchdata65,
                    xnat_a_scidresearchdata.substanceusedisorders_pastamphetamineabuse AS xnat_a_scidresearchdata66,
                    xnat_a_scidresearchdata.substanceusedisorders_currentcannabisdependence AS xnat_a_scidresearchdata67,
                    xnat_a_scidresearchdata.substanceusedisorders_pastcannabisdependence AS xnat_a_scidresearchdata68,
                    xnat_a_scidresearchdata.substanceusedisorders_currentcannabisabuse AS xnat_a_scidresearchdata69,
                    xnat_a_scidresearchdata.substanceusedisorders_pastcannabisabuse AS xnat_a_scidresearchdata70,
                    xnat_a_scidresearchdata.substanceusedisorders_currentcocainedependence AS xnat_a_scidresearchdata71,
                    xnat_a_scidresearchdata.substanceusedisorders_pastcocainedependence AS xnat_a_scidresearchdata72,
                    xnat_a_scidresearchdata.substanceusedisorders_currentcocaineabuse AS xnat_a_scidresearchdata73,
                    xnat_a_scidresearchdata.substanceusedisorders_pastcocaineabuse AS xnat_a_scidresearchdata74,
                    xnat_a_scidresearchdata.substanceusedisorders_currenthallucinogendependence AS xnat_a_scidresearchdata75,
                    xnat_a_scidresearchdata.substanceusedisorders_pasthallucinogendependence AS xnat_a_scidresearchdata76,
                    xnat_a_scidresearchdata.substanceusedisorders_currenthallucinogenabuse AS xnat_a_scidresearchdata77,
                    xnat_a_scidresearchdata.substanceusedisorders_pasthallucinogenabuse AS xnat_a_scidresearchdata78,
                    xnat_a_scidresearchdata.substanceusedisorders_currentopioiddependence AS xnat_a_scidresearchdata79,
                    xnat_a_scidresearchdata.substanceusedisorders_pastopioiddependence AS xnat_a_scidresearchdata80,
                    xnat_a_scidresearchdata.substanceusedisorders_currentopioidabuse AS xnat_a_scidresearchdata81,
                    xnat_a_scidresearchdata.substanceusedisorders_pastopioidabuse AS xnat_a_scidresearchdata82,
                    xnat_a_scidresearchdata.substanceusedisorders_currentphencyclidinedependence AS xnat_a_scidresearchdata83,
                    xnat_a_scidresearchdata.substanceusedisorders_pastphencyclidinedependence AS xnat_a_scidresearchdata84,
                    xnat_a_scidresearchdata.substanceusedisorders_currentphencyclidineabuse AS xnat_a_scidresearchdata85,
                    xnat_a_scidresearchdata.substanceusedisorders_pastphencyclidineabuse AS xnat_a_scidresearchdata86,
                    xnat_a_scidresearchdata.substanceusedisorders_currentsedativehypnoticanxiolyticdependen AS xnat_a_scidresearchdata87,
                    xnat_a_scidresearchdata.substanceusedisorders_pastsedativehypnoticanxiolyticdependence AS xnat_a_scidresearchdata88,
                    xnat_a_scidresearchdata.substanceusedisorders_currentsedativehypnoticanxiolyticabuse AS xnat_a_scidresearchdata89,
                    xnat_a_scidresearchdata.substanceusedisorders_pastsedativehypnoticanxiolyticabuse AS xnat_a_scidresearchdata90,
                    xnat_a_scidresearchdata.substanceusedisorders_currentpolysubstancedependence AS xnat_a_scidresearchdata91,
                    xnat_a_scidresearchdata.substanceusedisorders_pastpolysubstancedependence AS xnat_a_scidresearchdata92,
                    xnat_a_scidresearchdata.substanceusedisorders_currentotherorunknowndependence AS xnat_a_scidresearchdata93,
                    xnat_a_scidresearchdata.substanceusedisorders_pastotherorunknowndependence AS xnat_a_scidresearchdata94,
                    xnat_a_scidresearchdata.substanceusedisorders_currentotherorunknownabuse AS xnat_a_scidresearchdata95,
                    xnat_a_scidresearchdata.substanceusedisorders_pastotherorunknownabuse AS xnat_a_scidresearchdata96,
                    xnat_a_scidresearchdata.anxietydisorders_currentpanicwithagoraphobia AS xnat_a_scidresearchdata97,
                    xnat_a_scidresearchdata.anxietydisorders_pastpanicwithagoraphobia AS xnat_a_scidresearchdata98,
                    xnat_a_scidresearchdata.anxietydisorders_currentpanicwithoutagoraphobia AS xnat_a_scidresearchdata99,
                    xnat_a_scidresearchdata.anxietydisorders_pastpanicwithoutagoraphobia AS xnat_a_scidresearchdata100,
                    xnat_a_scidresearchdata.anxietydisorders_currentagoraphobiawithoutpanichx AS xnat_a_scidresearchdata101,
                    xnat_a_scidresearchdata.anxietydisorders_pastagoraphobiawithoutpanichx AS xnat_a_scidresearchdata102,
                    xnat_a_scidresearchdata.anxietydisorders_currentsocialphobia AS xnat_a_scidresearchdata103,
                    xnat_a_scidresearchdata.anxietydisorders_pastsocialphobia AS xnat_a_scidresearchdata104,
                    xnat_a_scidresearchdata.anxietydisorders_currentspecificphobia AS xnat_a_scidresearchdata105,
                    xnat_a_scidresearchdata.anxietydisorders_pastspecificphobia AS xnat_a_scidresearchdata106,
                    xnat_a_scidresearchdata.anxietydisorders_currentocd AS xnat_a_scidresearchdata107,
                    xnat_a_scidresearchdata.anxietydisorders_pastocd AS xnat_a_scidresearchdata108,
                    xnat_a_scidresearchdata.anxietydisorders_currentptsd AS xnat_a_scidresearchdata109,
                    xnat_a_scidresearchdata.anxietydisorders_pastptsd AS xnat_a_scidresearchdata110,
                    xnat_a_scidresearchdata.anxietydisorders_currentgeneralizedanxietydisorder AS xnat_a_scidresearchdata111,
                    xnat_a_scidresearchdata.anxietydisorders_currentanxietyduetomedicalcondition AS xnat_a_scidresearchdata112,
                    xnat_a_scidresearchdata.anxietydisorders_pastanxietyduetomedicalcondition AS xnat_a_scidresearchdata113,
                    xnat_a_scidresearchdata.anxietydisorders_currentsubstanceinducedanxietydisorder AS xnat_a_scidresearchdata114,
                    xnat_a_scidresearchdata.anxietydisorders_pastsubstanceinducedanxietydisorder AS xnat_a_scidresearchdata115,
                    xnat_a_scidresearchdata.anxietydisorders_currentanxietydisordernos AS xnat_a_scidresearchdata116,
                    xnat_a_scidresearchdata.anxietydisorders_pastanxietydisordernos AS xnat_a_scidresearchdata117,
                    xnat_a_scidresearchdata.somatoformdisorders_somatizationdisorder AS xnat_a_scidresearchdata118,
                    xnat_a_scidresearchdata.somatoformdisorders_undifferentiatedsomatformdisorder AS xnat_a_scidresearchdata119,
                    xnat_a_scidresearchdata.somatoformdisorders_paindisorder AS xnat_a_scidresearchdata120,
                    xnat_a_scidresearchdata.somatoformdisorders_hypochondriasis AS xnat_a_scidresearchdata121,
                    xnat_a_scidresearchdata.somatoformdisorders_bodydysmorphicdisorder AS xnat_a_scidresearchdata122,
                    xnat_a_scidresearchdata.eatingdisorders_currentanorexianervosa AS xnat_a_scidresearchdata123,
                    xnat_a_scidresearchdata.eatingdisorders_pastanorexianervosa AS xnat_a_scidresearchdata124,
                    xnat_a_scidresearchdata.eatingdisorders_currentbulimianervosa AS xnat_a_scidresearchdata125,
                    xnat_a_scidresearchdata.eatingdisorders_pastbulimianervosa AS xnat_a_scidresearchdata126,
                    xnat_a_scidresearchdata.eatingdisorders_currentbingeeatingdisorder AS xnat_a_scidresearchdata127,
                    xnat_a_scidresearchdata.eatingdisorders_pastbingeeatingdisorder AS xnat_a_scidresearchdata128,
                    xnat_a_scidresearchdata.adjustmentdisorder AS xnat_a_scidresearchdata129,
                    xnat_a_scidresearchdata.optional_currentacutestressdisorder AS xnat_a_scidresearchdata130,
                    xnat_a_scidresearchdata.optional_pastacutestressdisorder AS xnat_a_scidresearchdata131,
                    xnat_a_scidresearchdata.optional_currentminordepressivedisorder AS xnat_a_scidresearchdata132,
                    xnat_a_scidresearchdata.optional_pastminordepressivedisorder AS xnat_a_scidresearchdata133,
                    xnat_a_scidresearchdata.optional_currentmixedanxietydepressivedisorder AS xnat_a_scidresearchdata134,
                    xnat_a_scidresearchdata.optional_pastmixedanxietydepressivedisorder AS xnat_a_scidresearchdata135,
                    xnat_a_scidresearchdata.optional_pastsympomaticdetails AS xnat_a_scidresearchdata136,
                    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_a_scidresearchdata_projects.projects AS xnat_a_scidresearchdata_projects_projects
                   FROM (((((((public.xnat_a_scidresearchdata xnat_a_scidresearchdata
                     LEFT JOIN public.xnat_subjectassessordata table0 ON (((xnat_a_scidresearchdata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_a_scidresearchdata_meta_data table3 ON ((xnat_a_scidresearchdata.scidresearchdata_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_a_scidresearchdata_projects xnat_a_scidresearchdata_projects ON (((table1.id)::text = (xnat_a_scidresearchdata_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_a_scidresearchdata_tdata_xnat_a_scidresearchdata0,
                            search_2.xnat_a_scidresearchdata_tdata_e_xnat_experimentdata142,
                            search_2.xnat_a_scidresearchdata_id_xnat_subjectassessordata139,
                            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_a_scidresearchdata_1.xnat_a_scidresearchdata0 AS xnat_a_scidresearchdata_tdata_xnat_a_scidresearchdata0,
                                    xnat_a_scidresearchdata_1.xnat_experimentdata142 AS xnat_a_scidresearchdata_tdata_e_xnat_experimentdata142,
                                    xnat_a_scidresearchdata_1.xnat_subjectassessordata139 AS xnat_a_scidresearchdata_id_xnat_subjectassessordata139
                                   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_a_scidresearchdata0,
    table1_2.date AS xnat_experimentdata142,
    table0_1.subject_id AS xnat_subjectassessordata139
   FROM ((public.xnat_a_scidresearchdata xnat_a_scidresearchdata_2
     LEFT JOIN public.xnat_subjectassessordata table0_1 ON (((xnat_a_scidresearchdata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_experimentdata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))) xnat_a_scidresearchdata_1 ON (((xnat_subjectdata.id)::text = (xnat_a_scidresearchdata_1.xnat_subjectassessordata139)::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_a_scidresearchdata_tdata_e_xnat_experimentdata142 DESC) map_xnat_subjectdata_xnat_demographicdata ON (((table1.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_a_scidresearchdata_tdata_xnat_a_scidresearchdata0)::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_a_scidresearchdata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_a_scidresearchdata0
           FROM ( SELECT table1.id AS xnat_a_scidresearchdata0,
                    table1.date AS xnat_experimentdata142
                   FROM ((public.xnat_a_scidresearchdata xnat_a_scidresearchdata
                     LEFT JOIN public.xnat_subjectassessordata table0 ON (((xnat_a_scidresearchdata.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_a_scidresearchdata0)::text = (search.xnat_a_scidresearchdata0)::text)))
  ORDER BY search.xnat_subjectassessordata139;


ALTER TABLE public.displayfields_xnat_a_scidresearchdata OWNER TO xnat;

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

CREATE TABLE public.xnat_a_sideeffectspittsburghdata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    motortics integer,
    buccal_lingualmovements integer,
    picking_skin_fingers_nails_lip integer,
    worried_anxious integer,
    dull_tired_listless integer,
    sedation integer,
    stomachache integer,
    nausea_vomiting integer,
    crabby_irritable integer,
    tearful_sad_depressed integer,
    hallucinations integer,
    troublesleeping integer,
    lossofappetite integer,
    troubleconcentrating_distractible integer,
    dizziness_lightheadedness integer,
    headaches integer,
    socialwithdrawal integer,
    drymouth integer,
    palpitations integer,
    sideeffectspittsburghdata_info integer
);


ALTER TABLE public.xnat_a_sideeffectspittsburghdata OWNER TO xnat;

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

CREATE TABLE public.xnat_a_sideeffectspittsburghdata_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_a_sideeffectspittsburghdata_meta_data OWNER TO xnat;

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

CREATE VIEW public.xnat_a_sideeffectspittsburghdata_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_a:sideEffectsPittsburghData'::text)
  GROUP BY expt.id, expt.project;


ALTER TABLE public.xnat_a_sideeffectspittsburghdata_projects OWNER TO xnat;

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

CREATE VIEW public.displayfields_xnat_a_sideeffectspittsburghdata AS
 SELECT search.xnat_subjectassessordata22 AS subject_id,
    search.xnat_a_sideeffectspittsburghdata0 AS expt_id,
    '/@WEBAPP/images/r.gif'::text AS rpt,
    search.xnat_experimentdata25 AS date,
    (COALESCE((floor(((((search.xnat_experimentdata25 - search.xnat_demographicdata_xnat_demographicdata1))::real / (365)::double precision))::numeric))::double precision, floor((date_part('year'::text, search.xnat_experimentdata25) - (search.xnat_demographicdata_xnat_demographicdata2)::double precision))))::numeric AS age,
    search.xnat_a_sideeffectspittsburghdata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata41, search.xnat_a_sideeffectspittsburghdata0) AS label,
    search.table4_login AS insert_user,
    search.xnat_a_sideeffectspittsburghdata_meta_data192 AS insert_date,
    search.xnat_experimentdata35 AS project,
    search.xnat_a_sideeffectspittsburghdata1 AS motortics,
    search.xnat_a_sideeffectspittsburghdata2 AS buccal_lingualmovements,
    search.xnat_a_sideeffectspittsburghdata3 AS picking_skin_fingers_nails_lip,
    search.xnat_a_sideeffectspittsburghdata4 AS worried_anxious,
    search.xnat_a_sideeffectspittsburghdata5 AS dull_tired_listless,
    search.xnat_a_sideeffectspittsburghdata6 AS sedation,
    search.xnat_a_sideeffectspittsburghdata7 AS stomachache,
    search.xnat_a_sideeffectspittsburghdata8 AS nausea_vomiting,
    search.xnat_a_sideeffectspittsburghdata9 AS crabby_irritable,
    search.xnat_a_sideeffectspittsburghdata10 AS tearful_sad_depressed,
    search.xnat_a_sideeffectspittsburghdata11 AS hallucinations,
    search.xnat_a_sideeffectspittsburghdata12 AS troublesleeping,
    search.xnat_a_sideeffectspittsburghdata13 AS lossofappetite,
    search.xnat_a_sideeffectspittsburghdata14 AS troubleconcentrating_distractible,
    search.xnat_a_sideeffectspittsburghdata15 AS dizziness_lightheadedness,
    search.xnat_a_sideeffectspittsburghdata16 AS headaches,
    search.xnat_a_sideeffectspittsburghdata17 AS socialwithdrawal,
    search.xnat_a_sideeffectspittsburghdata18 AS drymouth,
    search.xnat_a_sideeffectspittsburghdata19 AS palpitations,
    search.xnat_a_sideeffectspittsburghdata_meta_data189 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_a_sideeffectspittsburghdata0) search_1.xnat_a_sideeffectspittsburghdata0,
            search_1.xnat_a_sideeffectspittsburghdata_meta_data189,
            search_1.xnat_subjectassessordata22,
            search_1.xnat_experimentdata25,
            search_1.xnat_experimentdata41,
            search_1.table4_login,
            search_1.xnat_a_sideeffectspittsburghdata_meta_data192,
            search_1.xnat_experimentdata35,
            search_1.xnat_a_sideeffectspittsburghdata1,
            search_1.xnat_a_sideeffectspittsburghdata2,
            search_1.xnat_a_sideeffectspittsburghdata3,
            search_1.xnat_a_sideeffectspittsburghdata4,
            search_1.xnat_a_sideeffectspittsburghdata5,
            search_1.xnat_a_sideeffectspittsburghdata6,
            search_1.xnat_a_sideeffectspittsburghdata7,
            search_1.xnat_a_sideeffectspittsburghdata8,
            search_1.xnat_a_sideeffectspittsburghdata9,
            search_1.xnat_a_sideeffectspittsburghdata10,
            search_1.xnat_a_sideeffectspittsburghdata11,
            search_1.xnat_a_sideeffectspittsburghdata12,
            search_1.xnat_a_sideeffectspittsburghdata13,
            search_1.xnat_a_sideeffectspittsburghdata14,
            search_1.xnat_a_sideeffectspittsburghdata15,
            search_1.xnat_a_sideeffectspittsburghdata16,
            search_1.xnat_a_sideeffectspittsburghdata17,
            search_1.xnat_a_sideeffectspittsburghdata18,
            search_1.xnat_a_sideeffectspittsburghdata19,
            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_a_sideeffectspittsburghdata_projects_projects
           FROM ( SELECT table1.id AS xnat_a_sideeffectspittsburghdata0,
                    table3.status AS xnat_a_sideeffectspittsburghdata_meta_data189,
                    table0.subject_id AS xnat_subjectassessordata22,
                    table1.date AS xnat_experimentdata25,
                    table1.label AS xnat_experimentdata41,
                    table4.login AS table4_login,
                    table3.insert_date AS xnat_a_sideeffectspittsburghdata_meta_data192,
                    table1.project AS xnat_experimentdata35,
                    xnat_a_sideeffectspittsburghdata.motortics AS xnat_a_sideeffectspittsburghdata1,
                    xnat_a_sideeffectspittsburghdata.buccal_lingualmovements AS xnat_a_sideeffectspittsburghdata2,
                    xnat_a_sideeffectspittsburghdata.picking_skin_fingers_nails_lip AS xnat_a_sideeffectspittsburghdata3,
                    xnat_a_sideeffectspittsburghdata.worried_anxious AS xnat_a_sideeffectspittsburghdata4,
                    xnat_a_sideeffectspittsburghdata.dull_tired_listless AS xnat_a_sideeffectspittsburghdata5,
                    xnat_a_sideeffectspittsburghdata.sedation AS xnat_a_sideeffectspittsburghdata6,
                    xnat_a_sideeffectspittsburghdata.stomachache AS xnat_a_sideeffectspittsburghdata7,
                    xnat_a_sideeffectspittsburghdata.nausea_vomiting AS xnat_a_sideeffectspittsburghdata8,
                    xnat_a_sideeffectspittsburghdata.crabby_irritable AS xnat_a_sideeffectspittsburghdata9,
                    xnat_a_sideeffectspittsburghdata.tearful_sad_depressed AS xnat_a_sideeffectspittsburghdata10,
                    xnat_a_sideeffectspittsburghdata.hallucinations AS xnat_a_sideeffectspittsburghdata11,
                    xnat_a_sideeffectspittsburghdata.troublesleeping AS xnat_a_sideeffectspittsburghdata12,
                    xnat_a_sideeffectspittsburghdata.lossofappetite AS xnat_a_sideeffectspittsburghdata13,
                    xnat_a_sideeffectspittsburghdata.troubleconcentrating_distractible AS xnat_a_sideeffectspittsburghdata14,
                    xnat_a_sideeffectspittsburghdata.dizziness_lightheadedness AS xnat_a_sideeffectspittsburghdata15,
                    xnat_a_sideeffectspittsburghdata.headaches AS xnat_a_sideeffectspittsburghdata16,
                    xnat_a_sideeffectspittsburghdata.socialwithdrawal AS xnat_a_sideeffectspittsburghdata17,
                    xnat_a_sideeffectspittsburghdata.drymouth AS xnat_a_sideeffectspittsburghdata18,
                    xnat_a_sideeffectspittsburghdata.palpitations AS xnat_a_sideeffectspittsburghdata19,
                    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_a_sideeffectspittsburghdata_projects.projects AS xnat_a_sideeffectspittsburghdata_projects_projects
                   FROM (((((((public.xnat_a_sideeffectspittsburghdata xnat_a_sideeffectspittsburghdata
                     LEFT JOIN public.xnat_subjectassessordata table0 ON (((xnat_a_sideeffectspittsburghdata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_a_sideeffectspittsburghdata_meta_data table3 ON ((xnat_a_sideeffectspittsburghdata.sideeffectspittsburghdata_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_a_sideeffectspittsburghdata_projects xnat_a_sideeffectspittsburghdata_projects ON (((table1.id)::text = (xnat_a_sideeffectspittsburghdata_projects.id)::text)))
                     LEFT JOIN ( SELECT search_2.xnat_subjectdata3,
                            search_2.xnat_subjectdata_meta_data328,
                            search_2.xnat_a_sideeffectspittsburghda_t_a_sideeffectspittsburghdata0,
                            search_2.xnat_a_sideeffectspittsburghda_tdata_ex_xnat_experimentdata25,
                            search_2.xnat_a_sideeffectspittsburghda_dee_xnat_subjectassessordata22,
                            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_a_sideeffectspittsburghdata_1.xnat_a_sideeffectspittsburghdata0 AS xnat_a_sideeffectspittsburghda_t_a_sideeffectspittsburghdata0,
                                    xnat_a_sideeffectspittsburghdata_1.xnat_experimentdata25 AS xnat_a_sideeffectspittsburghda_tdata_ex_xnat_experimentdata25,
                                    xnat_a_sideeffectspittsburghdata_1.xnat_subjectassessordata22 AS xnat_a_sideeffectspittsburghda_dee_xnat_subjectassessordata22,
                                    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 table1_2.id AS xnat_a_sideeffectspittsburghdata0,
    table1_2.date AS xnat_experimentdata25,
    table0_1.subject_id AS xnat_subjectassessordata22
   FROM ((public.xnat_a_sideeffectspittsburghdata xnat_a_sideeffectspittsburghdata_2
     LEFT JOIN public.xnat_subjectassessordata table0_1 ON (((xnat_a_sideeffectspittsburghdata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_experimentdata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))) xnat_a_sideeffectspittsburghdata_1 ON (((xnat_subjectdata.id)::text = (xnat_a_sideeffectspittsburghdata_1.xnat_subjectassessordata22)::text)))
                                     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)))) search_2
                          ORDER BY search_2.xnat_subjectdata3, search_2.xnat_a_sideeffectspittsburghda_tdata_ex_xnat_experimentdata25 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 (((table1.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_a_sideeffectspittsburghda_t_a_sideeffectspittsburghdata0)::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_a_sideeffectspittsburghdata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_a_sideeffectspittsburghdata0
           FROM ( SELECT table1.id AS xnat_a_sideeffectspittsburghdata0,
                    table1.date AS xnat_experimentdata25
                   FROM ((public.xnat_a_sideeffectspittsburghdata xnat_a_sideeffectspittsburghdata
                     LEFT JOIN public.xnat_subjectassessordata table0 ON (((xnat_a_sideeffectspittsburghdata.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_a_sideeffectspittsburghdata0)::text = (search.xnat_a_sideeffectspittsburghdata0)::text)))
  ORDER BY search.xnat_subjectassessordata22;


ALTER TABLE public.displayfields_xnat_a_sideeffectspittsburghdata OWNER TO xnat;

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

CREATE TABLE public.xnat_a_updrs3data (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    inscanner integer,
    clicker_right integer,
    clicker_left integer,
    clicker_interval integer DEFAULT 0 NOT NULL,
    tremorrest_face character varying(255),
    tremorrest_rue character varying(255),
    tremorrest_lue character varying(255),
    tremorrest_rle character varying(255),
    tremorrest_lle character varying(255),
    rigidity_neck character varying(255),
    rigidity_rue character varying(255),
    rigidity_lue character varying(255),
    rigidity_rle character varying(255),
    rigidity_lle character varying(255),
    handmovementsgrip_right integer,
    handmovementsgrip_left integer,
    facialexpression integer,
    gait integer,
    speech integer,
    writing integer,
    arisefromchair integer,
    actionposturaltremor_right integer,
    actionposturaltremor_left integer,
    handsram_right integer,
    handsram_left integer,
    fingertaps_right integer,
    fingertaps_left integer,
    posture integer,
    posturalstability integer,
    foottaps_right integer,
    foottaps_left integer,
    bodybradykinesiahypokinesia integer,
    problem integer,
    updrs3data_info integer
);


ALTER TABLE public.xnat_a_updrs3data OWNER TO xnat;

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

CREATE TABLE public.xnat_a_updrs3data_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_a_updrs3data_meta_data OWNER TO xnat;

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

CREATE VIEW public.xnat_a_updrs3data_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_a:updrs3Data'::text)
  GROUP BY expt.id, expt.project;


ALTER TABLE public.xnat_a_updrs3data_projects OWNER TO xnat;

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

CREATE VIEW public.displayfields_xnat_a_updrs3data AS
 SELECT search.xnat_subjectassessordata36 AS subject_id,
    search.xnat_a_updrs3data0 AS expt_id,
    '/@WEBAPP/images/r.gif'::text AS rpt,
    search.xnat_experimentdata39 AS date,
    (COALESCE((floor(((((search.xnat_experimentdata39 - search.xnat_demographicdata_xnat_demographicdata1))::real / (365)::double precision))::numeric))::double precision, floor((date_part('year'::text, search.xnat_experimentdata39) - (search.xnat_demographicdata_xnat_demographicdata2)::double precision))))::numeric AS age,
    search.xnat_a_updrs3data_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata55, search.xnat_a_updrs3data0) AS label,
    search.table4_login AS insert_user,
    search.xnat_a_updrs3data_meta_data206 AS insert_date,
    search.xnat_experimentdata49 AS project,
    search.xnat_a_updrs3data1 AS inscanner,
    search.xnat_a_updrs3data2 AS clicker_right,
    search.xnat_a_updrs3data3 AS clicker_left,
    search.xnat_a_updrs3data4 AS clicker_interval,
    search.xnat_a_updrs3data5 AS tremorrest_face,
    search.xnat_a_updrs3data6 AS tremorrest_rue,
    search.xnat_a_updrs3data7 AS tremorrest_lue,
    search.xnat_a_updrs3data8 AS tremorrest_rle,
    search.xnat_a_updrs3data9 AS tremorrest_lle,
    search.xnat_a_updrs3data10 AS rigidity_neck,
    search.xnat_a_updrs3data11 AS rigidity_rue,
    search.xnat_a_updrs3data12 AS rigidity_lue,
    search.xnat_a_updrs3data13 AS rigidity_rle,
    search.xnat_a_updrs3data14 AS rigidity_lle,
    search.xnat_a_updrs3data15 AS handmovementsgrip_right,
    search.xnat_a_updrs3data16 AS handmovementsgrip_left,
    search.xnat_a_updrs3data17 AS facialexpression,
    search.xnat_a_updrs3data18 AS gait,
    search.xnat_a_updrs3data19 AS speech,
    search.xnat_a_updrs3data20 AS writing,
    search.xnat_a_updrs3data21 AS arisefromchair,
    search.xnat_a_updrs3data22 AS actionposturaltremor_right,
    search.xnat_a_updrs3data23 AS actionposturaltremor_left,
    search.xnat_a_updrs3data24 AS handsram_right,
    search.xnat_a_updrs3data25 AS handsram_left,
    search.xnat_a_updrs3data26 AS fingertaps_right,
    search.xnat_a_updrs3data27 AS fingertaps_left,
    search.xnat_a_updrs3data28 AS posture,
    search.xnat_a_updrs3data29 AS posturalstability,
    search.xnat_a_updrs3data30 AS foottaps_right,
    search.xnat_a_updrs3data31 AS foottaps_left,
    search.xnat_a_updrs3data32 AS bodybradykinesiahypokinesia,
    search.xnat_a_updrs3data33 AS problem,
    search.xnat_a_updrs3data_meta_data203 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_a_updrs3data0) search_1.xnat_a_updrs3data0,
            search_1.xnat_a_updrs3data_meta_data203,
            search_1.xnat_subjectassessordata36,
            search_1.xnat_experimentdata39,
            search_1.xnat_experimentdata55,
            search_1.table4_login,
            search_1.xnat_a_updrs3data_meta_data206,
            search_1.xnat_experimentdata49,
            search_1.xnat_a_updrs3data1,
            search_1.xnat_a_updrs3data2,
            search_1.xnat_a_updrs3data3,
            search_1.xnat_a_updrs3data4,
            search_1.xnat_a_updrs3data5,
            search_1.xnat_a_updrs3data6,
            search_1.xnat_a_updrs3data7,
            search_1.xnat_a_updrs3data8,
            search_1.xnat_a_updrs3data9,
            search_1.xnat_a_updrs3data10,
            search_1.xnat_a_updrs3data11,
            search_1.xnat_a_updrs3data12,
            search_1.xnat_a_updrs3data13,
            search_1.xnat_a_updrs3data14,
            search_1.xnat_a_updrs3data15,
            search_1.xnat_a_updrs3data16,
            search_1.xnat_a_updrs3data17,
            search_1.xnat_a_updrs3data18,
            search_1.xnat_a_updrs3data19,
            search_1.xnat_a_updrs3data20,
            search_1.xnat_a_updrs3data21,
            search_1.xnat_a_updrs3data22,
            search_1.xnat_a_updrs3data23,
            search_1.xnat_a_updrs3data24,
            search_1.xnat_a_updrs3data25,
            search_1.xnat_a_updrs3data26,
            search_1.xnat_a_updrs3data27,
            search_1.xnat_a_updrs3data28,
            search_1.xnat_a_updrs3data29,
            search_1.xnat_a_updrs3data30,
            search_1.xnat_a_updrs3data31,
            search_1.xnat_a_updrs3data32,
            search_1.xnat_a_updrs3data33,
            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_a_updrs3data_projects_projects
           FROM ( SELECT table1.id AS xnat_a_updrs3data0,
                    table3.status AS xnat_a_updrs3data_meta_data203,
                    table0.subject_id AS xnat_subjectassessordata36,
                    table1.date AS xnat_experimentdata39,
                    table1.label AS xnat_experimentdata55,
                    table4.login AS table4_login,
                    table3.insert_date AS xnat_a_updrs3data_meta_data206,
                    table1.project AS xnat_experimentdata49,
                    xnat_a_updrs3data.inscanner AS xnat_a_updrs3data1,
                    xnat_a_updrs3data.clicker_right AS xnat_a_updrs3data2,
                    xnat_a_updrs3data.clicker_left AS xnat_a_updrs3data3,
                    xnat_a_updrs3data.clicker_interval AS xnat_a_updrs3data4,
                    xnat_a_updrs3data.tremorrest_face AS xnat_a_updrs3data5,
                    xnat_a_updrs3data.tremorrest_rue AS xnat_a_updrs3data6,
                    xnat_a_updrs3data.tremorrest_lue AS xnat_a_updrs3data7,
                    xnat_a_updrs3data.tremorrest_rle AS xnat_a_updrs3data8,
                    xnat_a_updrs3data.tremorrest_lle AS xnat_a_updrs3data9,
                    xnat_a_updrs3data.rigidity_neck AS xnat_a_updrs3data10,
                    xnat_a_updrs3data.rigidity_rue AS xnat_a_updrs3data11,
                    xnat_a_updrs3data.rigidity_lue AS xnat_a_updrs3data12,
                    xnat_a_updrs3data.rigidity_rle AS xnat_a_updrs3data13,
                    xnat_a_updrs3data.rigidity_lle AS xnat_a_updrs3data14,
                    xnat_a_updrs3data.handmovementsgrip_right AS xnat_a_updrs3data15,
                    xnat_a_updrs3data.handmovementsgrip_left AS xnat_a_updrs3data16,
                    xnat_a_updrs3data.facialexpression AS xnat_a_updrs3data17,
                    xnat_a_updrs3data.gait AS xnat_a_updrs3data18,
                    xnat_a_updrs3data.speech AS xnat_a_updrs3data19,
                    xnat_a_updrs3data.writing AS xnat_a_updrs3data20,
                    xnat_a_updrs3data.arisefromchair AS xnat_a_updrs3data21,
                    xnat_a_updrs3data.actionposturaltremor_right AS xnat_a_updrs3data22,
                    xnat_a_updrs3data.actionposturaltremor_left AS xnat_a_updrs3data23,
                    xnat_a_updrs3data.handsram_right AS xnat_a_updrs3data24,
                    xnat_a_updrs3data.handsram_left AS xnat_a_updrs3data25,
                    xnat_a_updrs3data.fingertaps_right AS xnat_a_updrs3data26,
                    xnat_a_updrs3data.fingertaps_left AS xnat_a_updrs3data27,
                    xnat_a_updrs3data.posture AS xnat_a_updrs3data28,
                    xnat_a_updrs3data.posturalstability AS xnat_a_updrs3data29,
                    xnat_a_updrs3data.foottaps_right AS xnat_a_updrs3data30,
                    xnat_a_updrs3data.foottaps_left AS xnat_a_updrs3data31,
                    xnat_a_updrs3data.bodybradykinesiahypokinesia AS xnat_a_updrs3data32,
                    xnat_a_updrs3data.problem AS xnat_a_updrs3data33,
                    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_a_updrs3data_projects.projects AS xnat_a_updrs3data_projects_projects
                   FROM (((((((public.xnat_a_updrs3data xnat_a_updrs3data
                     LEFT JOIN public.xnat_subjectassessordata table0 ON (((xnat_a_updrs3data.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_a_updrs3data_meta_data table3 ON ((xnat_a_updrs3data.updrs3data_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_a_updrs3data_projects xnat_a_updrs3data_projects ON (((table1.id)::text = (xnat_a_updrs3data_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_a_updrs3data_tdata_ext_x_xnat_a_updrs3data0,
                            search_2.xnat_a_updrs3data_tdata_ex_xnat_experimentdata39,
                            search_2.xnat_a_updrs3data_drs_xnat_subjectassessordata36,
                            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_a_updrs3data_1.xnat_a_updrs3data0 AS xnat_a_updrs3data_tdata_ext_x_xnat_a_updrs3data0,
                                    xnat_a_updrs3data_1.xnat_experimentdata39 AS xnat_a_updrs3data_tdata_ex_xnat_experimentdata39,
                                    xnat_a_updrs3data_1.xnat_subjectassessordata36 AS xnat_a_updrs3data_drs_xnat_subjectassessordata36
                                   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_a_updrs3data0,
    table1_2.date AS xnat_experimentdata39,
    table0_1.subject_id AS xnat_subjectassessordata36
   FROM ((public.xnat_a_updrs3data xnat_a_updrs3data_2
     LEFT JOIN public.xnat_subjectassessordata table0_1 ON (((xnat_a_updrs3data_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_experimentdata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))) xnat_a_updrs3data_1 ON (((xnat_subjectdata.id)::text = (xnat_a_updrs3data_1.xnat_subjectassessordata36)::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_a_updrs3data_tdata_ex_xnat_experimentdata39 DESC) map_xnat_subjectdata_xnat_demographicdata ON (((table1.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_a_updrs3data_tdata_ext_x_xnat_a_updrs3data0)::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_a_updrs3data0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_a_updrs3data0
           FROM ( SELECT table1.id AS xnat_a_updrs3data0,
                    table1.date AS xnat_experimentdata39
                   FROM ((public.xnat_a_updrs3data xnat_a_updrs3data
                     LEFT JOIN public.xnat_subjectassessordata table0 ON (((xnat_a_updrs3data.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_a_updrs3data0)::text = (search.xnat_a_updrs3data0)::text)))
  ORDER BY search.xnat_subjectassessordata36;


ALTER TABLE public.displayfields_xnat_a_updrs3data OWNER TO xnat;

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

CREATE TABLE public.xnat_a_ybocsdata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    currentorworstever character varying(255),
    timeoccupiedwiththoughts integer,
    thoughtsinterferefunctioning integer,
    distresscaused integer,
    efforttoresistthoughts integer,
    controloverthoughts integer,
    timeperforming integer,
    behaviorsinterferefunctioning integer,
    feelingifprevented integer,
    efforttoresistbehaviors integer,
    behaviordrivestrength integer,
    untiljustright integer,
    untiljustrightawareness character varying(255),
    untiljustrightperceptions character varying(255),
    whenstartuntiljustright character varying(255),
    frequencyuntiljustright character varying(255),
    firstuntiljustrightage double precision,
    ybocsdata_info integer
);


ALTER TABLE public.xnat_a_ybocsdata OWNER TO xnat;

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

CREATE TABLE public.xnat_a_ybocsdata_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_a_ybocsdata_meta_data OWNER TO xnat;

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

CREATE VIEW public.xnat_a_ybocsdata_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_a:ybocsData'::text)
  GROUP BY expt.id, expt.project;


ALTER TABLE public.xnat_a_ybocsdata_projects OWNER TO xnat;

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

CREATE VIEW public.displayfields_xnat_a_ybocsdata AS
 SELECT search.xnat_subjectassessordata20 AS subject_id,
    search.xnat_a_ybocsdata0 AS expt_id,
    '/@WEBAPP/images/r.gif'::text AS rpt,
    search.xnat_experimentdata23 AS date,
    (COALESCE((floor(((((search.xnat_experimentdata23 - search.xnat_demographicdata_xnat_demographicdata1))::real / (365)::double precision))::numeric))::double precision, floor((date_part('year'::text, search.xnat_experimentdata23) - (search.xnat_demographicdata_xnat_demographicdata2)::double precision))))::numeric AS age,
    search.xnat_a_ybocsdata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata39, search.xnat_a_ybocsdata0) AS label,
    search.table4_login AS insert_user,
    search.xnat_a_ybocsdata_meta_data190 AS insert_date,
    search.xnat_experimentdata33 AS project,
    search.xnat_a_ybocsdata1 AS currentorworstever,
    search.xnat_a_ybocsdata2 AS timeoccupiedwiththoughts,
    search.xnat_a_ybocsdata3 AS thoughtsinterferefunctioning,
    search.xnat_a_ybocsdata4 AS distresscaused,
    search.xnat_a_ybocsdata5 AS efforttoresistthoughts,
    search.xnat_a_ybocsdata6 AS controloverthoughts,
    search.xnat_a_ybocsdata7 AS timeperforming,
    search.xnat_a_ybocsdata8 AS behaviorsinterferefunctioning,
    search.xnat_a_ybocsdata9 AS feelingifprevented,
    search.xnat_a_ybocsdata10 AS efforttoresistbehaviors,
    search.xnat_a_ybocsdata11 AS behaviordrivestrength,
    search.xnat_a_ybocsdata12 AS untiljustright,
    search.xnat_a_ybocsdata13 AS untiljustrightawareness,
    search.xnat_a_ybocsdata14 AS untiljustrightperceptions,
    search.xnat_a_ybocsdata15 AS whenstartuntiljustright,
    search.xnat_a_ybocsdata16 AS frequencyuntiljustright,
    search.xnat_a_ybocsdata17 AS firstuntiljustrightage,
    search.xnat_a_ybocsdata_meta_data187 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_a_ybocsdata0) search_1.xnat_a_ybocsdata0,
            search_1.xnat_a_ybocsdata_meta_data187,
            search_1.xnat_subjectassessordata20,
            search_1.xnat_experimentdata23,
            search_1.xnat_experimentdata39,
            search_1.table4_login,
            search_1.xnat_a_ybocsdata_meta_data190,
            search_1.xnat_experimentdata33,
            search_1.xnat_a_ybocsdata1,
            search_1.xnat_a_ybocsdata2,
            search_1.xnat_a_ybocsdata3,
            search_1.xnat_a_ybocsdata4,
            search_1.xnat_a_ybocsdata5,
            search_1.xnat_a_ybocsdata6,
            search_1.xnat_a_ybocsdata7,
            search_1.xnat_a_ybocsdata8,
            search_1.xnat_a_ybocsdata9,
            search_1.xnat_a_ybocsdata10,
            search_1.xnat_a_ybocsdata11,
            search_1.xnat_a_ybocsdata12,
            search_1.xnat_a_ybocsdata13,
            search_1.xnat_a_ybocsdata14,
            search_1.xnat_a_ybocsdata15,
            search_1.xnat_a_ybocsdata16,
            search_1.xnat_a_ybocsdata17,
            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_a_ybocsdata_projects_projects
           FROM ( SELECT table1.id AS xnat_a_ybocsdata0,
                    table3.status AS xnat_a_ybocsdata_meta_data187,
                    table0.subject_id AS xnat_subjectassessordata20,
                    table1.date AS xnat_experimentdata23,
                    table1.label AS xnat_experimentdata39,
                    table4.login AS table4_login,
                    table3.insert_date AS xnat_a_ybocsdata_meta_data190,
                    table1.project AS xnat_experimentdata33,
                    xnat_a_ybocsdata.currentorworstever AS xnat_a_ybocsdata1,
                    xnat_a_ybocsdata.timeoccupiedwiththoughts AS xnat_a_ybocsdata2,
                    xnat_a_ybocsdata.thoughtsinterferefunctioning AS xnat_a_ybocsdata3,
                    xnat_a_ybocsdata.distresscaused AS xnat_a_ybocsdata4,
                    xnat_a_ybocsdata.efforttoresistthoughts AS xnat_a_ybocsdata5,
                    xnat_a_ybocsdata.controloverthoughts AS xnat_a_ybocsdata6,
                    xnat_a_ybocsdata.timeperforming AS xnat_a_ybocsdata7,
                    xnat_a_ybocsdata.behaviorsinterferefunctioning AS xnat_a_ybocsdata8,
                    xnat_a_ybocsdata.feelingifprevented AS xnat_a_ybocsdata9,
                    xnat_a_ybocsdata.efforttoresistbehaviors AS xnat_a_ybocsdata10,
                    xnat_a_ybocsdata.behaviordrivestrength AS xnat_a_ybocsdata11,
                    xnat_a_ybocsdata.untiljustright AS xnat_a_ybocsdata12,
                    xnat_a_ybocsdata.untiljustrightawareness AS xnat_a_ybocsdata13,
                    xnat_a_ybocsdata.untiljustrightperceptions AS xnat_a_ybocsdata14,
                    xnat_a_ybocsdata.whenstartuntiljustright AS xnat_a_ybocsdata15,
                    xnat_a_ybocsdata.frequencyuntiljustright AS xnat_a_ybocsdata16,
                    xnat_a_ybocsdata.firstuntiljustrightage AS xnat_a_ybocsdata17,
                    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_a_ybocsdata_projects.projects AS xnat_a_ybocsdata_projects_projects
                   FROM (((((((public.xnat_a_ybocsdata xnat_a_ybocsdata
                     LEFT JOIN public.xnat_subjectassessordata table0 ON (((xnat_a_ybocsdata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_a_ybocsdata_meta_data table3 ON ((xnat_a_ybocsdata.ybocsdata_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_a_ybocsdata_projects xnat_a_ybocsdata_projects ON (((table1.id)::text = (xnat_a_ybocsdata_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_a_ybocsdata_tdata_ext_xn_xnat_a_ybocsdata0,
                            search_2.xnat_a_ybocsdata_tdata_ex_xnat_experimentdata23,
                            search_2.xnat_a_ybocsdata_ocs_xnat_subjectassessordata20,
                            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_a_ybocsdata_1.xnat_a_ybocsdata0 AS xnat_a_ybocsdata_tdata_ext_xn_xnat_a_ybocsdata0,
                                    xnat_a_ybocsdata_1.xnat_experimentdata23 AS xnat_a_ybocsdata_tdata_ex_xnat_experimentdata23,
                                    xnat_a_ybocsdata_1.xnat_subjectassessordata20 AS xnat_a_ybocsdata_ocs_xnat_subjectassessordata20
                                   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_a_ybocsdata0,
    table1_2.date AS xnat_experimentdata23,
    table0_1.subject_id AS xnat_subjectassessordata20
   FROM ((public.xnat_a_ybocsdata xnat_a_ybocsdata_2
     LEFT JOIN public.xnat_subjectassessordata table0_1 ON (((xnat_a_ybocsdata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_experimentdata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))) xnat_a_ybocsdata_1 ON (((xnat_subjectdata.id)::text = (xnat_a_ybocsdata_1.xnat_subjectassessordata20)::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_a_ybocsdata_tdata_ex_xnat_experimentdata23 DESC) map_xnat_subjectdata_xnat_demographicdata ON (((table1.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_a_ybocsdata_tdata_ext_xn_xnat_a_ybocsdata0)::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_a_ybocsdata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_a_ybocsdata0
           FROM ( SELECT table1.id AS xnat_a_ybocsdata0,
                    table1.date AS xnat_experimentdata23
                   FROM ((public.xnat_a_ybocsdata xnat_a_ybocsdata
                     LEFT JOIN public.xnat_subjectassessordata table0 ON (((xnat_a_ybocsdata.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_a_ybocsdata0)::text = (search.xnat_a_ybocsdata0)::text)))
  ORDER BY search.xnat_subjectassessordata20;


ALTER TABLE public.displayfields_xnat_a_ybocsdata OWNER TO xnat;

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

CREATE TABLE public.xnat_a_ygtssdata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    filledoutby character varying(255),
    period character varying(255),
    worsteverage double precision,
    motor_number integer,
    motor_frequency integer,
    motor_intensity integer,
    motor_complexity integer,
    motor_interference integer,
    motor_inventory character varying(255),
    phonic_number integer,
    phonic_frequency integer,
    phonic_intensity integer,
    phonic_complexity integer,
    phonic_interference integer,
    phonic_inventory character varying(255),
    impairment integer,
    ygtssdata_info integer
);


ALTER TABLE public.xnat_a_ygtssdata OWNER TO xnat;

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

CREATE TABLE public.xnat_a_ygtssdata_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_a_ygtssdata_meta_data OWNER TO xnat;

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

CREATE VIEW public.xnat_a_ygtssdata_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_a:ygtssData'::text)
  GROUP BY expt.id, expt.project;


ALTER TABLE public.xnat_a_ygtssdata_projects OWNER TO xnat;

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

CREATE VIEW public.displayfields_xnat_a_ygtssdata AS
 SELECT search.xnat_subjectassessordata19 AS subject_id,
    search.xnat_a_ygtssdata0 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_a_ygtssdata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata38, search.xnat_a_ygtssdata0) AS label,
    search.table4_login AS insert_user,
    search.xnat_a_ygtssdata_meta_data189 AS insert_date,
    search.xnat_experimentdata32 AS project,
    search.xnat_a_ygtssdata1 AS filledoutby,
    search.xnat_a_ygtssdata2 AS period,
    search.xnat_a_ygtssdata3 AS worsteverage,
    search.xnat_a_ygtssdata4 AS motor_number,
    search.xnat_a_ygtssdata5 AS motor_frequency,
    search.xnat_a_ygtssdata6 AS motor_intensity,
    search.xnat_a_ygtssdata7 AS motor_complexity,
    search.xnat_a_ygtssdata8 AS motor_interference,
    search.xnat_a_ygtssdata9 AS motor_inventory,
    search.xnat_a_ygtssdata10 AS phonic_number,
    search.xnat_a_ygtssdata11 AS phonic_frequency,
    search.xnat_a_ygtssdata12 AS phonic_intensity,
    search.xnat_a_ygtssdata13 AS phonic_complexity,
    search.xnat_a_ygtssdata14 AS phonic_interference,
    search.xnat_a_ygtssdata15 AS phonic_inventory,
    search.xnat_a_ygtssdata16 AS impairment,
    search.xnat_a_ygtssdata_meta_data186 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_a_ygtssdata0) search_1.xnat_a_ygtssdata0,
            search_1.xnat_a_ygtssdata_meta_data186,
            search_1.xnat_subjectassessordata19,
            search_1.xnat_experimentdata22,
            search_1.xnat_experimentdata38,
            search_1.table4_login,
            search_1.xnat_a_ygtssdata_meta_data189,
            search_1.xnat_experimentdata32,
            search_1.xnat_a_ygtssdata1,
            search_1.xnat_a_ygtssdata2,
            search_1.xnat_a_ygtssdata3,
            search_1.xnat_a_ygtssdata4,
            search_1.xnat_a_ygtssdata5,
            search_1.xnat_a_ygtssdata6,
            search_1.xnat_a_ygtssdata7,
            search_1.xnat_a_ygtssdata8,
            search_1.xnat_a_ygtssdata9,
            search_1.xnat_a_ygtssdata10,
            search_1.xnat_a_ygtssdata11,
            search_1.xnat_a_ygtssdata12,
            search_1.xnat_a_ygtssdata13,
            search_1.xnat_a_ygtssdata14,
            search_1.xnat_a_ygtssdata15,
            search_1.xnat_a_ygtssdata16,
            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_a_ygtssdata_projects_projects
           FROM ( SELECT table1.id AS xnat_a_ygtssdata0,
                    table3.status AS xnat_a_ygtssdata_meta_data186,
                    table0.subject_id AS xnat_subjectassessordata19,
                    table1.date AS xnat_experimentdata22,
                    table1.label AS xnat_experimentdata38,
                    table4.login AS table4_login,
                    table3.insert_date AS xnat_a_ygtssdata_meta_data189,
                    table1.project AS xnat_experimentdata32,
                    xnat_a_ygtssdata.filledoutby AS xnat_a_ygtssdata1,
                    xnat_a_ygtssdata.period AS xnat_a_ygtssdata2,
                    xnat_a_ygtssdata.worsteverage AS xnat_a_ygtssdata3,
                    xnat_a_ygtssdata.motor_number AS xnat_a_ygtssdata4,
                    xnat_a_ygtssdata.motor_frequency AS xnat_a_ygtssdata5,
                    xnat_a_ygtssdata.motor_intensity AS xnat_a_ygtssdata6,
                    xnat_a_ygtssdata.motor_complexity AS xnat_a_ygtssdata7,
                    xnat_a_ygtssdata.motor_interference AS xnat_a_ygtssdata8,
                    xnat_a_ygtssdata.motor_inventory AS xnat_a_ygtssdata9,
                    xnat_a_ygtssdata.phonic_number AS xnat_a_ygtssdata10,
                    xnat_a_ygtssdata.phonic_frequency AS xnat_a_ygtssdata11,
                    xnat_a_ygtssdata.phonic_intensity AS xnat_a_ygtssdata12,
                    xnat_a_ygtssdata.phonic_complexity AS xnat_a_ygtssdata13,
                    xnat_a_ygtssdata.phonic_interference AS xnat_a_ygtssdata14,
                    xnat_a_ygtssdata.phonic_inventory AS xnat_a_ygtssdata15,
                    xnat_a_ygtssdata.impairment AS xnat_a_ygtssdata16,
                    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_a_ygtssdata_projects.projects AS xnat_a_ygtssdata_projects_projects
                   FROM (((((((public.xnat_a_ygtssdata xnat_a_ygtssdata
                     LEFT JOIN public.xnat_subjectassessordata table0 ON (((xnat_a_ygtssdata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_a_ygtssdata_meta_data table3 ON ((xnat_a_ygtssdata.ygtssdata_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_a_ygtssdata_projects xnat_a_ygtssdata_projects ON (((table1.id)::text = (xnat_a_ygtssdata_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_a_ygtssdata_tdata_ext_xn_xnat_a_ygtssdata0,
                            search_2.xnat_a_ygtssdata_tdata_ex_xnat_experimentdata22,
                            search_2.xnat_a_ygtssdata_tss_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_a_ygtssdata_1.xnat_a_ygtssdata0 AS xnat_a_ygtssdata_tdata_ext_xn_xnat_a_ygtssdata0,
                                    xnat_a_ygtssdata_1.xnat_experimentdata22 AS xnat_a_ygtssdata_tdata_ex_xnat_experimentdata22,
                                    xnat_a_ygtssdata_1.xnat_subjectassessordata19 AS xnat_a_ygtssdata_tss_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.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_a_ygtssdata0,
    table1_2.date AS xnat_experimentdata22,
    table0_1.subject_id AS xnat_subjectassessordata19
   FROM ((public.xnat_a_ygtssdata xnat_a_ygtssdata_2
     LEFT JOIN public.xnat_subjectassessordata table0_1 ON (((xnat_a_ygtssdata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_experimentdata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))) xnat_a_ygtssdata_1 ON (((xnat_subjectdata.id)::text = (xnat_a_ygtssdata_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_a_ygtssdata_tdata_ex_xnat_experimentdata22 DESC) map_xnat_subjectdata_xnat_demographicdata ON (((table1.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_a_ygtssdata_tdata_ext_xn_xnat_a_ygtssdata0)::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_a_ygtssdata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_a_ygtssdata0
           FROM ( SELECT table1.id AS xnat_a_ygtssdata0,
                    table1.date AS xnat_experimentdata22
                   FROM ((public.xnat_a_ygtssdata xnat_a_ygtssdata
                     LEFT JOIN public.xnat_subjectassessordata table0 ON (((xnat_a_ygtssdata.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_a_ygtssdata0)::text = (search.xnat_a_ygtssdata0)::text)))
  ORDER BY search.xnat_subjectassessordata19;


ALTER TABLE public.displayfields_xnat_a_ygtssdata OWNER TO xnat;

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

CREATE TABLE public.xnat_algorithm (
    family_xnat_dicomcodedvalue_id integer DEFAULT 0 NOT NULL,
    name character varying(255),
    version character varying(255),
    source character varying(255),
    parameters text,
    namecode_xnat_dicomcodedvalue_id integer,
    algorithm_info integer,
    xnat_algorithm_id integer NOT NULL
);


ALTER TABLE public.xnat_algorithm OWNER TO xnat;

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

CREATE TABLE public.xnat_algorithm_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_algorithm_meta_data OWNER TO xnat;

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

CREATE VIEW public.displayfields_xnat_algorithm AS
 SELECT search.xnat_algorithm_meta_data49 AS insert_date,
    search.table2_login AS insert_user,
    search.xnat_algorithm1 AS name,
    search.xnat_algorithm2 AS version,
    search.xnat_algorithm3 AS source,
    search.xnat_algorithm4 AS parameters,
    search.xnat_algorithm_meta_data46 AS quarantine_status
   FROM (( SELECT DISTINCT xnat_algorithm.xnat_algorithm_id AS xnat_algorithm7,
            table1.status AS xnat_algorithm_meta_data46,
            table1.insert_date AS xnat_algorithm_meta_data49,
            table2.login AS table2_login,
            xnat_algorithm.name AS xnat_algorithm1,
            xnat_algorithm.version AS xnat_algorithm2,
            xnat_algorithm.source AS xnat_algorithm3,
            xnat_algorithm.parameters AS xnat_algorithm4
           FROM ((public.xnat_algorithm xnat_algorithm
             LEFT JOIN public.xnat_algorithm_meta_data table1 ON ((xnat_algorithm.algorithm_info = table1.meta_data_id)))
             LEFT JOIN public.xdat_user table2 ON ((table1.insert_user_xdat_user_id = table2.xdat_user_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_algorithm7
           FROM ( SELECT xnat_algorithm.xnat_algorithm_id AS xnat_algorithm7,
                    table1.insert_date AS xnat_algorithm_meta_data49
                   FROM (public.xnat_algorithm xnat_algorithm
                     LEFT JOIN public.xnat_algorithm_meta_data table1 ON ((xnat_algorithm.algorithm_info = table1.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.xnat_algorithm7 = search.xnat_algorithm7)))
  ORDER BY search.xnat_algorithm_meta_data49;


ALTER TABLE public.displayfields_xnat_algorithm OWNER TO xnat;

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

CREATE TABLE public.xnat_crscandata (
    xnat_imagescandata_id integer DEFAULT 0 NOT NULL,
    crscandata_info integer
);


ALTER TABLE public.xnat_crscandata OWNER TO xnat;

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

CREATE TABLE public.xnat_crscandata_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_crscandata_meta_data OWNER TO xnat;

--
