I believe this tune is actually by Jeremiah Clarke, it is a mistake that has propagated through the years. I don't know anything about where the D minor section comes from though, I only recognize the D major theme. Clarke also has a Trumpet Voluntary (different than this tune) which incorrectly gets Purcell's name attached to it. see the biography section https://en.wikipedia.org/wiki/Jeremiah_Clarke
Haven't yet had a chance to try it out so cannot comment on others' posts about accuracy, but it is quite obviously an arrangement for organ - the bottom line of the bass stave is intended to be played on the pedals, unless any of you have hands that can span a 2-octave range with one hand?!
https://en.wikipedia.org/wiki/Jeremiah_Clarke