First post, have been searching extensively for a month for an answer to this and figured I would just ask the experts.
I have populated a table with patient accounts that have received services at a hospital. I am pulling columns listing the performing physician on each of their procedures. The values of those columns are sequence numbers that point me to a set of columns in a second table. The columns in the second table actually contain the physician identifiers I need.
Example:
TABLE 1
Account: Phys_Proc1 Phys_Proc2 PhysProc3 PhysProc4 PhysProc5`
Patient1 2 5 1 4 5
Patient2 1 3 3 4 0
Patient3 2 0 0 0 0
TABLE 2
Account: Physician1 Physician2 Physician3 Physician4 Physician5
Patient1 500123 500456 500789 600123 600456
Patient2 400321 500700 300876 456789 987654
Patient3 300500 800700 0 0 0
I need up update the records in TABLE 1 with the values from TABLE 2 where the value in TABLE 1 refers to the column name from TABLE 2.
EXAMPLE
Patient1 had procedure1 performed by ‘500456’ (Phys_Proc1’s value is “2” which refers to the Physician2 field in TABLE 2.)
Any help would be greatly appreciated. Even a hint at this point would give me a direction to look in. Pointing me toward a specific function name to search is better than what I have now (nothing.) I tried an extensive CASE statement but it didn’t pull the values for each patient account and pulled the values from TABLE 2 for the first account and applied it to all patient records.
Note: I haven’t tried this for syntax. I hope this gives you an idea on how to proceed further.