Hadiza Bawa-Garba called off attempts to save Jack Adcock before the error was picked up by a junior doctor.
Jack, of Glen Parva, died after being admitted to Leicester Royal Infirmary with pneumonia in 2011.
Dr Bawa-Garba and two nurses deny manslaughter by gross negligence.
The prosecution has accepted that Jack was already "past the point of no return" and that resuscitation at that point was "futile".
However, Andrew Thomas QC said the case, at Nottingham Crown Court, was about "whether she fell below the conduct of a reasonably competent junior doctor".
Mr Thomas asked: "Did you ask anyone what is the name of the patient you were treating?" Dr Bawa-Garba replied "No."
Mr Thomas then asked: "When you arrived, could you see the face of the little boy being resuscitated?" The 38-year-old doctor replied: "I cannot recall whether I saw the face or not. I could see a small room, an oxygen mask, it's an emotionally charged environment."
Mr Thomas said: "Is it symptomatic of your behaviour that day that you rushed to a decision without checking?"
She said: "It's not that. It's a reflection of how long I had been working without a break."
Dr Bawa-Garba has admitted making a series of errors in relation to Jack's care and said she had underestimated the severity of his illness.
She added that she should have checked nursing and observation charts and spotted abnormal blood test results.
Jack, who had Down's syndrome and a heart condition, died from a cardiac arrest after sepsis was triggered by a bacterial infection.
The two nurses are Sister Theresa Taylor, 55, and 47-year-old Portuguese-born agency nurse Isabel Amaro.
The trial continues.
A doctor accused of manslaughter has said working without a break may have led her to mistake a six-year-old boy for another child who was marked "do not resuscitate", a jury has been told.