OHDSI / PheValuator

An R package for evaluating phenotype algorithms.
https://ohdsi.github.io/PheValuator/
17 stars 6 forks source link

Future dates not supported #10

Closed SSMK-wq closed 4 years ago

SSMK-wq commented 4 years ago

Hello,

We shifted date records to future (lik 2500-01-01 etc) in our data-source (by retaining the chronological order) to maintain privacy.

When I executed the createPhenotypeModel function, I was able to see the below error message

Error: Error executing SQL:
org.postgresql.util.PSQLException: ERROR: function pg_catalog.date_part(unknown, unknown) is not unique
  Hint: Could not choose a best candidate function. You might need to add explicit type casts.
  Position: 817

Upon investigating the error report, I was able to see that you set future dates to 1900 which finally ends up giving zero records and date condition applied on these zero records results in the above error. I manually executed the SQL code provided in attached Error report

errorReport.txt

Can help us with this?

jswerdel commented 4 years ago

This was added in to catch "bad" dates from several CDMs. We will look for a better fix for this but in the interim perhaps you can continue to run it manually.

SSMK-wq commented 4 years ago

Hi,

Thanks for the response. Sorry, I didn't understand. This is what I did.

I followed the tutorial doc and created 3 cohorts.

Later, when I executed "CreatePhenoTypeModel", I encountered this error. Because our full dataset (all dates column in the data) is shifted to future dates.

As I encountered error in the very first step during model creation, I was of the understanding that I will not be able to use PheValuator.

What do you mean by run it manually? Which part of the section are you referring to? As Phevaluator provided error report, I inspected the query and manually executed to see what's the issue.

Can Phevaluator be used just as usual by following the tutorial despite the above error?

jswerdel commented 4 years ago

You can try changing the file getPopnPrev.sql in the PheValuator package with something like the code in this file:

getPopnPrev.txt

(you need to change the file extension to sql - this forum won't allow extensions of sql to be uploaded into the comment field)

where the lowest valid observation period end year is equal to the current year + 500 (assuming you use 500 as the offset in years).

The package will use the new sql file for determining the prevalence. You probably want to rename the original getPopnPrev.sql file to save it just in case.

SSMK-wq commented 4 years ago

Hi,

Thanks. I am made changes to the package that I downloaded in my system. I have overcome this error now. Thanks for your suggestion.

jswerdel commented 4 years ago

Hello I have made a change to the package to allow for CDMs with dates in the future. The new parameter, checkDates, in the createPhenotypeModel function should be set to FALSE to bypass date checking. Please let me know if you still have issues.

SSMK-wq commented 4 years ago

Is default value for the parameter checkDates is False?

Because it works fine without specifying the parameter as well.

If yes, then this issue can be closed.

jswerdel commented 4 years ago

The default should be TRUE. Please re-install the latest version of PheValuator (1.0.4) and test using checkDates = FALSE.

Thanks.

SSMK-wq commented 4 years ago

I tried this without using the CheckDates parameter (default) and it didn't throw any error. Shouldn't I expect to see error message which I had earlier.

jswerdel commented 4 years ago

Please try it with the checkDates = FALSE rather than leaving it blank.

SSMK-wq commented 4 years ago

Should I expect to see error like earlier for future dates? Irrespective of whether I use checkDates = False or checkDates = True, I don't see any difference/error message like before.

jswerdel commented 4 years ago

Yes it should - I will see if I can further debug it.