I'm very interested to know if those that were unaffected were simply lucky or have been doing something different that can and should be shared across the NHS as a whole.
Two factors at present from what we have been told: -
1) Some Trusts/CCGs haven't applied patches to the servers leaving an opportunity for the ransomware to be able to deploy across a network
2) McAfee AV software caught it and the firewall stopped it whereas another AV software didn't catch it and it got into the system then propagated
A 3rd factor will be the speed at which IT services for those affected were able to isolate the system to prevent it spreading further.
This will need a long hard look at as it will not be the last time we see this attempted on the IT systems within the NHS and in fact, any organisation.