-- DBMS: bigquery
CREATE TABLE `isb-cgc-bq.HTAN_versioned.clinical_tier3_lung_r4`
(
  entityId STRING OPTIONS(description="Synapse ID of entity"),
  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'"),
  HTAN_Participant_ID STRING OPTIONS(description="HTAN ID associated with a patient based on HTAN ID SOP (eg HTANx_yyy )"),
  Current_Lung_Cancer_Symptoms STRING OPTIONS(description="Reported lung cancer related symptoms person is currently experiencing"),
  Id STRING OPTIONS(description="Unique identifier of entity e.g. a96059eb-81af-4b24-ae50-9242c0d8f819"),
  Lung_Adjacent_Histology_Type STRING OPTIONS(description="The type of morphologic characteristics observed by microscope in the tissue next to a benign or malignant tissue growth"),
  Lung_Cancer_Harboring_Genomic_Aberrations STRING OPTIONS(description="Genomic aberrations in participants with lung cancer (specific lung cancer associated gene mutations not covered in Tiers 1 and 2)"),
  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."),
  Component STRING OPTIONS(description="Category of metadata (e.g. Diagnosis, Biospecimen, scRNA-seq Level 1, etc.); provide the same one for all items/rows."),
  Lung_Cancer_Participant_Procedure_History STRING OPTIONS(description="Text name of a surgical or operative procedure used in a natural history protocol of a lung cancer participant."),
  Lung_Tumor_Location_Anatomic_Site STRING OPTIONS(description="Anatomic location of the tumor inside the lung"),
  Lung_Tumor_Lobe_Bronchial_Location STRING OPTIONS(description="Anatomic lobe and bronchial location of the tumor inside the lung"),
  Lung_Topography STRING OPTIONS(description="Lung PCA specific topography (not covered in previous tiers)"),
  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'"),
  Lung_Cancer_Detection_Method_Type STRING OPTIONS(description="The means, manner of procedure, or systematic course of actions performed in order to discover or identify lung cancer"),
  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 3 DATA - LUNG R4 VERSIONED",
  description="This table contains third-tier, lung clinical information about HTAN patient cases, specifically disease-agnostic extensions to the 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_tier3_lung_r4` (entityId, Stop_Days_from_Index, HTAN_Participant_ID, Current_Lung_Cancer_Symptoms, Id, Lung_Adjacent_Histology_Type, Lung_Cancer_Harboring_Genomic_Aberrations, Timepoint_Label, Component, Lung_Cancer_Participant_Procedure_History, Lung_Tumor_Location_Anatomic_Site, Lung_Tumor_Lobe_Bronchial_Location, Lung_Topography, Start_Days_from_Index, Lung_Cancer_Detection_Method_Type, HTAN_Center, Manifest_Id, Manifest_Version) VALUES ('syn24994797', NULL, 'HTA3_8002', NULL, 'becc2e14-7d72-4ac1-8027-31f6561a3c90', NULL, NULL, 'baseline', 'LungCancerTier3', 'Lobectomy Left', 'Left', 'Upper lobe', NULL, '0', NULL, 'HTAN BU', 'syn39148208', 2), ('syn24994800', NULL, 'HTA3_8005', NULL, '57a9ca13-540a-4f49-a6a3-4940ca26cb74', NULL, NULL, 'baseline', 'LungCancerTier3', 'Lobectomy Left', 'Left', 'Upper lobe', NULL, '0', NULL, 'HTAN BU', 'syn39148208', 2), ('syn24994801', NULL, 'HTA3_8006', NULL, 'b7c64ec5-987e-4604-9dfa-f3d179191c6c', NULL, NULL, 'baseline', 'LungCancerTier3', 'Lobectomy Left', 'Left', 'Upper lobe', NULL, '0', NULL, 'HTAN BU', 'syn39148208', 2), ('syn24994796', NULL, 'HTA3_8001', NULL, '5b9f5040-f56a-4749-be40-7ce22e9bfa12', NULL, NULL, 'baseline', 'LungCancerTier3', 'Lobectomy Right', 'Right', 'Lower lobe', NULL, '0', NULL, 'HTAN BU', 'syn39148208', 2), ('syn24994798', NULL, 'HTA3_8003', NULL, 'e6689588-8231-4dc1-bbec-d85d51ba07b1', NULL, NULL, 'baseline', 'LungCancerTier3', 'Lobectomy Right', 'Right', 'Upper lobe', NULL, '0', NULL, 'HTAN BU', 'syn39148208', 2);