Skip to content

Commit

Permalink
Adding comments that explain motivation behind row_id and person_seq_id.
Browse files Browse the repository at this point in the history
  • Loading branch information
Admin_mschuemi authored and Admin_mschuemi committed Mar 17, 2023
1 parent 457f0ed commit 456537f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions inst/sql/sql_server/CreateCohorts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ limitations under the License.

DROP TABLE IF EXISTS #cohort_person;

-- Generating a unique row_id that can be used instead of the compound key
-- (subjectId, cohort_definition_id, cohort_start_date) for easier joining etc.
SELECT ROW_NUMBER() OVER (ORDER BY person_id, cohort_start_date) AS row_id,
subject_id,
cohort_definition_id,
Expand Down
2 changes: 2 additions & 0 deletions inst/sql/sql_server/GetCohorts.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{DEFAULT @target_id = ''}
{DEFAULT @sampled = FALSE}

-- Storing person_id as a VARCHAR because R doesn't support 64-bit integers. Generating
-- a proper integer (person_seq_id) on the fly for easy joining, etc.
SELECT row_id,
person_seq_id,
CAST(cohort.subject_id AS VARCHAR(30)) AS person_id,
Expand Down

0 comments on commit 456537f

Please sign in to comment.