Yes, they purposefully set this up. If you watch the first season of the show, the Janitor never interacts with anyone except for JD. There are a few occasions when a janitor is interacting minimally with others, but if you examine those scenes, it's not clear that anyone else sees the Janitor there.

As revealed in the DVD commentary on several episodes, the Janitor character was initially to be used as a figment of J.D.'s imagination if the show had been canceled during the first season or the first half of the second. This would have been revealed to the audience in the finale. ... Since the start of season two, Janitor has had encounters with most of the other regular characters. He has even had an entire episode ("His Story III") devoted mostly to him.