Skip to content

Commit

Permalink
add: add sample sql help files #29
Browse files Browse the repository at this point in the history
  • Loading branch information
MeetAnithaVarghese committed Oct 1, 2024
1 parent b879adc commit 91b84a0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- TODO: Use ChatGPT to fully understand what participant data represents and incorporate insights from GitHub discussions.
-- If the column in the CSV file `participant` is `patient_id` and instead of `gender` the CSV file has `sex` as the column name.
-- Drop and recreate the participant_data view
DROP VIEW IF EXISTS drh_participant_data;
CREATE VIEW drh_participant_data AS
SELECT
patient_id AS participant_id, study_id, site_id, diagnosis_icd, med_rxnorm,
treatment_modality, sex AS gender, race_ethnicity, age, bmi, baseline_hba1c,
diabetes_type, study_arm
FROM uniform_resource_participant;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- Drop the view if it exists
DROP VIEW IF EXISTS drh_participant_data;

-- Create a view with a prefixed and UUID-appended participant_id, and unchanged foreign key values
CREATE VIEW drh_participant_data AS
SELECT
-- Prefix with 'PART_' and append a UUID-like hex blob
'PART_' || lower(hex(randomblob(2)) || hex(randomblob(2))) AS participant_id,
-- Foreign keys (study_id and site_id) must remain unchanged
study_id, site_id, diagnosis_icd, med_rxnorm,
treatment_modality, gender, race_ethnicity, age, bmi, baseline_hba1c,
diabetes_type, study_arm
FROM uniform_resource_participant;

0 comments on commit 91b84a0

Please sign in to comment.