214:1 The entire week of shiva, the mourner may not leave his home. He may leave for a funeral if a relative died, or even a non-relative if there aren’t enough people to take care of things. He may go out for this reason even on the first day of shiva. If the ruler sent for him, or if he needs to attend to some other pressing matter, such as avoiding a financial loss, he is permitted to go, placing dirt in his shoes.
214:2 Except for Shabbos, the mourner may not even go out during shiva in order to go to shul. If he can’t assemble a minyan and would be forced to daven alone and there is a minyan in the neighborhood, then he may leave his house and go there for services so as not to miss out on tefillah b’tzibbur (public prayer).