Since you indicated that there is a maximum time available, and it's only a single-action undo, I would expire the Undo when: (in order of evaluation)
- The Undo action is taken (they un-do what they did)
- Another action is taken (since it's only a 1-level undo)
- The maximum time has elapsed
This is very much how the GMail Labs "Undo Send" feature works with the only difference being that the user can configure the timeout, since there isn't a legal limit in their case.
Now, I don't know if I would hide the Undo capability, but I think it might be better to use a "Inactive" or "Disabled" state indicator for it. This is what most desktop editing programs I'm familiar with do, especially with common actions. If an action isn't available, it is greyed out.
The advantage is that users will at least have a good chance of knowing they can Undo an action.
The final piece I would put in, depending on the task being "un-done" would be to put in a "Redo" action. Especially for anything that requires more than a click or two (eg. entering any text), having to re-do that work if I miss-clicked or changed my mind would be very irritating to me as a user.
Since it has been pointed out to me that I mis-read the OP and in fact there isn't a legal time constraint on when an action would get auto-committed, allow me to expand a bit on what I have above.
Allowing the user to configure the "commit window" to their preference would be ideal, but it really depends on what the purpose is. Since you mentioned that there are many distractions, it sounds more like the Undo capability is more of a "I got distracted and did the wrong thing" sort of a catch. To me, an "Are you sure" double-check would be better at catching these sorts of "distraction errors" than an Undo capability. It shifts the idea to Cancel rather than Undo. Especially in a healthcare environment, users should not be in the mindset of "rolling back" their actions and that what they do is final. Fixing such a mistake requires additional actions.