Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 how to group this medical claim data?

Author  Topic 

jeff06
Posting Yak Master

166 Posts

Posted - 2009-08-07 : 11:38:05
table

patientid firstdateofsvc lastdateofsvc
1 4/1/2008 4/1/2008
1 4/1/2008 4/2/2008
1 4/1/2008 4/6/2008
1 4/2/2008 4/3/2008
1 4/2/2008 4/5/2008
1 4/7/2008 4/7/2008
1 4/9/2008 4/9/2008
1 4/9/2008 4/9/2008
1 4/21/2008 4/22/2008
1 4/23/2008 4/25/2008
2 4/21/2008 4/22/2008
2 4/22/2008 4/25/2008


expected ret
patientid firstdateofsvc lastdateofsvc admission
1 4/1/2008 4/1/2008 1
1 4/1/2008 4/2/2008 1
1 4/1/2008 4/6/2008 1
1 4/2/2008 4/3/2008 1
1 4/2/2008 4/5/2008 1
1 4/7/2008 4/7/2008 1 --because 4/7 next to 4/6
1 4/9/2008 4/9/2008 2 -- 4/9 is not next to 4/7
1 4/9/2008 4/9/2008 2
1 4/21/2008 4/22/2008 3
1 4/23/2008 4/25/2008 3
2 4/21/2008 4/22/2008 1
2 4/22/2008 4/25/2008 1

this is medical claim data. I want to find how many hospital admissions a patient have and how many days a patient stay in hospital. The assumption is a patient who stay in hospital should have continuous calims.For example for patientid 1 has claims from 4/1 to 4/7 every day. it is consider 1 admission. In 4/8, no claim.
but in 4/9 there is a claim. it is cosidered another admission. I spend two days but not able to find a solution. Can anyone kindly give me a hint on how to solve this problem?
Thanks.
Jeff

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-08-07 : 11:49:03
Let's stick with this original post:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=130792

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -