Hi,
You are specifying algorithms that perform calculations on your variables that exceed their standard limits. For example, in this statement:
analogWrite(redPin, 255-(255*openCases/500));
You have declared the "openCases" as an int Datatype which has a standard range of -32,768 to 32,767. Without notice, the Arduino compilier is not expecting to deal with values greater than 32,767 so when it processes "(255*openCases)" the calculation exceeds the limit at times during your loop.
A quick fix would be declare "openCases" as "long", or "unsigned long" and this should implicitly correct the calculations, but do recommend you go over the different datatypes the arduino uses, and look into Type Conversion and Type Casting. It'll be well worth the effort to get a grasp of these concepts as it will save you alot of hair-pulling down the road.