OHDSI / TheBookOfOhdsi

The Book of OHDSI repository
https://ohdsi.github.io/TheBookOfOhdsi/
Creative Commons Zero v1.0 Universal
111 stars 83 forks source link

document cohort exit magic #64

Closed clarkevans closed 4 years ago

clarkevans commented 5 years ago

In the cohort exit section it talks about "magic". While the SQL's implementation may be magical and need not be further discussed, the exact logical algorithm that this query implements is not documented. This is quite important to understanding what it means to generate an exit cohort in OHDSI. The algorithm could be discussed informally, but it should express what considerations and/or cases are accounted for.

Consider refactoring this code so that previous queries populate a temporary cohort era table, with subject, begin/end. Then, a separate SQL fragment that might be more digestible could be written that collapses these eras. Doing both the era extraction and the collapse at the same time make the logic hard to follow. If these two operations were separated, perhaps both could be more easily explained.

schuemie commented 5 years ago

Good points. I'll modify the section.