It is OK to file H1B before or after applying in the diversity visa lottery program, or vice-versa. There is no problem as the H visa is a dual-intent visa category allowing for intention to immigrate to the U.S. even though it is a nonimmigrant visa.