Пример #1
0
        /// <summary>
        /// Get a list of all Coded Concepts from the Context Group specified by the supplied CID
        /// that have the supplied Coding Scheme Designator and Code Value.
        /// </summary>
        /// <param name="cid">The Context ID.</param>
        /// <param name="codingSchemeDesignator">The Coding Scheme Designator.</param>
        /// <param name="codeValue">The Code Value.</param>
        /// <returns>
        /// Null of the Content Group specified by the supplied CID does not exist.
        /// Otherwise a list of Coded Concepts.
        /// </returns>
        public IList <CodedConcept> GetCodedConcepts(string cid, string codingSchemeDesignator, string codeValue)
        {
            List <CodedConcept> codedConcepts = null;

            ContextGroup contextGroup = null;

            if (!this.contextGroupDictionary.TryGetValue(cid, out contextGroup))
            // Key not found and contextGroup contains null;
            {
                codedConcepts = null;
            }
            else
            {
                codedConcepts = new List <CodedConcept>();

                foreach (CodedConceptOrInclude codedConceptOrInclude in contextGroup.CodedConceptsOrIncludes)
                {
                    if (codedConceptOrInclude is CodedConcept)
                    {
                        CodedConcept codedConcept = codedConceptOrInclude as CodedConcept;

                        if ((codingSchemeDesignator == codedConcept.CodingSchemeDesignator) && (codeValue == codedConcept.CodeValue))
                        {
                            codedConcepts.Add(codedConcept);
                        }
                    }
                    else if (codedConceptOrInclude is IncludedContextGroup)
                    {
                        IncludedContextGroup includedContextGroup = codedConceptOrInclude as IncludedContextGroup;

                        IList <CodedConcept> matchingCodedConceptsFromIncludedContentGroup = GetCodedConcepts(includedContextGroup.Id, codingSchemeDesignator, codeValue);

                        if (matchingCodedConceptsFromIncludedContentGroup != null)
                        {
                            codedConcepts.AddRange(matchingCodedConceptsFromIncludedContentGroup);
                        }
                    }
                }
            }

            return(codedConcepts);
        }
Пример #2
0
        /// <summary>
        /// Creates a string dump for a single Context Group.
        /// </summary>
        /// <param name="prefix">The prefix to use in the string dump.</param>
        /// <param name="contextGroup">The Context Group.</param>
        /// <returns>The string dump.</returns>
        private static String ContextGroupStringDump(String prefix, ContextGroup contextGroup)
        {
            StringBuilder stringDump = new StringBuilder();

            stringDump.Append(prefix + "Context ID \"" + contextGroup.Id + "\", Context Group Name \"" + contextGroup.Name + "\"\r\n");
            stringDump.Append(prefix + "  CODING SCHEME DESIGNATOR, CODE VALUE, CODE MEANING\r\n");
            stringDump.Append(prefix + "  ------------------------  ----------  ------------");


            foreach (CodedConceptOrInclude codedConceptOrInclude in contextGroup.CodedConceptsOrIncludes)
            {
                if (codedConceptOrInclude is CodedConcept)
                {
                    CodedConcept codedConcept = codedConceptOrInclude as CodedConcept;
                    stringDump.Append("\r\n" + prefix + "  " + codedConcept.CodingSchemeDesignator);

                    if (codedConcept.CodingSchemeVersion != null)
                    {
                        stringDump.Append(" [" + codedConcept.CodingSchemeVersion + "]");
                    }

                    stringDump.Append(", " + codedConcept.CodeValue + ", \"" + codedConcept.CodeMeaning + "\"");
                }
                else if (codedConceptOrInclude is IncludedContextGroup)
                {
                    IncludedContextGroup includedContextGroup = codedConceptOrInclude as IncludedContextGroup;

                    stringDump.Append("\r\n" + prefix + "  Include CONTEXT ID " + includedContextGroup.Id);
                }
                else
                {
                    throw new Exception("Not supposed to get here.");
                }
            }

            return(stringDump.ToString());
        }