Encounter form tabs all mixed up?

Occasionally after a long time running the EMR or CPS and many, many imports of encounter forms, something happens where errors begin to occur during the process of importing encounter forms.

When bringing up forms that show these errors on import, the tabs may be out of synch. Sometimes, tabs appear form other forms and sometimes they are just out of order.

The solution is a bit of a trick and has to do with resynching the id generation for form components:

Begin Tran
declare @maxfid varchar(10)
select @maxfid = dbo.maxfid()
update dbo.uniqueid set fid = @maxfid where FID <> @maxfid