Beispiel #1
0
        }         //end method

        /// <summary> This method takes in integer values for the year and month and day
        /// and performs validations, it then sets the value in the object
        /// formatted as an HL7 date value with year&month&day precision (YYYYMMDD).
        /// </summary>
        public virtual void  setYearMonthDayPrecision(int yr, int mnth, int dy)
        {
            try
            {
                System.Globalization.GregorianCalendar cal = new System.Globalization.GregorianCalendar();
                SupportClass.CalendarManager.manager.Clear(cal);

                //ensure that the year field is four digits long
                if (System.Convert.ToString(yr).Length != 4)
                {
                    System.String     msg = "The input year value must be four digits long";
                    DataTypeException e   = new DataTypeException(msg);
                    throw e;
                }
                //validate the input month/day combination
                SupportClass.CalendarManager.manager.Set(cal, yr, (mnth - 1), dy);
                SupportClass.CalendarManager.manager.GetDateTime(cal);                 //for error detection
                year          = yr;
                month         = mnth;
                day           = dy;
                value_Renamed = System.Convert.ToString(yr) + DataTypeUtil.preAppendZeroes(mnth, 2) + DataTypeUtil.preAppendZeroes(dy, 2);
            }
            catch (DataTypeException e)
            {
                throw e;
            }
            //end catch
            catch (System.Exception e)
            {
                throw new DataTypeException(e);
            }     //end catch
        }         //end method
Beispiel #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&minute precision (HHMM).
        /// </summary>
        public virtual void  setHourMinutePrecision(int hr, int min)
        {
            try
            {
                this.HourPrecision = hr;
                //validate input minute value
                if ((min < 0) || (min > 59))
                {
                    System.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 (System.Exception e)
            {
                throw new DataTypeException(e.Message);
            }     //end catch
        }         //end method
Beispiel #3
0
        }         //end method

        /// <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
            {
                this.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)System.Math.Round((double)(10000F * sec));
                sec = secMultRound / 10000F;
                //Now store the second and fractional component
                second = (int)System.Math.Floor(sec);
                //validate input seconds value
                if ((second < 0) || (second >= 60))
                {
                    System.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;
                System.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 (System.Exception e)
            {
                throw new DataTypeException(e);
            }     //end catch
        }         //end method