
912 P.2d 290 (1996)
121 N.M. 414
Terrence M. LANE, Petitioner-Appellee,
v.
Arlene Daniels LANE, Respondent-Appellant.
No. 16262.
Court of Appeals of New Mexico.
January 12, 1996.
*291 Frederick M. Mowrer, Law Offices of Raymond G. Sanchez, Albuquerque, for Petitioner-Appellee.
Jerry Todd Wertheim, Jones, Snead, Wertheim, Wentworth & Jaramillo, P.A., Santa Fe, for Respondent-Appellant.

OPINION
HARTZ, Judge.
1. Twentieth-century science has complicated the law of paternity. Advances in biology make it possible both to determine and to create biological parents in ways not contemplated *292 a few decades ago. On the one hand, laboratory technicians can now rebut the presumption that the husband of the mother at the time of conception is the biological father. On the other, physicians can now enable infertile couples to have children who do not share both parents' genes. Legislatures have been attempting to design paternity statutes that properly balance the important interests at stake. This appeal requires us to interpret one such attempt, the Uniform Parentage Act (the Uniform Act), approved by the National Conference of Commissioners on Uniform State Laws in 1973 and enacted, with some modifications, in New Mexico in 1986, NMSA 1978, §§ 40-11-1 to -23 (Repl.Pamp.1994) (the New Mexico Act).
2. The dispute before us arises out of the dissolution of the marriage of Arlene Daniels Lane (Wife) and Terrence M. Lane (Husband). Wife appeals the district court's order granting Husband joint custody of Colleen Lane, who was conceived during the marriage by artificial insemination from an anonymous donor. Husband is neither the biological nor adoptive parent of Colleen. The issue on appeal is whether Husband should nevertheless be treated as Colleen's "natural" father. We hold that he acquired that status through substantial compliance with the New Mexico Act. We therefore affirm the judgment of the district court.

BACKGROUND
3. Husband and Wife were married on December 4, 1984. With three children from two previous marriages, Husband had undergone a vasectomy in 1980. Shortly after the marriage, however, Wife expressed a desire to have children. Husband was hesitant and refused to have his vasectomy reversed. But after Wife stated that she would leave Husband if she could not have children, Husband and Wife explored various options. They chose artificial insemination from an anonymous donor, obtaining help first from a personal physician and then from the University of New Mexico Hospital. Husband participated in the process, driving Wife for some medical visits, attending birthing classes, and being present in the delivery room for the birth of Colleen. Husband testified that Wife assured him that he would be treated in all respects as the father of the child. He also testified that to ensure that Colleen would think he was her natural father, Wife made him swear not to reveal that she had undergone artificial insemination but, rather, to represent the child as having been conceived naturally by the couple.
4. The customary practice of the University of New Mexico Hospital was not to undertake artificial insemination without the signed consent of both the husband and the wife. A hospital representative testified that the consent's purpose was to make the couple aware of the risks involved, to establish that they both wished to participate in the program, and to obtain a release from liability. Yet, the only signed consent form relating to Wife is a document signed just by Wife and apparently brought to the hospital by Wife from her previous physician. Neither Husband nor Wife recalled signing any form of consent relating to the insemination that led to the conception of Colleen. Neither the hospital files nor the records of the New Mexico Bureau of Vital Records and Health Statistics contain any additional consent form, although medical notes for a later unsuccessful attempt to conceive another child in 1990 contain the notation: "patient [Wife] and spouse signed consent."
5. After Colleen was born, both Husband and Wife told friends and relatives that Husband was Colleen's natural father. Husband appears as Colleen's father on her birth certificate, although the circumstances under which his name was entered are unclear. See NMSA 1978, § 24-14-13(D) (Repl.1986) (birth certificate should name husband of mother as father unless paternity established in court or by agreement of both spouses and putative husband). Wife encouraged Husband to be an active parent, and he was.
6. On May 10, 1991 Husband filed a petition to dissolve the marriage. The petition, which Husband verified, alleges that Colleen is a child of the marriage. The response to the petition, which Wife verified, requests that she be awarded sole legal and physical custody of the child but admits that Colleen was a child of the marriage and does not challenge Husband's paternity. On March *293 26, 1992 the attorneys for Husband and Wife approved a stipulated order stating that the parties "agree and stipulate" that Husband and Wife "are the parents of Colleen Dawn Lane, born August 26, 1988."
7. On February 16, 1993 a new attorney entered an appearance for Wife. Two weeks later that attorney moved for leave to file an amended response and counterpetition, stating that "[t]he facts leading to the proposed Amended Response and Counterpetition have recently come to light." The new pleadings for the first time alleged that Colleen was conceived through artificial insemination and that Husband was neither her natural nor legal father.
8. After trial on the issues of paternity and custody, the district court awarded joint custody in July 1993. The court concluded that "[i]t is inequitable to strictly apply [the New Mexico Act] to this case, because this Court finds that both parties manifested through their actions and words that they both consented to the artificial insemination." A final order setting forth the terms of joint custody was entered by the district court on February 7, 1995.

DISCUSSION
9. Although a stepparent may be entitled to visitation rights after dissolution of a marriage, see NMSA 1978, § 40-4-9.1(L)(4) and (8) (Repl.Pamp.1994); Rhinehart v. Nowlin, 111 N.M. 319, 323-25, 805 P.2d 88, 92-94 (Ct.App.1990); id. at 330-32, 805 P.2d at 99-101 (Hartz, J., concurring), Husband has a right to custody only if he is Colleen's "natural" father. According to the statutory provision governing joint custody of children after dissolution of marriage, "[w]hen any person other than a natural or adoptive parent seeks custody of a child, no such person shall be awarded custody absent a showing of unfitness of the natural or adoptive parent." Section 40-4-9.1(K).
10. Under what circumstances may someone who is not the biological father be the "natural" father? New Mexico law provides that "[t]he parent and child relationship between a child and . . . the natural father may be established as provided in the [New Mexico] Act." Section 40-11-4(B). The New Mexico Act recognizes a presumption of paternity in several circumstances, such as when the child is born during the marriage, § 40-11-5(A)(1), or when the man during the child's minority "openly holds out the child as his natural child and has established a personal, financial or custodial relationship with the child," Section 40-11-5(A)(4). Husband here could rely on one or more of these presumptions, except that the presumptions can be rebutted by clear and convincing evidence. Section 40-11-5(C). Any presumption in this case was indisputably rebutted by evidence of Husband's sterility and the artificial insemination.
11. Consequently, Husband's claim to be Colleen's natural father must rest on Section 40-11-6, which addresses artificial insemination. It reads:
A. If, under the supervision of a licensed physician and with the consent of her husband, a woman is inseminated artificially with semen donated by a man not her husband, the husband is treated as if he were the natural father of the child thereby conceived so long as the husband's consent is in writing, signed by him and his wife. The physician shall certify their signatures and the date of the insemination and file the husband's consent with the vital statistics bureau of the health services division of the health and environment department [department of health], where it shall be kept confidential and in a sealed file; provided, however, that the physician's failure to either certify or file the consent shall not affect the father and child relationship.
B. Any donor of semen provided to a licensed physician for use in artificial insemination of a woman other than the donor's wife may be treated as if he were the natural father of the child thereby conceived if he so consents in writing signed by him and the woman. The physician shall certify their signatures and the date of the insemination and file the donor's consent with the vital statistics bureau of the health services division of the health and environment department [department of health] where it shall be kept confidential and in a sealed file; provided, however, *294 that the physician's failure to either certify or file the consent shall not affect the father and child relationship.
C. All papers and records pertaining to the insemination, whether part of a court, medical or any other file, are subject to inspection only upon an order of the court for good cause shown.[1]
12. Wife argues that written consent is essential if the husband is to be treated as the natural father. She points out that the statute not only requires the husband's consent but also specifically provides that the husband is treated as the natural father only "so long as the husband's consent is in writing, signed by him and his wife." Comparison of the language of the New Mexico Act with the language of the Uniform Act reinforces the argument that the existence of a writing is an absolute requirement for the husband to be treated as the natural father. The first sentence of the New Mexico Act differs in a suggestive way from the first two sentences of the Uniform Act. Section 5 of the Uniform Act states:
If, under the supervision of a licensed physician and with the consent of her husband, a wife is inseminated artificially with semen donated by a man not her husband, the husband is treated in law as if he were the natural father of a child thereby conceived. The husband's consent must be in writing and signed by him and his wife.
The New Mexico Act's version of this languagecombining the two sentences by inserting the conditional phrase "so long as"serves little purpose but to emphasize the dependence of the husband's status on the execution of a written consent.
13. Moreover, the New Mexico Act (just as the Uniform Act) explicitly states that the failure of the physician to certify the signatures and file the consent shall "not affect the father and child relationship." By stating that the failure to comply with certain requirements does not affect the husband's status as the natural father, the statute implies that failure to comply with other requirements does affect that status.
14. Wife further argues that strict compliance with the statutory requirements is called for because of the precious maternal rights that are at stake. Although the district court did not annul Wife's right to her child, the reduction in those rights resulting from her having to share joint custody with Husband is a matter of profound significance. Indeed, there is some authority that even granting just visitation rights to a third party can violate the constitutional rights of a parent. See Brooks v. Parkerson, 265 Ga. 189, 454 S.E.2d 769 (holding grandparent visitation statute to be unconstitutional), cert. denied, ___ U.S. ____, 116 S.Ct. 377, 133 L.Ed.2d 301 (1995); but see Campbell v. Campbell, 896 P.2d 635 (Utah Ct.App.1995) (refusing to follow Brooks).
15. The final step in Wife's argument is simply to point out that there was not strict compliance with the New Mexico Act in this case. The record contains no written consent signed by both Husband and Wife. Although there was sufficient evidence at trial for the district court to make a finding that such a document had once been in existence, the district court made no such finding.
16. Wife's syllogism is not without persuasive force. But we do not adopt it. In our view, the absence of strict compliance does not end the inquiry. To begin with, despite the constitutional protection given to parenthood, we view the matter before us as a matter of statutory construction. We are aware of no constitutional doctrine that insists on a genetic basis for parenthood. Wife does not suggest that Section 40-11-6, which permits a husband who is not the biological father to be treated as the natural father, is unconstitutional. Nor does she suggest that the statute would be unconstitutional if the requirement of a writing were eliminated. Although the importance of the interests involved cautions us to be circumspect, traditional *295 precepts of statutory interpretation should apply.
17. Those precepts tell us that even though a statute constitutes a command to the courts regarding what law to apply, the command must be read with intelligence. The legislature, as with anyone who issues an order, cannot anticipate every contingency. The legislature can, however, expect that when one of its orders (i.e., a law) is to be carried out, those who have that duty (i.e., the courts) will discern its purpose and act in accordance with its essence if not necessarily its letter. The doctrine of statutory interpretation that captures this proposition is the doctrine of substantial compliance. Under that doctrine, "a court should determine whether the statute has been followed sufficiently so as to carry out the intent for which the statute was adopted and accomplishes the reasonable objectives of the statute." Vaughn v. United Nuclear Corp., 98 N.M. 481, 485, 650 P.2d 3, 7 (Ct.App.), cert. quashed, 98 N.M. 478, 649 P.2d 1391 (1982).
18. Application of the substantial-compliance doctrine is a risky venture. The danger, of course, is that the court will choose its personal view of what is just or fair, rather than complying with the mandate of the statute. Departure from the strict letter of a statute should therefore be undertaken with great caution. In particular, one must be careful not to underestimate the purposes served by strict compliance with the letter of the statute.
19. Keeping these concerns in mind, we nevertheless find that this case presents an example of exceptional circumstances in which the doctrine of substantial compliance must be employed. The purposes of Section 40-11-6(A) are best effectuated by treating Husband as Colleen's natural father.
20. The essential policy of the section is that when a husband and wife both approve of her conceiving a child through artificial insemination and both wish the husband to be treated as the natural father, then the State should honor that wish. As for the requirement that the consent be in writing, we have searched in vain for commentary on the Uniform Act that addresses the matter. See, e.g., Harry D. Krause, Bringing the Bastard Into the Great SocietyA Proposed Uniform Act on Legitimacy, 44 Tex.L.Rev. 829 (1966) (described in the prefatory note to the Uniform Act as providing the genesis for the Act). Nevertheless, it appears clear to us that the requirement of a writing serves two functions. First, the writing serves an evidentiary function. The existence of a document signed by the husband and the wife avoids disputes regarding whether consent was actually given. Second, the requirement serves a cautionary purpose. One who pauses to sign a document can be expected to give more thought to the consequences of consent than one who gives consent in a less formal setting. An additional purpose that may be served by the requirement of written consent is to protect from liability the medical personnel who conduct the procedure, but failure to advance that purpose could hardly be a ground for denying the husband's status as a natural parent.
21. It is important to note that while the New Mexico Act requires a writing to achieve these two purposes, it is not rigid about the nature of the writing. The statute does not require any particular form of words for the consent. Given the purposes of the statute, a writing should be satisfactory if it conveys in some manner that (1) the husband knows of the conception by artificial insemination, (2) the husband agrees to be treated as the lawful father of the child so conceived, and (3) the wife agrees that the husband will be treated as the lawful father of the child.
22. We also note that the New Mexico Act does not prescribe when the written consent must be executed. Although the mother may wish to be assured of the husband's responsibility toward the child before undergoing the procedure, and the medical personnel may wish to be assured that the husband will not hold them responsible before they initiate the procedure, the evidentiary and cautionary purposes of the writing requirement can be fully served by a writing executed after the artificial insemination, or even after the birth of the child. We fail to see how the date of the writing affects the probative value of the writing as evidence of *296 the consent. The date certainly has less effect on the probative value than does the presence or absence of certification by the physician, which is a statutory requirement that by the express terms of the statute "shall not affect the father and child relationship." Section 40-11-6(A). As for the cautionary purpose of the writing requirement, a consent to parenthood after successful insemination, and especially after the birth of the child, would probably reflect more solemn consideration than such a consent before the insemination procedure. After all, the full consequences of consent become strikingly evident once the child is born.
23. The above analysis of the purposes and terms of Section 40-11-6(A) convinces us that there was substantial compliance with the New Mexico Act in this case. Of particular interest are the pleadings filed in district court. Husband verified his petition claiming Colleen as a "minor child[ ] of the marriage." Wife likewise verified the response, which admitted that "there is one minor child of the marriage, Colleen Dawn Lane," and did not challenge Husband's paternity in any manner. Later in the litigation the attorneys for Husband and Wife each signed a stipulated order which stated: "The parties agree and stipulate as follows: 1. The parties are the parents of Colleen Dawn Lane, born August 26, 1988." Although no document was signed by both Husband and Wife, and one of the pleadings was signed only by their attorneys, these pleadings unequivocally demonstrate that more than two and one-half years after the birth of Colleen, and even after the marriage had failed, both Husband and Wife were acknowledging Husband's status as Colleen's natural father. Cf. NMSA 1978, § 55-2-201(3)(b) (Repl.Pamp.1993) (Uniform Commercial Code statute of frauds can be satisfied by a pleading). To be sure, missing from these documents is any reference to the artificial insemination by which Colleen was conceived. But there is absolutely no dispute in this case that Husband was fully aware of the artificial insemination and that Wife knew that he was fully aware. There is not even a whisper of a possibility that Husband was deceived regarding the circumstances of Colleen's conception. Consequently, the pleadings referred to represent a knowing consent by both Husband and Wife to treating Husband as the natural father of the child born to Wife as a result of artificial conception. The purposes of the statute are served.
24. We recognize that pleadings can be amended and a party is not necessarily bound by the first pleading filed in court. Indeed, the district court in this case permitted Wife to file an amended response to Husband's petition and a counterpetition challenging Husband's paternity. Nevertheless, we fail to see why the fact that a pleading can be amended to expand the issues to be decided at trial should necessarily impact upon the effect of statements in those pleadings with respect to Section 40-11-6(A). Nothing in the New Mexico Act permits withdrawal of consent. Wife has not suggested any equitable grounds for setting aside her sworn allegation or the stipulation of her counsel. At most, she could argue that the statements were made without knowledge of (1) the requirements of Section 40-11-6(A) or (2) the absence of a written consent to the artificial insemination. In the circumstances of this case, we see no reason why Wife's ignorance of the law and of that particular fact warrants setting aside the clear import of the assertions made in the pleadingsthat both Husband and Wife considered Husband to be Colleen's father.

CONCLUSION
25. We affirm the judgment of the district court. The parties shall bear their own costs and attorney's fees on appeal.
IT IS SO ORDERED.
DONNELLY and FLORES, JJ., concur.
NOTES
[1]  We note with interest that under the Uniform Status of Children of Assisted Conception Act, approved by the National Conference of Commissioners on Uniform State Laws in 1988, but not adopted in New Mexico, the husband of a woman, other than a surrogate mother, who bears a child through assisted conception is deemed the father if he does not challenge his paternity in court within two years of learning of the child's birth. Section 3.
