You're still missing DDL for tables and indexes.
Things might speed up if you remove the ORDER BY and change your WHERE clause to
WHERE A.entitlement_function NOT LIKE '@@@%'
However, more improvements can be made with some changes to the DB (and possibly the code to remove the self join but I'm not sure). I'm sure that others will give better advices.