Part of a hospital roof has collapsed in South Africa's largest city, injuring five people and forcing some patients wrapped in gowns and blankets to temporarily leave the building.

Rescue workers were assessing whether anyone was trapped in the rubble at Charlotte Maxeke Hospital in Johannesburg, where a section of roof fell near the main entrance, close to the maternity department.

Construction workers were fixing part of the roof when it collapsed, according to Gwen Ramokgopa, the provincial health chief.

She said the injured included two patients, two construction workers and one hospital staff member.

"The rest of the hospital is safe. The problem is contained to the entrance and the area is cordoned off," Ms Ramokgopa said.

Stones had been moved on to the section of roof that later collapsed, said Jack Bloom, a member of the Democratic Alliance, an opposition party.

He also cited hospital staff as saying in the past that there were leaking roofs and other structural problems in the building.

Beauty Mashaba, a patient who left the building after the collapse, was relieved.

"Thank God, because I am out in safety and I am alive even though I am in shock right now," she said.