예제 #1
0
파일: CommonTS.cs 프로젝트: snosrap/nhapi
 /// <summary> Returns a string value representing the input Gregorian Calendar object in
 /// an Hl7 TimeStamp Format.
 /// </summary>
 public static System.String toHl7TSFormat(System.Globalization.GregorianCalendar cal)
 {
     System.String val = "";
     try
     {
         //set the input cal object so that it can report errors
         //on it's value
         //UPGRADE_ISSUE: Method 'java.util.Calendar.setLenient' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javautilCalendarsetLenient_boolean'"
         // // UPGRADE_ISSUE: Commented out:cal.setLenient(false);
         // UPGRADE_ISSUE: Above all was commented out, do we need?
         //UPGRADE_TODO: Method 'java.util.Calendar.get' was converted to 'SupportClass.CalendarManager.Get' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilCalendarget_int'"
         int calYear = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.YEAR);
         //UPGRADE_TODO: Method 'java.util.Calendar.get' was converted to 'SupportClass.CalendarManager.Get' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilCalendarget_int'"
         int calMonth = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.MONTH) + 1;
         //UPGRADE_TODO: Method 'java.util.Calendar.get' was converted to 'SupportClass.CalendarManager.Get' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilCalendarget_int'"
         int calDay = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.DAY_OF_MONTH);
         //UPGRADE_TODO: Method 'java.util.Calendar.get' was converted to 'SupportClass.CalendarManager.Get' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilCalendarget_int'"
         int calHour = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.HOUR_OF_DAY);
         //UPGRADE_TODO: Method 'java.util.Calendar.get' was converted to 'SupportClass.CalendarManager.Get' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilCalendarget_int'"
         int calMin = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.MINUTE);
         //UPGRADE_TODO: Method 'java.util.Calendar.get' was converted to 'SupportClass.CalendarManager.Get' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilCalendarget_int'"
         int calSec = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.SECOND);
         //UPGRADE_TODO: Method 'java.util.Calendar.get' was converted to 'SupportClass.CalendarManager.Get' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilCalendarget_int'"
         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;
         //UPGRADE_TODO: Method 'java.util.Calendar.get' was converted to 'SupportClass.CalendarManager.Get' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilCalendarget_int'"
         //UPGRADE_ISSUE: Field 'java.util.Calendar.ZONE_OFFSET' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javautilCalendarZONE_OFFSET_f'"
         int calOffset = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.ZONE_OFFSET);
         //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
         CommonTS ts = new CommonTS();
         ts.setDateSecondPrecision(calYear, calMonth, calDay, calHour, calMin, calSecFloat);
         ts.Offset = calOffset;
         val = ts.Value;
     }
         // end try
     catch (DataTypeException e)
     {
         throw e;
     }
         //end catch
     catch (System.Exception e)
     {
         throw new DataTypeException("An unexpected exception ocurred", e);
     } //end catch
     return val;
 }
예제 #2
0
        }         //end method

        /// <summary> Returns a string value representing the input Gregorian Calendar object in
        /// an Hl7 TimeStamp Format.
        /// </summary>
        public static System.String toHl7TSFormat(System.Globalization.GregorianCalendar cal)
        {
            System.String val = "";
            try
            {
                //set the input cal object so that it can report errors
                //on it's value
                //UPGRADE_ISSUE: Method 'java.util.Calendar.setLenient' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javautilCalendarsetLenient_boolean'"
                // // UPGRADE_ISSUE: Commented out:cal.setLenient(false);
                // UPGRADE_ISSUE: Above all was commented out, do we need?
                //UPGRADE_TODO: Method 'java.util.Calendar.get' was converted to 'SupportClass.CalendarManager.Get' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilCalendarget_int'"
                int calYear = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.YEAR);
                //UPGRADE_TODO: Method 'java.util.Calendar.get' was converted to 'SupportClass.CalendarManager.Get' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilCalendarget_int'"
                int calMonth = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.MONTH) + 1;
                //UPGRADE_TODO: Method 'java.util.Calendar.get' was converted to 'SupportClass.CalendarManager.Get' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilCalendarget_int'"
                int calDay = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.DAY_OF_MONTH);
                //UPGRADE_TODO: Method 'java.util.Calendar.get' was converted to 'SupportClass.CalendarManager.Get' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilCalendarget_int'"
                int calHour = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.HOUR_OF_DAY);
                //UPGRADE_TODO: Method 'java.util.Calendar.get' was converted to 'SupportClass.CalendarManager.Get' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilCalendarget_int'"
                int calMin = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.MINUTE);
                //UPGRADE_TODO: Method 'java.util.Calendar.get' was converted to 'SupportClass.CalendarManager.Get' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilCalendarget_int'"
                int calSec = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.SECOND);
                //UPGRADE_TODO: Method 'java.util.Calendar.get' was converted to 'SupportClass.CalendarManager.Get' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilCalendarget_int'"
                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;
                //UPGRADE_TODO: Method 'java.util.Calendar.get' was converted to 'SupportClass.CalendarManager.Get' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilCalendarget_int'"
                //UPGRADE_ISSUE: Field 'java.util.Calendar.ZONE_OFFSET' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javautilCalendarZONE_OFFSET_f'"
                int calOffset = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.ZONE_OFFSET);
                //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
                CommonTS ts = new CommonTS();
                ts.setDateSecondPrecision(calYear, calMonth, calDay, calHour, calMin, calSecFloat);
                ts.Offset = calOffset;
                val       = ts.Value;
            }
            // end try
            catch (DataTypeException e)
            {
                throw e;
            }
            //end catch
            catch (System.Exception e)
            {
                throw new DataTypeException("An unexpected exception ocurred", e);
            }     //end catch
            return(val);
        }         //end method