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

CREATE TABLE public.xnat_mrscandata (
    xnat_imagescandata_id integer DEFAULT 0 NOT NULL,
    coil character varying(255),
    fieldstrength character varying(255),
    marker character varying(255),
    stabilization character varying(255),
    filenameuuid character varying(255),
    parameters_voxelres_units character varying(255),
    parameters_voxelres_x double precision,
    parameters_voxelres_y double precision,
    parameters_voxelres_z double precision,
    parameters_orientation character varying(5),
    parameters_subjectposition character varying(255),
    parameters_fov_x integer,
    parameters_fov_y integer,
    parameters_matrix_x integer,
    parameters_matrix_y integer,
    parameters_partitions integer,
    parameters_tr double precision,
    parameters_te double precision,
    parameters_deltate double precision,
    parameters_ti double precision,
    parameters_flip integer,
    parameters_sequence character varying(255),
    parameters_origin character varying(255),
    parameters_imagetype character varying(255),
    parameters_scansequence character varying(255),
    parameters_seqvariant character varying(255),
    parameters_scanoptions character varying(255),
    parameters_acqtype character varying(255),
    parameters_readoutsamplespacing character varying(255),
    parameters_coil character varying(255),
    parameters_coilelements character varying(255),
    parameters_dtiacqcount integer,
    parameters_pixelbandwidth double precision,
    parameters_echospacing double precision,
    parameters_phaseencodingdirection character varying(255),
    parameters_acqtime character varying(255),
    parameters_diffusion_bvalues character varying(255),
    parameters_diffusion_bmax character varying(255),
    parameters_diffusion_directionality character varying(255),
    parameters_diffusion_orientations character varying(255),
    parameters_diffusion_anisotropytype character varying(255),
    parameters_diffusion_refocusflipangle character varying(255),
    parameters_inplanephaseencoding_direction character varying(255),
    parameters_inplanephaseencoding_rotation character varying(255),
    parameters_inplanephaseencoding_polarityswap character varying(255),
    parameters_inplanephaseencoding_directionpositive character varying(255),
    parameters_pmc character varying(255),
    dcmvalidation character varying(255),
    dcmvalidation_status integer,
    mrscandata_info integer
);


ALTER TABLE public.xnat_mrscandata OWNER TO xnat;

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

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

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

CREATE VIEW public.displayfields_xnat_mrscandata AS
 SELECT search.xnat_imagescandata51 AS image_session_id,
    search.xnat_imagescandata52 AS note,
    search.xnat_imagescandata53 AS quality,
    search.xnat_imagescandata54 AS condition,
    search.xnat_imagescandata55 AS series_description,
    search.xnat_imagescandata57 AS documentation,
    search.xnat_imagescandata58 AS scanner,
    search.xnat_imagescandata59 AS scanner_manufacturer,
    search.xnat_imagescandata60 AS scanner_model,
    search.xnat_imagescandata62 AS modality,
    search.xnat_imagescandata63 AS frames,
    search.xnat_imagescandata64 AS operator,
    search.xnat_imagescandata66 AS starttime,
    search.xnat_imagescandata68 AS id,
    search.xnat_imagescandata69 AS type,
    search.xnat_imagescandata70 AS uid,
    search.xnat_imagescandata71 AS project,
    search.xnat_mrscandata_meta_data190 AS insert_date,
    search.table4_login AS insert_user,
    search.xnat_mrscandata1 AS coil,
    search.xnat_mrscandata2 AS fieldstrength,
    search.xnat_mrscandata3 AS marker,
    search.xnat_mrscandata4 AS stabilization,
    search.xnat_mrscandata6 AS parameters_voxelres_units,
    search.xnat_mrscandata7 AS parameters_voxelres_x,
    search.xnat_mrscandata8 AS parameters_voxelres_y,
    search.xnat_mrscandata9 AS parameters_voxelres_z,
    search.xnat_mrscandata10 AS parameters_orientation,
    search.xnat_mrscandata12 AS parameters_fov_x,
    search.xnat_mrscandata13 AS parameters_fov_y,
    search.xnat_mrscandata14 AS parameters_matrix_x,
    search.xnat_mrscandata15 AS parameters_matrix_y,
    search.xnat_mrscandata16 AS parameters_partitions,
    search.xnat_mrscandata17 AS parameters_tr,
    search.xnat_mrscandata18 AS parameters_te,
    search.xnat_mrscandata20 AS parameters_ti,
    search.xnat_mrscandata21 AS parameters_flip,
    search.xnat_mrscandata22 AS parameters_sequence,
    search.xnat_mrscandata23 AS parameters_origin,
    search.xnat_mrscandata24 AS parameters_imagetype,
    search.xnat_mrscandata25 AS parameters_scansequence,
    search.xnat_mrscandata26 AS parameters_seqvariant,
    search.xnat_mrscandata27 AS parameters_scanoptions,
    search.xnat_mrscandata28 AS parameters_acqtype,
    search.xnat_mrscandata30 AS parameters_coil,
    search.xnat_mrscandata32 AS parameters_dtiacqcount,
    search.xnat_mrscandata33 AS parameters_pixelbandwidth,
    search.xnat_mrscandata37 AS parameters_diffusion_bvalues,
    search.xnat_mrscandata39 AS parameters_diffusion_directionality,
    search.xnat_mrscandata40 AS parameters_diffusion_orientations,
    search.xnat_mrscandata41 AS parameters_diffusion_anisotropytype,
    search.xnat_mrscandata48 AS dcmvalidation,
    search.xnat_mrscandata49 AS dcmvalidation_status,
    search.xnat_mrscandata_meta_data187 AS quarantine_status
   FROM (( SELECT DISTINCT table0.xnat_imagescandata_id AS xnat_mrscandata0,
            table2.status AS xnat_mrscandata_meta_data187,
            table0.image_session_id AS xnat_imagescandata51,
            table0.note AS xnat_imagescandata52,
            table0.quality AS xnat_imagescandata53,
            table0.condition AS xnat_imagescandata54,
            table0.series_description AS xnat_imagescandata55,
            table0.documentation AS xnat_imagescandata57,
            table0.scanner AS xnat_imagescandata58,
            table0.scanner_manufacturer AS xnat_imagescandata59,
            table0.scanner_model AS xnat_imagescandata60,
            table0.modality AS xnat_imagescandata62,
            table0.frames AS xnat_imagescandata63,
            table0.operator AS xnat_imagescandata64,
            table0.starttime AS xnat_imagescandata66,
            table0.id AS xnat_imagescandata68,
            table0.type AS xnat_imagescandata69,
            table0.uid AS xnat_imagescandata70,
            table0.project AS xnat_imagescandata71,
            table2.insert_date AS xnat_mrscandata_meta_data190,
            table4.login AS table4_login,
            xnat_mrscandata.coil AS xnat_mrscandata1,
            xnat_mrscandata.fieldstrength AS xnat_mrscandata2,
            xnat_mrscandata.marker AS xnat_mrscandata3,
            xnat_mrscandata.stabilization AS xnat_mrscandata4,
            xnat_mrscandata.parameters_voxelres_units AS xnat_mrscandata6,
            xnat_mrscandata.parameters_voxelres_x AS xnat_mrscandata7,
            xnat_mrscandata.parameters_voxelres_y AS xnat_mrscandata8,
            xnat_mrscandata.parameters_voxelres_z AS xnat_mrscandata9,
            xnat_mrscandata.parameters_orientation AS xnat_mrscandata10,
            xnat_mrscandata.parameters_fov_x AS xnat_mrscandata12,
            xnat_mrscandata.parameters_fov_y AS xnat_mrscandata13,
            xnat_mrscandata.parameters_matrix_x AS xnat_mrscandata14,
            xnat_mrscandata.parameters_matrix_y AS xnat_mrscandata15,
            xnat_mrscandata.parameters_partitions AS xnat_mrscandata16,
            xnat_mrscandata.parameters_tr AS xnat_mrscandata17,
            xnat_mrscandata.parameters_te AS xnat_mrscandata18,
            xnat_mrscandata.parameters_ti AS xnat_mrscandata20,
            xnat_mrscandata.parameters_flip AS xnat_mrscandata21,
            xnat_mrscandata.parameters_sequence AS xnat_mrscandata22,
            xnat_mrscandata.parameters_origin AS xnat_mrscandata23,
            xnat_mrscandata.parameters_imagetype AS xnat_mrscandata24,
            xnat_mrscandata.parameters_scansequence AS xnat_mrscandata25,
            xnat_mrscandata.parameters_seqvariant AS xnat_mrscandata26,
            xnat_mrscandata.parameters_scanoptions AS xnat_mrscandata27,
            xnat_mrscandata.parameters_acqtype AS xnat_mrscandata28,
            xnat_mrscandata.parameters_coil AS xnat_mrscandata30,
            xnat_mrscandata.parameters_dtiacqcount AS xnat_mrscandata32,
            xnat_mrscandata.parameters_pixelbandwidth AS xnat_mrscandata33,
            xnat_mrscandata.parameters_diffusion_bvalues AS xnat_mrscandata37,
            xnat_mrscandata.parameters_diffusion_directionality AS xnat_mrscandata39,
            xnat_mrscandata.parameters_diffusion_orientations AS xnat_mrscandata40,
            xnat_mrscandata.parameters_diffusion_anisotropytype AS xnat_mrscandata41,
            xnat_mrscandata.dcmvalidation AS xnat_mrscandata48,
            xnat_mrscandata.dcmvalidation_status AS xnat_mrscandata49
           FROM (((public.xnat_mrscandata xnat_mrscandata
             LEFT JOIN public.xnat_imagescandata table0 ON ((xnat_mrscandata.xnat_imagescandata_id = table0.xnat_imagescandata_id)))
             LEFT JOIN public.xnat_mrscandata_meta_data table2 ON ((xnat_mrscandata.mrscandata_info = table2.meta_data_id)))
             LEFT JOIN public.xdat_user table4 ON ((table2.insert_user_xdat_user_id = table4.xdat_user_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_mrscandata0
           FROM ( SELECT table0.xnat_imagescandata_id AS xnat_mrscandata0,
                    table2.insert_date AS xnat_mrscandata_meta_data190
                   FROM ((public.xnat_mrscandata xnat_mrscandata
                     LEFT JOIN public.xnat_imagescandata table0 ON ((xnat_mrscandata.xnat_imagescandata_id = table0.xnat_imagescandata_id)))
                     LEFT JOIN public.xnat_mrscandata_meta_data table2 ON ((xnat_mrscandata.mrscandata_info = table2.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.xnat_mrscandata0 = search.xnat_mrscandata0)))
  ORDER BY search.xnat_imagescandata51;


ALTER TABLE public.displayfields_xnat_mrscandata OWNER TO xnat;

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

CREATE VIEW public.dti_count AS
 SELECT xnat_imagescandata.image_session_id,
    count(*) AS dti_count
   FROM public.xnat_imagescandata
  WHERE (((xnat_imagescandata.series_description)::text ~~ '%DTI%'::text) OR ((xnat_imagescandata.type)::text ~~ '%DTI%'::text))
  GROUP BY xnat_imagescandata.image_session_id;


ALTER TABLE public.dti_count OWNER TO xnat;

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

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


ALTER TABLE public.mr_projects OWNER TO xnat;

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

CREATE VIEW public.mr_scan_count_agg AS
 SELECT _types.image_session_id,
    btrim(public.xs_a_concat((_types.type_count || ', '::text)), ', '::text) AS type_count
   FROM ( SELECT xnat_imagescandata.image_session_id,
            ((((xnat_imagescandata.type)::text || '('::text) || count(xnat_imagescandata.id)) || ')'::text) AS type_count
           FROM public.xnat_imagescandata
          GROUP BY xnat_imagescandata.image_session_id, xnat_imagescandata.type
          ORDER BY xnat_imagescandata.image_session_id, xnat_imagescandata.type) _types
  GROUP BY _types.image_session_id;


ALTER TABLE public.mr_scan_count_agg OWNER TO xnat;

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

CREATE VIEW public.ordered_workflows AS
 SELECT wrk_workflowdata.id,
    wrk_workflowdata.status,
    wrk_workflowdata.wrk_workflowdata_id,
        CASE wrk_workflowdata.pipeline_name
            WHEN 'Transfer'::text THEN 'Archive'::text
            ELSE
            CASE public.xs_lastposition('/'::text, (wrk_workflowdata.pipeline_name)::text)
                WHEN 0 THEN (wrk_workflowdata.pipeline_name)::text
                ELSE "substring"("substring"((wrk_workflowdata.pipeline_name)::text, (public.xs_lastposition('/'::text, (wrk_workflowdata.pipeline_name)::text) + 1)), 1, (public.xs_lastposition('.'::text, "substring"((wrk_workflowdata.pipeline_name)::text, (public.xs_lastposition('/'::text, (wrk_workflowdata.pipeline_name)::text) + 1))) - 1))
            END
        END AS pipeline_name
   FROM (public.wrk_workflowdata
     RIGHT JOIN ( SELECT wrk_workflowdata_1.id,
            max(wrk_workflowdata_1.launch_time) AS launch_time
           FROM public.wrk_workflowdata wrk_workflowdata_1
          GROUP BY wrk_workflowdata_1.id) wrk_max ON ((((wrk_workflowdata.id)::text = (wrk_max.id)::text) AND (wrk_workflowdata.launch_time = wrk_max.launch_time))));


ALTER TABLE public.ordered_workflows OWNER TO xnat;

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

CREATE VIEW public.subject_label AS
 SELECT isd.id AS image_session_id,
    sd.label AS subject_label
   FROM ((public.xnat_imagesessiondata isd
     LEFT JOIN public.xnat_subjectassessordata sad ON (((isd.id)::text = (sad.id)::text)))
     LEFT JOIN public.xnat_subjectdata sd ON (((sad.subject_id)::text = (sd.id)::text)));


ALTER TABLE public.subject_label OWNER TO xnat;

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

CREATE TABLE public.xnat_mrsessiondata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    coil character varying(255),
    fieldstrength character varying(255),
    marker character varying(255),
    stabilization character varying(255),
    mrsessiondata_info integer
);


ALTER TABLE public.xnat_mrsessiondata OWNER TO xnat;

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

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

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

CREATE VIEW public.displayfields_xnat_mrsessiondata AS
 SELECT search.xnat_mrsessiondata0 AS session_id,
    search.mr_projects_projects AS projects,
    '/@WEBAPP/images/v.gif'::text AS view,
    search.xnat_subjectassessordata23 AS subject_id,
    search.subject_label_subject_label AS subject_label,
    '/@WEBAPP/images/r.gif'::text AS rpt,
    search.table5_login AS insert_user,
    search.xnat_mrsessiondata_meta_data980 AS insert_date,
    search.xnat_experimentdata26 AS date,
    (search.xnat_experimentdata26)::character varying AS date_char,
    search.xnat_experimentdata37 AS visit,
    (((search.xnat_investigatordata66)::text || ' '::text) || (search.xnat_investigatordata67)::text) AS invest_search,
    search.xnat_investigatordata67 AS invest,
    search.xnat_investigatordata74 AS invest_id,
    search.xnat_investigatordata67 AS invest_csv,
    "substring"(search.xnat_experimentdata31, 0, 10) AS mr_notes,
    search.xnat_experimentdata31 AS mr_notes_csv,
    "substring"((search.xnat_imagesessiondata10)::text, 0, 6) AS operator,
    search.xnat_imagesessiondata17 AS type,
    search.xnat_imagesessiondata7 AS scanner,
    "substring"((search.xnat_mrsessiondata3)::text, 0, 6) AS marker,
    "substring"((search.xnat_mrsessiondata4)::text, 0, 6) AS stabilization,
    search.xnat_imagesessiondata10 AS operator_csv,
    search.xnat_imagesessiondata7 AS scanner_csv,
    search.xnat_mrsessiondata3 AS marker_csv,
    search.xnat_mrsessiondata4 AS stabilization_csv,
    round((COALESCE(search.xnat_subjectassessordata24, date_part('year'::text, age((search.xnat_experimentdata26)::timestamp with time zone, (search.xnat_demographicdata_xnat_demographicdata1)::timestamp with time zone)), (date_part('year'::text, search.xnat_experimentdata26) - (search.xnat_demographicdata_xnat_demographicdata2)::double precision)))::numeric, 2) AS gen_age,
    floor((COALESCE(search.xnat_subjectassessordata24, (search.xnat_demographicdata_xnat_demographicdata3)::double precision, date_part('year'::text, age((search.xnat_experimentdata26)::timestamp with time zone, (search.xnat_demographicdata_xnat_demographicdata1)::timestamp with time zone)), (date_part('year'::text, search.xnat_experimentdata26) - (search.xnat_demographicdata_xnat_demographicdata2)::double precision)))::numeric) AS age,
    search.dti_count_dti_count AS dti_count,
    COALESCE(search.xnat_mrsessiondata_meta_data976, search.xnat_mrsessiondata_meta_data980) AS last_modified,
    search.mr_scan_count_agg_type_count AS mr_scan_count_agg,
    (('<B>'::text ||
        CASE search.ordered_workflows_status
            WHEN 'Complete'::text THEN (('<FONT COLOR=green>'::text || search.ordered_workflows_pipeline_name) || '</FONT>'::text)
            WHEN 'In Progress'::text THEN (('<FONT COLOR=SlateGrey>'::text || search.ordered_workflows_pipeline_name) || '</FONT>'::text)
            WHEN 'Running'::text THEN (('<FONT COLOR=SlateGrey>'::text || search.ordered_workflows_pipeline_name) || '</FONT>'::text)
            WHEN 'Queued'::text THEN (('<FONT COLOR=orange>'::text || search.ordered_workflows_pipeline_name) || '</FONT>'::text)
            WHEN 'Failed'::text THEN (('<FONT COLOR=red>'::text || search.ordered_workflows_pipeline_name) || '</FONT>'::text)
            ELSE (('<FONT COLOR=orange>'::text || search.ordered_workflows_pipeline_name) || '</FONT>'::text)
        END) || '</B>'::text) AS workflow_status,
    search.xnat_experimentdata36 AS project,
    COALESCE(search.xnat_experimentdata42, search.xnat_mrsessiondata0) AS label,
    search.xnat_mrsessiondata_meta_data977 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_mrsessiondata0) search_1.xnat_mrsessiondata0,
            search_1.xnat_mrsessiondata_meta_data977,
            search_1.xnat_subjectassessordata23,
            search_1.table5_login,
            search_1.xnat_mrsessiondata_meta_data980,
            search_1.xnat_experimentdata26,
            search_1.xnat_experimentdata37,
            search_1.xnat_investigatordata66,
            search_1.xnat_investigatordata67,
            search_1.xnat_investigatordata74,
            search_1.xnat_experimentdata31,
            search_1.xnat_imagesessiondata10,
            search_1.xnat_imagesessiondata17,
            search_1.xnat_imagesessiondata7,
            search_1.xnat_mrsessiondata3,
            search_1.xnat_mrsessiondata4,
            search_1.xnat_subjectassessordata24,
            search_1.xnat_mrsessiondata_meta_data976,
            search_1.xnat_experimentdata36,
            search_1.xnat_experimentdata42,
            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_demographicdata_xnat_demographicdata3,
            search_1.mr_projects_projects,
            search_1.subject_label_subject_label,
            search_1.dti_count_dti_count,
            search_1.mr_scan_count_agg_type_count,
            search_1.ordered_workflows_status,
            search_1.ordered_workflows_pipeline_name
           FROM ( SELECT table2.id AS xnat_mrsessiondata0,
                    table4.status AS xnat_mrsessiondata_meta_data977,
                    table1.subject_id AS xnat_subjectassessordata23,
                    table5.login AS table5_login,
                    table4.insert_date AS xnat_mrsessiondata_meta_data980,
                    table2.date AS xnat_experimentdata26,
                    table2.visit_id AS xnat_experimentdata37,
                    table7.firstname AS xnat_investigatordata66,
                    table7.lastname AS xnat_investigatordata67,
                    table7.xnat_investigatordata_id AS xnat_investigatordata74,
                    table2.note AS xnat_experimentdata31,
                    table0.operator AS xnat_imagesessiondata10,
                    table0.session_type AS xnat_imagesessiondata17,
                    table0.scanner AS xnat_imagesessiondata7,
                    xnat_mrsessiondata.marker AS xnat_mrsessiondata3,
                    xnat_mrsessiondata.stabilization AS xnat_mrsessiondata4,
                    table1.age AS xnat_subjectassessordata24,
                    table4.last_modified AS xnat_mrsessiondata_meta_data976,
                    table2.project AS xnat_experimentdata36,
                    table2.label AS xnat_experimentdata42,
                    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_demographicdata.xnat_demographicdata3 AS xnat_demographicdata_xnat_demographicdata3,
                    mr_projects.projects AS mr_projects_projects,
                    subject_label.subject_label AS subject_label_subject_label,
                    dti_count.dti_count AS dti_count_dti_count,
                    mr_scan_count_agg.type_count AS mr_scan_count_agg_type_count,
                    ordered_workflows.status AS ordered_workflows_status,
                    ordered_workflows.pipeline_name AS ordered_workflows_pipeline_name
                   FROM (((((((((((((public.xnat_mrsessiondata xnat_mrsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_mrsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))
                     LEFT JOIN public.xnat_mrsessiondata_meta_data table4 ON ((xnat_mrsessiondata.mrsessiondata_info = table4.meta_data_id)))
                     LEFT JOIN public.xdat_user table5 ON ((table4.insert_user_xdat_user_id = table5.xdat_user_id)))
                     LEFT JOIN public.xnat_investigatordata table7 ON ((table2.investigator_xnat_investigatordata_id = table7.xnat_investigatordata_id)))
                     LEFT JOIN public.mr_projects mr_projects ON (((table2.id)::text = (mr_projects.id)::text)))
                     LEFT JOIN public.subject_label subject_label ON (((table2.id)::text = (subject_label.image_session_id)::text)))
                     LEFT JOIN public.dti_count dti_count ON (((table2.id)::text = (dti_count.image_session_id)::text)))
                     LEFT JOIN public.mr_scan_count_agg mr_scan_count_agg ON (((table2.id)::text = (mr_scan_count_agg.image_session_id)::text)))
                     LEFT JOIN public.ordered_workflows ordered_workflows ON (((table2.id)::text = (ordered_workflows.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_mrsessiondata_sordata_ex_xnat_mrsessiondata0,
                            search_2.xnat_mrsessiondata_sordata__xnat_experimentdata26,
                            search_2.xnat_mrsessiondata_sor_xnat_subjectassessordata23,
                            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_mrsessiondata_1.xnat_mrsessiondata0 AS xnat_mrsessiondata_sordata_ex_xnat_mrsessiondata0,
                                    xnat_mrsessiondata_1.xnat_experimentdata26 AS xnat_mrsessiondata_sordata__xnat_experimentdata26,
                                    xnat_mrsessiondata_1.xnat_subjectassessordata23 AS xnat_mrsessiondata_sor_xnat_subjectassessordata23
                                   FROM ((((public.xnat_subjectdata xnat_subjectdata
                                     LEFT JOIN public.xnat_subjectdata_meta_data table1_1 ON ((xnat_subjectdata.subjectdata_info = table1_1.meta_data_id)))
                                     LEFT JOIN ( SELECT xnat_subjectdata_1.id AS xnat_subjectdata3,
    table1_2.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata91,
    table2_1.insert_date AS xnat_subjectdata_meta_data328
   FROM ((public.xnat_subjectdata xnat_subjectdata_1
     LEFT JOIN public.xnat_abstractdemographicdata table1_2 ON ((xnat_subjectdata_1.demographics_xnat_abstractdemographicdata_id = table1_2.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_subjectdata_meta_data table2_1 ON ((xnat_subjectdata_1.subjectdata_info = table2_1.meta_data_id)))) map_xnat_demographicdata ON (((xnat_subjectdata.id)::text = (map_xnat_demographicdata.xnat_subjectdata3)::text)))
                                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
    table2_1.insert_date AS xnat_demographicdata_meta_data47,
    table0_1.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata27
   FROM ((public.xnat_demographicdata xnat_demographicdata_2
     LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_2.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_2.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata_1 ON ((map_xnat_demographicdata.xnat_abstractdemographicdata91 = xnat_demographicdata_1.xnat_abstractdemographicdata27)))
                                     LEFT JOIN ( SELECT table2_1.id AS xnat_mrsessiondata0,
    table2_1.date AS xnat_experimentdata26,
    table1_2.subject_id AS xnat_subjectassessordata23
   FROM (((public.xnat_mrsessiondata xnat_mrsessiondata_2
     LEFT JOIN public.xnat_imagesessiondata table0_1 ON (((xnat_mrsessiondata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_subjectassessordata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))
     LEFT JOIN public.xnat_experimentdata table2_1 ON (((table1_2.id)::text = (table2_1.id)::text)))) xnat_mrsessiondata_1 ON (((xnat_subjectdata.id)::text = (xnat_mrsessiondata_1.xnat_subjectassessordata23)::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_mrsessiondata_sordata__xnat_experimentdata26 DESC) map_xnat_subjectdata_xnat_demographicdata ON (((table2.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_mrsessiondata_sordata_ex_xnat_mrsessiondata0)::text)))
                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
                            table2_1.insert_date AS xnat_demographicdata_meta_data47,
                            xnat_demographicdata_1.dob AS xnat_demographicdata1,
                            xnat_demographicdata_1.yob AS xnat_demographicdata2,
                            xnat_demographicdata_1.age AS xnat_demographicdata3
                           FROM ((public.xnat_demographicdata xnat_demographicdata_1
                             LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_1.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
                             LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_1.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata ON ((map_xnat_subjectdata_xnat_demographicdata.xnat_demographicdata_demograp_xnat_demographicdata0 = xnat_demographicdata.xnat_demographicdata0)))) search_1
          ORDER BY search_1.xnat_mrsessiondata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_mrsessiondata0
           FROM ( SELECT table2.id AS xnat_mrsessiondata0,
                    table2.date AS xnat_experimentdata26
                   FROM (((public.xnat_mrsessiondata xnat_mrsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_mrsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))) where_clause_1) where_clause ON (((where_clause.xnat_mrsessiondata0)::text = (search.xnat_mrsessiondata0)::text)))
  ORDER BY search.xnat_mrsessiondata0;


ALTER TABLE public.displayfields_xnat_mrsessiondata OWNER TO xnat;

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

CREATE TABLE public.xnat_mrsscandata (
    xnat_imagescandata_id integer DEFAULT 0 NOT NULL,
    mrsscandata_info integer
);


ALTER TABLE public.xnat_mrsscandata OWNER TO xnat;

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

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

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

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


ALTER TABLE public.displayfields_xnat_mrsscandata OWNER TO xnat;

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

CREATE TABLE public.xnat_nmscandata (
    xnat_imagescandata_id integer DEFAULT 0 NOT NULL,
    nmscandata_info integer
);


ALTER TABLE public.xnat_nmscandata OWNER TO xnat;

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

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

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

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


ALTER TABLE public.displayfields_xnat_nmscandata OWNER TO xnat;

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

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


ALTER TABLE public.xnat_nmsessiondata OWNER TO xnat;

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

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

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

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


ALTER TABLE public.xnat_nmsessiondata_projects OWNER TO xnat;

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

CREATE VIEW public.displayfields_xnat_nmsessiondata AS
 SELECT search.xnat_subjectassessordata19 AS subject_id,
    search.xnat_nmsessiondata0 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_nmsessiondata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata38, search.xnat_nmsessiondata0) AS label,
    search.table5_login AS insert_user,
    search.xnat_nmsessiondata_meta_data976 AS insert_date,
    search.xnat_experimentdata32 AS project,
    search.xnat_nmsessiondata_meta_data973 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_nmsessiondata0) search_1.xnat_nmsessiondata0,
            search_1.xnat_nmsessiondata_meta_data973,
            search_1.xnat_subjectassessordata19,
            search_1.xnat_experimentdata22,
            search_1.xnat_experimentdata38,
            search_1.table5_login,
            search_1.xnat_nmsessiondata_meta_data976,
            search_1.xnat_experimentdata32,
            search_1.xnat_demographicdata_demograp_xnat_demographicdata0,
            search_1.xnat_demographicdata_at_demographicdata_meta_data47,
            search_1.xnat_demographicdata_xnat_demographicdata1,
            search_1.xnat_demographicdata_xnat_demographicdata2,
            search_1.xnat_nmsessiondata_projects_projects
           FROM ( SELECT table2.id AS xnat_nmsessiondata0,
                    table4.status AS xnat_nmsessiondata_meta_data973,
                    table1.subject_id AS xnat_subjectassessordata19,
                    table2.date AS xnat_experimentdata22,
                    table2.label AS xnat_experimentdata38,
                    table5.login AS table5_login,
                    table4.insert_date AS xnat_nmsessiondata_meta_data976,
                    table2.project AS xnat_experimentdata32,
                    xnat_demographicdata.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                    xnat_demographicdata.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                    xnat_demographicdata.xnat_demographicdata1 AS xnat_demographicdata_xnat_demographicdata1,
                    xnat_demographicdata.xnat_demographicdata2 AS xnat_demographicdata_xnat_demographicdata2,
                    xnat_nmsessiondata_projects.projects AS xnat_nmsessiondata_projects_projects
                   FROM ((((((((public.xnat_nmsessiondata xnat_nmsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_nmsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))
                     LEFT JOIN public.xnat_nmsessiondata_meta_data table4 ON ((xnat_nmsessiondata.nmsessiondata_info = table4.meta_data_id)))
                     LEFT JOIN public.xdat_user table5 ON ((table4.insert_user_xdat_user_id = table5.xdat_user_id)))
                     LEFT JOIN public.xnat_nmsessiondata_projects xnat_nmsessiondata_projects ON (((table2.id)::text = (xnat_nmsessiondata_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_nmsessiondata_sordata_ex_xnat_nmsessiondata0,
                            search_2.xnat_nmsessiondata_sordata__xnat_experimentdata22,
                            search_2.xnat_nmsessiondata_sor_xnat_subjectassessordata19,
                            date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47)) AS xnat_subjectdata_xnat_demographicdata_diff
                           FROM ( SELECT xnat_subjectdata.id AS xnat_subjectdata3,
                                    table1_1.insert_date AS xnat_subjectdata_meta_data328,
                                    xnat_demographicdata_1.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                                    xnat_demographicdata_1.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                                    xnat_demographicdata_1.xnat_abstractdemographicdata27 AS xnat_demographicdata_xnat_abstractdemographicdata27,
                                    xnat_nmsessiondata_1.xnat_nmsessiondata0 AS xnat_nmsessiondata_sordata_ex_xnat_nmsessiondata0,
                                    xnat_nmsessiondata_1.xnat_experimentdata22 AS xnat_nmsessiondata_sordata__xnat_experimentdata22,
                                    xnat_nmsessiondata_1.xnat_subjectassessordata19 AS xnat_nmsessiondata_sor_xnat_subjectassessordata19
                                   FROM ((((public.xnat_subjectdata xnat_subjectdata
                                     LEFT JOIN public.xnat_subjectdata_meta_data table1_1 ON ((xnat_subjectdata.subjectdata_info = table1_1.meta_data_id)))
                                     LEFT JOIN ( SELECT xnat_subjectdata_1.id AS xnat_subjectdata3,
    table1_2.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata91,
    table2_1.insert_date AS xnat_subjectdata_meta_data328
   FROM ((public.xnat_subjectdata xnat_subjectdata_1
     LEFT JOIN public.xnat_abstractdemographicdata table1_2 ON ((xnat_subjectdata_1.demographics_xnat_abstractdemographicdata_id = table1_2.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_subjectdata_meta_data table2_1 ON ((xnat_subjectdata_1.subjectdata_info = table2_1.meta_data_id)))) map_xnat_demographicdata ON (((xnat_subjectdata.id)::text = (map_xnat_demographicdata.xnat_subjectdata3)::text)))
                                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
    table2_1.insert_date AS xnat_demographicdata_meta_data47,
    table0_1.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata27
   FROM ((public.xnat_demographicdata xnat_demographicdata_2
     LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_2.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_2.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata_1 ON ((map_xnat_demographicdata.xnat_abstractdemographicdata91 = xnat_demographicdata_1.xnat_abstractdemographicdata27)))
                                     LEFT JOIN ( SELECT table2_1.id AS xnat_nmsessiondata0,
    table2_1.date AS xnat_experimentdata22,
    table1_2.subject_id AS xnat_subjectassessordata19
   FROM (((public.xnat_nmsessiondata xnat_nmsessiondata_2
     LEFT JOIN public.xnat_imagesessiondata table0_1 ON (((xnat_nmsessiondata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_subjectassessordata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))
     LEFT JOIN public.xnat_experimentdata table2_1 ON (((table1_2.id)::text = (table2_1.id)::text)))) xnat_nmsessiondata_1 ON (((xnat_subjectdata.id)::text = (xnat_nmsessiondata_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_nmsessiondata_sordata__xnat_experimentdata22 DESC) map_xnat_subjectdata_xnat_demographicdata ON (((table2.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_nmsessiondata_sordata_ex_xnat_nmsessiondata0)::text)))
                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
                            table2_1.insert_date AS xnat_demographicdata_meta_data47,
                            xnat_demographicdata_1.dob AS xnat_demographicdata1,
                            xnat_demographicdata_1.yob AS xnat_demographicdata2
                           FROM ((public.xnat_demographicdata xnat_demographicdata_1
                             LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_1.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
                             LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_1.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata ON ((map_xnat_subjectdata_xnat_demographicdata.xnat_demographicdata_demograp_xnat_demographicdata0 = xnat_demographicdata.xnat_demographicdata0)))) search_1
          ORDER BY search_1.xnat_nmsessiondata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_nmsessiondata0
           FROM ( SELECT table2.id AS xnat_nmsessiondata0,
                    table2.date AS xnat_experimentdata22
                   FROM (((public.xnat_nmsessiondata xnat_nmsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_nmsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))) where_clause_1) where_clause ON (((where_clause.xnat_nmsessiondata0)::text = (search.xnat_nmsessiondata0)::text)))
  ORDER BY search.xnat_subjectassessordata19;


ALTER TABLE public.displayfields_xnat_nmsessiondata OWNER TO xnat;

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

CREATE TABLE public.xnat_opscandata (
    xnat_imagescandata_id integer DEFAULT 0 NOT NULL,
    opscandata_info integer
);


ALTER TABLE public.xnat_opscandata OWNER TO xnat;

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

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

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

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


ALTER TABLE public.displayfields_xnat_opscandata OWNER TO xnat;

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

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


ALTER TABLE public.xnat_opsessiondata OWNER TO xnat;

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

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

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

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


ALTER TABLE public.xnat_opsessiondata_projects OWNER TO xnat;

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

CREATE VIEW public.displayfields_xnat_opsessiondata AS
 SELECT search.xnat_subjectassessordata19 AS subject_id,
    search.xnat_opsessiondata0 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_opsessiondata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata38, search.xnat_opsessiondata0) AS label,
    search.table5_login AS insert_user,
    search.xnat_opsessiondata_meta_data976 AS insert_date,
    search.xnat_experimentdata32 AS project,
    search.xnat_opsessiondata_meta_data973 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_opsessiondata0) search_1.xnat_opsessiondata0,
            search_1.xnat_opsessiondata_meta_data973,
            search_1.xnat_subjectassessordata19,
            search_1.xnat_experimentdata22,
            search_1.xnat_experimentdata38,
            search_1.table5_login,
            search_1.xnat_opsessiondata_meta_data976,
            search_1.xnat_experimentdata32,
            search_1.xnat_demographicdata_demograp_xnat_demographicdata0,
            search_1.xnat_demographicdata_at_demographicdata_meta_data47,
            search_1.xnat_demographicdata_xnat_demographicdata1,
            search_1.xnat_demographicdata_xnat_demographicdata2,
            search_1.xnat_opsessiondata_projects_projects
           FROM ( SELECT table2.id AS xnat_opsessiondata0,
                    table4.status AS xnat_opsessiondata_meta_data973,
                    table1.subject_id AS xnat_subjectassessordata19,
                    table2.date AS xnat_experimentdata22,
                    table2.label AS xnat_experimentdata38,
                    table5.login AS table5_login,
                    table4.insert_date AS xnat_opsessiondata_meta_data976,
                    table2.project AS xnat_experimentdata32,
                    xnat_demographicdata.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                    xnat_demographicdata.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                    xnat_demographicdata.xnat_demographicdata1 AS xnat_demographicdata_xnat_demographicdata1,
                    xnat_demographicdata.xnat_demographicdata2 AS xnat_demographicdata_xnat_demographicdata2,
                    xnat_opsessiondata_projects.projects AS xnat_opsessiondata_projects_projects
                   FROM ((((((((public.xnat_opsessiondata xnat_opsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_opsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))
                     LEFT JOIN public.xnat_opsessiondata_meta_data table4 ON ((xnat_opsessiondata.opsessiondata_info = table4.meta_data_id)))
                     LEFT JOIN public.xdat_user table5 ON ((table4.insert_user_xdat_user_id = table5.xdat_user_id)))
                     LEFT JOIN public.xnat_opsessiondata_projects xnat_opsessiondata_projects ON (((table2.id)::text = (xnat_opsessiondata_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_opsessiondata_sordata_ex_xnat_opsessiondata0,
                            search_2.xnat_opsessiondata_sordata__xnat_experimentdata22,
                            search_2.xnat_opsessiondata_sor_xnat_subjectassessordata19,
                            date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47)) AS xnat_subjectdata_xnat_demographicdata_diff
                           FROM ( SELECT xnat_subjectdata.id AS xnat_subjectdata3,
                                    table1_1.insert_date AS xnat_subjectdata_meta_data328,
                                    xnat_demographicdata_1.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                                    xnat_demographicdata_1.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                                    xnat_demographicdata_1.xnat_abstractdemographicdata27 AS xnat_demographicdata_xnat_abstractdemographicdata27,
                                    xnat_opsessiondata_1.xnat_opsessiondata0 AS xnat_opsessiondata_sordata_ex_xnat_opsessiondata0,
                                    xnat_opsessiondata_1.xnat_experimentdata22 AS xnat_opsessiondata_sordata__xnat_experimentdata22,
                                    xnat_opsessiondata_1.xnat_subjectassessordata19 AS xnat_opsessiondata_sor_xnat_subjectassessordata19
                                   FROM ((((public.xnat_subjectdata xnat_subjectdata
                                     LEFT JOIN public.xnat_subjectdata_meta_data table1_1 ON ((xnat_subjectdata.subjectdata_info = table1_1.meta_data_id)))
                                     LEFT JOIN ( SELECT xnat_subjectdata_1.id AS xnat_subjectdata3,
    table1_2.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata91,
    table2_1.insert_date AS xnat_subjectdata_meta_data328
   FROM ((public.xnat_subjectdata xnat_subjectdata_1
     LEFT JOIN public.xnat_abstractdemographicdata table1_2 ON ((xnat_subjectdata_1.demographics_xnat_abstractdemographicdata_id = table1_2.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_subjectdata_meta_data table2_1 ON ((xnat_subjectdata_1.subjectdata_info = table2_1.meta_data_id)))) map_xnat_demographicdata ON (((xnat_subjectdata.id)::text = (map_xnat_demographicdata.xnat_subjectdata3)::text)))
                                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
    table2_1.insert_date AS xnat_demographicdata_meta_data47,
    table0_1.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata27
   FROM ((public.xnat_demographicdata xnat_demographicdata_2
     LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_2.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_2.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata_1 ON ((map_xnat_demographicdata.xnat_abstractdemographicdata91 = xnat_demographicdata_1.xnat_abstractdemographicdata27)))
                                     LEFT JOIN ( SELECT table2_1.id AS xnat_opsessiondata0,
    table2_1.date AS xnat_experimentdata22,
    table1_2.subject_id AS xnat_subjectassessordata19
   FROM (((public.xnat_opsessiondata xnat_opsessiondata_2
     LEFT JOIN public.xnat_imagesessiondata table0_1 ON (((xnat_opsessiondata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_subjectassessordata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))
     LEFT JOIN public.xnat_experimentdata table2_1 ON (((table1_2.id)::text = (table2_1.id)::text)))) xnat_opsessiondata_1 ON (((xnat_subjectdata.id)::text = (xnat_opsessiondata_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_opsessiondata_sordata__xnat_experimentdata22 DESC) map_xnat_subjectdata_xnat_demographicdata ON (((table2.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_opsessiondata_sordata_ex_xnat_opsessiondata0)::text)))
                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
                            table2_1.insert_date AS xnat_demographicdata_meta_data47,
                            xnat_demographicdata_1.dob AS xnat_demographicdata1,
                            xnat_demographicdata_1.yob AS xnat_demographicdata2
                           FROM ((public.xnat_demographicdata xnat_demographicdata_1
                             LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_1.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
                             LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_1.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata ON ((map_xnat_subjectdata_xnat_demographicdata.xnat_demographicdata_demograp_xnat_demographicdata0 = xnat_demographicdata.xnat_demographicdata0)))) search_1
          ORDER BY search_1.xnat_opsessiondata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_opsessiondata0
           FROM ( SELECT table2.id AS xnat_opsessiondata0,
                    table2.date AS xnat_experimentdata22
                   FROM (((public.xnat_opsessiondata xnat_opsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_opsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))) where_clause_1) where_clause ON (((where_clause.xnat_opsessiondata0)::text = (search.xnat_opsessiondata0)::text)))
  ORDER BY search.xnat_subjectassessordata19;


ALTER TABLE public.displayfields_xnat_opsessiondata OWNER TO xnat;

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

CREATE TABLE public.xnat_optscandata (
    xnat_imagescandata_id integer DEFAULT 0 NOT NULL,
    parameters_voxelres_units character varying(255),
    parameters_voxelres_x double precision,
    parameters_voxelres_y double precision,
    parameters_voxelres_z double precision,
    parameters_fov_x integer,
    parameters_fov_y integer,
    parameters_laterality character varying(255),
    parameters_illumination_wavelength character varying(255),
    parameters_illumination_power character varying(255),
    parameters_imagetype character varying(255),
    dcmvalidation character varying(255),
    dcmvalidation_status integer,
    optscandata_info integer
);


ALTER TABLE public.xnat_optscandata OWNER TO xnat;

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

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

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

CREATE VIEW public.displayfields_xnat_optscandata AS
 SELECT search.xnat_imagescandata14 AS image_session_id,
    search.xnat_imagescandata15 AS note,
    search.xnat_imagescandata16 AS quality,
    search.xnat_imagescandata17 AS condition,
    search.xnat_imagescandata18 AS series_description,
    search.xnat_imagescandata20 AS documentation,
    search.xnat_imagescandata21 AS scanner,
    search.xnat_imagescandata22 AS scanner_manufacturer,
    search.xnat_imagescandata23 AS scanner_model,
    search.xnat_imagescandata25 AS modality,
    search.xnat_imagescandata26 AS frames,
    search.xnat_imagescandata27 AS operator,
    search.xnat_imagescandata29 AS starttime,
    search.xnat_imagescandata31 AS id,
    search.xnat_imagescandata32 AS type,
    search.xnat_imagescandata33 AS uid,
    search.xnat_imagescandata34 AS project,
    search.xnat_optscandata_meta_data133 AS insert_date,
    search.table4_login AS insert_user,
    search.xnat_optscandata1 AS parameters_voxelres_units,
    search.xnat_optscandata2 AS parameters_voxelres_x,
    search.xnat_optscandata3 AS parameters_voxelres_y,
    search.xnat_optscandata4 AS parameters_voxelres_z,
    search.xnat_optscandata5 AS parameters_fov_x,
    search.xnat_optscandata6 AS parameters_fov_y,
    search.xnat_optscandata7 AS parameters_laterality,
    search.xnat_optscandata8 AS parameters_illumination_wavelength,
    search.xnat_optscandata9 AS parameters_illumination_power,
    search.xnat_optscandata10 AS parameters_imagetype,
    search.xnat_optscandata11 AS dcmvalidation,
    search.xnat_optscandata12 AS dcmvalidation_status,
    search.xnat_optscandata_meta_data130 AS quarantine_status
   FROM (( SELECT DISTINCT table0.xnat_imagescandata_id AS xnat_optscandata0,
            table2.status AS xnat_optscandata_meta_data130,
            table0.image_session_id AS xnat_imagescandata14,
            table0.note AS xnat_imagescandata15,
            table0.quality AS xnat_imagescandata16,
            table0.condition AS xnat_imagescandata17,
            table0.series_description AS xnat_imagescandata18,
            table0.documentation AS xnat_imagescandata20,
            table0.scanner AS xnat_imagescandata21,
            table0.scanner_manufacturer AS xnat_imagescandata22,
            table0.scanner_model AS xnat_imagescandata23,
            table0.modality AS xnat_imagescandata25,
            table0.frames AS xnat_imagescandata26,
            table0.operator AS xnat_imagescandata27,
            table0.starttime AS xnat_imagescandata29,
            table0.id AS xnat_imagescandata31,
            table0.type AS xnat_imagescandata32,
            table0.uid AS xnat_imagescandata33,
            table0.project AS xnat_imagescandata34,
            table2.insert_date AS xnat_optscandata_meta_data133,
            table4.login AS table4_login,
            xnat_optscandata.parameters_voxelres_units AS xnat_optscandata1,
            xnat_optscandata.parameters_voxelres_x AS xnat_optscandata2,
            xnat_optscandata.parameters_voxelres_y AS xnat_optscandata3,
            xnat_optscandata.parameters_voxelres_z AS xnat_optscandata4,
            xnat_optscandata.parameters_fov_x AS xnat_optscandata5,
            xnat_optscandata.parameters_fov_y AS xnat_optscandata6,
            xnat_optscandata.parameters_laterality AS xnat_optscandata7,
            xnat_optscandata.parameters_illumination_wavelength AS xnat_optscandata8,
            xnat_optscandata.parameters_illumination_power AS xnat_optscandata9,
            xnat_optscandata.parameters_imagetype AS xnat_optscandata10,
            xnat_optscandata.dcmvalidation AS xnat_optscandata11,
            xnat_optscandata.dcmvalidation_status AS xnat_optscandata12
           FROM (((public.xnat_optscandata xnat_optscandata
             LEFT JOIN public.xnat_imagescandata table0 ON ((xnat_optscandata.xnat_imagescandata_id = table0.xnat_imagescandata_id)))
             LEFT JOIN public.xnat_optscandata_meta_data table2 ON ((xnat_optscandata.optscandata_info = table2.meta_data_id)))
             LEFT JOIN public.xdat_user table4 ON ((table2.insert_user_xdat_user_id = table4.xdat_user_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_optscandata0
           FROM ( SELECT table0.xnat_imagescandata_id AS xnat_optscandata0,
                    table2.insert_date AS xnat_optscandata_meta_data133
                   FROM ((public.xnat_optscandata xnat_optscandata
                     LEFT JOIN public.xnat_imagescandata table0 ON ((xnat_optscandata.xnat_imagescandata_id = table0.xnat_imagescandata_id)))
                     LEFT JOIN public.xnat_optscandata_meta_data table2 ON ((xnat_optscandata.optscandata_info = table2.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.xnat_optscandata0 = search.xnat_optscandata0)))
  ORDER BY search.xnat_imagescandata14;


ALTER TABLE public.displayfields_xnat_optscandata OWNER TO xnat;

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

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


ALTER TABLE public.xnat_optsessiondata OWNER TO xnat;

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

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

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

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


ALTER TABLE public.xnat_optsessiondata_projects OWNER TO xnat;

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

CREATE VIEW public.displayfields_xnat_optsessiondata AS
 SELECT search.xnat_subjectassessordata19 AS subject_id,
    search.xnat_optsessiondata0 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_optsessiondata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata38, search.xnat_optsessiondata0) AS label,
    search.table5_login AS insert_user,
    search.xnat_optsessiondata_meta_data976 AS insert_date,
    search.xnat_experimentdata32 AS project,
    search.xnat_optsessiondata_meta_data973 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_optsessiondata0) search_1.xnat_optsessiondata0,
            search_1.xnat_optsessiondata_meta_data973,
            search_1.xnat_subjectassessordata19,
            search_1.xnat_experimentdata22,
            search_1.xnat_experimentdata38,
            search_1.table5_login,
            search_1.xnat_optsessiondata_meta_data976,
            search_1.xnat_experimentdata32,
            search_1.xnat_demographicdata_demograp_xnat_demographicdata0,
            search_1.xnat_demographicdata_at_demographicdata_meta_data47,
            search_1.xnat_demographicdata_xnat_demographicdata1,
            search_1.xnat_demographicdata_xnat_demographicdata2,
            search_1.xnat_optsessiondata_projects_projects
           FROM ( SELECT table2.id AS xnat_optsessiondata0,
                    table4.status AS xnat_optsessiondata_meta_data973,
                    table1.subject_id AS xnat_subjectassessordata19,
                    table2.date AS xnat_experimentdata22,
                    table2.label AS xnat_experimentdata38,
                    table5.login AS table5_login,
                    table4.insert_date AS xnat_optsessiondata_meta_data976,
                    table2.project AS xnat_experimentdata32,
                    xnat_demographicdata.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                    xnat_demographicdata.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                    xnat_demographicdata.xnat_demographicdata1 AS xnat_demographicdata_xnat_demographicdata1,
                    xnat_demographicdata.xnat_demographicdata2 AS xnat_demographicdata_xnat_demographicdata2,
                    xnat_optsessiondata_projects.projects AS xnat_optsessiondata_projects_projects
                   FROM ((((((((public.xnat_optsessiondata xnat_optsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_optsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))
                     LEFT JOIN public.xnat_optsessiondata_meta_data table4 ON ((xnat_optsessiondata.optsessiondata_info = table4.meta_data_id)))
                     LEFT JOIN public.xdat_user table5 ON ((table4.insert_user_xdat_user_id = table5.xdat_user_id)))
                     LEFT JOIN public.xnat_optsessiondata_projects xnat_optsessiondata_projects ON (((table2.id)::text = (xnat_optsessiondata_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_optsessiondata_sordata_e_xnat_optsessiondata0,
                            search_2.xnat_optsessiondata_sordata__xnat_experimentdata22,
                            search_2.xnat_optsessiondata_sor_xnat_subjectassessordata19,
                            date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47)) AS xnat_subjectdata_xnat_demographicdata_diff
                           FROM ( SELECT xnat_subjectdata.id AS xnat_subjectdata3,
                                    table1_1.insert_date AS xnat_subjectdata_meta_data328,
                                    xnat_demographicdata_1.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                                    xnat_demographicdata_1.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                                    xnat_demographicdata_1.xnat_abstractdemographicdata27 AS xnat_demographicdata_xnat_abstractdemographicdata27,
                                    xnat_optsessiondata_1.xnat_optsessiondata0 AS xnat_optsessiondata_sordata_e_xnat_optsessiondata0,
                                    xnat_optsessiondata_1.xnat_experimentdata22 AS xnat_optsessiondata_sordata__xnat_experimentdata22,
                                    xnat_optsessiondata_1.xnat_subjectassessordata19 AS xnat_optsessiondata_sor_xnat_subjectassessordata19
                                   FROM ((((public.xnat_subjectdata xnat_subjectdata
                                     LEFT JOIN public.xnat_subjectdata_meta_data table1_1 ON ((xnat_subjectdata.subjectdata_info = table1_1.meta_data_id)))
                                     LEFT JOIN ( SELECT xnat_subjectdata_1.id AS xnat_subjectdata3,
    table1_2.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata91,
    table2_1.insert_date AS xnat_subjectdata_meta_data328
   FROM ((public.xnat_subjectdata xnat_subjectdata_1
     LEFT JOIN public.xnat_abstractdemographicdata table1_2 ON ((xnat_subjectdata_1.demographics_xnat_abstractdemographicdata_id = table1_2.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_subjectdata_meta_data table2_1 ON ((xnat_subjectdata_1.subjectdata_info = table2_1.meta_data_id)))) map_xnat_demographicdata ON (((xnat_subjectdata.id)::text = (map_xnat_demographicdata.xnat_subjectdata3)::text)))
                                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
    table2_1.insert_date AS xnat_demographicdata_meta_data47,
    table0_1.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata27
   FROM ((public.xnat_demographicdata xnat_demographicdata_2
     LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_2.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_2.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata_1 ON ((map_xnat_demographicdata.xnat_abstractdemographicdata91 = xnat_demographicdata_1.xnat_abstractdemographicdata27)))
                                     LEFT JOIN ( SELECT table2_1.id AS xnat_optsessiondata0,
    table2_1.date AS xnat_experimentdata22,
    table1_2.subject_id AS xnat_subjectassessordata19
   FROM (((public.xnat_optsessiondata xnat_optsessiondata_2
     LEFT JOIN public.xnat_imagesessiondata table0_1 ON (((xnat_optsessiondata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_subjectassessordata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))
     LEFT JOIN public.xnat_experimentdata table2_1 ON (((table1_2.id)::text = (table2_1.id)::text)))) xnat_optsessiondata_1 ON (((xnat_subjectdata.id)::text = (xnat_optsessiondata_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_optsessiondata_sordata__xnat_experimentdata22 DESC) map_xnat_subjectdata_xnat_demographicdata ON (((table2.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_optsessiondata_sordata_e_xnat_optsessiondata0)::text)))
                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
                            table2_1.insert_date AS xnat_demographicdata_meta_data47,
                            xnat_demographicdata_1.dob AS xnat_demographicdata1,
                            xnat_demographicdata_1.yob AS xnat_demographicdata2
                           FROM ((public.xnat_demographicdata xnat_demographicdata_1
                             LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_1.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
                             LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_1.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata ON ((map_xnat_subjectdata_xnat_demographicdata.xnat_demographicdata_demograp_xnat_demographicdata0 = xnat_demographicdata.xnat_demographicdata0)))) search_1
          ORDER BY search_1.xnat_optsessiondata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_optsessiondata0
           FROM ( SELECT table2.id AS xnat_optsessiondata0,
                    table2.date AS xnat_experimentdata22
                   FROM (((public.xnat_optsessiondata xnat_optsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_optsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))) where_clause_1) where_clause ON (((where_clause.xnat_optsessiondata0)::text = (search.xnat_optsessiondata0)::text)))
  ORDER BY search.xnat_subjectassessordata19;


ALTER TABLE public.displayfields_xnat_optsessiondata OWNER TO xnat;

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

CREATE TABLE public.xnat_otherdicomscandata (
    xnat_imagescandata_id integer DEFAULT 0 NOT NULL,
    otherdicomscandata_info integer
);


ALTER TABLE public.xnat_otherdicomscandata OWNER TO xnat;

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

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

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

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


ALTER TABLE public.displayfields_xnat_otherdicomscandata OWNER TO xnat;

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

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


ALTER TABLE public.xnat_otherdicomsessiondata OWNER TO xnat;

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

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

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

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


ALTER TABLE public.xnat_otherdicomsessiondata_projects OWNER TO xnat;

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

CREATE VIEW public.displayfields_xnat_otherdicomsessiondata AS
 SELECT search.xnat_subjectassessordata19 AS subject_id,
    search.xnat_otherdicomsessiondata0 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_otherdicomsessiondata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata38, search.xnat_otherdicomsessiondata0) AS label,
    search.table5_login AS insert_user,
    search.xnat_otherdicomsessiondata_meta_data976 AS insert_date,
    search.xnat_experimentdata32 AS project,
    search.xnat_otherdicomsessiondata_meta_data973 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_otherdicomsessiondata0) search_1.xnat_otherdicomsessiondata0,
            search_1.xnat_otherdicomsessiondata_meta_data973,
            search_1.xnat_subjectassessordata19,
            search_1.xnat_experimentdata22,
            search_1.xnat_experimentdata38,
            search_1.table5_login,
            search_1.xnat_otherdicomsessiondata_meta_data976,
            search_1.xnat_experimentdata32,
            search_1.xnat_demographicdata_demograp_xnat_demographicdata0,
            search_1.xnat_demographicdata_at_demographicdata_meta_data47,
            search_1.xnat_demographicdata_xnat_demographicdata1,
            search_1.xnat_demographicdata_xnat_demographicdata2,
            search_1.xnat_otherdicomsessiondata_projects_projects
           FROM ( SELECT table2.id AS xnat_otherdicomsessiondata0,
                    table4.status AS xnat_otherdicomsessiondata_meta_data973,
                    table1.subject_id AS xnat_subjectassessordata19,
                    table2.date AS xnat_experimentdata22,
                    table2.label AS xnat_experimentdata38,
                    table5.login AS table5_login,
                    table4.insert_date AS xnat_otherdicomsessiondata_meta_data976,
                    table2.project AS xnat_experimentdata32,
                    xnat_demographicdata.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                    xnat_demographicdata.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                    xnat_demographicdata.xnat_demographicdata1 AS xnat_demographicdata_xnat_demographicdata1,
                    xnat_demographicdata.xnat_demographicdata2 AS xnat_demographicdata_xnat_demographicdata2,
                    xnat_otherdicomsessiondata_projects.projects AS xnat_otherdicomsessiondata_projects_projects
                   FROM ((((((((public.xnat_otherdicomsessiondata xnat_otherdicomsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_otherdicomsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))
                     LEFT JOIN public.xnat_otherdicomsessiondata_meta_data table4 ON ((xnat_otherdicomsessiondata.otherdicomsessiondata_info = table4.meta_data_id)))
                     LEFT JOIN public.xdat_user table5 ON ((table4.insert_user_xdat_user_id = table5.xdat_user_id)))
                     LEFT JOIN public.xnat_otherdicomsessiondata_projects xnat_otherdicomsessiondata_projects ON (((table2.id)::text = (xnat_otherdicomsessiondata_projects.id)::text)))
                     LEFT JOIN ( SELECT search_2.xnat_subjectdata3,
                            search_2.xnat_subjectdata_meta_data328,
                            search_2.xnat_otherdicomsessiondata_so_xnat_otherdicomsessiondata0,
                            search_2.xnat_otherdicomsessiondata_sordata__xnat_experimentdata22,
                            search_2.xnat_otherdicomsessiondata_sor_xnat_subjectassessordata19,
                            search_2.xnat_demographicdata_demograp_xnat_demographicdata0,
                            search_2.xnat_demographicdata_at_demographicdata_meta_data47,
                            search_2.xnat_demographicdata_xnat_abstractdemographicdata27,
                            date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47)) AS xnat_subjectdata_xnat_demographicdata_diff
                           FROM ( SELECT xnat_subjectdata.id AS xnat_subjectdata3,
                                    table1_1.insert_date AS xnat_subjectdata_meta_data328,
                                    xnat_otherdicomsessiondata_1.xnat_otherdicomsessiondata0 AS xnat_otherdicomsessiondata_so_xnat_otherdicomsessiondata0,
                                    xnat_otherdicomsessiondata_1.xnat_experimentdata22 AS xnat_otherdicomsessiondata_sordata__xnat_experimentdata22,
                                    xnat_otherdicomsessiondata_1.xnat_subjectassessordata19 AS xnat_otherdicomsessiondata_sor_xnat_subjectassessordata19,
                                    xnat_demographicdata_1.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                                    xnat_demographicdata_1.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                                    xnat_demographicdata_1.xnat_abstractdemographicdata27 AS xnat_demographicdata_xnat_abstractdemographicdata27
                                   FROM ((((public.xnat_subjectdata xnat_subjectdata
                                     LEFT JOIN public.xnat_subjectdata_meta_data table1_1 ON ((xnat_subjectdata.subjectdata_info = table1_1.meta_data_id)))
                                     LEFT JOIN ( SELECT table2_1.id AS xnat_otherdicomsessiondata0,
    table2_1.date AS xnat_experimentdata22,
    table1_2.subject_id AS xnat_subjectassessordata19
   FROM (((public.xnat_otherdicomsessiondata xnat_otherdicomsessiondata_2
     LEFT JOIN public.xnat_imagesessiondata table0_1 ON (((xnat_otherdicomsessiondata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_subjectassessordata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))
     LEFT JOIN public.xnat_experimentdata table2_1 ON (((table1_2.id)::text = (table2_1.id)::text)))) xnat_otherdicomsessiondata_1 ON (((xnat_subjectdata.id)::text = (xnat_otherdicomsessiondata_1.xnat_subjectassessordata19)::text)))
                                     LEFT JOIN ( SELECT xnat_subjectdata_1.id AS xnat_subjectdata3,
    table1_2.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata91,
    table2_1.insert_date AS xnat_subjectdata_meta_data328
   FROM ((public.xnat_subjectdata xnat_subjectdata_1
     LEFT JOIN public.xnat_abstractdemographicdata table1_2 ON ((xnat_subjectdata_1.demographics_xnat_abstractdemographicdata_id = table1_2.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_subjectdata_meta_data table2_1 ON ((xnat_subjectdata_1.subjectdata_info = table2_1.meta_data_id)))) map_xnat_demographicdata ON (((xnat_subjectdata.id)::text = (map_xnat_demographicdata.xnat_subjectdata3)::text)))
                                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
    table2_1.insert_date AS xnat_demographicdata_meta_data47,
    table0_1.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata27
   FROM ((public.xnat_demographicdata xnat_demographicdata_2
     LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_2.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_2.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata_1 ON ((map_xnat_demographicdata.xnat_abstractdemographicdata91 = xnat_demographicdata_1.xnat_abstractdemographicdata27)))) search_2
                          ORDER BY search_2.xnat_subjectdata3, search_2.xnat_otherdicomsessiondata_sordata__xnat_experimentdata22 DESC, (date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47)))) map_xnat_subjectdata_xnat_demographicdata ON (((table2.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_otherdicomsessiondata_so_xnat_otherdicomsessiondata0)::text)))
                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
                            table2_1.insert_date AS xnat_demographicdata_meta_data47,
                            xnat_demographicdata_1.dob AS xnat_demographicdata1,
                            xnat_demographicdata_1.yob AS xnat_demographicdata2
                           FROM ((public.xnat_demographicdata xnat_demographicdata_1
                             LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_1.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
                             LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_1.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata ON ((map_xnat_subjectdata_xnat_demographicdata.xnat_demographicdata_demograp_xnat_demographicdata0 = xnat_demographicdata.xnat_demographicdata0)))) search_1
          ORDER BY search_1.xnat_otherdicomsessiondata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_otherdicomsessiondata0
           FROM ( SELECT table2.id AS xnat_otherdicomsessiondata0,
                    table2.date AS xnat_experimentdata22
                   FROM (((public.xnat_otherdicomsessiondata xnat_otherdicomsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_otherdicomsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))) where_clause_1) where_clause ON (((where_clause.xnat_otherdicomsessiondata0)::text = (search.xnat_otherdicomsessiondata0)::text)))
  ORDER BY search.xnat_subjectassessordata19;


ALTER TABLE public.displayfields_xnat_otherdicomsessiondata OWNER TO xnat;

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

CREATE TABLE public.xnat_petmrsessiondata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    coil character varying(255),
    fieldstrength character varying(255),
    marker character varying(255),
    stabilization character varying(255),
    studytype character varying(255),
    patientid character varying(255),
    patientname character varying(255),
    tracer_dose_units character varying(255),
    tracer_dose double precision,
    tracer_specificactivity double precision,
    tracer_totalmass_units character varying(255),
    tracer_totalmass double precision,
    tracer_intermediate_units character varying(255),
    tracer_intermediate double precision,
    tracer_isotope_half_life double precision,
    tracer_isotope character varying(255),
    tracer_transmissions integer,
    tracer_transmissions_starttime timestamp without time zone,
    tracer_name character varying(255),
    tracer_starttime timestamp without time zone,
    start_time timestamp without time zone,
    start_time_scan timestamp without time zone,
    start_time_injection timestamp without time zone,
    blood_glucose double precision,
    blood_glucose_units character varying(255),
    blood_glucose_time timestamp without time zone,
    petmrsessiondata_info integer
);


ALTER TABLE public.xnat_petmrsessiondata OWNER TO xnat;

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

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

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

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


ALTER TABLE public.xnat_petmrsessiondata_projects OWNER TO xnat;

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

CREATE VIEW public.displayfields_xnat_petmrsessiondata AS
 SELECT search.xnat_subjectassessordata45 AS subject_id,
    search.xnat_petmrsessiondata0 AS expt_id,
    '/@WEBAPP/images/r.gif'::text AS rpt,
    search.xnat_experimentdata48 AS date,
    (COALESCE((floor(((((search.xnat_experimentdata48 - search.xnat_demographicdata_xnat_demographicdata1))::real / (365)::double precision))::numeric))::double precision, floor((date_part('year'::text, search.xnat_experimentdata48) - (search.xnat_demographicdata_xnat_demographicdata2)::double precision))))::numeric AS age,
    search.xnat_petmrsessiondata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata64, search.xnat_petmrsessiondata0) AS label,
    search.table5_login AS insert_user,
    search.xnat_petmrsessiondata_meta_data1002 AS insert_date,
    search.xnat_experimentdata58 AS project,
    search.xnat_petmrsessiondata1 AS coil,
    search.xnat_petmrsessiondata2 AS fieldstrength,
    search.xnat_petmrsessiondata3 AS marker,
    search.xnat_petmrsessiondata4 AS stabilization,
    search.xnat_petmrsessiondata5 AS studytype,
    search.xnat_petmrsessiondata6 AS patientid,
    search.xnat_petmrsessiondata7 AS patientname,
    search.xnat_petmrsessiondata8 AS tracer_dose_units,
    search.xnat_petmrsessiondata9 AS tracer_dose,
    search.xnat_petmrsessiondata10 AS tracer_specificactivity,
    search.xnat_petmrsessiondata11 AS tracer_totalmass_units,
    search.xnat_petmrsessiondata12 AS tracer_totalmass,
    search.xnat_petmrsessiondata13 AS tracer_intermediate_units,
    search.xnat_petmrsessiondata14 AS tracer_intermediate,
    search.xnat_petmrsessiondata15 AS tracer_isotope_half_life,
    search.xnat_petmrsessiondata16 AS tracer_isotope,
    search.xnat_petmrsessiondata17 AS tracer_transmissions,
    search.xnat_petmrsessiondata18 AS tracer_transmissions_starttime,
    search.xnat_petmrsessiondata19 AS tracer_name,
    search.xnat_petmrsessiondata20 AS tracer_starttime,
    search.xnat_petmrsessiondata21 AS start_time,
    search.xnat_petmrsessiondata22 AS start_time_scan,
    search.xnat_petmrsessiondata23 AS start_time_injection,
    search.xnat_petmrsessiondata24 AS blood_glucose,
    search.xnat_petmrsessiondata25 AS blood_glucose_units,
    search.xnat_petmrsessiondata26 AS blood_glucose_time,
    search.xnat_petmrsessiondata_meta_data999 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_petmrsessiondata0) search_1.xnat_petmrsessiondata0,
            search_1.xnat_petmrsessiondata_meta_data999,
            search_1.xnat_subjectassessordata45,
            search_1.xnat_experimentdata48,
            search_1.xnat_experimentdata64,
            search_1.table5_login,
            search_1.xnat_petmrsessiondata_meta_data1002,
            search_1.xnat_experimentdata58,
            search_1.xnat_petmrsessiondata1,
            search_1.xnat_petmrsessiondata2,
            search_1.xnat_petmrsessiondata3,
            search_1.xnat_petmrsessiondata4,
            search_1.xnat_petmrsessiondata5,
            search_1.xnat_petmrsessiondata6,
            search_1.xnat_petmrsessiondata7,
            search_1.xnat_petmrsessiondata8,
            search_1.xnat_petmrsessiondata9,
            search_1.xnat_petmrsessiondata10,
            search_1.xnat_petmrsessiondata11,
            search_1.xnat_petmrsessiondata12,
            search_1.xnat_petmrsessiondata13,
            search_1.xnat_petmrsessiondata14,
            search_1.xnat_petmrsessiondata15,
            search_1.xnat_petmrsessiondata16,
            search_1.xnat_petmrsessiondata17,
            search_1.xnat_petmrsessiondata18,
            search_1.xnat_petmrsessiondata19,
            search_1.xnat_petmrsessiondata20,
            search_1.xnat_petmrsessiondata21,
            search_1.xnat_petmrsessiondata22,
            search_1.xnat_petmrsessiondata23,
            search_1.xnat_petmrsessiondata24,
            search_1.xnat_petmrsessiondata25,
            search_1.xnat_petmrsessiondata26,
            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_petmrsessiondata_projects_projects
           FROM ( SELECT table2.id AS xnat_petmrsessiondata0,
                    table4.status AS xnat_petmrsessiondata_meta_data999,
                    table1.subject_id AS xnat_subjectassessordata45,
                    table2.date AS xnat_experimentdata48,
                    table2.label AS xnat_experimentdata64,
                    table5.login AS table5_login,
                    table4.insert_date AS xnat_petmrsessiondata_meta_data1002,
                    table2.project AS xnat_experimentdata58,
                    xnat_petmrsessiondata.coil AS xnat_petmrsessiondata1,
                    xnat_petmrsessiondata.fieldstrength AS xnat_petmrsessiondata2,
                    xnat_petmrsessiondata.marker AS xnat_petmrsessiondata3,
                    xnat_petmrsessiondata.stabilization AS xnat_petmrsessiondata4,
                    xnat_petmrsessiondata.studytype AS xnat_petmrsessiondata5,
                    xnat_petmrsessiondata.patientid AS xnat_petmrsessiondata6,
                    xnat_petmrsessiondata.patientname AS xnat_petmrsessiondata7,
                    xnat_petmrsessiondata.tracer_dose_units AS xnat_petmrsessiondata8,
                    xnat_petmrsessiondata.tracer_dose AS xnat_petmrsessiondata9,
                    xnat_petmrsessiondata.tracer_specificactivity AS xnat_petmrsessiondata10,
                    xnat_petmrsessiondata.tracer_totalmass_units AS xnat_petmrsessiondata11,
                    xnat_petmrsessiondata.tracer_totalmass AS xnat_petmrsessiondata12,
                    xnat_petmrsessiondata.tracer_intermediate_units AS xnat_petmrsessiondata13,
                    xnat_petmrsessiondata.tracer_intermediate AS xnat_petmrsessiondata14,
                    xnat_petmrsessiondata.tracer_isotope_half_life AS xnat_petmrsessiondata15,
                    xnat_petmrsessiondata.tracer_isotope AS xnat_petmrsessiondata16,
                    xnat_petmrsessiondata.tracer_transmissions AS xnat_petmrsessiondata17,
                    xnat_petmrsessiondata.tracer_transmissions_starttime AS xnat_petmrsessiondata18,
                    xnat_petmrsessiondata.tracer_name AS xnat_petmrsessiondata19,
                    xnat_petmrsessiondata.tracer_starttime AS xnat_petmrsessiondata20,
                    xnat_petmrsessiondata.start_time AS xnat_petmrsessiondata21,
                    xnat_petmrsessiondata.start_time_scan AS xnat_petmrsessiondata22,
                    xnat_petmrsessiondata.start_time_injection AS xnat_petmrsessiondata23,
                    xnat_petmrsessiondata.blood_glucose AS xnat_petmrsessiondata24,
                    xnat_petmrsessiondata.blood_glucose_units AS xnat_petmrsessiondata25,
                    xnat_petmrsessiondata.blood_glucose_time AS xnat_petmrsessiondata26,
                    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_petmrsessiondata_projects.projects AS xnat_petmrsessiondata_projects_projects
                   FROM ((((((((public.xnat_petmrsessiondata xnat_petmrsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_petmrsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))
                     LEFT JOIN public.xnat_petmrsessiondata_meta_data table4 ON ((xnat_petmrsessiondata.petmrsessiondata_info = table4.meta_data_id)))
                     LEFT JOIN public.xdat_user table5 ON ((table4.insert_user_xdat_user_id = table5.xdat_user_id)))
                     LEFT JOIN public.xnat_petmrsessiondata_projects xnat_petmrsessiondata_projects ON (((table2.id)::text = (xnat_petmrsessiondata_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_petmrsessiondata_sordata_xnat_petmrsessiondata0,
                            search_2.xnat_petmrsessiondata_sordata__xnat_experimentdata48,
                            search_2.xnat_petmrsessiondata_sor_xnat_subjectassessordata45,
                            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_petmrsessiondata_1.xnat_petmrsessiondata0 AS xnat_petmrsessiondata_sordata_xnat_petmrsessiondata0,
                                    xnat_petmrsessiondata_1.xnat_experimentdata48 AS xnat_petmrsessiondata_sordata__xnat_experimentdata48,
                                    xnat_petmrsessiondata_1.xnat_subjectassessordata45 AS xnat_petmrsessiondata_sor_xnat_subjectassessordata45
                                   FROM ((((public.xnat_subjectdata xnat_subjectdata
                                     LEFT JOIN public.xnat_subjectdata_meta_data table1_1 ON ((xnat_subjectdata.subjectdata_info = table1_1.meta_data_id)))
                                     LEFT JOIN ( SELECT xnat_subjectdata_1.id AS xnat_subjectdata3,
    table1_2.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata91,
    table2_1.insert_date AS xnat_subjectdata_meta_data328
   FROM ((public.xnat_subjectdata xnat_subjectdata_1
     LEFT JOIN public.xnat_abstractdemographicdata table1_2 ON ((xnat_subjectdata_1.demographics_xnat_abstractdemographicdata_id = table1_2.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_subjectdata_meta_data table2_1 ON ((xnat_subjectdata_1.subjectdata_info = table2_1.meta_data_id)))) map_xnat_demographicdata ON (((xnat_subjectdata.id)::text = (map_xnat_demographicdata.xnat_subjectdata3)::text)))
                                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
    table2_1.insert_date AS xnat_demographicdata_meta_data47,
    table0_1.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata27
   FROM ((public.xnat_demographicdata xnat_demographicdata_2
     LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_2.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_2.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata_1 ON ((map_xnat_demographicdata.xnat_abstractdemographicdata91 = xnat_demographicdata_1.xnat_abstractdemographicdata27)))
                                     LEFT JOIN ( SELECT table2_1.id AS xnat_petmrsessiondata0,
    table2_1.date AS xnat_experimentdata48,
    table1_2.subject_id AS xnat_subjectassessordata45
   FROM (((public.xnat_petmrsessiondata xnat_petmrsessiondata_2
     LEFT JOIN public.xnat_imagesessiondata table0_1 ON (((xnat_petmrsessiondata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_subjectassessordata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))
     LEFT JOIN public.xnat_experimentdata table2_1 ON (((table1_2.id)::text = (table2_1.id)::text)))) xnat_petmrsessiondata_1 ON (((xnat_subjectdata.id)::text = (xnat_petmrsessiondata_1.xnat_subjectassessordata45)::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_petmrsessiondata_sordata__xnat_experimentdata48 DESC) map_xnat_subjectdata_xnat_demographicdata ON (((table2.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_petmrsessiondata_sordata_xnat_petmrsessiondata0)::text)))
                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
                            table2_1.insert_date AS xnat_demographicdata_meta_data47,
                            xnat_demographicdata_1.dob AS xnat_demographicdata1,
                            xnat_demographicdata_1.yob AS xnat_demographicdata2
                           FROM ((public.xnat_demographicdata xnat_demographicdata_1
                             LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_1.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
                             LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_1.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata ON ((map_xnat_subjectdata_xnat_demographicdata.xnat_demographicdata_demograp_xnat_demographicdata0 = xnat_demographicdata.xnat_demographicdata0)))) search_1
          ORDER BY search_1.xnat_petmrsessiondata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_petmrsessiondata0
           FROM ( SELECT table2.id AS xnat_petmrsessiondata0,
                    table2.date AS xnat_experimentdata48
                   FROM (((public.xnat_petmrsessiondata xnat_petmrsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_petmrsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))) where_clause_1) where_clause ON (((where_clause.xnat_petmrsessiondata0)::text = (search.xnat_petmrsessiondata0)::text)))
  ORDER BY search.xnat_subjectassessordata45;


ALTER TABLE public.displayfields_xnat_petmrsessiondata OWNER TO xnat;

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

CREATE TABLE public.xnat_petscandata (
    xnat_imagescandata_id integer DEFAULT 0 NOT NULL,
    parameters_orientation integer,
    parameters_originalfilename character varying(255),
    parameters_systemtype integer,
    parameters_filetype integer,
    parameters_transaxialfov double precision,
    parameters_acqtype integer,
    parameters_facility character varying(255),
    parameters_numplanes integer,
    parameters_frames_numframes integer,
    parameters_numgates integer,
    parameters_planeseparation double precision,
    parameters_binsize double precision,
    parameters_datatype integer,
    parameters_dimensions_x integer,
    parameters_dimensions_y integer,
    parameters_dimensions_z integer,
    parameters_dimensions_num integer,
    parameters_offset_x double precision,
    parameters_offset_y double precision,
    parameters_offset_z double precision,
    parameters_reconzoom double precision,
    parameters_pixelsize_x double precision,
    parameters_pixelsize_y double precision,
    parameters_pixelsize_z double precision,
    parameters_filtercode integer,
    parameters_resolution_x double precision,
    parameters_resolution_y double precision,
    parameters_resolution_z double precision,
    parameters_numrelements double precision,
    parameters_numangles double precision,
    parameters_zrotationangle double precision,
    parameters_processingcode integer,
    parameters_gateduration integer,
    parameters_rwaveoffset integer,
    parameters_numacceptedbeats integer,
    parameters_filter_cutoff double precision,
    parameters_annotation character varying(255),
    parameters_mt_1_1 double precision,
    parameters_mt_1_2 double precision,
    parameters_mt_1_3 double precision,
    parameters_mt_1_4 double precision,
    parameters_mt_2_1 double precision,
    parameters_mt_2_2 double precision,
    parameters_mt_2_3 double precision,
    parameters_mt_2_4 double precision,
    parameters_mt_3_1 double precision,
    parameters_mt_3_2 double precision,
    parameters_mt_3_3 double precision,
    parameters_mt_3_4 double precision,
    parameters_rfilter_cutoff double precision,
    parameters_rfilter_resolution double precision,
    parameters_rfilter_code integer,
    parameters_rfilter_order integer,
    parameters_zfilter_cutoff double precision,
    parameters_zfilter_resolution double precision,
    parameters_zfilter_code integer,
    parameters_zfilter_order integer,
    parameters_scattertype integer,
    parameters_recontype integer,
    parameters_reconviews integer,
    parameters_bedposition double precision,
    parameters_ecatcalibrationfactor double precision,
    ecatvalidation character varying(255),
    ecatvalidation_status integer,
    petscandata_info integer
);


ALTER TABLE public.xnat_petscandata OWNER TO xnat;

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

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

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

CREATE VIEW public.displayfields_xnat_petscandata AS
 SELECT search.xnat_imagescandata66 AS image_session_id,
    search.xnat_imagescandata67 AS note,
    search.xnat_imagescandata68 AS quality,
    search.xnat_imagescandata69 AS condition,
    search.xnat_imagescandata70 AS series_description,
    search.xnat_imagescandata72 AS documentation,
    search.xnat_imagescandata73 AS scanner,
    search.xnat_imagescandata74 AS scanner_manufacturer,
    search.xnat_imagescandata75 AS scanner_model,
    search.xnat_imagescandata77 AS modality,
    search.xnat_imagescandata78 AS frames,
    search.xnat_imagescandata79 AS operator,
    search.xnat_imagescandata81 AS starttime,
    search.xnat_imagescandata83 AS id,
    search.xnat_imagescandata84 AS type,
    search.xnat_imagescandata85 AS uid,
    search.xnat_imagescandata86 AS project,
    search.xnat_petscandata_meta_data224 AS insert_date,
    search.table4_login AS insert_user,
    search.xnat_petscandata1 AS parameters_orientation,
    search.xnat_petscandata2 AS parameters_originalfilename,
    search.xnat_petscandata3 AS parameters_systemtype,
    search.xnat_petscandata4 AS parameters_filetype,
    search.xnat_petscandata5 AS parameters_transaxialfov,
    search.xnat_petscandata6 AS parameters_acqtype,
    search.xnat_petscandata7 AS parameters_facility,
    search.xnat_petscandata8 AS parameters_numplanes,
    search.xnat_petscandata9 AS parameters_frames_numframes,
    search.xnat_petscandata10 AS parameters_numgates,
    search.xnat_petscandata11 AS parameters_planeseparation,
    search.xnat_petscandata12 AS parameters_binsize,
    search.xnat_petscandata13 AS parameters_datatype,
    search.xnat_petscandata14 AS parameters_dimensions_x,
    search.xnat_petscandata15 AS parameters_dimensions_y,
    search.xnat_petscandata16 AS parameters_dimensions_z,
    search.xnat_petscandata17 AS parameters_dimensions_num,
    search.xnat_petscandata18 AS parameters_offset_x,
    search.xnat_petscandata19 AS parameters_offset_y,
    search.xnat_petscandata20 AS parameters_offset_z,
    search.xnat_petscandata21 AS parameters_reconzoom,
    search.xnat_petscandata22 AS parameters_pixelsize_x,
    search.xnat_petscandata23 AS parameters_pixelsize_y,
    search.xnat_petscandata24 AS parameters_pixelsize_z,
    search.xnat_petscandata25 AS parameters_filtercode,
    search.xnat_petscandata26 AS parameters_resolution_x,
    search.xnat_petscandata27 AS parameters_resolution_y,
    search.xnat_petscandata28 AS parameters_resolution_z,
    search.xnat_petscandata29 AS parameters_numrelements,
    search.xnat_petscandata30 AS parameters_numangles,
    search.xnat_petscandata31 AS parameters_zrotationangle,
    search.xnat_petscandata32 AS parameters_processingcode,
    search.xnat_petscandata33 AS parameters_gateduration,
    search.xnat_petscandata34 AS parameters_rwaveoffset,
    search.xnat_petscandata35 AS parameters_numacceptedbeats,
    search.xnat_petscandata36 AS parameters_filter_cutoff,
    search.xnat_petscandata37 AS parameters_annotation,
    search.xnat_petscandata38 AS parameters_mt_1_1,
    search.xnat_petscandata39 AS parameters_mt_1_2,
    search.xnat_petscandata40 AS parameters_mt_1_3,
    search.xnat_petscandata41 AS parameters_mt_1_4,
    search.xnat_petscandata42 AS parameters_mt_2_1,
    search.xnat_petscandata43 AS parameters_mt_2_2,
    search.xnat_petscandata44 AS parameters_mt_2_3,
    search.xnat_petscandata45 AS parameters_mt_2_4,
    search.xnat_petscandata46 AS parameters_mt_3_1,
    search.xnat_petscandata47 AS parameters_mt_3_2,
    search.xnat_petscandata48 AS parameters_mt_3_3,
    search.xnat_petscandata49 AS parameters_mt_3_4,
    search.xnat_petscandata50 AS parameters_rfilter_cutoff,
    search.xnat_petscandata51 AS parameters_rfilter_resolution,
    search.xnat_petscandata52 AS parameters_rfilter_code,
    search.xnat_petscandata53 AS parameters_rfilter_order,
    search.xnat_petscandata54 AS parameters_zfilter_cutoff,
    search.xnat_petscandata55 AS parameters_zfilter_resolution,
    search.xnat_petscandata56 AS parameters_zfilter_code,
    search.xnat_petscandata57 AS parameters_zfilter_order,
    search.xnat_petscandata58 AS parameters_scattertype,
    search.xnat_petscandata59 AS parameters_recontype,
    search.xnat_petscandata60 AS parameters_reconviews,
    search.xnat_petscandata61 AS parameters_bedposition,
    search.xnat_petscandata62 AS parameters_ecatcalibrationfactor,
    search.xnat_petscandata63 AS ecatvalidation,
    search.xnat_petscandata64 AS ecatvalidation_status,
    search.xnat_petscandata_meta_data221 AS quarantine_status
   FROM (( SELECT DISTINCT table0.xnat_imagescandata_id AS xnat_petscandata0,
            table2.status AS xnat_petscandata_meta_data221,
            table0.image_session_id AS xnat_imagescandata66,
            table0.note AS xnat_imagescandata67,
            table0.quality AS xnat_imagescandata68,
            table0.condition AS xnat_imagescandata69,
            table0.series_description AS xnat_imagescandata70,
            table0.documentation AS xnat_imagescandata72,
            table0.scanner AS xnat_imagescandata73,
            table0.scanner_manufacturer AS xnat_imagescandata74,
            table0.scanner_model AS xnat_imagescandata75,
            table0.modality AS xnat_imagescandata77,
            table0.frames AS xnat_imagescandata78,
            table0.operator AS xnat_imagescandata79,
            table0.starttime AS xnat_imagescandata81,
            table0.id AS xnat_imagescandata83,
            table0.type AS xnat_imagescandata84,
            table0.uid AS xnat_imagescandata85,
            table0.project AS xnat_imagescandata86,
            table2.insert_date AS xnat_petscandata_meta_data224,
            table4.login AS table4_login,
            xnat_petscandata.parameters_orientation AS xnat_petscandata1,
            xnat_petscandata.parameters_originalfilename AS xnat_petscandata2,
            xnat_petscandata.parameters_systemtype AS xnat_petscandata3,
            xnat_petscandata.parameters_filetype AS xnat_petscandata4,
            xnat_petscandata.parameters_transaxialfov AS xnat_petscandata5,
            xnat_petscandata.parameters_acqtype AS xnat_petscandata6,
            xnat_petscandata.parameters_facility AS xnat_petscandata7,
            xnat_petscandata.parameters_numplanes AS xnat_petscandata8,
            xnat_petscandata.parameters_frames_numframes AS xnat_petscandata9,
            xnat_petscandata.parameters_numgates AS xnat_petscandata10,
            xnat_petscandata.parameters_planeseparation AS xnat_petscandata11,
            xnat_petscandata.parameters_binsize AS xnat_petscandata12,
            xnat_petscandata.parameters_datatype AS xnat_petscandata13,
            xnat_petscandata.parameters_dimensions_x AS xnat_petscandata14,
            xnat_petscandata.parameters_dimensions_y AS xnat_petscandata15,
            xnat_petscandata.parameters_dimensions_z AS xnat_petscandata16,
            xnat_petscandata.parameters_dimensions_num AS xnat_petscandata17,
            xnat_petscandata.parameters_offset_x AS xnat_petscandata18,
            xnat_petscandata.parameters_offset_y AS xnat_petscandata19,
            xnat_petscandata.parameters_offset_z AS xnat_petscandata20,
            xnat_petscandata.parameters_reconzoom AS xnat_petscandata21,
            xnat_petscandata.parameters_pixelsize_x AS xnat_petscandata22,
            xnat_petscandata.parameters_pixelsize_y AS xnat_petscandata23,
            xnat_petscandata.parameters_pixelsize_z AS xnat_petscandata24,
            xnat_petscandata.parameters_filtercode AS xnat_petscandata25,
            xnat_petscandata.parameters_resolution_x AS xnat_petscandata26,
            xnat_petscandata.parameters_resolution_y AS xnat_petscandata27,
            xnat_petscandata.parameters_resolution_z AS xnat_petscandata28,
            xnat_petscandata.parameters_numrelements AS xnat_petscandata29,
            xnat_petscandata.parameters_numangles AS xnat_petscandata30,
            xnat_petscandata.parameters_zrotationangle AS xnat_petscandata31,
            xnat_petscandata.parameters_processingcode AS xnat_petscandata32,
            xnat_petscandata.parameters_gateduration AS xnat_petscandata33,
            xnat_petscandata.parameters_rwaveoffset AS xnat_petscandata34,
            xnat_petscandata.parameters_numacceptedbeats AS xnat_petscandata35,
            xnat_petscandata.parameters_filter_cutoff AS xnat_petscandata36,
            xnat_petscandata.parameters_annotation AS xnat_petscandata37,
            xnat_petscandata.parameters_mt_1_1 AS xnat_petscandata38,
            xnat_petscandata.parameters_mt_1_2 AS xnat_petscandata39,
            xnat_petscandata.parameters_mt_1_3 AS xnat_petscandata40,
            xnat_petscandata.parameters_mt_1_4 AS xnat_petscandata41,
            xnat_petscandata.parameters_mt_2_1 AS xnat_petscandata42,
            xnat_petscandata.parameters_mt_2_2 AS xnat_petscandata43,
            xnat_petscandata.parameters_mt_2_3 AS xnat_petscandata44,
            xnat_petscandata.parameters_mt_2_4 AS xnat_petscandata45,
            xnat_petscandata.parameters_mt_3_1 AS xnat_petscandata46,
            xnat_petscandata.parameters_mt_3_2 AS xnat_petscandata47,
            xnat_petscandata.parameters_mt_3_3 AS xnat_petscandata48,
            xnat_petscandata.parameters_mt_3_4 AS xnat_petscandata49,
            xnat_petscandata.parameters_rfilter_cutoff AS xnat_petscandata50,
            xnat_petscandata.parameters_rfilter_resolution AS xnat_petscandata51,
            xnat_petscandata.parameters_rfilter_code AS xnat_petscandata52,
            xnat_petscandata.parameters_rfilter_order AS xnat_petscandata53,
            xnat_petscandata.parameters_zfilter_cutoff AS xnat_petscandata54,
            xnat_petscandata.parameters_zfilter_resolution AS xnat_petscandata55,
            xnat_petscandata.parameters_zfilter_code AS xnat_petscandata56,
            xnat_petscandata.parameters_zfilter_order AS xnat_petscandata57,
            xnat_petscandata.parameters_scattertype AS xnat_petscandata58,
            xnat_petscandata.parameters_recontype AS xnat_petscandata59,
            xnat_petscandata.parameters_reconviews AS xnat_petscandata60,
            xnat_petscandata.parameters_bedposition AS xnat_petscandata61,
            xnat_petscandata.parameters_ecatcalibrationfactor AS xnat_petscandata62,
            xnat_petscandata.ecatvalidation AS xnat_petscandata63,
            xnat_petscandata.ecatvalidation_status AS xnat_petscandata64
           FROM (((public.xnat_petscandata xnat_petscandata
             LEFT JOIN public.xnat_imagescandata table0 ON ((xnat_petscandata.xnat_imagescandata_id = table0.xnat_imagescandata_id)))
             LEFT JOIN public.xnat_petscandata_meta_data table2 ON ((xnat_petscandata.petscandata_info = table2.meta_data_id)))
             LEFT JOIN public.xdat_user table4 ON ((table2.insert_user_xdat_user_id = table4.xdat_user_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_petscandata0
           FROM ( SELECT table0.xnat_imagescandata_id AS xnat_petscandata0,
                    table2.insert_date AS xnat_petscandata_meta_data224
                   FROM ((public.xnat_petscandata xnat_petscandata
                     LEFT JOIN public.xnat_imagescandata table0 ON ((xnat_petscandata.xnat_imagescandata_id = table0.xnat_imagescandata_id)))
                     LEFT JOIN public.xnat_petscandata_meta_data table2 ON ((xnat_petscandata.petscandata_info = table2.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.xnat_petscandata0 = search.xnat_petscandata0)))
  ORDER BY search.xnat_imagescandata66;


ALTER TABLE public.displayfields_xnat_petscandata OWNER TO xnat;

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

CREATE TABLE public.xnat_petsessiondata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    stabilization character varying(255),
    studytype character varying(255),
    patientid character varying(255),
    patientname character varying(255),
    tracer_dose_units character varying(255),
    tracer_dose double precision,
    tracer_specificactivity double precision,
    tracer_totalmass_units character varying(255),
    tracer_totalmass double precision,
    tracer_intermediate_units character varying(255),
    tracer_intermediate double precision,
    tracer_isotope_half_life double precision,
    tracer_isotope character varying(255),
    tracer_transmissions integer,
    tracer_transmissions_starttime timestamp without time zone,
    tracer_name character varying(255),
    tracer_starttime timestamp without time zone,
    start_time timestamp without time zone,
    start_time_scan timestamp without time zone,
    start_time_injection timestamp without time zone,
    blood_glucose double precision,
    blood_glucose_units character varying(255),
    blood_glucose_time timestamp without time zone,
    petsessiondata_info integer
);


ALTER TABLE public.xnat_petsessiondata OWNER TO xnat;

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

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

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

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


ALTER TABLE public.xnat_petsessiondata_projects OWNER TO xnat;

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

CREATE VIEW public.displayfields_xnat_petsessiondata AS
 SELECT search.xnat_subjectassessordata42 AS subject_id,
    search.xnat_petsessiondata0 AS expt_id,
    '/@WEBAPP/images/r.gif'::text AS rpt,
    search.xnat_experimentdata45 AS date,
    floor((COALESCE(search.xnat_subjectassessordata43, (search.xnat_demographicdata_xnat_demographicdata3)::double precision, date_part('year'::text, age((search.xnat_experimentdata45)::timestamp with time zone, (search.xnat_demographicdata_xnat_demographicdata1)::timestamp with time zone)), (date_part('year'::text, search.xnat_experimentdata45) - (search.xnat_demographicdata_xnat_demographicdata2)::double precision)))::numeric) AS age,
    search.xnat_petsessiondata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata61, search.xnat_petsessiondata0) AS label,
    search.table5_login AS insert_user,
    search.xnat_petsessiondata_meta_data999 AS insert_date,
    search.xnat_experimentdata55 AS project,
    search.xnat_petsessiondata1 AS stabilization,
    search.xnat_petsessiondata2 AS studytype,
    search.xnat_petsessiondata3 AS patientid,
    search.xnat_petsessiondata4 AS patientname,
    search.xnat_petsessiondata5 AS tracer_dose_units,
    search.xnat_petsessiondata6 AS tracer_dose,
    search.xnat_petsessiondata7 AS tracer_specificactivity,
    search.xnat_petsessiondata8 AS tracer_totalmass_units,
    search.xnat_petsessiondata9 AS tracer_totalmass,
    search.xnat_petsessiondata10 AS tracer_intermediate_units,
    search.xnat_petsessiondata11 AS tracer_intermediate,
    search.xnat_petsessiondata12 AS tracer_isotope_half_life,
    search.xnat_petsessiondata13 AS tracer_isotope,
    search.xnat_petsessiondata15 AS tracer_transmissions_starttime,
    search.xnat_petsessiondata14 AS tracer_transmissions,
    search.xnat_petsessiondata16 AS tracer_name,
    search.xnat_petsessiondata17 AS tracer_starttime,
    search.xnat_imagesessiondata38 AS uid,
    search.xnat_petsessiondata_meta_data996 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_petsessiondata0) search_1.xnat_petsessiondata0,
            search_1.xnat_petsessiondata_meta_data996,
            search_1.xnat_subjectassessordata42,
            search_1.xnat_experimentdata45,
            search_1.xnat_subjectassessordata43,
            search_1.xnat_experimentdata61,
            search_1.table5_login,
            search_1.xnat_petsessiondata_meta_data999,
            search_1.xnat_experimentdata55,
            search_1.xnat_petsessiondata1,
            search_1.xnat_petsessiondata2,
            search_1.xnat_petsessiondata3,
            search_1.xnat_petsessiondata4,
            search_1.xnat_petsessiondata5,
            search_1.xnat_petsessiondata6,
            search_1.xnat_petsessiondata7,
            search_1.xnat_petsessiondata8,
            search_1.xnat_petsessiondata9,
            search_1.xnat_petsessiondata10,
            search_1.xnat_petsessiondata11,
            search_1.xnat_petsessiondata12,
            search_1.xnat_petsessiondata13,
            search_1.xnat_petsessiondata15,
            search_1.xnat_petsessiondata14,
            search_1.xnat_petsessiondata16,
            search_1.xnat_petsessiondata17,
            search_1.xnat_imagesessiondata38,
            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_demographicdata_xnat_demographicdata3,
            search_1.xnat_petsessiondata_projects_projects
           FROM ( SELECT table2.id AS xnat_petsessiondata0,
                    table4.status AS xnat_petsessiondata_meta_data996,
                    table1.subject_id AS xnat_subjectassessordata42,
                    table2.date AS xnat_experimentdata45,
                    table1.age AS xnat_subjectassessordata43,
                    table2.label AS xnat_experimentdata61,
                    table5.login AS table5_login,
                    table4.insert_date AS xnat_petsessiondata_meta_data999,
                    table2.project AS xnat_experimentdata55,
                    xnat_petsessiondata.stabilization AS xnat_petsessiondata1,
                    xnat_petsessiondata.studytype AS xnat_petsessiondata2,
                    xnat_petsessiondata.patientid AS xnat_petsessiondata3,
                    xnat_petsessiondata.patientname AS xnat_petsessiondata4,
                    xnat_petsessiondata.tracer_dose_units AS xnat_petsessiondata5,
                    xnat_petsessiondata.tracer_dose AS xnat_petsessiondata6,
                    xnat_petsessiondata.tracer_specificactivity AS xnat_petsessiondata7,
                    xnat_petsessiondata.tracer_totalmass_units AS xnat_petsessiondata8,
                    xnat_petsessiondata.tracer_totalmass AS xnat_petsessiondata9,
                    xnat_petsessiondata.tracer_intermediate_units AS xnat_petsessiondata10,
                    xnat_petsessiondata.tracer_intermediate AS xnat_petsessiondata11,
                    xnat_petsessiondata.tracer_isotope_half_life AS xnat_petsessiondata12,
                    xnat_petsessiondata.tracer_isotope AS xnat_petsessiondata13,
                    xnat_petsessiondata.tracer_transmissions_starttime AS xnat_petsessiondata15,
                    xnat_petsessiondata.tracer_transmissions AS xnat_petsessiondata14,
                    xnat_petsessiondata.tracer_name AS xnat_petsessiondata16,
                    xnat_petsessiondata.tracer_starttime AS xnat_petsessiondata17,
                    table0.uid AS xnat_imagesessiondata38,
                    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_demographicdata.xnat_demographicdata3 AS xnat_demographicdata_xnat_demographicdata3,
                    xnat_petsessiondata_projects.projects AS xnat_petsessiondata_projects_projects
                   FROM ((((((((public.xnat_petsessiondata xnat_petsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_petsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))
                     LEFT JOIN public.xnat_petsessiondata_meta_data table4 ON ((xnat_petsessiondata.petsessiondata_info = table4.meta_data_id)))
                     LEFT JOIN public.xdat_user table5 ON ((table4.insert_user_xdat_user_id = table5.xdat_user_id)))
                     LEFT JOIN public.xnat_petsessiondata_projects xnat_petsessiondata_projects ON (((table2.id)::text = (xnat_petsessiondata_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_petsessiondata_sordata_e_xnat_petsessiondata0,
                            search_2.xnat_petsessiondata_sordata__xnat_experimentdata45,
                            search_2.xnat_petsessiondata_sor_xnat_subjectassessordata42,
                            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_petsessiondata_1.xnat_petsessiondata0 AS xnat_petsessiondata_sordata_e_xnat_petsessiondata0,
                                    xnat_petsessiondata_1.xnat_experimentdata45 AS xnat_petsessiondata_sordata__xnat_experimentdata45,
                                    xnat_petsessiondata_1.xnat_subjectassessordata42 AS xnat_petsessiondata_sor_xnat_subjectassessordata42
                                   FROM ((((public.xnat_subjectdata xnat_subjectdata
                                     LEFT JOIN public.xnat_subjectdata_meta_data table1_1 ON ((xnat_subjectdata.subjectdata_info = table1_1.meta_data_id)))
                                     LEFT JOIN ( SELECT xnat_subjectdata_1.id AS xnat_subjectdata3,
    table1_2.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata91,
    table2_1.insert_date AS xnat_subjectdata_meta_data328
   FROM ((public.xnat_subjectdata xnat_subjectdata_1
     LEFT JOIN public.xnat_abstractdemographicdata table1_2 ON ((xnat_subjectdata_1.demographics_xnat_abstractdemographicdata_id = table1_2.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_subjectdata_meta_data table2_1 ON ((xnat_subjectdata_1.subjectdata_info = table2_1.meta_data_id)))) map_xnat_demographicdata ON (((xnat_subjectdata.id)::text = (map_xnat_demographicdata.xnat_subjectdata3)::text)))
                                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
    table2_1.insert_date AS xnat_demographicdata_meta_data47,
    table0_1.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata27
   FROM ((public.xnat_demographicdata xnat_demographicdata_2
     LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_2.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_2.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata_1 ON ((map_xnat_demographicdata.xnat_abstractdemographicdata91 = xnat_demographicdata_1.xnat_abstractdemographicdata27)))
                                     LEFT JOIN ( SELECT table2_1.id AS xnat_petsessiondata0,
    table2_1.date AS xnat_experimentdata45,
    table1_2.subject_id AS xnat_subjectassessordata42
   FROM (((public.xnat_petsessiondata xnat_petsessiondata_2
     LEFT JOIN public.xnat_imagesessiondata table0_1 ON (((xnat_petsessiondata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_subjectassessordata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))
     LEFT JOIN public.xnat_experimentdata table2_1 ON (((table1_2.id)::text = (table2_1.id)::text)))) xnat_petsessiondata_1 ON (((xnat_subjectdata.id)::text = (xnat_petsessiondata_1.xnat_subjectassessordata42)::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_petsessiondata_sordata__xnat_experimentdata45 DESC) map_xnat_subjectdata_xnat_demographicdata ON (((table2.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_petsessiondata_sordata_e_xnat_petsessiondata0)::text)))
                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
                            table2_1.insert_date AS xnat_demographicdata_meta_data47,
                            xnat_demographicdata_1.dob AS xnat_demographicdata1,
                            xnat_demographicdata_1.yob AS xnat_demographicdata2,
                            xnat_demographicdata_1.age AS xnat_demographicdata3
                           FROM ((public.xnat_demographicdata xnat_demographicdata_1
                             LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_1.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
                             LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_1.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata ON ((map_xnat_subjectdata_xnat_demographicdata.xnat_demographicdata_demograp_xnat_demographicdata0 = xnat_demographicdata.xnat_demographicdata0)))) search_1
          ORDER BY search_1.xnat_petsessiondata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_petsessiondata0
           FROM ( SELECT table2.id AS xnat_petsessiondata0,
                    table2.date AS xnat_experimentdata45
                   FROM (((public.xnat_petsessiondata xnat_petsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_petsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))) where_clause_1) where_clause ON (((where_clause.xnat_petsessiondata0)::text = (search.xnat_petsessiondata0)::text)))
  ORDER BY search.xnat_subjectassessordata42;


ALTER TABLE public.displayfields_xnat_petsessiondata OWNER TO xnat;

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

CREATE VIEW public.proj_arc AS
 SELECT arc_project.id AS proj_id,
    arc_project.current_arc,
    COALESCE(arc_project.quarantine_code, 0) AS quarantine_code,
    COALESCE(arc_project.prearchive_code, 0) AS prearchive_code
   FROM public.arc_project;


ALTER TABLE public.proj_arc OWNER TO xnat;

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

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


ALTER TABLE public.proj_ct_counts OWNER TO xnat;

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

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


ALTER TABLE public.proj_mr_counts OWNER TO xnat;

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

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


ALTER TABLE public.proj_pet_counts OWNER TO xnat;

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

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


ALTER TABLE public.proj_ut_counts OWNER TO xnat;

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

CREATE TABLE public.xnat_projectdata (
    name character varying(255),
    type character varying(255),
    description text,
    keywords character varying(255),
    pi_xnat_investigatordata_id integer,
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    secondary_id character varying(255),
    active integer,
    projectdata_info integer
);


ALTER TABLE public.xnat_projectdata OWNER TO xnat;

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

CREATE VIEW public.project_access AS
 SELECT proj.id,
        CASE
            WHEN ((project_read.project_read = 1) AND (subject_read.subject_read = 1)) THEN 'public'::text
            WHEN (project_read.project_read = 1) THEN 'protected'::text
            ELSE 'private'::text
        END AS accessibility
   FROM ((public.xnat_projectdata proj
     LEFT JOIN ( SELECT fm.field_value,
            fm.read_element AS project_read
           FROM (((public.xdat_element_access ea
             LEFT JOIN public.xdat_field_mapping_set fms ON ((ea.xdat_element_access_id = fms.permissions_allow_set_xdat_elem_xdat_element_access_id)))
             LEFT JOIN public.xdat_user u ON ((ea.xdat_user_xdat_user_id = u.xdat_user_id)))
             LEFT JOIN public.xdat_field_mapping fm ON ((fms.xdat_field_mapping_set_id = fm.xdat_field_mapping_set_xdat_field_mapping_set_id)))
          WHERE (((u.login)::text = 'guest'::text) AND ((ea.element_name)::text = 'xnat:projectData'::text))) project_read ON (((proj.id)::text = (project_read.field_value)::text)))
     LEFT JOIN ( SELECT fm.field_value,
            fm.read_element AS subject_read
           FROM (((public.xdat_element_access ea
             LEFT JOIN public.xdat_field_mapping_set fms ON ((ea.xdat_element_access_id = fms.permissions_allow_set_xdat_elem_xdat_element_access_id)))
             LEFT JOIN public.xdat_user u ON ((ea.xdat_user_xdat_user_id = u.xdat_user_id)))
             LEFT JOIN public.xdat_field_mapping fm ON ((fms.xdat_field_mapping_set_id = fm.xdat_field_mapping_set_xdat_field_mapping_set_id)))
          WHERE (((u.login)::text = 'guest'::text) AND ((fm.field)::text = 'xnat:subjectData/project'::text))) subject_read ON (((proj.id)::text = (subject_read.field_value)::text)));


ALTER TABLE public.project_access OWNER TO xnat;

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

CREATE TABLE public.xdat_user_groupid (
    groupid character varying(255),
    user_groupid_info integer,
    xdat_user_groupid_id integer NOT NULL,
    groups_groupid_xdat_user_xdat_user_id integer
);


ALTER TABLE public.xdat_user_groupid OWNER TO xnat;

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

CREATE VIEW public.project_collabs AS
 SELECT proj_users.field_value AS xnat_projectdata_id,
    btrim(public.xs_a_concat(((' '::text || (proj_users.login)::text) || ' <br/>'::text)), '<br/>'::text) AS users
   FROM ( SELECT DISTINCT fm.field_value,
            u.login
           FROM (((((public.xdat_element_access ea
             LEFT JOIN public.xdat_field_mapping_set fms ON ((ea.xdat_element_access_id = fms.permissions_allow_set_xdat_elem_xdat_element_access_id)))
             LEFT JOIN public.xdat_field_mapping fm ON ((fms.xdat_field_mapping_set_id = fm.xdat_field_mapping_set_xdat_field_mapping_set_id)))
             RIGHT JOIN public.xdat_usergroup grp ON (((ea.xdat_usergroup_xdat_usergroup_id = grp.xdat_usergroup_id) AND ((grp.displayname)::text = 'Collaborators'::text))))
             RIGHT JOIN public.xdat_user_groupid map ON (((grp.id)::text = (map.groupid)::text)))
             RIGHT JOIN public.xdat_user u ON ((map.groups_groupid_xdat_user_xdat_user_id = u.xdat_user_id)))
          WHERE ((fm.field)::text = 'xnat:subjectData/sharing/share/project'::text)) proj_users
  GROUP BY proj_users.field_value;


ALTER TABLE public.project_collabs OWNER TO xnat;

--
-- Name: xs_fav_entries; Type: TABLE; Schema: xdat_search; Owner: xnat
--

CREATE TABLE xdat_search.xs_fav_entries (
    datatype character varying(255),
    id character varying(255),
    xdat_user_id integer
);


ALTER TABLE xdat_search.xs_fav_entries OWNER TO xnat;

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

CREATE VIEW public.project_favs AS
 SELECT last_access.id AS project_id,
    btrim(public.xs_a_concat(((' '::text || (u.login)::text) || ' <br/>'::text)), '<br/>'::text) AS users
   FROM (( SELECT DISTINCT xs_fav_entries.id,
            xs_fav_entries.xdat_user_id
           FROM xdat_search.xs_fav_entries
          WHERE ((xs_fav_entries.datatype)::text = 'Project'::text)) last_access
     LEFT JOIN public.xdat_user u ON ((last_access.xdat_user_id = u.xdat_user_id)))
  GROUP BY last_access.id;


ALTER TABLE public.project_favs OWNER TO xnat;


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

CREATE TABLE public.xnat_projectdata_investigator (
    xnat_projectdata_id character varying NOT NULL,
    xnat_investigatordata_xnat_investigatordata_id integer NOT NULL,
    xnat_projectdata_investigator_id integer NOT NULL
);


ALTER TABLE public.xnat_projectdata_investigator OWNER TO xnat;

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

CREATE VIEW public.project_invs AS
 SELECT proj.id AS xnat_projectdata_id,
    (COALESCE((((pi.lastname)::text || ', '::text) || (pi.firstname)::text), ''::text) || COALESCE(others.other_invs, ''::text)) AS proj_invs
   FROM ((public.xnat_projectdata proj
     LEFT JOIN public.xnat_investigatordata pi ON ((proj.pi_xnat_investigatordata_id = pi.xnat_investigatordata_id)))
     LEFT JOIN ( SELECT pinv.xnat_projectdata_id,
            public.xs_a_concat((((' <br/> '::text || (inv.lastname)::text) || ', '::text) || (inv.firstname)::text)) AS other_invs
           FROM (public.xnat_projectdata_investigator pinv
             LEFT JOIN public.xnat_investigatordata inv ON ((pinv.xnat_investigatordata_xnat_investigatordata_id = inv.xnat_investigatordata_id)))
          GROUP BY pinv.xnat_projectdata_id) others ON (((proj.id)::text = (others.xnat_projectdata_id)::text)));


ALTER TABLE public.project_invs OWNER TO xnat;


--
-- Name: xs_item_access; Type: TABLE; Schema: xdat_search; Owner: xnat
--

CREATE TABLE xdat_search.xs_item_access (
    search_value character varying(255),
    search_element character varying(255),
    search_field character varying(255),
    accessed timestamp without time zone DEFAULT now(),
    xdat_user_id character varying(255),
    method character varying(255)
);


ALTER TABLE xdat_search.xs_item_access OWNER TO xnat;

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

CREATE VIEW public.project_last_access AS
 SELECT last_access.search_value,
    btrim(public.xs_a_concat(((' '::text || (u.login)::text) || ' <br/>'::text)), '<br/>'::text) AS users
   FROM (( SELECT DISTINCT xs_item_access.search_value,
            xs_item_access.xdat_user_id
           FROM xdat_search.xs_item_access
          WHERE (((xs_item_access.search_element)::text = 'xnat:projectData'::text) AND (xs_item_access.accessed > (now() - '1 mon'::interval)))) last_access
     LEFT JOIN public.xdat_user u ON (((last_access.xdat_user_id)::text = (u.xdat_user_id)::text)))
  GROUP BY last_access.search_value;


ALTER TABLE public.project_last_access OWNER TO xnat;

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

CREATE VIEW public.project_last_workflow AS
 SELECT proj.id,
    launch_times.last_workflow
   FROM (public.xnat_projectdata proj
     LEFT JOIN ( SELECT wrk_workflowdata.externalid,
            max(wrk_workflowdata.launch_time) AS last_workflow
           FROM public.wrk_workflowdata
          GROUP BY wrk_workflowdata.externalid) launch_times ON (((proj.id)::text = (launch_times.externalid)::text)));


ALTER TABLE public.project_last_workflow OWNER TO xnat;

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

CREATE VIEW public.project_members AS
 SELECT proj_users.field_value AS xnat_projectdata_id,
    btrim(public.xs_a_concat(((' '::text || (proj_users.login)::text) || ' <br/>'::text)), '<br/>'::text) AS users
   FROM ( SELECT DISTINCT fm.field_value,
            u.login
           FROM (((((public.xdat_element_access ea
             LEFT JOIN public.xdat_field_mapping_set fms ON ((ea.xdat_element_access_id = fms.permissions_allow_set_xdat_elem_xdat_element_access_id)))
             LEFT JOIN public.xdat_field_mapping fm ON ((fms.xdat_field_mapping_set_id = fm.xdat_field_mapping_set_xdat_field_mapping_set_id)))
             RIGHT JOIN public.xdat_usergroup grp ON (((ea.xdat_usergroup_xdat_usergroup_id = grp.xdat_usergroup_id) AND ((grp.displayname)::text = 'Members'::text))))
             RIGHT JOIN public.xdat_user_groupid map ON (((grp.id)::text = (map.groupid)::text)))
             RIGHT JOIN public.xdat_user u ON ((map.groups_groupid_xdat_user_xdat_user_id = u.xdat_user_id)))
          WHERE ((fm.field)::text = 'xnat:subjectData/sharing/share/project'::text)) proj_users
  GROUP BY proj_users.field_value;


ALTER TABLE public.project_members OWNER TO xnat;

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

CREATE VIEW public.project_owners AS
 SELECT proj_users.field_value AS xnat_projectdata_id,
    btrim(public.xs_a_concat(((' '::text || (proj_users.login)::text) || ' <br/>'::text)), '<br/>'::text) AS users
   FROM ( SELECT DISTINCT fm.field_value,
            u.login
           FROM (((((public.xdat_element_access ea
             LEFT JOIN public.xdat_field_mapping_set fms ON ((ea.xdat_element_access_id = fms.permissions_allow_set_xdat_elem_xdat_element_access_id)))
             LEFT JOIN public.xdat_field_mapping fm ON ((fms.xdat_field_mapping_set_id = fm.xdat_field_mapping_set_xdat_field_mapping_set_id)))
             RIGHT JOIN public.xdat_usergroup grp ON (((ea.xdat_usergroup_xdat_usergroup_id = grp.xdat_usergroup_id) AND ((grp.displayname)::text = 'Owners'::text))))
             RIGHT JOIN public.xdat_user_groupid map ON (((grp.id)::text = (map.groupid)::text)))
             RIGHT JOIN public.xdat_user u ON ((map.groups_groupid_xdat_user_xdat_user_id = u.xdat_user_id)))
          WHERE ((fm.field)::text = 'xnat:subjectData/sharing/share/project'::text)) proj_users
  GROUP BY proj_users.field_value;


ALTER TABLE public.project_owners OWNER TO xnat;

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

CREATE VIEW public.project_users AS
 SELECT proj_users.field_value AS xnat_projectdata_id,
    btrim(public.xs_a_concat(((' '::text || (proj_users.login)::text) || ' <br/>'::text)), '<br/>'::text) AS users
   FROM ( SELECT DISTINCT fm.field_value,
            u.login
           FROM (((((public.xdat_element_access ea
             LEFT JOIN public.xdat_field_mapping_set fms ON ((ea.xdat_element_access_id = fms.permissions_allow_set_xdat_elem_xdat_element_access_id)))
             LEFT JOIN public.xdat_field_mapping fm ON ((fms.xdat_field_mapping_set_id = fm.xdat_field_mapping_set_xdat_field_mapping_set_id)))
             RIGHT JOIN public.xdat_usergroup grp ON ((ea.xdat_usergroup_xdat_usergroup_id = grp.xdat_usergroup_id)))
             RIGHT JOIN public.xdat_user_groupid map ON (((grp.id)::text = (map.groupid)::text)))
             RIGHT JOIN public.xdat_user u ON ((map.groups_groupid_xdat_user_xdat_user_id = u.xdat_user_id)))
          WHERE ((fm.field)::text = 'xnat:subjectData/sharing/share/project'::text)) proj_users
  GROUP BY proj_users.field_value;


ALTER TABLE public.project_users OWNER TO xnat;

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

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

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

CREATE VIEW public.displayfields_xnat_projectdata AS
 SELECT search.xnat_projectdata_meta_data218 AS insert_date,
    search.table2_login AS insert_user,
    search.xnat_projectdata5 AS id,
    search.xnat_projectdata0 AS name,
    search.xnat_projectdata0 AS name_csv,
    "substring"(search.xnat_projectdata2, 0, 162) AS description,
    search.xnat_projectdata2 AS description_csv,
    search.xnat_projectdata6 AS secondary_id,
    search.xnat_projectdata3 AS keywords,
    (((search.xnat_investigatordata153)::text || ' '::text) || (search.xnat_investigatordata154)::text) AS pi,
    search.project_invs_proj_invs AS project_invs,
    search.project_access_accessibility AS project_access,
    search.project_users_users AS project_users,
    search.project_owners_users AS project_owners,
    search.project_members_users AS project_members,
    search.project_collabs_users AS project_collabs,
    search.project_last_workflow_last_workflow AS project_last_workflow,
    search.project_last_access_users AS project_last_access,
    search.project_favs_users AS project_fav,
        CASE search.project_access_accessibility
            WHEN 'public'::text THEN '/@WEBAPPimages/globe.gif'::text
            ELSE '/@WEBAPPimages/key.gif'::text
        END AS project_access_img,
    search.proj_mr_counts_proj_expt_count AS proj_mr_count,
    search.proj_ct_counts_proj_expt_count AS proj_ct_count,
    search.proj_pet_counts_proj_expt_count AS proj_pet_count,
    search.proj_ut_counts_proj_expt_count AS proj_ut_count,
    search.proj_arc_quarantine_code AS proj_quarantine,
    search.proj_arc_prearchive_code AS proj_prearchive_code,
    search.xnat_projectdata_meta_data215 AS quarantine_status
   FROM (( SELECT DISTINCT xnat_projectdata.id AS xnat_projectdata5,
            table1.status AS xnat_projectdata_meta_data215,
            table1.insert_date AS xnat_projectdata_meta_data218,
            table2.login AS table2_login,
            xnat_projectdata.name AS xnat_projectdata0,
            xnat_projectdata.description AS xnat_projectdata2,
            xnat_projectdata.secondary_id AS xnat_projectdata6,
            xnat_projectdata.keywords AS xnat_projectdata3,
            table3.firstname AS xnat_investigatordata153,
            table3.lastname AS xnat_investigatordata154,
            project_invs.proj_invs AS project_invs_proj_invs,
            project_access.accessibility AS project_access_accessibility,
            project_users.users AS project_users_users,
            project_owners.users AS project_owners_users,
            project_members.users AS project_members_users,
            project_collabs.users AS project_collabs_users,
            project_last_workflow.last_workflow AS project_last_workflow_last_workflow,
            project_last_access.users AS project_last_access_users,
            project_favs.users AS project_favs_users,
            proj_mr_counts.proj_expt_count AS proj_mr_counts_proj_expt_count,
            proj_ct_counts.proj_expt_count AS proj_ct_counts_proj_expt_count,
            proj_pet_counts.proj_expt_count AS proj_pet_counts_proj_expt_count,
            proj_ut_counts.proj_expt_count AS proj_ut_counts_proj_expt_count,
            proj_arc.quarantine_code AS proj_arc_quarantine_code,
            proj_arc.prearchive_code AS proj_arc_prearchive_code
           FROM (((((((((((((((((public.xnat_projectdata xnat_projectdata
             LEFT JOIN public.xnat_projectdata_meta_data table1 ON ((xnat_projectdata.projectdata_info = table1.meta_data_id)))
             LEFT JOIN public.xdat_user table2 ON ((table1.insert_user_xdat_user_id = table2.xdat_user_id)))
             LEFT JOIN public.xnat_investigatordata table3 ON ((xnat_projectdata.pi_xnat_investigatordata_id = table3.xnat_investigatordata_id)))
             LEFT JOIN public.project_invs project_invs ON (((xnat_projectdata.id)::text = (project_invs.xnat_projectdata_id)::text)))
             LEFT JOIN public.project_access project_access ON (((xnat_projectdata.id)::text = (project_access.id)::text)))
             LEFT JOIN public.project_users project_users ON (((xnat_projectdata.id)::text = (project_users.xnat_projectdata_id)::text)))
             LEFT JOIN public.project_owners project_owners ON (((xnat_projectdata.id)::text = (project_owners.xnat_projectdata_id)::text)))
             LEFT JOIN public.project_members project_members ON (((xnat_projectdata.id)::text = (project_members.xnat_projectdata_id)::text)))
             LEFT JOIN public.project_collabs project_collabs ON (((xnat_projectdata.id)::text = (project_collabs.xnat_projectdata_id)::text)))
             LEFT JOIN public.project_last_workflow project_last_workflow ON (((xnat_projectdata.id)::text = (project_last_workflow.id)::text)))
             LEFT JOIN public.project_last_access project_last_access ON (((xnat_projectdata.id)::text = (project_last_access.search_value)::text)))
             LEFT JOIN public.project_favs project_favs ON (((xnat_projectdata.id)::text = (project_favs.project_id)::text)))
             LEFT JOIN public.proj_mr_counts proj_mr_counts ON (((xnat_projectdata.id)::text = (proj_mr_counts.project)::text)))
             LEFT JOIN public.proj_ct_counts proj_ct_counts ON (((xnat_projectdata.id)::text = (proj_ct_counts.project)::text)))
             LEFT JOIN public.proj_pet_counts proj_pet_counts ON (((xnat_projectdata.id)::text = (proj_pet_counts.project)::text)))
             LEFT JOIN public.proj_ut_counts proj_ut_counts ON (((xnat_projectdata.id)::text = (proj_ut_counts.project)::text)))
             LEFT JOIN public.proj_arc proj_arc ON (((xnat_projectdata.id)::text = (proj_arc.proj_id)::text)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_projectdata5
           FROM ( SELECT xnat_projectdata.id AS xnat_projectdata5,
                    table1.insert_date AS xnat_projectdata_meta_data218
                   FROM (public.xnat_projectdata xnat_projectdata
                     LEFT JOIN public.xnat_projectdata_meta_data table1 ON ((xnat_projectdata.projectdata_info = table1.meta_data_id)))) where_clause_1) where_clause ON (((where_clause.xnat_projectdata5)::text = (search.xnat_projectdata5)::text)))
  ORDER BY search.xnat_projectdata_meta_data218;


ALTER TABLE public.displayfields_xnat_projectdata OWNER TO xnat;

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

CREATE TABLE public.xnat_pvisitdata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    subject_id character varying(255),
    visit_type character varying(255),
    visit_name character varying(255),
    notes text,
    start_date timestamp without time zone,
    end_date timestamp without time zone,
    closed integer,
    terminal integer,
    status character varying(255),
    protocolversion integer,
    protocolid character varying(255),
    pvisitdata_info integer
);


ALTER TABLE public.xnat_pvisitdata OWNER TO xnat;

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

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

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

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


ALTER TABLE public.xnat_pvisitdata_projects OWNER TO xnat;

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

CREATE VIEW public.displayfields_xnat_pvisitdata AS
 SELECT search.xnat_pvisitdata1 AS subject_id,
    search.xnat_pvisitdata0 AS expt_id,
    '/@WEBAPP/images/r.gif'::text AS rpt,
    search.xnat_experimentdata15 AS date,
    search.xnat_pvisitdata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata31, search.xnat_pvisitdata0) AS label,
    search.table4_login AS insert_user,
    search.xnat_pvisitdata_meta_data182 AS insert_date,
    search.xnat_experimentdata25 AS project,
    search.xnat_pvisitdata2 AS visit_type,
    search.xnat_pvisitdata3 AS visit_name,
    search.xnat_pvisitdata7 AS closed,
    search.xnat_pvisitdata8 AS terminal,
    search.xnat_pvisitdata10 AS protocolversion,
    search.xnat_pvisitdata11 AS protocolid,
    search.xnat_pvisitdata_meta_data179 AS quarantine_status
   FROM (( SELECT DISTINCT table1.id AS xnat_pvisitdata0,
            table3.status AS xnat_pvisitdata_meta_data179,
            xnat_pvisitdata.subject_id AS xnat_pvisitdata1,
            table1.date AS xnat_experimentdata15,
            table1.label AS xnat_experimentdata31,
            table4.login AS table4_login,
            table3.insert_date AS xnat_pvisitdata_meta_data182,
            table1.project AS xnat_experimentdata25,
            xnat_pvisitdata.visit_type AS xnat_pvisitdata2,
            xnat_pvisitdata.visit_name AS xnat_pvisitdata3,
            xnat_pvisitdata.closed AS xnat_pvisitdata7,
            xnat_pvisitdata.terminal AS xnat_pvisitdata8,
            xnat_pvisitdata.protocolversion AS xnat_pvisitdata10,
            xnat_pvisitdata.protocolid AS xnat_pvisitdata11,
            xnat_pvisitdata_projects.projects AS xnat_pvisitdata_projects_projects
           FROM (((((public.xnat_pvisitdata xnat_pvisitdata
             LEFT JOIN public.xnat_genericdata table0 ON (((xnat_pvisitdata.id)::text = (table0.id)::text)))
             LEFT JOIN public.xnat_experimentdata table1 ON (((table0.id)::text = (table1.id)::text)))
             LEFT JOIN public.xnat_pvisitdata_meta_data table3 ON ((xnat_pvisitdata.pvisitdata_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_pvisitdata_projects xnat_pvisitdata_projects ON (((table1.id)::text = (xnat_pvisitdata_projects.id)::text)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_pvisitdata0
           FROM ( SELECT table1.id AS xnat_pvisitdata0,
                    table1.date AS xnat_experimentdata15
                   FROM ((public.xnat_pvisitdata xnat_pvisitdata
                     LEFT JOIN public.xnat_genericdata table0 ON (((xnat_pvisitdata.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_pvisitdata0)::text = (search.xnat_pvisitdata0)::text)))
  ORDER BY search.xnat_pvisitdata1;


ALTER TABLE public.displayfields_xnat_pvisitdata OWNER TO xnat;

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

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


ALTER TABLE public.xnat_mrassessordata OWNER TO xnat;

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

CREATE TABLE public.xnat_qcassessmentdata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    type character varying(255),
    qcassessmentdata_info integer
);


ALTER TABLE public.xnat_qcassessmentdata OWNER TO xnat;

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

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

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

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


ALTER TABLE public.xnat_qcassessmentdata_projects OWNER TO xnat;

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

CREATE VIEW public.displayfields_xnat_qcassessmentdata AS
 SELECT search.xnat_imageassessordata6 AS session_id,
    search.xnat_mrsessiondata_sor_xnat_subjectassessordata23 AS subject_id,
    search.xnat_mrsessiondata_sordata__xnat_experimentdata26 AS mr_date,
    search.xnat_qcassessmentdata0 AS expt_id,
    '/@WEBAPP/images/r.gif'::text AS rpt,
    search.xnat_experimentdata11 AS date,
    (COALESCE((floor(((((search.xnat_mrsessiondata_sordata__xnat_experimentdata26 - search.xnat_demographicdata_xnat_demographicdata1))::real / (365)::double precision))::numeric))::double precision, floor((date_part('year'::text, search.xnat_mrsessiondata_sordata__xnat_experimentdata26) - (search.xnat_demographicdata_xnat_demographicdata2)::double precision))))::numeric AS age,
    search.xnat_qcassessmentdata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata27, search.xnat_qcassessmentdata0) AS label,
    search.table6_login AS insert_user,
    search.xnat_qcassessmentdata_meta_data425 AS insert_date,
    search.xnat_experimentdata21 AS project,
    search.xnat_qcassessmentdata1 AS type,
    search.xnat_qcassessmentdata_meta_data422 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_qcassessmentdata0) search_1.xnat_qcassessmentdata0,
            search_1.xnat_qcassessmentdata_meta_data422,
            search_1.xnat_imageassessordata6,
            search_1.xnat_experimentdata11,
            search_1.xnat_experimentdata27,
            search_1.table6_login,
            search_1.xnat_qcassessmentdata_meta_data425,
            search_1.xnat_experimentdata21,
            search_1.xnat_qcassessmentdata1,
            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_mrsessiondata_sordata_ex_xnat_mrsessiondata0,
            search_1.xnat_mrsessiondata_sordata__xnat_experimentdata26,
            search_1.xnat_mrsessiondata_sor_xnat_subjectassessordata23,
            search_1.xnat_qcassessmentdata_projects_projects,
            (search_1.xnat_experimentdata11 - search_1.xnat_mrsessiondata_sordata__xnat_experimentdata26) AS xnat_qcassessmentdata_xnat_mrsessiondata_diff
           FROM ( SELECT table3.id AS xnat_qcassessmentdata0,
                    table5.status AS xnat_qcassessmentdata_meta_data422,
                    table1.imagesession_id AS xnat_imageassessordata6,
                    table3.date AS xnat_experimentdata11,
                    table3.label AS xnat_experimentdata27,
                    table6.login AS table6_login,
                    table5.insert_date AS xnat_qcassessmentdata_meta_data425,
                    table3.project AS xnat_experimentdata21,
                    xnat_qcassessmentdata.type AS xnat_qcassessmentdata1,
                    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_mrsessiondata.xnat_mrsessiondata0 AS xnat_mrsessiondata_sordata_ex_xnat_mrsessiondata0,
                    xnat_mrsessiondata.xnat_experimentdata26 AS xnat_mrsessiondata_sordata__xnat_experimentdata26,
                    xnat_mrsessiondata.xnat_subjectassessordata23 AS xnat_mrsessiondata_sor_xnat_subjectassessordata23,
                    xnat_qcassessmentdata_projects.projects AS xnat_qcassessmentdata_projects_projects
                   FROM ((((((((((public.xnat_qcassessmentdata xnat_qcassessmentdata
                     LEFT JOIN public.xnat_mrassessordata table0 ON (((xnat_qcassessmentdata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_imageassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_deriveddata table2 ON (((table1.id)::text = (table2.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table3 ON (((table2.id)::text = (table3.id)::text)))
                     LEFT JOIN public.xnat_qcassessmentdata_meta_data table5 ON ((xnat_qcassessmentdata.qcassessmentdata_info = table5.meta_data_id)))
                     LEFT JOIN public.xdat_user table6 ON ((table5.insert_user_xdat_user_id = table6.xdat_user_id)))
                     LEFT JOIN public.xnat_qcassessmentdata_projects xnat_qcassessmentdata_projects ON (((table3.id)::text = (xnat_qcassessmentdata_projects.id)::text)))
                     LEFT JOIN ( SELECT search_2.xnat_subjectdata3,
                            search_2.xnat_subjectdata_meta_data328,
                            search_2.xnat_qcassessmentdata_ata_ext_xnat_qcassessmentdata0,
                            search_2.xnat_qcassessmentdata_ata_ext__xnat_experimentdata11,
                            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_qcassessmentdata_1.xnat_qcassessmentdata0 AS xnat_qcassessmentdata_ata_ext_xnat_qcassessmentdata0,
                                    xnat_qcassessmentdata_1.xnat_experimentdata11 AS xnat_qcassessmentdata_ata_ext__xnat_experimentdata11,
                                    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 table3_1.id AS xnat_qcassessmentdata0,
    table1_2.imagesession_id AS xnat_imageassessordata6,
    xnat_mrsessiondata_1.xnat_subjectassessordata23
   FROM (((((public.xnat_qcassessmentdata xnat_qcassessmentdata_2
     LEFT JOIN public.xnat_mrassessordata table0_1 ON (((xnat_qcassessmentdata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_imageassessordata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))
     LEFT JOIN public.xnat_deriveddata table2_1 ON (((table1_2.id)::text = (table2_1.id)::text)))
     LEFT JOIN public.xnat_experimentdata table3_1 ON (((table2_1.id)::text = (table3_1.id)::text)))
     LEFT JOIN ( SELECT table2_2.id AS xnat_mrsessiondata0,
      table1_3.subject_id AS xnat_subjectassessordata23
     FROM (((public.xnat_mrsessiondata xnat_mrsessiondata_2
       LEFT JOIN public.xnat_imagesessiondata table0_2 ON (((xnat_mrsessiondata_2.id)::text = (table0_2.id)::text)))
       LEFT JOIN public.xnat_subjectassessordata table1_3 ON (((table0_2.id)::text = (table1_3.id)::text)))
       LEFT JOIN public.xnat_experimentdata table2_2 ON (((table1_3.id)::text = (table2_2.id)::text)))) xnat_mrsessiondata_1 ON (((table1_2.imagesession_id)::text = (xnat_mrsessiondata_1.xnat_mrsessiondata0)::text)))) map_xnat_qcassessmentdata ON (((xnat_subjectdata.id)::text = (map_xnat_qcassessmentdata.xnat_subjectassessordata23)::text)))
                                     LEFT JOIN ( SELECT table3_1.id AS xnat_qcassessmentdata0,
    table3_1.date AS xnat_experimentdata11
   FROM ((((public.xnat_qcassessmentdata xnat_qcassessmentdata_2
     LEFT JOIN public.xnat_mrassessordata table0_1 ON (((xnat_qcassessmentdata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_imageassessordata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))
     LEFT JOIN public.xnat_deriveddata table2_1 ON (((table1_2.id)::text = (table2_1.id)::text)))
     LEFT JOIN public.xnat_experimentdata table3_1 ON (((table2_1.id)::text = (table3_1.id)::text)))) xnat_qcassessmentdata_1 ON (((map_xnat_qcassessmentdata.xnat_qcassessmentdata0)::text = (xnat_qcassessmentdata_1.xnat_qcassessmentdata0)::text)))
                                     LEFT JOIN ( SELECT xnat_subjectdata_1.id AS xnat_subjectdata3,
    table1_2.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata91,
    table2_1.insert_date AS xnat_subjectdata_meta_data328
   FROM ((public.xnat_subjectdata xnat_subjectdata_1
     LEFT JOIN public.xnat_abstractdemographicdata table1_2 ON ((xnat_subjectdata_1.demographics_xnat_abstractdemographicdata_id = table1_2.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_subjectdata_meta_data table2_1 ON ((xnat_subjectdata_1.subjectdata_info = table2_1.meta_data_id)))) map_xnat_demographicdata ON (((xnat_subjectdata.id)::text = (map_xnat_demographicdata.xnat_subjectdata3)::text)))
                                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
    table2_1.insert_date AS xnat_demographicdata_meta_data47,
    table0_1.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata27
   FROM ((public.xnat_demographicdata xnat_demographicdata_2
     LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_2.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_2.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata_1 ON ((map_xnat_demographicdata.xnat_abstractdemographicdata91 = xnat_demographicdata_1.xnat_abstractdemographicdata27)))) search_2
                          ORDER BY search_2.xnat_subjectdata3, search_2.xnat_qcassessmentdata_ata_ext__xnat_experimentdata11 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 (((table3.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_qcassessmentdata_ata_ext_xnat_qcassessmentdata0)::text)))
                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
                            table2_1.insert_date AS xnat_demographicdata_meta_data47,
                            xnat_demographicdata_1.dob AS xnat_demographicdata1,
                            xnat_demographicdata_1.yob AS xnat_demographicdata2
                           FROM ((public.xnat_demographicdata xnat_demographicdata_1
                             LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_1.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
                             LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_1.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata ON ((map_xnat_subjectdata_xnat_demographicdata.xnat_demographicdata_demograp_xnat_demographicdata0 = xnat_demographicdata.xnat_demographicdata0)))
                     LEFT JOIN ( SELECT table2_1.id AS xnat_mrsessiondata0,
                            table2_1.date AS xnat_experimentdata26,
                            table1_1.subject_id AS xnat_subjectassessordata23
                           FROM (((public.xnat_mrsessiondata xnat_mrsessiondata_1
                             LEFT JOIN public.xnat_imagesessiondata table0_1 ON (((xnat_mrsessiondata_1.id)::text = (table0_1.id)::text)))
                             LEFT JOIN public.xnat_subjectassessordata table1_1 ON (((table0_1.id)::text = (table1_1.id)::text)))
                             LEFT JOIN public.xnat_experimentdata table2_1 ON (((table1_1.id)::text = (table2_1.id)::text)))) xnat_mrsessiondata ON (((table1.imagesession_id)::text = (xnat_mrsessiondata.xnat_mrsessiondata0)::text)))) search_1
          ORDER BY search_1.xnat_qcassessmentdata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC, (search_1.xnat_experimentdata11 - search_1.xnat_mrsessiondata_sordata__xnat_experimentdata26)) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_qcassessmentdata0
           FROM ( SELECT table3.id AS xnat_qcassessmentdata0,
                    table3.date AS xnat_experimentdata11
                   FROM ((((public.xnat_qcassessmentdata xnat_qcassessmentdata
                     LEFT JOIN public.xnat_mrassessordata table0 ON (((xnat_qcassessmentdata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_imageassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_deriveddata table2 ON (((table1.id)::text = (table2.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table3 ON (((table2.id)::text = (table3.id)::text)))) where_clause_1) where_clause ON (((where_clause.xnat_qcassessmentdata0)::text = (search.xnat_qcassessmentdata0)::text)))
  ORDER BY search.xnat_imageassessordata6;


ALTER TABLE public.displayfields_xnat_qcassessmentdata OWNER TO xnat;

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

CREATE TABLE public.xnat_qcmanualassessordata (
    id character varying(255) DEFAULT ''::character varying NOT NULL,
    rater character varying(255),
    stereotacticmarker character varying(255),
    incidentalfindings text,
    comments text,
    pass character varying(255),
    payable character varying(255),
    rescan character varying(255),
    resolvable character varying(255),
    retrain character varying(255),
    qcmanualassessordata_info integer
);


ALTER TABLE public.xnat_qcmanualassessordata OWNER TO xnat;

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

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

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

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


ALTER TABLE public.xnat_qcmanualassessordata_projects OWNER TO xnat;

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

CREATE VIEW public.displayfields_xnat_qcmanualassessordata AS
 SELECT search.xnat_qcmanualassessordata0 AS expt_id,
    '/@WEBAPP/images/r.gif'::text AS rpt,
    search.xnat_experimentdata17 AS date,
    search.xnat_qcmanualassessordata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata33, search.xnat_qcmanualassessordata0) AS label,
    search.table5_login AS insert_user,
    search.xnat_qcmanualassessordata_meta_data395 AS insert_date,
    search.xnat_experimentdata27 AS project,
    search.xnat_qcmanualassessordata1 AS rater,
    search.xnat_qcmanualassessordata2 AS stereotacticmarker,
    search.xnat_qcmanualassessordata3 AS incidentalfindings,
    search.xnat_qcmanualassessordata4 AS comments,
    search.xnat_qcmanualassessordata5 AS pass,
    search.xnat_qcmanualassessordata6 AS payable,
    search.xnat_qcmanualassessordata7 AS rescan,
    search.xnat_qcmanualassessordata8 AS resolvable,
    search.xnat_qcmanualassessordata9 AS retrain,
    search.xnat_qcmanualassessordata_meta_data392 AS quarantine_status
   FROM (( SELECT DISTINCT table2.id AS xnat_qcmanualassessordata0,
            table4.status AS xnat_qcmanualassessordata_meta_data392,
            table2.date AS xnat_experimentdata17,
            table2.label AS xnat_experimentdata33,
            table5.login AS table5_login,
            table4.insert_date AS xnat_qcmanualassessordata_meta_data395,
            table2.project AS xnat_experimentdata27,
            xnat_qcmanualassessordata.rater AS xnat_qcmanualassessordata1,
            xnat_qcmanualassessordata.stereotacticmarker AS xnat_qcmanualassessordata2,
            xnat_qcmanualassessordata.incidentalfindings AS xnat_qcmanualassessordata3,
            xnat_qcmanualassessordata.comments AS xnat_qcmanualassessordata4,
            xnat_qcmanualassessordata.pass AS xnat_qcmanualassessordata5,
            xnat_qcmanualassessordata.payable AS xnat_qcmanualassessordata6,
            xnat_qcmanualassessordata.rescan AS xnat_qcmanualassessordata7,
            xnat_qcmanualassessordata.resolvable AS xnat_qcmanualassessordata8,
            xnat_qcmanualassessordata.retrain AS xnat_qcmanualassessordata9,
            xnat_qcmanualassessordata_projects.projects AS xnat_qcmanualassessordata_projects_projects
           FROM ((((((public.xnat_qcmanualassessordata xnat_qcmanualassessordata
             LEFT JOIN public.xnat_imageassessordata table0 ON (((xnat_qcmanualassessordata.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.xnat_qcmanualassessordata_meta_data table4 ON ((xnat_qcmanualassessordata.qcmanualassessordata_info = table4.meta_data_id)))
             LEFT JOIN public.xdat_user table5 ON ((table4.insert_user_xdat_user_id = table5.xdat_user_id)))
             LEFT JOIN public.xnat_qcmanualassessordata_projects xnat_qcmanualassessordata_projects ON (((table2.id)::text = (xnat_qcmanualassessordata_projects.id)::text)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_qcmanualassessordata0
           FROM ( SELECT table2.id AS xnat_qcmanualassessordata0,
                    table2.date AS xnat_experimentdata17
                   FROM (((public.xnat_qcmanualassessordata xnat_qcmanualassessordata
                     LEFT JOIN public.xnat_imageassessordata table0 ON (((xnat_qcmanualassessordata.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.xnat_qcmanualassessordata0)::text = (search.xnat_qcmanualassessordata0)::text)))
  ORDER BY search.xnat_qcmanualassessordata0;


ALTER TABLE public.displayfields_xnat_qcmanualassessordata OWNER TO xnat;

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

CREATE TABLE public.xnat_reconstructedimagedata (
    image_session_id character varying(255),
    provenance_prov_process_id integer,
    id character varying(255),
    type character varying(255),
    basescantype character varying(255),
    reconstructedimagedata_info integer,
    xnat_reconstructedimagedata_id integer NOT NULL
);


ALTER TABLE public.xnat_reconstructedimagedata OWNER TO xnat;

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

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

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

CREATE VIEW public.displayfields_xnat_reconstructedimagedata AS
 SELECT search.xnat_reconstructedimagedata_meta_data202 AS insert_date,
    search.table2_login AS insert_user,
    search.xnat_reconstructedimagedata0 AS image_session_id,
    search.xnat_reconstructedimagedata2 AS id,
    search.xnat_reconstructedimagedata3 AS type,
    search.xnat_reconstructedimagedata4 AS basescantype,
    search.xnat_reconstructedimagedata_meta_data199 AS quarantine_status
   FROM (( SELECT DISTINCT xnat_reconstructedimagedata.xnat_reconstructedimagedata_id AS xnat_reconstructedimagedata6,
            table1.status AS xnat_reconstructedimagedata_meta_data199,
            table1.insert_date AS xnat_reconstructedimagedata_meta_data202,
            table2.login AS table2_login,
            xnat_reconstructedimagedata.image_session_id AS xnat_reconstructedimagedata0,
            xnat_reconstructedimagedata.id AS xnat_reconstructedimagedata2,
            xnat_reconstructedimagedata.type AS xnat_reconstructedimagedata3,
            xnat_reconstructedimagedata.basescantype AS xnat_reconstructedimagedata4
           FROM ((public.xnat_reconstructedimagedata xnat_reconstructedimagedata
             LEFT JOIN public.xnat_reconstructedimagedata_meta_data table1 ON ((xnat_reconstructedimagedata.reconstructedimagedata_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_reconstructedimagedata6
           FROM ( SELECT xnat_reconstructedimagedata.xnat_reconstructedimagedata_id AS xnat_reconstructedimagedata6,
                    table1.insert_date AS xnat_reconstructedimagedata_meta_data202
                   FROM (public.xnat_reconstructedimagedata xnat_reconstructedimagedata
                     LEFT JOIN public.xnat_reconstructedimagedata_meta_data table1 ON ((xnat_reconstructedimagedata.reconstructedimagedata_info = table1.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.xnat_reconstructedimagedata6 = search.xnat_reconstructedimagedata6)))
  ORDER BY search.xnat_reconstructedimagedata_meta_data202;


ALTER TABLE public.displayfields_xnat_reconstructedimagedata OWNER TO xnat;

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

CREATE TABLE public.xnat_regionresource (
    file_xnat_abstractresource_id integer DEFAULT 0 NOT NULL,
    baseimage_xnat_abstractresource_id integer DEFAULT 0 NOT NULL,
    creator_firstname character varying(255),
    creator_lastname character varying(255),
    name character varying(255) DEFAULT ''::character varying NOT NULL,
    hemisphere character varying(255) DEFAULT ''::character varying NOT NULL,
    session_id character varying(255),
    regionresource_info integer,
    xnat_regionresource_id integer NOT NULL
);


ALTER TABLE public.xnat_regionresource OWNER TO xnat;

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

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

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

CREATE VIEW public.displayfields_xnat_regionresource AS
 SELECT search.xnat_regionresource_meta_data110 AS insert_date,
    search.table2_login AS insert_user,
    search.xnat_regionresource2 AS creator_firstname,
    search.xnat_regionresource3 AS creator_lastname,
    search.xnat_regionresource4 AS name,
    search.xnat_regionresource5 AS hemisphere,
    search.xnat_regionresource6 AS session_id,
    search.xnat_regionresource_meta_data107 AS quarantine_status
   FROM (( SELECT DISTINCT xnat_regionresource.xnat_regionresource_id AS xnat_regionresource8,
            table1.status AS xnat_regionresource_meta_data107,
            table1.insert_date AS xnat_regionresource_meta_data110,
            table2.login AS table2_login,
            xnat_regionresource.creator_firstname AS xnat_regionresource2,
            xnat_regionresource.creator_lastname AS xnat_regionresource3,
            xnat_regionresource.name AS xnat_regionresource4,
            xnat_regionresource.hemisphere AS xnat_regionresource5,
            xnat_regionresource.session_id AS xnat_regionresource6
           FROM ((public.xnat_regionresource xnat_regionresource
             LEFT JOIN public.xnat_regionresource_meta_data table1 ON ((xnat_regionresource.regionresource_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_regionresource8
           FROM ( SELECT xnat_regionresource.xnat_regionresource_id AS xnat_regionresource8,
                    table1.insert_date AS xnat_regionresource_meta_data110
                   FROM (public.xnat_regionresource xnat_regionresource
                     LEFT JOIN public.xnat_regionresource_meta_data table1 ON ((xnat_regionresource.regionresource_info = table1.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.xnat_regionresource8 = search.xnat_regionresource8)))
  ORDER BY search.xnat_regionresource_meta_data110;


ALTER TABLE public.displayfields_xnat_regionresource OWNER TO xnat;

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

CREATE TABLE public.xnat_abstractresource (
    note text,
    label character varying(255),
    file_count integer,
    file_size bigint,
    extension integer,
    abstractresource_info integer,
    xnat_abstractresource_id integer NOT NULL,
    xnat_imagescandata_xnat_imagescandata_id integer
);


ALTER TABLE public.xnat_abstractresource OWNER TO xnat;

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

CREATE TABLE public.xnat_resource (
    xnat_abstractresource_id integer DEFAULT 0 NOT NULL,
    provenance_prov_process_id integer,
    uri character varying(255) DEFAULT ''::character varying NOT NULL,
    format character varying(255),
    description character varying(255),
    content character varying(255),
    cachepath character varying(255),
    resource_info integer
);


ALTER TABLE public.xnat_resource OWNER TO xnat;

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

CREATE TABLE public.xnat_resourcecatalog (
    xnat_abstractresource_id integer DEFAULT 0 NOT NULL,
    resourcecatalog_info integer
);


ALTER TABLE public.xnat_resourcecatalog OWNER TO xnat;

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

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

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

CREATE VIEW public.displayfields_xnat_resourcecatalog AS
 SELECT search.xnat_resource4 AS uri,
    search.xnat_resource5 AS format,
    search.xnat_resource6 AS description,
    search.xnat_resource7 AS content,
    search.xnat_resource8 AS cachepath,
    search.xnat_abstractresource10 AS note,
    search.xnat_abstractresource11 AS label,
    search.xnat_abstractresource12 AS file_count,
    search.xnat_abstractresource13 AS file_size,
    search.xnat_resourcecatalog_meta_data123 AS insert_date,
    search.table4_login AS insert_user,
    search.xnat_resourcecatalog_meta_data120 AS quarantine_status
   FROM (( SELECT DISTINCT table1.xnat_abstractresource_id AS xnat_resourcecatalog0,
            table3.status AS xnat_resourcecatalog_meta_data120,
            table0.uri AS xnat_resource4,
            table0.format AS xnat_resource5,
            table0.description AS xnat_resource6,
            table0.content AS xnat_resource7,
            table0.cachepath AS xnat_resource8,
            table1.note AS xnat_abstractresource10,
            table1.label AS xnat_abstractresource11,
            table1.file_count AS xnat_abstractresource12,
            table1.file_size AS xnat_abstractresource13,
            table3.insert_date AS xnat_resourcecatalog_meta_data123,
            table4.login AS table4_login
           FROM ((((public.xnat_resourcecatalog xnat_resourcecatalog
             LEFT JOIN public.xnat_resource table0 ON ((xnat_resourcecatalog.xnat_abstractresource_id = table0.xnat_abstractresource_id)))
             LEFT JOIN public.xnat_abstractresource table1 ON ((table0.xnat_abstractresource_id = table1.xnat_abstractresource_id)))
             LEFT JOIN public.xnat_resourcecatalog_meta_data table3 ON ((xnat_resourcecatalog.resourcecatalog_info = table3.meta_data_id)))
             LEFT JOIN public.xdat_user table4 ON ((table3.insert_user_xdat_user_id = table4.xdat_user_id)))) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_resourcecatalog0
           FROM ( SELECT table1.xnat_abstractresource_id AS xnat_resourcecatalog0,
                    table3.insert_date AS xnat_resourcecatalog_meta_data123
                   FROM (((public.xnat_resourcecatalog xnat_resourcecatalog
                     LEFT JOIN public.xnat_resource table0 ON ((xnat_resourcecatalog.xnat_abstractresource_id = table0.xnat_abstractresource_id)))
                     LEFT JOIN public.xnat_abstractresource table1 ON ((table0.xnat_abstractresource_id = table1.xnat_abstractresource_id)))
                     LEFT JOIN public.xnat_resourcecatalog_meta_data table3 ON ((xnat_resourcecatalog.resourcecatalog_info = table3.meta_data_id)))) where_clause_1) where_clause ON ((where_clause.xnat_resourcecatalog0 = search.xnat_resourcecatalog0)))
  ORDER BY search.xnat_resource4;


ALTER TABLE public.displayfields_xnat_resourcecatalog OWNER TO xnat;

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

CREATE TABLE public.xnat_rfscandata (
    xnat_imagescandata_id integer DEFAULT 0 NOT NULL,
    rfscandata_info integer
);


ALTER TABLE public.xnat_rfscandata OWNER TO xnat;

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

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

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

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


ALTER TABLE public.displayfields_xnat_rfscandata OWNER TO xnat;

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

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


ALTER TABLE public.xnat_rfsessiondata OWNER TO xnat;

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

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

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

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


ALTER TABLE public.xnat_rfsessiondata_projects OWNER TO xnat;

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

CREATE VIEW public.displayfields_xnat_rfsessiondata AS
 SELECT search.xnat_subjectassessordata19 AS subject_id,
    search.xnat_rfsessiondata0 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_rfsessiondata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata38, search.xnat_rfsessiondata0) AS label,
    search.table5_login AS insert_user,
    search.xnat_rfsessiondata_meta_data976 AS insert_date,
    search.xnat_experimentdata32 AS project,
    search.xnat_rfsessiondata_meta_data973 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_rfsessiondata0) search_1.xnat_rfsessiondata0,
            search_1.xnat_rfsessiondata_meta_data973,
            search_1.xnat_subjectassessordata19,
            search_1.xnat_experimentdata22,
            search_1.xnat_experimentdata38,
            search_1.table5_login,
            search_1.xnat_rfsessiondata_meta_data976,
            search_1.xnat_experimentdata32,
            search_1.xnat_demographicdata_demograp_xnat_demographicdata0,
            search_1.xnat_demographicdata_at_demographicdata_meta_data47,
            search_1.xnat_demographicdata_xnat_demographicdata1,
            search_1.xnat_demographicdata_xnat_demographicdata2,
            search_1.xnat_rfsessiondata_projects_projects
           FROM ( SELECT table2.id AS xnat_rfsessiondata0,
                    table4.status AS xnat_rfsessiondata_meta_data973,
                    table1.subject_id AS xnat_subjectassessordata19,
                    table2.date AS xnat_experimentdata22,
                    table2.label AS xnat_experimentdata38,
                    table5.login AS table5_login,
                    table4.insert_date AS xnat_rfsessiondata_meta_data976,
                    table2.project AS xnat_experimentdata32,
                    xnat_demographicdata.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                    xnat_demographicdata.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                    xnat_demographicdata.xnat_demographicdata1 AS xnat_demographicdata_xnat_demographicdata1,
                    xnat_demographicdata.xnat_demographicdata2 AS xnat_demographicdata_xnat_demographicdata2,
                    xnat_rfsessiondata_projects.projects AS xnat_rfsessiondata_projects_projects
                   FROM ((((((((public.xnat_rfsessiondata xnat_rfsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_rfsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))
                     LEFT JOIN public.xnat_rfsessiondata_meta_data table4 ON ((xnat_rfsessiondata.rfsessiondata_info = table4.meta_data_id)))
                     LEFT JOIN public.xdat_user table5 ON ((table4.insert_user_xdat_user_id = table5.xdat_user_id)))
                     LEFT JOIN public.xnat_rfsessiondata_projects xnat_rfsessiondata_projects ON (((table2.id)::text = (xnat_rfsessiondata_projects.id)::text)))
                     LEFT JOIN ( SELECT search_2.xnat_subjectdata3,
                            search_2.xnat_subjectdata_meta_data328,
                            search_2.xnat_rfsessiondata_sordata_ex_xnat_rfsessiondata0,
                            search_2.xnat_rfsessiondata_sordata__xnat_experimentdata22,
                            search_2.xnat_rfsessiondata_sor_xnat_subjectassessordata19,
                            search_2.xnat_demographicdata_demograp_xnat_demographicdata0,
                            search_2.xnat_demographicdata_at_demographicdata_meta_data47,
                            search_2.xnat_demographicdata_xnat_abstractdemographicdata27,
                            date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47)) AS xnat_subjectdata_xnat_demographicdata_diff
                           FROM ( SELECT xnat_subjectdata.id AS xnat_subjectdata3,
                                    table1_1.insert_date AS xnat_subjectdata_meta_data328,
                                    xnat_rfsessiondata_1.xnat_rfsessiondata0 AS xnat_rfsessiondata_sordata_ex_xnat_rfsessiondata0,
                                    xnat_rfsessiondata_1.xnat_experimentdata22 AS xnat_rfsessiondata_sordata__xnat_experimentdata22,
                                    xnat_rfsessiondata_1.xnat_subjectassessordata19 AS xnat_rfsessiondata_sor_xnat_subjectassessordata19,
                                    xnat_demographicdata_1.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                                    xnat_demographicdata_1.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                                    xnat_demographicdata_1.xnat_abstractdemographicdata27 AS xnat_demographicdata_xnat_abstractdemographicdata27
                                   FROM ((((public.xnat_subjectdata xnat_subjectdata
                                     LEFT JOIN public.xnat_subjectdata_meta_data table1_1 ON ((xnat_subjectdata.subjectdata_info = table1_1.meta_data_id)))
                                     LEFT JOIN ( SELECT table2_1.id AS xnat_rfsessiondata0,
    table2_1.date AS xnat_experimentdata22,
    table1_2.subject_id AS xnat_subjectassessordata19
   FROM (((public.xnat_rfsessiondata xnat_rfsessiondata_2
     LEFT JOIN public.xnat_imagesessiondata table0_1 ON (((xnat_rfsessiondata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_subjectassessordata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))
     LEFT JOIN public.xnat_experimentdata table2_1 ON (((table1_2.id)::text = (table2_1.id)::text)))) xnat_rfsessiondata_1 ON (((xnat_subjectdata.id)::text = (xnat_rfsessiondata_1.xnat_subjectassessordata19)::text)))
                                     LEFT JOIN ( SELECT xnat_subjectdata_1.id AS xnat_subjectdata3,
    table1_2.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata91,
    table2_1.insert_date AS xnat_subjectdata_meta_data328
   FROM ((public.xnat_subjectdata xnat_subjectdata_1
     LEFT JOIN public.xnat_abstractdemographicdata table1_2 ON ((xnat_subjectdata_1.demographics_xnat_abstractdemographicdata_id = table1_2.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_subjectdata_meta_data table2_1 ON ((xnat_subjectdata_1.subjectdata_info = table2_1.meta_data_id)))) map_xnat_demographicdata ON (((xnat_subjectdata.id)::text = (map_xnat_demographicdata.xnat_subjectdata3)::text)))
                                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
    table2_1.insert_date AS xnat_demographicdata_meta_data47,
    table0_1.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata27
   FROM ((public.xnat_demographicdata xnat_demographicdata_2
     LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_2.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_2.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata_1 ON ((map_xnat_demographicdata.xnat_abstractdemographicdata91 = xnat_demographicdata_1.xnat_abstractdemographicdata27)))) search_2
                          ORDER BY search_2.xnat_subjectdata3, search_2.xnat_rfsessiondata_sordata__xnat_experimentdata22 DESC, (date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47)))) map_xnat_subjectdata_xnat_demographicdata ON (((table2.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_rfsessiondata_sordata_ex_xnat_rfsessiondata0)::text)))
                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
                            table2_1.insert_date AS xnat_demographicdata_meta_data47,
                            xnat_demographicdata_1.dob AS xnat_demographicdata1,
                            xnat_demographicdata_1.yob AS xnat_demographicdata2
                           FROM ((public.xnat_demographicdata xnat_demographicdata_1
                             LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_1.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
                             LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_1.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata ON ((map_xnat_subjectdata_xnat_demographicdata.xnat_demographicdata_demograp_xnat_demographicdata0 = xnat_demographicdata.xnat_demographicdata0)))) search_1
          ORDER BY search_1.xnat_rfsessiondata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_rfsessiondata0
           FROM ( SELECT table2.id AS xnat_rfsessiondata0,
                    table2.date AS xnat_experimentdata22
                   FROM (((public.xnat_rfsessiondata xnat_rfsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_rfsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))) where_clause_1) where_clause ON (((where_clause.xnat_rfsessiondata0)::text = (search.xnat_rfsessiondata0)::text)))
  ORDER BY search.xnat_subjectassessordata19;


ALTER TABLE public.displayfields_xnat_rfsessiondata OWNER TO xnat;

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

CREATE TABLE public.xnat_rtimagescandata (
    xnat_imagescandata_id integer DEFAULT 0 NOT NULL,
    rtimagescandata_info integer
);


ALTER TABLE public.xnat_rtimagescandata OWNER TO xnat;

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

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

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

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


ALTER TABLE public.displayfields_xnat_rtimagescandata OWNER TO xnat;

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

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


ALTER TABLE public.xnat_rtsessiondata OWNER TO xnat;

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

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

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

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


ALTER TABLE public.xnat_rtsessiondata_projects OWNER TO xnat;

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

CREATE VIEW public.displayfields_xnat_rtsessiondata AS
 SELECT search.xnat_subjectassessordata19 AS subject_id,
    search.xnat_rtsessiondata0 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_rtsessiondata_projects_projects AS projects,
    COALESCE(search.xnat_experimentdata38, search.xnat_rtsessiondata0) AS label,
    search.table5_login AS insert_user,
    search.xnat_rtsessiondata_meta_data976 AS insert_date,
    search.xnat_experimentdata32 AS project,
    search.xnat_rtsessiondata_meta_data973 AS quarantine_status
   FROM (( SELECT DISTINCT ON (search_1.xnat_rtsessiondata0) search_1.xnat_rtsessiondata0,
            search_1.xnat_rtsessiondata_meta_data973,
            search_1.xnat_subjectassessordata19,
            search_1.xnat_experimentdata22,
            search_1.xnat_experimentdata38,
            search_1.table5_login,
            search_1.xnat_rtsessiondata_meta_data976,
            search_1.xnat_experimentdata32,
            search_1.xnat_demographicdata_demograp_xnat_demographicdata0,
            search_1.xnat_demographicdata_at_demographicdata_meta_data47,
            search_1.xnat_demographicdata_xnat_demographicdata1,
            search_1.xnat_demographicdata_xnat_demographicdata2,
            search_1.xnat_rtsessiondata_projects_projects
           FROM ( SELECT table2.id AS xnat_rtsessiondata0,
                    table4.status AS xnat_rtsessiondata_meta_data973,
                    table1.subject_id AS xnat_subjectassessordata19,
                    table2.date AS xnat_experimentdata22,
                    table2.label AS xnat_experimentdata38,
                    table5.login AS table5_login,
                    table4.insert_date AS xnat_rtsessiondata_meta_data976,
                    table2.project AS xnat_experimentdata32,
                    xnat_demographicdata.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                    xnat_demographicdata.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                    xnat_demographicdata.xnat_demographicdata1 AS xnat_demographicdata_xnat_demographicdata1,
                    xnat_demographicdata.xnat_demographicdata2 AS xnat_demographicdata_xnat_demographicdata2,
                    xnat_rtsessiondata_projects.projects AS xnat_rtsessiondata_projects_projects
                   FROM ((((((((public.xnat_rtsessiondata xnat_rtsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_rtsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))
                     LEFT JOIN public.xnat_rtsessiondata_meta_data table4 ON ((xnat_rtsessiondata.rtsessiondata_info = table4.meta_data_id)))
                     LEFT JOIN public.xdat_user table5 ON ((table4.insert_user_xdat_user_id = table5.xdat_user_id)))
                     LEFT JOIN public.xnat_rtsessiondata_projects xnat_rtsessiondata_projects ON (((table2.id)::text = (xnat_rtsessiondata_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_rtsessiondata_sordata_ex_xnat_rtsessiondata0,
                            search_2.xnat_rtsessiondata_sordata__xnat_experimentdata22,
                            search_2.xnat_rtsessiondata_sor_xnat_subjectassessordata19,
                            date_part('milliseconds'::text, (search_2.xnat_subjectdata_meta_data328 - search_2.xnat_demographicdata_at_demographicdata_meta_data47)) AS xnat_subjectdata_xnat_demographicdata_diff
                           FROM ( SELECT xnat_subjectdata.id AS xnat_subjectdata3,
                                    table1_1.insert_date AS xnat_subjectdata_meta_data328,
                                    xnat_demographicdata_1.xnat_demographicdata0 AS xnat_demographicdata_demograp_xnat_demographicdata0,
                                    xnat_demographicdata_1.xnat_demographicdata_meta_data47 AS xnat_demographicdata_at_demographicdata_meta_data47,
                                    xnat_demographicdata_1.xnat_abstractdemographicdata27 AS xnat_demographicdata_xnat_abstractdemographicdata27,
                                    xnat_rtsessiondata_1.xnat_rtsessiondata0 AS xnat_rtsessiondata_sordata_ex_xnat_rtsessiondata0,
                                    xnat_rtsessiondata_1.xnat_experimentdata22 AS xnat_rtsessiondata_sordata__xnat_experimentdata22,
                                    xnat_rtsessiondata_1.xnat_subjectassessordata19 AS xnat_rtsessiondata_sor_xnat_subjectassessordata19
                                   FROM ((((public.xnat_subjectdata xnat_subjectdata
                                     LEFT JOIN public.xnat_subjectdata_meta_data table1_1 ON ((xnat_subjectdata.subjectdata_info = table1_1.meta_data_id)))
                                     LEFT JOIN ( SELECT xnat_subjectdata_1.id AS xnat_subjectdata3,
    table1_2.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata91,
    table2_1.insert_date AS xnat_subjectdata_meta_data328
   FROM ((public.xnat_subjectdata xnat_subjectdata_1
     LEFT JOIN public.xnat_abstractdemographicdata table1_2 ON ((xnat_subjectdata_1.demographics_xnat_abstractdemographicdata_id = table1_2.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_subjectdata_meta_data table2_1 ON ((xnat_subjectdata_1.subjectdata_info = table2_1.meta_data_id)))) map_xnat_demographicdata ON (((xnat_subjectdata.id)::text = (map_xnat_demographicdata.xnat_subjectdata3)::text)))
                                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
    table2_1.insert_date AS xnat_demographicdata_meta_data47,
    table0_1.xnat_abstractdemographicdata_id AS xnat_abstractdemographicdata27
   FROM ((public.xnat_demographicdata xnat_demographicdata_2
     LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_2.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
     LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_2.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata_1 ON ((map_xnat_demographicdata.xnat_abstractdemographicdata91 = xnat_demographicdata_1.xnat_abstractdemographicdata27)))
                                     LEFT JOIN ( SELECT table2_1.id AS xnat_rtsessiondata0,
    table2_1.date AS xnat_experimentdata22,
    table1_2.subject_id AS xnat_subjectassessordata19
   FROM (((public.xnat_rtsessiondata xnat_rtsessiondata_2
     LEFT JOIN public.xnat_imagesessiondata table0_1 ON (((xnat_rtsessiondata_2.id)::text = (table0_1.id)::text)))
     LEFT JOIN public.xnat_subjectassessordata table1_2 ON (((table0_1.id)::text = (table1_2.id)::text)))
     LEFT JOIN public.xnat_experimentdata table2_1 ON (((table1_2.id)::text = (table2_1.id)::text)))) xnat_rtsessiondata_1 ON (((xnat_subjectdata.id)::text = (xnat_rtsessiondata_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_rtsessiondata_sordata__xnat_experimentdata22 DESC) map_xnat_subjectdata_xnat_demographicdata ON (((table2.id)::text = (map_xnat_subjectdata_xnat_demographicdata.xnat_rtsessiondata_sordata_ex_xnat_rtsessiondata0)::text)))
                     LEFT JOIN ( SELECT table0_1.xnat_abstractdemographicdata_id AS xnat_demographicdata0,
                            table2_1.insert_date AS xnat_demographicdata_meta_data47,
                            xnat_demographicdata_1.dob AS xnat_demographicdata1,
                            xnat_demographicdata_1.yob AS xnat_demographicdata2
                           FROM ((public.xnat_demographicdata xnat_demographicdata_1
                             LEFT JOIN public.xnat_abstractdemographicdata table0_1 ON ((xnat_demographicdata_1.xnat_abstractdemographicdata_id = table0_1.xnat_abstractdemographicdata_id)))
                             LEFT JOIN public.xnat_demographicdata_meta_data table2_1 ON ((xnat_demographicdata_1.demographicdata_info = table2_1.meta_data_id)))) xnat_demographicdata ON ((map_xnat_subjectdata_xnat_demographicdata.xnat_demographicdata_demograp_xnat_demographicdata0 = xnat_demographicdata.xnat_demographicdata0)))) search_1
          ORDER BY search_1.xnat_rtsessiondata0, search_1.xnat_demographicdata_at_demographicdata_meta_data47 DESC) search
     RIGHT JOIN ( SELECT DISTINCT where_clause_1.xnat_rtsessiondata0
           FROM ( SELECT table2.id AS xnat_rtsessiondata0,
                    table2.date AS xnat_experimentdata22
                   FROM (((public.xnat_rtsessiondata xnat_rtsessiondata
                     LEFT JOIN public.xnat_imagesessiondata table0 ON (((xnat_rtsessiondata.id)::text = (table0.id)::text)))
                     LEFT JOIN public.xnat_subjectassessordata table1 ON (((table0.id)::text = (table1.id)::text)))
                     LEFT JOIN public.xnat_experimentdata table2 ON (((table1.id)::text = (table2.id)::text)))) where_clause_1) where_clause ON (((where_clause.xnat_rtsessiondata0)::text = (search.xnat_rtsessiondata0)::text)))
  ORDER BY search.xnat_subjectassessordata19;


ALTER TABLE public.displayfields_xnat_rtsessiondata OWNER TO xnat;

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

CREATE TABLE public.xnat_scscandata (
    xnat_imagescandata_id integer DEFAULT 0 NOT NULL,
    scscandata_info integer
);


ALTER TABLE public.xnat_scscandata OWNER TO xnat;

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

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

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

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


ALTER TABLE public.displayfields_xnat_scscandata OWNER TO xnat;

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

CREATE TABLE public.xnat_segscandata (
    xnat_imagescandata_id integer DEFAULT 0 NOT NULL,
    segscandata_info integer
);


ALTER TABLE public.xnat_segscandata OWNER TO xnat;

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

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

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

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


ALTER TABLE public.displayfields_xnat_segscandata OWNER TO xnat;

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

CREATE TABLE public.xnat_smscandata (
    xnat_imagescandata_id integer DEFAULT 0 NOT NULL,
    smscandata_info integer
);


ALTER TABLE public.xnat_smscandata OWNER TO xnat;

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

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

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

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


ALTER TABLE public.displayfields_xnat_smscandata OWNER TO xnat;

--
