-- DBMS: bigquery
CREATE TABLE `isb-cgc-bq.HTAN_versioned.clinical_tier2_r3`
(
  Component STRING OPTIONS(description="Category of metadata (e.g. Diagnosis, Biospecimen, scRNA-seq Level 1, etc.); provide the same one for all items/rows."),
  HTAN_Participant_ID STRING OPTIONS(description="HTAN ID associated with a patient based on HTAN ID SOP (eg HTANx_yyy )"),
  Timepoint_Label STRING OPTIONS(description="Label to identify the time point at which the clinical data or biospecimen was obtained (e.g. Baseline, End of Treatment, Overall survival, Final). NO PHI/PII INFORMATION IS ALLOWED."),
  Start_Days_from_Index STRING OPTIONS(description="Number of days from the date of birth (index date) to the date of an event (e.g. exposure to environmental factor, treatment start, etc.). If not applicable please enter 'Not Applicable'"),
  Stop_Days_from_Index STRING OPTIONS(description="Number of days from the date of birth (index date) to the end date of the event (e.g. exposure to environmental factor, treatment start, etc.). Note: if the event occurs at a single time point, e.g. a diagnosis or a lab test, the values for this column is 'Not Applicable'"),
  Sentinel_Lymph_Node_Count STRING OPTIONS(description="Numeric count of sentinel lymph nodes."),
  Sentinel_Node_Positive_Assessment_Count STRING OPTIONS(description="The number or amount of metastatic neoplasms related to the confirmed presence of disease or specific microorganisms during examination of the first rounded mass of lymphatic tissue to which cancer is likely to spread from the primary tumor."),
  Tumor_Extranodal_Extension_Indicator STRING OPTIONS(description="The indicator to determine extranodal involvement or extent of the disease."),
  Satellite_Metastasis_Present_Indicator STRING OPTIONS(description="A yes/no indicator to ask if intransit metastases or satellite lesions are present."),
  Other_Biopsy_Resection_Site STRING OPTIONS(description="A description of the location on or within the human body where the surgical biopsy/resection procedure was performed (Not covered under HTAN Clinical Data Tier 1)"),
  Extent_of_Tumor_Resection STRING OPTIONS(description="The degree to which the lesion has been cut out, or resected."),
  Precancerous_Condition_Type STRING OPTIONS(description="The classification of pre-cancerous cells found in a specific collection of data being studied by the Consortium for Molecular and Cellular Characterization of Screen-Detected Lesions (MCL)."),
  Prior_Sites_of_Radiation STRING OPTIONS(description="The anatomic location to which radiation treatment was administered to a patient prior to enrollment on a protocol."),
  Immunosuppression STRING OPTIONS(description="The indicator that describes whether or not immunosuppressive therapy was administered."),
  Concomitant_Medication_Received_Type STRING OPTIONS(description="An enumerated list of the type of concomitant medication received by the patient."),
  Family_Member_Vital_Status_Indicator STRING OPTIONS(description="The response indicates whether the family member of the patient with a history of cancer is alive. (Extension to GDC attributes in Family History Tier 1)"),
  COVID19_Occurrence_Indicator STRING OPTIONS(description="The indicator that describes whether or not a COVID-19 infectious disorder occurred."),
  COVID19_Current_Status STRING OPTIONS(description="The patient's current COVID-19 status of sign or symptom events or interventions"),
  COVID19_Positive_Lab_Test_Indicator STRING OPTIONS(description="The indicator that describes whether or not there was a COVID-19 positive test result."),
  COVID19_Antibody_Testing STRING OPTIONS(description="Text term that demonstrates the test results of immunoglobulin M (IgM) and immunoglobulin G (IgG) antibodies to the SARS-CoV-2 virus in subject serum samples."),
  COVID19_Complications_Severity STRING OPTIONS(description="Text term that retrospectively indicates the worst complications during COVID-19 infectious disorder in the patient."),
  COVID19_Cancer_Treatment_Followup STRING OPTIONS(description="Indicator that describes if cancer treatment was modified for the patient due to COVID-19 infectious disorder"),
  Ecig_vape_use STRING OPTIONS(description="Use of non-traditional cigarette nicotine delivery device (electronic cigarette, ENDS - electronic nicotine delivery system)"),
  Ecig_vape_30_day_use_num STRING OPTIONS(description="Number of days e-cigarettes or vaping device was used in the last 30 days"),
  Ecig_vape_times_per_day STRING OPTIONS(description="e-cig frequency of use (times per day—one “time” consists of around 15 puffs or lasts around 10 minutes)"),
  Type_of_smoke_exposure_cumulative_years STRING OPTIONS(description="The number of cumulative years of the patient's specific type of smoke exposure"),
  Chewing_tobacco_daily_use_count STRING OPTIONS(description="The quantity of daily use of tobacco, in the form of a plug, usually flavored, for chewing rather than smoking."),
  Second_hand_smoke_exposure_years STRING OPTIONS(description="The number of cumulative years of the patient's exposure to second-hand cigarette smoke"),
  Known_Genetic_Predisposition_Mutation STRING OPTIONS(description="A yes/no/unknown indicator to identify whether there is a known genetic predisposition mutation present in the patient."),
  Hereditary_Cancer_Predisposition_Syndrome STRING OPTIONS(description="History of presence of inherited genetic predisposition syndrome that confers heightened susceptibility to cancer in the patient."),
  Cancer_Associated_Gene_Mutations STRING OPTIONS(description="Type of inherited germline or other gene mutations that confers heightened susceptibility to cancer identified in patient history"),
  Mutational_Signatures STRING OPTIONS(description="Mutational signatures identified in the patient, includes signatures linked to selected exogenous carcinogens, endogenous and enzymatic modification of DNA or defective DNA repair. Note: Include only outputs of tests that were completed clinically for the participant and only include data from a diagnostic array that was completed prior to research sequencing was done. "),
  Mismatch_Repair_System_Status STRING OPTIONS(description="The text that best describes the condition or state of MMR (mismatch repair system) in the patient"),
  Lab_Tests_for_MMR_Status STRING OPTIONS(description="Laboratory tests used to evaluate the status of mismatch repair pathways"),
  Mode_of_Cancer_Detection STRING OPTIONS(description="Text term used to describe the mode of cancer detection, like standard of care screening or random detection"),
  Education_Level STRING OPTIONS(description="Highest level of education that the patient completed (direct patient-derived information)"),
  Country_of_Birth STRING OPTIONS(description="Country where the patient was born."),
  Medically_Underserved_Area STRING OPTIONS(description="Areas or populations designated by HRSA as having too few primary care providers, high infant mortality, high poverty or a high elderly population:  Use patient zip code to find the county the patient lives in by going to https://www.unitedstateszipcodes.org/ - enter the zip code in the main text field and use the associated county on the right side of the result field. Go to data.hrsa.gov website and select \"Query Data\". Pick the Medically Underserved Areas/Populations (MUA/P) data source in the step 1 menu and select \"View Data\". Enter the name of the county (_______ county) in the first \"Service Area\" column, adding the state in the 5th column may help direct you to the data.  If the designation type in the third column is \"medically underserved area\" enter \"Yes\" as the value. If the county generates a \"No data available in table\" enter \"No\" as the value.  A value of \"Unknown\" indicates that sufficient data was not available to look up the value.  If value is yes, complete the Medically_underserved_score d"),
  Rural_vs_Urban STRING OPTIONS(description="Density of population in the county of residence, based on census data (updated last on 4/28/20). Use patient zip code to find the county the patient lives in by going to https://www.unitedstateszipcodes.org/. Enter the zip code in the main text field and use the associated county on the right side of the result field. Go to https://www2.census.gov/programs-surveys/acs/data/covid_19/Data_Profiles_for_HHS/050-County_By_State/. Select the dp02_XX.csv file where XX = the two letter abbreviation for the appropriate state. On row 166 find the total population for the appropriate county.  If the total population is <2,500 enter a value of \"Rural Population\"; if 2,500 - 50,000 enter a value of \"Urban Cluster\"; or if >50,000 enter \"Urban Population\""),
  Cancer_Incidence STRING OPTIONS(description="Incidence of specific cancer type in a defined area (a number between 0 and 100). The rate of incident cases per population of 100,000 persons of a specific type of cancer as designated in the \"primary_diagnosis\" data element in the county where the patient resides, using the most recent 2013-2017 NCI Cancer Atlas derived data.  Use patient zip code to find the county the patient lives in by going to https://www.unitedstateszipcodes.org/. Enter the zip code in the main text field and use the asociated county on the right side of the result field. On the https://gis.cancer.gov/canceratlas/tableview/ website, choose \"Incidence\" from the Topic dropdown menu, state of interest from the Area menu, \"All Races\" from the Race menu, and the cancer type (\"Both Sexes\" when possible) from the Statistic menu. Find the county of interest and enter the numeric Age-Adjusted Rate per 100,000 as the value."),
  Cancer_Incidence_Location STRING OPTIONS(description="The county and state in which the patient lives and to which the cancer_incidence data correlates. Record as \"County, State\" as they appear in the incidence box from which the cancer_incidence data is obtained in the https://gis.cancer.gov/canceratlas/tableview/ website"),
  entityId STRING OPTIONS(description="Synapse ID of entity"),
  HTAN_Center STRING OPTIONS(description="Name of HTAN Center e.g. HTAN HTAPP"),
  Data_Release STRING OPTIONS(description="Inclusion in HTAN Data Release e.g. Release 1.0"),
  Manifest_Version INT64 OPTIONS(description="Latest version of metadata manifest"),
  Uuid STRING OPTIONS(description="Unique identifier of entity e.g. a96059eb-81af-4b24-ae50-9242c0d8f819")
)
OPTIONS(
  friendly_name="HTAN CLINICAL TIER 2 DATA R3 VERSIONED",
  description="This table contains second tier clinical information about HTAN patient cases, specifically disease-agnostic extensions to the GDC clinical data model. Data was extracted from HTAN Synapse projects in April 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_tier2_r3` (Component, HTAN_Participant_ID, Timepoint_Label, Start_Days_from_Index, Stop_Days_from_Index, Sentinel_Lymph_Node_Count, Sentinel_Node_Positive_Assessment_Count, Tumor_Extranodal_Extension_Indicator, Satellite_Metastasis_Present_Indicator, Other_Biopsy_Resection_Site, Extent_of_Tumor_Resection, Precancerous_Condition_Type, Prior_Sites_of_Radiation, Immunosuppression, Concomitant_Medication_Received_Type, Family_Member_Vital_Status_Indicator, COVID19_Occurrence_Indicator, COVID19_Current_Status, COVID19_Positive_Lab_Test_Indicator, COVID19_Antibody_Testing, COVID19_Complications_Severity, COVID19_Cancer_Treatment_Followup, Ecig_vape_use, Ecig_vape_30_day_use_num, Ecig_vape_times_per_day, Type_of_smoke_exposure_cumulative_years, Chewing_tobacco_daily_use_count, Second_hand_smoke_exposure_years, Known_Genetic_Predisposition_Mutation, Hereditary_Cancer_Predisposition_Syndrome, Cancer_Associated_Gene_Mutations, Mutational_Signatures, Mismatch_Repair_System_Status, Lab_Tests_for_MMR_Status, Mode_of_Cancer_Detection, Education_Level, Country_of_Birth, Medically_Underserved_Area, Rural_vs_Urban, Cancer_Incidence, Cancer_Incidence_Location, entityId, HTAN_Center, Data_Release, Manifest_Version, Uuid) VALUES ('ClinicalDataTier2', 'HTA1_261', 'resection initial', '31054', NULL, NULL, NULL, NULL, 'Yes', 'brain right frontal lobe', 'Gross Total Resection', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'syn25882759', 'HTAN HTAPP', 'Release 2.0', 1, '3ff3e0be-714b-49c7-b6ee-0945caf180f2'), ('ClinicalDataTier2', 'HTA1_261', 'resection recurrence', '31414', NULL, NULL, NULL, NULL, 'Yes', 'brain left temporal lobe', 'Optimal debulking', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'syn25882760', 'HTAN HTAPP', 'Release 2.0', 1, '513e3d3f-d236-4010-8509-d4e5b8bc87dc'), ('ClinicalDataTier2', 'HTA1_293', 'resection recurrence', '27183', NULL, NULL, NULL, NULL, 'Yes', 'brain left frontal lobe', 'Subtotal Resection', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'syn25882764', 'HTAN HTAPP', 'Release 2.0', 1, '56b20b0c-5169-475c-afb2-7fd119d71aa1'), ('ClinicalDataTier2', 'HTA1_261', 'radiation timepoint 1', '31085', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Brain', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'syn25882758', 'HTAN HTAPP', 'Release 2.0', 1, 'd88f0893-2b0e-4f52-9aa7-c5fb1cac3af5'), ('ClinicalDataTier2', 'HTA1_415', 'radiation timepoint 1', '9300', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Mantle', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'syn25882772', 'HTAN HTAPP', 'Release 2.0', 1, 'e18bb03b-edea-4621-b5cb-1fe0e4cbe315');