Exemplo n.º 1
0
        /// <summary>
        /// A private method that is used by both GetTermDictionary by id and Name.
        /// </summary>
        /// <param name="byType">The  value that specifies the type of search to be performed.</param>
        /// <param name="language">This is English or Spanish</param>
        /// <param name="termId">The CDRID of the term</param>
        /// <param name="termName">The term name</param>
        /// <param name="audience">This Patient or HealthProfessional</param>
        /// <returns>TermDictionaryServiceItem instance</returns>
        private TermDictionaryServiceItem getTermDictionary(TermDefinitionByType byType, string language, int termId, string termName, string audience)
        {
            TermDictionaryServiceItem termDicSvcItem = null;

            try
            {
                // language passed to an enum calling this also validates the language value passed is meaningful DisplayLanguage
                DisplayLanguage displayLanguage =
                    (DisplayLanguage)Enum.Parse(typeof(DisplayLanguage), language);

                // Call the database query
                TermDictionaryDataItem termDicDataItem = null;

                if (byType == TermDefinitionByType.ById)
                {
                    termDicDataItem = TermDictionaryManager.GetDefinitionByTermID(language, termId.ToString(), audience, 1);
                }
                else
                {
                    termDicDataItem = TermDictionaryManager.GetDefinitionByTermName(displayLanguage, termName, audience, 1);
                }

                if (termDicDataItem != null)
                {
                    termDicSvcItem = createTermDictionarySvcItem(termDicDataItem);
                }
            }
            catch (Exception ex)
            {
                // Log the error that occured
                CancerGovError.LogError("TermDictionary", 2, ex);
            }

            return(termDicSvcItem);
        }
Exemplo n.º 2
0
        private TermDictionaryServiceItem createTermDictionarySvcItem(TermDictionaryDataItem termDictItem)
        {
            TermDictionaryServiceItem termDictionaryServiceItem = new TermDictionaryServiceItem(termDictItem.GlossaryTermID, termDictItem.TermName, null);

            termDictionaryServiceItem.TermDictionaryDetail = termDictItem;
            return(termDictionaryServiceItem);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Extracts information from the datarow that has the term names
        /// that are before and after the term name that is passed to this
        /// method. Two lists get built and are set inside the TermDictionaryDataItem
        /// object.
        /// </summary>
        /// <param name="di"></param>
        public static void GetTermNeighbors(TermDictionaryDataItem di, string language, int nMatches)
        {
            try
            {
                // Call the database layer and get data
                DataTable dt =
                    TermDictionaryQuery.GetTermNeighbors(
                        language.ToString(), di.TermName, nMatches);

                // use Linq to move information from the dataTable
                // into the TermDictionaryCollection
                di.PreviousNeighbors.AddRange(
                    from entry in dt.AsEnumerable()
                    where entry["isPrevious"].ToString() == "Y"
                    select GetEntryFromDR(entry)
                    );

                // use Linq to move information from the dataTable
                // into the TermDictionaryCollection
                di.NextNeighbors.AddRange(
                    from entry in dt.AsEnumerable()
                    where entry["isPrevious"].ToString() == "N"
                    select GetEntryFromDR(entry)
                    );
            }
            catch (Exception ex)
            {
                CancerGovError.LogError("TermDictionaryManager", 2, ex);
                throw ex;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Extracts information from a DataRow and builds a new
        /// TermDictionaryDataItem
        /// </summary>
        /// <param name="dr"></param>
        /// <returns>TermDictionaryDataItem</returns>
        private static TermDictionaryDataItem GetEntryFromDR(DataRow dr)
        {
            // return the new object
            TermDictionaryDataItem ddi = new TermDictionaryDataItem(
                Strings.ToInt(dr["GlossaryTermID"]),
                Strings.Clean(dr["TermName"]),
                Strings.Clean(dr["OLTermName"]),
                Strings.Clean(dr["TermPronunciation"]),
                Strings.Clean(dr["DefinitionHTML"]),
                Strings.Clean(dr["MediaHTML"]),
                Strings.Clean(dr["MediaCaption"]),
                Strings.ToInt(dr["MediaID"]),
                Strings.Clean(dr["AudioMediaHTML"]),
                Strings.Clean(dr["RelatedInformationHtml"])
                );

            return(ddi);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Method will return a single TermDictionaryItem with its associated
        /// TermDictionaryNeighbors
        /// </summary>
        /// <param name="language"></param>
        /// <param name="termName"></param>
        /// <param name="nMatches"></param>
        /// <returns></returns>
        public static TermDictionaryDataItem GetDefinitionByTermID(string language, string termID, string audience, int nNeighborMatches)
        {
            TermDictionaryDataItem di = null;

            // default the audience if there was none supplied
            if (string.IsNullOrEmpty(audience))
            {
                audience = "Patient";
            }

            try
            {
                // Call the database layer and get data
                DataTable dt =
                    TermDictionaryQuery.GetDefinitionByTermID(
                        language.ToString(),
                        termID,
                        audience);

                // Get the entry record
                if (dt.Rows.Count == 1)
                {
                    // build the data item
                    di = GetEntryFromDR(dt.Rows[0]);

                    // Get the neighbors
                    GetTermNeighbors(di, language, nNeighborMatches);
                }
                else if (dt.Rows.Count > 0)
                {
                    throw new Exception("GetDefinitionByTermID returned more than 1 record.");
                }
            }
            catch (Exception ex)
            {
                CancerGovError.LogError("TermDictionaryManager", 2, ex);
                throw ex;
            }

            return(di);
        }