DROP TABLE ps_oid_index;
DROP TABLE ps_class;
DROP TABLE ps_field;
DROP TABLE person;
DROP TABLE patient;
DROP TABLE observation;

CREATE TABLE ps_class (jname VARCHAR(32) PRIMARY KEY, name VARCHAR(32), make VARCHAR(32));
CREATE TABLE ps_field (jcname VARCHAR(32), jname VARCHAR(32), name VARCHAR(32), modifier INTEGER);

INSERT INTO ps_class VALUES ('rmrs.persist.test.Person', 'person', NULL);
INSERT INTO ps_field VALUES ('rmrs.persist.test.Person', 'name', 'pname', 1);
INSERT INTO ps_field VALUES ('rmrs.persist.test.Person', 'address', 'paddress', 1);
INSERT INTO ps_field VALUES ('rmrs.persist.test.Person', 'birth_dttm', 'pdob', 1);

INSERT INTO ps_class VALUES ('rmrs.persist.test.Patient', 'patient', 'newInstance');
INSERT INTO ps_field VALUES ('rmrs.persist.test.Patient', 'mrn', 'patmrn', 1);
INSERT INTO ps_field VALUES ('rmrs.persist.test.Patient', 'ivl', 'pivl', 6);
INSERT INTO ps_field VALUES ('rmrs.persist.test.Patient', 'doctor', 'pdoctor', 10);

INSERT INTO ps_class VALUES ('rmrs.persist.test.Interval', 'interval', NULL);
INSERT INTO ps_field VALUES ('rmrs.persist.test.Interval', 'low', '_low', 1);
INSERT INTO ps_field VALUES ('rmrs.persist.test.Interval', 'high', '_high', 1);

CREATE TABLE person (ps_oid CHAR(32) PRIMARY KEY, ps_species VARCHAR(32), ps_flags INTEGER, ps_cotime TIMESTAMP, ps_savetime TIMESTAMP, pname VARCHAR(32), paddress VARCHAR(32), pdob TIMESTAMP);

CREATE TABLE patient (ps_oid CHAR(32) PRIMARY KEY, patmrn VARCHAR(32), pivl_low REAL, pivl_high REAL, pdoctor CHAR(32));

GRANT ALL ON ps_class TO PUBLIC;
GRANT ALL ON ps_field TO PUBLIC;
GRANT ALL ON person TO PUBLIC;
GRANT ALL ON patient TO PUBLIC;
