Any individual in custody for a violent offense or a sex offense as those terms are defined in RCW
9.94A.030 who is brought by, or accompanied by, an officer to a hospital must continue to be accompanied or otherwise secured by an officer during the time that the individual is receiving care at the hospital. However, this section does not apply to an individual being supervised by the department of corrections if the individual's custody is the result solely of a sanction imposed by the department of corrections, the indeterminate sentence review board, or the court, in response to a violation of conditions.