If [ not IsEmpty(Patient::Export_record=1) ] makes me think too much, why not
IF [ Patient::Export_record ] ??
and in any case, the if should be inside the loop, not outside...
I used the 'not IsEmpty' to lead to a dialogue telling the user to 'X checkbox' some records, ie. select some for export.
I put the 'if' outside the loop so that if there are no records for export, the script would hop straight to the above-mentioned dialogue.