Question about Numeric ID

So I am using a Numeric ID question as our study ID for our patients in my application. I already limited the length to 4 digits (string-length(.) = 4). Is there any condition I can use to ensure that there are no repetitions in the study ID even for cases that have been closed? I.E. A case worker should not be able to enter an ID that is/was already used by another patient.

short answer - Yes.

you would need to make sure that the ID is stored as a case property. then you can run a query on your casedb instance to check if there are any cases with that property having the same value entered by the user. if there are, it should stop them.
the query would look something like this
count( instance(‘casedb’)/casedb/case[@case_type=’ your_type '])<1
i would put that condition in the validation conditions.

so the idea is, you count the number of cases that have that property set to the value entered by the user, and if you get a count that is higher than 0, it should fail.

this relies on case sharing being active.