Пример #1
0
        /// <summary>
        /// Load raw snomed description data into memory.
        /// </summary>
        /// <param name="path"></param>
        void FixDescription(RF2DescriptionGroup descriptionGroup)
        {
            RF2Description description = descriptionGroup.Active;

            if (description == null)
            {
                return;
            }

            RF2ConceptGroup conceptGroup;

            if (this.ConceptGroups.TryGetValue(description.ConceptId, out conceptGroup) == false)
            {
                throw new ApplicationException($"Concept {description.ConceptId} in Description {description.Id} not found");
            }
            else
            {
                RF2ConceptGroup typeConcept;
                if (this.DescriptionTypes.TryGetValue(description.TypeId, out typeConcept) == false)
                {
                    if (this.ConceptGroups.TryGetValue(description.TypeId, out typeConcept) == false)
                    {
                        throw new ApplicationException($"Description Type concept {description.TypeId} not found");
                    }
                    if (this.DescriptionTypes.TryAdd(description.TypeId, typeConcept) == false)
                    {
                        throw new ApplicationException($"Error adding {description.TypeId} to disctionary");
                    }
                }
                this.GetConceptGroup(description.ConceptId).AddDescriptionGroup(descriptionGroup);
            }
        }
Пример #2
0
 /// <summary>
 /// Load raw snomed description data into memory.
 /// </summary>
 /// <param name="path"></param>
 void FixDescriptions()
 {
     foreach (KeyValuePair <Int64, RF2DescriptionGroup> kvp in this.DescriptionGroups)
     {
         RF2DescriptionGroup descriptionGroup = kvp.Value;
         this.FixDescription(descriptionGroup);
     }
 }
Пример #3
0
 /// <summary>
 /// Add description group to concept group.
 /// </summary>
 /// <param name="descriptionGroup"></param>
 public void AddDescriptionGroup(RF2DescriptionGroup descriptionGroup)
 {
     if (this.descriptionGroupIds.Contains(descriptionGroup.Id) == true)
     {
         return;
     }
     this.descriptionGroupIds.Add(descriptionGroup.Id);
     // force lazy reloading of description groups id called.
     this.descriptionGroups = null;
 }
Пример #4
0
        /// <summary>
        /// Load raw snomed description data into memory.
        /// </summary>
        /// <param name="path"></param>
        void LoadDescriptions(String path)
        {
            StreamReader reader = new StreamReader(File.OpenRead(path));

            String[] parts = reader.ReadLine().Split('\t');
            if (
                (parts.Length != 9) ||
                (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], "conceptId") != 0) ||
                (String.Compare(parts[5], "languageCode") != 0) ||
                (String.Compare(parts[6], "typeId") != 0) ||
                (String.Compare(parts[7], "term") != 0) ||
                (String.Compare(parts[8], "caseSignificanceId") != 0)
                )
            {
                throw new ApplicationException("Invalid header line to description file");
            }


            RF2DescriptionGroup descriptionGroup = null;

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

                    if (
                        (descriptionGroup == null) &&
                        (this.DescriptionGroups.TryGetValue(description.Id, out descriptionGroup) == false)
                        )
                    {
                        descriptionGroup = null;
                    }

                    if (descriptionGroup == null)
                    {
                        descriptionGroup = new RF2DescriptionGroup()
                        {
                            Parser = this,
                            Id     = description.Id
                        };
                        if (this.DescriptionGroups.TryAdd(description.Id, descriptionGroup) == false)
                        {
                            throw new ApplicationException("Error adding description to dictionary");
                        }
                    }
                    descriptionGroup.AddDescription(description);
                }
            }
        }