-- Software Version: MKF 4.4.1, ProdDefinition.XML version: 201603221300, CreateDate: 3/22/2016
SET FEEDBACK OFF;
SET ECHO OFF;

REM DROP TABLE fdb_custom_allergenpicklstsrch PURGE;
CREATE TABLE fdb_custom_allergenpicklstsrch (conceptunivid VARCHAR2 (50) NOT NULL ,descsearch VARCHAR2 (255) NULL );
ALTER TABLE fdb_custom_allergenpicklstsrch ADD CONSTRAINT pkfdbcustomallergenpicklstsrch PRIMARY KEY (conceptunivid);

REM DROP TABLE fdb_custom_attribute_name PURGE;
CREATE TABLE fdb_custom_attribute_name (attribute_id SMALLINT NOT NULL ,attribute_desc VARCHAR2 (255) NULL );
ALTER TABLE fdb_custom_attribute_name ADD CONSTRAINT pkfdbcustomattributename PRIMARY KEY (attribute_id);

REM DROP TABLE fdb_custom_attribute_value PURGE;
CREATE TABLE fdb_custom_attribute_value (attribute_item_univid VARCHAR2 (50) NOT NULL ,attribute_id SMALLINT NOT NULL ,attribute_seq_number SMALLINT NOT NULL ,attribute_value VARCHAR2 (255) NULL ,attribute_value_desc VARCHAR2 (255) NULL );
ALTER TABLE fdb_custom_attribute_value ADD CONSTRAINT pkfdbcustomattributevalue PRIMARY KEY (attribute_item_univid,attribute_id,attribute_seq_number);

REM DROP TABLE fdb_custom_clinical_drug PURGE;
CREATE TABLE fdb_custom_clinical_drug (category VARCHAR2 (50) NOT NULL ,clinicalmoduleunivid VARCHAR2 (50) NOT NULL ,drugunivid VARCHAR2 (50) NOT NULL ,include SMALLINT NULL );
ALTER TABLE fdb_custom_clinical_drug ADD CONSTRAINT pkfdbcustomclinicaldrug PRIMARY KEY (category,clinicalmoduleunivid,drugunivid);

REM DROP TABLE fdb_custom_clinical_exclusion PURGE;
CREATE TABLE fdb_custom_clinical_exclusion (category VARCHAR2 (50) NOT NULL ,clinicalmoduleunivid VARCHAR2 (50) NOT NULL );
ALTER TABLE fdb_custom_clinical_exclusion ADD CONSTRAINT pkfdbcustomclinicalexclusion PRIMARY KEY (category,clinicalmoduleunivid);

REM DROP TABLE fdb_custom_ddim_druglinkcat PURGE;
CREATE TABLE fdb_custom_ddim_druglinkcat (category VARCHAR2 (50) NOT NULL ,drug1univid VARCHAR2 (50) NOT NULL ,drug2univid VARCHAR2 (50) NOT NULL ,interactionid INTEGER NOT NULL );
ALTER TABLE fdb_custom_ddim_druglinkcat ADD CONSTRAINT pkfdbcustomddimdruglinkcat PRIMARY KEY (category,drug1univid,drug2univid,interactionid);

REM DROP TABLE fdb_custom_ddim_severity PURGE;
CREATE TABLE fdb_custom_ddim_severity (category VARCHAR2 (10) NOT NULL ,interaction INTEGER NOT NULL ,severitylevelcode VARCHAR2 (1) NULL );
ALTER TABLE fdb_custom_ddim_severity ADD CONSTRAINT pkfdbcustomddimseverity PRIMARY KEY (category,interaction);

REM DROP TABLE fdb_custom_dosing PURGE;
CREATE TABLE fdb_custom_dosing (drugunivid VARCHAR2 (50) NOT NULL ,rtid INTEGER NOT NULL ,lowagedays INTEGER NOT NULL ,highagedays INTEGER NOT NULL ,dxid INTEGER NOT NULL ,dosetypecode VARCHAR2 (2) NOT NULL ,lowgestbirthageweeks SMALLINT NOT NULL ,highgestbirthageweeks SMALLINT NOT NULL ,lowcurrentweightgrams INTEGER NOT NULL ,highcurrentweightgrams INTEGER NOT NULL ,exclusioncode VARCHAR2 (1) NULL ,patientparamreqind SMALLINT NULL ,dosingagesourcecode VARCHAR2 (1) NULL ,lowdoseperday_m decimal(19,6)  NULL ,lowdoseperdayunitid_m INTEGER NULL ,highdoseperday_m decimal(19,6)  NULL ,highdoseperdayunitid_m INTEGER NULL ,lowdoseperday_f decimal(19,6)  NULL ,lowdoseperdayunitid_f INTEGER NULL ,highdoseperday_f decimal(19,6)  NULL ,highdoseperdayunitid_f INTEGER NULL ,maxdoseperday_m decimal(19,6)  NULL ,maxdoseperdayunitid_m INTEGER NULL ,maxdoseperday_f decimal(19,6)  NULL ,maxdoseperdayunitid_f INTEGER NULL ,maxsingledose_m decimal(19,6)  NULL ,maxsingledoseunitid_m INTEGER NULL ,maxsingledose_f decimal(19,6)  NULL ,maxsingledoseunitid_f INTEGER NULL ,maxlifedose_m decimal(19,6)  NULL ,maxlifedoseunitid_m INTEGER NULL ,maxlifedose_f decimal(19,6)  NULL ,maxlifedoseunitid_f INTEGER NULL ,ntesingledose_m decimal(19,6)  NULL ,ntesingledoseunitid_m INTEGER NULL ,ntesingledose_f decimal(19,6)  NULL ,ntesingledoseunitid_f INTEGER NULL ,lowelimhalflife decimal(19,6)  NULL ,highelimhalflife decimal(19,6)  NULL ,halflifeunitid INTEGER NULL ,lowfrequency_m decimal(19,6)  NULL ,highfrequency_m decimal(19,6)  NULL ,lowfrequency_f decimal(19,6)  NULL ,highfrequency_f decimal(19,6)  NULL ,lowdurationoftx INTEGER NULL ,highdurationoftx INTEGER NULL ,maxdurationoftx INTEGER NULL ,hepaticimpairmentind SMALLINT NULL ,renalimpairmentind SMALLINT NULL ,creatinineclrthreshold SMALLINT NULL ,creatinineclrthresholdunitid INTEGER NULL ,exclusionreasonid INTEGER NULL ,severitylevelcode VARCHAR2 (1) NULL ,availableprecautionind SMALLINT NULL ,exclusionmessagetext VARCHAR2 (750) NULL ,nextscreeningdosetext VARCHAR2 (510) NULL ,nextscreeningdoseagetext VARCHAR2 (255) NULL );
ALTER TABLE fdb_custom_dosing ADD CONSTRAINT pkfdbcustomdosing PRIMARY KEY (drugunivid,rtid,lowagedays,highagedays,dxid,dosetypecode,lowgestbirthageweeks,highgestbirthageweeks,lowcurrentweightgrams,highcurrentweightgrams);

REM DROP TABLE fdb_custom_dosing_minmax PURGE;
CREATE TABLE fdb_custom_dosing_minmax (drugunivid VARCHAR2 (50) NOT NULL ,lowage INTEGER NOT NULL ,highage INTEGER NOT NULL ,mindailydosestrength decimal(19,6)  NULL ,mindailydosestrengthunitid INTEGER NULL ,mindailydoseunits decimal(19,6)  NULL ,mindailydoseunitsunitid INTEGER NULL ,maxdailydosestrength decimal(19,6)  NULL ,maxdailydosestrengthunitid INTEGER NULL ,maxdailydoseunits decimal(19,6)  NULL ,maxdailydoseunitsunitid INTEGER NULL ,ntedailydosestrength decimal(19,6)  NULL ,ntedailydosestrengthunitid INTEGER NULL ,ntedailydoseunits decimal(19,6)  NULL ,ntedailydoseunitsunitid INTEGER NULL ,dosingagesourcecode VARCHAR2 (1) NULL ,warningcode VARCHAR2 (1) NULL ,patientparamreqind SMALLINT NULL );
ALTER TABLE fdb_custom_dosing_minmax ADD CONSTRAINT pkfdbcustomdosingminmax PRIMARY KEY (drugunivid,lowage,highage);

REM DROP TABLE fdb_custom_dosing_pat_param PURGE;
CREATE TABLE fdb_custom_dosing_pat_param (drugunivid VARCHAR2 (50) NOT NULL ,rtid INTEGER NOT NULL ,lowagedays INTEGER NOT NULL ,highagedays INTEGER NOT NULL ,dxid INTEGER NOT NULL ,dosetypecode VARCHAR2 (2) NOT NULL ,lowgestbirthageweeks SMALLINT NOT NULL ,highgestbirthageweeks SMALLINT NOT NULL ,lowcurrentweightgrams INTEGER NOT NULL ,highcurrentweightgrams INTEGER NOT NULL ,patient_param_req_cd VARCHAR2 (4) NOT NULL );
ALTER TABLE fdb_custom_dosing_pat_param ADD CONSTRAINT pkfdbcustomdosingpatparam PRIMARY KEY (drugunivid,rtid,lowagedays,highagedays,dxid,dosetypecode,lowgestbirthageweeks,highgestbirthageweeks,lowcurrentweightgrams,highcurrentweightgrams,patient_param_req_cd);

REM DROP TABLE fdb_custom_dosing_renal PURGE;
CREATE TABLE fdb_custom_dosing_renal (drugunivid VARCHAR2 (50) NOT NULL ,rtid INTEGER NOT NULL ,lowagedays INTEGER NOT NULL ,highagedays INTEGER NOT NULL ,dxid INTEGER NOT NULL ,dosetypecode VARCHAR2 (2) NOT NULL ,lowcreatinineclr SMALLINT NOT NULL ,highcreatinineclr SMALLINT NOT NULL ,sortorder SMALLINT NOT NULL ,dosingadjustmenttypecode VARCHAR2 (1) NULL ,patientparamreqind SMALLINT NULL ,lowdoseperday_m decimal(19,6)  NULL ,lowdoseperdayunitid_m INTEGER NULL ,highdoseperday_m decimal(19,6)  NULL ,highdoseperdayunitid_m INTEGER NULL ,lowdoseperday_f decimal(19,6)  NULL ,lowdoseperdayunitid_f INTEGER NULL ,highdoseperday_f decimal(19,6)  NULL ,highdoseperdayunitid_f INTEGER NULL ,maxdoseperday_m decimal(19,6)  NULL ,maxdoseperdayunitid_m INTEGER NULL ,maxdoseperday_f decimal(19,6)  NULL ,maxdoseperdayunitid_f INTEGER NULL ,maxsingledose_m decimal(19,6)  NULL ,maxsingledoseunitid_m INTEGER NULL ,maxsingledose_f decimal(19,6)  NULL ,maxsingledoseunitid_f INTEGER NULL ,ntesingledose_m decimal(19,6)  NULL ,ntesingledoseunitid_m INTEGER NULL ,ntesingledose_f decimal(19,6)  NULL ,ntesingledoseunitid_f INTEGER NULL ,lowfrequency_m decimal(19,6)  NULL ,highfrequency_m decimal(19,6)  NULL ,low_frequency_f decimal(19,6)  NULL ,highfreqeuncy_f decimal(19,6)  NULL ,footnote VARCHAR2 (255) NULL ,monographid INTEGER NULL );
ALTER TABLE fdb_custom_dosing_renal ADD CONSTRAINT pkfdbcustomdosingrenal PRIMARY KEY (drugunivid,rtid,lowagedays,highagedays,dxid,dosetypecode,lowcreatinineclr,highcreatinineclr,sortorder);

REM DROP TABLE fdb_custom_dosing_renal_pat_pm PURGE;
CREATE TABLE fdb_custom_dosing_renal_pat_pm (drugunivid VARCHAR2 (50) NOT NULL ,rtid INTEGER NOT NULL ,lowagedays INTEGER NOT NULL ,highagedays INTEGER NOT NULL ,dxid INTEGER NOT NULL ,dosetypecode VARCHAR2 (2) NOT NULL ,lowcreatinineclr SMALLINT NOT NULL ,highcreatinineclr SMALLINT NOT NULL ,sortorder SMALLINT NOT NULL ,patient_param_req_cd VARCHAR2 (4) NOT NULL );
ALTER TABLE fdb_custom_dosing_renal_pat_pm ADD CONSTRAINT pkfdbcustomdosingrpp PRIMARY KEY (drugunivid,rtid,lowagedays,highagedays,dxid,dosetypecode,lowcreatinineclr,highcreatinineclr,sortorder,patient_param_req_cd);

REM DROP TABLE fdb_custom_dpt_allowance PURGE;
CREATE TABLE fdb_custom_dpt_allowance (category VARCHAR2 (10) NOT NULL ,dtcid INTEGER NOT NULL ,customdupallowance SMALLINT NULL );
ALTER TABLE fdb_custom_dpt_allowance ADD CONSTRAINT pkfdbcustomdptallowance PRIMARY KEY (category,dtcid);

REM DROP TABLE fdb_custom_frequency_interval PURGE;
CREATE TABLE fdb_custom_frequency_interval (freq_int_id INTEGER NOT NULL ,freq_int_text_short VARCHAR2 (50) NULL ,freq_int_text_long VARCHAR2 (50) NULL ,freq_amount SMALLINT NULL ,freq_amount_upper SMALLINT NULL ,int_amount SMALLINT NULL ,int_amount_upper SMALLINT NULL ,int_amount_uom_id INTEGER NULL ,alternative_expression_id INTEGER NULL ,doses_per_day_amount decimal(19, 6)  NULL );
ALTER TABLE fdb_custom_frequency_interval ADD CONSTRAINT pkcustomfreqint PRIMARY KEY (freq_int_id);

REM DROP TABLE fdb_custom_indication PURGE;
CREATE TABLE fdb_custom_indication (category VARCHAR2 (10) NOT NULL ,rtgenid INTEGER NOT NULL ,vocabtypeid VARCHAR2 (2) NOT NULL ,vocabid VARCHAR2 (50) NOT NULL ,comments VARCHAR2 (255) NULL );
ALTER TABLE fdb_custom_indication ADD CONSTRAINT pkfdbcustomindication PRIMARY KEY (category,rtgenid,vocabtypeid,vocabid);

REM DROP TABLE fdb_custom_minmax_pat_param PURGE;
CREATE TABLE fdb_custom_minmax_pat_param (drugunivid VARCHAR2 (50) NOT NULL ,lowage INTEGER NOT NULL ,highage INTEGER NOT NULL ,patient_param_req_cd VARCHAR2 (4) NOT NULL );
ALTER TABLE fdb_custom_minmax_pat_param ADD CONSTRAINT pkfdbcustomminmaxpatparam PRIMARY KEY (drugunivid,lowage,highage,patient_param_req_cd);

REM DROP TABLE fdb_custom_monograph PURGE;
CREATE TABLE fdb_custom_monograph (languageid SMALLINT NOT NULL ,category VARCHAR2 (10) NOT NULL ,monographid INTEGER NOT NULL ,sequencenumber SMALLINT NOT NULL ,sectioncode VARCHAR2 (1) NULL ,formatcode VARCHAR2 (1) NULL ,linetext VARCHAR2 (255) NULL );
ALTER TABLE fdb_custom_monograph ADD CONSTRAINT pkfdbcustommonograph PRIMARY KEY (languageid,category,monographid,sequencenumber);

REM DROP TABLE fdb_custom_monograph_link PURGE;
CREATE TABLE fdb_custom_monograph_link (category VARCHAR2 (50) NOT NULL ,itemunivid VARCHAR2 (50) NOT NULL ,custommonoid VARCHAR2 (50) NOT NULL );
ALTER TABLE fdb_custom_monograph_link ADD CONSTRAINT pkfdbcustommonographlink PRIMARY KEY (category,itemunivid,custommonoid);

exit;