SQL Continuous Date Ranges Previously Grouped Data
0
I'm working with a data extract that represents claims data for a population. The ultimate goal is to be able to associate specific claims to unique encounters. The way we'd define an encounter is a string of claims that are continuous, or within the same range; meaning the claim-to date is followed up by a claim-from date immediately after, or has an identical to & from date as another claim. However, because there is no key that actually indicates that a group of claims represent a specific encounter, we have to implement logic that does this for us. For the sake of this example, we've already grouped the data by Patient & Facility. CREATE TABLE #BillingData ( ClaimID VARCHAR(MAX) ,Patient VARCHAR(MAX) ,Facility VARCHAR(MAX) ,ClaimFromDate DATE ,ClaimToDate DATE ,GroupID VARCHAR(MA...