In Dances With Wolves, why did John Dunbar leave the field hospital and later ride out into the field in front of enemy soldiers?

As Kevin Costner, directing from Michael Blake's screenplay, opens his film Dances with Wolves, the character of Lt. John Dunbar, played by Costner, is lying on a table in a crude Army field hospital. His leg is badly wounded from enemy gunfire, and two physically and mentally exhausted surgeons prepare to amputate his wounded limb. Pausing instead to get some coffee and rest before proceeding, having already operated on numerous soldiers and amputated numerous infected limbs, the surgeons leave Dunbar alone on the table. The wounded lieutenant sits up and looks around. As Blake's screenplay continues:

"His (Dunbar) eyes come to rest on the form of a legless man lying in blood-soaked sheets. He's whimpering like a child.

"Dunbar comes to a sitting position on the operating table. As his eyes move around the room, they come to rest on a crate filled with the boots of man who have lost their legs."

Dunbar pulls on his boots and walks out into the chaotic field where Union and Confederate soldiers continue to face-off. He climbs upon a horse and begins to ride along the Confederate lines, provoking shots in his direction. When he is finally felled, but still alive, General Tide leans over him. Dunbar says only, "Don't take off my foot." Lt. Dunbar is motivated by a strong desire to remain whole, which means keeping his wounded leg. His ride along Confederate lines was, in effect, a suicide attempt, as indicated also in Blake's screeplay:

Dunbar's suicidal act is treated as heroic by the general, and Dunbar is given his choice of assignments, which leads to his being sent to the remote outpost on the edges of the frontier where he will befriend the nearby Indians.