A Perth court has heard harrowing details of the events that led to a young girl being placed into foster care after her heroin-addict mother failed to get her simple medical treatment.