Both could be used.
However, the use of “whether” always implies at least one alternative.
So, if “whether” is used, the sentence should be either:
“They discussed whether they should build a hospital or not.”
or
“They discussed whether they should build a hospital or a nursing home.”