-- Tables

/***** Object:  Table AKUZ.T_PREGNANT_HOSPITALIZATION_INFO *****/
CREATE TABLE AKUZ.T_PREGNANT_HOSPITALIZATION_INFO
(
    "pregnanthospitalizationinfoid" uuid NOT NULL,
    "datebegin" timestamp NOT NULL,
    "dateend" timestamp NULL,
    "hospitalizationtype" integer NOT NULL,
    "ehrrusmdr308" uuid NOT NULL,
    "diagnosis" varchar(255) NULL,
    "pregnantdispanserisation" uuid NOT NULL
);

/***** Object:  Table AKUZ.T_PREVIOUS_PREGNANCIES_LINK_COMPLICATION *****/
CREATE TABLE AKUZ.T_PREVIOUS_PREGNANCIES_LINK_COMPLICATION
(
    "previouspregnancieslinkcomplicationid" uuid NOT NULL,
    "previouspregnanciesinformation" uuid NOT NULL,
    "mkb" varchar(255) NOT NULL,
    "diagnosis" varchar(255) NOT NULL,
    "users" uuid NULL,
    "recorddate" timestamp NULL
);

/***** Object:  Table AKUZ.T_PREVIOUS_PREGNANICES_NEWBORN_INFORMATION *****/
CREATE TABLE AKUZ.T_PREVIOUS_PREGNANICES_NEWBORN_INFORMATION
(
    "previouspregnanicesnewborninformationid" uuid NOT NULL,
    "bornalive" boolean NOT NULL,
    "sex" integer NOT NULL,
    "height" integer NOT NULL,
    "weight" integer NOT NULL,
    "previouspregnanciesinformation" uuid NOT NULL,
    "users" uuid NULL,
    "recorddate" timestamp NULL
);

-- Alters

ALTER TABLE AKUZ.T_PREGNANT_HOSPITALIZATION_INFO ADD CONSTRAINT PK_T_PREGNANT_HOSPITALIZATION_INFO
PRIMARY KEY (PregnantHospitalizationInfoID);

ALTER TABLE AKUZ.T_PREGNANT_HOSPITALIZATION_INFO ADD CONSTRAINT FK_T_EHR_RUS_MDR308_T_PREGNANT_HOSPITALIZATION_INFO_Eh_DAF9243A
FOREIGN KEY("ehrrusmdr308") REFERENCES EHR.T_EHR_RUS_MDR308 (EhrRusID);

ALTER TABLE AKUZ.T_PREGNANT_HOSPITALIZATION_INFO ADD CONSTRAINT FK_T_PREGNANT_DISPANSERISATION_T_PREGNANT_HOSPITALIZAT_238DC511
FOREIGN KEY("pregnantdispanserisation") REFERENCES AKUZ.T_PREGNANT_DISPANSERISATION (MedicalRecordID);

ALTER TABLE AKUZ.T_PREVIOUS_PREGNANCIES_LINK_COMPLICATION ADD CONSTRAINT PK_T_PREVIOUS_PREGNANCIES_LINK_COMPLICATION
PRIMARY KEY (PreviousPregnanciesLinkComplicationID);

ALTER TABLE AKUZ.T_PREVIOUS_PREGNANCIES_LINK_COMPLICATION ADD CONSTRAINT FK_T_PREVIOUS_PREGNANCIES_INFORMATION_T_PREVIOUS_PREGN_BA8D4EE9
FOREIGN KEY("previouspregnanciesinformation") REFERENCES AKUZ.T_PREVIOUS_PREGNANCIES_INFORMATION (PreviousPregnanciesInformationID);

ALTER TABLE AKUZ.T_PREVIOUS_PREGNANCIES_LINK_COMPLICATION ADD CONSTRAINT FK_T_USERS_T_PREVIOUS_PREGNANCIES_LINK_COMPLICATION_Users
FOREIGN KEY("users") REFERENCES AKUZ.T_USERS (UserID);

ALTER TABLE AKUZ.T_PREVIOUS_PREGNANICES_NEWBORN_INFORMATION ADD CONSTRAINT PK_T_PREVIOUS_PREGNANICES_NEWBORN_INFORMATION
PRIMARY KEY (PreviousPregnanicesNewbornInformationID);

ALTER TABLE AKUZ.T_PREVIOUS_PREGNANICES_NEWBORN_INFORMATION ADD CONSTRAINT FK_T_PREVIOUS_PREGNANCIES_INFORMATION_T_PREVIOUS_PREGN_4CBBBE22
FOREIGN KEY("previouspregnanciesinformation") REFERENCES AKUZ.T_PREVIOUS_PREGNANCIES_INFORMATION (PreviousPregnanciesInformationID);

ALTER TABLE AKUZ.T_PREVIOUS_PREGNANICES_NEWBORN_INFORMATION ADD CONSTRAINT FK_T_USERS_T_PREVIOUS_PREGNANICES_NEWBORN_INFORMATION_Users
FOREIGN KEY("users") REFERENCES AKUZ.T_USERS (UserID);

