A baby poisoned with an adult painkiller might have been given the potentially fatal dose minutes before seeing a health visitor, a court has heard.
Michelle Smith, 34, is on trial accused of murdering 42-day-old daughter Amy Smith at home in Morriston, Swansea.
The baby girl was seen by a health visitor on the day she died on 9 November 2007 and described as "thriving."
Two-and-a-half hours later paramedics called to the home were forced to give up resuscitating Amy's blue-lipped lifeless body.
A post-mortem examination found the pain killer dihydrocodeine (DHC) in Amy's blood, Swansea Crown Court was told.
Expert toxicologist Dr Stephen Morley told the jury Amy may have been drugged just minutes before an official home health visit.
The powerful drug was also found in her urine more than a fortnight before her death when she was rushed to hospital with breathing problems.
In a potentially fatal oversight the discovery that she was being poisoned with a drug never given to babies was not revealed to her doctors. When tests found an opiate in Amy's urine the sample was sent to a specialist lab for further testing but the results were never passed on.
Dr Morley was called in to the case to examine the medical findings following Amy's death and draw conclusions from them.
A health visitor on the day of Amy's death recorded her as being "immaculate" and "thriving" at 11.50am, the jury has heard.
Smith denies a charge of murder and an alternative charge of causing or allowing the death of the child.
She later told police that she bottle-fed Amy after the visit and took her up to bed at 1pm, finding her dying one hour later.
"It appears that Amy Smith was well and caused no concern to the health visitor at 11.50am, but was found collapsed two-and-a-half hours later," Dr Morley told the court.
"Therefore, the history suggests that the dihydrocodeine had been administered either after the health visitor has left or just before the health visitor has arrived.
"It may have take some time for the effects of the dihydrocodeine to manifest itself."
He said that if the drug had been given to Amy some time before the visit the effects would have been visible.
"I would have expected there to have been drowsiness. I would have expected her to be drowsy and floppy when the health visitor was present."
Earlier he ruled out that finding DHC in Amy's blood was the same dose as previously found in her urine weeks before.
"That is almost impossible as far as I am concerned. It is my opinion that there had been two separate administrations of dihydrocodeine."
He stressed that because the drug is never given to babies no clinical tests exist to show how long DHC takes to work through the system.
But in adults DHC would still test positive for three days after having been taken.
Speaking of the effects of DHC, Dr Morley said: "It can cause people to become unconscious and go into a coma.
"It may cause drowsiness and it may cause sickness."
He said that in the case of Amy "There has been a history of blue lips and that is a sign of poor breathing and that can be due to a slow breathing rate or a very shallow breathing rate.
He added: "There was a history of floppiness and drowsiness which is consistent with DHC toxicity."
Sasha Wass QC, defending, later questioned Dr Morley, pointing out: "As far as the cause of death is concerned you have not given evidence that Amy died of dihydrocodeine."
She added that all he could say was that "Amy had this drug in her system. This drug may cause these effects and these effects may have caused her to die."
Dr Morley: "I am saying that dihydrocodeine contributed to the death. From the evidence that I have seen there has been no other mechanism of death discovered."
Mrs Wass also suggested that sudden infant death syndrome (SIDS) could theoretically also explain Amy's death.
She said that could be another explanation of the death since it was not known what part DHC played.
Dr Morley said that that was "speculating" SIDS was responsible which was only possible if the evidence of HDC was discounted.
Previously the jury has heard evidence to say Amy's medical records showed she was never given DHC while in hospital.
Both Smith and her husband had each been prescribed drugs which contained DHC in the past.
An amount in tablet form was found at Smith's Swansea address.
Smith was arrested and questioned about Amy's death initially in September 2010 but was released without charge.
She was arrested and later charged in June 2011 and released on bail with a condition that she report to Neath Police Station.
On 6 January 2012 she texted her father-in-law to say she was going to hand herself in then went to a police station to confess.
She retracted her confession within minutes of making it, claiming she was struggling with the situation she found herself in.
The trial, which is scheduled to run for up to four weeks, was adjourned until tomorrow.