Set a check constraint for a set of conditions which aren't universally true
Since the status column is not nullable, the check constraint expression in your own solution

case
  when status = 2 and PatientId is null then false
  else true
end


is equivalent to this more concise expression:

not (status = 2 and PatientId is null)


Applying De Morgan's laws, you can transform it further:

        not (status = 2 and PatientId is null)   →

    →   not (status = 2) or not (PatientId is null)   →

    →   status &lt;> 2 or PatientId is not null


which is what McNets suggested in the comments.

Using the final expression, your check constraint definition would look like this:

alter table tbl 
  add constraint cons_name 
  check (status &lt;&gt; 2 or PatientId is not null);