Hospital security guards and law experts say a recent court case in Perth has highlighted the legal risks of detaining some patients.