The following script builds a transitive closure of the CCG mergers over time.
The included .csv will include one row for each CCG from when it was valid, to the day before the successor was valid.
It then includes a row from that CCG to any of it's successors, along with the dates that successor was valid from and to.
You can therefore filter the .csv file for any date by checking if your_date >= from_date & your_date <= to_date,
then you can join your data on the from column, using the to column as the successor organisation.