Short buffs and long actions

How do buffs with short durations (guidance for 1 minute lets say) work when used to buff rolls for long actions? (such as a heal check for treat disease)

Does the buff work at all? Does it have to be cast right at the end before the check?