This invention relates to heterocyclic compounds and their use in medicine. In particular, the present invention discloses heterocyclic compound of formula I, or an isotopically labeled compound thereof, or an optical isomer thereof, a geometric isomer thereof, a tautomer thereof or a mixture of various isomers, or a pharmaceutically acceptable salt thereof, or a prodrug thereof. The invention also relates to the use of these compounds in medicine.