I have a list of patients with visit effective from dates that fall within the effective dates of their initial visits that i don't need to bill. The effective dates start on the date of admission and end 30 days from the date of discharge. Since most patients are discharged the same day the common effective date rand is 30 days but can be more.
| Patient | Visit start date | discharge + 29 days | Number of visits | Bill / Don't Bill |
|---|---|---|---|---|
| John | 1/7/2021 | 2/5/2021 | 4 | Bill |
| John | 1/13/2021 | 2/11/2021 | 4 | Don't Bill |
| John | 2/11/2021 | 3/12/2021 | 4 | Bill |
| John | 2/18/2021 | 3/19/2021 | 4 | Don't Bill |
| Jane | 4/19/2021 | 5/18/2021 | 4 | Bill |
| Jane | 9/8/2021 | 10/7/2021 | 4 | Bill |
| Jane | 9/10/2021 | 10/9/2021 | 4 | Don't Bill |
| Jane | 9/18/2021 | 10/17/2021 | 4 | Don't Bill |
| Joe | 1/9/2021 | 2/7/2021 | 2 | Bill |
| Joe | 1/14/2021 | 2/12/2021 | 2 | Don't Bill |
I was hoping to find a function that can grab the initial date range based on the minimum of the "visit start date" column for each patient. In the image above the initial visit is marked "bill" and the initial date range is set to 1/7/2021-2/5/2021. Since John's 2nd visit has a visit start date that falls within the initial range it id marked don't bill. it does not matter that the discharge date is out of the range as long as the start date is within. John's 3rd visit has a visit start date outside the previous date range so it should be billed and set as the new date range. I hope this makes sense :(
