@Lampasas Bill 's explanation correlates with most of the accounts I have read. The example I know the most about, Longstreet's corps at Gettysburg and Knoxville, seem to illustrate what would be considered the 'normal' process.
On the approach, the surgeons set up brigade field hospitals three to five miles behind the anticipated line of battle, at farms and houses along the approach route. Men who were sick, were treated before, during and after the battle. Men who were wounded were brought from the battlefield to the field hospital - usually the one of their brigade, although there are documented instances where a soldier or officer was brought to the nearest one instead. At both Gettysburg and Knoxville, men who were too sick or too badly wounded to transport were left behind in the barns and houses.
At Gettysburg, a group of surgeons and men serving as nurses was left behind to care for the patients. The hospitals were captured by the Union army soon after the Confederates retreated and the wounded left behind were eventually consolidated and incorporated into field hospitals run by the Federals.
At Knoxville, it was a bit of a different situation. There were not enough surgeons to leave any behind. At that point, each brigade seems to have had only a few surgeons and, in one brigade, only one. As far as I can tell, none were left behind with the wounded there. The hospitals were captured after Longstreet's force retreated. There was an outbreak of smallpox and so some of those in the hospitals were infectious. As far as I can tell, they were left where they were - out on the outlying farms. They were not moved into Federal hospitals in the city. A good number of them died and a good number of men who were left behind wounded, were infected. It was a mess.
EDIT TO ADD: I do not know what the exact situation was at Vicksburg, but it seems the retreat would have been an emergency situation..... not a planned one like Gettysburg or even Knoxville. In an emergency retreat, the sick and wounded would have most certainly have had to be left behind. No way to organize logistics and transportation in that situation.