--
--


-- Started on 2025-08-28 16:56:52 CEST

SELECT pg_catalog.set_config('search_path', '', false);

--
-- TOC entry 2 (class 3079 OID 17386)
-- Name: intarray; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS intarray WITH SCHEMA public;


--
-- TOC entry 4452 (class 0 OID 0)
-- Dependencies: 2
-- Name: EXTENSION intarray; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION intarray IS 'functions, operators, and index support for 1-D arrays of integers';


--
-- TOC entry 418 (class 1255 OID 16389)
-- Name: f_create_login_role_permission(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.f_create_login_role_permission() RETURNS character varying
    LANGUAGE plpgsql
    AS $$ 


  	  	    DECLARE 


  	  			v_admin_id integer; 


  	  	    BEGIN 






  	  		 v_admin_id := 0; 






  	         insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


  	          (select v_admin_id as login_role_id,'VIEW' as ptype, 'VIEW_INSTITUTION'::text as nameid, 'View institution settings' as description ,true as def_value, true as value) as rp_data 


  	          where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 


  	         insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


  	          (select v_admin_id as login_role_id,'VIEW' as ptype, 'VIEW_STAFFROLE'::text as nameid, 'View staff role settings' as description ,true as def_value, true as value) as rp_data 


  	          where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 






  	         insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


  	          (select v_admin_id as login_role_id,'VIEW' as ptype, 'VIEW_LOGINROLE'::text as nameid, 'View login role settings' as description ,true as def_value, true as value) as rp_data 


  	          where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 






  	         insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


  	          (select v_admin_id as login_role_id,'VIEW' as ptype, 'VIEW_STAFFMEMBER'::text as nameid, 'View staff member settings' as description ,true as def_value, true as value) as rp_data 


  	          where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 






  	          insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


  	           (select v_admin_id as login_role_id,'VIEW' as ptype, 'VIEW_TAG'::text as nameid, 'View tag settings' as description ,true as def_value, true as value) as rp_data 


  	           where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 






  	         insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


  	          (select v_admin_id as login_role_id,'VIEW' as ptype, 'VIEW_WARNING'::text as nameid, 'View warning settings' as description ,true as def_value, true as value) as rp_data 


  	          where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 






  	          insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


  	           (select v_admin_id as login_role_id,'VIEW' as ptype, 'VIEW_DASHBOARD'::text as nameid, 'View dashboard frame' as description ,true as def_value, true as value) as rp_data 


  	           where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 






  	          insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


  	            (select v_admin_id as login_role_id,'VIEW' as ptype, 'VIEW_AUDIT'::text as nameid, 'View audit frame' as description ,true as def_value, true as value) as rp_data 


  	            where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 






  	          insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value,working_view,working_view_exist) select login_role_id,ptype,nameid,description,def_value,value,false,true from 


  	            (select v_admin_id as login_role_id,'VIEW' as ptype, 'VIEW_PROCEDURE'::text as nameid, 'View procedure frame' as description ,true as def_value, true as value) as rp_data 


  	            where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 






  	          insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


  	            (select v_admin_id as login_role_id,'VIEW' as ptype, 'VIEW_DEVICE'::text as nameid, 'View device frame' as description ,true as def_value, true as value,false,true) as rp_data 


  	            where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 






  	          insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value,working_view,working_view_exist) select login_role_id,ptype,nameid,description,def_value,value,false,true from 


  	              (select v_admin_id as login_role_id,'VIEW' as ptype, 'VIEW_EXAMLIST'::text as nameid, 'View exam list frame' as description ,true as def_value, true as value) as rp_data 


  	              where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 






  	          insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


  	              (select v_admin_id as login_role_id,'VIEW' as ptype, 'VIEW_STAFF'::text as nameid, 'View staff frame' as description ,true as def_value, true as value) as rp_data 


  	              where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 






  	          insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


  	              (select v_admin_id as login_role_id,'VIEW' as ptype, 'VIEW_DOSIMETRY'::text as nameid, 'View dosimetry frame' as description ,true as def_value, true as value) as rp_data 


  	              where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 






  	          insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


  	              (select v_admin_id as login_role_id,'VIEW' as ptype, 'VIEW_LEGALDOCUMENT'::text as nameid, 'View legal document frame' as description ,true as def_value, true as value) as rp_data 


  	              where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 






  	          insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


  	              (select v_admin_id as login_role_id,'VIEW' as ptype, 'VIEW_SCHEDULEDTASK'::text as nameid, 'View scheduled task frame' as description ,true as def_value, true as value) as rp_data 


  	              where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 


  	          insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


  	              (select v_admin_id as login_role_id,'VIEW' as ptype, 'VIEW_INCIDENTREPORTING'::text as nameid, 'View incident reporting frame' as description ,true as def_value, true as value) as rp_data 


  	              where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 






  	          insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


  	          (select v_admin_id as login_role_id,'VIEW' as ptype, 'VIEW_INSTITUTIONDOCUMENT'::text as nameid, 'View institution document frame' as description ,true as def_value, true as value) as rp_data 


  	          where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 




  	           insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


  	          (select v_admin_id as login_role_id,'VIEW' as ptype, 'VIEW_EXAMIDENT'::text as nameid, 'View the exam link frame' as description ,true as def_value, true as value) as rp_data 


  	          where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 




  	          insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


  	          (select v_admin_id as login_role_id,'VIEW' as ptype, 'VIEW_EXAMLINK'::text as nameid, 'View the exam link frame' as description ,true as def_value, true as value) as rp_data 


  	          where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 




              insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


              (select v_admin_id as login_role_id,'VIEW' as ptype, 'VIEW_STATISTIC'::text as nameid, 'View the statistic frame' as description ,true as def_value, true as value) as rp_data 


              where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 




  	         -- insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


  	         --  (select v_admin_id as login_role_id,'ACTION' as ptype, 'ACTION_ADD_INSTITUTION'::text as nameid,'Can add an institution' as description ,true as def_value, true as value) as rp_data 


  	         --  where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 


  	         -- insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


  	         --  (select v_admin_id as login_role_id,'ACTION' as ptype, 'ACTION_MODIFY_INSTITUTION'::text as nameid,'Can modify an institution' as description ,true as def_value, true as value) as rp_data 


  	         --  where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 


  	         -- insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value) select login_role_id,ptype,nameid,description,def_value,value from 


  	         --  (select v_admin_id as login_role_id,'ACTION' as ptype, 'ACTION_DELETE_INSTITUTION'::text as nameid,'Can delete an institution' as description ,true as def_value, true as value) as rp_data 


  	         --  where not exists (select * from login_role_permission where v_admin_id = login_role_permission.login_role_id and login_role_permission.nameid = rp_data.nameid); 










  	  	    -- update other role if necessary 


  	  	    insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value,working_view,working_view_exist) 


  	          select roleid,alluserpermission.ptype,alluserpermission.nameid,alluserpermission.description,alluserpermission.def_value,alluserpermission.def_value,alluserpermission.working_view,alluserpermission.working_view_exist from (select login_role.id as roleid,ptype,nameid,description,def_value,value,working_view,working_view_exist from 


  	  	  (select login_role_permission.ptype,nameid,description,def_value,value,working_view,working_view_exist from login_role_permission,login_role where login_role_permission.login_role_id = login_role.id and login_role.id = v_admin_id) as adminpermission,login_role) as alluserpermission 


  	  	   left join login_role_permission on login_role_permission.login_role_id = roleid and  login_role_permission.nameid = alluserpermission.nameid 


  	  	   where id is null; 






  	    		return true; 


  	  	    END 


  	  	$$;


ALTER FUNCTION public.f_create_login_role_permission() OWNER TO postgres;

--
-- TOC entry 393 (class 1255 OID 16390)
-- Name: f_staffmember_equals_staff(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.f_staffmember_equals_staff() RETURNS trigger
    LANGUAGE plpgsql
    AS $$ 
	begin  
		new.staff_member_id := new.staff_id; 
	 
	return new; 
	end; 
$$;


ALTER FUNCTION public.f_staffmember_equals_staff() OWNER TO postgres;

--
-- TOC entry 391 (class 1255 OID 16391)
-- Name: f_tag_link(integer); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.f_tag_link(in_exam_id integer) RETURNS character varying
    LANGUAGE plpgsql
    AS $$
  	    DECLARE
  			v_list varchar;
  	    BEGIN

  		 v_list := null;
		select STRING_AGG (tag_link.tag_id::text,',') into v_list from tag_link where type = 'examlist' and ext_id = in_exam_id;
		RETURN v_list;

  	    END
  	$$;


ALTER FUNCTION public.f_tag_link(in_exam_id integer) OWNER TO postgres;

--
-- TOC entry 438 (class 1255 OID 16392)
-- Name: trg_init_login_role_permission(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.trg_init_login_role_permission() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
  DECLARE
  v_admin_id integer;
  BEGIN

    v_admin_id := 0;
    insert into login_role_permission(login_role_id,ptype,nameid,description,def_value,value,working_view,working_view_exist)
    select NEW.id,ptype,nameid,description,def_value,def_value,working_view,working_view_exist from login_role_permission where login_role_id = v_admin_id;

    RETURN NEW;
  END;
  $$;


ALTER FUNCTION public.trg_init_login_role_permission() OWNER TO postgres;

--
-- TOC entry 388 (class 1255 OID 16393)
-- Name: trg_init_tag_department(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.trg_init_tag_department() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
  DECLARE
  tag_id integer;
  site_id integer;
  site_name varchar;
  BEGIN
    select institution.id,institution.name into site_id, site_name from institution,department where institution.id = department.inst_id and department.id = NEW.id;

    insert into tag(type,name,removed) values('OR',site_name || ' ' || NEW.name,false) RETURNING id INTO tag_id;
    insert into tag_link(type,ext_id,tag_id) values('department',NEW.id,tag_id);
    RETURN NEW;
  END;
  $$;


ALTER FUNCTION public.trg_init_tag_department() OWNER TO postgres;

--
-- TOC entry 437 (class 1255 OID 16394)
-- Name: trg_init_tag_department_update(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.trg_init_tag_department_update() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
  DECLARE
  tag_id integer;
  site_name varchar;
  site_id integer;
  BEGIN
    select institution.id,institution.name into site_id, site_name from institution,department where institution.id = department.inst_id and department.id = NEW.id;
    update tag set removed = NEW.removed, name = site_name || ' ' || NEW.name from tag_link where tag_link.type = 'department' and tag_link.ext_id = NEW.id and tag_link.tag_id = tag.id;
    RETURN NEW;
  END;
  $$;


ALTER FUNCTION public.trg_init_tag_department_update() OWNER TO postgres;

--
-- TOC entry 432 (class 1255 OID 16395)
-- Name: trg_init_tag_institution(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.trg_init_tag_institution() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
  DECLARE
  tag_id integer;
  BEGIN
    insert into tag(type,name,removed) values('OR',NEW.name,false) RETURNING id INTO tag_id;
    insert into tag_link(type,ext_id,tag_id) values('institution',NEW.id,tag_id);
    RETURN NEW;
  END;
  $$;


ALTER FUNCTION public.trg_init_tag_institution() OWNER TO postgres;

--
-- TOC entry 451 (class 1255 OID 16396)
-- Name: trg_init_tag_institution_update(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION public.trg_init_tag_institution_update() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
  DECLARE
  tag_id integer;
  BEGIN
    update tag set removed = NEW.removed, name = NEW.name from tag_link where tag_link.type = 'institution' and tag_link.ext_id = NEW.id and tag_link.tag_id = tag.id;
    RETURN NEW;
  END;
  $$;


ALTER FUNCTION public.trg_init_tag_institution_update() OWNER TO postgres;



--
-- TOC entry 216 (class 1259 OID 16397)
-- Name: action; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.action (
    id integer NOT NULL,
    description character varying,
    status_id integer,
    origine character varying,
    deadline timestamp with time zone,
    enddate timestamp with time zone,
    begdate timestamp with time zone NOT NULL,
    personincharge integer,
    removed boolean DEFAULT false,
    dep_id integer DEFAULT '-1'::integer,
    comment character varying
);


ALTER TABLE public.action OWNER TO postgres;

--
-- TOC entry 217 (class 1259 OID 16404)
-- Name: action_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.action_id_seq OWNER TO postgres;

--
-- TOC entry 4453 (class 0 OID 0)
-- Dependencies: 217
-- Name: action_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.action_id_seq OWNED BY public.action.id;


--
-- TOC entry 218 (class 1259 OID 16405)
-- Name: action_link; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.action_link (
    id integer NOT NULL,
    action_id integer NOT NULL,
    ext_id integer NOT NULL,
    scope character varying NOT NULL
);


ALTER TABLE public.action_link OWNER TO postgres;

--
-- TOC entry 219 (class 1259 OID 16410)
-- Name: action_link_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.action_link_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.action_link_id_seq OWNER TO postgres;

--
-- TOC entry 4454 (class 0 OID 0)
-- Dependencies: 219
-- Name: action_link_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.action_link_id_seq OWNED BY public.action_link.id;


--
-- TOC entry 220 (class 1259 OID 16411)
-- Name: action_status_link; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.action_status_link (
    staff_member_id integer NOT NULL,
    document_id integer NOT NULL,
    last_opened timestamp without time zone,
    action_at timestamp without time zone,
    action_id integer,
    date timestamp without time zone,
    last_reminder timestamp without time zone
);


ALTER TABLE public.action_status_link OWNER TO postgres;

--
-- TOC entry 221 (class 1259 OID 16414)
-- Name: afcnsend; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.afcnsend (
    id integer NOT NULL,
    inst_id integer,
    dep_id integer,
    device_id integer,
    title character varying,
    senddate timestamp with time zone NOT NULL,
    sender integer,
    comment character varying,
    removed boolean DEFAULT false,
    status_id integer
);


ALTER TABLE public.afcnsend OWNER TO postgres;

--
-- TOC entry 222 (class 1259 OID 16420)
-- Name: afcnsend_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.afcnsend_id_seq OWNER TO postgres;

--
-- TOC entry 4455 (class 0 OID 0)
-- Dependencies: 222
-- Name: afcnsend_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.afcnsend_id_seq OWNED BY public.afcnsend.id;


--
-- TOC entry 223 (class 1259 OID 16421)
-- Name: agelist; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.agelist (
    id integer NOT NULL,
    label character varying NOT NULL
);


ALTER TABLE public.agelist OWNER TO postgres;

--
-- TOC entry 224 (class 1259 OID 16426)
-- Name: agelist_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.agelist_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.agelist_id_seq OWNER TO postgres;

--
-- TOC entry 4456 (class 0 OID 0)
-- Dependencies: 224
-- Name: agelist_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.agelist_id_seq OWNED BY public.agelist.id;


--
-- TOC entry 225 (class 1259 OID 16427)
-- Name: audit; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.audit (
    id integer NOT NULL,
    inst_id integer DEFAULT '-1'::integer,
    dep_id integer DEFAULT '-1'::integer,
    date timestamp with time zone,
    origine integer,
    title character varying,
    comment character varying,
    status_id integer,
    personincharge integer,
    removed boolean DEFAULT false,
    type integer DEFAULT 2 NOT NULL,
    start_date timestamp(0) with time zone,
    end_date timestamp(0) with time zone
);


ALTER TABLE public.audit OWNER TO postgres;

--
-- TOC entry 226 (class 1259 OID 16436)
-- Name: audit_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.audit_id_seq OWNER TO postgres;

--
-- TOC entry 4457 (class 0 OID 0)
-- Dependencies: 226
-- Name: audit_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.audit_id_seq OWNED BY public.audit.id;


--
-- TOC entry 227 (class 1259 OID 16437)
-- Name: audit_record; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.audit_record (
    id integer NOT NULL,
    audit_id integer NOT NULL,
    quaad_point_id integer NOT NULL,
    validated boolean DEFAULT false NOT NULL
);


ALTER TABLE public.audit_record OWNER TO postgres;

--
-- TOC entry 228 (class 1259 OID 16441)
-- Name: audit_record_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.audit_record_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.audit_record_id_seq OWNER TO postgres;

--
-- TOC entry 4458 (class 0 OID 0)
-- Dependencies: 228
-- Name: audit_record_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.audit_record_id_seq OWNED BY public.audit_record.id;


--
-- TOC entry 229 (class 1259 OID 16442)
-- Name: audit_recordprocedure; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.audit_recordprocedure (
    id integer NOT NULL,
    audit_record_id integer NOT NULL,
    procedure_id integer NOT NULL,
    doc_id integer NOT NULL,
    remark text,
    status boolean DEFAULT false NOT NULL,
    forcedstatus boolean
);


ALTER TABLE public.audit_recordprocedure OWNER TO postgres;

--
-- TOC entry 230 (class 1259 OID 16448)
-- Name: audit_recordprocedure_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.audit_recordprocedure_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.audit_recordprocedure_id_seq OWNER TO postgres;

--
-- TOC entry 4459 (class 0 OID 0)
-- Dependencies: 230
-- Name: audit_recordprocedure_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.audit_recordprocedure_id_seq OWNED BY public.audit_recordprocedure.id;


--
-- TOC entry 231 (class 1259 OID 16449)
-- Name: audit_subrecord; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.audit_subrecord (
    id integer NOT NULL,
    audit_record_id integer NOT NULL,
    quaadpoint_tag_id integer NOT NULL,
    scope_id integer NOT NULL,
    scope2_id integer,
    force_doctext text,
    force_docid integer,
    remark text,
    status boolean DEFAULT false NOT NULL,
    forcedstatus boolean,
    doc_id integer NOT NULL,
    force_result character varying
);


ALTER TABLE public.audit_subrecord OWNER TO postgres;

--
-- TOC entry 232 (class 1259 OID 16455)
-- Name: audit_subrecord_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.audit_subrecord_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.audit_subrecord_id_seq OWNER TO postgres;

--
-- TOC entry 4460 (class 0 OID 0)
-- Dependencies: 232
-- Name: audit_subrecord_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.audit_subrecord_id_seq OWNED BY public.audit_subrecord.id;


--
-- TOC entry 233 (class 1259 OID 16456)
-- Name: audit_type; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.audit_type (
    id integer NOT NULL,
    name character varying NOT NULL,
    removed character varying DEFAULT false NOT NULL,
    maintype character varying
);


ALTER TABLE public.audit_type OWNER TO postgres;

--
-- TOC entry 234 (class 1259 OID 16462)
-- Name: audit_type_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.audit_type_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.audit_type_id_seq OWNER TO postgres;

--
-- TOC entry 4461 (class 0 OID 0)
-- Dependencies: 234
-- Name: audit_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.audit_type_id_seq OWNED BY public.audit_type.id;


--
-- TOC entry 235 (class 1259 OID 16463)
-- Name: civilitylist; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.civilitylist (
    id integer NOT NULL,
    name character varying NOT NULL
);


ALTER TABLE public.civilitylist OWNER TO postgres;

--
-- TOC entry 236 (class 1259 OID 16468)
-- Name: civilitylist_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.civilitylist_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.civilitylist_id_seq OWNER TO postgres;

--
-- TOC entry 4462 (class 0 OID 0)
-- Dependencies: 236
-- Name: civilitylist_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.civilitylist_id_seq OWNED BY public.civilitylist.id;


--
-- TOC entry 237 (class 1259 OID 16469)
-- Name: default_action_needed; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.default_action_needed (
    document_type character varying,
    staff_role_id integer,
    department_id integer,
    id integer NOT NULL,
    action integer NOT NULL
);


ALTER TABLE public.default_action_needed OWNER TO postgres;

--
-- TOC entry 238 (class 1259 OID 16474)
-- Name: default_read_needed_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

ALTER TABLE public.default_action_needed ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY (
    SEQUENCE NAME public.default_read_needed_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 239 (class 1259 OID 16475)
-- Name: department; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.department (
    id integer NOT NULL,
    name character varying NOT NULL,
    inst_id integer,
    removed boolean DEFAULT false
);


ALTER TABLE public.department OWNER TO postgres;

--
-- TOC entry 240 (class 1259 OID 16481)
-- Name: department_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.department_id_seq OWNER TO postgres;

--
-- TOC entry 4463 (class 0 OID 0)
-- Dependencies: 240
-- Name: department_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.department_id_seq OWNED BY public.department.id;


--
-- TOC entry 241 (class 1259 OID 16482)
-- Name: device; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.device (
    id integer NOT NULL,
    name character varying,
    brand character varying,
    model character varying,
    serialnumber character varying,
    removed boolean DEFAULT false,
    ris_name character varying,
    pacs_name character varying,
    dacs_name character varying,
    modalitytype character varying DEFAULT 'RX'::character varying NOT NULL,
    photo bytea,
    type integer
);


ALTER TABLE public.device OWNER TO postgres;

--
-- TOC entry 242 (class 1259 OID 16489)
-- Name: device_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.device_id_seq OWNER TO postgres;

--
-- TOC entry 4464 (class 0 OID 0)
-- Dependencies: 242
-- Name: device_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.device_id_seq OWNED BY public.device.id;


--
-- TOC entry 243 (class 1259 OID 16490)
-- Name: device_inspection; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.device_inspection (
    id integer NOT NULL,
    device_id integer NOT NULL,
    inspection_date timestamp with time zone,
    planned_date timestamp with time zone,
    result integer,
    comment character varying,
    type character varying,
    status_id integer,
    removed boolean DEFAULT false
);


ALTER TABLE public.device_inspection OWNER TO postgres;

--
-- TOC entry 244 (class 1259 OID 16496)
-- Name: device_inspection_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.device_inspection_id_seq OWNER TO postgres;

--
-- TOC entry 4465 (class 0 OID 0)
-- Dependencies: 244
-- Name: device_inspection_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.device_inspection_id_seq OWNED BY public.device_inspection.id;


--
-- TOC entry 245 (class 1259 OID 16497)
-- Name: device_installation; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.device_installation (
    id integer NOT NULL,
    device_id integer NOT NULL,
    dep_id integer NOT NULL,
    installdate timestamp with time zone NOT NULL,
    removeddate timestamp with time zone,
    removed boolean DEFAULT false,
    installedby character varying DEFAULT ''::character varying,
    inchargeof character varying DEFAULT ''::character varying,
    comment character varying DEFAULT ''::character varying
);


ALTER TABLE public.device_installation OWNER TO postgres;

--
-- TOC entry 246 (class 1259 OID 16506)
-- Name: device_installation_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.device_installation_id_seq OWNER TO postgres;

--
-- TOC entry 4466 (class 0 OID 0)
-- Dependencies: 246
-- Name: device_installation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.device_installation_id_seq OWNED BY public.device_installation.id;


--
-- TOC entry 247 (class 1259 OID 16507)
-- Name: device_maintenance; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.device_maintenance (
    id integer NOT NULL,
    device_id integer NOT NULL,
    maintenance_date timestamp with time zone,
    planned_date timestamp with time zone,
    result integer,
    comment character varying,
    type character varying,
    status_id integer,
    removed boolean DEFAULT false
);


ALTER TABLE public.device_maintenance OWNER TO postgres;

--
-- TOC entry 248 (class 1259 OID 16513)
-- Name: device_maintenance_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.device_maintenance_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.device_maintenance_id_seq OWNER TO postgres;

--
-- TOC entry 4467 (class 0 OID 0)
-- Dependencies: 248
-- Name: device_maintenance_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.device_maintenance_id_seq OWNED BY public.device_maintenance.id;


--
-- TOC entry 352 (class 1259 OID 17521)
-- Name: devicetypelist; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.devicetypelist (
    id integer NOT NULL,
    name character varying
);


ALTER TABLE public.devicetypelist OWNER TO postgres;

--
-- TOC entry 353 (class 1259 OID 17524)
-- Name: devicetypelist_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.devicetypelist_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.devicetypelist_id_seq OWNER TO postgres;

--
-- TOC entry 4468 (class 0 OID 0)
-- Dependencies: 353
-- Name: devicetypelist_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.devicetypelist_id_seq OWNED BY public.devicetypelist.id;


--
-- TOC entry 249 (class 1259 OID 16514)
-- Name: document; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.document (
    id integer NOT NULL,
    file character varying,
    realfilename character varying,
    folder character varying NOT NULL,
    type character varying DEFAULT 'PDF'::character varying NOT NULL,
    creation_date timestamp with time zone DEFAULT now() NOT NULL,
    removed boolean DEFAULT false,
    revision integer DEFAULT 1 NOT NULL,
    label character varying DEFAULT ''::character varying,
    comment character varying DEFAULT ''::character varying,
    uploadedby integer NOT NULL,
    doc_master_id integer NOT NULL,
    sourcefile character varying,
    sourcerealfilename character varying,
    extern_link character varying,
    upload_date timestamp with time zone DEFAULT now() NOT NULL,
    valid_until_date timestamp with time zone DEFAULT to_timestamp('29991231235959'::text, 'YYYYMMDDHH24MISS'::text) NOT NULL,
    modification_date timestamp with time zone DEFAULT now()
);


ALTER TABLE public.document OWNER TO postgres;

--
-- TOC entry 250 (class 1259 OID 16528)
-- Name: document_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.document_id_seq OWNER TO postgres;

--
-- TOC entry 4469 (class 0 OID 0)
-- Dependencies: 250
-- Name: document_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.document_id_seq OWNED BY public.document.id;


--
-- TOC entry 251 (class 1259 OID 16529)
-- Name: document_link; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.document_link (
    id integer NOT NULL,
    type character varying NOT NULL,
    ext_id integer,
    doc_id integer
);


ALTER TABLE public.document_link OWNER TO postgres;

--
-- TOC entry 4470 (class 0 OID 0)
-- Dependencies: 251
-- Name: COLUMN document_link.type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.document_link.type IS 'doit être le nom de la table à lier';


--
-- TOC entry 252 (class 1259 OID 16534)
-- Name: document_link_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.document_link_id_seq OWNER TO postgres;

--
-- TOC entry 4471 (class 0 OID 0)
-- Dependencies: 252
-- Name: document_link_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.document_link_id_seq OWNED BY public.document_link.id;


--
-- TOC entry 253 (class 1259 OID 16535)
-- Name: document_master; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.document_master (
    id integer NOT NULL,
    name character varying NOT NULL,
    removed boolean DEFAULT false
);


ALTER TABLE public.document_master OWNER TO postgres;

--
-- TOC entry 254 (class 1259 OID 16541)
-- Name: document_master_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.document_master_id_seq OWNER TO postgres;

--
-- TOC entry 4472 (class 0 OID 0)
-- Dependencies: 254
-- Name: document_master_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.document_master_id_seq OWNED BY public.document_master.id;


--
-- TOC entry 255 (class 1259 OID 16542)
-- Name: documentstatus; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.documentstatus (
    id integer NOT NULL,
    begdate timestamp with time zone NOT NULL,
    enddate timestamp with time zone DEFAULT '2999-12-31 00:00:00+01'::timestamp with time zone NOT NULL,
    doc_id integer NOT NULL,
    status_id integer NOT NULL
);


ALTER TABLE public.documentstatus OWNER TO postgres;

--
-- TOC entry 256 (class 1259 OID 16546)
-- Name: documentstatus_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.documentstatus_id_seq OWNER TO postgres;

--
-- TOC entry 4473 (class 0 OID 0)
-- Dependencies: 256
-- Name: documentstatus_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.documentstatus_id_seq OWNED BY public.documentstatus.id;


--
-- TOC entry 257 (class 1259 OID 16547)
-- Name: documenttypelist; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.documenttypelist (
    id integer NOT NULL,
    name character varying NOT NULL
);


ALTER TABLE public.documenttypelist OWNER TO postgres;

--
-- TOC entry 258 (class 1259 OID 16552)
-- Name: documenttypelist_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.documenttypelist_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.documenttypelist_id_seq OWNER TO postgres;

--
-- TOC entry 4474 (class 0 OID 0)
-- Dependencies: 258
-- Name: documenttypelist_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.documenttypelist_id_seq OWNED BY public.documenttypelist.id;


--
-- TOC entry 259 (class 1259 OID 16553)
-- Name: enum_listvalue; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.enum_listvalue (
    scope character varying,
    value integer,
    name character varying,
    lang character varying
);


ALTER TABLE public.enum_listvalue OWNER TO postgres;

--
-- TOC entry 260 (class 1259 OID 16558)
-- Name: examident; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.examident (
    id integer NOT NULL,
    name character varying NOT NULL,
    description character varying NOT NULL,
    removed boolean DEFAULT false
);


ALTER TABLE public.examident OWNER TO postgres;

--
-- TOC entry 261 (class 1259 OID 16564)
-- Name: examident_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.examident_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.examident_id_seq OWNER TO postgres;

--
-- TOC entry 4475 (class 0 OID 0)
-- Dependencies: 261
-- Name: examident_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.examident_id_seq OWNED BY public.examident.id;


--
-- TOC entry 262 (class 1259 OID 16565)
-- Name: examident_link; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.examident_link (
    exam_id integer,
    examident_id integer
);


ALTER TABLE public.examident_link OWNER TO postgres;

--
-- TOC entry 263 (class 1259 OID 16568)
-- Name: examlist; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.examlist (
    id integer NOT NULL,
    modality character varying,
    nameid character varying,
    description character varying,
    removed boolean DEFAULT false
);


ALTER TABLE public.examlist OWNER TO postgres;

--
-- TOC entry 264 (class 1259 OID 16574)
-- Name: examlist_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.examlist_id_seq OWNER TO postgres;

--
-- TOC entry 4476 (class 0 OID 0)
-- Dependencies: 264
-- Name: examlist_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.examlist_id_seq OWNED BY public.examlist.id;


--
-- TOC entry 265 (class 1259 OID 16575)
-- Name: examwarning; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.examwarning (
    id integer NOT NULL,
    title character varying,
    description character varying,
    removed boolean DEFAULT false,
    sex_id integer,
    age_id integer
);


ALTER TABLE public.examwarning OWNER TO postgres;

--
-- TOC entry 266 (class 1259 OID 16581)
-- Name: examwarning_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.examwarning_id_seq OWNER TO postgres;

--
-- TOC entry 4477 (class 0 OID 0)
-- Dependencies: 266
-- Name: examwarning_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.examwarning_id_seq OWNED BY public.examwarning.id;


--
-- TOC entry 267 (class 1259 OID 16582)
-- Name: examwarning_link; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.examwarning_link (
    exam_id integer,
    examwarning_id integer
);


ALTER TABLE public.examwarning_link OWNER TO postgres;

--
-- TOC entry 268 (class 1259 OID 16585)
-- Name: external_link; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.external_link (
    id integer NOT NULL,
    table_name character varying NOT NULL,
    table_id bigint NOT NULL,
    ext_id character varying NOT NULL,
    ext_src integer NOT NULL
);


ALTER TABLE public.external_link OWNER TO postgres;

--
-- TOC entry 269 (class 1259 OID 16590)
-- Name: external_link_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.external_link_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.external_link_id_seq OWNER TO postgres;

--
-- TOC entry 4478 (class 0 OID 0)
-- Dependencies: 269
-- Name: external_link_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.external_link_id_seq OWNED BY public.external_link.id;


--
-- TOC entry 270 (class 1259 OID 16591)
-- Name: external_src; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.external_src (
    id integer NOT NULL,
    src_name character varying NOT NULL
);


ALTER TABLE public.external_src OWNER TO postgres;

--
-- TOC entry 271 (class 1259 OID 16596)
-- Name: external_src_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.external_src_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.external_src_id_seq OWNER TO postgres;

--
-- TOC entry 4479 (class 0 OID 0)
-- Dependencies: 271
-- Name: external_src_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.external_src_id_seq OWNED BY public.external_src.id;


--
-- TOC entry 272 (class 1259 OID 16597)
-- Name: institution; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.institution (
    id integer NOT NULL,
    name character varying NOT NULL,
    removed boolean DEFAULT false
);


ALTER TABLE public.institution OWNER TO postgres;

--
-- TOC entry 273 (class 1259 OID 16603)
-- Name: institution_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.institution_id_seq OWNER TO postgres;

--
-- TOC entry 4480 (class 0 OID 0)
-- Dependencies: 273
-- Name: institution_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.institution_id_seq OWNED BY public.institution.id;


--
-- TOC entry 274 (class 1259 OID 16604)
-- Name: legaldocument; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.legaldocument (
    id integer NOT NULL,
    name character varying,
    type character varying,
    comment character varying,
    removed boolean DEFAULT false
);


ALTER TABLE public.legaldocument OWNER TO postgres;

--
-- TOC entry 275 (class 1259 OID 16610)
-- Name: legaldocument_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.legaldocument_id_seq OWNER TO postgres;

--
-- TOC entry 4481 (class 0 OID 0)
-- Dependencies: 275
-- Name: legaldocument_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.legaldocument_id_seq OWNED BY public.legaldocument.id;


--
-- TOC entry 276 (class 1259 OID 16611)
-- Name: link_quaad_tag; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.link_quaad_tag (
    id_quaadpoint integer NOT NULL,
    id_tag integer NOT NULL
);


ALTER TABLE public.link_quaad_tag OWNER TO postgres;

--
-- TOC entry 277 (class 1259 OID 16614)
-- Name: link_scope_view; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.link_scope_view (
    scope character varying NOT NULL,
    view character varying
);


ALTER TABLE public.link_scope_view OWNER TO postgres;

--
-- TOC entry 278 (class 1259 OID 16619)
-- Name: login_role; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.login_role (
    id integer NOT NULL,
    name character varying,
    removed boolean DEFAULT false
);


ALTER TABLE public.login_role OWNER TO postgres;

--
-- TOC entry 279 (class 1259 OID 16625)
-- Name: login_role_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.login_role_id_seq OWNER TO postgres;

--
-- TOC entry 4482 (class 0 OID 0)
-- Dependencies: 279
-- Name: login_role_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.login_role_id_seq OWNED BY public.login_role.id;


--
-- TOC entry 280 (class 1259 OID 16626)
-- Name: login_role_permission; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.login_role_permission (
    id integer NOT NULL,
    ptype character varying DEFAULT ''::character varying,
    nameid character varying NOT NULL,
    description character varying DEFAULT ''::character varying,
    def_value boolean DEFAULT false,
    value boolean DEFAULT false,
    working_view boolean DEFAULT false,
    working_view_exist boolean DEFAULT false,
    login_role_id integer NOT NULL
);


ALTER TABLE public.login_role_permission OWNER TO postgres;

--
-- TOC entry 281 (class 1259 OID 16637)
-- Name: login_role_permission_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.login_role_permission_id_seq OWNER TO postgres;

--
-- TOC entry 4483 (class 0 OID 0)
-- Dependencies: 281
-- Name: login_role_permission_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.login_role_permission_id_seq OWNED BY public.login_role_permission.id;


--
-- TOC entry 282 (class 1259 OID 16638)
-- Name: procedure; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.procedure (
    id integer NOT NULL,
    name_en character varying,
    name_fr character varying,
    name_nl character varying,
    comment character varying,
    removed boolean DEFAULT false,
    type integer
);


ALTER TABLE public.procedure OWNER TO postgres;

--
-- TOC entry 283 (class 1259 OID 16644)
-- Name: procedure_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.procedure_id_seq OWNER TO postgres;

--
-- TOC entry 4484 (class 0 OID 0)
-- Dependencies: 283
-- Name: procedure_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.procedure_id_seq OWNED BY public.procedure.id;


--
-- TOC entry 284 (class 1259 OID 16645)
-- Name: quaad_description; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.quaad_description (
    id integer NOT NULL,
    id_quaadpoint integer NOT NULL,
    language character varying NOT NULL,
    description character varying,
    description_summary character varying
);


ALTER TABLE public.quaad_description OWNER TO postgres;

--
-- TOC entry 285 (class 1259 OID 16650)
-- Name: quaad_description_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.quaad_description_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.quaad_description_id_seq OWNER TO postgres;

--
-- TOC entry 4485 (class 0 OID 0)
-- Dependencies: 285
-- Name: quaad_description_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.quaad_description_id_seq OWNED BY public.quaad_description.id;


--
-- TOC entry 286 (class 1259 OID 16651)
-- Name: quaad_nameinscope; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.quaad_nameinscope (
    scope_name character varying NOT NULL,
    name character varying NOT NULL
);


ALTER TABLE public.quaad_nameinscope OWNER TO postgres;

--
-- TOC entry 287 (class 1259 OID 16656)
-- Name: quaad_point; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.quaad_point (
    id integer NOT NULL,
    level1 integer DEFAULT '-1'::integer NOT NULL,
    level2 integer DEFAULT '-1'::integer NOT NULL,
    level3 integer DEFAULT '-1'::integer NOT NULL,
    level4 integer DEFAULT '-1'::integer NOT NULL,
    level5 integer DEFAULT '-1'::integer NOT NULL,
    inlevelorder integer DEFAULT 1 NOT NULL,
    istitle boolean DEFAULT false,
    datebeg date,
    dateend date,
    quaadversion integer
);


ALTER TABLE public.quaad_point OWNER TO postgres;

--
-- TOC entry 288 (class 1259 OID 16666)
-- Name: quaad_point_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.quaad_point_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.quaad_point_id_seq OWNER TO postgres;

--
-- TOC entry 4486 (class 0 OID 0)
-- Dependencies: 288
-- Name: quaad_point_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.quaad_point_id_seq OWNED BY public.quaad_point.id;


--
-- TOC entry 289 (class 1259 OID 16667)
-- Name: quaadpoint_tag; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.quaadpoint_tag (
    id integer NOT NULL,
    procedure_needed character varying,
    documents_needed integer DEFAULT 0 NOT NULL,
    scope character varying NOT NULL,
    additional_param character varying,
    period integer DEFAULT '-1'::integer NOT NULL,
    scope2 character varying,
    where_notagid character varying DEFAULT false NOT NULL,
    isglobalscope boolean DEFAULT false NOT NULL,
    document_scope character varying DEFAULT 'institution'::character varying NOT NULL
);


ALTER TABLE public.quaadpoint_tag OWNER TO postgres;

--
-- TOC entry 290 (class 1259 OID 16677)
-- Name: quaadpoint_tag_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.quaadpoint_tag_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.quaadpoint_tag_id_seq OWNER TO postgres;

--
-- TOC entry 4487 (class 0 OID 0)
-- Dependencies: 290
-- Name: quaadpoint_tag_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.quaadpoint_tag_id_seq OWNED BY public.quaadpoint_tag.id;


--
-- TOC entry 291 (class 1259 OID 16678)
-- Name: quaadpoint_tag_name; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.quaadpoint_tag_name (
    id integer NOT NULL,
    name character varying NOT NULL,
    language character varying DEFAULT 'FR'::character varying NOT NULL,
    id_quaadpoint_tag integer NOT NULL
);


ALTER TABLE public.quaadpoint_tag_name OWNER TO postgres;

--
-- TOC entry 292 (class 1259 OID 16684)
-- Name: quaadpoint_tag_name_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.quaadpoint_tag_name_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.quaadpoint_tag_name_id_seq OWNER TO postgres;

--
-- TOC entry 4488 (class 0 OID 0)
-- Dependencies: 292
-- Name: quaadpoint_tag_name_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.quaadpoint_tag_name_id_seq OWNED BY public.quaadpoint_tag_name.id;


--
-- TOC entry 293 (class 1259 OID 16685)
-- Name: quaadtag_doc_link; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.quaadtag_doc_link (
    id_quaadtag integer NOT NULL,
    id_doclink integer NOT NULL
);


ALTER TABLE public.quaadtag_doc_link OWNER TO postgres;

--
-- TOC entry 294 (class 1259 OID 16688)
-- Name: report; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.report (
    id integer NOT NULL,
    severity integer DEFAULT 0,
    title character varying,
    reportdate timestamp with time zone NOT NULL,
    closeddate timestamp with time zone,
    reporter integer,
    comment character varying DEFAULT ''::character varying,
    statuscomment character varying DEFAULT ''::character varying,
    status_id integer,
    dep_id integer,
    removed boolean DEFAULT false
);


ALTER TABLE public.report OWNER TO postgres;

--
-- TOC entry 295 (class 1259 OID 16697)
-- Name: report_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.report_id_seq OWNER TO postgres;

--
-- TOC entry 4489 (class 0 OID 0)
-- Dependencies: 295
-- Name: report_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.report_id_seq OWNED BY public.report.id;


--
-- TOC entry 296 (class 1259 OID 16698)
-- Name: sequpdate_state; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.sequpdate_state (
    updateid character varying NOT NULL,
    uid double precision
);


ALTER TABLE public.sequpdate_state OWNER TO postgres;

--
-- TOC entry 297 (class 1259 OID 16703)
-- Name: sexlist; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.sexlist (
    id integer NOT NULL,
    label character varying NOT NULL
);


ALTER TABLE public.sexlist OWNER TO postgres;

--
-- TOC entry 298 (class 1259 OID 16708)
-- Name: sexlist_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.sexlist_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.sexlist_id_seq OWNER TO postgres;

--
-- TOC entry 4490 (class 0 OID 0)
-- Dependencies: 298
-- Name: sexlist_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.sexlist_id_seq OWNED BY public.sexlist.id;


--
-- TOC entry 299 (class 1259 OID 16709)
-- Name: staff_formation; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.staff_formation (
    id integer NOT NULL,
    staff_id integer NOT NULL,
    formation_date timestamp with time zone,
    planned_date timestamp with time zone,
    title character varying,
    comment character varying,
    type character varying,
    status_id integer,
    removed boolean DEFAULT false,
    staff_member_id integer
);


ALTER TABLE public.staff_formation OWNER TO postgres;

--
-- TOC entry 300 (class 1259 OID 16715)
-- Name: staff_formation_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.staff_formation_id_seq OWNER TO postgres;

--
-- TOC entry 4491 (class 0 OID 0)
-- Dependencies: 300
-- Name: staff_formation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.staff_formation_id_seq OWNED BY public.staff_formation.id;


--
-- TOC entry 301 (class 1259 OID 16716)
-- Name: staff_job; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.staff_job (
    id integer NOT NULL,
    dep_id integer NOT NULL,
    staff_id integer NOT NULL,
    begdate timestamp with time zone NOT NULL,
    enddate timestamp with time zone DEFAULT '2999-12-31 00:00:00+01'::timestamp with time zone NOT NULL,
    staff_role_id integer NOT NULL,
    active boolean DEFAULT false,
    removed boolean DEFAULT false
);


ALTER TABLE public.staff_job OWNER TO postgres;

--
-- TOC entry 302 (class 1259 OID 16722)
-- Name: staff_job_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.staff_job_id_seq OWNER TO postgres;

--
-- TOC entry 4492 (class 0 OID 0)
-- Dependencies: 302
-- Name: staff_job_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.staff_job_id_seq OWNED BY public.staff_job.id;


--
-- TOC entry 303 (class 1259 OID 16723)
-- Name: staff_member; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.staff_member (
    id integer NOT NULL,
    lastname character varying,
    firstname character varying,
    removed boolean DEFAULT false,
    login character varying NOT NULL,
    password character varying NOT NULL,
    login_role_id integer,
    active boolean DEFAULT false,
    ris_name character varying,
    pacs_name character varying,
    dacs_name character varying,
    photo bytea,
    email character varying,
    civility_id integer
);


ALTER TABLE public.staff_member OWNER TO postgres;

--
-- TOC entry 304 (class 1259 OID 16730)
-- Name: staff_member_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.staff_member_id_seq OWNER TO postgres;

--
-- TOC entry 4493 (class 0 OID 0)
-- Dependencies: 304
-- Name: staff_member_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.staff_member_id_seq OWNED BY public.staff_member.id;


--
-- TOC entry 305 (class 1259 OID 16731)
-- Name: staff_role; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.staff_role (
    id integer NOT NULL,
    name character varying,
    removed boolean DEFAULT false,
    scope_id integer DEFAULT 1
);


ALTER TABLE public.staff_role OWNER TO postgres;

--
-- TOC entry 4494 (class 0 OID 0)
-- Dependencies: 305
-- Name: TABLE staff_role; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.staff_role IS 'Scope ID : {0 = institution}, {1 = departement}';


--
-- TOC entry 306 (class 1259 OID 16738)
-- Name: staff_role_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.staff_role_id_seq OWNER TO postgres;

--
-- TOC entry 4495 (class 0 OID 0)
-- Dependencies: 306
-- Name: staff_role_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.staff_role_id_seq OWNED BY public.staff_role.id;


--
-- TOC entry 307 (class 1259 OID 16739)
-- Name: statuslist; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.statuslist (
    id integer NOT NULL,
    status_name character varying NOT NULL,
    type character varying
);


ALTER TABLE public.statuslist OWNER TO postgres;

--
-- TOC entry 4496 (class 0 OID 0)
-- Dependencies: 307
-- Name: COLUMN statuslist.type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.statuslist.type IS 'active status for table';


--
-- TOC entry 308 (class 1259 OID 16744)
-- Name: statuslist_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.statuslist_id_seq OWNER TO postgres;

--
-- TOC entry 4497 (class 0 OID 0)
-- Dependencies: 308
-- Name: statuslist_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.statuslist_id_seq OWNED BY public.statuslist.id;


--
-- TOC entry 309 (class 1259 OID 16745)
-- Name: survey; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.survey (
    id integer NOT NULL,
    title character varying NOT NULL,
    description character varying,
    type integer NOT NULL,
    status integer NOT NULL,
    begindate timestamp(0) with time zone,
    enddate timestamp(0) with time zone,
    comment character varying,
    conclusion character varying,
    removed boolean DEFAULT false
);


ALTER TABLE public.survey OWNER TO postgres;

--
-- TOC entry 310 (class 1259 OID 16751)
-- Name: survey_field; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.survey_field (
    id integer NOT NULL,
    content character varying,
    type integer NOT NULL,
    survey_id integer NOT NULL,
    "position" integer NOT NULL,
    ai_analysis boolean DEFAULT false
);


ALTER TABLE public.survey_field OWNER TO postgres;

--
-- TOC entry 311 (class 1259 OID 16756)
-- Name: survey_field_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.survey_field_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.survey_field_id_seq OWNER TO postgres;

--
-- TOC entry 4498 (class 0 OID 0)
-- Dependencies: 311
-- Name: survey_field_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.survey_field_id_seq OWNED BY public.survey_field.id;


--
-- TOC entry 312 (class 1259 OID 16757)
-- Name: survey_field_type; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.survey_field_type (
    id integer NOT NULL,
    name character varying NOT NULL
);


ALTER TABLE public.survey_field_type OWNER TO postgres;

--
-- TOC entry 313 (class 1259 OID 16762)
-- Name: survey_field_type_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.survey_field_type_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.survey_field_type_id_seq OWNER TO postgres;

--
-- TOC entry 4499 (class 0 OID 0)
-- Dependencies: 313
-- Name: survey_field_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.survey_field_type_id_seq OWNED BY public.survey_field_type.id;


--
-- TOC entry 314 (class 1259 OID 16763)
-- Name: survey_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.survey_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.survey_id_seq OWNER TO postgres;

--
-- TOC entry 4500 (class 0 OID 0)
-- Dependencies: 314
-- Name: survey_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.survey_id_seq OWNED BY public.survey.id;


--
-- TOC entry 315 (class 1259 OID 16764)
-- Name: survey_resp; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.survey_resp (
    id integer NOT NULL,
    survey_id integer NOT NULL,
    rdate timestamp(0) with time zone
);


ALTER TABLE public.survey_resp OWNER TO postgres;

--
-- TOC entry 316 (class 1259 OID 16767)
-- Name: survey_resp_field; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.survey_resp_field (
    id integer NOT NULL,
    field_id integer NOT NULL,
    value integer NOT NULL,
    resp_id integer NOT NULL,
    value_text character varying
);


ALTER TABLE public.survey_resp_field OWNER TO postgres;

--
-- TOC entry 317 (class 1259 OID 16772)
-- Name: survey_resp_field_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.survey_resp_field_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.survey_resp_field_id_seq OWNER TO postgres;

--
-- TOC entry 4501 (class 0 OID 0)
-- Dependencies: 317
-- Name: survey_resp_field_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.survey_resp_field_id_seq OWNED BY public.survey_resp_field.id;


--
-- TOC entry 318 (class 1259 OID 16773)
-- Name: survey_resp_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.survey_resp_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.survey_resp_id_seq OWNER TO postgres;

--
-- TOC entry 4502 (class 0 OID 0)
-- Dependencies: 318
-- Name: survey_resp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.survey_resp_id_seq OWNED BY public.survey_resp.id;


--
-- TOC entry 319 (class 1259 OID 16774)
-- Name: survey_type; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.survey_type (
    id integer NOT NULL,
    name character varying NOT NULL
);


ALTER TABLE public.survey_type OWNER TO postgres;

--
-- TOC entry 320 (class 1259 OID 16779)
-- Name: survey_type_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.survey_type_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.survey_type_id_seq OWNER TO postgres;

--
-- TOC entry 4503 (class 0 OID 0)
-- Dependencies: 320
-- Name: survey_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.survey_type_id_seq OWNED BY public.survey_type.id;


--
-- TOC entry 321 (class 1259 OID 16780)
-- Name: tag; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.tag (
    id integer NOT NULL,
    type character varying,
    name character varying NOT NULL,
    removed boolean DEFAULT false
);


ALTER TABLE public.tag OWNER TO postgres;

--
-- TOC entry 322 (class 1259 OID 16786)
-- Name: tag_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.tag_id_seq OWNER TO postgres;

--
-- TOC entry 4504 (class 0 OID 0)
-- Dependencies: 322
-- Name: tag_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.tag_id_seq OWNED BY public.tag.id;


--
-- TOC entry 323 (class 1259 OID 16787)
-- Name: tag_link; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.tag_link (
    id integer NOT NULL,
    type character varying NOT NULL,
    ext_id integer,
    tag_id integer
);


ALTER TABLE public.tag_link OWNER TO postgres;

--
-- TOC entry 4505 (class 0 OID 0)
-- Dependencies: 323
-- Name: COLUMN tag_link.type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.tag_link.type IS 'doit être le nom de la table à lier';


--
-- TOC entry 324 (class 1259 OID 16792)
-- Name: tag_link_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

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


ALTER SEQUENCE public.tag_link_id_seq OWNER TO postgres;

--
-- TOC entry 4506 (class 0 OID 0)
-- Dependencies: 324
-- Name: tag_link_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.tag_link_id_seq OWNED BY public.tag_link.id;


--
-- TOC entry 371 (class 1259 OID 26698)
-- Name: task; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.task (
    id integer NOT NULL,
    task_master_id integer NOT NULL,
    due_date timestamp with time zone NOT NULL,
    title character varying NOT NULL,
    description character varying,
    comment character varying,
    status_id integer DEFAULT 3,
    removed boolean DEFAULT false,
    closing_date timestamp with time zone
);


ALTER TABLE public.task OWNER TO postgres;

--
-- TOC entry 4507 (class 0 OID 0)
-- Dependencies: 371
-- Name: COLUMN task.status_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.task.status_id IS '3 : Planned';


--
-- TOC entry 372 (class 1259 OID 26701)
-- Name: task_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.task_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.task_id_seq OWNER TO postgres;

--
-- TOC entry 4508 (class 0 OID 0)
-- Dependencies: 372
-- Name: task_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.task_id_seq OWNED BY public.task.id;


--
-- TOC entry 376 (class 1259 OID 26761)
-- Name: task_link; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.task_link (
    id integer NOT NULL,
    task_id integer NOT NULL,
    staff_member_id integer NOT NULL,
    status_id integer NOT NULL,
    comment character varying,
    status_date timestamp with time zone,
    last_reminder timestamp with time zone,
    last_reminder_staff_id integer
);


ALTER TABLE public.task_link OWNER TO postgres;

--
-- TOC entry 377 (class 1259 OID 26764)
-- Name: task_link_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.task_link_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.task_link_id_seq OWNER TO postgres;

--
-- TOC entry 4509 (class 0 OID 0)
-- Dependencies: 377
-- Name: task_link_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.task_link_id_seq OWNED BY public.task_link.id;


--
-- TOC entry 369 (class 1259 OID 26648)
-- Name: task_master; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.task_master (
    id integer NOT NULL,
    title character varying NOT NULL,
    description character varying,
    start_date timestamp with time zone NOT NULL,
    end_date timestamp with time zone DEFAULT '2099-12-31 00:00:00+01'::timestamp with time zone,
    recurrence integer DEFAULT 0 NOT NULL,
    day_of_week character varying DEFAULT '-1'::character varying NOT NULL,
    active boolean DEFAULT true NOT NULL,
    dep_id integer DEFAULT '-1'::integer NOT NULL,
    removed boolean DEFAULT false NOT NULL,
    closing_type integer DEFAULT 0
);


ALTER TABLE public.task_master OWNER TO postgres;

--
-- TOC entry 4510 (class 0 OID 0)
-- Dependencies: 369
-- Name: COLUMN task_master.recurrence; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.task_master.recurrence IS '0: unique, 1: daily, 2: weekly, 3: monthly, 4: yearly';


--
-- TOC entry 4511 (class 0 OID 0)
-- Dependencies: 369
-- Name: COLUMN task_master.day_of_week; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.task_master.day_of_week IS '-1: undef, 0: sunday, 1: monday, ...';


--
-- TOC entry 370 (class 1259 OID 26651)
-- Name: task_master_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.task_master_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.task_master_id_seq OWNER TO postgres;

--
-- TOC entry 4512 (class 0 OID 0)
-- Dependencies: 370
-- Name: task_master_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.task_master_id_seq OWNED BY public.task_master.id;


--
-- TOC entry 374 (class 1259 OID 26753)
-- Name: task_master_link; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.task_master_link (
    id integer NOT NULL,
    task_master_id integer NOT NULL,
    staff_member_id integer NOT NULL
);


ALTER TABLE public.task_master_link OWNER TO postgres;

--
-- TOC entry 375 (class 1259 OID 26756)
-- Name: task_master_link_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.task_master_link_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.task_master_link_id_seq OWNER TO postgres;

--
-- TOC entry 4513 (class 0 OID 0)
-- Dependencies: 375
-- Name: task_master_link_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.task_master_link_id_seq OWNED BY public.task_master_link.id;


--
-- TOC entry 373 (class 1259 OID 26708)
-- Name: task_task_master_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.task_task_master_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.task_task_master_id_seq OWNER TO postgres;

--
-- TOC entry 4514 (class 0 OID 0)
-- Dependencies: 373
-- Name: task_task_master_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.task_task_master_id_seq OWNED BY public.task.task_master_id;


--
-- TOC entry 340 (class 1259 OID 16861)
-- Name: v_fullinfo_department; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_fullinfo_department AS
 SELECT ((institution.name)::text || COALESCE((' '::text || (department.name)::text), ''::text)) AS fullname,
    institution.id AS inst_id,
    institution.name AS inst_name,
    department.id AS dep_id,
    department.name AS dep_name,
    (institution.removed OR COALESCE(department.removed, false)) AS instordepremoved
   FROM (public.institution
     LEFT JOIN public.department ON ((department.inst_id = institution.id)));


ALTER VIEW public.v_fullinfo_department OWNER TO postgres;

--
-- TOC entry 349 (class 1259 OID 16900)
-- Name: v_taglink_instdep; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_taglink_instdep AS
 SELECT v_fullinfo_department.inst_id,
    ti.tag_id AS taginstid,
    v_fullinfo_department.dep_id,
    td.tag_id AS tagdepid,
    v_fullinfo_department.instordepremoved
   FROM public.tag_link ti,
    public.tag_link td,
    public.v_fullinfo_department
  WHERE (((ti.type)::text = 'institution'::text) AND ((td.type)::text = 'department'::text) AND (ti.ext_id = v_fullinfo_department.inst_id) AND (td.ext_id = v_fullinfo_department.dep_id));


ALTER VIEW public.v_taglink_instdep OWNER TO postgres;

--
-- TOC entry 355 (class 1259 OID 26360)
-- Name: test; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.test AS
 WITH vtl1 AS (
         SELECT DISTINCT v_taglink_instdep.inst_id,
            v_taglink_instdep.taginstid AS tag_id,
            '-1'::integer AS dep_id
           FROM public.v_taglink_instdep
          WHERE (v_taglink_instdep.instordepremoved = false)
        ), vtl2 AS (
         SELECT v_taglink_instdep.inst_id,
            v_taglink_instdep.tagdepid AS tag_id,
            v_taglink_instdep.dep_id
           FROM public.v_taglink_instdep
          WHERE (v_taglink_instdep.instordepremoved = false)
        ), t AS (
         SELECT tag_link.id,
            tag_link.type,
            tag_link.ext_id,
            tag_link.tag_id
           FROM public.tag_link
        ), f AS (
         SELECT vtl1.inst_id,
            vtl1.dep_id,
            vtl1.tag_id,
            t.ext_id,
            t.type
           FROM vtl1,
            t
          WHERE (vtl1.tag_id = t.tag_id)
        UNION
         SELECT vtl2.inst_id,
            vtl2.dep_id,
            vtl2.tag_id,
            t.ext_id,
            t.type
           FROM vtl2,
            t
          WHERE (vtl2.tag_id = t.tag_id)
        )
 SELECT f.inst_id,
    f.dep_id,
    f.tag_id,
    f.ext_id,
    f.type,
    i.name AS institution_name,
    d.name AS department_name
   FROM ((f
     LEFT JOIN public.institution i ON ((f.inst_id = i.id)))
     LEFT JOIN public.department d ON ((f.dep_id = d.id)));


ALTER VIEW public.test OWNER TO postgres;

--
-- TOC entry 325 (class 1259 OID 16793)
-- Name: v_alert; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_alert AS
 SELECT 'device_inspection'::character varying AS type,
    device.name,
        CASE
            WHEN ((now())::date >= (device_inspection.planned_date)::date) THEN 3
            WHEN ((((now())::date + '3 days'::interval))::date >= (device_inspection.planned_date)::date) THEN 2
            ELSE 1
        END AS level,
    device_inspection.planned_date,
    ''::character varying AS title
   FROM public.device_inspection,
    public.device
  WHERE ((device.id = device_inspection.device_id) AND (device_inspection.status_id = 3) AND (device_inspection.planned_date IS NOT NULL))
UNION ALL
 SELECT 'staff_formation'::character varying AS type,
    (((staff_member.lastname)::text || ' '::text) || (staff_member.firstname)::text) AS name,
        CASE
            WHEN ((now())::date >= (staff_formation.planned_date)::date) THEN 3
            WHEN ((((now())::date + '3 days'::interval))::date >= (staff_formation.planned_date)::date) THEN 2
            ELSE 1
        END AS level,
    staff_formation.planned_date,
    staff_formation.title
   FROM public.staff_formation,
    public.staff_member
  WHERE ((staff_member.id = staff_formation.staff_id) AND (staff_formation.status_id = 3) AND (staff_formation.planned_date IS NOT NULL))
UNION ALL
 SELECT 'action'::character varying AS type,
    action.description AS name,
        CASE
            WHEN ((now())::date >= (action.deadline)::date) THEN 3
            WHEN ((((now())::date + '3 days'::interval))::date >= (action.deadline)::date) THEN 2
            ELSE 1
        END AS level,
    action.deadline AS planned_date,
    action.origine AS title
   FROM public.action
  WHERE ((action.removed = false) AND (action.status_id = 3) AND (action.deadline IS NOT NULL));


ALTER VIEW public.v_alert OWNER TO postgres;

--
-- TOC entry 326 (class 1259 OID 16798)
-- Name: v_alert_action; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_alert_action AS
 SELECT description,
        CASE
            WHEN ((now())::date >= (deadline)::date) THEN 3
            WHEN ((((now())::date + '3 days'::interval))::date >= (deadline)::date) THEN 2
            ELSE 1
        END AS level,
    deadline,
    origine AS title,
    dep_id
   FROM public.action
  WHERE ((removed = false) AND (status_id = 3) AND (deadline IS NOT NULL));


ALTER VIEW public.v_alert_action OWNER TO postgres;

--
-- TOC entry 327 (class 1259 OID 16802)
-- Name: v_alert_afcnsend; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_alert_afcnsend AS
 SELECT afcnsend.id,
        CASE
            WHEN ((now())::date >= (afcnsend.senddate)::date) THEN 3
            WHEN ((((now())::date + '3 days'::interval))::date >= (afcnsend.senddate)::date) THEN 2
            ELSE 1
        END AS level,
    afcnsend.senddate,
    afcnsend.comment,
    department.name AS department,
    department.id AS dep_id
   FROM (public.afcnsend
     LEFT JOIN public.department ON ((afcnsend.dep_id = department.id)))
  WHERE ((afcnsend.removed = false) AND (afcnsend.status_id = 3) AND (afcnsend.senddate IS NOT NULL));


ALTER VIEW public.v_alert_afcnsend OWNER TO postgres;

--
-- TOC entry 328 (class 1259 OID 16807)
-- Name: v_alert_audit; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_alert_audit AS
 SELECT id,
        CASE
            WHEN ((now())::date >= (date)::date) THEN 3
            WHEN ((((now())::date + '3 days'::interval))::date >= (date)::date) THEN 2
            ELSE 1
        END AS level,
    date,
    title,
    inst_id,
    dep_id
   FROM public.audit
  WHERE ((removed = false) AND (status_id = 3) AND (date IS NOT NULL));


ALTER VIEW public.v_alert_audit OWNER TO postgres;

--
-- TOC entry 329 (class 1259 OID 16811)
-- Name: v_alert_device_inspection; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_alert_device_inspection AS
 SELECT device.id,
    device.name,
        CASE
            WHEN ((now())::date >= (device_inspection.planned_date)::date) THEN 3
            WHEN ((((now())::date + '3 days'::interval))::date >= (device_inspection.planned_date)::date) THEN 2
            ELSE 1
        END AS level,
    device_inspection.planned_date,
    ''::character varying AS title
   FROM public.device_inspection,
    public.device
  WHERE ((device.removed = false) AND (device_inspection.removed = false) AND (device.id = device_inspection.device_id) AND (device_inspection.status_id = 3) AND (device_inspection.planned_date IS NOT NULL));


ALTER VIEW public.v_alert_device_inspection OWNER TO postgres;

--
-- TOC entry 330 (class 1259 OID 16816)
-- Name: v_alert_device_maintenance; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_alert_device_maintenance AS
 SELECT device.id,
    device.name,
        CASE
            WHEN ((now())::date >= (device_maintenance.planned_date)::date) THEN 3
            WHEN ((((now())::date + '3 days'::interval))::date >= (device_maintenance.planned_date)::date) THEN 2
            ELSE 1
        END AS level,
    device_maintenance.planned_date,
    ''::character varying AS title
   FROM public.device_maintenance,
    public.device
  WHERE ((device.removed = false) AND (device_maintenance.removed = false) AND (device.id = device_maintenance.device_id) AND (device_maintenance.status_id = 3) AND (device_maintenance.planned_date IS NOT NULL));


ALTER VIEW public.v_alert_device_maintenance OWNER TO postgres;

--
-- TOC entry 331 (class 1259 OID 16821)
-- Name: v_alert_report; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_alert_report AS
 SELECT title,
    COALESCE(severity, 1) AS severity,
    reportdate,
    dep_id
   FROM public.report
  WHERE ((status_id = 7) AND (removed = false))
  ORDER BY COALESCE(severity, 1) DESC NULLS LAST, reportdate;


ALTER VIEW public.v_alert_report OWNER TO postgres;

--
-- TOC entry 332 (class 1259 OID 16825)
-- Name: v_alert_staff_formation; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_alert_staff_formation AS
 SELECT (((staff_member.lastname)::text || ' '::text) || (staff_member.firstname)::text) AS name,
        CASE
            WHEN ((now())::date >= (staff_formation.planned_date)::date) THEN 3
            WHEN ((((now())::date + '3 days'::interval))::date >= (staff_formation.planned_date)::date) THEN 2
            ELSE 1
        END AS level,
    staff_formation.planned_date,
    staff_formation.title,
    staff_member.id AS staff_id
   FROM public.staff_formation,
    public.staff_member
  WHERE ((staff_member.id = staff_formation.staff_id) AND (staff_formation.status_id = 3) AND (staff_formation.planned_date IS NOT NULL) AND (staff_formation.removed = false) AND (staff_member.removed = false));


ALTER VIEW public.v_alert_staff_formation OWNER TO postgres;

--
-- TOC entry 378 (class 1259 OID 26812)
-- Name: v_alert_task; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_alert_task AS
 WITH t1 AS (
         SELECT t.id,
            t.task_master_id,
            t.due_date,
            t.title,
            t.description,
            t.comment,
            t.status_id,
            t.removed,
            tl.id,
            tl.task_id,
            tl.staff_member_id,
            tl.status_id,
            tl.comment,
            tl.status_date,
            tl.last_reminder,
            tl.last_reminder_staff_id
           FROM public.task t,
            public.task_link tl
          WHERE ((t.id = tl.task_id) AND (tl.status_id <> 4))
        )
 SELECT task_id,
    description,
        CASE
            WHEN ((now())::date >= (due_date)::date) THEN 3
            WHEN ((((now())::date + '3 days'::interval))::date >= (due_date)::date) THEN 2
            ELSE 1
        END AS level,
    due_date,
    title,
    staff_member_id,
    task_master_id,
    last_reminder,
    last_reminder_staff_id
   FROM t1 t1(id, task_master_id, due_date, title, description, comment, status_id, removed, id_1, task_id, staff_member_id, status_id_1, comment_1, status_date, last_reminder, last_reminder_staff_id)
  WHERE (removed = false);


ALTER VIEW public.v_alert_task OWNER TO postgres;

--
-- TOC entry 333 (class 1259 OID 16830)
-- Name: v_bquaad_deviceinspection; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_bquaad_deviceinspection AS
 WITH t4 AS (
         WITH t3 AS (
                 WITH t2 AS (
                         WITH t AS (
                                 SELECT device_inspection.device_id,
                                    device_inspection.id,
CASE
 WHEN (device_inspection.result = 5) THEN 'OK'::text
 ELSE 'KO'::text
END AS result_okko,
                                    device_inspection.result AS inspection_result,
                                    device_inspection.inspection_date,
                                    device_inspection.planned_date,
                                    action.id AS act_id,
                                    action.status_id AS act_status,
                                    action.description AS action_desc,
                                    device_inspection.comment AS inspection_comment
                                   FROM ((public.device_inspection
                                     LEFT JOIN ( SELECT action_link_1.id,
    action_link_1.action_id,
    action_link_1.ext_id,
    action_link_1.scope
   FROM public.action_link action_link_1
  WHERE ((action_link_1.scope)::text = 'device_inspection'::text)) action_link ON ((action_link.ext_id = device_inspection.id)))
                                     LEFT JOIN public.action ON ((action_link.action_id = action.id)))
                                  WHERE ((device_inspection.removed = false) AND ((action.removed = false) OR (action.removed IS NULL)))
                                )
                         SELECT t.id,
                            t.result_okko,
                            t.inspection_result,
                            t.inspection_date,
                            t.planned_date,
                            t.act_id,
                            t.act_status,
                            t.action_desc AS inspection_comment,
                            doc_l.doc_id,
                            t.device_id
                           FROM (t
                             LEFT JOIN ( SELECT document_link.id,
                                    document_link.type,
                                    document_link.ext_id,
                                    document_link.doc_id
                                   FROM public.document_link
                                  WHERE ((document_link.type)::text = 'device_inspection'::text)) doc_l ON ((doc_l.ext_id = t.id)))
                        )
                 SELECT
                        CASE
                            WHEN (t2.result_okko = 'OK'::text) THEN 'OK'::text
                            ELSE
                            CASE
                                WHEN (t2.act_id IS NOT NULL) THEN 'OK'::text
                                ELSE 'KO'::text
                            END
                        END AS force_result,
                    t2.id,
                    t2.result_okko,
                    t2.inspection_result,
                    t2.inspection_date,
                    t2.planned_date,
                    t2.act_id,
                    t2.act_status,
                    t2.inspection_comment,
                    t2.doc_id,
                    t2.device_id
                   FROM t2
                )
         SELECT t3.id,
            t3.device_id,
                CASE
                    WHEN (t3.inspection_date IS NULL) THEN NULL::integer
                    ELSE t3.doc_id
                END AS doc_id,
            t3.force_result,
                CASE
                    WHEN (t3.force_result = 'KO'::text) THEN (('Le contrôle a été effectué le '::text || to_char(t3.inspection_date, 'DD/MM/YYYY'::text)) || ' avec un résultat négatif et aucune tâche n''a été planifiée'::text)
                    WHEN ((t3.result_okko = t3.force_result) AND (t3.result_okko = 'OK'::text)) THEN (('Le contrôle a été effectué le '::text || to_char(t3.inspection_date, 'DD/MM/YYYY'::text)) || ' et le résultat est positif'::text)
                    ELSE ((('Le contrôle a été effectué le '::text || to_char(t3.inspection_date, 'DD/MM/YYYY'::text)) || ' et le résultat est négatif<br><br> La tâche suivante a été planifiée dans le logiciel eoQUAL:<br>'::text) || (t3.inspection_comment)::text)
                END AS force_doctext,
            NULL::text AS force_docid,
            t3.inspection_date,
            t3.planned_date
           FROM t3
          WHERE (t3.inspection_date IS NOT NULL)
        )
 SELECT t4.id,
    t4.device_id,
    t4.doc_id,
    t4.force_result,
    t4.force_doctext,
    t4.force_docid,
    t4.inspection_date,
    t4.planned_date,
    device_installation.id AS v_device_plus_deviceinstallation_devid_id,
    COALESCE(t4.inspection_date, t4.planned_date) AS tocheck_date
   FROM t4,
    public.device_installation
  WHERE (t4.device_id = device_installation.id);


ALTER VIEW public.v_bquaad_deviceinspection OWNER TO postgres;

--
-- TOC entry 334 (class 1259 OID 16835)
-- Name: v_deptagidbyinsttagid; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_deptagidbyinsttagid AS
 SELECT i.tag_id AS insttagid,
    string_agg((d.tag_id)::text, ','::text) AS tagdepidforinsttagid
   FROM public.tag_link i,
    public.tag_link d,
    public.department
  WHERE (((i.type)::text = 'institution'::text) AND (department.id = d.ext_id) AND ((d.type)::text = 'department'::text) AND (department.inst_id = i.ext_id))
  GROUP BY i.tag_id;


ALTER VIEW public.v_deptagidbyinsttagid OWNER TO postgres;

--
-- TOC entry 335 (class 1259 OID 16839)
-- Name: v_device_actif_by_deptagid; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_device_actif_by_deptagid AS
 SELECT device_installation.dep_id,
    tag_link.tag_id,
    (((now())::date >= (device_installation.installdate)::date) AND (COALESCE((device_installation.removeddate)::date, (now())::date) >= (now())::date)) AS is_actif,
    department.name AS depname,
    device_installation.device_id,
    device_installation.installdate
   FROM public.device_installation,
    public.department,
    public.tag_link
  WHERE (((tag_link.type)::text = 'department'::text) AND (tag_link.ext_id = department.id) AND (device_installation.dep_id = department.id) AND (device_installation.removed = false));


ALTER VIEW public.v_device_actif_by_deptagid OWNER TO postgres;

--
-- TOC entry 336 (class 1259 OID 16844)
-- Name: v_device_historyinstallationdeptagidlist; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_device_historyinstallationdeptagidlist AS
 SELECT device_installation.device_id,
    ((('{'::text || string_agg(DISTINCT (tag_link.tag_id)::text, ','::text)) || '}'::text))::integer[] AS deptagidlist,
    ((('{'::text || string_agg(DISTINCT (tag_link.ext_id)::text, ','::text)) || '}'::text))::integer[] AS depidlist
   FROM public.device_installation,
    public.tag_link
  WHERE (((tag_link.type)::text = 'department'::text) AND (tag_link.ext_id = device_installation.dep_id) AND (device_installation.removed = false))
  GROUP BY device_installation.device_id;


ALTER VIEW public.v_device_historyinstallationdeptagidlist OWNER TO postgres;

--
-- TOC entry 337 (class 1259 OID 16849)
-- Name: v_device_plus_deviceinstallation_devid; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_device_plus_deviceinstallation_devid AS
 SELECT device.id,
    device.brand,
    device.dacs_name,
    device.modalitytype,
    device.model,
    device.name,
    device.pacs_name,
    device.removed,
    device.ris_name,
    device.serialnumber,
    device_installation.id AS install_id,
    device_installation.comment,
    device_installation.dep_id,
    device_installation.inchargeof,
    device_installation.installdate,
    device_installation.installedby,
    device_installation.removed AS inst_removed,
    device_installation.removeddate
   FROM public.device_installation,
    public.device
  WHERE (device.id = device_installation.device_id);


ALTER VIEW public.v_device_plus_deviceinstallation_devid OWNER TO postgres;

--
-- TOC entry 338 (class 1259 OID 16853)
-- Name: v_device_plus_deviceinstallation_instid; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_device_plus_deviceinstallation_instid AS
 SELECT device.id AS dev_id,
    device.brand,
    device.dacs_name,
    device.modalitytype,
    device.model,
    device.name,
    device.pacs_name,
    device.removed,
    device.ris_name,
    device.serialnumber,
    device_installation.id,
    device_installation.comment,
    device_installation.dep_id,
    device_installation.inchargeof,
    device_installation.installdate,
    device_installation.installedby,
    device_installation.removed AS inst_removed,
    device_installation.removeddate
   FROM public.device_installation,
    public.device
  WHERE (device.id = device_installation.device_id);


ALTER VIEW public.v_device_plus_deviceinstallation_instid OWNER TO postgres;

--
-- TOC entry 341 (class 1259 OID 16865)
-- Name: v_last_documentstatus; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_last_documentstatus AS
 SELECT DISTINCT ON (doc_id) id,
    begdate,
    enddate,
    doc_id,
    status_id
   FROM public.documentstatus
  ORDER BY doc_id, begdate DESC;


ALTER VIEW public.v_last_documentstatus OWNER TO postgres;

--
-- TOC entry 368 (class 1259 OID 26594)
-- Name: v_document_departmentdocument; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_document_departmentdocument AS
 WITH t AS (
         SELECT vld.type AS document_type,
            dm.name,
            p.id AS ext_id,
            d.id AS doc_id,
            d.doc_master_id AS master_doc_id,
            d.type AS extension,
            d.creation_date AS date,
            d.revision,
            d.label AS document_label,
            dm.name AS document_name,
            d.valid_until_date,
            vlds.status_id,
            sl.status_name,
            vlds.begdate AS status_begdate,
            vlds.enddate AS status_enddate,
            p.id AS inst_id,
            '-1'::integer AS dep_id,
            '-1'::integer AS tag_ids,
            p.name AS department_fullname
           FROM public.department p,
            public.document_link vld,
            public.document d,
            public.document_master dm,
            public.v_last_documentstatus vlds,
            public.statuslist sl
          WHERE ((vlds.status_id <> 2) AND (vlds.status_id <> 13) AND (p.removed = false) AND ((vld.type)::text = 'department'::text) AND (p.id = vld.ext_id) AND (vld.doc_id = d.id) AND (d.id = vlds.doc_id) AND (d.doc_master_id = dm.id) AND (dm.removed = false) AND (vlds.status_id = sl.id) AND (d.removed = false))
        )
 SELECT t.document_type,
    t.name,
    t.ext_id,
    t.doc_id,
    t.master_doc_id,
    t.extension,
    t.date,
    t.revision,
    t.document_label,
    t.document_name,
    t.valid_until_date,
    t.status_id,
    t.status_name,
    t.status_begdate,
    t.status_enddate,
    t.inst_id,
    '-1'::integer AS dep_id,
    tl.tag_id AS tag_ids,
    t.department_fullname
   FROM (t
     LEFT JOIN public.tag_link tl ON (((t.ext_id = tl.ext_id) AND ((tl.type)::text = 'institution'::text))));


ALTER VIEW public.v_document_departmentdocument OWNER TO postgres;

--
-- TOC entry 360 (class 1259 OID 26459)
-- Name: v_document_device; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_document_device AS
 SELECT vld.type AS document_type,
    ((((((p.name)::text || '('::text) || (p.brand)::text) || ' - '::text) || (p.model)::text) || ')'::text) AS name,
    p.id AS ext_id,
    d.id AS doc_id,
    d.doc_master_id AS master_doc_id,
    d.type AS extension,
    d.creation_date AS date,
    d.revision,
    d.label AS document_label,
    dm.name AS document_name,
    d.valid_until_date,
    vlds.status_id,
    sl.status_name,
    vlds.begdate AS status_begdate,
    vlds.enddate AS status_enddate
   FROM public.device p,
    public.document_link vld,
    public.document d,
    public.document_master dm,
    public.v_last_documentstatus vlds,
    public.statuslist sl
  WHERE ((vlds.status_id <> 2) AND (vlds.status_id <> 13) AND (p.removed = false) AND ((vld.type)::text = 'device'::text) AND (p.id = vld.ext_id) AND (vld.doc_id = d.id) AND (d.id = vlds.doc_id) AND (d.doc_master_id = dm.id) AND (dm.removed = false) AND (vlds.status_id = sl.id) AND (d.removed = false))
  ORDER BY p.name;


ALTER VIEW public.v_document_device OWNER TO postgres;

--
-- TOC entry 363 (class 1259 OID 26515)
-- Name: v_document_device_instdep; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_document_device_instdep AS
 WITH t AS (
         SELECT device_installation.device_id,
            max(device_installation.installdate) AS lastdate
           FROM public.device_installation
          GROUP BY device_installation.device_id
        ), t1 AS (
         SELECT inst.name AS institution_name,
            dep.name AS department_name,
            dep.id AS dep_id,
            dep.inst_id
           FROM public.institution inst,
            public.department dep
          WHERE ((inst.id = dep.inst_id) AND (dep.removed = false))
        ), t2 AS (
         SELECT di.device_id,
            di.dep_id
           FROM public.device_installation di,
            t
          WHERE ((t.device_id = di.device_id) AND (t.lastdate = di.installdate))
        ), t3 AS (
         SELECT t2.device_id,
            t1.institution_name,
            t1.department_name,
            ((((t1.institution_name)::text || ' ('::text) || (t1.department_name)::text) || ')'::text) AS department_fullname,
            t1.inst_id,
            t1.dep_id
           FROM (t2
             LEFT JOIN t1 ON ((t1.dep_id = t2.dep_id)))
        ), t4 AS (
         SELECT vdd.document_type,
            vdd.name,
            vdd.ext_id,
            vdd.doc_id,
            vdd.master_doc_id,
            vdd.extension,
            vdd.date,
            vdd.revision,
            vdd.document_label,
            vdd.document_name,
            vdd.valid_until_date,
            vdd.status_id,
            vdd.status_name,
            vdd.status_begdate,
            vdd.status_enddate,
            t3.device_id,
            t3.institution_name,
            t3.department_name,
            t3.department_fullname,
            t3.inst_id,
            t3.dep_id
           FROM (public.v_document_device vdd
             LEFT JOIN t3 ON ((vdd.ext_id = t3.device_id)))
        )
 SELECT t4.document_type,
    t4.name,
    t4.ext_id,
    t4.doc_id,
    t4.master_doc_id,
    t4.extension,
    t4.date,
    t4.revision,
    t4.document_label,
    t4.document_name,
    t4.valid_until_date,
    t4.status_id,
    t4.status_name,
    t4.status_begdate,
    t4.status_enddate,
    t4.device_id,
    t4.institution_name,
    t4.department_name,
    t4.department_fullname,
    t4.inst_id,
    t4.dep_id,
    tl.tag_id AS tag_ids
   FROM (t4
     LEFT JOIN public.tag_link tl ON (((t4.dep_id = tl.ext_id) AND ((tl.type)::text = 'department'::text))));


ALTER VIEW public.v_document_device_instdep OWNER TO postgres;

--
-- TOC entry 367 (class 1259 OID 26557)
-- Name: v_document_institutiondocument; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_document_institutiondocument AS
 WITH t AS (
         SELECT vld.type AS document_type,
            dm.name,
            p.id AS ext_id,
            d.id AS doc_id,
            d.doc_master_id AS master_doc_id,
            d.type AS extension,
            d.creation_date AS date,
            d.revision,
            d.label AS document_label,
            dm.name AS document_name,
            d.valid_until_date,
            vlds.status_id,
            sl.status_name,
            vlds.begdate AS status_begdate,
            vlds.enddate AS status_enddate,
            p.id AS inst_id,
            '-1'::integer AS dep_id,
            '-1'::integer AS tag_ids,
            p.name AS department_fullname
           FROM public.institution p,
            public.document_link vld,
            public.document d,
            public.document_master dm,
            public.v_last_documentstatus vlds,
            public.statuslist sl
          WHERE ((vlds.status_id <> 2) AND (vlds.status_id <> 13) AND (p.removed = false) AND ((vld.type)::text = 'institution'::text) AND (p.id = vld.ext_id) AND (vld.doc_id = d.id) AND (d.id = vlds.doc_id) AND (d.doc_master_id = dm.id) AND (dm.removed = false) AND (vlds.status_id = sl.id) AND (d.removed = false))
        )
 SELECT t.document_type,
    t.name,
    t.ext_id,
    t.doc_id,
    t.master_doc_id,
    t.extension,
    t.date,
    t.revision,
    t.document_label,
    t.document_name,
    t.valid_until_date,
    t.status_id,
    t.status_name,
    t.status_begdate,
    t.status_enddate,
    t.inst_id,
    '-1'::integer AS dep_id,
    tl.tag_id AS tag_ids,
    t.department_fullname
   FROM (t
     LEFT JOIN public.tag_link tl ON (((t.ext_id = tl.ext_id) AND ((tl.type)::text = 'institution'::text))));


ALTER VIEW public.v_document_institutiondocument OWNER TO postgres;

--
-- TOC entry 366 (class 1259 OID 26544)
-- Name: v_document_legaldocument; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_document_legaldocument AS
 SELECT vld.type AS document_type,
    p.name,
    p.id AS ext_id,
    d.id AS doc_id,
    d.doc_master_id AS master_doc_id,
    d.type AS extension,
    d.creation_date AS date,
    d.revision,
    d.label AS document_label,
    dm.name AS document_name,
    d.valid_until_date,
    vlds.status_id,
    sl.status_name,
    vlds.begdate AS status_begdate,
    vlds.enddate AS status_enddate,
    '-1'::integer AS inst_id,
    '-1'::integer AS dep_id,
    '-1'::integer AS tag_ids
   FROM public.legaldocument p,
    public.document_link vld,
    public.document d,
    public.document_master dm,
    public.v_last_documentstatus vlds,
    public.statuslist sl
  WHERE ((vlds.status_id <> 2) AND (vlds.status_id <> 13) AND (p.removed = false) AND ((vld.type)::text = 'legaldocument'::text) AND (p.id = vld.ext_id) AND (vld.doc_id = d.id) AND (d.id = vlds.doc_id) AND (d.doc_master_id = dm.id) AND (dm.removed = false) AND (vlds.status_id = sl.id) AND (d.removed = false))
  ORDER BY p.name;


ALTER VIEW public.v_document_legaldocument OWNER TO postgres;

--
-- TOC entry 354 (class 1259 OID 26299)
-- Name: v_last_document; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_last_document AS
 SELECT DISTINCT ON (ext_id) id,
    type,
    ext_id,
    doc_id
   FROM public.document_link dl
  ORDER BY ext_id, doc_id DESC;


ALTER VIEW public.v_last_document OWNER TO postgres;

--
-- TOC entry 358 (class 1259 OID 26420)
-- Name: v_document_procedure; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_document_procedure AS
 SELECT vld.type AS document_type,
    p.name_fr AS name,
    dm.name AS document_name,
    p.id AS ext_id,
    d.id AS doc_id,
    d.doc_master_id AS master_doc_id,
    d.type AS extension,
    d.creation_date AS date,
    d.revision,
    d.label AS document_label,
    d.valid_until_date,
    vlds.status_id,
    sl.status_name,
    vlds.begdate AS status_begdate,
    vlds.enddate AS status_enddate
   FROM public.procedure p,
    public.v_last_document vld,
    public.document d,
    public.document_master dm,
    public.v_last_documentstatus vlds,
    public.statuslist sl
  WHERE ((p.removed = false) AND ((vld.type)::text = 'procedure'::text) AND (p.id = vld.ext_id) AND (vld.doc_id = d.id) AND (d.id = vlds.doc_id) AND (d.doc_master_id = dm.id) AND (dm.removed = false) AND (vlds.status_id = sl.id) AND (d.removed = false))
  ORDER BY p.name_fr;


ALTER VIEW public.v_document_procedure OWNER TO postgres;

--
-- TOC entry 356 (class 1259 OID 26367)
-- Name: v_instdep_from_extid_type; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_instdep_from_extid_type AS
 WITH vtl1 AS (
         SELECT DISTINCT v_taglink_instdep.inst_id,
            v_taglink_instdep.taginstid AS tag_id,
            '-1'::integer AS dep_id
           FROM public.v_taglink_instdep
          WHERE (v_taglink_instdep.instordepremoved = false)
        ), vtl2 AS (
         SELECT v_taglink_instdep.inst_id,
            v_taglink_instdep.tagdepid AS tag_id,
            v_taglink_instdep.dep_id
           FROM public.v_taglink_instdep
          WHERE (v_taglink_instdep.instordepremoved = false)
        ), t AS (
         SELECT tag_link.id,
            tag_link.type,
            tag_link.ext_id,
            tag_link.tag_id
           FROM public.tag_link
        ), f AS (
         SELECT vtl1.inst_id,
            vtl1.dep_id,
            vtl1.tag_id,
            t.ext_id,
            t.type
           FROM vtl1,
            t
          WHERE (vtl1.tag_id = t.tag_id)
        UNION
         SELECT vtl2.inst_id,
            vtl2.dep_id,
            vtl2.tag_id,
            t.ext_id,
            t.type
           FROM vtl2,
            t
          WHERE (vtl2.tag_id = t.tag_id)
        )
 SELECT f.inst_id,
    f.dep_id,
    f.tag_id,
    f.ext_id,
    f.type,
    i.name AS institution_name,
    d.name AS department_name
   FROM ((f
     LEFT JOIN public.institution i ON ((f.inst_id = i.id)))
     LEFT JOIN public.department d ON ((f.dep_id = d.id)));


ALTER VIEW public.v_instdep_from_extid_type OWNER TO postgres;

--
-- TOC entry 357 (class 1259 OID 26372)
-- Name: v_instdep_fullname_from_extid_type; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_instdep_fullname_from_extid_type AS
 WITH r AS (
         SELECT v_instdep_from_extid_type.inst_id,
            v_instdep_from_extid_type.dep_id,
            v_instdep_from_extid_type.tag_id,
            v_instdep_from_extid_type.ext_id,
            v_instdep_from_extid_type.type,
            v_instdep_from_extid_type.institution_name,
            v_instdep_from_extid_type.department_name
           FROM public.v_instdep_from_extid_type
        ), r1 AS (
         SELECT r.type,
            string_agg((r.tag_id)::text, ','::text) AS tag_ids,
            ((((r.institution_name)::text || ' ('::text) || string_agg((r.department_name)::text, ','::text)) || ')'::text) AS name,
            r.ext_id
           FROM r
          WHERE (r.dep_id <> '-1'::integer)
          GROUP BY r.type, r.institution_name, r.ext_id, r.inst_id
        UNION
         SELECT r.type,
            string_agg((r.tag_id)::text, ','::text) AS tag_ids,
            r.institution_name AS name,
            r.ext_id
           FROM r
          WHERE (r.dep_id = '-1'::integer)
          GROUP BY r.type, r.institution_name, r.ext_id, r.inst_id
        )
 SELECT type,
    name,
    ext_id,
    tag_ids
   FROM r1;


ALTER VIEW public.v_instdep_fullname_from_extid_type OWNER TO postgres;

--
-- TOC entry 359 (class 1259 OID 26425)
-- Name: v_document_procedure_instdep; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_document_procedure_instdep AS
 SELECT v1.doc_id,
    v1.ext_id,
    v1.document_type,
    v1.name,
    v1.document_name,
    v1.document_label,
    v1.revision,
    v1.status_name,
    v1.status_id,
    v1.extension,
    v1.status_begdate,
    v2.name AS department_fullname,
    v2.tag_ids
   FROM (public.v_document_procedure v1
     LEFT JOIN public.v_instdep_fullname_from_extid_type v2 ON (((v1.ext_id = v2.ext_id) AND ((v1.document_type)::text = (v2.type)::text))));


ALTER VIEW public.v_document_procedure_instdep OWNER TO postgres;

--
-- TOC entry 362 (class 1259 OID 26488)
-- Name: v_document_staff_formation; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_document_staff_formation AS
 SELECT vld.type AS document_type,
    ((((((p.title)::text || ' ('::text) || (sm.lastname)::text) || ' '::text) || (sm.firstname)::text) || ')'::text) AS name,
    p.id AS ext_id,
    d.id AS doc_id,
    p.staff_id,
    d.doc_master_id AS master_doc_id,
    d.type AS extension,
    d.creation_date AS date,
    d.revision,
    d.label AS document_label,
    dm.name AS document_name,
    d.valid_until_date,
    vlds.status_id,
    sl.status_name,
    vlds.begdate AS status_begdate,
    vlds.enddate AS status_enddate
   FROM public.staff_formation p,
    public.document_link vld,
    public.document d,
    public.document_master dm,
    public.v_last_documentstatus vlds,
    public.statuslist sl,
    public.staff_member sm
  WHERE ((sm.id = p.staff_id) AND (vlds.status_id <> 2) AND (vlds.status_id <> 13) AND (p.removed = false) AND ((vld.type)::text = 'staff_formation'::text) AND (p.id = vld.ext_id) AND (vld.doc_id = d.id) AND (d.id = vlds.doc_id) AND (d.doc_master_id = dm.id) AND (dm.removed = false) AND (vlds.status_id = sl.id) AND (d.removed = false))
  ORDER BY sm.lastname;


ALTER VIEW public.v_document_staff_formation OWNER TO postgres;

--
-- TOC entry 365 (class 1259 OID 26526)
-- Name: v_document_staff_formation_instdep; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_document_staff_formation_instdep AS
 WITH t AS (
         SELECT sj.staff_id,
            sj.begdate AS lastdate
           FROM public.staff_job sj
          WHERE ((CURRENT_DATE >= sj.begdate) AND (CURRENT_DATE <= sj.enddate) AND (sj.removed = false))
        ), t1 AS (
         SELECT inst.name AS institution_name,
            dep.name AS department_name,
            dep.id AS dep_id,
            dep.inst_id
           FROM public.institution inst,
            public.department dep
          WHERE ((inst.id = dep.inst_id) AND (dep.removed = false))
        ), t2 AS (
         SELECT di.staff_id,
            di.dep_id
           FROM public.staff_job di,
            t
          WHERE ((t.staff_id = di.staff_id) AND (t.lastdate = di.begdate))
        ), t3 AS (
         SELECT t2.staff_id,
            t1.institution_name,
            t1.department_name,
            ((((t1.institution_name)::text || ' ('::text) || (t1.department_name)::text) || ')'::text) AS department_fullname,
            t1.inst_id,
            t1.dep_id
           FROM (t2
             LEFT JOIN t1 ON ((t1.dep_id = t2.dep_id)))
        ), t4 AS (
         SELECT vdsm.document_type,
            vdsm.name,
            vdsm.ext_id,
            vdsm.doc_id,
            vdsm.master_doc_id,
            vdsm.extension,
            vdsm.date,
            vdsm.revision,
            vdsm.document_label,
            vdsm.document_name,
            vdsm.valid_until_date,
            vdsm.status_id,
            vdsm.status_name,
            vdsm.status_begdate,
            vdsm.status_enddate,
            t3.staff_id,
            t3.institution_name,
            t3.department_name,
            t3.department_fullname,
            t3.inst_id,
            t3.dep_id
           FROM (public.v_document_staff_formation vdsm
             LEFT JOIN t3 ON ((vdsm.staff_id = t3.staff_id)))
        )
 SELECT t4.document_type,
    t4.name,
    t4.ext_id,
    t4.doc_id,
    t4.master_doc_id,
    t4.extension,
    t4.date,
    t4.revision,
    t4.document_label,
    t4.document_name,
    t4.valid_until_date,
    t4.status_id,
    t4.status_name,
    t4.status_begdate,
    t4.status_enddate,
    t4.staff_id,
    t4.institution_name,
    t4.department_name,
    t4.department_fullname,
    t4.dep_id,
    t4.inst_id,
    tl.tag_id AS tag_ids
   FROM (t4
     LEFT JOIN public.tag_link tl ON (((t4.dep_id = tl.ext_id) AND ((tl.type)::text = 'department'::text))));


ALTER VIEW public.v_document_staff_formation_instdep OWNER TO postgres;

--
-- TOC entry 361 (class 1259 OID 26470)
-- Name: v_document_staff_member; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_document_staff_member AS
 SELECT vld.type AS document_type,
    (((p.lastname)::text || ' '::text) || (p.firstname)::text) AS name,
    p.id AS ext_id,
    d.id AS doc_id,
    d.doc_master_id AS master_doc_id,
    d.type AS extension,
    d.creation_date AS date,
    d.revision,
    d.label AS document_label,
    dm.name AS document_name,
    d.valid_until_date,
    vlds.status_id,
    sl.status_name,
    vlds.begdate AS status_begdate,
    vlds.enddate AS status_enddate
   FROM public.staff_member p,
    public.document_link vld,
    public.document d,
    public.document_master dm,
    public.v_last_documentstatus vlds,
    public.statuslist sl
  WHERE ((vlds.status_id <> 2) AND (vlds.status_id <> 13) AND (p.removed = false) AND ((vld.type)::text = 'staff_member'::text) AND (p.id = vld.ext_id) AND (vld.doc_id = d.id) AND (d.id = vlds.doc_id) AND (d.doc_master_id = dm.id) AND (dm.removed = false) AND (vlds.status_id = sl.id) AND (d.removed = false))
  ORDER BY p.lastname;


ALTER VIEW public.v_document_staff_member OWNER TO postgres;

--
-- TOC entry 364 (class 1259 OID 26520)
-- Name: v_document_staff_member_instdep; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_document_staff_member_instdep AS
 WITH t AS (
         SELECT sj.staff_id,
            sj.begdate AS lastdate
           FROM public.staff_job sj
          WHERE ((CURRENT_DATE >= sj.begdate) AND (CURRENT_DATE <= sj.enddate) AND (sj.removed = false))
        ), t1 AS (
         SELECT inst.name AS institution_name,
            dep.name AS department_name,
            dep.id AS dep_id,
            dep.inst_id
           FROM public.institution inst,
            public.department dep
          WHERE ((inst.id = dep.inst_id) AND (dep.removed = false))
        ), t2 AS (
         SELECT di.staff_id,
            di.dep_id
           FROM public.staff_job di,
            t
          WHERE ((t.staff_id = di.staff_id) AND (t.lastdate = di.begdate))
        ), t3 AS (
         SELECT t2.staff_id,
            t1.institution_name,
            t1.department_name,
            ((((t1.institution_name)::text || ' ('::text) || (t1.department_name)::text) || ')'::text) AS department_fullname,
            t1.inst_id,
            t1.dep_id
           FROM (t2
             LEFT JOIN t1 ON ((t1.dep_id = t2.dep_id)))
        ), t4 AS (
         SELECT vdsm.document_type,
            vdsm.name,
            vdsm.ext_id,
            vdsm.doc_id,
            vdsm.master_doc_id,
            vdsm.extension,
            vdsm.date,
            vdsm.revision,
            vdsm.document_label,
            vdsm.document_name,
            vdsm.valid_until_date,
            vdsm.status_id,
            vdsm.status_name,
            vdsm.status_begdate,
            vdsm.status_enddate,
            t3.staff_id,
            t3.institution_name,
            t3.department_name,
            t3.department_fullname,
            t3.inst_id,
            t3.dep_id
           FROM (public.v_document_staff_member vdsm
             LEFT JOIN t3 ON ((vdsm.ext_id = t3.staff_id)))
        )
 SELECT t4.document_type,
    t4.name,
    t4.ext_id,
    t4.doc_id,
    t4.master_doc_id,
    t4.extension,
    t4.date,
    t4.revision,
    t4.document_label,
    t4.document_name,
    t4.valid_until_date,
    t4.status_id,
    t4.status_name,
    t4.status_begdate,
    t4.status_enddate,
    t4.staff_id,
    t4.institution_name,
    t4.department_name,
    t4.department_fullname,
    t4.inst_id,
    t4.dep_id,
    tl.tag_id AS tag_ids
   FROM (t4
     LEFT JOIN public.tag_link tl ON (((t4.dep_id = tl.ext_id) AND ((tl.type)::text = 'department'::text))));


ALTER VIEW public.v_document_staff_member_instdep OWNER TO postgres;

--
-- TOC entry 339 (class 1259 OID 16857)
-- Name: v_exam_risk_tag_doc; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_exam_risk_tag_doc AS
SELECT
    NULL::integer AS id,
    NULL::character varying AS modality,
    NULL::character varying AS name,
    NULL::character varying AS description,
    NULL::text AS risklist,
    NULL::character varying AS taglist,
    NULL::integer AS doc_id,
    NULL::integer AS doc_otherdoc_id;


ALTER VIEW public.v_exam_risk_tag_doc OWNER TO postgres;

--
-- TOC entry 342 (class 1259 OID 16869)
-- Name: v_notremoveddocument; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_notremoveddocument AS
 SELECT document.id,
    document.file,
    document.realfilename,
    document.folder,
    document.type,
    document.creation_date,
    document.removed,
    document.revision,
    document.label,
    document.comment,
    document.uploadedby,
    document.doc_master_id,
    document.sourcefile,
    document.sourcerealfilename
   FROM public.document,
    public.document_master
  WHERE ((document.removed = false) AND (document_master.removed = false) AND (document.doc_master_id = document_master.id));


ALTER VIEW public.v_notremoveddocument OWNER TO postgres;

--
-- TOC entry 343 (class 1259 OID 16873)
-- Name: v_staff_member_depaccess; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_staff_member_depaccess AS
 SELECT DISTINCT dp.id AS dep_id,
    idbj.staff_id
   FROM public.department dp,
    ( SELECT DISTINCT
                CASE
                    WHEN (staff_role.scope_id = 0) THEN vfd.inst_id
                    ELSE NULL::integer
                END AS inst_id,
                CASE
                    WHEN (staff_role.scope_id = 0) THEN NULL::integer
                    ELSE vfd.dep_id
                END AS dep_id,
            staff_job.staff_id
           FROM public.staff_job,
            public.staff_role,
            public.v_fullinfo_department vfd
          WHERE ((staff_job.removed = false) AND (staff_role.removed = false) AND (staff_role.id = staff_job.staff_role_id) AND (staff_job.begdate <= now()) AND (now() <= staff_job.enddate) AND (staff_job.dep_id <> '-1'::integer) AND (vfd.dep_id = staff_job.dep_id))
        UNION
         SELECT NULL::integer AS int4,
            vfd.dep_id,
            staff_member.id
           FROM public.staff_member,
            public.v_fullinfo_department vfd
          WHERE ((staff_member.login_role_id = 0) AND (vfd.dep_id <> '-1'::integer))) idbj
  WHERE ((idbj.inst_id = dp.inst_id) OR (idbj.dep_id = dp.id));


ALTER VIEW public.v_staff_member_depaccess OWNER TO postgres;

--
-- TOC entry 344 (class 1259 OID 16878)
-- Name: v_staff_member_historyjobdeplist; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_staff_member_historyjobdeplist AS
 SELECT DISTINCT vfd.dep_id,
    staff_job.staff_id
   FROM public.staff_job,
    public.staff_role,
    public.v_fullinfo_department vfd
  WHERE ((staff_job.removed = false) AND (staff_role.removed = false) AND (staff_role.id = staff_job.staff_role_id) AND (staff_job.dep_id <> '-1'::integer) AND (vfd.dep_id = staff_job.dep_id));


ALTER VIEW public.v_staff_member_historyjobdeplist OWNER TO postgres;

--
-- TOC entry 345 (class 1259 OID 16882)
-- Name: v_staff_member_historyjobdeptagidlist; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_staff_member_historyjobdeptagidlist AS
 SELECT v_staff_member_historyjobdeplist.staff_id,
    ((('{'::text || string_agg((tag_link.tag_id)::text, ','::text)) || '}'::text))::integer[] AS deptagidlist,
    ((('{'::text || string_agg((tag_link.ext_id)::text, ','::text)) || '}'::text))::integer[] AS depidlist
   FROM public.v_staff_member_historyjobdeplist,
    public.tag_link
  WHERE (((tag_link.type)::text = 'department'::text) AND (tag_link.ext_id = v_staff_member_historyjobdeplist.dep_id))
  GROUP BY v_staff_member_historyjobdeplist.staff_id;


ALTER VIEW public.v_staff_member_historyjobdeptagidlist OWNER TO postgres;

--
-- TOC entry 346 (class 1259 OID 16886)
-- Name: v_staffmember_taglistdep_active_staffjob; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_staffmember_taglistdep_active_staffjob AS
 SELECT ((('{'::text || COALESCE(string_agg(DISTINCT (tag_link.tag_id)::text, ','::text), ''::text)) || '}'::text))::integer[] AS taglistdep_id,
    staff_job.staff_id
   FROM public.staff_job,
    public.department,
    public.tag_link
  WHERE ((staff_job.removed = false) AND (department.removed = false) AND (staff_job.begdate <= now()) AND (staff_job.enddate >= now()) AND (department.id = staff_job.dep_id) AND (tag_link.ext_id = department.id) AND ((tag_link.type)::text = 'department'::text))
  GROUP BY staff_job.staff_id;


ALTER VIEW public.v_staffmember_taglistdep_active_staffjob OWNER TO postgres;

--
-- TOC entry 347 (class 1259 OID 16891)
-- Name: v_survey; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_survey AS
 SELECT survey_field.survey_id,
    survey_field.id AS field_id,
    survey_field.type AS field_type,
    survey_field."position"
   FROM public.survey,
    public.survey_field
  WHERE (survey.id = survey_field.survey_id);


ALTER VIEW public.v_survey OWNER TO postgres;

--
-- TOC entry 348 (class 1259 OID 16895)
-- Name: v_taginfo; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.v_taginfo AS
 SELECT tt.id,
    tt.link_type,
    tt.ext_id,
    tt.tag_id,
    tt.type,
    tt.alltagidallow,
    tt.name,
    tt.removed,
    (((('{'::text || string_agg(v1.tagdepidforinsttagid, ','::text)) || '}'::text))::integer[] || ((('{'::text || string_agg((v2.insttagid)::text, ','::text)) || '}'::text))::integer[]) AS alltagidinducedallow
   FROM ((( SELECT tag_link.id,
            tag_link.type AS link_type,
            tag_link.ext_id,
            tag_link.tag_id,
            tag.type,
            ((('{'::text || string_agg((tag_link.tag_id)::text, ','::text) OVER (PARTITION BY tag_link.type, tag_link.ext_id)) || '}'::text))::integer[] AS alltagidallow,
            ((('{'::text || string_agg(
                CASE
                    WHEN ((tag.type)::text = 'OR'::text) THEN (tag_link.tag_id)::text
                    ELSE NULL::text
                END, ','::text) OVER (PARTITION BY tag_link.type, tag_link.ext_id)) || '}'::text))::integer[] AS tagtomapinstid,
            tag.name,
            tag.removed
           FROM public.tag_link,
            public.tag
          WHERE (tag.id = tag_link.tag_id)) tt
     LEFT JOIN public.v_deptagidbyinsttagid v1 ON ((v1.insttagid = ANY (tt.alltagidallow))))
     LEFT JOIN public.v_deptagidbyinsttagid v2 ON ((((('{'::text || v2.tagdepidforinsttagid) || '}'::text))::integer[] && tt.tagtomapinstid)))
  GROUP BY tt.id, tt.link_type, tt.ext_id, tt.tag_id, tt.type, tt.alltagidallow, tt.name, tt.removed;


ALTER VIEW public.v_taginfo OWNER TO postgres;

--
-- TOC entry 350 (class 1259 OID 16904)
-- Name: xusercfg; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.xusercfg (
    id integer NOT NULL,
    data character varying,
    cfgparameter_id integer NOT NULL
);


ALTER TABLE public.xusercfg OWNER TO postgres;

--
-- TOC entry 351 (class 1259 OID 16909)
-- Name: xusercfgparameter; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.xusercfgparameter (
    cfgparameter_id integer NOT NULL,
    vtype integer,
    type integer DEFAULT 1,
    vorder integer,
    variable character varying NOT NULL,
    label character varying NOT NULL,
    description character varying,
    vdefault character varying
);


ALTER TABLE public.xusercfgparameter OWNER TO postgres;

--
-- TOC entry 3825 (class 2604 OID 16915)
-- Name: action id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.action ALTER COLUMN id SET DEFAULT nextval('public.action_id_seq'::regclass);


--
-- TOC entry 3828 (class 2604 OID 16916)
-- Name: action_link id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.action_link ALTER COLUMN id SET DEFAULT nextval('public.action_link_id_seq'::regclass);


--
-- TOC entry 3829 (class 2604 OID 16917)
-- Name: afcnsend id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.afcnsend ALTER COLUMN id SET DEFAULT nextval('public.afcnsend_id_seq'::regclass);


--
-- TOC entry 3831 (class 2604 OID 16918)
-- Name: agelist id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.agelist ALTER COLUMN id SET DEFAULT nextval('public.agelist_id_seq'::regclass);


--
-- TOC entry 3832 (class 2604 OID 16919)
-- Name: audit id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.audit ALTER COLUMN id SET DEFAULT nextval('public.audit_id_seq'::regclass);


--
-- TOC entry 3837 (class 2604 OID 16920)
-- Name: audit_record id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.audit_record ALTER COLUMN id SET DEFAULT nextval('public.audit_record_id_seq'::regclass);


--
-- TOC entry 3839 (class 2604 OID 16921)
-- Name: audit_recordprocedure id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.audit_recordprocedure ALTER COLUMN id SET DEFAULT nextval('public.audit_recordprocedure_id_seq'::regclass);


--
-- TOC entry 3841 (class 2604 OID 16922)
-- Name: audit_subrecord id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.audit_subrecord ALTER COLUMN id SET DEFAULT nextval('public.audit_subrecord_id_seq'::regclass);


--
-- TOC entry 3843 (class 2604 OID 16923)
-- Name: audit_type id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.audit_type ALTER COLUMN id SET DEFAULT nextval('public.audit_type_id_seq'::regclass);


--
-- TOC entry 3845 (class 2604 OID 16924)
-- Name: civilitylist id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.civilitylist ALTER COLUMN id SET DEFAULT nextval('public.civilitylist_id_seq'::regclass);


--
-- TOC entry 3846 (class 2604 OID 16925)
-- Name: department id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.department ALTER COLUMN id SET DEFAULT nextval('public.department_id_seq'::regclass);


--
-- TOC entry 3848 (class 2604 OID 16926)
-- Name: device id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.device ALTER COLUMN id SET DEFAULT nextval('public.device_id_seq'::regclass);


--
-- TOC entry 3851 (class 2604 OID 16927)
-- Name: device_inspection id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.device_inspection ALTER COLUMN id SET DEFAULT nextval('public.device_inspection_id_seq'::regclass);


--
-- TOC entry 3853 (class 2604 OID 16928)
-- Name: device_installation id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.device_installation ALTER COLUMN id SET DEFAULT nextval('public.device_installation_id_seq'::regclass);


--
-- TOC entry 3858 (class 2604 OID 16929)
-- Name: device_maintenance id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.device_maintenance ALTER COLUMN id SET DEFAULT nextval('public.device_maintenance_id_seq'::regclass);


--
-- TOC entry 3947 (class 2604 OID 17525)
-- Name: devicetypelist id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.devicetypelist ALTER COLUMN id SET DEFAULT nextval('public.devicetypelist_id_seq'::regclass);


--
-- TOC entry 3860 (class 2604 OID 16930)
-- Name: document id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.document ALTER COLUMN id SET DEFAULT nextval('public.document_id_seq'::regclass);


--
-- TOC entry 3870 (class 2604 OID 16931)
-- Name: document_link id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.document_link ALTER COLUMN id SET DEFAULT nextval('public.document_link_id_seq'::regclass);


--
-- TOC entry 3871 (class 2604 OID 16932)
-- Name: document_master id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.document_master ALTER COLUMN id SET DEFAULT nextval('public.document_master_id_seq'::regclass);


--
-- TOC entry 3873 (class 2604 OID 16933)
-- Name: documentstatus id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.documentstatus ALTER COLUMN id SET DEFAULT nextval('public.documentstatus_id_seq'::regclass);


--
-- TOC entry 3875 (class 2604 OID 16934)
-- Name: documenttypelist id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.documenttypelist ALTER COLUMN id SET DEFAULT nextval('public.documenttypelist_id_seq'::regclass);


--
-- TOC entry 3876 (class 2604 OID 16935)
-- Name: examident id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.examident ALTER COLUMN id SET DEFAULT nextval('public.examident_id_seq'::regclass);


--
-- TOC entry 3878 (class 2604 OID 16936)
-- Name: examlist id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.examlist ALTER COLUMN id SET DEFAULT nextval('public.examlist_id_seq'::regclass);


--
-- TOC entry 3880 (class 2604 OID 16937)
-- Name: examwarning id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.examwarning ALTER COLUMN id SET DEFAULT nextval('public.examwarning_id_seq'::regclass);


--
-- TOC entry 3882 (class 2604 OID 16938)
-- Name: external_link id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.external_link ALTER COLUMN id SET DEFAULT nextval('public.external_link_id_seq'::regclass);


--
-- TOC entry 3883 (class 2604 OID 16939)
-- Name: external_src id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.external_src ALTER COLUMN id SET DEFAULT nextval('public.external_src_id_seq'::regclass);


--
-- TOC entry 3884 (class 2604 OID 16940)
-- Name: institution id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.institution ALTER COLUMN id SET DEFAULT nextval('public.institution_id_seq'::regclass);


--
-- TOC entry 3886 (class 2604 OID 16941)
-- Name: legaldocument id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.legaldocument ALTER COLUMN id SET DEFAULT nextval('public.legaldocument_id_seq'::regclass);


--
-- TOC entry 3888 (class 2604 OID 16942)
-- Name: login_role id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.login_role ALTER COLUMN id SET DEFAULT nextval('public.login_role_id_seq'::regclass);


--
-- TOC entry 3890 (class 2604 OID 16943)
-- Name: login_role_permission id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.login_role_permission ALTER COLUMN id SET DEFAULT nextval('public.login_role_permission_id_seq'::regclass);


--
-- TOC entry 3897 (class 2604 OID 16944)
-- Name: procedure id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.procedure ALTER COLUMN id SET DEFAULT nextval('public.procedure_id_seq'::regclass);


--
-- TOC entry 3899 (class 2604 OID 16945)
-- Name: quaad_description id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.quaad_description ALTER COLUMN id SET DEFAULT nextval('public.quaad_description_id_seq'::regclass);


--
-- TOC entry 3900 (class 2604 OID 16946)
-- Name: quaad_point id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.quaad_point ALTER COLUMN id SET DEFAULT nextval('public.quaad_point_id_seq'::regclass);


--
-- TOC entry 3908 (class 2604 OID 16947)
-- Name: quaadpoint_tag id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.quaadpoint_tag ALTER COLUMN id SET DEFAULT nextval('public.quaadpoint_tag_id_seq'::regclass);


--
-- TOC entry 3914 (class 2604 OID 16948)
-- Name: quaadpoint_tag_name id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.quaadpoint_tag_name ALTER COLUMN id SET DEFAULT nextval('public.quaadpoint_tag_name_id_seq'::regclass);


--
-- TOC entry 3916 (class 2604 OID 16949)
-- Name: report id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.report ALTER COLUMN id SET DEFAULT nextval('public.report_id_seq'::regclass);


--
-- TOC entry 3921 (class 2604 OID 16950)
-- Name: sexlist id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.sexlist ALTER COLUMN id SET DEFAULT nextval('public.sexlist_id_seq'::regclass);


--
-- TOC entry 3922 (class 2604 OID 16951)
-- Name: staff_formation id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.staff_formation ALTER COLUMN id SET DEFAULT nextval('public.staff_formation_id_seq'::regclass);


--
-- TOC entry 3924 (class 2604 OID 16952)
-- Name: staff_job id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.staff_job ALTER COLUMN id SET DEFAULT nextval('public.staff_job_id_seq'::regclass);


--
-- TOC entry 3928 (class 2604 OID 16953)
-- Name: staff_member id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.staff_member ALTER COLUMN id SET DEFAULT nextval('public.staff_member_id_seq'::regclass);


--
-- TOC entry 3931 (class 2604 OID 16954)
-- Name: staff_role id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.staff_role ALTER COLUMN id SET DEFAULT nextval('public.staff_role_id_seq'::regclass);


--
-- TOC entry 3934 (class 2604 OID 16955)
-- Name: statuslist id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.statuslist ALTER COLUMN id SET DEFAULT nextval('public.statuslist_id_seq'::regclass);


--
-- TOC entry 3935 (class 2604 OID 16956)
-- Name: survey id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.survey ALTER COLUMN id SET DEFAULT nextval('public.survey_id_seq'::regclass);


--
-- TOC entry 3937 (class 2604 OID 16957)
-- Name: survey_field id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.survey_field ALTER COLUMN id SET DEFAULT nextval('public.survey_field_id_seq'::regclass);


--
-- TOC entry 3939 (class 2604 OID 16958)
-- Name: survey_field_type id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.survey_field_type ALTER COLUMN id SET DEFAULT nextval('public.survey_field_type_id_seq'::regclass);


--
-- TOC entry 3940 (class 2604 OID 16959)
-- Name: survey_resp id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.survey_resp ALTER COLUMN id SET DEFAULT nextval('public.survey_resp_id_seq'::regclass);


--
-- TOC entry 3941 (class 2604 OID 16960)
-- Name: survey_resp_field id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.survey_resp_field ALTER COLUMN id SET DEFAULT nextval('public.survey_resp_field_id_seq'::regclass);


--
-- TOC entry 3942 (class 2604 OID 16961)
-- Name: survey_type id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.survey_type ALTER COLUMN id SET DEFAULT nextval('public.survey_type_id_seq'::regclass);


--
-- TOC entry 3943 (class 2604 OID 16962)
-- Name: tag id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.tag ALTER COLUMN id SET DEFAULT nextval('public.tag_id_seq'::regclass);


--
-- TOC entry 3945 (class 2604 OID 16963)
-- Name: tag_link id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.tag_link ALTER COLUMN id SET DEFAULT nextval('public.tag_link_id_seq'::regclass);


--
-- TOC entry 3956 (class 2604 OID 26702)
-- Name: task id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.task ALTER COLUMN id SET DEFAULT nextval('public.task_id_seq'::regclass);


--
-- TOC entry 3957 (class 2604 OID 26709)
-- Name: task task_master_id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.task ALTER COLUMN task_master_id SET DEFAULT nextval('public.task_task_master_id_seq'::regclass);


--
-- TOC entry 3961 (class 2604 OID 26765)
-- Name: task_link id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.task_link ALTER COLUMN id SET DEFAULT nextval('public.task_link_id_seq'::regclass);


--
-- TOC entry 3948 (class 2604 OID 26652)
-- Name: task_master id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.task_master ALTER COLUMN id SET DEFAULT nextval('public.task_master_id_seq'::regclass);


--
-- TOC entry 3960 (class 2604 OID 26757)
-- Name: task_master_link id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.task_master_link ALTER COLUMN id SET DEFAULT nextval('public.task_master_link_id_seq'::regclass);


--
-- TOC entry 4325 (class 0 OID 16397)
-- Dependencies: 216
-- Data for Name: action; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.action VALUES (8, 'BBBBBBBBBBBBBBB', NULL, 'AAAAAAAAAA', '2024-08-16 00:00:00+02', NULL, '2024-08-14 00:00:00+02', NULL, true, -1, NULL);
INSERT INTO public.action VALUES (3, 'New task', 3, 'Interne', '2024-08-14 00:00:00+02', NULL, '2023-12-12 00:00:00+01', 0, false, 1, NULL);
INSERT INTO public.action VALUES (9, 'New', NULL, NULL, NULL, NULL, '2024-09-30 00:00:00+02', NULL, true, -1, NULL);
INSERT INTO public.action VALUES (7, 'New', 4, '', '2024-08-28 00:00:00+02', '2025-03-06 00:00:00+01', '2024-08-13 00:00:00+02', 14, false, 2, NULL);
INSERT INTO public.action VALUES (10, 'New', NULL, '', NULL, NULL, '2025-05-28 00:00:00+02', 15, false, 1, NULL);
INSERT INTO public.action VALUES (11, 'New', 3, 'Interne', NULL, NULL, '2025-06-10 00:00:00+02', 13, false, 3, NULL);
INSERT INTO public.action VALUES (2, 'Remplacer tube RX2000', 4, '', '2021-04-09 00:00:00+02', '2025-03-14 00:00:00+01', '2021-03-22 00:00:00+01', 0, false, 2, NULL);
INSERT INTO public.action VALUES (12, 'New', NULL, NULL, NULL, NULL, '2025-06-10 00:00:00+02', NULL, false, -1, NULL);


--
-- TOC entry 4327 (class 0 OID 16405)
-- Dependencies: 218
-- Data for Name: action_link; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.action_link VALUES (19, 7, 8, 'device_inspection');
INSERT INTO public.action_link VALUES (25, 3, 8, 'device_inspection');
INSERT INTO public.action_link VALUES (29, 3, 25, 'report');
INSERT INTO public.action_link VALUES (30, 2, 25, 'report');
INSERT INTO public.action_link VALUES (32, 2, 1, 'survey');
INSERT INTO public.action_link VALUES (35, 7, 5, 'device_inspection');
INSERT INTO public.action_link VALUES (36, 3, 5, 'device_inspection');


--
-- TOC entry 4329 (class 0 OID 16411)
-- Dependencies: 220
-- Data for Name: action_status_link; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.action_status_link VALUES (15, 330, NULL, NULL, 1, '2025-05-15 09:45:29.923186', NULL);
INSERT INTO public.action_status_link VALUES (15, 329, NULL, NULL, 1, '2025-05-14 17:57:28.908729', NULL);
INSERT INTO public.action_status_link VALUES (12, 329, NULL, NULL, 1, '2025-05-16 16:06:04.610289', '2025-05-16 16:15:07.736839');
INSERT INTO public.action_status_link VALUES (12, 329, NULL, NULL, 0, '2025-05-14 17:56:03.117503', '2025-05-16 16:15:07.736839');
INSERT INTO public.action_status_link VALUES (16, 330, NULL, NULL, 0, '2025-05-12 17:56:17.094', '2025-05-16 16:15:12.306363');
INSERT INTO public.action_status_link VALUES (16, 330, NULL, NULL, 1, '2025-05-15 09:45:29.924615', '2025-05-16 16:15:12.306363');
INSERT INTO public.action_status_link VALUES (14, 329, NULL, NULL, 1, '2025-05-16 16:06:04.62151', '2025-05-16 16:21:07.59762');
INSERT INTO public.action_status_link VALUES (12, 330, NULL, NULL, 1, '2025-05-15 09:45:29.912307', '2025-05-21 11:10:47.132773');
INSERT INTO public.action_status_link VALUES (12, 425, NULL, NULL, 2, '2025-05-23 14:13:30.793208', NULL);
INSERT INTO public.action_status_link VALUES (14, 425, NULL, NULL, 0, '2025-05-23 14:13:49.527761', NULL);
INSERT INTO public.action_status_link VALUES (12, 416, NULL, NULL, 0, '2025-05-23 15:39:17.973869', NULL);
INSERT INTO public.action_status_link VALUES (12, 418, NULL, NULL, 2, '2025-05-23 15:41:24.359158', NULL);
INSERT INTO public.action_status_link VALUES (12, 414, NULL, NULL, 2, '2025-05-23 15:45:49.605059', NULL);
INSERT INTO public.action_status_link VALUES (14, 414, NULL, NULL, 2, '2025-05-23 15:45:49.60919', NULL);
INSERT INTO public.action_status_link VALUES (15, 414, NULL, NULL, 2, '2025-05-23 15:45:49.611954', NULL);
INSERT INTO public.action_status_link VALUES (16, 414, NULL, NULL, 2, '2025-05-23 15:45:49.615486', NULL);
INSERT INTO public.action_status_link VALUES (16, 427, NULL, NULL, 1, '2025-05-23 15:46:53.900845', NULL);
INSERT INTO public.action_status_link VALUES (12, 430, NULL, NULL, 2, '2025-05-23 16:01:32.382957', NULL);
INSERT INTO public.action_status_link VALUES (14, 430, NULL, NULL, 2, '2025-05-23 16:01:32.38906', NULL);
INSERT INTO public.action_status_link VALUES (16, 311, NULL, NULL, 2, '2025-05-23 17:19:19.516343', NULL);
INSERT INTO public.action_status_link VALUES (16, 311, NULL, NULL, 1, '2025-05-23 17:20:21.472902', NULL);
INSERT INTO public.action_status_link VALUES (14, 454, NULL, NULL, 1, '2025-06-03 17:01:55.435576', NULL);
INSERT INTO public.action_status_link VALUES (15, 454, NULL, NULL, 1, '2025-06-03 17:01:55.466174', NULL);
INSERT INTO public.action_status_link VALUES (14, 330, NULL, NULL, 0, '2025-05-10 17:56:42.313', '2025-06-03 17:20:11.303954');
INSERT INTO public.action_status_link VALUES (14, 330, NULL, NULL, 1, '2025-05-15 09:45:29.921768', '2025-06-03 17:20:11.303954');
INSERT INTO public.action_status_link VALUES (16, 458, NULL, NULL, 1, '2025-06-17 15:27:06.716919', NULL);
INSERT INTO public.action_status_link VALUES (14, 458, NULL, NULL, 1, '2025-06-17 15:30:30.025968', NULL);


--
-- TOC entry 4330 (class 0 OID 16414)
-- Dependencies: 221
-- Data for Name: afcnsend; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.afcnsend VALUES (8, NULL, NULL, NULL, 'New sending', '2021-03-11 12:27:13.099173+01', 0, NULL, true, NULL);
INSERT INTO public.afcnsend VALUES (10, 1, 2, NULL, 'Rapport dosimètres', '2021-03-11 00:00:00+01', 0, 'Rapport dosimètres', true, 4);
INSERT INTO public.afcnsend VALUES (11, 1, 2, 11, 'Titre 001', '2025-01-14 00:00:00+01', 0, 'Titre 001', false, 4);
INSERT INTO public.afcnsend VALUES (9, 1, 2, 12, 'rapport dosimétrie 2020', '2020-12-31 00:00:00+01', 0, 'rapport dosimétrie 2020', false, 4);
INSERT INTO public.afcnsend VALUES (12, 2, 6, NULL, 'New sending', '2025-01-15 00:00:00+01', 0, 'New sending', false, 4);
INSERT INTO public.afcnsend VALUES (16, -1, -1, NULL, 'New sending', '2025-02-05 17:21:59.661234+01', 0, NULL, true, 3);
INSERT INTO public.afcnsend VALUES (14, -1, -1, NULL, 'New sending', '2025-01-16 09:18:52.894812+01', 0, NULL, true, 3);
INSERT INTO public.afcnsend VALUES (15, -1, -1, NULL, 'New sending', '2025-01-16 11:38:32.671429+01', 0, NULL, true, 3);
INSERT INTO public.afcnsend VALUES (13, 1, 4, 10, 'New sending', '2025-02-01 00:00:00+01', 0, 'New sending', false, 3);


--
-- TOC entry 4332 (class 0 OID 16421)
-- Dependencies: 223
-- Data for Name: agelist; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.agelist VALUES (0, 'Infant');
INSERT INTO public.agelist VALUES (1, 'Child');
INSERT INTO public.agelist VALUES (2, 'Adult');
INSERT INTO public.agelist VALUES (3, 'All');


--
-- TOC entry 4334 (class 0 OID 16427)
-- Dependencies: 225
-- Data for Name: audit; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.audit VALUES (13, 1, 2, '2023-08-21 00:00:00+02', 1, 'New audit', '', 3, NULL, true, 4, '2023-08-21 00:00:00+02', '2023-08-21 00:00:00+02');
INSERT INTO public.audit VALUES (11, 1, 2, '2023-03-13 00:00:00+01', 2, 'Auto-audit B-QUAADRIL - 2023', '', 4, NULL, false, 1, '2022-04-07 00:00:00+02', '2023-03-13 00:00:00+01');
INSERT INTO public.audit VALUES (16, -1, -1, '2024-08-16 16:28:43.264387+02', 0, 'New audit', NULL, 3, NULL, true, 2, '2024-08-16 16:28:43+02', '2024-08-16 16:28:43+02');
INSERT INTO public.audit VALUES (15, -1, -1, '2024-08-16 16:27:26.638303+02', 0, 'New audit', NULL, 3, NULL, true, 2, '2024-08-16 16:27:27+02', '2024-08-16 16:27:27+02');
INSERT INTO public.audit VALUES (12, 2, 7, '2023-03-20 00:00:00+01', 0, 'Test 001', 'Rem', 3, NULL, true, 4, '2023-03-20 00:00:00+01', '2023-03-20 00:00:00+01');
INSERT INTO public.audit VALUES (17, 1, 4, '2025-03-06 00:00:00+01', 2, 'Test 002', '', 4, NULL, false, 4, '2025-03-06 00:00:00+01', '2025-03-06 00:00:00+01');
INSERT INTO public.audit VALUES (20, 2, 7, '2025-03-06 00:00:00+01', 1, 'Test 003', '', 4, NULL, false, 1, '2025-03-06 00:00:00+01', '2025-03-07 00:00:00+01');
INSERT INTO public.audit VALUES (19, -1, -1, '2025-03-06 11:02:16.790735+01', 0, 'New audit', NULL, 3, NULL, true, 2, '2025-03-06 11:02:17+01', '2025-03-06 11:02:17+01');
INSERT INTO public.audit VALUES (18, -1, -1, '2025-03-06 11:01:45.627996+01', 0, 'New audit', NULL, 3, NULL, true, 2, '2025-03-06 11:01:46+01', '2025-03-06 11:01:46+01');
INSERT INTO public.audit VALUES (14, 1, 2, '2023-09-28 00:00:00+02', 1, 'Audit selon NF S-99-300  - 2023', 'Test remarque.', 3, NULL, false, 4, '2022-12-14 00:00:00+01', '2023-09-28 00:00:00+02');


--
-- TOC entry 4336 (class 0 OID 16437)
-- Dependencies: 227
-- Data for Name: audit_record; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.audit_record VALUES (409, 11, 10, false);
INSERT INTO public.audit_record VALUES (410, 11, 5, false);
INSERT INTO public.audit_record VALUES (411, 11, 62, false);
INSERT INTO public.audit_record VALUES (415, 11, 9, false);
INSERT INTO public.audit_record VALUES (422, 11, 6, true);
INSERT INTO public.audit_record VALUES (412, 11, 4, true);


--
-- TOC entry 4338 (class 0 OID 16442)
-- Dependencies: 229
-- Data for Name: audit_recordprocedure; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.audit_recordprocedure VALUES (111, 422, 6, 326, 'Test.', true, NULL);
INSERT INTO public.audit_recordprocedure VALUES (112, 412, 2, 325, '', true, NULL);


--
-- TOC entry 4340 (class 0 OID 16449)
-- Dependencies: 231
-- Data for Name: audit_subrecord; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.audit_subrecord VALUES (357, 411, 53, 92, -1, '', -1, 'Mis à jour en 07/2023', true, false, 128, NULL);
INSERT INTO public.audit_subrecord VALUES (359, 410, 2, 9, -1, NULL, NULL, 'Disponible au format papier dans la salle', false, true, -1, NULL);
INSERT INTO public.audit_subrecord VALUES (360, 410, 2, 10, -1, NULL, NULL, 'a retrouver', false, false, -1, NULL);
INSERT INTO public.audit_subrecord VALUES (361, 415, 9, 11, -1, NULL, NULL, 'Disponible en papier dans la salle armoire 2', false, true, -1, NULL);
INSERT INTO public.audit_subrecord VALUES (372, 412, 1, 1, -1, NULL, NULL, 'En attente.', false, true, -1, NULL);


--
-- TOC entry 4342 (class 0 OID 16456)
-- Dependencies: 233
-- Data for Name: audit_type; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.audit_type VALUES (2, 'Other', 'false', NULL);
INSERT INTO public.audit_type VALUES (1, 'B-QUAADRIL(2019/07)', 'false', 'QUAADRIL');
INSERT INTO public.audit_type VALUES (3, 'BQUANUM(2019/07)', 'false', 'QUANUM');
INSERT INTO public.audit_type VALUES (4, 'NF S-99-300', 'false', 'NF S99-300');


--
-- TOC entry 4344 (class 0 OID 16463)
-- Dependencies: 235
-- Data for Name: civilitylist; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.civilitylist VALUES (1, 'Mrs.');
INSERT INTO public.civilitylist VALUES (0, 'Mr.');
INSERT INTO public.civilitylist VALUES (2, 'Miss');
INSERT INTO public.civilitylist VALUES (3, 'Dr.');
INSERT INTO public.civilitylist VALUES (4, 'Prof.');
INSERT INTO public.civilitylist VALUES (5, 'Mx.');


--
-- TOC entry 4346 (class 0 OID 16469)
-- Dependencies: 237
-- Data for Name: default_action_needed; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('afcnsend', 2, 4, 200, 0);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('examlist', 2, 4, 207, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('examlist', 1, 4, 208, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('examlist', 2, 1, 209, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('examlist', 1, 1, 210, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('examlist', 2, 2, 211, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('examlist', 1, 2, 212, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('afcnsend', 2, 4, 213, 2);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('afcnsend', 1, 1, 214, 2);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('examlist_otherdocument', 3, 4, 183, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('examlist_otherdocument', 2, 2, 184, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('procedure', 2, 2, 186, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('institution', 1, 1, 193, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('institution', 10, 1, 194, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('institution', 1, 2, 195, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('institution', 1, 7, 196, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('institution', 1, 6, 197, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('institution', 10, 6, 198, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('audit', 2, 1, 18, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('audit', 1, 1, 19, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('audit', 4, 1, 20, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('audit', 3, 1, 21, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('audit', 2, 6, 22, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('audit', 1, 6, 23, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('audit', 4, 6, 24, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('audit', 3, 6, 25, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 2, 4, 26, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 5, 4, 27, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 1, 4, 28, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 4, 4, 29, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 3, 4, 30, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 2, 1, 31, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 5, 1, 32, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 1, 1, 33, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 4, 1, 34, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 3, 1, 35, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 2, 2, 36, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 5, 2, 37, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 1, 2, 38, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 4, 2, 39, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 3, 2, 40, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 2, 7, 41, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 5, 7, 42, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 1, 7, 43, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 4, 7, 44, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 3, 7, 45, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 2, 6, 46, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 5, 6, 47, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 1, 6, 48, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 4, 6, 49, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 3, 6, 50, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 2, 3, 51, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 5, 3, 52, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 1, 3, 53, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 4, 3, 54, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('legaldocument', 3, 3, 55, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('survey', 1, 1, 56, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('survey', 4, 1, 57, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('survey', 3, 1, 58, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('survey', 2, 6, 59, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('survey', 5, 6, 60, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('survey', 1, 6, 61, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('survey', 4, 6, 62, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('afcnsend', 3, 4, 63, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('afcnsend', 3, 1, 64, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('afcnsend', 3, 2, 65, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('afcnsend', 3, 7, 66, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('afcnsend', 3, 6, 67, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('afcnsend', 3, 3, 68, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('device', 1, 4, 69, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('device', 3, 4, 70, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('device', 1, 1, 71, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('device', 3, 1, 72, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('device', 1, 2, 73, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('device', 3, 2, 74, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('device', 1, 7, 75, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('device', 3, 7, 76, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('device', 1, 6, 77, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('device', 3, 6, 78, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('device', 1, 3, 79, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('device', 3, 3, 80, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('institution', 1, 3, 199, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_formation', 10, 4, 99, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_formation', 10, 1, 100, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_formation', 10, 2, 101, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_formation', 10, 7, 102, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_formation', 10, 6, 103, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_formation', 10, 3, 104, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('examlist', 2, 4, 201, 0);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('examlist', 2, 1, 202, 0);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('examlist', 2, 2, 203, 0);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('examlist', 2, 7, 204, 0);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('examlist', 2, 6, 205, 0);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('examlist', 2, 3, 206, 0);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('device', 2, 2, 215, 0);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('device', 5, 2, 216, 0);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('device', 1, 2, 217, 0);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('device', 10, 2, 218, 0);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('device', 4, 2, 219, 0);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('device', 3, 2, 220, 0);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('device_installation', 2, 2, 221, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('device_maintenance', 3, 2, 222, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 10, 4, 229, 2);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 10, 1, 230, 2);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 2, 2, 231, 2);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 5, 2, 232, 2);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 1, 2, 233, 2);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 10, 2, 234, 2);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 4, 2, 235, 2);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 3, 2, 236, 2);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 10, 7, 237, 2);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 10, 6, 238, 2);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 10, 3, 239, 2);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 10, 4, 240, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 10, 1, 241, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 2, 2, 242, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 5, 2, 243, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 1, 2, 244, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 10, 2, 245, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 4, 2, 246, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 3, 2, 247, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 10, 7, 248, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 10, 6, 249, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('staff_member', 10, 3, 250, 1);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('report', 2, 4, 251, 2);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('report', 5, 4, 252, 2);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('report', 1, 4, 253, 2);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('report', 10, 4, 254, 2);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('report', 4, 4, 255, 2);
INSERT INTO public.default_action_needed OVERRIDING SYSTEM VALUE VALUES ('report', 3, 4, 256, 2);


--
-- TOC entry 4348 (class 0 OID 16475)
-- Dependencies: 239
-- Data for Name: department; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.department VALUES (-1, 'Undef', -1, true);
INSERT INTO public.department VALUES (1, 'Qualité', 1, false);
INSERT INTO public.department VALUES (2, 'Radiologie', 1, false);
INSERT INTO public.department VALUES (4, 'Médecine nucléaire', 1, false);
INSERT INTO public.department VALUES (5, 'New department', 1, true);
INSERT INTO public.department VALUES (6, 'Qualité', 2, false);
INSERT INTO public.department VALUES (3, 'Radiologie', 2, false);
INSERT INTO public.department VALUES (7, 'Médecine nucléaire', 2, false);
INSERT INTO public.department VALUES (8, 'New department', 1, true);
INSERT INTO public.department VALUES (9, 'New departmenttttt', 1, true);
INSERT INTO public.department VALUES (10, 'New department', 5, true);


--
-- TOC entry 4350 (class 0 OID 16482)
-- Dependencies: 241
-- Data for Name: device; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.device VALUES (13, 'New device', NULL, NULL, NULL, false, NULL, NULL, NULL, 'RX', NULL, 0);
INSERT INTO public.device VALUES (16, 'New device', NULL, NULL, NULL, false, NULL, NULL, NULL, 'RX', NULL, 0);
INSERT INTO public.device VALUES (11, 'Scanner', 'Siemens', '', '123453', false, 'null', 'PACS', 'DACS', 'CT', '\x[encoded data, 10434 characters]', 0);
INSERT INTO public.device VALUES (17, 'New device', NULL, NULL, NULL, false, NULL, NULL, NULL, 'RX', NULL, 0);
INSERT INTO public.device VALUES (18, 'New device', NULL, NULL, NULL, false, NULL, NULL, NULL, 'RX', NULL, 0);
INSERT INTO public.device VALUES (19, 'New device', NULL, NULL, NULL, false, NULL, NULL, NULL, 'RX', NULL, 0);
INSERT INTO public.device VALUES (10, 'RX', 'Ximeo', '', '123456', false, '0', 'PACS', 'DACS', 'RX', '\x[encoded data, 8730 characters]', 0);
INSERT INTO public.device VALUES (12, 'Mammo', 'ximeo', '', '123456', false, '5', 'PACS', 'DACS', 'MG', '\x[encoded data, 6612 characters]', 0);
INSERT INTO public.device VALUES (31, 'Réfrigérateur 2', 'Philips', 'PH001', '321', false, 'null', 'PACS', 'DACS', 'RX', NULL, 4);
INSERT INTO public.device VALUES (29, 'New device', 'Brand', NULL, NULL, true, NULL, NULL, NULL, 'RX', NULL, 0);
INSERT INTO public.device VALUES (30, 'Réfrigérateur 1', 'Frigo', 'AZE', '76565654433', false, 'null', 'PACS', 'DACS', 'RX', '\x[encoded data, 7678 characters]', 4);
INSERT INTO public.device VALUES (34, 'New device', 'Brand', NULL, NULL, false, NULL, NULL, NULL, 'RX', NULL, 0);
INSERT INTO public.device VALUES (33, 'New device1111', 'Brand', '', '', false, 'null', 'PACS', 'DACS', 'RX', NULL, 0);
INSERT INTO public.device VALUES (28, 'Chariot 1', 'Brand', '', '', false, 'null', 'PACS', 'DACS', 'RX', '\x[encoded data, 95072 characters]', 2);
INSERT INTO public.device VALUES (27, 'IRM 1', 'GE', 'MR412', '', false, 'null', 'PACS', 'DACS', 'MR', NULL, 0);
INSERT INTO public.device VALUES (32, 'Injecteur 1', 'Brand', 'BF12', 'XD654321', false, 'null', 'PACS', 'DACS', 'RX', NULL, 1);


--
-- TOC entry 4352 (class 0 OID 16490)
-- Dependencies: 243
