-- DBMS: bigquery
CREATE TABLE `isb-cgc-bq.HTAN_versioned.clinical_tier1_demographics_r4`
(
  Age_Is_Obfuscated STRING OPTIONS(description="The age of the patient has been modified for compliance reasons. The actual age differs from what is reported. Other date intervals for this patient may also be modified."),
  Days_to_Birth STRING OPTIONS(description="Number of days between the date used for index and the date from a person's date of birth represented as a calculated negative number of days. If not applicable please enter 'Not Applicable'"),
  Id STRING OPTIONS(description="Unique identifier of entity e.g. a96059eb-81af-4b24-ae50-9242c0d8f819"),
  Occupation_Duration_Years STRING OPTIONS(description="The number of years a patient worked in a specific occupation."),
  Year_of_Death STRING OPTIONS(description="Numeric value to represent the year of the death of an individual."),
  entityId STRING OPTIONS(description="Synapse ID of entity"),
  Gender STRING OPTIONS(description="Text designations that identify gender. Gender is described as the assemblage of properties that distinguish people on the basis of their societal roles. [Identification of gender is based upon self-report and may come from a form, questionnaire, interview, etc.]"),
  Component STRING OPTIONS(description="Category of metadata (e.g. Diagnosis, Biospecimen, scRNA-seq Level 1, etc.); provide the same one for all items/rows."),
  Vital_Status STRING OPTIONS(description="The survival state of the person registered on the protocol."),
  Race STRING OPTIONS(description="An arbitrary classification of a taxonomic group that is a division of a species. It usually arises as a consequence of geographical isolation withina a species and is characterized by shared heredity, physical attributes and behavior, and in the case of humans, by common history, nationality, or geographic distribution."),
  Premature_At_Birth STRING OPTIONS(description="The yes/no/unknown indicator used to describe whether the patient was premature (less than 37 weeks gestation) at birth."),
  Cause_of_Death_Source STRING OPTIONS(description="The text term used to describe the source used to determine the patient's cause of death."),
  HTAN_Participant_ID STRING OPTIONS(description="HTAN ID associated with a patient based on HTAN ID SOP (eg HTANx_yyy )"),
  Weeks_Gestation_at_Birth STRING OPTIONS(description="Numeric value used to describe the number of weeks starting from the approximate date of the biological mother's last menstrual period and ending with the birth of the patient."),
  Days_to_Death STRING OPTIONS(description="Number of days between the date used for index and the date from a person's date of death represented as a calculated number of days. If not applicable please enter 'Not Applicable'"),
  Cause_of_Death STRING OPTIONS(description="The cause of death"),
  Year_Of_Birth STRING OPTIONS(description="Numeric value to represent the calendar year in which an individual was born."),
  Country_of_Residence STRING OPTIONS(description="Country of Residence at enrollment"),
  Ethnicity STRING OPTIONS(description="An individual's self-described social and cultural grouping, specifically whether an individual describes themselves as Hispanic or Latino. The provided values are based on the categories defined by the U.S. Office of Management and Business and used by the U.S. Census Bureau."),
  HTAN_Center STRING OPTIONS(description="Name of HTAN Center e.g. HTAN HTAPP"),
  Manifest_Id STRING OPTIONS(description="Synapse ID of manifest containing file annotation"),
  Manifest_Version INT64 OPTIONS(description="Latest version of metadata manifest")
)
OPTIONS(
  friendly_name="HTAN CLINICAL TIER 1 DATA - DEMOGRAPHICS R4 VERSIONED",
  description="This table contains demographic clinical information about HTAN patient cases based on the NCI Genomic Data Commons (GDC) clinical data model. Data was extracted from HTAN Synapse projects in October 2023. More details: see https://data.humantumoratlas.org/standard/clinical",
  labels=[("access", "open"), ("data_type", "clinical_data"), ("program", "htan"), ("source", "htan"), ("category", "clinical_biospecimen_data"), ("status", "current")]
);

INSERT INTO `isb-cgc-bq.HTAN_versioned.clinical_tier1_demographics_r4` (Age_Is_Obfuscated, Days_to_Birth, Id, Occupation_Duration_Years, Year_of_Death, entityId, Gender, Component, Vital_Status, Race, Premature_At_Birth, Cause_of_Death_Source, HTAN_Participant_ID, Weeks_Gestation_at_Birth, Days_to_Death, Cause_of_Death, Year_Of_Birth, Country_of_Residence, Ethnicity, HTAN_Center, Manifest_Id, Manifest_Version) VALUES (NULL, '0', '301e179a-ed59-45b0-ab13-f0ea2a2da1d3', NULL, NULL, NULL, 'female', 'Demographics', 'Alive', 'Other', 'Not Reported', 'Not Reported', 'HTA11_347', NULL, NULL, 'Not Reported', '1959.0', NULL, 'not hispanic or latino', 'HTAN Vanderbilt', 'syn38868669', 9), ('True', NULL, 'fc08e4ab-bbc6-4783-9acf-a77d13d04498', NULL, NULL, 'syn26707337', 'male', 'Demographics', 'Alive', 'Other', NULL, NULL, 'HTA7_985', NULL, NULL, NULL, NULL, NULL, 'hispanic or latino', 'HTAN HMS', 'syn39143312', 5), ('True', '0', 'bc05371e-17fe-4bcb-86c2-13dcb8e4483f', NULL, NULL, NULL, 'male', 'Demographics', 'Dead', 'Other', NULL, 'Death Certificate', 'HTA3_80018', NULL, NULL, 'Cancer Related', NULL, NULL, 'unknown', 'HTAN BU', 'syn39147270', 7), ('True', '0', 'c9c908cc-f904-4481-bb3a-1f2993427fe7', NULL, NULL, NULL, 'Not Reported', 'Demographics', 'Alive', 'Other', NULL, NULL, 'HTA3_80026', NULL, NULL, 'Not Applicable', NULL, NULL, 'not hispanic or latino', 'HTAN BU', 'syn39147270', 7), ('True', NULL, '0e949083-08ee-4ce6-a81d-d3996e9b1a5b', NULL, NULL, 'syn28271980', 'female', 'Demographics', 'Alive', 'Other', 'Unknown', NULL, 'HTA2_229', NULL, NULL, NULL, '1957', NULL, 'hispanic or latino', 'HTAN HTAPP', 'syn42295584', 1);