Matching and confirming combination of data from different columns, where data could be exact or an approximate match

I have a case, I am not sure if its possible to solve, but I will appreciate any help or soem sort of workaround. I need to compare combination of data from columns A+B with combination of data from columns D+E. For example row 2 Procedure MRI + subject 25 can be found on row 4 Columns D and E. The tricky part is that column A can contain different version of MRI, or any other procedure. Is it possible to match A+B combo and D+E combo and yet detect how many versions of a procedure are present in column A. You can refer to column G for results in this scenario. For example, Pharm dispense have 3 corresponding procedures in column A, etc.

Can the above be done through a formula, or vba?

enter image description here