table coding_sys {
  coding_sys_id integer [pk]
  abb varchar(10) [unique]
  name varchar
  description text
  create_date datetime
  end_date datetime
}

table races {
  race_id integer [pk]
  site_id integer 
  coding_sys_id integer [ref:<coding_sys.coding_sys_id]
  name varchar 
  create_date datetime
  end_date datetime
}

table religions {
  religion_id integer [pk]
  site_id integer
  coding_sys_id integer [ref:<coding_sys.coding_sys_id]
  name varchar
  create_date datetime
  end_date datetime
}

table ethnics {
  ethnic_id integer [pk]
  site_id integer
  coding_sys_id integer [ref:<coding_sys.coding_sys_id]
  name varchar
  create_date datetime
  end_date datetime
}

table countries {
  country_id integer [pk]
  site_id integer
  coding_sys_id integer [ref:<coding_sys.coding_sys_id]
  name varchar
  create_date datetime
  end_date datetime
}

table patients {
  patient_id integer [pk]
  patient_num varchar [unique]
  patient_altnum varchar [unique]
  prefix varchar
  name_first varchar
  name_middle varchar
  name_maiden varchar
  name_last varchar
  suffix varchar
  name_alias varchar
  gender varchar
  birth_place varchar
  birth_date date
  address_1 varchar
  address_2 varchar
  address_3 varchar
  city varchar
  province varchar
  zip varchar
  email_1 varchar
  email_2 varchar
  phone varchar
  mobile_phone varchar
  mother varchar
  account_number varchar
  marital_status varchar
  country_id integer [ref:<countries.country_id]
  race_id integer [ref:<races.race_id]
  religion_id integer [ref:<religions.religion_id]
  ethnic_id integer [ref:<ethnics.ethnic_id]
  citizenship varchar
  death bit 
  death_date datetime
  link_to integer
  create_date datetime
  del_date datetime
}

table patient_comments {
  patient_comment_id integer [pk]
  patient_id integer [ref:<patients.patient_id]
  comment_text text
  user_id integer
  create_date datetime
  del_date datetime
}

table patient_identities {
  patient_identity_id integer [pk]
  patient_id integer [ref:<patients.patient_id]
  identity_type varchar
  identity_number varchar
  effective_date datetime
  expiration_date datetime
  create_date datetime
  del_date datetime
}

table patient_visits {
  visit_id integer [pk]
  visit_number varchar [unique]
  patient_id integer [ref:<patients.patient_id]
  episode_number integer
  visit_class_id integer
  bill_account varchar
  bill_status integer
  create_date datetime
  end_date datetime
  archived_date datetime
  del_date datetime
}

table patient_diagnose {
  diagnose_id integer [pk]
  patient_id integer [ref:<patients.patient_id]
  diagnose_code varchar
  diagnose_comment varchar
  create_date datetime
  end_date datetime
  archived_date datetime
  del_date datetime
}
