Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Match unlinked data based on datetimes

Status
Not open for further replies.

kdbenson

Programmer
Jan 7, 2009
11
US
I am trying to track the time between when a patient is discharged from a hospital to when they receive a follow-up telephone call. There is no direct link in the database (Teradata) between the hospital admission encounter and the folow-up telephone call so I would like to match the discharge date from the hospital admission to the most recent follow-up call after the discharge. However, a patient may have multiple admissions during a timeframe and multiple follow-up calls. If a follow-up call is matched with one previous discharge it cannot be matched with another discharge. The data looks similar to this:

LINE PAT_NAME DISCHARGE_DT FU_CALL_DT TIME_DIFF
1 Smith, Bob 9/1/2012 18:28 9/17/2012 13:34 22746
2 Smith, Bob 9/1/2012 18:28 9/21/2012 9:40 28272
3 Smith, Bob 9/1/2012 18:28 9/25/2012 14:24 34316
4 Smith, Bob 9/13/2012 17:37 9/17/2012 13:34 5517
5 Smith, Bob 9/13/2012 17:37 9/21/2012 9:40 11043
6 Smith, Bob 9/13/2012 17:37 9/25/2012 14:24 17087
7 Smith, Bob 9/20/2012 13:35 9/21/2012 9:40 1205
8 Smith, Bob 9/20/2012 13:35 9/25/2012 14:24 7249

In the case above, the records I need to return are lines 1,5, and 8. This matches the discharge with the most recent follow-up call that does not already have a match. The follow-up time can also be null in the cases where a patient did not receive a follow-up call so this scenario needs to be accounted for as well.

Any suggestions for how to do this would be appreciated. Please let me know if something is unclear or if you need more information.

Thanks,
Kevin
 
Why do you require separate fu-calls for different discharge dates? I mean, Bob Smith was discharged twice before he got his first fu-call, why does this call only count for the first discharged date? (If it doesn't count for both days, don't store that fu_call for both discharged days.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top