Section 34. (a) The judgment or order of commitment by a court of competent jurisdiction of another state or of the district of Columbia, committing a person to the Veterans Administration or other agency of the United States government for care or treatment shall have the same force and effect as to the committed person while in this commonwealth as in the jurisdiction in which is situated the court entering the judgment or making the order; and the courts of the committing state, or of the District of Columbia, shall be deemed to have retained jurisdiction of the person so committed for the purpose of inquiring into the mental condition of such person, and of determining the necessity for continuance of his restraint. The law of the committing state or district shall govern with respect to the authority of the chief officer of any facility of said Veterans Administration or of any institution operated in this commonwealth by any other agency of the United States to retain custody of, or transfer, trial visit, or discharge, the committed person.
(b) Whenever, in any proceeding under the laws of this commonwealth for the commitment of a person alleged to be of unsound mind or otherwise in need of care and treatment in a facility or other institution for his proper care, it is determined after such adjudication of the status of such person as may be required by law that commitment to a facility for the mentally ill or other institution is necessary for care and treatment and it appears that such person is eligible for care or treatment by said Veterans Administration or other agency of the United States government, the court, upon receipt of certificate from said Veterans Administration or such other agency showing that facilities are available and that such person is eligible for care or treatment therein, may commit such person to said Veterans Administration or other agency. The person whose commitment is sought shall be personally served with such notice of the pending commitment proceedings as is required, and in such manner as is provided, by the laws of the commonwealth; and nothing in this section shall affect his right to appear and be heard in the proceedings. Upon commitment, such person, when admitted to any facility operated by any such agency within or without this commonwealth shall be subject to the rules and regulations of said Veterans Administration or other agency. The chief officer of any facility of said Veterans Administration or institution operated by any other agency of the United States to which the person is so committed shall with respect to such person be vested with the same powers as the department with respect to retention of custody, transfer, parole or discharge. Jurisdiction is retained in the committing or other appropriate court of the commonwealth at any time to inquire into the mental condition of the person so committed, and to determine the necessity for continuance of his restraint, and all commitments pursuant to this section are so conditioned.
(c) Upon receipt of a certificate of said Veterans Administration or such other agency of the United States that facilities are available for the care or treatment of any person committed to any facility for the mentally ill or other institution for the care or treatment of persons similarly afflicted and that such person is eligible for care or treatment, the department or the committing court may cause the transfer of such person to said Veterans Administration or other agency of the United States for care or treatment. Upon effecting any such transfer, the committing court or proper officer thereof shall be notified thereof by the transferring agency. No person shall be transferred to said Veterans Administration or other agency of the United States if he is confined pursuant to conviction of any felony or misdemeanor or if he has been acquitted of the charge solely on the grounds of insanity, unless prior to transfer the court or other authority originally committing such person shall enter an order for such transfer after appropriate motion and hearing. Any person transferred as provided in this subsection shall be deemed to be committed to said Veterans Administration or other agency of the United States pursuant to the original commitment.