Update: Here's what I came up with
I'm doing a ton of refactoring. Some of these are directly from a port that I was doing at blinding speed trying to reach a very short deadline (Even though I'm refactoring these now, you should have SEEN what I had to start with :) ). I'm now able to go back and refactor to make everything better. I'll post what I come up with in later posts.
Refactor the code below:
bool failedMin = (testReadingValue < studyVisitProfileMinValue);
bool failedMax = (testReadingValue > studyVisitProfileMaxValue);
if(failedMin)
{
this.ErrorCount++;
switch(limitType)
{
case LimitType.Systolic:
processResultDetail.FailedMinSystolic = true;
this.FailedSystolicLimit = true;
break;
case LimitType.Diastolic:
processResultDetail.FailedMinDiastolic = true;
this.FailedDiastolicLimit = true;
break;
case LimitType.HeartRate:
processResultDetail.FailedMinHR = true;
this.FailedHeartRateLimit = true;
break;
case LimitType.MeanArterialPressure:
processResultDetail.FailedMinMAP = true;
this.FailedMapLimit = true;
break;
}
}
if(failedMax)
{
this.ErrorCount++;
switch (limitType)
{
case LimitType.Systolic:
processResultDetail.FailedMaxSystolic = true;
this.FailedSystolicLimit = true;
break;
case LimitType.Diastolic:
processResultDetail.FailedMaxDiastolic = true;
this.FailedDiastolicLimit = true;
break;
case LimitType.HeartRate:
processResultDetail.FailedMaxHR = true;
this.FailedHeartRateLimit = true;
break;
case LimitType.MeanArterialPressure:
processResultDetail.FailedMaxMAP = true;
this.FailedMapLimit = true;
break;
}
}