PRAGMA foreign_keys = ON;

PRAGMA writable_schema = 1;
DELETE FROM sqlite_master WHERE type IN ("table", "index", "trigger");
PRAGMA writable_schema = 0;
VACUUM;

CREATE TABLE "Examination" (
"ID" INT,
"Diagnosis" TEXT,
"Thrombosis" INT,
FOREIGN KEY ("ID") REFERENCES "Patient"("ID")
);

CREATE TABLE "Laboratory" (
"ID" INT,
"Date" DATE,
"HGB" FLOAT,
"HCT" FLOAT,
PRIMARY KEY ("ID", "Date"),
FOREIGN KEY ("ID") REFERENCES "Patient"("ID")
);

CREATE TABLE "Patient" (
"ID" INT UNIQUE,
"SEX" TEXT,
"Birthday" DATE,
"Admission" TEXT,
"Diagnosis" TEXT,
PRIMARY KEY ("ID")
);



INSERT INTO "Patient" VALUES ("1", "F", "1940-05-12", "2023-01-10", "SLE");
INSERT INTO "Patient" VALUES ("2", "M", "1955-11-23", "2023-01-15", "SLE");
INSERT INTO "Patient" VALUES ("3", "F", "1935-07-30", "2023-01-20", "SLE");
INSERT INTO "Patient" VALUES ("4", "M", "1960-03-05", "2023-01-25", "Diabetes");
INSERT INTO "Patient" VALUES ("5", "F", "1945-12-01", "2023-01-30", "SLE");
INSERT INTO "Patient" VALUES ("6", "M", "1930-08-15", "2023-02-01", "SLE");
INSERT INTO "Examination" VALUES ("1", "SLE", "0");
INSERT INTO "Examination" VALUES ("2", "SLE", "1");
INSERT INTO "Examination" VALUES ("3", "SLE", "0");
INSERT INTO "Examination" VALUES ("4", "Diabetes", "0");
INSERT INTO "Examination" VALUES ("5", "SLE", "1");
INSERT INTO "Examination" VALUES ("6", "SLE", "0");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-11", "12.5", "38.0");
INSERT INTO "Laboratory" VALUES ("2", "2023-01-16", "9.8", "35.0");
INSERT INTO "Laboratory" VALUES ("3", "2023-01-21", "16.8", "45.0");
INSERT INTO "Laboratory" VALUES ("4", "2023-01-26", "14.0", "40.0");
INSERT INTO "Laboratory" VALUES ("5", "2023-01-31", "11.0", "37.0");
INSERT INTO "Laboratory" VALUES ("6", "2023-02-02", "15.5", "42.0");
INSERT INTO "Patient" VALUES ("7", "F", "1925-04-10", "2023-02-05", "SLE");
INSERT INTO "Examination" VALUES ("7", "SLE", "0");
INSERT INTO "Laboratory" VALUES ("7", "2023-02-06", "10.0", "36.0");
INSERT INTO "Patient" VALUES ("8", "M", "1920-09-20", "2023-02-07", "SLE");
INSERT INTO "Examination" VALUES ("8", "SLE", "0");
INSERT INTO "Laboratory" VALUES ("8", "2023-02-08", "17.0", "44.0");