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,
"Examination Date" DATE,
"Diagnosis" TEXT,
"Thrombosis" INT,
FOREIGN KEY ("ID") REFERENCES "Patient"("ID")
);

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

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



INSERT INTO "Patient" VALUES ("1", "M", "1970-05-20", "Hypertension");
INSERT INTO "Patient" VALUES ("2", "F", "1985-11-15", "Diabetes");
INSERT INTO "Patient" VALUES ("3", "M", "1990-01-30", "Asthma");
INSERT INTO "Patient" VALUES ("4", "F", "2000-07-10", "Healthy");
INSERT INTO "Patient" VALUES ("5", "M", "1965-03-05", "Cardiovascular Disease");
INSERT INTO "Examination" VALUES ("1", "2023-06-01", "Stable", "0");
INSERT INTO "Examination" VALUES ("2", "2023-06-01", "Needs follow-up", "1");
INSERT INTO "Examination" VALUES ("3", "2023-06-01", "Stable", "0");
INSERT INTO "Examination" VALUES ("4", "2023-06-01", "Healthy", "0");
INSERT INTO "Examination" VALUES ("5", "2023-06-01", "Critical", "1");
INSERT INTO "Laboratory" VALUES ("1", "2023-06-01", "6.5", "14.2");
INSERT INTO "Laboratory" VALUES ("2", "2023-06-01", "7.0", "15.8");
INSERT INTO "Laboratory" VALUES ("3", "2023-06-01", "5.8", "13.5");
INSERT INTO "Laboratory" VALUES ("4", "2023-06-01", "6.0", "12.0");
INSERT INTO "Laboratory" VALUES ("5", "2023-06-01", "7.2", "16.5");
INSERT INTO "Laboratory" VALUES ("1", "2022-12-01", "6.3", "14.0");
INSERT INTO "Laboratory" VALUES ("2", "2022-12-01", "7.1", "15.0");
INSERT INTO "Laboratory" VALUES ("3", "2022-12-01", "5.9", "13.8");
INSERT INTO "Laboratory" VALUES ("4", "2022-12-01", "6.2", "12.5");
INSERT INTO "Laboratory" VALUES ("5", "2022-12-01", "7.0", "16.0");
INSERT INTO "Examination" VALUES ("1", "2022-12-01", "Improving", "0");
INSERT INTO "Examination" VALUES ("2", "2022-12-01", "Stable", "0");
INSERT INTO "Examination" VALUES ("3", "2022-12-01", "Stable", "0");
INSERT INTO "Examination" VALUES ("4", "2022-12-01", "Healthy", "0");
INSERT INTO "Examination" VALUES ("5", "2022-12-01", "Critical", "1");