He was one of the most respected and powerful men in the British Army but, when he died, he turned out to be a woman from Cork.
A report with the startling facts leaked out in July 1865 after the death of Dr James Barry, Inspector General of Hospitals -- the highest medical rank in the British Army. It emerged that he was a woman and possibly even a mother.
In a way, it was a fitting end to the doctor's life -- he died as he had lived, surrounded by controversy.
A strict vegetarian, Barry was an outspoken, ambitious doctor of small stature and immense energy, a champion of the sick and marginalised. He blazed an illustrious medical career which, sadly, was eclipsed by the ensuing scandal surrounding his gender.
The earliest known record of the man who would become Dr James Barry is the registration of the student at Edinburgh University in 1809. He gave his place of birth as London, but his story begins in Cork city.
Barry was born Margaret Ann Bulkley in Cork in 1879. She had one brother and one sister. Little is known of the younger sister.
In 1804, when Margaret was 15, her father Jeremiah was sent to the debtors' prison. He faced bankruptcy after the marriage of her brother, John, and Margaret and her mother Mary Ann faced destitution.
Mary Ann had four brothers, one of whom lived in London. His name was James Barry, and he was an artist and a member of the Royal Academy. Mary Ann had not seen her brother for almost 30 years but wrote to him for help.
She and her daughter Margaret moved to London in around 1804.
While he did not have money, James Barry RA did have a loyal and influential circle of liberal-minded friends. And so began the education of young Margaret Bulkley. Her main tutor became Dr Edward Fryer, a medical doctor and academic.
Another friend, General Francisco Miranda, a Venezuelan soldier and scholar, had a house in London with a famously extensive library of more than 6,000 volumes, which he willingly made available to Margaret.
David Stuart Erskine, 11th Earl of Buchan, an avid supporter of the education of women, was also part of the inner circle.
It is not clear when the idea of Margaret going to medical school was mooted, but one theory suggests that it may have been General Miranda's idea, as part of his vision for the future of Venezuela.
General Miranda was impressed by Margaret's intellect and maturity and encouraged her to train as a doctor.
If her ability was not an issue, there was one seemingly insurmountable problem. In the early 19th century, women were barred from attending medical school. So the group came up with the most daring conspiracy. Margaret, then 20, would disguise herself as a man for three years to undergo medical training.
When she graduated, she could then join General Miranda in Venezuela. And so, in November 1809, Margaret Bulkley disappeared into her London home. A few days later, the dashing, if slightly effeminate, young James Miranda Stuart Barry emerged. He left London immediately.
At Edinburgh University, the failure rate was high and James Barry was one of only about 20pc of students who graduated. He was then accepted for a limited and highly competitive apprenticeship at Guy's and St Thomas's Hospital in London, and in 1813 he applied to join the army medical board.
This was a particularly risky thing to do, but Barry's plan to move to Venezuela would have to wait, as General Miranda had been captured by the Spanish and was in prison in Cadiz. Barry was recruited to the Army medical service in 1813 and posted to Plymouth.
But even the best-laid plans can be foiled and Barry's was about to be completely hamstrung.
In 1816, General Miranda died in prison. If there had been a plan for Dr James Barry to revert to womanhood, that plan now lay in tatters.
Barry was posted to the Cape of Good Hope, one of the British colonies. On his arrival, Barry introduced himself to the Governor of the Cape, Lord Charles Somerset and the pair became fast friends.
There was very little medical infrastructure in the Cape and Barry, with his characteristic energy and enthusiasm, worked tirelessly.
Apart from daily surgeries, Barry began investigating the reform of the treatment of leprosy and the resulting leper hospital became the first permanent, specialised hospital at the Cape.
In 1824, Barry and Lord Somerset were publicly accused of having a homosexual relationship, a crime punishable by death. While the accusation was judged to be untrue, the scandal hit Lord Somerset hard. His political career never recovered from it.
When news of the scandal reached Westminster months later, Somerset decided to return to England to face his accusers. He never returned to his beloved Africa.
In 1826, the wife of local businessman Thomas Munnik was having difficulty giving birth to their first baby. Barry was unquestionably one of the best birthing doctors on the Cape and Munnik summoned him immediately. Barry acted quickly and decided to carry out a Caesarean section.
By that time, only six Caesarean sections had been performed in Europe -- each of which had resulted in the death of either the mother or the baby. For his part, Barry had never seen the operation -- he would only have read of it as a possibility but, supplying Mrs Munnik with some brandy and opium to dull the pain, he confidently operated.
Later that night, Barry delivered a baby boy. Both mother and son survived, and the baby was the first to be delivered by Caesarean in South Africa and one of the first successful operations of this kind in the world.
By way of thanking Barry, Thomas Munnik called his newborn son James Barry Munnik, a tradition that carried in the family for more than a century. One descendant, James Barry Munnik Hertzog, became Prime Minister of South Africa in 1924.
There was a huge transient population on the Cape and sexual disease was rife. Barry successfully treated patients for gonorrhoea and syphilis with a locally grown plant. He is credited with successful experiments preventing the corrosion of pipes carrying fresh water. He received personal thanks from the Duke of Wellington for his work on an outbreak of cholera.
In 1831, Barry was posted to Jamaica and again began developing a medical infrastructure where none had existed. He had recurrent conflicts with the military authorities, demanding reform for prisoners and soldiers alike.
Barry was based in Corfu when the Crimean war broke out and offered the services of his hospital and staff to the war effort. He applied a ruthless regime of cleanliness to any building commandeered to be used as temporary hospitals.
His success rate was astonishing, and the death rate dropped by a stunning 90pc compared with the death rate in Scutari.
Coincidentally, on a brief visit to Scutari in 1855, Barry met the other great medical reformer of the age, Florence Nightingale.
In 1858, Barry was posted to Canada and promoted to Inspector General of Hospitals, the highest medical rank within the British Army. This was a very serious acknowledgement of his achievements and contribution to medicine.
In May 1859, Barry returned to England and was 'retired' by the Medical Board. He lived in London until his death on July 25, 1865.
On the same day, some 6,000 miles away in Cape Town, his namesake and godson James Barry Munnik celebrated his 39th birthday.
Four weeks after his death, Sophia Bishop, a maidservant or charwoman, claimed that she had not been paid for laying out the body of Barry for burial.
She went on to make the claim that shook British medicine and military to the core, a claim that has haunted writers and historians since.
If Bishop was telling the truth about Dr James Barry, then a woman had posed as a man long enough to complete medical training, making her the first medically qualified woman in Britain.
In addition, this woman had fooled the army into hiring her, and had kept her true gender a secret for more than 50 years.
Some claim to have known all along that Dr James Barry was a woman. However, more recent research claims that Barry was probably a hermaphrodite. The fact remains that there was no post-mortem and only Bishop's testimony exists, given four weeks after Barry's burial.
We can continue to hypothesise, but without exhuming the remains, the truth can never be fully known.
It is easy to understand the sensationalism around Barry's death or why the military reacted as it did. But it is unforgivable that Barry's achievements have been forgotten.
His lifelong insistence on the connection between sanitation and health was ahead of its time. He had an uncompromising attitude to his patients and to authority, never pandering to corrupt or negligent practise.
His medical reform was global, threading together the care of the sick from the Atlantic to the Indian Ocean. His life is distinguished by independence and determination, and his career, by ability and brilliance.
Cork-born Dr James Barry was a humanitarian, driven by principle, and utterly committed to the voiceless in society.
The Dr Barry documentary will be broadcast on 'The Curious Ear' on RTE Radio One, Monday at 6.45pm