Exemple #1
0
		public void Value__Set_to_Valid_Year()
		{
			var commonDt = new CommonDT();
			commonDt.Value = "2001";
			Assert.AreEqual("2001", commonDt.Value);
			Assert.AreEqual(2001, commonDt.Year);
		}
Exemple #2
0
        /// <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 and month
        /// and day precision (YYYYMMDD).
        /// </summary>
        ///
        /// <exception cref="DataTypeException">    Thrown when a Data Type error condition occurs. </exception>
        ///
        /// <param name="yr">   The yr. </param>
        /// <param name="mnth"> The mnth. </param>
        /// <param name="dy">   The dy. </param>

        public virtual void setDatePrecision(int yr, int mnth, int dy)
        {
            try
            {
                //create date object if there isn't one
                if (this.dt == null)
                {
                    this.dt = new CommonDT();
                }
                //set the value of the date object to the input date value
                this.dt.setYearMonthDayPrecision(yr, mnth, dy);
                //clear the time value object
                this.tm = null;
            }
            //end try
            catch (DataTypeException e)
            {
                throw e;
            }
            //end catch
            catch (System.Exception e)
            {
                throw new DataTypeException("An unexpected exception ocurred", e);
            } //end catch
        }
Exemple #3
0
        /// <summary> Returns a string value representing the input Gregorian Calendar object in
        /// an Hl7 Date Format.
        /// </summary>
        public static String toHl7DTFormat(GregorianCalendar cal)
        {
            String val = "";

            try
            {
                //set the input cal object so that it can report errors
                //on it's value
                int      calYear  = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.YEAR);
                int      calMonth = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.MONTH) + 1;
                int      calDay   = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.DAY_OF_MONTH);
                CommonDT dt       = new CommonDT();
                dt.setYearMonthDayPrecision(calYear, calMonth, calDay);
                val = dt.Value;
            }
            catch (DataTypeException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new DataTypeException("An unexpected exception ocurred", e);
            }
            return(val);
        }
Exemple #4
0
		public void Value__Set_to_Valid_Year_and_Month()
		{
			var commonDt = new CommonDT();
			commonDt.Value = "200102";
			Assert.AreEqual("200102", commonDt.Value);
			Assert.AreEqual(2001, commonDt.Year);
			Assert.AreEqual(2, commonDt.Month);
		}
Exemple #5
0
		public void Value__Set_to_Invalid_Year()
		{
			var commonDt = new CommonDT();
			commonDt.Value = "200a";
		}
Exemple #6
0
		public void Value__Set_to_Invalid_Length()
		{
			var commonDt = new CommonDT();
			commonDt.Value = "20010";
		}
Exemple #7
0
		public void Value__Set_to_Empty_Quoted_String()
		{
			var commonDt = new CommonDT();
			commonDt.Value = "\"\"";
			Assert.AreEqual("\"\"", commonDt.Value);
		}
Exemple #8
0
		public void Value__Set_to_Null()
		{
			var commonDt = new CommonDT();
			commonDt.Value = null;
			Assert.AreEqual(null, commonDt.Value);
		}
Exemple #9
0
 /// <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 and month and 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("An unexpected exception ocurred", e);
     } //end catch
 }
Exemple #10
0
		public void setYearMonthDayPrecision_With_Valid_Year_and_Month_and_Day()
		{
			var commonDt = new CommonDT();
			commonDt.setYearMonthDayPrecision(2001, 2, 3);
			Assert.AreEqual("20010203", commonDt.Value);
			Assert.AreEqual(2001, commonDt.Year);
			Assert.AreEqual(2, commonDt.Month);
			Assert.AreEqual(3, commonDt.Day);
		}
Exemple #11
0
		public void setYearMonthPrecision_With_Invalid_Month()
		{
			var commonDt = new CommonDT();
			commonDt.setYearMonthPrecision(2001, 13);
		}
Exemple #12
0
		public void setYearMonthPrecision_With_Valid_Year_and_Month()
		{
			var commonDt = new CommonDT();
			commonDt.setYearMonthPrecision(2001, 02);
			Assert.AreEqual("200102", commonDt.Value);
			Assert.AreEqual(2001, commonDt.Year);
			Assert.AreEqual(2, commonDt.Month);
		}
Exemple #13
0
		public void YearPrecision__Set_to_Invalid_Year()
		{
			var commonDt = new CommonDT();
			commonDt.YearPrecision = 20010;
		}
Exemple #14
0
		public void YearPrecision__Set_to_Valid_Year()
		{
			var commonDt = new CommonDT();
			commonDt.YearPrecision = 2001;
			Assert.AreEqual("2001", commonDt.Value);
			Assert.AreEqual(2001, commonDt.Year);
			Assert.AreEqual(0, commonDt.Month);
			Assert.AreEqual(0, commonDt.Day);
		}
Exemple #15
0
		public void Constructor_Sets_Value()
		{
			var commonDt = new CommonDT("20010203");
			Assert.AreEqual("20010203", commonDt.Value);
		}
Exemple #16
0
		public void Value__Set_to_Invalid_Day()
		{
			var commonDt = new CommonDT();
			commonDt.Value = "2001020a";
		}
Exemple #17
0
		public void setYearMonthDayPrecision_With_Invalid_Day()
		{
			var commonDt = new CommonDT();
			commonDt.setYearMonthDayPrecision(2001, 2, 29);
		}
Exemple #18
0
 /// <summary> Returns a string value representing the input Gregorian Calendar object in
 /// an Hl7 Date Format.
 /// </summary>
 public static System.String toHl7DTFormat(System.Globalization.GregorianCalendar cal)
 {
     System.String val = "";
     try
     {
         //set the input cal object so that it can report errors
         //on it's value
         int calYear = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.YEAR);
         int calMonth = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.MONTH) + 1;
         int calDay = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.DAY_OF_MONTH);
         CommonDT dt = new CommonDT();
         dt.setYearMonthDayPrecision(calYear, calMonth, calDay);
         val = dt.Value;
     }
     catch (DataTypeException e)
     {
         throw e;
     }
     catch (System.Exception e)
     {
         throw new DataTypeException("An unexpected exception ocurred", e);
     }
     return val;
 }