Exemple #1
0
        /// <summary>
        /// Return list of all SNOMED relationship groups that are IsA relationships, where this concept is
        /// the source.
        /// </summary>
        /// <returns></returns>
        public List <RF2RelationshipGroup> IsAChildRelationships()
        {
            List <RF2RelationshipGroup> retVal = new List <RF2RelationshipGroup>();

            foreach (RF2RelationshipGroup g in this.DestinationRelationships)
            {
                RF2Relationship relationship = g.Active;
                if (
                    (relationship.Active == true) &&
                    (relationship.TypeId == RF2Parser.IsAConceptId)
                    )
                {
                    retVal.Add(g);
                }
            }
            return(retVal);
        }
Exemple #2
0
        /// <summary>
        /// Pathc relationships.
        /// This must be run after concepts are read in.
        /// </summary>
        /// <param name="path"></param>
        void FixRelationships()
        {
            foreach (KeyValuePair <Int64, RF2RelationshipGroup> kvp in this.RelationshipGroups)
            {
                RF2RelationshipGroup relationshipGroup = kvp.Value;

                RF2Relationship relationship = relationshipGroup.Active;
                if (relationship != null)
                {
                    RF2ConceptGroup sourceConcept      = this.GetConceptGroup(relationship.SourceId);
                    RF2ConceptGroup destinationConcept = this.GetConceptGroup(relationship.DestinationId);

                    sourceConcept.AddSourceRelationship(relationshipGroup);
                    destinationConcept.AddDestinationRelationship(relationshipGroup);
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Parse all SNOMED realtionships and create applicadia attributes for each one.
        /// </summary>
        void CreateRelationship(RF2RelationshipGroup rf2RelationshipGroup,
                                ConcurrentDictionary <Int64, List <SnomedQueryConcept> > parentMap,
                                ConcurrentDictionary <Int64, List <SnomedQueryConcept> > childMap)
        {
            RF2Relationship rf2Relationship = rf2RelationshipGroup.Active;

            if (rf2Relationship == null)
            {
                return;
            }

            switch (rf2Relationship.TypeId)
            {
            case RF2Parser.IsAConceptId:
                SnomedQueryConcept source = this.FindConcept(rf2Relationship.Source.Id);
                SnomedQueryConcept dest   = this.FindConcept(rf2Relationship.Destination.Id);
                this.Add(parentMap, source, dest);
                this.Add(childMap, dest, source);
                break;
            }
        }
Exemple #4
0
        /// <summary>
        /// Load raw snomed description data into memory.
        /// </summary>
        /// <param name="path"></param>
        void LoadRelationships(String path)
        {
            StreamReader reader = new StreamReader(File.OpenRead(path));

            String[] parts = reader.ReadLine().Split('\t');
            if (
                (parts.Length != 10) ||
                (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], "sourceId") != 0) ||
                (String.Compare(parts[5], "destinationId") != 0) ||
                (String.Compare(parts[6], "relationshipGroup") != 0) ||
                (String.Compare(parts[7], "typeId") != 0) ||
                (String.Compare(parts[8], "characteristicTypeId") != 0) ||
                (String.Compare(parts[9], "modifierId") != 0)
                )
            {
                throw new ApplicationException("Invalid header line to Relationship file");
            }

            RF2RelationshipGroup relationshipGroup = null;

            while (true)
            {
                String line = reader.ReadLine();
                if (line == null)
                {
                    break;
                }

                RF2Relationship relationship = RF2Relationship.Parse(this, line);
                if (relationship != null)
                {
                    /*
                     * Relationships in a common group are usually grouped together, so check
                     * last relationship to see if it is same group first.
                     */
                    if ((relationshipGroup != null) && (relationshipGroup.Id != relationship.Id))
                    {
                        relationshipGroup = null;
                    }

                    if (
                        (relationshipGroup == null) &&
                        (this.RelationshipGroups.TryGetValue(relationship.Id, out relationshipGroup) == false)
                        )
                    {
                        relationshipGroup = null;
                    }

                    if (relationshipGroup == null)
                    {
                        relationshipGroup = new RF2RelationshipGroup()
                        {
                            Parser = this,
                            Id     = relationship.Id
                        };
                        if (this.RelationshipGroups.TryAdd(relationship.Id, relationshipGroup) == false)
                        {
                            throw new ApplicationException("Error adding relationship to dictionary");
                        }
                    }
                    relationshipGroup.AddRelationship(relationship);
                }
            }
        }