import sys

class VisitPurposesRecord:
    def __init__(self, visit_purpose_id, name):
        self.visit_purpose_id = visit_purpose_id
        self.name = name

f = open(sys.argv[1], mode="r")

dump_file = open(sys.argv[2], mode="w")

rows = f.read().split("\n")

dump_file.write("""
CREATE TABLE IF NOT EXISTS evi.visit_purpose
(
    visit_purpose_id text COLLATE pg_catalog."default" NOT NULL,
    name text COLLATE pg_catalog."default" NOT NULL
);
\n""")

for row in rows:
    if len(row) == 0:
        continue

    cols = row.split(",")
    record = VisitPurposesRecord(cols[0], cols[1])

    dump_file.write(f"""INSERT INTO evi.visit_purpose (visit_purpose_id, name)
                    VALUES ('{record.visit_purpose_id}', '{record.name}');\n""")
