Exemple #1
0
		/// <summary> This method takes in integer values for the hour, minute, seconds, and fractional seconds
		/// (going to the tenthousandths precision).
		/// The method performs validations and then sets the value field formatted as an
		/// HL7 time value with a precision that starts from the hour and goes down to the tenthousandths
		/// of a second (HHMMSS.SSSS).
		/// Note: all of the precisions from tenths down to tenthousandths of a
		/// second are optional. If the precision goes below tenthousandths of a second then the second
		/// value will be rounded to the nearest tenthousandths of a second.
		/// </summary>
		public virtual void setHourMinSecondPrecision(int hr, int min, float sec)
		{
			try
			{
				setHourMinutePrecision(hr, min);
				//multiply the seconds input value by 10000 and round the result
				//then divide the number by tenthousand and store it back.
				//This will round the fractional seconds to the nearest tenthousandths
				int secMultRound = (int) Math.Round((double) (10000F*sec));
				sec = secMultRound/10000F;
				//Now store the second and fractional component
				second = (int) Math.Floor(sec);
				//validate input seconds value
				if ((second < 0) || (second >= 60))
				{
					String msg = "The (rounded) second value of the TM datatype must be >=0 and <60";
					DataTypeException e = new DataTypeException(msg);
					throw e;
				} //end if
				int fractionOfSecInt = (int) (secMultRound - (second*10000));
				fractionOfSec = fractionOfSecInt/10000F;
				String fractString = "";
				//Now convert the fractionOfSec field to a string without the leading zero
				if (fractionOfSec != 0.0F)
				{
					fractString = (fractionOfSec.ToString()).Substring(1);
				} //end if
				//Now update the value field
				offSet = 0;
				//Here the offset is not defined, we should omit showing it in the
				//return value from the getValue() method
				omitOffsetFg = 'y';
				value_Renamed = value_Renamed + DataTypeUtil.preAppendZeroes(second, 2) + fractString;
			}
				//end try
			catch (DataTypeException e)
			{
				throw e;
			}
				//end catch
			catch (Exception e)
			{
				throw new DataTypeException("An unexpected exception ocurred", e);
			} //end catch
		}
Exemple #2
0
		} //end constructor

		/// <summary> This method takes in integer values for the hour and minute and performs validations,
		/// it then sets the value field formatted as an HL7 time value
		/// with hour and minute precision (HHMM).
		/// </summary>
		public virtual void setHourMinutePrecision(int hr, int min)
		{
			try
			{
				HourPrecision = hr;
				//validate input minute value
				if ((min < 0) || (min > 59))
				{
					String msg = "The minute value of the TM datatype must be >=0 and <=59";
					DataTypeException e = new DataTypeException(msg);
					throw e;
				} //end if
				minute = min;
				second = 0;
				fractionOfSec = 0;
				offSet = 0;
				//Here the offset is not defined, we should omit showing it in the
				//return value from the getValue() method
				omitOffsetFg = 'y';
				value_Renamed = value_Renamed + DataTypeUtil.preAppendZeroes(min, 2);
			}
				//end try
			catch (DataTypeException e)
			{
				throw e;
			}
				//end catch
			catch (Exception e)
			{
				throw new DataTypeException(e.Message);
			} //end catch
		}