Ejemplo n.º 1
0
        /// <summary>
        /// Indexes the text.
        /// </summary>
        /// <param name="text">The text to index.</param>
        /// <param name="domains">The domains.</param>
        /// <param name="ancestorConceptId">The ancestor concept id.</param>
        /// <param name="includeAncestor">If set to <c>true</c> [include ancestor].</param>
        /// <param name="locale">The locale.</param>
        /// <returns>Array of Indexer Results indicating the positions of SNOMED CT concepts in a given string of text.</returns>
        public IndexerResult[] IndexText(string text, string[] domains, string ancestorConceptId, bool includeAncestor, string locale)
        {
            if (!TerminologyProvider.initialized)
            {
                TerminologyProvider.Initialize();
            }

            // look for possible qualifiers
            List <IndexerResult> possibleQuals = (from result in this.qualifiers
                                                  where text.ToUpperInvariant().Contains(result.ToUpperInvariant())
                                                  select new IndexerResult
            {
                Concept = new ConceptResult()
                {
                    PreferredTerm = result, SnomedConceptId = "1234567890", FullySpecifiedName = result
                },
                Description = result,
                StartIndex = text.IndexOf(result, StringComparison.OrdinalIgnoreCase),
                EndIndex = text.IndexOf(result, StringComparison.OrdinalIgnoreCase) + result.Length,
                SnomedDescriptionId = "1234567890"
            }).ToList();

            // look to ensure the correct terms are being used
            foreach (IndexerResult qual in possibleQuals)
            {
                // look for left and right terms
                if (qual.Description.Equals(this.qualifiers[3], StringComparison.OrdinalIgnoreCase) || qual.Description.Equals(this.qualifiers[4], StringComparison.OrdinalIgnoreCase) || qual.Description.Equals(this.qualifiers[5], StringComparison.OrdinalIgnoreCase))
                {
                    qual.Description                = this.qualifiers[2];
                    qual.Concept.PreferredTerm      = this.qualifiers[2];
                    qual.Concept.FullySpecifiedName = this.qualifiers[2];
                }

                // look for sudden onset terms
                if (qual.Description.Equals(this.qualifiers[20], StringComparison.OrdinalIgnoreCase) || qual.Description.Equals(this.qualifiers[21], StringComparison.OrdinalIgnoreCase) || qual.Description.Equals(this.qualifiers[22], StringComparison.OrdinalIgnoreCase))
                {
                    qual.Description                = this.qualifiers[19];
                    qual.Concept.PreferredTerm      = this.qualifiers[19];
                    qual.Concept.FullySpecifiedName = this.qualifiers[19];
                }
            }

            // Processes single qualifiers
            this.RemoveSingleQualifiers(possibleQuals);

            // return the complete set of qualifiers as an IndexerResult array
            return(possibleQuals.ToArray());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Searches the HLI SNOMED CT terminology service based on description.
        /// </summary>
        /// <param name="searchText">The search text.</param>
        /// <param name="domains">The domains.</param>
        /// <param name="ancestorConceptId">The ancestor concept id.</param>
        /// <param name="includeAncestor">If set to <c>true</c> [include ancestor].</param>
        /// <param name="fullText">If set to <c>true</c> perform a [full text] search.  If set to <c>false</c> perform a [starts with] search.</param>
        /// <param name="locale">The locale.</param>
        /// <param name="fromIndex">The index of the first result to return.</param>
        /// <param name="endIndex">The index of the last result to return.</param>
        /// <param name="maxTotal">The maximum total.</param>
        /// <returns>SNOMED CT Search Result based on searchText.</returns>
        public SearchResult SearchByDescription(string searchText, string[] domains, string ancestorConceptId, bool includeAncestor, bool fullText, string locale, int fromIndex, int endIndex, int maxTotal)
        {
            if (!TerminologyProvider.initialized)
            {
                TerminologyProvider.Initialize();
            }

            SearchResult searchResult = new SearchResult();

            var searchTerms = from term in TerminologyProvider.searchByDescriptionTerms
                              where term.Description.ToUpperInvariant().Contains(searchText.Replace("*", string.Empty).Trim())
                              select term;

            searchResult.Terms = new ObservableCollection <TermResult>(searchTerms);

            return(searchResult);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the concept detail.
        /// </summary>
        /// <param name="snomedConceptId">The SNOMED concept id.</param>
        /// <param name="locale">The locale.</param>
        /// <returns>Concept Details of the given SNOMED CT concept id.</returns>
        public ConceptDetail GetConceptDetails(string snomedConceptId, string locale)
        {
            if (!TerminologyProvider.initialized)
            {
                TerminologyProvider.Initialize();
            }

            // Getting First rather than Select as for a snomedConceptId multiple entries can be found
            TermResult    termResult    = TerminologyProvider.searchByDescriptionTerms.FirstOrDefault <TermResult>(entry => entry.Concept.SnomedConceptId == snomedConceptId);
            ConceptDetail conceptDetail = null;

            if (termResult != null)
            {
                ConceptResult concept = termResult.Concept;
                if (concept != null)
                {
                    conceptDetail = new ConceptDetail()
                    {
                        SnomedConceptId          = snomedConceptId,
                        PreferredTerm            = concept.PreferredTerm,
                        FullySpecifiedName       = concept.FullySpecifiedName,
                        Parents                  = concept.Parents,
                        AlternateDescriptions    = concept.AlternateDescriptions,
                        Children                 = new ObservableCollection <ConceptResult>(),
                        RefinableCharacteristics = new ObservableCollection <RefinableCharacteristic>(),
                        Relations                = new ObservableCollection <RelationResult>()
                    };
                }
            }

            if (null == conceptDetail)
            {
                conceptDetail = new ConceptDetail()
                {
                    SnomedConceptId    = snomedConceptId,
                    PreferredTerm      = "Sample Concept Preferred Term",
                    FullySpecifiedName = "Sample Concept (Fully Specified Name)",
                    Parents            = new ObservableCollection <ConceptItem>()
                    {
                        new ConceptItem()
                        {
                            SnomedConceptId = snomedConceptId, FullySpecifiedName = "A Sample Concept (SampleConcept)", PreferredTerm = "A Sample Concept"
                        },
                        new ConceptItem()
                        {
                            SnomedConceptId = snomedConceptId, FullySpecifiedName = "Another Sample Concept (SampleConcept)", PreferredTerm = "Another Sample Concept"
                        }
                    },
                    AlternateDescriptions = new ObservableCollection <TermItem>()
                    {
                        new TermItem()
                        {
                            Description = "A sample synonym", SnomedDescriptionId = snomedConceptId
                        },
                        new TermItem()
                        {
                            Description = "Another sample synonym", SnomedDescriptionId = snomedConceptId
                        }
                    },
                    Children = new ObservableCollection <ConceptResult>(),
                    RefinableCharacteristics = new ObservableCollection <RefinableCharacteristic>(),
                    Relations = new ObservableCollection <RelationResult>()
                };
            }

            return(conceptDetail);
        }