--Order 20010966.50

COMMENT ON COLUMN WEBUSER.ALLOWDELIVERYREALLOC IS 'Obsolete';



COMMENT ON COLUMN WEBUSER.ALLOWPATIENTDAYENTRY IS 'Obsolete';



COMMENT ON COLUMN WEBUSER.ALLOWBUDGETENTRY IS 'Obsolete';



COMMENT ON COLUMN WEBUSER.ALLOWCOSTREPORTS IS 'Obsolete';



COMMENT ON COLUMN WEBUSER.ALLOWLOCKERENTRY IS 'Obsolete';



COMMENT ON COLUMN WEBUSER.ACCESSFINANCIALDETAILS IS 'Obsolete';

ALTER TABLE WEBUSER
	MODIFY ALLOWDELIVERYREALLOC DEFAULT 'N';

ALTER TABLE WEBUSER
	MODIFY ALLOWPATIENTDAYENTRY DEFAULT 'N';

ALTER TABLE WEBUSER
	MODIFY ALLOWBUDGETENTRY DEFAULT 'N';

ALTER TABLE WEBUSER
	MODIFY ALLOWCOSTREPORTS DEFAULT 'N';

ALTER TABLE WEBUSER
	MODIFY ALLOWLOCKERENTRY DEFAULT 'N';

ALTER TABLE WEBUSER
	MODIFY ACCESSFINANCIALDETAILS DEFAULT 'N';

CREATE SEQUENCE SEQ_WEBMENUDIALOG
START WITH 1
INCREMENT BY 1;

CREATE TABLE WEBMENUDIALOG
(
	WEBMENUDIALOG_ID     NUMBER NOT NULL ,
	WEBMENUGROUP_ID      NUMBER NOT NULL ,
	DIALOG_ID            NUMBER NOT NULL ,
	SEQUENCENUMBER       NUMBER DEFAULT  1  NOT NULL ,
	ACTIVE               VARCHAR2(1) DEFAULT  'Y'  NOT NULL  CONSTRAINT  YN_ValidationField33 CHECK (ACTIVE IN ('Y', 'N')),
	SYSTEMUSER_ID        NUMBER NOT NULL ,
	TIMESTAMP            DATE NOT NULL 
)
TABLESPACE ABS_DATA;




COMMENT ON COLUMN WEBMENUDIALOG.SEQUENCENUMBER IS 'Sequence of menu item within menu group. Can be defined from within application with Up-Down buttons.';



ALTER TABLE WEBMENUDIALOG
ADD CONSTRAINT  XPKWEBMENUDIALOG PRIMARY KEY (WEBMENUDIALOG_ID) USING INDEX TABLESPACE INDX;

CREATE  INDEX XIF1WEBMENUDIALOG ON WEBMENUDIALOG
(WEBMENUGROUP_ID   ASC) TABLESPACE INDX;

CREATE  INDEX XIF2WEBMENUDIALOG ON WEBMENUDIALOG
(DIALOG_ID   ASC) TABLESPACE INDX;

CREATE UNIQUE INDEX XAK1WEBMENUDIALOG ON WEBMENUDIALOG
(WEBMENUGROUP_ID   ASC,DIALOG_ID   ASC)
TABLESPACE INDX;



CREATE UNIQUE INDEX XAK2WEBMENUDIALOG ON WEBMENUDIALOG
(WEBMENUGROUP_ID   ASC,SEQUENCENUMBER   ASC)
TABLESPACE INDX;



CREATE TABLE WEBMENUDIALOG_DESC
(
	WEBMENUDIALOG_ID     NUMBER NOT NULL ,
	LANGUAGE_ID          NUMBER NOT NULL ,
	DESCRIPTION          VARCHAR2(40) NOT NULL ,
	SYSTEMUSER_ID        NUMBER NOT NULL ,
	TIMESTAMP            DATE NOT NULL 
)
TABLESPACE ABS_DATA;



ALTER TABLE WEBMENUDIALOG_DESC
ADD CONSTRAINT  XPKWEBMENUDIALOG_DESC PRIMARY KEY (WEBMENUDIALOG_ID,LANGUAGE_ID) USING INDEX TABLESPACE INDX;

CREATE  INDEX XIF1WEBMENUDIALOG_DESC ON WEBMENUDIALOG_DESC
(LANGUAGE_ID   ASC) TABLESPACE INDX;

CREATE  INDEX XIF2WEBMENUDIALOG_DESC ON WEBMENUDIALOG_DESC
(WEBMENUDIALOG_ID   ASC) TABLESPACE INDX;

CREATE SEQUENCE SEQ_WEBMENUGROUP
START WITH 1
INCREMENT BY 1;

CREATE TABLE WEBMENUGROUP
(
	WEBMENUGROUP_ID      NUMBER NOT NULL ,
	SEQUENCENUMBER       NUMBER DEFAULT  1  NOT NULL ,
	FACTORYDESCRIPTION   VARCHAR2(30) NULL ,
	ACTIVE               VARCHAR2(1) DEFAULT  'N'  NOT NULL  CONSTRAINT  YN_ValidationField34 CHECK (ACTIVE IN ('Y', 'N')),
	REMARK               VARCHAR2(80) NULL ,
	SYSTEMUSER_ID        NUMBER NOT NULL ,
	TIMESTAMP            DATE NOT NULL 
)
TABLESPACE ABS_DATA;




COMMENT ON COLUMN WEBMENUGROUP.SEQUENCENUMBER IS 'Sequence of menu group within menu. Can be defined from within application with Up-Down buttons.';



ALTER TABLE WEBMENUGROUP
ADD CONSTRAINT  XPKWEBMENUGROUP PRIMARY KEY (WEBMENUGROUP_ID) USING INDEX TABLESPACE INDX;



CREATE UNIQUE INDEX XAK1WEBMENUGROUP ON WEBMENUGROUP
(SEQUENCENUMBER   ASC)
TABLESPACE INDX;



CREATE TABLE WEBMENUGROUP_DESC
(
	WEBMENUGROUP_ID      NUMBER NOT NULL ,
	LANGUAGE_ID          NUMBER NOT NULL ,
	DESCRIPTION          VARCHAR2(40) NOT NULL ,
	SYSTEMUSER_ID        NUMBER NOT NULL ,
	TIMESTAMP            DATE NOT NULL 
)
TABLESPACE ABS_DATA;




ALTER TABLE WEBMENUGROUP_DESC
ADD CONSTRAINT  XPKWEBMENUGROUP_DESC PRIMARY KEY (WEBMENUGROUP_ID,LANGUAGE_ID) USING INDEX TABLESPACE INDX;

CREATE  INDEX XIF1WEBMENUGROUP_DESC ON WEBMENUGROUP_DESC
(LANGUAGE_ID   ASC) TABLESPACE INDX;

CREATE  INDEX XIF2WEBMENUGROUP_DESC ON WEBMENUGROUP_DESC
(WEBMENUGROUP_ID   ASC) TABLESPACE INDX;

CREATE SEQUENCE SEQ_WEBUSERDIALOG
START WITH 1
INCREMENT BY 1;

CREATE TABLE WEBUSERDIALOG
(
	WEBUSERDIALOG_ID     NUMBER NOT NULL ,
	WEBUSER_ID           NUMBER NOT NULL ,
	WEBMENUDIALOG_ID     NUMBER NOT NULL ,
	REPORTLAYOUTPARAMETER VARCHAR2(6) NULL ,
	SYSTEMUSER_ID        NUMBER NOT NULL ,
	TIMESTAMP            DATE NOT NULL 
)
TABLESPACE ABS_DATA;


COMMENT ON COLUMN WEBUSERDIALOG.REPORTLAYOUTPARAMETER IS 'Parameter that can be used to switch between different report layouts. Will only be filled in case Dialogs.DialogType = 4.';


ALTER TABLE WEBUSERDIALOG
ADD CONSTRAINT  XPKWEBUSERDIALOG PRIMARY KEY (WEBUSERDIALOG_ID) USING INDEX TABLESPACE INDX;

CREATE  INDEX XIF1WEBUSERDIALOG ON WEBUSERDIALOG
(WEBUSER_ID   ASC) TABLESPACE INDX;

CREATE  INDEX XIF2WEBUSERDIALOG ON WEBUSERDIALOG
(WEBMENUDIALOG_ID   ASC) TABLESPACE INDX;

CREATE UNIQUE INDEX XAK1WEBUSERDIALOG ON WEBUSERDIALOG
(WEBUSER_ID   ASC,WEBMENUDIALOG_ID   ASC)
TABLESPACE INDX;



CREATE  INDEX XIE1WEBUSERDIALOG ON WEBUSERDIALOG
(WEBMENUDIALOG_ID   ASC,WEBUSER_ID   ASC)
TABLESPACE INDX;



ALTER TABLE WEBMENUDIALOG
ADD CONSTRAINT WEBMENUDIALOG_WEBMENUGROUP FOREIGN KEY (WEBMENUGROUP_ID) REFERENCES WEBMENUGROUP (WEBMENUGROUP_ID);



ALTER TABLE WEBMENUDIALOG
ADD CONSTRAINT WEBMENUDIALOG_DIALOGS FOREIGN KEY (DIALOG_ID) REFERENCES DIALOGS (DIALOG_ID);



ALTER TABLE WEBMENUDIALOG_DESC
ADD CONSTRAINT WEBMENUDIALOG_DESC_WEBMENUDIAL FOREIGN KEY (WEBMENUDIALOG_ID) REFERENCES WEBMENUDIALOG (WEBMENUDIALOG_ID) ON DELETE CASCADE;



ALTER TABLE WEBMENUDIALOG_DESC
ADD CONSTRAINT WEBMENUDIALOG_DESC_LANGUAGES FOREIGN KEY (LANGUAGE_ID) REFERENCES LANGUAGES (LANGUAGE_ID) ON DELETE CASCADE;



ALTER TABLE WEBMENUGROUP_DESC
ADD CONSTRAINT WEBMENUGROUP_DESC_WEBMENUGROUP FOREIGN KEY (WEBMENUGROUP_ID) REFERENCES WEBMENUGROUP (WEBMENUGROUP_ID) ON DELETE CASCADE;



ALTER TABLE WEBMENUGROUP_DESC
ADD CONSTRAINT WEBMENUGROUP_DESC_LANGUAGES FOREIGN KEY (LANGUAGE_ID) REFERENCES LANGUAGES (LANGUAGE_ID) ON DELETE CASCADE;



ALTER TABLE WEBUSERDIALOG
ADD CONSTRAINT WEBUSERDIALOG_WEBUSER FOREIGN KEY (WEBUSER_ID) REFERENCES WEBUSER (WEBUSER_ID) ON DELETE CASCADE;



ALTER TABLE WEBUSERDIALOG
ADD CONSTRAINT WEBUSERDIALOG_WEBMENUDIALOG FOREIGN KEY (WEBMENUDIALOG_ID) REFERENCES WEBMENUDIALOG (WEBMENUDIALOG_ID) ON DELETE CASCADE;


ALTER TABLE DIALOGS
	DROP CONSTRAINT DIALOGTYPE_VALID;



ALTER TABLE DIALOGS
	ADD CONSTRAINT DIALOGTYPE_VALID  CHECK (DIALOGTYPE IN (0, 1, 2, 3, 4));

COMMENT ON COLUMN DIALOGS.DIALOGTYPE IS '0 = Simple dialog (Default)
1 = Dialog with reports
2 = Report with Selection dialog
3 = Web dialog
4 = Web report';


