Order, Supreme Court, Westchester County (Vincent Gurahian, J.), entered April 19, 1989, which dismissed the complaint, unanimously reversed, on the law, to vacate that part of the order sua sponte dismissing the complaint for failure to state a cause of action and to grant defendant’s motion for summary judgment, without costs.
In his complaint, plaintiff alleged that during a therapy session with defendant, his psychologist for five years, he *114communicated certain privileged information which defendant thereafter revealed, without plaintiffs authorization. After plaintiff allegedly threatened the life of his son’s schoolmate during this session, defendant informed the police that plaintiff was dangerous and told plaintiffs wife that plaintiff would be arrested unless she told him "the names and addresses of certain individuals.” Defendant also called the family of the boy named by plaintiffs wife and warned them that plaintiff was violent. Plaintiff claimed that defendant’s actions were a breach of CPLR 4507 and caused him physical and emotional harm.
The court’s dismissal for failure to state a cause of action was improper. On a motion to dismiss, the court must look at the substance of the facts pleaded and not the form (Edwards v Codd, 59 AD2d 148). Although plaintiff incorrectly referred to his cause of action as a breach of CPLR 4507, which is a rule of evidence and does not create a cause of action, the facts alleged make out a cause of action for breach of a fiduciary duty of confidentiality. (See, MacDonald v Clinger, 84 AD2d 482; Doe v Roe, 42 AD2d 559, affd 33 NY2d 902, cert dismissed 420 US 307.)
Nevertheless, the complaint was properly dismissed. Plaintiffs appeal from the dismissal of his complaint for failure to state a cause of action brings up for review the court’s denial of defendant’s motion for summary judgment (CPLR 5501 [a] [1]). Motions for summary judgment search the record and on appeal, this court may grant summary judgment to the nonappealing party (Merritt Hill Vineyards v Windy Hgts. Vineyard, 61 NY2d 106, 110-111). Here, defendant established that there is no triable issue of fact as to whether he was justified in disclosing the confidence. Defendant was an employee of the Rockland Psychiatric Institute, a State facility, at the time of his session with plaintiff. His allegation that plaintiff threatened the life of his son’s schoolmate during this session was unrefuted. The contemporaneous clinical records kept by defendant document his finding that plaintiff presented a serious and imminent danger and authorized him to disclose the threat to the authorities and to the family of the boy (Mental Hygiene Law § 33.13 [c] [6]). Moreover, his initial disclosure to plaintiffs spouse, which was made for the purpose of identifying the threatened boy, was also justified (MacDonald v Clinger, supra, at 488). Concur—Murphy, P. J., Rosenberger, Asch, Smith and Rubin, JJ.