Hello all:
I cannot figure out how to do this...
I have a batch of claims data that look like this:
id from thru
date date cpt severity
1 1 1 99281 1
1 1 1 99282 3
1 1 2 99283 1
1 1 3 99284 1
1 1 4 99284 2
1 2 3 99285 2
1 2 4 99285 1
1 3 4 99283 2
2 1 2 99284 3
2 2 3 99285 2
3 3 4 99285 1
4 1 1 99281 1
4 2 2 99281 3
4 3 3 99281 2
5 1 2 99282 3
6 1 1 99283 2
7 1 1 99282 1
7 1 2 99282 3
7 1 3 99283 2
7 1 4 99284 1
8 1 1 99285 2
etc.
I am supposed to aggregate this into an episode level file that allows for a maximum of three days between from and through date, while retaining all the other information in the claims, but only if dates overlap in claims. So, for example, all of the claims for id=1 would be collapsed into a single episode of care, because all the dates fall into the range 1-4. But the claims for id=4 would generate 3 episodes, because the dates between services are distinct. And I have to save all the information from all the claims regardless of how many distinct episodes are created - original from and thru dates, cpt codes, and severity levels.
Any ideas?
Thanks a lot!!!
bethcook