Пример #1
0
        /// <summary>
        /// Specifies whether the row should be filtered or not.
        /// </summary>
        /// <param name="inputRow">Medications row.</param>
        /// <returns>True if the medications row has to be filtered, otherwise false.</returns>
        private bool FilterData(Dictionary <string, string> inputRow)
        {
            bool     filter = true;
            DateTime dt     = new DateTime();

            switch (this.filterCondition)
            {
            case FilterCondition.Current:
                if (IsvDataProvider.IsCurrentMedication(inputRow[ISVDataProviderResources.MedicationStatus]))
                {
                    filter = false;
                }

                break;

            case FilterCondition.Past:
                if (IsvDataProvider.IsCurrentMedication(inputRow[ISVDataProviderResources.MedicationStatus]) == false)
                {
                    filter = false;
                }

                break;

            case FilterCondition.PastTwoMonths:
                if (IsvDataProvider.IsCurrentMedication(inputRow[ISVDataProviderResources.MedicationStatus]) == false && DateTime.TryParse(inputRow[ISVDataProviderResources.StopDate], CultureInfo.CurrentCulture, DateTimeStyles.None, out dt))
                {
                    if (dt.AddMonths(2) >= this.CustomDate)
                    {
                        filter = false;
                    }
                    else
                    {
                        filter = true;
                    }
                }

                break;

            case FilterCondition.PastSixMonths:
                if (IsvDataProvider.IsCurrentMedication(inputRow[ISVDataProviderResources.MedicationStatus]) == false && DateTime.TryParse(inputRow[ISVDataProviderResources.StopDate], CultureInfo.CurrentCulture, DateTimeStyles.None, out dt))
                {
                    if (dt.AddMonths(6) >= this.CustomDate)
                    {
                        filter = false;
                    }
                    else
                    {
                        filter = true;
                    }
                }

                break;

            default:
                filter = false;
                break;
            }

            return(filter);
        }
Пример #2
0
 /// <summary>
 /// Sorts the data
 /// </summary>
 private void Sort()
 {
     if (!string.IsNullOrEmpty(this.sortColumn))
     {
         if (this.sortDirection == SortDirection.Ascending)
         {
             if (IsvDataProvider.IsStringComparer(this.sortColumn))
             {
                 this.rows = this.rows.OrderBy(row => row[this.sortColumn], new StringComparer()).ToList();
             }
             else
             {
                 this.rows = this.rows.OrderBy(row => row[this.sortColumn], new DateComparer()).ToList();
             }
         }
         else
         {
             if (IsvDataProvider.IsStringComparer(this.sortColumn))
             {
                 this.rows = this.rows.OrderByDescending(row => row[this.sortColumn], new StringComparer()).ToList();
             }
             else
             {
                 this.rows = this.rows.OrderByDescending(row => row[this.sortColumn], new DateComparer()).ToList();
             }
         }
     }
 }
Пример #3
0
        /// <summary>
        /// Gets the data from XML file and returns the data to data manager in list of dictionary format.
        /// </summary>
        /// <param name="rows">List of dictionary object to hold the output data.</param>
        /// <param name="totalRowCount">Total number of rows returned.</param>
        /// <param name="startOrdinalPosition">Specifies the start position of the data from where to fetch the data.</param>
        /// <param name="pageSize">Specifies the number of records to be returned.</param>
        public void GetPage(out List <Dictionary <string, string> > rows, out int totalRowCount, int startOrdinalPosition, int pageSize)
        {
            if (this.patientID == null)
            {
                rows          = null;
                totalRowCount = -1;
                return;
            }

            this.rows.Clear();
            totalRowCount = 0;
            rows          = this.rows;

            XmlReader dataReader = IsvDataProvider.GetReader("Microsoft.Cui.IsvData.BabyEvansData.xml");

            if (dataReader != null)
            {
                dataReader.MoveToContent();

                while (dataReader.ReadToFollowing(ISVDataProviderResources.Patient))
                {
                    if (dataReader.HasAttributes && dataReader.GetAttribute(ISVDataProviderResources.PatientId) != null)
                    {
                        if (string.Compare(dataReader.GetAttribute(ISVDataProviderResources.PatientId), this.patientID, StringComparison.CurrentCultureIgnoreCase) == 0)
                        {
                            dataReader = dataReader.ReadSubtree();

                            while (dataReader.ReadToFollowing(ISVDataProviderResources.Medication))
                            {
                                this.GetPatientMedications(dataReader.ReadSubtree());
                            }
                        }
                    }
                }

                this.SortOrGroup();
                totalRowCount = this.rows.Count;

                this.rows.RemoveRange(0, startOrdinalPosition);

                if (this.rows.Count > pageSize)
                {
                    this.rows.RemoveRange(pageSize, this.rows.Count - pageSize);
                }
            }
        }
Пример #4
0
 /// <summary>
 /// Groups the data.
 /// </summary>
 private void Group()
 {
     if (string.IsNullOrEmpty(this.sortColumn))
     {
         // only grouping
         if (IsvDataProvider.IsStringComparer(this.groupByColumnName))
         {
             this.rows = this.rows.OrderBy(row => row[this.groupByColumnName], new StringComparer()).ToList();
         }
         else
         {
             this.rows = this.rows.OrderBy(row => row[this.groupByColumnName], new DateComparer()).ToList();
         }
     }
     else
     {
         // grouping and sorting.
         if (IsvDataProvider.IsStringComparer(this.groupByColumnName))
         {
             if (IsvDataProvider.IsStringComparer(this.sortColumn))
             {
                 if (this.sortDirection == SortDirection.Ascending)
                 {
                     this.rows = this.rows.OrderBy(row => row[this.groupByColumnName], new StringComparer()).ThenBy(row => row[this.sortColumn], new StringComparer()).ToList();
                 }
                 else
                 {
                     this.rows = this.rows.OrderBy(row => row[this.groupByColumnName], new StringComparer()).ThenByDescending(row => row[this.sortColumn], new StringComparer()).ToList();
                 }
             }
             else
             {
                 if (this.sortDirection == SortDirection.Ascending)
                 {
                     this.rows = this.rows.OrderBy(row => row[this.groupByColumnName], new StringComparer()).ThenBy(row => row[this.sortColumn], new DateComparer()).ToList();
                 }
                 else
                 {
                     this.rows = this.rows.OrderBy(row => row[this.groupByColumnName], new StringComparer()).ThenByDescending(row => row[this.sortColumn], new DateComparer()).ToList();
                 }
             }
         }
         else
         {
             if (IsvDataProvider.IsStringComparer(this.sortColumn))
             {
                 if (this.sortDirection == SortDirection.Ascending)
                 {
                     this.rows = this.rows.OrderBy(row => row[this.groupByColumnName], new DateComparer()).ThenBy(row => row[this.sortColumn], new StringComparer()).ToList();
                 }
                 else
                 {
                     this.rows = this.rows.OrderBy(row => row[this.groupByColumnName], new DateComparer()).ThenByDescending(row => row[this.sortColumn], new StringComparer()).ToList();
                 }
             }
             else
             {
                 if (this.sortDirection == SortDirection.Ascending)
                 {
                     this.rows = this.rows.OrderBy(row => row[this.groupByColumnName], new DateComparer()).ThenBy(row => row[this.sortColumn], new DateComparer()).ToList();
                 }
                 else
                 {
                     this.rows = this.rows.OrderBy(row => row[this.groupByColumnName], new DateComparer()).ThenByDescending(row => row[this.sortColumn], new DateComparer()).ToList();
                 }
             }
         }
     }
 }