Exemple #1
0
        /// <summary>
        /// Create a Worklist Query Dataset from the given query tags and the default return keys.
        /// </summary>
        /// <param name="queryTags">Query Tags.</param>
        /// <returns>DvtkData.Dimse.DataSet - Modality Worklist Query Dataset.</returns>
        public static DvtkData.Dimse.DataSet CreateWorklistQueryDataset(TagValueCollection queryTags)
        {
            DvtkData.Dimse.DataSet dataset = new DvtkData.Dimse.DataSet("Modality Worklist Information Model - FIND SOP Class");

            // update the query tags with any parent sequence information needed
            UpdateTagParentSequences(queryTags);

            // add the default return keys
            AddDefaultReturnKeys(dataset);

            // add the query keys
            AddTagsToDataset(queryTags, dataset);

            return dataset;
        }
Exemple #2
0
        public bool UseComparator(TagValueCollection tagValueFilterCollection, bool universalMatchAllowed)
        {
            int filterCounter = 0;

            // Check if the filter values match those in the template
            foreach(BaseTagValue baseTagValue in tagValueFilterCollection)
            {
                DicomTagValue dicomTagValue = null;

                if (baseTagValue is DicomTagValue)
                {
                    dicomTagValue = (DicomTagValue)baseTagValue;
                }
                else if (baseTagValue is Hl7TagValue)
                {
                    Hl7TagValue hl7TagValue = (Hl7TagValue)baseTagValue;
                    dicomTagValue = new DicomTagValue(DicomHl7TagMapTemplate.Hl7ToDicomTag(hl7TagValue.Tag), hl7TagValue.Value);
                }

                if (dicomTagValue.Tag != Tag.UNDEFINED)
                {
                    foreach (DicomComparisonTag thisComparisonTag in this.Template.ComparisonTags)
                    {
                        // Tags are the same
                        if (thisComparisonTag.Tag == dicomTagValue.Tag)
                        {
                            if (universalMatchAllowed == true)
                            {
                                // When universal matching either a zero-length or exact match are OK
                                if ((dicomTagValue.Value == System.String.Empty) ||
                                    (thisComparisonTag.DataFormat.ToDicomFormat() == dicomTagValue.Value))
                                {
                                    filterCounter++;
                                }
                            }
                            else if ((universalMatchAllowed == false) &&
                                (thisComparisonTag.DataFormat.ToDicomFormat() == dicomTagValue.Value))
                            {
                                // Not universal matching so only an exact match is OK
                                filterCounter++;
                            }
                            break;
                        }
                    }
                }
            }

            bool useThisComparator = (tagValueFilterCollection.Count == filterCounter) ? true : false;

            return useThisComparator;
        }
Exemple #3
0
        /// <summary>
        /// Send a C-MOVE-RQ Information Model Retrieve.
        /// Retrieve based on the informationModel provided and the query/retrieve level. Take
        /// the retrieve tags from the retrieveTags provided. The retrieve is done to the move
        /// destination.
        /// 
        /// The C-MOVE-RSP messages returned are stored in a DicomQueryItemCollection named RetrieveItems.
        /// </summary>
        /// <param name="informationModel">Q/R Information Model to be used in the retrieve operation.</param>
        /// <param name="level">Query / retrieve level.</param>
        /// <param name="moveDestination">AE Title of the "move" destination.</param>
        /// <param name="retrieveTags">List of Retrieve Tags.</param>
        /// <returns>Boolean indicating success or failure.</returns>
        public bool SendRetrieveImages(QueryRetrieveInformationModelEnum informationModel, QueryRetrieveLevelEnum level, System.String moveDestination, TagValueCollection retrieveTags)
        {
            System.String queryRetrieveLevel = System.String.Empty;
            switch(level)
            {
                case QueryRetrieveLevelEnum.PatientQueryRetrieveLevel:
                    queryRetrieveLevel = "PATIENT";
                    break;
                case QueryRetrieveLevelEnum.StudyQueryRetrieveLevel:
                    queryRetrieveLevel = "STUDY";
                    break;
                case QueryRetrieveLevelEnum.SeriesQueryRetrieveLevel:
                    queryRetrieveLevel = "SERIES";
                    break;
                case QueryRetrieveLevelEnum.InstanceQueryRetrieveLevel:
                    queryRetrieveLevel = "IMAGE";
                    break;
                default:
                    return false;
            }
            if (retrieveTags.Find(Tag.QUERY_RETRIEVE_LEVEL) == null)
            {
                retrieveTags.Add(new DicomTagValue(Tag.QUERY_RETRIEVE_LEVEL, queryRetrieveLevel));
            }
            _retrieveItems = new DicomQueryItemCollection();

            DicomTrigger trigger = new DicomTrigger(TransactionNameEnum.RAD_16);
            System.String sopClassUid = System.String.Empty;
            switch(informationModel)
            {
                case QueryRetrieveInformationModelEnum.PatientRootQueryRetrieveInformationModel:
                    sopClassUid = "1.2.840.10008.5.1.4.1.2.1.2";
                    break;
                case QueryRetrieveInformationModelEnum.StudyRootQueryRetrieveInformationModel:
                    sopClassUid = "1.2.840.10008.5.1.4.1.2.2.2";
                    break;
                case QueryRetrieveInformationModelEnum.PatientStudyOnlyQueryRetrieveInformationModel:
                    sopClassUid = "1.2.840.10008.5.1.4.1.2.3.2";
                    break;
                default:
                    return false;
            }
            trigger.AddItem(GenerateTriggers.MakeCMoveRetrieve(informationModel, moveDestination, retrieveTags),
                            sopClassUid,
                            "1.2.840.10008.1.2");

            // RAD-16 - trigger the ImageArchive
            bool triggerResult = TriggerActorInstances(ActorTypeEnum.ImageArchive, trigger, true);

            // Get the retrieve items returned
            if (triggerResult == true)
            {
                foreach (ActorsTransaction actorsTransaction in ActorsTransactionLog)
                {
                    if (actorsTransaction.FromActorName.Type == ActorTypeEnum.ImageArchive)
                    {
                        BaseTransaction baseTransaction = actorsTransaction.Transaction;
                        if (baseTransaction is DicomTransaction)
                        {
                            DicomTransaction dicomTransaction = (DicomTransaction)baseTransaction;
                            if (dicomTransaction.Processed == false)
                            {
                                DicomMessageCollection cMoveResponses = dicomTransaction.DicomMessages.CMoveResponses;
                                int index = 0;
                                foreach (DvtkHighLevelInterface.Dicom.Messages.DicomMessage dicomMessage in cMoveResponses)
                                {
                                    // store all C-MOVE-RSP messages
                                    // - use DicomQueryItem.GetValue(Tag.NUMBER_OF_COMPLETED_SUBOPERATIONS) to get completed count
                                    // - use DicomQueryItem.GetValue(Tag.NUMBER_OF_FAILED_SUBOPERATIONS) to get failed count
                                    // - use DicomQueryItem.GetValue(Tag.NUMBER_OF_REMAINING_SUBOPERATIONS) to get remaining count
                                    // - use DicomQueryItem.GetValue(Tag.NUMBER_OF_WARNING_SUBOPERATIONS) to get warning count
                                    DicomQueryItem dicomRetriveItem = new DicomQueryItem(index++, dicomMessage);
                                    _retrieveItems.Add(dicomRetriveItem);
                                }
                                dicomTransaction.Processed = true;
                            }
                        }
                    }
                }
            }

            return triggerResult;
        }
Exemple #4
0
        /// <summary>
        /// Send a C-FIND-RQ Information Model Query.
        /// Query based on the informationModel provided and the query/retrieve level. Take
        /// the query tags from the queryTags provided.
        /// 
        /// The C-FIND-RSP messages returned are stored in a DicomQueryItemCollection named QueryItems.
        /// </summary>
        /// <param name="informationModel">Q/R Information Model to be used in the query operation.</param>
        /// <param name="level">Query / retrieve level.</param>
        /// <param name="queryTags">List of Query Tags.</param>
        /// <returns>Boolean indicating success or failure.</returns>
        public bool SendQueryImages(QueryRetrieveInformationModelEnum informationModel, QueryRetrieveLevelEnum level, TagValueCollection queryTags)
        {
            System.String queryRetrieveLevel = System.String.Empty;
            switch(level)
            {
                case QueryRetrieveLevelEnum.PatientQueryRetrieveLevel:
                    _patientLevelQueryItems = new DicomQueryItemCollection();
                    queryRetrieveLevel = "PATIENT";
                    break;
                case QueryRetrieveLevelEnum.StudyQueryRetrieveLevel:
                    _studyLevelQueryItems = new DicomQueryItemCollection();
                    queryRetrieveLevel = "STUDY";
                    break;
                case QueryRetrieveLevelEnum.SeriesQueryRetrieveLevel:
                    _seriesLevelQueryItems = new DicomQueryItemCollection();
                    queryRetrieveLevel = "SERIES";
                    break;
                case QueryRetrieveLevelEnum.InstanceQueryRetrieveLevel:
                    _instanceLevelQueryItems = new DicomQueryItemCollection();
                    queryRetrieveLevel = "IMAGE";
                    break;
                default:
                    return false;
            }
            if (queryTags.Find(Tag.QUERY_RETRIEVE_LEVEL) == null)
            {
                queryTags.Add(new DicomTagValue(Tag.QUERY_RETRIEVE_LEVEL, queryRetrieveLevel));
            }

            DicomQueryItemCollection queryItems = QueryItems(level);

            DicomTrigger trigger = new DicomTrigger(TransactionNameEnum.RAD_14);
            System.String sopClassUid = System.String.Empty;
            switch(informationModel)
            {
                case QueryRetrieveInformationModelEnum.PatientRootQueryRetrieveInformationModel:
                    sopClassUid = "1.2.840.10008.5.1.4.1.2.1.1";
                    break;
                case QueryRetrieveInformationModelEnum.StudyRootQueryRetrieveInformationModel:
                    sopClassUid = "1.2.840.10008.5.1.4.1.2.2.1";
                    break;
                case QueryRetrieveInformationModelEnum.PatientStudyOnlyQueryRetrieveInformationModel:
                    sopClassUid = "1.2.840.10008.5.1.4.1.2.3.1";
                    break;
                default:
                    return false;
            }
            trigger.AddItem(GenerateTriggers.MakeCFindQuery(informationModel, queryTags),
                            sopClassUid,
                            "1.2.840.10008.1.2");

            // RAD-14 - trigger the ImageArchive
            bool triggerResult = TriggerActorInstances(ActorTypeEnum.ImageArchive, trigger, true);

            // Get the query items returned
            if (triggerResult == true)
            {
                foreach (ActorsTransaction actorsTransaction in ActorsTransactionLog)
                {
                    if (actorsTransaction.FromActorName.Type == ActorTypeEnum.ImageArchive)
                    {
                        BaseTransaction baseTransaction = actorsTransaction.Transaction;
                        if (baseTransaction is DicomTransaction)
                        {
                            DicomTransaction dicomTransaction = (DicomTransaction)baseTransaction;
                            if (dicomTransaction.Processed == false)
                            {
                                DicomMessageCollection cFindResponses = dicomTransaction.DicomMessages.CFindResponses;
                                int index = 0;
                                foreach (DvtkHighLevelInterface.Dicom.Messages.DicomMessage dicomMessage in cFindResponses)
                                {
                                    if (dicomMessage.DataSet.Count != 0)
                                    {
                                        DicomQueryItem dicomQueryItem = new DicomQueryItem(index++, dicomMessage);
                                        queryItems.Add(dicomQueryItem);
                                    }
                                }
                                dicomTransaction.Processed = true;
                            }
                        }
                    }
                }
            }

            return triggerResult;
        }
Exemple #5
0
        private static void AddQueryRetrieveKeys(TagValueCollection queryTags, DvtkData.Dimse.DataSet dataset)
        {
            // use script session to get to definition singleton
            Dvtk.Sessions.ScriptSession scriptSession = new Dvtk.Sessions.ScriptSession();

            // iterate over the query tags
            foreach(DicomTagValue queryTag in queryTags)
            {
                if (queryTag.ParentSequenceTag != DvtkData.Dimse.Tag.UNDEFINED)
                {
                    // try to get the sequence tag in the dataset
                    DvtkData.Dimse.Attribute sequenceAttribute = dataset.GetAttribute(queryTag.ParentSequenceTag);
                    if ((sequenceAttribute != null) &&
                        (sequenceAttribute.ValueRepresentation == DvtkData.Dimse.VR.SQ))
                    {
                        SequenceOfItems sequenceOfItems = (SequenceOfItems)sequenceAttribute.DicomValue;
                        if (sequenceOfItems.Sequence.Count == 1)
                        {
                            DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0];

                            if (item != null)
                            {
                                VR vr = scriptSession.DefinitionManagement.GetAttributeVrFromDefinition(queryTag.Tag);

                                // add the query value
                                item.AddAttribute(queryTag.Tag.GroupNumber,
                                    queryTag.Tag.ElementNumber,
                                    vr,
                                    queryTag.Value);
                            }
                        }
                    }
                }
                else
                {
                    VR vr = scriptSession.DefinitionManagement.GetAttributeVrFromDefinition(queryTag.Tag);

                    // add the query value
                    dataset.AddAttribute(queryTag.Tag.GroupNumber,
                        queryTag.Tag.ElementNumber,
                        vr,
                        queryTag.Value);
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Generate a Modality Worklist Item from the user defined tags provided and
        /// the Default Value Manager.
        /// </summary>
        /// <param name="defaultValueManager">Default Value Manager.</param>
        /// <param name="userDefinedTags">User defined Tags.</param>
        /// <returns>CFind Modality Worklist Response message.</returns>
        public static DvtkHighLevelInterface.Dicom.Messages.DicomMessage MakeModalityWorklistItem(Dvtk.Dicom.InformationEntity.DefaultValues.DefaultValueManager defaultValueManager, 
            TagValueCollection userDefinedTags)
        {
            DvtkHighLevelInterface.Dicom.Messages.DicomMessage worklistResponseMessage = new DvtkHighLevelInterface.Dicom.Messages.DicomMessage(DvtkData.Dimse.DimseCommand.CFINDRSP);
            worklistResponseMessage.Set("0x00000002", VR.UI, "1.2.840.10008.5.1.4.31");

            DvtkData.Dimse.DataSet worklistItemDataset = Dvtk.Dicom.InformationEntity.Worklist.WorklistQueryDataset.CreateWorklistItemDataset(userDefinedTags);
            worklistResponseMessage.DataSet.DvtkDataDataSet = worklistItemDataset;

            // Add the default values
            AddDefaultWorklistResponseValues(defaultValueManager, worklistItemDataset);

            return worklistResponseMessage;
        }
Exemple #7
0
        /// <summary>
        /// Create C-Move retrieve.
        /// </summary>
        /// <param name="informationModel">The information model.</param>
        /// <param name="moveDestination">The move destination.</param>
        /// <param name="retrieveTags">The retrieve tags.</param>
        /// <returns>teh C-MOVE message.</returns>
        public static DvtkHighLevelInterface.Dicom.Messages.DicomMessage MakeCMoveRetrieve(QueryRetrieveInformationModelEnum informationModel, System.String moveDestination, TagValueCollection retrieveTags)
        {
            DvtkHighLevelInterface.Dicom.Messages.DicomMessage retrieveMessage = new DvtkHighLevelInterface.Dicom.Messages.DicomMessage(DvtkData.Dimse.DimseCommand.CMOVERQ);
            DvtkData.Dimse.DataSet retrieveDataset = null;

            switch(informationModel)
            {
                case QueryRetrieveInformationModelEnum.PatientRootQueryRetrieveInformationModel:
                default:
                    retrieveMessage.Set("0x00000002", VR.UI, "1.2.840.10008.5.1.4.1.2.1.2");
                    retrieveDataset = new DvtkData.Dimse.DataSet("Patient Root Query/Retrieve Information Model - MOVE SOP Class");
                    break;
                case QueryRetrieveInformationModelEnum.StudyRootQueryRetrieveInformationModel:
                    retrieveMessage.Set("0x00000002", VR.UI, "1.2.840.10008.5.1.4.1.2.2.2");
                    retrieveDataset = new DvtkData.Dimse.DataSet("Study Root Query/Retrieve Information Model - MOVE SOP Class");
                    break;
                case QueryRetrieveInformationModelEnum.PatientStudyOnlyQueryRetrieveInformationModel:
                    retrieveMessage.Set("0x00000002", VR.UI, "1.2.840.10008.5.1.4.1.2.3.2");
                    retrieveDataset = new DvtkData.Dimse.DataSet("Patient/Study Only Query/Retrieve Info. Model - MOVE SOP Class");
                    break;
            }

            retrieveMessage.Set("0x00000600", VR.AE, moveDestination);

            // add the query keys
            AddQueryRetrieveKeys(retrieveTags, retrieveDataset);
            retrieveMessage.DataSet.DvtkDataDataSet = retrieveDataset;

            return retrieveMessage;
        }
Exemple #8
0
        private static void AddTagsToDataset(TagValueCollection tags, DvtkData.Dimse.DataSet dataset)
        {
            // iterate over the tags
            foreach(DicomTagValue tag in tags)
            {
                if (tag.ParentSequenceTag != Tag.UNDEFINED)
                {
                    // try to get the sequence tag in the dataset
                    DvtkData.Dimse.Attribute sequenceAttribute = dataset.GetAttribute(tag.ParentSequenceTag);
                    if ((sequenceAttribute != null) &&
                        (sequenceAttribute.ValueRepresentation == DvtkData.Dimse.VR.SQ))
                    {
                        SequenceOfItems sequenceOfItems = (SequenceOfItems)sequenceAttribute.DicomValue;
                        if (sequenceOfItems.Sequence.Count == 1)
                        {
                            SequenceItem item = sequenceOfItems.Sequence[0];

                            if (item != null)
                            {
                                VR vr = VR.UN;

                                // try to get the attribute in the item
                                DvtkData.Dimse.Attribute attribute = item.GetAttribute(tag.Tag);
                                if (attribute != null)
                                {
                                    vr = attribute.ValueRepresentation;
                                    item.Remove(attribute);
                                }

                                // add the query value
                                item.AddAttribute(tag.Tag.GroupNumber,
                                    tag.Tag.ElementNumber,
                                    vr,
                                    tag.Value);
                            }
                        }
                    }
                }
                else
                {
                    VR vr = VR.UN;

                    // try to get the attribute in the dataset
                    DvtkData.Dimse.Attribute attribute = dataset.GetAttribute(tag.Tag);
                    if (attribute != null)
                    {
                        vr = attribute.ValueRepresentation;
                        dataset.Remove(attribute);
                    }

                    // special check for the SPECIFIC CHARACTER SET attribute
                    if (tag.Tag == Tag.SPECIFIC_CHARACTER_SET)
                    {
                        vr = VR.CS;
                    }

                    // add the query value
                    dataset.AddAttribute(tag.Tag.GroupNumber,
                        tag.Tag.ElementNumber,
                        vr,
                        tag.Value);
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// Generate a CFind Modality Worklist Query trigger from the given queryTags.
        /// All other return keys are taken from the supported return key attributes
        /// in the Worklist Information Model.
        /// </summary>
        /// <param name="queryTags">List of Query Tags.</param>
        /// <returns>CFind Modality Worklist Query trigger.</returns>
        public static DvtkHighLevelInterface.Dicom.Messages.DicomMessage MakeCFindModalityWorklist(TagValueCollection queryTags)
        {
            DvtkHighLevelInterface.Dicom.Messages.DicomMessage queryMessage = new DvtkHighLevelInterface.Dicom.Messages.DicomMessage(DvtkData.Dimse.DimseCommand.CFINDRQ);
            queryMessage.Set("0x00000002", VR.UI, "1.2.840.10008.5.1.4.31");

            DvtkData.Dimse.DataSet queryDataset = Dvtk.Dicom.InformationEntity.Worklist.WorklistQueryDataset.CreateWorklistQueryDataset(queryTags);
            queryMessage.DataSet.DvtkDataDataSet = queryDataset;

            return queryMessage;
        }
Exemple #10
0
 /// <summary>
 /// Compare the two messages.
 /// </summary>
 /// <param name="tagValueFilterCollection">Tag Value Filter.</param>
 /// <param name="resultsReporter">Results reporter.</param>
 /// <param name="thatBaseComparator">Reference comparator.</param>
 /// <returns>bool - true = messages compared, false messages not compared</returns>
 public abstract bool Compare(TagValueCollection tagValueFilterCollection, ResultsReporter resultsReporter, BaseComparator thatBaseComparator);
 /// <summary>
 /// Send a CFind Modality Worklist Query trigger from the given queryTags.
 /// All other return keys are taken from the supported return key attributes
 /// in the Worklist Information Model.
 /// </summary>
 /// <param name="queryTags">List of Query Tags.</param>
 /// <returns>Boolean indicating success or failure.</returns>
 public bool SendQueryModalityWorklist(TagValueCollection queryTags)
 {
     // Generate trigger using the query tags
     DicomTrigger trigger = new DicomTrigger(TransactionNameEnum.RAD_5);
     trigger.AddItem(GenerateTriggers.MakeCFindModalityWorklist(queryTags),
                     "1.2.840.10008.5.1.4.31",
                     "1.2.840.10008.1.2");
     return TriggerModalityWorklistQuery(trigger);
 }
 /// <summary>
 /// Create an unscheduled worklist item by adding the given user defined tags to those
 /// of the Default Value Manager. This worklist item can then be used in the
 /// SendNCreateModalityProcedureStepInProgress() and SendModalityImagesStored() method
 /// calls.
 /// This simulates the IHE Unscheduled Use Case.
 /// </summary>
 /// <param name="userDefinedTags">User defined Tags.</param>
 /// <returns>Modality worklist item populated from the user defined tags and default values.</returns>
 public DicomQueryItem CreateUnscheduledWorklistItem(TagValueCollection userDefinedTags)
 {
     return new DicomQueryItem(1, GenerateTriggers.MakeModalityWorklistItem(DefaultValueManager, userDefinedTags));
 }
Exemple #13
0
 private static void UpdateTagParentSequences(TagValueCollection tags)
 {
     ScheduledProcedureStepInformationEntity scheduledProcedureStepIe = new ScheduledProcedureStepInformationEntity();
     foreach(DicomTagValue tag in tags)
     {
         foreach (TagType tagType in scheduledProcedureStepIe.TagTypeList)
         {
             // special check to be made on the Specific Character Set tag
             // - this tag is added to the scheduledProcedureStepIe.TagTypeList purely to
             // be able to return the correct values in the query response - we should not set
             // the ParentSequenceTag for this attribute
             // - this is a workaround - but please do not change it!
             if ((tag.Tag == tagType.Tag) &&
                 (tag.Tag != Tag.SPECIFIC_CHARACTER_SET))
             {
                 // set the parent sequence in the tag
                 tag.ParentSequenceTag = Tag.SCHEDULED_PROCEDURE_STEP_SEQUENCE;
                 break;
             }
         }
     }
 }
Exemple #14
0
        private TagValueCollection GenerateTagValueCollection(TagValueCollection tagValueFilterCollection)
        {
            TagValueCollection localTagValueCollection = new TagValueCollection();

            // Check if the comparator can be used with a Universal Match on the Value of the Tag
            // - that is zero-length Value.
            if (this.UseComparator(tagValueFilterCollection, true) == true)
            {
                foreach(BaseTagValue baseTagValue in tagValueFilterCollection)
                {
                    DicomTagValue dicomTagValue = null;

                    if (baseTagValue is DicomTagValue)
                    {
                        dicomTagValue = (DicomTagValue)baseTagValue;
                    }
                    else if (baseTagValue is Hl7TagValue)
                    {
                        Hl7TagValue hl7TagValue = (Hl7TagValue)baseTagValue;
                        dicomTagValue = new DicomTagValue(DicomHl7TagMapTemplate.Hl7ToDicomTag(hl7TagValue.Tag), hl7TagValue.Value);
                    }

                    // If the Value is empty (Universal Match) then try to get the actual
                    // value from the comparator so that is actual value will be used against
                    // other comparators.
                    if (dicomTagValue.Tag != Tag.UNDEFINED)
                    {
                        if (dicomTagValue.Value == System.String.Empty)
                        {
                            // try to get a value for this Tag from this comparator
                            System.String lValue = getValue(dicomTagValue.Tag);

                            // Add a new Tag Value - with Value coming from this comparator
                            // to the local filter.
                            DicomTagValue lDicomTagValue = new DicomTagValue(dicomTagValue.Tag, lValue);
                            localTagValueCollection.Add(lDicomTagValue);
                        }
                        else
                        {
                            // Just add the given Tag Value pair to the local filter
                            localTagValueCollection.Add(dicomTagValue);
                        }
                    }
                }
            }

            // Return the local filter
            return localTagValueCollection;
        }
Exemple #15
0
        /// <summary>
        /// Make C-FIND query.
        /// </summary>
        /// <param name="informationModel">The information model.</param>
        /// <param name="queryTags">The query tags.</param>
        /// <returns>The create C-FIND message.</returns>
        public static DvtkHighLevelInterface.Dicom.Messages.DicomMessage MakeCFindQuery(QueryRetrieveInformationModelEnum informationModel, TagValueCollection queryTags)
        {
            DvtkHighLevelInterface.Dicom.Messages.DicomMessage queryMessage = new DvtkHighLevelInterface.Dicom.Messages.DicomMessage(DvtkData.Dimse.DimseCommand.CFINDRQ);
            DvtkData.Dimse.DataSet queryDataset = null;

            switch(informationModel)
            {
                case QueryRetrieveInformationModelEnum.PatientRootQueryRetrieveInformationModel:
                default:
                    queryMessage.Set("0x00000002", VR.UI, "1.2.840.10008.5.1.4.1.2.1.1");
                    queryDataset = new DvtkData.Dimse.DataSet("Patient Root Query/Retrieve Information Model - FIND SOP Class");
                    break;
                case QueryRetrieveInformationModelEnum.StudyRootQueryRetrieveInformationModel:
                    queryMessage.Set("0x00000002", VR.UI, "1.2.840.10008.5.1.4.1.2.2.1");
                    queryDataset = new DvtkData.Dimse.DataSet("Study Root Query/Retrieve Information Model - FIND SOP Class");
                    break;
                case QueryRetrieveInformationModelEnum.PatientStudyOnlyQueryRetrieveInformationModel:
                    queryMessage.Set("0x00000002", VR.UI, "1.2.840.10008.5.1.4.1.2.3.1");
                    queryDataset = new DvtkData.Dimse.DataSet("Patient/Study Only Query/Retrieve Info. Model - FIND SOP Class");
                    break;
            }

            // add the query keys
            AddQueryRetrieveKeys(queryTags, queryDataset);
            queryMessage.DataSet.DvtkDataDataSet = queryDataset;

            return queryMessage;
        }
Exemple #16
0
        /// <summary>
        /// Compare the two messages.
        /// </summary>
        /// <param name="tagValueFilterCollection">Tag Value Filter.</param>
        /// <param name="resultsReporter">Results reporter.</param>
        /// <param name="thatBaseComparator">Reference comparator.</param>
        /// <returns>bool - true = messages compared, false messages not compared</returns>
        public override bool Compare(TagValueCollection tagValueFilterCollection, ResultsReporter resultsReporter, BaseComparator thatBaseComparator)
        {
            bool compared = false;

            if (thatBaseComparator is DicomComparator)
            {
                DicomComparator thatDicomComparator = (DicomComparator)thatBaseComparator;

                // Check if both templates have been initialized correctly
                if ((this.Template == null) ||
                    (thatDicomComparator.Template == null))
                {
                    return false;
                }

                // Check for comparator equality
                if (this == thatDicomComparator)
                {
                    return true;
                }

                // filter out comparators for the same message types
                if ((this.Template.Command == thatDicomComparator.Template.Command) &&
                    (this.Template.SopClassUid == thatDicomComparator.Template.SopClassUid))
                {
                    return false;
                }

                // generate a local Tag Value collection from this
                // - this collection will include any tag value pair from the original collection and
                // the tag value pairs of any tags only (in the original collection) that match from this
                // comparator - that is the values are taken from this comparator.
                TagValueCollection lTagValueFilterCollection = GenerateTagValueCollection(tagValueFilterCollection);

                // check to see if the comparision filters match - without Univeral Matching
                // - now try to match this local filter collection against thatDicomComparator
                // - comparators that match will have the same tag value pairs (including the value) as
                // each other.
                if ((tagValueFilterCollection.Count == lTagValueFilterCollection.Count) &&
                    (thatDicomComparator.UseComparator(lTagValueFilterCollection, false) == true))
                {
                    MessageComparisonResults messageComparisonResults
                        = new MessageComparisonResults(this.Name,
                        thatDicomComparator.Name,
                        this.Template.Command,
                        thatDicomComparator.Template.Command,
                        this.Template.SopClassUid,
                        thatDicomComparator.Template.SopClassUid);

                    // Iterate over this comparator
                    foreach (DicomComparisonTag thisComparisonTag in this.Template.ComparisonTags)
                    {
                        // try to get the equivalent tag in thatDicomComparator
                        DicomComparisonTag thatComparisonTag = thatDicomComparator.Template.ComparisonTags.Find(thisComparisonTag.Tag);
                        if (thatComparisonTag != null)
                        {
                            AttributeComparisonResults attributeComparisonResults
                                = new AttributeComparisonResults(thisComparisonTag.Tag,
                                thisComparisonTag.DataFormat.ToDicomFormat(),
                                thatComparisonTag.DataFormat.ToDicomFormat());

                            if (thisComparisonTag.DataFormat.Equals(thatComparisonTag.DataFormat) == false)
                            {
                                DvtkData.Validation.ValidationMessage validationMessage = new DvtkData.Validation.ValidationMessage();
                                validationMessage.Type = DvtkData.Validation.MessageType.Error;
                                validationMessage.Message = "Attribute values do not match.";

                                attributeComparisonResults.Messages.Add(validationMessage);
                            }
                            messageComparisonResults.Add(attributeComparisonResults);
                        }
                    }

                    resultsReporter.WriteMessageComparisonResults(messageComparisonResults);

                    compared = true;
                }
            }
            else if (thatBaseComparator is Hl7Comparator)
            {
                Hl7Comparator thatHl7Comparator = (Hl7Comparator)thatBaseComparator;

                // Check if both templates have been initialized correctly
                if ((this.Template == null) ||
                    (thatHl7Comparator.Template == null))
                {
                    return false;
                }

                // generate a local Tag Value collection from this
                // - this collection will include any tag value pair from the original collection and
                // the tag value pairs of any tags only (in the original collection) that match from this
                // comparator - that is the values are taken from this comparator.
                TagValueCollection lTagValueFilterCollection = GenerateTagValueCollection(tagValueFilterCollection);

                // check to see if the comparision filters match - without Univeral Matching
                // - now try to match this local filter collection against thatDicomComparator
                // - comparators that match will have the same tag value pairs (including the value) as
                // each other.
                if ((tagValueFilterCollection.Count == lTagValueFilterCollection.Count) &&
                    (thatHl7Comparator.UseComparator(lTagValueFilterCollection, false) == true))
                {
                    MessageComparisonResults messageComparisonResults
                        = new MessageComparisonResults(this.Name,
                        thatHl7Comparator.Name,
                        this.Template.Command,
                        thatHl7Comparator.Template.MessageType,
                        this.Template.SopClassUid,
                        thatHl7Comparator.Template.MessageSubType);

                    // Iterate over this comparator
                    foreach (DicomComparisonTag thisComparisonTag in this.Template.ComparisonTags)
                    {
                        // try to get the equivalent tag in thatHl7Comparator
                        Hl7ComparisonTag thatComparisonTag = thatHl7Comparator.Template.ComparisonTags.Find(DicomHl7TagMapTemplate.DicomToHl7Tag(thisComparisonTag.Tag));
                        if (thatComparisonTag != null)
                        {
                            AttributeComparisonResults attributeComparisonResults
                                = new AttributeComparisonResults(thisComparisonTag.Tag,
                                SegmentNames.Name(thatComparisonTag.Tag.Segment),
                                thatComparisonTag.Tag.FieldIndex,
                                thisComparisonTag.DataFormat.ToDicomFormat(),
                                thatComparisonTag.DataFormat.ToHl7Format());

                            if (thisComparisonTag.DataFormat.Equals(thatComparisonTag.DataFormat) == false)
                            {
                                DvtkData.Validation.ValidationMessage validationMessage = new DvtkData.Validation.ValidationMessage();
                                validationMessage.Type = DvtkData.Validation.MessageType.Error;
                                validationMessage.Message = "Attribute values do not match.";

                                attributeComparisonResults.Messages.Add(validationMessage);
                            }
                            messageComparisonResults.Add(attributeComparisonResults);
                        }
                    }

                    resultsReporter.WriteMessageComparisonResults(messageComparisonResults);

                    compared = true;
                }
            }

            return compared;
        }
Exemple #17
0
        /// <summary>
        /// 
        /// </summary>
        public void CreateDefaultTagValues()
        {
            // Create a default value list that is the combination of the user defined
            // default values and the in-built default values. The user defined values
            // take precedence.
            _defaultDicomTagValues = new TagValueCollection();

            // Add all the user defined default values provided
            foreach(BaseDicomTagValue userDefinedTagValue in _userDefinedDefaultTagValues)
            {
                if (userDefinedTagValue is DicomTagValueDelete)
                {
                    // Do not add this to the list as the default should be deleted
                }
                else
                {
                    _defaultDicomTagValues.Add(userDefinedTagValue);
                }
            }

            // Generate all the in-built default values
            InBuiltDefaultTagValues inBuiltDefaultTagValues = new InBuiltDefaultTagValues();

            // Add the in-built default values - but only if not defined by the user
            foreach(BaseDicomTagValue inBuiltTagValue in inBuiltDefaultTagValues.TagValueDefaults)
            {
                BaseDicomTagValue userDefinedTagValue = _userDefinedDefaultTagValues.Find(inBuiltTagValue.Tag);
                if ((userDefinedTagValue != null) &&
                    (userDefinedTagValue is DicomTagValueDelete))
                {
                    // Do not add this to the list as the default should be deleted
                }
                else if (_defaultDicomTagValues.Find(inBuiltTagValue.Tag) == null)
                {
                    _defaultDicomTagValues.Add(inBuiltTagValue);
                }
            }

            // Now instantiate the default tag value list
            _instantiatedDefaultTagValues = new TagValueCollection();
            foreach(BaseDicomTagValue defaultTagValue in _defaultDicomTagValues)
            {
                // The Value property of defaultTagValue returns the next instantiated value based on the
                // how the default value was defined at setup.
                _instantiatedDefaultTagValues.Add(new DicomTagValue(defaultTagValue.Tag, defaultTagValue.Value));
            }
        }