--UID:           1.5.0_20180918
--NAME:          1.5.0_kfoqsdb-update.sql
--VERSION:       1.05.00.00
--DESCRIPTION:   UPDATE



INSERT INTO RW (RWTYP, RWNAME, RWVALUE) VALUES ('report_role','ALL','KFOQSDB.ADMIN');
INSERT INTO RW (RWTYP, RWNAME, RWVALUE) VALUES ('report_role','ALL','KFOQSDB.BEARB');
INSERT INTO RW (RWTYP, RWNAME, RWVALUE) VALUES ('report_role','ALL','KFOQSDB.LESER');

INSERT INTO RW (RWTYP, RWNAME, RWVALUE) VALUES ('report_role','SB','KFOQSDB.BEARB');
INSERT INTO RW (RWTYP, RWNAME, RWVALUE) VALUES ('report_role','SB','KFOQSDB.LESER');


INSERT INTO RW (RWTYP, RWNAME, RWVALUE) VALUES ('report_role','ADMIN','KFOQSDB.ADMIN');


CREATE TABLE audit(

  id bigint NOT NULL DEFAULT nextval('kfoqsdb_seq'::regclass),
  auditdatum timestamp without time zone NOT NULL,
  identifier character varying,
  bereuser character varying,
  trager character varying,
  qsid bigint,
  valueold character varying,
  valuenew character varying,
  version bigint NOT NULL DEFAULT 0

);

ALTER TABLE audit ADD PRIMARY KEY (id);
ALTER TABLE audit ADD CONSTRAINT fk_takeover_qs FOREIGN KEY (qsid) REFERENCES "QsEintrag" ("ID");


INSERT INTO reporttype ("ID", sql, version, "Erstelldatum", role, type, name) VALUES (1,'SELECT q."LZTraeger" as "LZ Traeger", q."ABRTraeger" as "ABR Traeger", q."QSTraeger" as "QS Traeger", q."Ersteller" as "Ersteller", q."Erstelldatum" as "Erstelldatum", p."VpNr" as "VPNR", p."PartnerName" as "VP Name", p."PartnerBundesland" as "VP Bundesland", p."countryCode" as "Laendercode", q."Leistungsart" as "Leistungsart", q."Fachgebiet" as "Fachgebiet", q."PartnerArt" as "Partnerart", q."VsNr" as "VSNR", q."IOTNLE" as "IOTN-Grad LE", q."IOTNQS" as "IOTN-Grad QS", q."IOTNDatumLE" as "IOTN Feststellungsdatum LE", q."IOTNDatumQS" as "IOTN Feststellungsdatum QS", q."IndikationLE" as "Indikation LE", q."IndikationQS" as "Indikation QS", q."IndikationDatumLE" as "Indikation Feststellungsdatum LE", q."IndikationDatumQS" as "Indikation Feststellungsdatum QS", q."IBBehandlungsendeLE" as "Datum Behandlungsende LE", q."Behandlungsabbruch" as "Datum Behandlungsabbruch LE", q."ErfolgsannahmeErreicht" as "Erfolgsannahme", q."PARAnfangswert" as "PAR-Index Anfangswert", q."PAREndwert" as "PAR-Index Endwert", q."HBDatumBehandlungsbeginnLE" as "Datum Behandlungsbeginn HB LE", q."HBDatumBehandlungsendeLE" as "Datum Behandlungsende HB LE" FROM "QsEintrag" q INNER JOIN "Partner" p ON q."VpNr" = P."VpNr" WHERE q."ABRTraeger" = ''?''',0,'2018-10-02 16:29:36.714632','ALL','user','Export');
