Hello,
I need to run descriptive stats on 'episodes of care' for patients at the hospital I work for. An episode of care is defined as a surgical date and the pre-surgical visits leading up to the surgical date. Any post surgical visits would not be included in the definition of 'episode of care'. The issue I'm running into is a single patient (PatientInternalID) may have received multiple surgeries at our surgery center. For example, PatientInternalId="100583" had surgery on 22330 (Feb 19, 2021). The patient had an office visit piror to surgery on 22312 (Feb 1, 2019). I would like to group these visits as being an 'episode of care'. The same patient then had a second surgery on 22600(Nov 16, 2021), and had four office visits prior to the patient's second surgery (or post first surgery). I would like group these four visits and surgery as an 'episode of care'. The only caveat is the pre-surgical visits for the patient's second surgery can only be part of that (second) episode of care if the visits are 90 days after the patients first surgery (there's a 90 day global period post surgery where we do not bill). So, in my second example, only 2/4 of the visits piror to the patient's second surgery would be included because two of the visits fall in the 90 day window post first surgery (22341 & 22369). Hopefully this isn't too convoluted. I'm hoping to create a variable that would help group episodes of care. When a patient only has a single surgery its quite easy to deal with. I use egen first = min(cond(TotalJoints=="Yes", date, .)), by(PatientInternalId). I get the surgical date across all observations by patient, calculate the difference from the patient's other dates of service, and drop any cases greater than 90 days. However, it becomes much more complicated when a patient has had multiple surgeries.
Any help would be much appreciated.
input str8 PatientInternalId float date str25 Department str3 TotalJoints
"100404" 21102 "X-Ray/Imaging" "No"
"100404" 21102 "Office Visits - Est" "No"
"100404" 21220 "X-Ray/Imaging" "No"
"100404" 21220 "Office Visits - Est" "No"
"100404" 21244 "Surgery" "Yes"
"100404" 21244 "Surgery" "Yes"
"100404" 21244 "Surgery" "No"
"100404" 21244 "Surgery" "No"
"100404" 21258 "X-Ray/Imaging" "No"
"100404" 21258 "Office Visits - Est" "No"
"100404" 21258 "Miscellaneous" "No"
"100404" 21283 "X-Ray/Imaging" "No"
"100404" 21283 "Miscellaneous" "No"
"100404" 21423 "Office Visits - Est" "No"
"100404" 21423 "X-Ray/Imaging" "No"
"100583" 22312 "**No Department" "No"
"100583" 22312 "Office Visits - Est" "No"
"100583" 22330 "Surgery" "Yes"
"100583" 22330 "Surgery" "Yes"
"100583" 22341 "X-Ray/Imaging" "No"
"100583" 22341 "Office Visits - Est" "No"
"100583" 22341 "Medications" "No"
"100583" 22341 "Medications" "No"
"100583" 22341 "Injections" "No"
"100583" 22341 "X-Ray/Imaging" "No"
"100583" 22369 "X-Ray/Imaging" "No"
"100583" 22369 "Miscellaneous" "No"
"100583" 22508 "X-Ray/Imaging" "No"
"100583" 22508 "Office Visits - Est" "No"
"100583" 22585 "Office Visits - Est" "No"
"100583" 22585 "X-Ray/Imaging" "No"
"100583" 22585 "**No Department" "No"
"100583" 22600 "Surgery" "Yes"
"100583" 22600 "Injections" "No"
"100583" 22613 "Miscellaneous" "No"
"100583" 22613 "X-Ray/Imaging" "No"
"100583" 22650 "Miscellaneous" "No"
"100583" 22650 "**No Department" "No"
"100583" 22650 "X-Ray/Imaging" "No"
"100583" 22719 "Office Visits - Est" "No"
"100583" 22719 "X-Ray/Imaging" "No"
"100583" 22719 "X-Ray/Imaging" "No"
"100583" 22964 "X-Ray/Imaging" "No"
"100583" 22964 "Injections" "No"
"100583" 22964 "Medications" "No"
"100583" 22964 "Office Visits - Est" "No"
"100583" 22964 "Medications" "No"
"100583" 23190 "X-Ray/Imaging" "No"
"100583" 23190 "Medications" "No"
"100583" 23190 "Injections" "No"
"100583" 23190 "Medications" "No"
"100583" 23190 "Office Visits - Est" "No"
"100583" 23288 "**No Department" "No"
"100583" 23288 "Office Visits - Est" "No"
"100583" 23310 "Surgery" "Yes"
"100583" 23310 "Surgery" "Yes"
"100583" 23323 "X-Ray/Imaging" "No"
"100583" 23323 "Miscellaneous" "No"
"100583" 23351 "X-Ray/Imaging" "No"
"100583" 23351 "Miscellaneous" "No"
"100583" 23351 "**No Department" "No"
"100583" 23421 "X-Ray/Imaging" "No"
"100583" 23421 "Office Visits - Est" "No"
"100583" 23503 "X-Ray/Imaging" "No"
"100583" 23503 "Office Visits - Est" "No"
"101254" 22375 "Office Visits - Est" "No"
"101254" 22375 "**No Department" "No"
"101254" 22404 "Surgery" "Yes"
"101656" 23330 "X-Ray/Imaging" "No"
"101656" 23330 "Office Visits - Est" "No"
"101656" 23330 "**No Department" "No"
"101656" 23330 "X-Ray/Imaging" "No"
"101656" 23330 "X-Ray/Imaging" "No"
"101656" 23355 "Miscellaneous" "No"
"101656" 23356 "Surgery" "Yes"
"101656" 23399 "X-Ray/Imaging" "No"
"101656" 23399 "X-Ray/Imaging" "No"
"101656" 23399 "Miscellaneous" "No"
"101656" 23427 "Miscellaneous" "No"
"101656" 23462 "Office Visits - Est" "No"
"101656" 23462 "X-Ray/Imaging" "No"
"101656" 23462 "X-Ray/Imaging" "No"
"101656" 23462 "X-Ray/Imaging" "No"
"101656" 23553 "X-Ray/Imaging" "No"
"101656" 23553 "X-Ray/Imaging" "No"
"101656" 23553 "Office Visits - Est" "No"
"101656" 23553 "X-Ray/Imaging" "No"
"101934" 23075 "DME" "No"
"101934" 23075 "**No Department" "No"
"101934" 23075 "Office Visits - Est" "No"
"101934" 23100 "Surgery" "Yes"
"101934" 23100 "Surgery" "Yes"
"101934" 23323 "Miscellaneous" "No"
"101934" 23476 "X-Ray/Imaging" "No"
"101934" 23476 "Office Visits - Est" "No"
"102297" 22123 "Office Visits - Est" "No"
"102297" 22123 "X-Ray/Imaging" "No"
"102297" 22180 "Surgery" "Yes"
"102297" 22180 "Surgery" "Yes"
"102297" 22232 "Miscellaneous" "No"
I need to run descriptive stats on 'episodes of care' for patients at the hospital I work for. An episode of care is defined as a surgical date and the pre-surgical visits leading up to the surgical date. Any post surgical visits would not be included in the definition of 'episode of care'. The issue I'm running into is a single patient (PatientInternalID) may have received multiple surgeries at our surgery center. For example, PatientInternalId="100583" had surgery on 22330 (Feb 19, 2021). The patient had an office visit piror to surgery on 22312 (Feb 1, 2019). I would like to group these visits as being an 'episode of care'. The same patient then had a second surgery on 22600(Nov 16, 2021), and had four office visits prior to the patient's second surgery (or post first surgery). I would like group these four visits and surgery as an 'episode of care'. The only caveat is the pre-surgical visits for the patient's second surgery can only be part of that (second) episode of care if the visits are 90 days after the patients first surgery (there's a 90 day global period post surgery where we do not bill). So, in my second example, only 2/4 of the visits piror to the patient's second surgery would be included because two of the visits fall in the 90 day window post first surgery (22341 & 22369). Hopefully this isn't too convoluted. I'm hoping to create a variable that would help group episodes of care. When a patient only has a single surgery its quite easy to deal with. I use egen first = min(cond(TotalJoints=="Yes", date, .)), by(PatientInternalId). I get the surgical date across all observations by patient, calculate the difference from the patient's other dates of service, and drop any cases greater than 90 days. However, it becomes much more complicated when a patient has had multiple surgeries.
Any help would be much appreciated.
input str8 PatientInternalId float date str25 Department str3 TotalJoints
"100404" 21102 "X-Ray/Imaging" "No"
"100404" 21102 "Office Visits - Est" "No"
"100404" 21220 "X-Ray/Imaging" "No"
"100404" 21220 "Office Visits - Est" "No"
"100404" 21244 "Surgery" "Yes"
"100404" 21244 "Surgery" "Yes"
"100404" 21244 "Surgery" "No"
"100404" 21244 "Surgery" "No"
"100404" 21258 "X-Ray/Imaging" "No"
"100404" 21258 "Office Visits - Est" "No"
"100404" 21258 "Miscellaneous" "No"
"100404" 21283 "X-Ray/Imaging" "No"
"100404" 21283 "Miscellaneous" "No"
"100404" 21423 "Office Visits - Est" "No"
"100404" 21423 "X-Ray/Imaging" "No"
"100583" 22312 "**No Department" "No"
"100583" 22312 "Office Visits - Est" "No"
"100583" 22330 "Surgery" "Yes"
"100583" 22330 "Surgery" "Yes"
"100583" 22341 "X-Ray/Imaging" "No"
"100583" 22341 "Office Visits - Est" "No"
"100583" 22341 "Medications" "No"
"100583" 22341 "Medications" "No"
"100583" 22341 "Injections" "No"
"100583" 22341 "X-Ray/Imaging" "No"
"100583" 22369 "X-Ray/Imaging" "No"
"100583" 22369 "Miscellaneous" "No"
"100583" 22508 "X-Ray/Imaging" "No"
"100583" 22508 "Office Visits - Est" "No"
"100583" 22585 "Office Visits - Est" "No"
"100583" 22585 "X-Ray/Imaging" "No"
"100583" 22585 "**No Department" "No"
"100583" 22600 "Surgery" "Yes"
"100583" 22600 "Injections" "No"
"100583" 22613 "Miscellaneous" "No"
"100583" 22613 "X-Ray/Imaging" "No"
"100583" 22650 "Miscellaneous" "No"
"100583" 22650 "**No Department" "No"
"100583" 22650 "X-Ray/Imaging" "No"
"100583" 22719 "Office Visits - Est" "No"
"100583" 22719 "X-Ray/Imaging" "No"
"100583" 22719 "X-Ray/Imaging" "No"
"100583" 22964 "X-Ray/Imaging" "No"
"100583" 22964 "Injections" "No"
"100583" 22964 "Medications" "No"
"100583" 22964 "Office Visits - Est" "No"
"100583" 22964 "Medications" "No"
"100583" 23190 "X-Ray/Imaging" "No"
"100583" 23190 "Medications" "No"
"100583" 23190 "Injections" "No"
"100583" 23190 "Medications" "No"
"100583" 23190 "Office Visits - Est" "No"
"100583" 23288 "**No Department" "No"
"100583" 23288 "Office Visits - Est" "No"
"100583" 23310 "Surgery" "Yes"
"100583" 23310 "Surgery" "Yes"
"100583" 23323 "X-Ray/Imaging" "No"
"100583" 23323 "Miscellaneous" "No"
"100583" 23351 "X-Ray/Imaging" "No"
"100583" 23351 "Miscellaneous" "No"
"100583" 23351 "**No Department" "No"
"100583" 23421 "X-Ray/Imaging" "No"
"100583" 23421 "Office Visits - Est" "No"
"100583" 23503 "X-Ray/Imaging" "No"
"100583" 23503 "Office Visits - Est" "No"
"101254" 22375 "Office Visits - Est" "No"
"101254" 22375 "**No Department" "No"
"101254" 22404 "Surgery" "Yes"
"101656" 23330 "X-Ray/Imaging" "No"
"101656" 23330 "Office Visits - Est" "No"
"101656" 23330 "**No Department" "No"
"101656" 23330 "X-Ray/Imaging" "No"
"101656" 23330 "X-Ray/Imaging" "No"
"101656" 23355 "Miscellaneous" "No"
"101656" 23356 "Surgery" "Yes"
"101656" 23399 "X-Ray/Imaging" "No"
"101656" 23399 "X-Ray/Imaging" "No"
"101656" 23399 "Miscellaneous" "No"
"101656" 23427 "Miscellaneous" "No"
"101656" 23462 "Office Visits - Est" "No"
"101656" 23462 "X-Ray/Imaging" "No"
"101656" 23462 "X-Ray/Imaging" "No"
"101656" 23462 "X-Ray/Imaging" "No"
"101656" 23553 "X-Ray/Imaging" "No"
"101656" 23553 "X-Ray/Imaging" "No"
"101656" 23553 "Office Visits - Est" "No"
"101656" 23553 "X-Ray/Imaging" "No"
"101934" 23075 "DME" "No"
"101934" 23075 "**No Department" "No"
"101934" 23075 "Office Visits - Est" "No"
"101934" 23100 "Surgery" "Yes"
"101934" 23100 "Surgery" "Yes"
"101934" 23323 "Miscellaneous" "No"
"101934" 23476 "X-Ray/Imaging" "No"
"101934" 23476 "Office Visits - Est" "No"
"102297" 22123 "Office Visits - Est" "No"
"102297" 22123 "X-Ray/Imaging" "No"
"102297" 22180 "Surgery" "Yes"
"102297" 22180 "Surgery" "Yes"
"102297" 22232 "Miscellaneous" "No"
Comment