OHDSI / Era-Constructor

This is a repo that contains standardized code for hte construction of Drug Eras, Dose Eras and Condition Eras
2 stars 8 forks source link

Some era-building code already exists #2

Open schuemie opened 9 years ago

schuemie commented 9 years ago

Feel free to ignore, but might be helpful. I created code that constructs drug and condition eras for CDM v4 and v5, and it can be translated to all the platforms we support (SQL Server, PostgreSQL, Oracle, PDW, RedShift).

The R code is here.

The parameterized SQL it uses is here.

cgreich commented 9 years ago

Nice. Why is it in the Cohort Method?

schuemie commented 9 years ago

It had to be somewhere ;-)

Also, I currently just use it to construct custom drug eras (e.g. era of exposure to class of drugs) for CohortMethod.

cgreich commented 9 years ago

Let's consolidate. Looks like this is a V4.5 job, isn't it? What about the gap_days?

schuemie commented 9 years ago

It should run on both V4 and V5 (see the cdmVersion parameter).

I guess by gap_days you mean gracePeriod? ('The number of days allowed between periods for them to still be considered part of the same era')

cgreich commented 9 years ago

No. What you mean we call "Persistence Window" around here. :)

gap_days is the amount of days the era actually had no coverage with drugs, assuming a non-stockpiling model (meaning, if there is an overlap the patient throws away everything that he still had in the medicine cabinet and starts with the new filling).

taylordelehanty commented 9 years ago

Hi @schuemie, I didn't know you did all this! That's awesome, so will it use the SQL Renderer that Patrick Ryan talked about in the forums?: http://forums.ohdsi.org/t/populating--era-tables/78/2?u=taylordelehanty Also, if you want an idea for how to do the gap_days with both methods (stockpiling and non-stockpiling) I have it in my branch of the Era-Constructor.: https://github.com/taylordelehanty/Era-Constructor/tree/UColorado-Denver-Anschutz/v5/PostgreSQL Also, if you have all of that done then, I don't know if my code really is needed? @cgreich I sent a pull request a while ago but nothing's been accepted or merged.

schuemie commented 9 years ago

@cgreich : If I have two prescriptions of drug A, one starting on day 1 and ending on day 10, and another one starting on day 20 and ending on day 30, with a 30 day grace period these will be merged into one era from day 1 to day 30. With a 0 day grace period, these will not be merged and you will have 2 eras, from day 1 to 10 and from day 20 to day 30.

@taylordelehanty : My code is based on the code by Chris Knoll, and yes, I modified it so it uses SqlRender in order to make the code parameterized and work across platforms.

taylordelehanty commented 9 years ago

Mine is too, I spent some time going through it and asking Chris questions about it, and then used the same algorithm to build the condition, drug, and dose era codes for v4 and v5.

Also, Martijn, what you described is the grace period, but the gap days is something different and requires a different calculation. For instance, in the first scenario you gave, the gap_days would be 10 because there are 10 days in the era that the patient is not using or prescribed the drug. In the second scenario, the gap_days would be 0 because in the timeline of each era, the patient is on the drug for the entirety of the era. Check out this forum post: http://forums.ohdsi.org/t/where-does-gap-days-come-from-when-building-cdm-v5-drug-era/661/15 Especially check out Patrick Ryan's post that explains it, he gives a very good example. I wrote both of the methods (stockpile and non-stockpile) that are mentioned in the forum post using Chris's algorithm, and if you want to incorporate them into your builder, you can find them both on my gist account: Stockpile: https://gist.github.com/taylordelehanty/41742e2eb7357099b66b Non-stockpile: https://gist.github.com/taylordelehanty/0f01e7d32dfe6faa27d1 I also ran these by Chris himself and he said they looked really good, and he had the same idea for both of them. Feel free to post on the forum if anything isn't explained clearly enough!

Taylor