OHDSI/ROhdsiWebApi

@result_database_schema in ROhdsiWebApi::getCohortSql() output

jreps opened this issue · 3 comments

jreps commented

When executing:

ROhdsiWebApi::getCohortSql() with the public ATLAS webApi - it is adding the line:

"delete from @results_database_schema.cohort_censor_stats where cohort_definition_id = @target_cohort_id;"

which requires that the table 'cohort_censor_stats' exists - but if you just want to convert a json cohort into sql and execute it, you don't need the 'cohort_censor_stats' table and creating it is annoying.

I managed to remove the problematic line using gsub - but I'm wondering whether it is a bug that there is a @results_database_schema added?

@jreps - when calling getCohortSql() are you specifying generateStats = FALSE? By default, this parameter is set to TRUE which is why the cohort_censor_stats table is generated per Circe: https://github.com/OHDSI/circe-be/blob/master/src/main/resources/resources/cohortdefinition/sql/generateCohort.sql#L121-L127

As @anthonysena has said, this is resolved by setting generateStats to false.

However, in my opinion most users of this package will not want to generate the cohort stats because it requires creating additional tables. I think the boilerplate sql for these tables must live somewhere so I propose one of three solutions:

  1. Default behaviour of ROhdsiWebApi is to set generateStats = False
  2. Include the boilerplate sql to create the stats tables (including censor stats table)
  3. Both of the above.

@target_database_schema and @results_database_schema

Would use of #cohort_censor_stats instead of @results_database_schema.cohort_censor_stats made more sense?
also add 'if exists table' logic here

@chrisknoll