Closed MPagel closed 5 months ago
INSERT INTO @resultsDatabaseSchema.N3C_CONTROL_MAP
SELECT
person_id, 1 as buddy_num, CAST(NULL as integer)
FROM @resultsDatabaseSchema.n3c_case_cohort
WHERE person_id NOT IN (
SELECT case_person_id
FROM @resultsDatabaseSchema.N3C_CONTROL_MAP
WHERE buddy_num = 1
)
UNION
SELECT person_id, 2 as buddy_num, CAST(NULL as integer)
FROM @resultsDatabaseSchema.n3c_case_cohort
WHERE person_id NOT IN (
SELECT case_person_id
FROM @resultsDatabaseSchema.N3C_CONTROL_MAP
WHERE buddy_num = 2
)
;
appears to work
Using redshift as DBE
at 74% complete in N3cOhdsi::createCohort(connectionDetails = connectionDetails, sqlFilePath = phenotypeSqlPath, cdmDatabaseSchema = cdmDatabaseSchema, resultsDatabaseSchema = resultsDatabaseSchema ) executed from example_execution.R
contents of referenced text file:
CREATE TABLE IF NOT EXISTS n3c_ncats.n3c_control_map ( case_person_id INTEGER NOT NULL ENCODE az64 ,buddy_num INTEGER NOT NULL ENCODE az64 ,control_person_id INTEGER ENCODE az64 )
CREATE TABLE IF NOT EXISTS n3c_ncats.n3c_case_cohort ( person_id INTEGER NOT NULL ENCODE az64 ,pt_age VARCHAR(20) ENCODE lzo ,sex VARCHAR(20) ENCODE lzo ,hispanic VARCHAR(20) ENCODE lzo ,race VARCHAR(20) ENCODE lzo )