Exemple #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);
            }
        }
Exemple #2
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);
        }
Exemple #3
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);
                }
            }
        }