(a) If a person is convicted of a crime, any time spent in involuntary confinement in a mental health facility as a result of being charged with the crime shall be credited to the sentence.
(b) All inpatient care and treatment shall be paid by the department.