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,
FOREIGN KEY ("ID") REFERENCES "Patient"("ID")
);

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

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



INSERT INTO "Patient" VALUES ("1", "M", "-");
INSERT INTO "Patient" VALUES ("2", "F", "Inpatient");
INSERT INTO "Patient" VALUES ("3", "M", "-");
INSERT INTO "Patient" VALUES ("4", "F", "Inpatient");
INSERT INTO "Patient" VALUES ("5", "M", "-");
INSERT INTO "Patient" VALUES ("6", "F", "-");
INSERT INTO "Patient" VALUES ("7", "M", "Inpatient");
INSERT INTO "Patient" VALUES ("8", "F", "-");
INSERT INTO "Patient" VALUES ("9", "M", "-");
INSERT INTO "Patient" VALUES ("10", "F", "Inpatient");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-15", "9.5");
INSERT INTO "Laboratory" VALUES ("1", "2023-02-01", "11.2");
INSERT INTO "Laboratory" VALUES ("2", "2023-01-20", "13.0");
INSERT INTO "Laboratory" VALUES ("3", "2023-03-10", "8.8");
INSERT INTO "Laboratory" VALUES ("3", "2023-03-15", "10.1");
INSERT INTO "Laboratory" VALUES ("4", "2023-02-25", "12.5");
INSERT INTO "Laboratory" VALUES ("5", "2023-04-01", "9.9");
INSERT INTO "Laboratory" VALUES ("6", "2023-04-05", "10.0");
INSERT INTO "Laboratory" VALUES ("7", "2023-01-01", "14.0");
INSERT INTO "Laboratory" VALUES ("8", "2023-05-10", "9.2");
INSERT INTO "Laboratory" VALUES ("9", "2023-05-15", "10.5");
INSERT INTO "Laboratory" VALUES ("10", "2023-06-01", "11.8");
INSERT INTO "Examination" VALUES ("1", "Anemia");
INSERT INTO "Examination" VALUES ("2", "Healthy");
INSERT INTO "Examination" VALUES ("3", "Iron Deficiency");
INSERT INTO "Examination" VALUES ("4", "Healthy");
INSERT INTO "Examination" VALUES ("5", "Chronic Kidney Disease");
INSERT INTO "Examination" VALUES ("6", "Healthy");
INSERT INTO "Examination" VALUES ("7", "Pneumonia");
INSERT INTO "Examination" VALUES ("8", "Anemia");
INSERT INTO "Examination" VALUES ("9", "Healthy");
INSERT INTO "Examination" VALUES ("10", "Diabetes");