The ruling stems from a lawsuit brought by major medical organizations, including the American Academy of Pediatrics.