Deal to lower drug costs for Americans and shield the drugmaker from import tariffs was the culmination of efforts stretching back to November last year, sources say.