Modified the code around the waitbar to not make any changes to the patient data if the cancel button is pressed. This prevents half of the data from being changed while the other half remains the same.