Пример #1
0
 private void ValidateDecimal(string value, string type, XmlToModelResult result, XmlElement element)
 {
     if (NumberUtil.IsNumber(value))
     {
         if (!StandardDataType.REAL.Type.Equals(type))
         {
             string     integerPart = value.Contains(".") ? StringUtils.SubstringBefore(value, ".") : value;
             string     decimalPart = value.Contains(".") ? StringUtils.SubstringAfter(value, ".") : string.Empty;
             RealFormat format      = GetFormat(type);
             if (StandardDataType.REAL_CONF.Type.Equals(type) && !ValueIsBetweenZeroAndOneInclusive(integerPart, decimalPart))
             {
                 RecordValueMustBeBetweenZeroAndOneError(value, type, result, element);
             }
             // TM - decided to remove check on overall length; we check before and after decimal lengths, which should be sufficient
             if (StringUtils.Length(integerPart) > format.GetMaxIntegerPartLength())
             {
                 RecordTooManyCharactersBeforeDecimalError(value, type, result, element, format);
             }
             if (StringUtils.Length(decimalPart) > format.GetMaxDecimalPartLength())
             {
                 RecordTooManyDigitsAfterDecimalError(value, type, result, element, format);
             }
         }
     }
     else
     {
         if (StringUtils.IsBlank(value))
         {
             RecordValueMustBeSpecifiedError(result, element);
         }
     }
 }
Пример #2
0
 private void RecordTooManyCharactersBeforeDecimalError(string value, string type, XmlToModelResult result, XmlElement element
                                                        , RealFormat format)
 {
     result.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, "Value " + value + " of type " + type + " should have no more than "
                                     + format.GetMaxIntegerPartLength() + " characters before the decimal", element));
 }
Пример #3
0
 private void RecordTooManyDigitsAfterDecimalError(string value, string type, XmlToModelResult result, XmlElement element,
                                                   RealFormat format)
 {
     result.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, "Value " + value + " of type " + type + " should have no more than "
                                     + format.GetMaxDecimalPartLength() + " digits after the decimal", element));
 }