コード例 #1
0
        /// <summary>
        /// Iterate over all rf2Parser concepts and create correct GcSnomedConcept derived class for each element.
        /// </summary>
        SnomedQueryConcept CreateConceptRecord(RF2ConceptGroup rf2ConceptGroup)
        {
            RF2Concept rf2Concept = rf2ConceptGroup.Active;

            if (rf2Concept == null)
            {
                return(null);
            }

            RF2ConceptGroup module           = this.rf2Parser.GetConceptGroup(rf2Concept.ModuleId);
            RF2ConceptGroup definitionStatus = this.rf2Parser.GetConceptGroup(rf2Concept.DefinitionStatusId);

            List <String> synonyms = new List <string>();

            foreach (RF2DescriptionGroup descriptionGroup in rf2ConceptGroup.DescriptionGroups)
            {
                RF2Description description = descriptionGroup.GetActiveEnglishDescription();
                switch (description.TypeId)
                {
                case RF2Parser.SynonymTypeId:
                    synonyms.Add(description.Term);
                    break;

                case RF2Parser.FullySpecifiedNameConceptId:
                    break;

                default:
                    Console.WriteLine($"Unimplemented description type {this.rf2Parser.GetConceptGroup(description.TypeId).GetFullySpecifiedName()}");
                    break;
                }
            }

            SnomedQueryConcept concept = new SnomedQueryConcept(
                rf2Concept.Id,                              // conceptId,
                rf2ConceptGroup.GetFullySpecifiedName(),    // conceptFullyQualifiedName,
                synonyms.ToArray(),                         // conceptSynonymns,
                module.GetFullySpecifiedName(),             // String conceptModule,
                definitionStatus.GetFullySpecifiedName(),   // String conceptDefinitionStatus,
                rf2Concept.EffectiveTime                    // conceptEffectiveTime
                );

            return(concept);
        }
コード例 #2
0
        /// <summary>
        /// Load raw snomed concept data into memory.
        /// </summary>
        /// <param name="path"></param>
        void LoadConcepts(String path)
        {
            StreamReader reader = new StreamReader(File.OpenRead(path));

            String[] parts = reader.ReadLine().Split('\t');
            if (
                (parts.Length != 5) ||
                (String.Compare(parts[0], "id") != 0) ||
                (String.Compare(parts[1], "effectiveTime") != 0) ||
                (String.Compare(parts[2], "active") != 0) ||
                (String.Compare(parts[3], "moduleId") != 0) ||
                (String.Compare(parts[4], "definitionStatusId") != 0)
                )
            {
                throw new ApplicationException("Invalid header line to concept file");
            }

            RF2ConceptGroup conceptGroup = null;

            while (true)
            {
                String line = reader.ReadLine();
                if (line == null)
                {
                    break;
                }
                RF2Concept concept = RF2Concept.Parse(this, line);
                if (concept != null)
                {
                    /*
                     * Relationships in a common group are usually grouped together, so check
                     * last relationship to see if it is same group first.
                     */
                    if ((conceptGroup != null) && (conceptGroup.Id != concept.Id))
                    {
                        conceptGroup = null;
                    }

                    if (
                        (conceptGroup == null) &&
                        (this.ConceptGroups.TryGetValue(concept.Id, out conceptGroup) == false)
                        )
                    {
                        conceptGroup = null;
                    }

                    if (conceptGroup == null)
                    {
                        conceptGroup = new RF2ConceptGroup()
                        {
                            Parser = this,
                            Id     = concept.Id
                        };
                        if (this.ConceptGroups.TryAdd(concept.Id, conceptGroup) == false)
                        {
                            throw new ApplicationException("Error adding concept to dictionary");
                        }
                    }
                    conceptGroup.AddConcept(concept);
                }
            }
        }