コード例 #1
0
ファイル: CommonTS.cs プロジェクト: carlhuth/GenXSource
        }         //end constructor

        /// <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 Time Stamp value with year&month&day precision (YYYYMMDD).
        ///
        /// </summary>
        public virtual void  setDatePrecision(int yr, int mnth, int dy)
        {
            try
            {
                //create date object if there isn't one
                if (dt == null)
                {
                    dt = new CommonDT();
                }
                //set the value of the date object to the input date value
                dt.setYearMonthDayPrecision(yr, mnth, dy);
                //clear the time value object
                tm = null;
            }
            //end try
            catch (DataTypeException e)
            {
                throw e;
            }
            //end catch
            catch (System.Exception e)
            {
                throw new DataTypeException(e);
            }     //end catch
        }         //end method
コード例 #2
0
ファイル: CommonTS.cs プロジェクト: carlhuth/GenXSource
        }         //end method

        /// <summary> This method takes in integer values for the year, month, day, hour, minute, seconds,
        /// and fractional seconds (going to the tenthousandths precision).
        /// The method performs validations and then sets the value in the object formatted as an
        /// HL7 time value with a precision that starts from the year and goes down to the tenthousandths
        /// of a second (YYYYMMDDHHMMSS.SSSS).
        /// The Gmt Offset will not be effected.
        /// 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  setDateSecondPrecision(int yr, int mnth, int dy, int hr, int min, float sec)
        {
            try
            {
                //set the value of the date object to the input date value
                this.setDatePrecision(yr, mnth, dy);
                //create new time object is there isn't one
                if (tm == null)
                {
                    tm = new CommonTM();
                }
                //set the value of the time object to the second precision with the input values
                tm.setHourMinSecondPrecision(hr, min, sec);
            }
            //end try
            catch (DataTypeException e)
            {
                throw e;
            }
            //end catch
            catch (System.Exception e)
            {
                throw new DataTypeException(e);
            }     //end catch
        }         //end method
コード例 #3
0
ファイル: CommonTM.cs プロジェクト: carlhuth/GenXSource
        }         //end method

        /// <summary> Returns a string value representing the input Gregorian Calendar object in
        /// an Hl7 Time Format.
        /// </summary>
        public static System.String toHl7TMFormat(System.Globalization.GregorianCalendar cal)
        {
            System.String val = "";
            try
            {
                //set the input cal object so that it can report errors
                //on it's value
                int calHour  = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.HOUR_OF_DAY);
                int calMin   = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.MINUTE);
                int calSec   = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.SECOND);
                int calMilli = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.MILLISECOND);
                //the inputs seconds and milli seconds should be combined into a float type
                float fractSec    = calMilli / 1000F;
                float calSecFloat = calSec + fractSec;

                TimeSpan utcSpan   = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);
                int      dstOffset = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? -1 : 0;

                int calOffset = utcSpan.Hours * 100 + utcSpan.Minutes + dstOffset;

                //Note the input's Offset value is in milliseconds, we must convert it to
                //a 4 digit integer in the HL7 Offset format.
                int offSetSignInt;
                if (calOffset < 0)
                {
                    offSetSignInt = -1;
                }
                else
                {
                    offSetSignInt = 1;
                }
                //get the absolute value of the gmtOffSet
                int absGmtOffSet   = System.Math.Abs(calOffset);
                int gmtOffSetHours = absGmtOffSet / (3600 * 1000);
                int gmtOffSetMin   = (absGmtOffSet / 60000) % (60);
                //reset calOffset
                calOffset = ((gmtOffSetHours * 100) + gmtOffSetMin) * offSetSignInt;
                //Create an object of the TS class and populate it with the above values
                //then return the HL7 string value from the object
                CommonTM tm = new CommonTM();
                tm.setHourMinSecondPrecision(calHour, calMin, calSecFloat);
                tm.Offset = calOffset;
                val       = tm.Value;
            }
            // end try
            catch (DataTypeException e)
            {
                throw e;
            }
            //end catch
            catch (System.Exception e)
            {
                throw new DataTypeException(e);
            }     //end catch
            return(val);
        }         //end method