Section 121. An inmate of a public charitable institution or a prisoner in a penal institution who is afflicted with a venereal disease, as defined under section six or pulmonary tuberculosis shall be forthwith placed under medical treatment, and if, in the opinion of the attending physician, it is necessary, he shall be isolated until danger of contagion is passed or the physician determines his isolation unnecessary. If at the expiration of a prisoner’s sentence he is afflicted with a venereal disease, as defined under section six or pulmonary tuberculosis in its contagious or infectious stages, or if, in the opinion of the attending physician of the institution or of such physician as the authorities thereof may consult, his release would be dangerous to public health, he shall be placed under medical treatment in the institution where he has been confined. Thereupon the authorities of such institution shall notify the department of public welfare of his condition and said department shall provide for his hospitalization and medical care at an institution until, in the opinion of the attending physician of the institution wherein he is being treated, the symptoms have disappeared and his release will not endanger the public health. Notice of a prisoner’s release hereunder to the department of public welfare shall be made to the department of public health. The expense of his support, not exceeding three dollars and fifty cents a week, shall be paid by the town where he resides, after notice of the expiration of his sentence and of his condition to such town, or, if he is a state charge, by the commonwealth after like notice to the department of public welfare.