(a) Child. Mental or physical examination of a child may be obtained as provided by law.
(b) Parent, Guardian, or Other Person Requesting Custody. At any time after the filing of a petition, when the mental or physical condition, including the blood group, of a parent, guardian, or other person requesting custody of a child is in controversy, the court may order the person to submit to a physical or mental examination by a qualified professional. The order may be made only on good cause shown and on notice to the person as to the time, place, manner, conditions, and scope of the examination and the person or persons by whom it is to be made. The court may, on its own motion or the motion of any party, order a parent, guardian, or other person requesting custody of the child to undergo such evaluation, treatment, or counseling activities as authorized by law.