-- ======================
-- TABLE: FCT_CONTRATO
-- ======================
ALTER TABLE FCT_CONTRATO ADD DSJUSTIFICAENCERRA VARCHAR2(4000)
/
-- ================================
-- TABLE: FCT_PARAMPARALISACAOCONT
-- ================================ 
CREATE TABLE FCT_PARAMPARALISACAOCONT (
	NRPARAMPARALISAO    NUMBER 		   NOT NULL,
	NRSEQCONTRATO	    NUMBER 		   NOT NULL,
	CDOPERSOLICITANTE   VARCHAR2(12)   NOT NULL,
	QTDIASPARALISACAO   NUMBER 		   NOT NULL,
	DTINIPARALISACAO    DATE 		   NOT NULL,
	DTRETOMADAFATURA    DATE 		   NOT NULL,
	DSMOTIVOPARALISACAO VARCHAR2(4000) NOT NULL,
	DSMOTIVORETOMADA    VARCHAR2(4000),
	NRORG               NUMBER          DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') 	NOT NULL,	
    	IDATIVO             VARCHAR2(1)     DEFAULT 'S' 						NOT NULL
    	CONSTRAINT CKC_IDATIVO_FCT_PARAMPARACONT   CHECK (IDATIVO IN ('S','N')),
    	DTINCLUSAO          DATE                       						    NULL,
    	DTULTATU            DATE                       						    NULL,
   	NRORGINCLUSAO       NUMBER          DEFAULT 1   						    NULL,
    	CDOPERINCLUSAO      VARCHAR2(12)    DEFAULT '1' 						    NULL,
    	NRORGULTATU         NUMBER          DEFAULT 1   						    NULL,
    	CDOPERULTATU        VARCHAR2(12)    DEFAULT '1' 
)
/
ALTER TABLE FCT_PARAMPARALISACAOCONT ADD CONSTRAINT PK_PARAMPARALISACAO PRIMARY KEY (NRPARAMPARALISAO)
/
CREATE INDEX FKSM00251 ON "FCT_PARAMPARALISACAOCONT" ("NRSEQCONTRATO" ASC)
/
CREATE INDEX FKSM00252 ON "FCT_PARAMPARALISACAOCONT" ("CDOPERSOLICITANTE" ASC)
/
ALTER TABLE FCT_PARAMPARALISACAOCONT ADD CONSTRAINT CK_IDATIVO_PARAMPARALISACAO CHECK(IDATIVO IN ('S', 'N'))
/
ALTER TABLE FCT_MEDICAOFATURA ADD CONSTRAINT CKC_IDSITUACAO_FCT_MEDICAOFAT CHECK(IDSITUACAO IN ('1', '2', '3', '4', '5'))
/
ALTER TABLE FCT_PARAMPARALISACAOCONT ADD CONSTRAINT FKSM00251CONT_PARAMPARALI FOREIGN KEY (NRSEQCONTRATO)
	REFERENCES FCT_CONTRATO(NRSEQCONTRATO) ON DELETE CASCADE
/
ALTER TABLE FCT_PARAMPARALISACAOCONT ADD CONSTRAINT FKSM00252OPER_PARAMPARALI FOREIGN KEY (CDOPERSOLICITANTE)
	REFERENCES OPERADOR(CDOPERADOR)
/
-- ================================
-- TABLE: FCT_FATURACONT 
-- ================================ 
ALTER TABLE FCT_FATURACONT DROP CONSTRAINT CKC_IDSITUACAO_FCT_FATURACONT
/
ALTER TABLE FCT_FATURACONT ADD CONSTRAINT CKC_IDSITUACAO_FCT_FATURACONT CHECK(IDSITUACAO IN ('1', '2', '3', '4', '5'))
/
-- ================================
-- TABLE: FCT_MEDICAOFATURA 
-- ================================ 
ALTER TABLE FCT_MEDICAOFATURA DROP CONSTRAINT CKC_IDSITUACAO_FCT_MEDICAOFAT
