The invention provides a compound of formula (I) or its stereoisomer, tautomer or medicinal salt, wherein all variables are defined herein. These compounds are selective factor Xia inhibitors or double inhibitors of fxia and plasma kallikrein. The invention also relates to a pharmaceutical composition comprising these compounds and a method for treating thromboembolic and / or inflammatory diseases using the same.本發明提供式(I)化合物或其立體異構體、互變異構體或藥用鹽,其中所有變量均如本文中所定義。這些化合物爲選擇性因子XIa抑制劑或FXIa及血漿激肽釋放酶的雙重抑制劑。本發明還涉及包含這些化合物的藥物組合物及使用其治療血栓栓塞性和/或炎性病症的方法。