Ejemplo n.º 1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="sequenceItem">The single sequence item that encodes this Measured Value.</param>
        public MeasuredValue(SequenceItem sequenceItem)
        {
            this.sequenceItem = sequenceItem;

            this.measurementUnits = ConceptCode.CreateConceptCode(sequenceItem, "0x004008EA", measurementUnitsContext);

            this.validationResults = new ValidationResults(context);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Validate the Concept Code using all loaded Context Groups).
        /// </summary>
        /// <param name="conceptCode">The Concept Code to validate.</param>
        public void ValidateUsingContextGroups(ConceptCode conceptCode)
        {
            //
            // Sanity checks.
            //

            if (conceptCode == null)
            {
                throw new ArgumentNullException("conceptCode");
            }


            //
            // Validate the Coding Scheme Designator on its own.
            //

            ValidateCodingSchemeDesignator(conceptCode);


            //
            // Validate the Code Value on its own.
            //

            ValidateCodeValue(conceptCode);


            //
            // Validate the Coding Scheme Designator and Code Value pair: check if this pair is present in any loaded Context Group.
            //

            string codingSchemeDesignator = conceptCode.CodingSchemeDesignator;
            string codeValue = conceptCode.CodeValue;

            IList <Specification.CodedConcept> matchingCodedConcepts = null;

            if ((codingSchemeDesignator != null) && (codeValue != null) && (codingSchemeDesignator != "") && (codeValue != ""))
            {
                matchingCodedConcepts = this.contextGroups.GetCodedConcepts(codingSchemeDesignator, codeValue);

                if (matchingCodedConcepts.Count == 0)
                {
                    conceptCode.ValidationResults.Add(new ValidationResult("For the Coding Scheme Designator and Code Value pair, no Coded Concept could be found in the loaded Context Groups."));
                }
            }


            //
            // Validate the Code Meaning.
            //

            if ((matchingCodedConcepts != null) && (matchingCodedConcepts.Count > 0))
            {
                ValidateCodeMeaning(matchingCodedConcepts, conceptCode);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Validate the Code Value on its own.
        /// </summary>
        /// <param name="conceptCode">The Concept Code.</param>
        private void ValidateCodeValue(ConceptCode conceptCode)
        {
            string codeValue = conceptCode.CodeValue;

            if (codeValue == null)
            {
                conceptCode.ValidationResults.Add(new ValidationResult("Code Value attribute does not exist."));
            }
            else if (codeValue == "")
            {
                conceptCode.ValidationResults.Add(new ValidationResult("First value of Code Value attribute is empty."));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Validate the Coding Scheme Designator on its own.
        /// </summary>
        /// <param name="conceptCode">The Concept Code.</param>
        private void ValidateCodingSchemeDesignator(ConceptCode conceptCode)
        {
            string codingSchemeDesignator = conceptCode.CodingSchemeDesignator;

            if (codingSchemeDesignator == null)
            {
                conceptCode.ValidationResults.Add(new ValidationResult("Coding Scheme Designator attribute does not exist."));
            }
            else if (codingSchemeDesignator == "")
            {
                conceptCode.ValidationResults.Add(new ValidationResult("First value of Coding Scheme Designator attribute is empty."));
            }
        }
Ejemplo n.º 5
0
        //
        // - Methods -
        //

        /// <summary>
        /// Validate the value for a Content Item with Value Type Code.
        /// </summary>
        /// <param name="contentItemWithValueTypeCode">The Content Item.</param>
        private void ValidateValue(ContentItemWithValueTypeCode contentItemWithValueTypeCode)
        {
            ConceptCode conceptCode = contentItemWithValueTypeCode.ConceptCode;

            if (conceptCode == null)
            {
                contentItemWithValueTypeCode.ValidationResults.Add(new ValidationResult("Sequence Item encoding the Concept Code does not exist."));
            }
            else
            {
                conceptCodeValidationRule.ValidateUsingContextGroups(conceptCode);
            }
        }
Ejemplo n.º 6
0
        //
        // - Methods -
        //

        /// <summary>
        /// Visit the supplied Content Item instance to validate its Concept Name.
        /// </summary>
        /// <param name="contentItem">The ContentItem instance to visit.</param>
        public void Visit(ContentItem contentItem)
        {
            ConceptCode conceptName = contentItem.ConceptName;

            if (conceptName == null)
            {
                contentItem.ValidationResults.Add(new ValidationResult("Sequence Item encoding the Concept Name does not exist."));
            }
            else
            {
                conceptCodeValidationRule.ValidateUsingContextGroups(conceptName);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Validate the value for a Content Item with Value Type Num.
        /// </summary>
        /// <param name="contentItemWithValueTypeNum">The Content Item.</param>
        private void ValidateValue(ContentItemWithValueTypeNum contentItemWithValueTypeNum)
        {
            //
            // Validate the Measured Value.
            //

            MeasuredValue measuredValue = contentItemWithValueTypeNum.MeasuredValue;

            if (measuredValue != null)
            {
                ConceptCode measurementUnits = measuredValue.MeasurementUnits;

                if (measurementUnits == null)
                {
                    contentItemWithValueTypeNum.ValidationResults.Add(new ValidationResult("Sequence Item encoding the Measurement Units does not exist."));
                }
                else
                {
                    if (measurementUnits.CodingSchemeDesignator != "UCUM")
                    {
                        measurementUnits.ValidationResults.Add(new ValidationResult("Coding Scheme Designator is not equal to UCUM."));
                    }

                    if (!Dvtk.Ucum.Tools.IsValidTerm(measurementUnits.CodeValue, true, false))
                    {
                        measurementUnits.ValidationResults.Add(new ValidationResult("Code Value does not contain a valid Units of Measurement."));
                    }
                }
            }


            //
            // Validate the Numeric Value qualifier.
            //

            ConceptCode numericValueQualifier = contentItemWithValueTypeNum.NumericValueQualifier;

            if (numericValueQualifier != null)
            {
                this.conceptCodeValidationRule.ValidateUsingContextGroup("42", numericValueQualifier);
            }
        }
Ejemplo n.º 8
0
        //
        // - Methods -
        //

        /// <summary>
        /// Validate the Code Meaning.
        /// </summary>
        /// <param name="matchingCodedConcepts">The matching Coded Concepts for the supplied Concept Code.</param>
        /// <param name="conceptCode">The Concept Code.</param>
        private void ValidateCodeMeaning(IList <Specification.CodedConcept> matchingCodedConcepts, ConceptCode conceptCode)
        {
            string conceptCodeCodeMeaning = conceptCode.CodeMeaning;

            if (conceptCodeCodeMeaning == null)
            {
                conceptCode.ValidationResults.Add(new ValidationResult("Code Meaning attribute does not exist."));
            }
            else if (conceptCodeCodeMeaning == "")
            {
                conceptCode.ValidationResults.Add(new ValidationResult("First value of Code Meaning attribute is empty."));
            }
            else
            {
                bool matchingCodeMeaningFound = false;

                foreach (Specification.CodedConcept codedConcept in matchingCodedConcepts)
                {
                    string codedConceptCodeMeaning = Convert.ToTrimmedString(codedConcept.CodeMeaning, VR.LO);

                    if (conceptCodeCodeMeaning == codedConceptCodeMeaning)
                    {
                        matchingCodeMeaningFound = true;
                        break;
                    }
                }

                if (!matchingCodeMeaningFound)
                {
                    conceptCode.ValidationResults.Add(new ValidationResult("Code meaning not correct for Coding Scheme Designator and Code Value pair."));
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Validate the Concept Code using one specific Context Group (if loaded).
        /// </summary>
        /// <param name="cid">The Context ID of the Context Group to use.</param>
        /// <param name="conceptCode">The Concept Code to validate.</param>
        public void ValidateUsingContextGroup(string cid, ConceptCode conceptCode)
        {
            //
            // Sanity checks.
            //

            if (cid == null)
            {
                throw new ArgumentNullException("cid");
            }

            if (conceptCode == null)
            {
                throw new ArgumentNullException("conceptCode");
            }


            //
            // Validate the Coding Scheme Designator on its own.
            //

            ValidateCodingSchemeDesignator(conceptCode);


            //
            // Validate the Code Value on its own.
            //

            ValidateCodeValue(conceptCode);


            //
            // Validate the Coding Scheme Designator and Code Value pair:
            // check if this pair is present in the Context Group that is specified by the supplied Content ID.
            //

            string codingSchemeDesignator = conceptCode.CodingSchemeDesignator;
            string codeValue = conceptCode.CodeValue;

            IList <Specification.CodedConcept> matchingCodedConcepts = null;

            if ((codingSchemeDesignator != null) && (codeValue != null) && (codingSchemeDesignator != "") && (codeValue != ""))
            {
                matchingCodedConcepts = this.contextGroups.GetCodedConcepts(cid, codingSchemeDesignator, codeValue);

                if (matchingCodedConcepts == null)
                {
                    ValidationResult validationResult =
                        new ValidationResult
                            ("Unable to validate Coding Scheme Designator and Code Value pair because specific Context Group is not loaded.",
                            "Unable to validate Coding Scheme Designator and Code Value pair because Context Group \"" + cid + "\" is not loaded.");

                    conceptCode.ValidationResults.Add(validationResult);
                }
                else

                if (matchingCodedConcepts.Count == 0)
                {
                    ValidationResult validationResult =
                        new ValidationResult
                            ("For the Coding Scheme Designator and Code Value pair, no Coded Concept could be found in specific Context Group.",
                            "For the Coding Scheme Designator and Code Value pair, no Coded Concept could be found in Context Group \"" + cid + "\".");

                    conceptCode.ValidationResults.Add(validationResult);
                }
            }


            //
            // Validate the Code Meaning.
            //

            if ((matchingCodedConcepts != null) && (matchingCodedConcepts.Count > 0))
            {
                ValidateCodeMeaning(matchingCodedConcepts, conceptCode);
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="sequenceItem">
 /// The attributeSet instance containing the DICOM attributes to construct this instance with.
 /// </param>
 /// <param name="parentContentItem">The parent Content Item.</param>
 /// <param name="position">
 /// The ordinal position of the associated Sequence Item in it's contained Content Sequence
 /// Item.
 /// </param>
 internal ContentItem(AttributeSet attributeSet, ContentItem parentContentItem, uint position)
 {
     this.attributeSet = attributeSet;
     this.conceptName = ConceptCode.CreateConceptCode(attributeSet, "0x0040A043", conceptNameContext);
     this.position = position;
     this.parentContentItem = parentContentItem;
     childContentItems = new List<ContentItem>();
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="sequenceItem">
        /// The SequenceItem instance containing the DICOM attributes to construct this instance with.
        /// </param>
        /// <param name="parentContentItem">The parent Content Item.</param>
        /// <param name="position">The ordinal position of the associated Sequence Item in it's contained Content Sequence Item.</param>
        public ContentItemWithValueTypeNum(AttributeSet attributeSet, ContentItem parentContentItem, uint position)
            : base(attributeSet, parentContentItem, position)
        {
            DvtkHighLevelInterface.Dicom.Other.Attribute attribute = attributeSet["0x0040A300"];

            if (attribute.Exists)
            {
                if (attribute.VR == VR.SQ)
                {
                    if (attribute.ItemCount > 0)
                    {
                        this.measuredValue  = new MeasuredValue(attribute.GetItem(1));
                    }
                }
            }

            this.numericValueQualifier = ConceptCode.CreateConceptCode(attributeSet, "0x0040A301", numericValueQualifierContext);
        }