/// <summary> /// Copy from the given source Dataset into the local Dataset as defined by the /// default Tag Type list. In addition to the base copy we need to copy attributes from the /// Request Attributes Sequence (if present) and the Scheduled Procedure Step (if present). /// </summary> /// <param name="sourceDataset">Source Dataset used to populate the local Dataset.</param> public override void CopyFrom(AttributeSet sourceDataset) { // perform base copy base.CopyFrom(sourceDataset); // check if the Request Attributes Sequence is available in the source dataset DvtkData.Dimse.Attribute requestAttributesSequence = sourceDataset.GetAttribute(Tag.REQUEST_ATTRIBUTES_SEQUENCE); if (requestAttributesSequence != null) { SequenceOfItems sequenceOfItems = (SequenceOfItems)requestAttributesSequence.DicomValue; if (sequenceOfItems.Sequence.Count == 1) { DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0]; // copy item attributes too base.CopyFrom(item); } } // check if the Scheduled Procedure Step Sequence is available in the source dataset DvtkData.Dimse.Attribute scheduledProcedureStepSequence = sourceDataset.GetAttribute(Tag.SCHEDULED_PROCEDURE_STEP_SEQUENCE); if (scheduledProcedureStepSequence != null) { SequenceOfItems sequenceOfItems = (SequenceOfItems)scheduledProcedureStepSequence.DicomValue; if (sequenceOfItems.Sequence.Count == 1) { DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0]; // copy item attributes too base.CopyFrom(item); } } }
/// <summary> /// Check if the given match dataset is found in the local dataset using the default Tag Type list. /// A check is made to see if all the attributes in the given match dataset are present in the local /// dataset. In addition to the base match we need to try to match attributes from the /// Request Attributes Sequence (if present). /// </summary> /// <param name="matchDataset">Match dataset to check.</param> /// <returns>Boolean indicating if the match attributes are present in the local dataset.</returns> public override bool IsFoundIn(AttributeSet matchDataset) { bool isFoundIn = base.IsFoundIn(matchDataset); if (isFoundIn == false) { // check if the Request Attributes Sequence is available in the match dataset DvtkData.Dimse.Attribute requestAttributesSequence = matchDataset.GetAttribute(Tag.REQUEST_ATTRIBUTES_SEQUENCE); if (requestAttributesSequence != null) { SequenceOfItems sequenceOfItems = (SequenceOfItems)requestAttributesSequence.DicomValue; if (sequenceOfItems.Sequence.Count == 1) { // set up a temporary tag list to check the relevant tags in the Request Attributes Sequence TagTypeList itemTagTypeList = new TagTypeList(); itemTagTypeList.Add(new TagType(Tag.REQUESTED_PROCEDURE_ID, TagTypeEnum.TagOptional)); DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0]; // check if found in item isFoundIn = base.IsFoundIn(itemTagTypeList, item); } } } return(isFoundIn); }
/// <summary> /// Initialize the DicomComparator /// </summary> /// <param name="dicomMessage"></param> /// <returns></returns> /// <returns>bool - true = template initialized, false template not initialized</returns> public bool Initialize(DvtkData.Dimse.DicomMessage dicomMessage) { DvtkData.Dimse.DimseCommand command = dicomMessage.CommandField; System.String sopClassUid = System.String.Empty; DvtkData.Dimse.Attribute attribute = dicomMessage.CommandSet.GetAttribute(DvtkData.Dimse.Tag.AFFECTED_SOP_CLASS_UID); if (attribute == null) { attribute = dicomMessage.CommandSet.GetAttribute(DvtkData.Dimse.Tag.REQUESTED_SOP_CLASS_UID); } if ((attribute != null) && (attribute.Length != 0)) { UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue; sopClassUid = uniqueIdentifier.Values[0]; } // Try to initialise a template _template = new DicomComparisonTemplate(); bool initialized = _template.Initialize(command, sopClassUid); if (initialized == true) { // Load the template with the corresponding attribute values initialized = LoadTemplate(dicomMessage.DataSet); } return(initialized); }
/// <summary> /// Set the Default Tag Type List for this Entity. /// </summary> protected override void SetDefaultTagTypeList() { TagTypeList.Add(new TagType(Tag.SPECIFIC_CHARACTER_SET, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.STUDY_DATE, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.STUDY_TIME, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.ACCESSION_NUMBER, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.STUDY_ID, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.STUDY_INSTANCE_UID, TagTypeEnum.TagUnique)); TagTypeList.Add(new TagType(Tag.MODALITIES_IN_STUDY, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.REFERRING_PHYSICIANS_NAME, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.STUDY_DESCRIPTION, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PROCEDURE_CODE_SEQUENCE, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NAME_OF_PHYSICIANS_READING_STUDY, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.ADMITTING_DIAGNOSIS_DESCRIPTION, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.REFERENCED_STUDY_SEQUENCE, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_AGE, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_SIZE, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_WEIGHT, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.OCCUPATION, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.ADDITIONAL_PATIENT_HISTORY, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.OTHER_STUDY_NUMBERS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_STUDY_RELATED_SERIES, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_STUDY_RELATED_INSTANCES, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.INTERPRETATION_AUTHOR, TagTypeEnum.TagOptional)); // Add the Query Retrieve Level Attribute DvtkData.Dimse.Attribute attribute = new DvtkData.Dimse.Attribute(0x00080052, VR.CS, "STUDY"); DataSet.Add(attribute); }
/// <summary> /// Set the Default Tag Type List for this Entity. /// </summary> protected override void SetDefaultTagTypeList() { TagTypeList.Add(new TagType(Tag.SPECIFIC_CHARACTER_SET, VR.CS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.MODALITY, VR.CS, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.SERIES_NUMBER, VR.IS, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.SERIES_INSTANCE_UID, VR.UI, TagTypeEnum.TagUnique)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_SERIES_RELATED_INSTANCES, VR.IS, TagTypeEnum.TagOptional)); // plus all other attributes at a series level! for (int i = 0; i < CustomQueryAttributes.Instance.SeriesList.Count; i++) { TagTypeList.Add(new TagType(new Tag(Convert.ToUInt16(CustomQueryAttributes.Instance.SeriesList[i].group, 16), Convert.ToUInt16(CustomQueryAttributes.Instance.SeriesList[i].element, 16)) , TagTypeEnum.TagOptional)); } // add the specific character set attribute as a conditonal attribute at this level // - used purely to return the correct value in the Specific Character Set attribute of the C-FIND-RSP dataset TagTypeList.Add(new TagType(Tag.SPECIFIC_CHARACTER_SET, VR.CS, TagTypeEnum.TagConditional)); // Add the Query Retrieve Level Attribute DvtkData.Dimse.Attribute attribute = new DvtkData.Dimse.Attribute(0x00080052, VR.CS, "SERIES"); DataSet.Add(attribute); }
/// <summary> /// Set the Default Tag Type List for this Entity. /// </summary> protected override void SetDefaultTagTypeList() { TagTypeList.Add(new TagType(Tag.SPECIFIC_CHARACTER_SET, VR.CS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_NAME, VR.PN, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.PATIENT_ID, VR.LO, TagTypeEnum.TagUnique)); TagTypeList.Add(new TagType(Tag.ISSUER_OF_PATIENT_ID, VR.LO, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.REFERENCED_PATIENT_SEQUENCE, VR.SQ, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_BIRTH_DATE, VR.DA, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_BIRTH_TIME, VR.TM, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_SEX, VR.CS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.OTHER_PATIENT_IDS, VR.LO, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.OTHER_PATIENT_NAMES, VR.PN, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.ETHNIC_GROUP, VR.SH, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENT_COMMENTS, VR.LT, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_PATIENT_RELATED_STUDIES, VR.IS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_PATIENT_RELATED_SERIES, VR.IS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_PATIENT_RELATED_INSTANCES, VR.IS, TagTypeEnum.TagOptional)); for (int i = 0; i < CustomQueryAttributes.Instance.PatientList.Count; i++) { TagTypeList.Add(new TagType(new Tag(Convert.ToUInt16(CustomQueryAttributes.Instance.PatientList[i].group, 16), Convert.ToUInt16(CustomQueryAttributes.Instance.PatientList[i].element, 16)) , TagTypeEnum.TagOptional)); } // add the specific character set attribute as a conditonal attribute at this level // - used purely to return the correct value in the Specific Character Set attribute of the C-FIND-RSP dataset TagTypeList.Add(new TagType(Tag.SPECIFIC_CHARACTER_SET, VR.CS, TagTypeEnum.TagConditional)); // Add the Query Retrieve Level Attribute DvtkData.Dimse.Attribute attribute = new DvtkData.Dimse.Attribute(0x00080052, VR.CS, "PATIENT"); DataSet.Add(attribute); }
/// <summary> /// Set the Default Tag Type List for this Entity. /// </summary> protected override void SetDefaultTagTypeList() { TagTypeList.Add(new TagType(Tag.SPECIFIC_CHARACTER_SET, VR.CS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.INSTANCE_NUMBER, VR.IS, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.OVERLAY_NUMBER, VR.IS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.CURVE_NUMBER, VR.IS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.LUT_NUMBER, VR.IS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.SOP_INSTANCE_UID, VR.UI, TagTypeEnum.TagUnique)); // plus all other attributes at an instance level! TagTypeList.Add(new TagType(Tag.SOP_CLASS_UID, VR.UI, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(new Tag(0x0008, 0x001A), VR.UI, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.ROWS, VR.US, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.COLUMNS, VR.US, TagTypeEnum.TagOptional)); for (int i = 0; i < CustomQueryAttributes.Instance.InstanceList.Count; i++) { TagTypeList.Add(new TagType(new Tag(Convert.ToUInt16(CustomQueryAttributes.Instance.InstanceList[i].group, 16), Convert.ToUInt16(CustomQueryAttributes.Instance.InstanceList[i].element, 16)) , TagTypeEnum.TagOptional)); } // add the specific character set attribute as a conditonal attribute at this level // - used purely to return the correct value in the Specific Character Set attribute of the C-FIND-RSP dataset TagTypeList.Add(new TagType(Tag.SPECIFIC_CHARACTER_SET, VR.CS, TagTypeEnum.TagConditional)); // Add the Query Retrieve Level Attribute DvtkData.Dimse.Attribute attribute = new DvtkData.Dimse.Attribute(0x00080052, VR.CS, "IMAGE"); DataSet.Add(attribute); }
public bool SetUp(DvtkData.Dimse.DicomMessage dicomMessage) { DvtkData.Dimse.DimseCommand command = dicomMessage.CommandField; System.String sopClassUid = System.String.Empty; // To be fixed - why is the SOP Class UID not always filled in? // RB: TODO if (command == DvtkData.Dimse.DimseCommand.CSTORERQ) { sopClassUid = "1.2.840.10008.5.1.4.1.1.7"; } DvtkData.Dimse.Attribute attribute = dicomMessage.CommandSet.GetAttribute(DvtkData.Dimse.Tag.AFFECTED_SOP_CLASS_UID); if (attribute == null) { attribute = dicomMessage.CommandSet.GetAttribute(DvtkData.Dimse.Tag.REQUESTED_SOP_CLASS_UID); } if ((attribute != null) && (attribute.Length != 0)) { UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue; sopClassUid = uniqueIdentifier.Values[0]; } // Try to initialise a template _template = new DicomComparisonTemplate(); bool setUpDone = _template.Initialize(command, sopClassUid); return(setUpDone); }
/// <summary> /// Patient merge request - update modality worklist information model. /// </summary> /// <param name="dataset">Dataset containing patient merge attributes.</param> public override void PatientMerge(DvtkData.Dimse.DataSet dataset) { // Get the merge patient - need to use this to search for the corresponding patient IE DvtkData.Dimse.Attribute mergePatientId = dataset.GetAttribute(Tag.OTHER_PATIENT_IDS); if (mergePatientId.Length != 0) { LongString longString = (LongString)mergePatientId.DicomValue; System.String attributeValue = longString.Values[0]; DataSet queryDataset = new DataSet("Transient"); queryDataset.AddAttribute(Tag.PATIENT_ID.GroupNumber, Tag.PATIENT_ID.ElementNumber, VR.LO, attributeValue); // check each patient IE in the patientRootList foreach (PatientInformationEntity lPatientInformationEntity in Root) { // if IE matches the unique (merge) patient id field in the query dataset if (lPatientInformationEntity.IsUniqueTagFoundIn(queryDataset)) { // update the patient demographics - including the patient id lPatientInformationEntity.CopyFrom(dataset); break; } } } }
/// <summary> /// Retrieve a list of filenames from the Information Model. The filenames match the /// individual instances matching the retrieve dataset attributes. /// </summary> /// <param name="retrieveDataset">Retrive dataset.</param> /// <returns>File list - containing the filenames of all instances matching the retrieve dataset attributes.</returns> public DvtkData.Collections.StringCollection RetrieveInformationModel(DataSet retrieveDataset) { DvtkData.Collections.StringCollection fileList = new DvtkData.Collections.StringCollection(); // get the query/retrieve level String queryRetrieveLevel = "UNKNOWN"; DvtkData.Dimse.Attribute queryRetrieveLevelAttribute = retrieveDataset.GetAttribute(Tag.QUERY_RETRIEVE_LEVEL); if (queryRetrieveLevelAttribute != null) { CodeString codeString = (CodeString)queryRetrieveLevelAttribute.DicomValue; if (codeString.Values.Count == 1) { queryRetrieveLevel = codeString.Values[0].Trim(); } } // find the matching PATIENT PatientInformationEntity patientInformationEntity = null; foreach (PatientInformationEntity lPatientInformationEntity in Root) { if (lPatientInformationEntity.IsUniqueTagFoundIn(retrieveDataset)) { patientInformationEntity = lPatientInformationEntity; break; } } if (patientInformationEntity != null) { // retrieve at the PATIENT level if (queryRetrieveLevel == "PATIENT") { fileList = patientInformationEntity.FileNames; } else { // find the matching STUDY BaseInformationEntityList studyInformationEntities = patientInformationEntity.ChildrenWithUniqueTagFoundIn(retrieveDataset); // retrieve at the STUDY level if ((studyInformationEntities.Count > 0) && (queryRetrieveLevel == "STUDY")) { foreach (StudyInformationEntity studyInformationEntity in studyInformationEntities) { foreach (String fileName in studyInformationEntity.FileNames) { fileList.Add(fileName); } } } } } return(fileList); }
// // - Methods - // /// <summary> /// Get the HLI Attribute, given a DvtkData attribute. /// </summary> /// <param name="tagSequence">The tag sequence (one or more tags seperated with an '/') of this attribue.</param> /// <param name="dvtkDataAttribute">The DvtkData attribute.</param> /// <returns>The HLI Attribute.</returns> public static Attribute GetAttribute(String tagSequence, DvtkData.Dimse.Attribute dvtkDataAttribute) { Attribute attribute = null; switch (dvtkDataAttribute.ValueRepresentation) { // These cases handles the "simple" attributes. case VR.AE: // Application Entity case VR.AS: // Age String case VR.AT: // Attribute Tag case VR.CS: // Code String case VR.DA: // Date case VR.DS: // Decimal String case VR.DT: // Date Time case VR.FL: // Floating Point Single case VR.FD: // Floating Point Double case VR.IS: // Integer String case VR.LO: // Long String case VR.LT: // Long Text case VR.PN: // Person Name case VR.SH: // Short String case VR.SL: // Signed Long case VR.SS: // Signed Short case VR.ST: // Short Text case VR.TM: // Time case VR.UI: // Unique Identifier (UID) case VR.UL: // Unsigned Long case VR.US: // Unsigned Short case VR.UT: // Unlimited Text attribute = new SimpleAttribute(tagSequence, dvtkDataAttribute); break; // These cases handles the pixel data attributes. case VR.OB: // Other Byte String case VR.OF: // Other Float String case VR.OW: // Other Word String attribute = new PixelDataAttribute(tagSequence, dvtkDataAttribute); break; // This case handles the sequence attributes. case VR.SQ: // Sequence of Items attribute = new SequenceAttribute(tagSequence, dvtkDataAttribute); break; // This case handles the unknown attributes. case VR.UN: // Unknown attribute = new UnknownAttribute(tagSequence, dvtkDataAttribute); break; default: attribute = null; break; } return(attribute); }
/// <summary> /// Compare two pixel attributes (i.e. attributes that have VR OB, OF or OW). /// </summary> /// <param name="attribute1">The first attribute.</param> /// <param name="attribute2">The second attribute.</param> /// <returns>Indicates if the two are equal or not.</returns> public static bool ComparePixelAttributes( DvtkData.Dimse.Attribute attribute1, DvtkData.Dimse.Attribute attribute2) { bool equal = true; equal = MAttributeUtilities.ComparePixelAttributes(attribute1, attribute2); return(equal); }
/// <summary> /// Set the Default Tag Type List for this Entity. /// </summary> protected override void SetDefaultTagTypeList() { TagTypeList.Add(new TagType(Tag.SPECIFIC_CHARACTER_SET, VR.CS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.STUDY_DATE, VR.DA, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.STUDY_TIME, VR.TM, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.ACCESSION_NUMBER, VR.SH, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.PATIENTS_NAME, VR.PN, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.PATIENT_ID, VR.LO, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.STUDY_ID, VR.SH, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.STUDY_INSTANCE_UID, VR.UI, TagTypeEnum.TagUnique)); TagTypeList.Add(new TagType(Tag.MODALITIES_IN_STUDY, VR.CS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.REFERRING_PHYSICIANS_NAME, VR.PN, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.STUDY_DESCRIPTION, VR.LO, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PROCEDURE_CODE_SEQUENCE, VR.SQ, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NAME_OF_PHYSICIANS_READING_STUDY, VR.PN, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.ADMITTING_DIAGNOSIS_DESCRIPTION, VR.LO, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.REFERENCED_STUDY_SEQUENCE, VR.SQ, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.REFERENCED_PATIENT_SEQUENCE, VR.SQ, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_BIRTH_DATE, VR.DA, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_BIRTH_TIME, VR.TM, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_SEX, VR.CS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.OTHER_PATIENT_IDS, VR.LO, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.OTHER_PATIENT_NAMES, VR.PN, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_AGE, VR.AS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_SIZE, VR.DS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_WEIGHT, VR.DS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.ETHNIC_GROUP, VR.SH, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.OCCUPATION, VR.SH, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.ADDITIONAL_PATIENT_HISTORY, VR.LT, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENT_COMMENTS, VR.LT, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.OTHER_STUDY_NUMBERS, VR.IS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_PATIENT_RELATED_STUDIES, VR.IS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_PATIENT_RELATED_SERIES, VR.IS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_PATIENT_RELATED_INSTANCES, VR.IS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_STUDY_RELATED_SERIES, VR.IS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_STUDY_RELATED_INSTANCES, VR.IS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.INTERPRETATION_AUTHOR, VR.PN, TagTypeEnum.TagOptional)); for (int i = 0; i < CustomQueryAttributes.Instance.PatientStudyList.Count; i++) { TagTypeList.Add(new TagType(new Tag(Convert.ToUInt16(CustomQueryAttributes.Instance.PatientStudyList[i].group, 16), Convert.ToUInt16(CustomQueryAttributes.Instance.PatientStudyList[i].element, 16)) , TagTypeEnum.TagOptional)); } // add the specific character set attribute as a conditonal attribute at this level // - used purely to return the correct value in the Specific Character Set attribute of the C-FIND-RSP dataset TagTypeList.Add(new TagType(Tag.SPECIFIC_CHARACTER_SET, VR.CS, TagTypeEnum.TagConditional)); // Add the Query Retrieve Level Attribute DvtkData.Dimse.Attribute attribute = new DvtkData.Dimse.Attribute(0x00080052, VR.CS, "STUDY"); DataSet.Add(attribute); }
/// <summary> /// Set the Default Tag Type List for this Entity. /// </summary> protected override void SetDefaultTagTypeList() { TagTypeList.Add(new TagType(Tag.SPECIFIC_CHARACTER_SET, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.MODALITY, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.SERIES_NUMBER, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.SERIES_INSTANCE_UID, TagTypeEnum.TagUnique)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_SERIES_RELATED_INSTANCES, TagTypeEnum.TagOptional)); // plus all other attributes at a series level! // Add the Query Retrieve Level Attribute DvtkData.Dimse.Attribute attribute = new DvtkData.Dimse.Attribute(0x00080052, VR.CS, "SERIES"); DataSet.Add(attribute); }
// // - Constructors - // /// <summary> /// Constructor. /// </summary> /// <param name="tagSequence">The tag sequence (one or more tags seperated with an '/') of this attribue.</param> /// <param name="attribute"> /// The encapsulated Attribute from the DvtkData librbary. /// May not be null. /// </param> public Attribute(String tagSequence, DvtkData.Dimse.Attribute dvtkDataAttribute) { this.tagSequence = tagSequence; if (dvtkDataAttribute == null) { // Sanity check. DvtkHighLevelInterfaceException.Throw("Parameter may not be null."); } else { this.dvtkDataAttribute = dvtkDataAttribute; } }
private bool LoadTemplate(DvtkData.Dimse.DataSet dataset) { if (dataset == null) { return(false); } // try to find the template tag in the dataset foreach (DicomComparisonTag comparisonTag in this._template.ComparisonTags) { DvtkData.Dimse.Tag tag = comparisonTag.Tag; DvtkData.Dimse.Tag parentSequenceTag = comparisonTag.ParentSequenceTag; System.String attributeValue = System.String.Empty; if (parentSequenceTag != Tag.UNDEFINED) { DvtkData.Dimse.Attribute sequenceAttribute = dataset.GetAttribute(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) { DvtkData.Dimse.Attribute attribute = item.GetAttribute(tag); attributeValue = GetAttributeValue(attribute); } } } } else { DvtkData.Dimse.Attribute attribute = dataset.GetAttribute(tag); attributeValue = GetAttributeValue(attribute); } if (attributeValue != System.String.Empty) { comparisonTag.DataFormat.FromDicomFormat(attributeValue); } } return(true); }
/// <summary> /// Set the Default Tag Type List for this Entity. /// </summary> protected override void SetDefaultTagTypeList() { TagTypeList.Add(new TagType(Tag.SPECIFIC_CHARACTER_SET, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.INSTANCE_NUMBER, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.OVERLAY_NUMBER, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.CURVE_NUMBER, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.LUT_NUMBER, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.SOP_INSTANCE_UID, TagTypeEnum.TagUnique)); // plus all other attributes at an instance level! TagTypeList.Add(new TagType(Tag.SOP_CLASS_UID, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.ROWS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.COLUMNS, TagTypeEnum.TagOptional)); // Add the Query Retrieve Level Attribute DvtkData.Dimse.Attribute attribute = new DvtkData.Dimse.Attribute(0x00080052, VR.CS, "IMAGE"); DataSet.Add(attribute); }
/// <summary> /// Set the Default Tag Type List for this Entity. /// </summary> protected override void SetDefaultTagTypeList() { TagTypeList.Add(new TagType(Tag.SPECIFIC_CHARACTER_SET, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_NAME, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.PATIENT_ID, TagTypeEnum.TagUnique)); TagTypeList.Add(new TagType(Tag.REFERENCED_PATIENT_SEQUENCE, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_BIRTH_DATE, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_BIRTH_TIME, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_SEX, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.OTHER_PATIENT_IDS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.OTHER_PATIENT_NAMES, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.ETHNIC_GROUP, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENT_COMMENTS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_PATIENT_RELATED_STUDIES, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_PATIENT_RELATED_SERIES, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_PATIENT_RELATED_INSTANCES, TagTypeEnum.TagOptional)); // Add the Query Retrieve Level Attribute DvtkData.Dimse.Attribute attribute = new DvtkData.Dimse.Attribute(0x00080052, VR.CS, "PATIENT"); DataSet.Add(attribute); }
/// <summary> /// Create a Worklist Query Dataset from the given DCM file. We assume that the DCM file /// contains the appropriate MWL Query Dataset. If the scheduled procedure step start date /// is present in the DCM file, it will be overwritten with the value given by scheduledProcedureStepStartDate. /// </summary> /// <param name="mwlQueryDcmFilename">MWL Query Dcm Filename.</param> /// <param name="userDefinedScheduledProcedureStepStartDate">User Defined Scheduled Procedure Step Start Date.</param> /// <returns>DvtkData.Dimse.DataSet - Modality Worklist Query Dataset.</returns> public static DvtkData.Dimse.DataSet CreateWorklistQueryDataset(System.String mwlQueryDcmFilename, System.String userDefinedScheduledProcedureStepStartDate) { // Read the DCM file DataSet dataset = Dvtk.DvtkDataHelper.ReadDataSetFromFile(mwlQueryDcmFilename); dataset.IodId = "Modality Worklist Information Model - FIND SOP Class"; // Update the scheduled procedure step start date (if present) if (userDefinedScheduledProcedureStepStartDate != System.String.Empty) { DvtkData.Dimse.Attribute scheduledProcedureStepSequence = dataset.GetAttribute(Tag.SCHEDULED_PROCEDURE_STEP_SEQUENCE); if (scheduledProcedureStepSequence != null) { SequenceOfItems sequenceOfItems = (SequenceOfItems)scheduledProcedureStepSequence.DicomValue; if (sequenceOfItems.Sequence.Count == 1) { SequenceItem queryItem = sequenceOfItems.Sequence[0]; // Try to get the Scheduled Procedure Step Start Date // - update it if there is a value defined in the dataset DvtkData.Dimse.Attribute scheduledProcedureStepStartDate = queryItem.GetAttribute(Tag.SCHEDULED_PROCEDURE_STEP_START_DATE); if ((scheduledProcedureStepStartDate != null) && (scheduledProcedureStepStartDate.Length != 0)) { // Remove the existing attribute queryItem.Remove(scheduledProcedureStepStartDate); // Modify value to today's date queryItem.AddAttribute(Tag.SCHEDULED_PROCEDURE_STEP_START_DATE.GroupNumber, Tag.SCHEDULED_PROCEDURE_STEP_START_DATE.ElementNumber, DvtkData.Dimse.VR.DA, userDefinedScheduledProcedureStepStartDate); } } } } return(dataset); }
/// <summary> /// Checks the SQ item having value or not /// </summary> /// <param name="items"></param> /// <returns></returns> internal bool IsSequenceHavingValue(SequenceItem items) { for (int i = 0; i < items.Count; i++) { DvtkData.Dimse.Attribute attrib = items[i]; if (attrib.ValueRepresentation == VR.SQ) { foreach (SequenceItem s in ((SequenceOfItems)attrib.DicomValue).Sequence) { if (IsSequenceHavingValue(s)) { return(true); } } } else if ((attrib.Length != 0) && (attrib.Tag.ElementNumber != 0x0000)) { return(true); } } return(false); }
/// <summary> /// Check if the given instance is present in the Information Model. The instance will be at the leaf nodes of the Information Model. /// </summary> /// <param name="sopClassUid">SOP Class UID to search for.</param> /// <param name="sopInstanceUid">SOP Instance UID to search for.</param> /// <returns>Boolean - true if instance found in the Information Model, otherwise false.</returns> public bool IsInstanceInInformationModel(System.String sopClassUid, System.String sopInstanceUid) { bool isInstanceInInformationModel = false; // set up the commit tag list for comparing with the leaf TagTypeList commitTagTypeList = new TagTypeList(); commitTagTypeList.Add(new TagType(Tag.SOP_INSTANCE_UID, TagTypeEnum.TagRequired)); commitTagTypeList.Add(new TagType(Tag.SOP_CLASS_UID, TagTypeEnum.TagRequired)); // set up the commit dataset DvtkData.Dimse.DataSet commitDataset = new DvtkData.Dimse.DataSet(); DvtkData.Dimse.Attribute attribute = new DvtkData.Dimse.Attribute(0x00080016, DvtkData.Dimse.VR.UI, sopClassUid); commitDataset.Add(attribute); attribute = new DvtkData.Dimse.Attribute(0x00080018, DvtkData.Dimse.VR.UI, sopInstanceUid); commitDataset.Add(attribute); // iterate over the whole information model - we are interested in the leaf nodes foreach (PatientInformationEntity patientInformationEntity in Root) { foreach (StudyInformationEntity studyInformationEntity in patientInformationEntity.Children) { foreach (SeriesInformationEntity seriesInformationEntity in studyInformationEntity.Children) { foreach (InstanceInformationEntity instanceInformationEntity in seriesInformationEntity.Children) { if (instanceInformationEntity.IsFoundIn(commitTagTypeList, commitDataset)) { // an instance has been found with the matching commit uids isInstanceInInformationModel = true; break; } } } } } return(isInstanceInInformationModel); }
/// <summary> /// Copy the default dataset attributes to the Information Entities in the Information /// Model that define them. Do not overrule any attribute with the same tag as the default /// attribute that may already be in the Information Entity. /// </summary> /// <param name="defaultDataset">Dataset containing all the default values.</param> public void AddDefaultAttributesToInformationModel(DataSet defaultDataset) { if (defaultDataset == null) { return; } // iterate of all Information Entities foreach (BaseInformationEntity baseInformationEntity in Root) { baseInformationEntity.AddDefaultAttributes(defaultDataset); } // save these default attributes - in case of refresh foreach (DvtkData.Dimse.Attribute defaultAttribute in defaultDataset) { DvtkData.Dimse.Attribute lDefaultAttribute = _defaultDataset.GetAttribute(defaultAttribute.Tag); if (lDefaultAttribute == null) { _defaultDataset.Add(defaultAttribute); } } }
/// <summary> /// Add the attributes in this additional dataset to all Information Entities in the Information /// Model. Do not overrule any attribute with the same tag as the additional attribute that may /// already be in the Information Entity. /// </summary> /// <param name="additionalDataset">Dataset containing the additional values.</param> public void AddAdditionalAttributesToInformationModel(DataSet additionalDataset) { if (additionalDataset == null) { return; } // iterate of all Information Entities foreach (BaseInformationEntity baseInformationEntity in Root) { baseInformationEntity.AddAdditionalAttributes(additionalDataset); } // save these additional attributes - in case of refresh foreach (DvtkData.Dimse.Attribute additionalAttribute in additionalDataset) { DvtkData.Dimse.Attribute lAdditionalAttribute = _additionalDataset.GetAttribute(additionalAttribute.Tag); if (lAdditionalAttribute == null) { _additionalDataset.Add(additionalAttribute); } } }
///// <summary> ///// Store the dataset into a DICOM Media File in the current Information Model directory. ///// The file contents might be later used for retrieval. ///// </summary> ///// <param name="dataset">DICOM Dataset to store.</param> //protected void StoreDataset(DataSet dataset) //{ // System.String iom = System.String.Empty; // if (_name.Equals("PatientRootInformationModel")) // { // iom = "PR"; // } // else if (_name.Equals("StudyRootInformationModel")) // { // iom = "SR"; // } // else if (_name.Equals("PatientStudyOnlyInformationModel")) // { // iom = "PS"; // } // // generate a filename // System.String filename; // filename = System.String.Format("{0}\\DVTK_IOM_TMP_{1}_{2:00000000}.DCM", _dataDirectory, iom, _fileIndex++); // DvtkData.Media.DicomFile dicomMediaFile = new DvtkData.Media.DicomFile(); // // set up the file head // DvtkData.Media.FileHead fileHead = new DvtkData.Media.FileHead(); // // add the Transfer Syntax UID // DvtkData.Dul.TransferSyntax transferSyntax = new DvtkData.Dul.TransferSyntax(DvtkData.Dul.TransferSyntax.Explicit_VR_Little_Endian.UID); // fileHead.TransferSyntax = transferSyntax; // // set up the file meta information // DvtkData.Media.FileMetaInformation fileMetaInformation = new DvtkData.Media.FileMetaInformation(); // // add the FMI version // fileMetaInformation.AddAttribute(Tag.FILE_META_INFORMATION_VERSION.GroupNumber, // Tag.FILE_META_INFORMATION_VERSION.ElementNumber, VR.OB, 1, 2); // // add the SOP Class UID // System.String sopClassUid = ""; // DvtkData.Dimse.Attribute attribute = dataset.GetAttribute(DvtkData.Dimse.Tag.SOP_CLASS_UID); // if (attribute != null) // { // UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue; // if (uniqueIdentifier.Values.Count > 0) // { // sopClassUid = uniqueIdentifier.Values[0]; // } // } // fileMetaInformation.AddAttribute(Tag.MEDIA_STORAGE_SOP_CLASS_UID.GroupNumber, // Tag.MEDIA_STORAGE_SOP_CLASS_UID.ElementNumber, VR.UI, sopClassUid); // // add the SOP Instance UID // System.String sopInstanceUid = ""; // attribute = dataset.GetAttribute(DvtkData.Dimse.Tag.SOP_INSTANCE_UID); // if (attribute != null) // { // UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue; // if (uniqueIdentifier.Values.Count > 0) // { // sopInstanceUid = uniqueIdentifier.Values[0]; // } // } // fileMetaInformation.AddAttribute(Tag.MEDIA_STORAGE_SOP_INSTANCE_UID.GroupNumber, // Tag.MEDIA_STORAGE_SOP_INSTANCE_UID.ElementNumber, VR.UI, sopInstanceUid); // // add the Transfer Syntax UID // fileMetaInformation.AddAttribute(Tag.TRANSFER_SYNTAX_UID.GroupNumber, // Tag.TRANSFER_SYNTAX_UID.ElementNumber, VR.UI, DvtkData.Dul.TransferSyntax.Explicit_VR_Little_Endian.UID); // // add the Implemenation Class UID // fileMetaInformation.AddAttribute(Tag.IMPLEMENTATION_CLASS_UID.GroupNumber, // Tag.IMPLEMENTATION_CLASS_UID.ElementNumber, VR.UI, "1.2.826.0.1.3680043.2.1545.1.2.1.7"); // // add the Implementation Version Name // fileMetaInformation.AddAttribute(Tag.IMPLEMENTATION_VERSION_NAME.GroupNumber, // Tag.IMPLEMENTATION_VERSION_NAME.ElementNumber, VR.SH, "dvt2.1"); // // set up the dicomMediaFile contents // dicomMediaFile.FileHead = fileHead; // dicomMediaFile.FileMetaInformation = fileMetaInformation; // dicomMediaFile.DataSet = dataset; // // write the dicomMediaFile to file // Dvtk.DvtkDataHelper.WriteDataSetToFile(dicomMediaFile, filename); // // save the filename in the dataset // dataset.Filename = filename; //} /// <summary> /// Copy the default dataset attributes to the Information Entities in the Information /// Model that define them. /// </summary> /// <param name="overWriteExistingValue">Boolean to indicate whether any already existing value should be overwritten or not.</param> /// <param name="defaultDataset">Dataset containing all the default values.</param> public void AddDefaultAttributesToInformationModel(bool overWriteExistingValue, DataSet defaultDataset) { if (defaultDataset == null) { return; } // iterate of all Information Entities foreach (BaseInformationEntity baseInformationEntity in Root) { baseInformationEntity.AddDefaultAttributes(overWriteExistingValue, defaultDataset); } // save these default attributes - in case of refresh if (overWriteExistingValue == true) { foreach (DvtkData.Dimse.Attribute defaultAttribute in defaultDataset) { DvtkData.Dimse.Attribute lDefaultAttribute = _defaultDatasetOverWrite.GetAttribute(defaultAttribute.Tag); if (lDefaultAttribute == null) { _defaultDatasetOverWrite.Add(defaultAttribute); } } } else { foreach (DvtkData.Dimse.Attribute defaultAttribute in defaultDataset) { DvtkData.Dimse.Attribute lDefaultAttribute = _defaultDatasetNoOverWrite.GetAttribute(defaultAttribute.Tag); if (lDefaultAttribute == null) { _defaultDatasetNoOverWrite.Add(defaultAttribute); } } } }
/// <summary> /// Add the attributes in this additional dataset to all Information Entities in the Information /// Model. /// </summary> /// <param name="overWriteExistingValue">Boolean to indicate whether any already existing value should be overwritten or not.</param> /// <param name="additionalDataset">Dataset containing the additional values.</param> public void AddAdditionalAttributesToInformationModel(bool overWriteExistingValue, DataSet additionalDataset) { if (additionalDataset == null) { return; } // iterate of all Information Entities foreach (BaseInformationEntity baseInformationEntity in Root) { baseInformationEntity.AddAdditionalAttributes(overWriteExistingValue, additionalDataset); } // save these additional attributes - in case of refresh if (overWriteExistingValue == true) { foreach (DvtkData.Dimse.Attribute additionalAttribute in additionalDataset) { DvtkData.Dimse.Attribute lAdditionalAttribute = _additionalDatasetOverWrite.GetAttribute(additionalAttribute.Tag); if (lAdditionalAttribute == null) { _additionalDatasetOverWrite.Add(additionalAttribute); } } } else { foreach (DvtkData.Dimse.Attribute additionalAttribute in additionalDataset) { DvtkData.Dimse.Attribute lAdditionalAttribute = _additionalDatasetNoOverWrite.GetAttribute(additionalAttribute.Tag); if (lAdditionalAttribute == null) { _additionalDatasetNoOverWrite.Add(additionalAttribute); } } } }
/// <summary> /// Cretae a storage commitment event. /// </summary> /// <param name="informationModels">The information models.</param> /// <param name="actionMessage">The action message.</param> /// <returns>The created event.</returns> public static DvtkHighLevelInterface.Dicom.Messages.DicomMessage MakeStorageCommitEvent(QueryRetrieveInformationModels informationModels, DvtkHighLevelInterface.Dicom.Messages.DicomMessage actionMessage) { // refresh the information models informationModels.Refresh(); DvtkHighLevelInterface.Dicom.Messages.DicomMessage eventMessage = new DvtkHighLevelInterface.Dicom.Messages.DicomMessage(DvtkData.Dimse.DimseCommand.NEVENTREPORTRQ); eventMessage.Set("0x00000002", VR.UI, "1.2.840.10008.1.20.1"); eventMessage.Set("0x00001000", VR.UI, "1.2.840.10008.1.20.1.1"); DvtkData.Dimse.DataSet actionDataset = actionMessage.DataSet.DvtkDataDataSet; DvtkData.Dimse.DataSet eventDataset = new DvtkData.Dimse.DataSet(); DvtkData.Dimse.Attribute eventReferenceSopSequence = new DvtkData.Dimse.Attribute(0x00081199, DvtkData.Dimse.VR.SQ); SequenceOfItems eventReferenceSopSequenceOfItems = new SequenceOfItems(); eventReferenceSopSequence.DicomValue = eventReferenceSopSequenceOfItems; DvtkData.Dimse.Attribute eventFailedSopSequence = new DvtkData.Dimse.Attribute(0x00081198, DvtkData.Dimse.VR.SQ); SequenceOfItems eventFailedSopSequenceOfItems = new SequenceOfItems(); eventFailedSopSequence.DicomValue = eventFailedSopSequenceOfItems; if (actionDataset != null) { DvtkData.Dimse.Attribute transactionUid = actionDataset.GetAttribute(DvtkData.Dimse.Tag.TRANSACTION_UID); if (transactionUid != null) { eventDataset.Add(transactionUid); } DvtkData.Dimse.Attribute referencedSopSequence = actionDataset.GetAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_SEQUENCE); if (referencedSopSequence != null) { SequenceOfItems sequenceOfItems = (SequenceOfItems)referencedSopSequence.DicomValue; foreach(DvtkData.Dimse.SequenceItem item in sequenceOfItems.Sequence) { System.String sopClassUid = ""; System.String sopInstanceUid = ""; DvtkData.Dimse.Attribute attribute = item.GetAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID); if (attribute != null) { UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue; if (uniqueIdentifier.Values.Count > 0) { sopClassUid = uniqueIdentifier.Values[0]; } } attribute = item.GetAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID); if (attribute != null) { UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue; if (uniqueIdentifier.Values.Count > 0) { sopInstanceUid = uniqueIdentifier.Values[0]; } } if (informationModels.PatientRoot.IsInstanceInInformationModel(sopClassUid, sopInstanceUid)) { DvtkData.Dimse.SequenceItem itemOk = new DvtkData.Dimse.SequenceItem(); itemOk.AddAttribute(0x00081150, DvtkData.Dimse.VR.UI, sopClassUid); itemOk.AddAttribute(0x00081155, DvtkData.Dimse.VR.UI, sopInstanceUid); // add instance to committed list eventReferenceSopSequenceOfItems.Sequence.Add(itemOk); } else { DvtkData.Dimse.SequenceItem itemNotOk = new DvtkData.Dimse.SequenceItem(); itemNotOk.AddAttribute(0x00081150, DvtkData.Dimse.VR.UI, sopClassUid); itemNotOk.AddAttribute(0x00081155, DvtkData.Dimse.VR.UI, sopInstanceUid); itemNotOk.AddAttribute(0x00081197, DvtkData.Dimse.VR.US, 0x0110); // add instance to failed list eventFailedSopSequenceOfItems.Sequence.Add(itemNotOk); } } } if (eventReferenceSopSequenceOfItems.Sequence.Count > 0) { eventMessage.Set("0x00001002", VR.US, 1); eventDataset.Add(eventReferenceSopSequence); } if (eventFailedSopSequenceOfItems.Sequence.Count > 0) { eventMessage.Set("0x00001002", VR.US, 2); eventDataset.Add(eventFailedSopSequence); } } eventMessage.DataSet.DvtkDataDataSet = eventDataset; return eventMessage; }
/// <summary> /// Set the Default Tag Type List for this Entity. /// </summary> protected override void SetDefaultTagTypeList() { TagTypeList.Add(new TagType(Tag.SPECIFIC_CHARACTER_SET, VR.CS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.INSTANCE_NUMBER, VR.IS, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.OVERLAY_NUMBER, VR.IS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.CURVE_NUMBER, VR.IS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.LUT_NUMBER, VR.IS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.SOP_INSTANCE_UID, VR.UI, TagTypeEnum.TagUnique)); // plus all other attributes at an instance level! TagTypeList.Add(new TagType(Tag.SOP_CLASS_UID, VR.UI, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(new Tag(0x0008,0x001A), VR.UI, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.ROWS, VR.US, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.COLUMNS, VR.US, TagTypeEnum.TagOptional)); for (int i = 0; i < CustomQueryAttributes.Instance.InstanceList.Count; i++) TagTypeList.Add(new TagType(new Tag(Convert.ToUInt16(CustomQueryAttributes.Instance.InstanceList[i].group, 16), Convert.ToUInt16(CustomQueryAttributes.Instance.InstanceList[i].element, 16)) , TagTypeEnum.TagOptional)); // add the specific character set attribute as a conditonal attribute at this level // - used purely to return the correct value in the Specific Character Set attribute of the C-FIND-RSP dataset TagTypeList.Add(new TagType(Tag.SPECIFIC_CHARACTER_SET, VR.CS, TagTypeEnum.TagConditional)); // Add the Query Retrieve Level Attribute DvtkData.Dimse.Attribute attribute = new DvtkData.Dimse.Attribute(0x00080052, VR.CS, "IMAGE"); DataSet.Add(attribute); }
/// <summary> /// This static function returns the Re-Construted value of the particular Dicom attribute. /// </summary> /// <param name="attribute">Dicom attribute contains tag vr and value</param> /// <returns>Returns the value of the Dicom attribute</returns> public static String GetDicomValue(DvtkData.Dimse.Attribute attribute) { String dumpString = ""; if (attribute != null && attribute.Length != 0) { switch (attribute.ValueRepresentation) { case VR.AE: { ApplicationEntity applicationEntity = (ApplicationEntity)attribute.DicomValue; dumpString += String.Format("{0}", GetValues(applicationEntity.Values)); break; } case VR.AS: { AgeString ageString = (AgeString)attribute.DicomValue; dumpString += String.Format("{0}", GetValues(ageString.Values)); break; } case VR.AT: { AttributeTag attributeTag = (AttributeTag)attribute.DicomValue; Console.WriteLine("{0}", GetValues(attributeTag.Values)); break; } case VR.CS: { CodeString codeString = (CodeString)attribute.DicomValue; dumpString += String.Format("{0}", GetValues(codeString.Values)); break; } case VR.DA: { Date date = (Date)attribute.DicomValue; dumpString += String.Format("{0}", GetValues(date.Values)); break; } case VR.DS: { DecimalString decimalString = (DecimalString)attribute.DicomValue; dumpString += String.Format("{0}", GetValues(decimalString.Values)); break; } case VR.DT: { DvtkData.Dimse.DateTime dateTime = (DvtkData.Dimse.DateTime)attribute.DicomValue; dumpString += String.Format("{0}", GetValues(dateTime.Values)); break; } case VR.FD: { FloatingPointDouble floatingPointDouble = (FloatingPointDouble)attribute.DicomValue; dumpString += String.Format("{0}", GetValues(floatingPointDouble.Values)); break; } case VR.FL: { FloatingPointSingle floatingPointSingle = (FloatingPointSingle)attribute.DicomValue; dumpString += String.Format("{0}", GetValues(floatingPointSingle.Values)); break; } case VR.IS: { IntegerString integerString = (IntegerString)attribute.DicomValue; dumpString += String.Format("{0}", GetValues(integerString.Values)); break; } case VR.LO: { LongString longString = (LongString)attribute.DicomValue; dumpString += String.Format("{0}", GetValues(longString.Values)); break; } case VR.LT: { LongText longText = (LongText)attribute.DicomValue; dumpString += String.Format("{0}", longText.Value); break; } case VR.OB: { OtherByteString otherByteString = (OtherByteString)attribute.DicomValue; dumpString += String.Format("{0}", otherByteString.FileName); break; } case VR.OF: { OtherFloatString otherFloatString = (OtherFloatString)attribute.DicomValue; dumpString += String.Format("{0}", otherFloatString.FileName); break; } case VR.OW: { OtherWordString otherWordString = (OtherWordString)attribute.DicomValue; dumpString += String.Format("{0}", otherWordString.FileName); break; } case VR.OV: { OtherVeryLongString otherVeryLongString = (OtherVeryLongString)attribute.DicomValue; dumpString += String.Format("{0}", otherVeryLongString.FileName); break; } case VR.PN: { PersonName personName = (PersonName)attribute.DicomValue; dumpString += String.Format("{0}", GetValues(personName.Values)); break; } case VR.SH: { ShortString shortString = (ShortString)attribute.DicomValue; dumpString += String.Format("{0}", GetValues(shortString.Values)); break; } case VR.SL: { SignedLong signedLong = (SignedLong)attribute.DicomValue; dumpString += String.Format("{0}", GetValues(signedLong.Values)); break; } case VR.SQ: { //SequenceOfItems sequenceOfItems = (SequenceOfItems)attribute.DicomValue; //int itemNumber = 1; //dumpString += "\r\n"; //foreach (SequenceItem item in sequenceOfItems.Sequence) //{ // dumpString += String.Format("> Begin Item: {0}\r\n", itemNumber); // dumpString += item.Dump(prefix); // dumpString += prefix + String.Format("> End Item: {0}\r\n", itemNumber++); //} break; } case VR.SS: { SignedShort signedShort = (SignedShort)attribute.DicomValue; dumpString += String.Format("{0}", GetValues(signedShort.Values)); break; } case VR.ST: { ShortText shortText = (ShortText)attribute.DicomValue; dumpString += String.Format("{0}", shortText.Value); break; } case VR.TM: { Time time = (Time)attribute.DicomValue; dumpString += String.Format("{0}", GetValues(time.Values)); break; } case VR.UI: { UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue; dumpString += String.Format("{0}", GetValues(uniqueIdentifier.Values)); break; } case VR.UL: { UnsignedLong unsignedLong = (UnsignedLong)attribute.DicomValue; dumpString += String.Format("{0}", GetValues(unsignedLong.Values)); break; } case VR.UN: { break; } case VR.US: { UnsignedShort unsignedShort = (UnsignedShort)attribute.DicomValue; dumpString += String.Format("{0}", GetValues(unsignedShort.Values)); break; } case VR.UT: { break; } case VR.UR: { break; } case VR.UC: { break; } default: dumpString += String.Format("\' \'"); break; } } else { dumpString += String.Format("\' \'"); } return(dumpString); }
private static void AddReferencedSopSequence(ReferencedSopItemCollection storageCommitItems, uint tag, DvtkData.Dimse.AttributeSet attributeSet, InstanceStateEnum newInstanceState) { ushort group = (ushort)(tag >> 16); ushort element = (ushort)(tag & 0x0000FFFF); DvtkData.Dimse.Tag tagValue = new DvtkData.Dimse.Tag(group, element); DvtkData.Dimse.Attribute referencedSopSequence = attributeSet.GetAttribute(tagValue); if (referencedSopSequence != null) { attributeSet.Remove(referencedSopSequence); } referencedSopSequence = new DvtkData.Dimse.Attribute(tag, DvtkData.Dimse.VR.SQ); SequenceOfItems referencedSopSequenceOfItems = new SequenceOfItems(); referencedSopSequence.DicomValue = referencedSopSequenceOfItems; foreach(ReferencedSopItem referencedSopItem in storageCommitItems) { if (((referencedSopItem.InstanceState == InstanceStateEnum.InstanceStored) && (newInstanceState == InstanceStateEnum.InstanceMppsCompleted)) || ((referencedSopItem.InstanceState == InstanceStateEnum.InstanceMppsCompleted) && (newInstanceState == InstanceStateEnum.InstanceStorageCommitRequested))) { DvtkData.Dimse.SequenceItem referencedSopSequenceItem = new DvtkData.Dimse.SequenceItem(); referencedSopSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID.GroupNumber, DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID.ElementNumber, DvtkData.Dimse.VR.UI, referencedSopItem.SopClassUid); referencedSopSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID.GroupNumber, DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID.ElementNumber, DvtkData.Dimse.VR.UI, referencedSopItem.SopInstanceUid); referencedSopItem.InstanceState = newInstanceState; referencedSopSequenceOfItems.Sequence.Add(referencedSopSequenceItem); } } attributeSet.Add(referencedSopSequence); }
void HandlePatientRelatedInstances(TagType tagType, AttributeSet sourceDataset) { DvtkData.Dimse.Attribute sourceAttribute = sourceDataset.GetAttribute(tagType.Tag); if (sourceAttribute == null) { sourceAttribute = new DvtkData.Dimse.Attribute(); sourceAttribute.Tag = Tag.NUMBER_OF_PATIENT_RELATED_INSTANCES; sourceAttribute.Name = "Number of Patient related instances"; } DvtkData.Dimse.Attribute destinationAttribute = _dataset.GetAttribute(tagType.Tag); if (destinationAttribute != null) { _dataset.Remove(destinationAttribute); } IntegerString str = new IntegerString(); StringCollection colle = new StringCollection(); int noOfInstances = 0; for (int i = 0; i < Children.Count; i++) { for (int j = 0; j < Children[i].Children.Count; j++) { noOfInstances = noOfInstances + Children[i].Children[j].Children.Count; } } colle.Add(noOfInstances.ToString()); str.Values = colle; System.UInt32 length = 0; foreach (String data in str.Values) { length += (System.UInt32)data.Length; } sourceAttribute.DicomValue = str; sourceAttribute.Length = length + (System.UInt32)str.Values.Count - 1; _dataset.Add(sourceAttribute); }
/// <summary> /// Query the Information Model using the given Query Dataset. /// </summary> /// <param name="queryDataset">Query Dataset.</param> /// <returns>A collection of zero or more query reponse datasets.</returns> public override DataSetCollection QueryInformationModel(DataSet queryDataset) { DataSetCollection queryResponses = null; // get the query/retrieve level String queryRetrieveLevel = "UNKNOWN"; DvtkData.Dimse.Attribute queryRetrieveLevelAttribute = queryDataset.GetAttribute(Tag.QUERY_RETRIEVE_LEVEL); if (queryRetrieveLevelAttribute != null) { CodeString codeString = (CodeString)queryRetrieveLevelAttribute.DicomValue; if (codeString.Values.Count == 1) { queryRetrieveLevel = codeString.Values[0].Trim(); } } // query at the PATIENT level if (queryRetrieveLevel == "PATIENT") { TagTypeList queryTagTypeList = new TagTypeList(); TagTypeList returnTagTypeList = new TagTypeList(); foreach (DvtkData.Dimse.Attribute attribute in queryDataset) { if (attribute.Length != 0) { queryTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagRequired)); } returnTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagOptional)); } foreach (PatientInformationEntity patientInformationEntity in Root) { if (patientInformationEntity.IsFoundIn(queryTagTypeList, queryDataset)) { // PATIENT level matches DataSet queryResponse = new DataSet(); patientInformationEntity.CopyTo(returnTagTypeList, queryResponse); queryResponses.Add(queryResponse); } } } else { // find the matching PATIENT PatientInformationEntity patientInformationEntity = null; foreach (PatientInformationEntity lPatientInformationEntity in Root) { if (lPatientInformationEntity.IsUniqueTagFoundIn(queryDataset)) { patientInformationEntity = lPatientInformationEntity; break; } } if (patientInformationEntity != null) { // query at the STUDY level if (queryRetrieveLevel == "STUDY") { TagTypeList queryTagTypeList = new TagTypeList(); TagTypeList returnTagTypeList = new TagTypeList(); foreach (DvtkData.Dimse.Attribute attribute in queryDataset) { // do not add higher level tag if (attribute.Tag == Tag.PATIENT_ID) { continue; } if (attribute.Length != 0) { queryTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagRequired)); } returnTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagOptional)); } foreach (StudyInformationEntity studyInformationEntity in patientInformationEntity.Children) { if (studyInformationEntity.IsFoundIn(queryTagTypeList, queryDataset)) { // STUDY level matches DataSet queryResponse = new DataSet(); patientInformationEntity.CopyUniqueTagTo(queryResponse); studyInformationEntity.CopyTo(returnTagTypeList, queryResponse); queryResponses.Add(queryResponse); } } } } } return(queryResponses); }
/// <summary> /// Includes the non-dataset attributes in the information model. /// Handled attributes are, /// MODALITIES_IN_STUDY /// NUMBER_OF_PATIENT_RELATED_STUDIES /// NUMBER_OF_PATIENT_RELATED_SERIES /// NUMBER_OF_PATIENT_RELATED_INSTANCES /// NUMBER_OF_STUDY_RELATED_SERIES /// NUMBER_OF_STUDY_RELATED_INSTANCES. /// NUMBER_OF_SERIES_RELATED_INSTANCES /// </summary> /// <param name="sourceDataset"></param> public void CheckForSpecialTags(AttributeSet sourceDataset) { if (_tagTypeList != null&&sourceDataset!=null) { foreach (TagType tagType in _tagTypeList) { if (tagType.Tag == Tag.MODALITIES_IN_STUDY) { DvtkData.Dimse.Attribute sourceAttribute = sourceDataset.GetAttribute(tagType.Tag); if (sourceAttribute != null) { // if an entry already exists - remove it DvtkData.Dimse.Attribute destinationAttribute = _dataset.GetAttribute(tagType.Tag); if (destinationAttribute != null) { _dataset.Remove(destinationAttribute); } if (destinationAttribute != null && destinationAttribute.Tag == Tag.MODALITIES_IN_STUDY && destinationAttribute.ValueRepresentation == VR.CS) { StringCollection values = ((CodeString)destinationAttribute.DicomValue).Values; string actualModality = ((CodeString)sourceDataset.GetAttribute(Tag.MODALITY).DicomValue).Values[0]; if (actualModality != null && !values.Contains(actualModality.Trim())) { values.Add(actualModality.Trim()); } CodeString cs = new CodeString(); cs.Values = values; sourceAttribute.DicomValue = cs; System.UInt32 length = 0; foreach (String data in cs.Values) { length += (System.UInt32)data.Length; } sourceAttribute.Length = length + (System.UInt32)cs.Values.Count - 1; } _dataset.Add(sourceAttribute); } else if (tagType.Tag == Tag.MODALITIES_IN_STUDY) { sourceAttribute = new DvtkData.Dimse.Attribute(); sourceAttribute.Tag = Tag.MODALITIES_IN_STUDY; sourceAttribute.Name = "Modalities in study"; DvtkData.Dimse.Attribute destinationAttribute = _dataset.GetAttribute(tagType.Tag); string actualModality = ((CodeString)sourceDataset.GetAttribute(Tag.MODALITY).DicomValue).Values[0]; StringCollection values = null; if (destinationAttribute != null && destinationAttribute.ValueRepresentation == VR.CS) { _dataset.Remove(destinationAttribute); values = ((CodeString)destinationAttribute.DicomValue).Values; } if (values == null) values = new StringCollection(); if (actualModality != null && !values.Contains(actualModality.Trim())) { values.Add(actualModality.Trim()); } CodeString cs = new CodeString(); cs.Values = values; sourceAttribute.DicomValue = cs; System.UInt32 length = 0; foreach (String data in cs.Values) { length += (System.UInt32)data.Length; } sourceAttribute.Length = length + (System.UInt32)cs.Values.Count - 1; _dataset.Add(sourceAttribute); } } else if (tagType.Tag == Tag.NUMBER_OF_PATIENT_RELATED_STUDIES&&_level=="PATIENT") { HandlePatientRelatedStudies(tagType, sourceDataset); } else if (tagType.Tag == Tag.NUMBER_OF_PATIENT_RELATED_SERIES&& _level=="PATIENT") { HandlePatientRelatedSeries(tagType, sourceDataset); } else if (tagType.Tag == Tag.NUMBER_OF_PATIENT_RELATED_INSTANCES&&_level=="PATIENT") { HandlePatientRelatedInstances(tagType, sourceDataset); } else if (tagType.Tag == Tag.NUMBER_OF_STUDY_RELATED_SERIES&&_level=="STUDY") { HandleStudyRelatedSeries(tagType, sourceDataset); } else if (tagType.Tag == Tag.NUMBER_OF_STUDY_RELATED_INSTANCES&&_level=="STUDY") { HandleStudyRelatedInstances(tagType, sourceDataset); } else if (tagType.Tag == Tag.NUMBER_OF_SERIES_RELATED_INSTANCES&&_level=="SERIES") { HandleSeriesRelatedInstances(tagType, sourceDataset); } } } }
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); } } }
/// <summary> /// Check if the given instance is present in the Information Model. The instance will be at the leaf nodes of the Information Model. /// </summary> /// <param name="sopClassUid">SOP Class UID to search for.</param> /// <param name="sopInstanceUid">SOP Instance UID to search for.</param> /// <returns>Boolean - true if instance found in the Information Model, otherwise false.</returns> public bool IsInstanceInInformationModel(System.String sopClassUid, System.String sopInstanceUid) { bool isInstanceInInformationModel = false; // set up the commit tag list for comparing with the leaf TagTypeList commitTagTypeList = new TagTypeList(); commitTagTypeList.Add(new TagType(Tag.SOP_INSTANCE_UID, TagTypeEnum.TagRequired)); commitTagTypeList.Add(new TagType(Tag.SOP_CLASS_UID, TagTypeEnum.TagRequired)); // set up the commit dataset DvtkData.Dimse.DataSet commitDataset = new DvtkData.Dimse.DataSet(); DvtkData.Dimse.Attribute attribute = new DvtkData.Dimse.Attribute(0x00080016, DvtkData.Dimse.VR.UI, sopClassUid); commitDataset.Add(attribute); attribute = new DvtkData.Dimse.Attribute(0x00080018, DvtkData.Dimse.VR.UI, sopInstanceUid); commitDataset.Add(attribute); // iterate over the whole information model - we are interested in the leaf nodes foreach (PatientInformationEntity patientInformationEntity in Root) { foreach (StudyInformationEntity studyInformationEntity in patientInformationEntity.Children) { foreach (SeriesInformationEntity seriesInformationEntity in studyInformationEntity.Children) { foreach (InstanceInformationEntity instanceInformationEntity in seriesInformationEntity.Children) { if (instanceInformationEntity.IsFoundIn(commitTagTypeList, commitDataset)) { // an instance has been found with the matching commit uids isInstanceInInformationModel = true; break; } } } } } return isInstanceInInformationModel; }
/// <summary> /// Set the Default Tag Type List for this Entity. /// </summary> protected override void SetDefaultTagTypeList() { TagTypeList.Add(new TagType(Tag.SPECIFIC_CHARACTER_SET, VR.CS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.MODALITY, VR.CS, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.SERIES_NUMBER, VR.IS, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.SERIES_INSTANCE_UID, VR.UI, TagTypeEnum.TagUnique)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_SERIES_RELATED_INSTANCES, VR.IS, TagTypeEnum.TagOptional)); // plus all other attributes at a series level! for (int i = 0; i < CustomQueryAttributes.Instance.SeriesList.Count; i++) TagTypeList.Add(new TagType(new Tag(Convert.ToUInt16(CustomQueryAttributes.Instance.SeriesList[i].group,16), Convert.ToUInt16(CustomQueryAttributes.Instance.SeriesList[i].element,16)) , TagTypeEnum.TagOptional)); // add the specific character set attribute as a conditonal attribute at this level // - used purely to return the correct value in the Specific Character Set attribute of the C-FIND-RSP dataset TagTypeList.Add(new TagType(Tag.SPECIFIC_CHARACTER_SET, VR.CS, TagTypeEnum.TagConditional)); // Add the Query Retrieve Level Attribute DvtkData.Dimse.Attribute attribute = new DvtkData.Dimse.Attribute(0x00080052, VR.CS, "SERIES"); DataSet.Add(attribute); }
/// <summary> /// Set the Default Tag Type List for this Entity. /// </summary> protected override void SetDefaultTagTypeList() { TagTypeList.Add(new TagType(Tag.SPECIFIC_CHARACTER_SET, VR.CS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_NAME, VR.PN, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.PATIENT_ID, VR.LO, TagTypeEnum.TagUnique)); TagTypeList.Add(new TagType(Tag.ISSUER_OF_PATIENT_ID, VR.LO, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.REFERENCED_PATIENT_SEQUENCE, VR.SQ, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_BIRTH_DATE, VR.DA, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_BIRTH_TIME, VR.TM, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_SEX, VR.CS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.OTHER_PATIENT_IDS, VR.LO, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.OTHER_PATIENT_NAMES, VR.PN, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.ETHNIC_GROUP, VR.SH, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENT_COMMENTS, VR.LT, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_PATIENT_RELATED_STUDIES, VR.IS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_PATIENT_RELATED_SERIES, VR.IS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_PATIENT_RELATED_INSTANCES, VR.IS, TagTypeEnum.TagOptional)); for (int i = 0; i < CustomQueryAttributes.Instance.PatientList.Count; i++) TagTypeList.Add(new TagType(new Tag(Convert.ToUInt16(CustomQueryAttributes.Instance.PatientList[i].group, 16), Convert.ToUInt16(CustomQueryAttributes.Instance.PatientList[i].element, 16)) , TagTypeEnum.TagOptional)); // add the specific character set attribute as a conditonal attribute at this level // - used purely to return the correct value in the Specific Character Set attribute of the C-FIND-RSP dataset TagTypeList.Add(new TagType(Tag.SPECIFIC_CHARACTER_SET, VR.CS, TagTypeEnum.TagConditional)); // Add the Query Retrieve Level Attribute DvtkData.Dimse.Attribute attribute = new DvtkData.Dimse.Attribute(0x00080052, VR.CS, "PATIENT"); DataSet.Add(attribute); }
/// <summary> /// Set the Default Tag Type List for this Entity. /// </summary> protected override void SetDefaultTagTypeList() { TagTypeList.Add(new TagType(Tag.SPECIFIC_CHARACTER_SET, VR.CS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.STUDY_DATE, VR.DA, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.STUDY_TIME, VR.TM, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.ACCESSION_NUMBER, VR.SH, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.STUDY_ID, VR.SH, TagTypeEnum.TagRequired)); TagTypeList.Add(new TagType(Tag.STUDY_INSTANCE_UID, VR.UI, TagTypeEnum.TagUnique)); TagTypeList.Add(new TagType(Tag.MODALITIES_IN_STUDY, VR.CS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.REFERRING_PHYSICIANS_NAME, VR.PN, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.STUDY_DESCRIPTION, VR.LO, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PROCEDURE_CODE_SEQUENCE, VR.SQ, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NAME_OF_PHYSICIANS_READING_STUDY, VR.PN, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.ADMITTING_DIAGNOSIS_DESCRIPTION, VR.LO, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.REFERENCED_STUDY_SEQUENCE, VR.SQ, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_AGE, VR.AS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_SIZE, VR.DS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.PATIENTS_WEIGHT, VR.DS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.OCCUPATION, VR.SH, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.ADDITIONAL_PATIENT_HISTORY, VR.LT, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.OTHER_STUDY_NUMBERS, VR.IS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_STUDY_RELATED_SERIES, VR.IS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.NUMBER_OF_STUDY_RELATED_INSTANCES, VR.IS, TagTypeEnum.TagOptional)); TagTypeList.Add(new TagType(Tag.INTERPRETATION_AUTHOR, VR.PN, TagTypeEnum.TagOptional)); for (int i = 0; i < CustomQueryAttributes.Instance.StudyList.Count; i++) TagTypeList.Add(new TagType(new Tag(Convert.ToUInt16(CustomQueryAttributes.Instance.StudyList[i].group, 16), Convert.ToUInt16(CustomQueryAttributes.Instance.StudyList[i].element, 16)) , TagTypeEnum.TagOptional)); // add the specific character set attribute as a conditonal attribute at this level // - used purely to return the correct value in the Specific Character Set attribute of the C-FIND-RSP dataset TagTypeList.Add(new TagType(Tag.SPECIFIC_CHARACTER_SET, VR.CS, TagTypeEnum.TagConditional)); // Add the Query Retrieve Level Attribute DvtkData.Dimse.Attribute attribute = new DvtkData.Dimse.Attribute(0x00080052, VR.CS, "STUDY"); DataSet.Add(attribute); }
/// <summary> /// Store the DICOM file into a DICOM Media File in the current Information Model directory. /// The file contents might be later used for retrieval.The transfer syntax is also passed so that the TS specified /// in the dcm file is used while moving the file to a Storage SCP /// </summary> /// <param name="dicomFile">The DICOM file to store</param> protected void StoreDicomFile(DvtkData.Media.DicomFile dicomFile) { System.String iom = System.String.Empty; if (Name.Equals("PatientRootInformationModel")) { iom = "PR"; } else if (Name.Equals("StudyRootInformationModel")) { iom = "SR"; } else if (Name.Equals("PatientStudyOnlyInformationModel")) { iom = "PS"; } // generate a filename System.String filename; filename = System.String.Format("{0}\\DVTK_IOM_TMP_{1}_{2:00000000}.DCM", DataDirectory, iom, _fileIndex++); DvtkData.Media.DicomFile dicomMediaFile = new DvtkData.Media.DicomFile(); // set up the file head DvtkData.Media.FileHead FileHead = new DvtkData.Media.FileHead(); // add the Transfer Syntax UID //DvtkData.Dul.TransferSyntax transferSyntax = new DvtkData.Dul.TransferSyntax(DvtkData.Dul.TransferSyntax.Explicit_VR_Little_Endian.UID); FileHead.TransferSyntax = dicomFile.FileHead.TransferSyntax; // set up the file meta information DvtkData.Media.FileMetaInformation fileMetaInformation = new DvtkData.Media.FileMetaInformation(); // add the FMI version fileMetaInformation.AddAttribute(Tag.FILE_META_INFORMATION_VERSION.GroupNumber, Tag.FILE_META_INFORMATION_VERSION.ElementNumber, VR.OB, 1, 2); // add the SOP Class UID System.String sopClassUid = ""; DvtkData.Dimse.Attribute attribute = dicomFile.DataSet.GetAttribute(DvtkData.Dimse.Tag.SOP_CLASS_UID); if (attribute != null) { UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue; if (uniqueIdentifier.Values.Count > 0) { sopClassUid = uniqueIdentifier.Values[0]; } } fileMetaInformation.AddAttribute(Tag.MEDIA_STORAGE_SOP_CLASS_UID.GroupNumber, Tag.MEDIA_STORAGE_SOP_CLASS_UID.ElementNumber, VR.UI, sopClassUid); // add the SOP Instance UID System.String sopInstanceUid = ""; attribute = dicomFile.DataSet.GetAttribute(DvtkData.Dimse.Tag.SOP_INSTANCE_UID); if (attribute != null) { UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue; if (uniqueIdentifier.Values.Count > 0) { sopInstanceUid = uniqueIdentifier.Values[0]; } } fileMetaInformation.AddAttribute(Tag.MEDIA_STORAGE_SOP_INSTANCE_UID.GroupNumber, Tag.MEDIA_STORAGE_SOP_INSTANCE_UID.ElementNumber, VR.UI, sopInstanceUid); // add the Transfer Syntax UID fileMetaInformation.AddAttribute(Tag.TRANSFER_SYNTAX_UID.GroupNumber, Tag.TRANSFER_SYNTAX_UID.ElementNumber, VR.UI, dicomFile.FileHead.TransferSyntax); // add the Implemenation Class UID DvtkData.Dimse.Attribute implentationUID = dicomFile.FileMetaInformation.GetAttribute(0x00020012); fileMetaInformation.AddAttribute(Tag.IMPLEMENTATION_CLASS_UID.GroupNumber, Tag.IMPLEMENTATION_CLASS_UID.ElementNumber, VR.UI, implentationUID); // add the Implementation Version Name DvtkData.Dimse.Attribute implementationVersion = dicomFile.FileMetaInformation.GetAttribute(0x00020013); fileMetaInformation.AddAttribute(Tag.IMPLEMENTATION_VERSION_NAME.GroupNumber, Tag.IMPLEMENTATION_VERSION_NAME.ElementNumber, VR.SH, implementationVersion); // set up the dicomMediaFile contents dicomMediaFile.FileHead = FileHead; dicomMediaFile.FileMetaInformation = fileMetaInformation; dicomMediaFile.DataSet = dicomFile.DataSet; // write the dicomMediaFile to file Dvtk.DvtkDataHelper.WriteDataSetToFile(dicomMediaFile, filename); // save the filename in the dataset dicomFile.DataSet.Filename = filename; }
/// <summary> /// Query the Information Model using the given Query Dataset. /// </summary> /// <param name="queryDataset">Query Dataset.</param> /// <returns>A collection of zero or more query reponse datasets.</returns> public override DataSetCollection QueryInformationModel(DataSet queryDataset) { DataSetCollection queryResponses = new DataSetCollection(); BaseInformationEntityList matchingScheduledProcedureSteps = new BaseInformationEntityList(); SequenceItem queryItem = null; TagTypeList queryTagTypeList = new TagTypeList(); TagTypeList returnTagTypeList = new TagTypeList(); foreach (DvtkData.Dimse.Attribute attribute in queryDataset) { // special check for the Scheduled Procedure Step Sequence if (attribute.Tag == Tag.SCHEDULED_PROCEDURE_STEP_SEQUENCE) { SequenceOfItems sequenceOfItems = (SequenceOfItems)attribute.DicomValue; if (sequenceOfItems.Sequence.Count == 1) { queryItem = sequenceOfItems.Sequence[0]; foreach (DvtkData.Dimse.Attribute itemAttribute in queryItem) { if (itemAttribute.Length != 0) { queryTagTypeList.Add(new TagType(itemAttribute.Tag, TagTypeEnum.TagRequired)); } returnTagTypeList.Add(new TagType(itemAttribute.Tag, TagTypeEnum.TagOptional)); } } } else { if (attribute.Length != 0) { queryTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagRequired)); } returnTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagOptional)); } } // iterate over the Modality Worklist Information Model and save all the matching // Scheduled Procedure Steps // iterate of all Information Entities foreach (PatientInformationEntity patientInformationEntity in Root) { if ((patientInformationEntity.IsFoundIn(queryTagTypeList, queryDataset)) || (patientInformationEntity.UniversalMatch(queryTagTypeList))) { foreach (VisitInformationEntity visitInformationEntity in patientInformationEntity.Children) { if ((visitInformationEntity.IsFoundIn(queryTagTypeList, queryDataset)) || (visitInformationEntity.UniversalMatch(queryTagTypeList))) { foreach (ImagingServiceRequestInformationEntity imagingServiceRequestInformationEntity in visitInformationEntity.Children) { if ((imagingServiceRequestInformationEntity.IsFoundIn(queryTagTypeList, queryDataset)) || (imagingServiceRequestInformationEntity.UniversalMatch(queryTagTypeList))) { foreach (RequestedProcedureInformationEntity requestedProcedureInformationEntity in imagingServiceRequestInformationEntity.Children) { if ((requestedProcedureInformationEntity.IsFoundIn(queryTagTypeList, queryDataset)) || (requestedProcedureInformationEntity.UniversalMatch(queryTagTypeList))) { foreach (ScheduledProcedureStepInformationEntity scheduledProcedureStepInformationEntity in requestedProcedureInformationEntity.Children) { if (scheduledProcedureStepInformationEntity.IsFoundIn(queryTagTypeList, queryItem)) { // add the scheduled procedure step to the matched list matchingScheduledProcedureSteps.Add(scheduledProcedureStepInformationEntity); } } } } } } } } } } // we now have a list of all the matching scheduled procedure steps foreach (ScheduledProcedureStepInformationEntity matchingScheduledProcedureStepInformationEntity in matchingScheduledProcedureSteps) { SequenceItem responseItem = new SequenceItem(); matchingScheduledProcedureStepInformationEntity.CopyTo(returnTagTypeList, responseItem); DvtkData.Dimse.Attribute attribute = new DvtkData.Dimse.Attribute(0x00400100, VR.SQ, responseItem); DataSet queryResponse = new DataSet(); queryResponse.Add(attribute); RequestedProcedureInformationEntity matchingRequestedProcedureInformationEntity = (RequestedProcedureInformationEntity)matchingScheduledProcedureStepInformationEntity.Parent; matchingRequestedProcedureInformationEntity.CopyTo(returnTagTypeList, queryResponse); ImagingServiceRequestInformationEntity matchingImagingServiceRequestInformationEntity = (ImagingServiceRequestInformationEntity)matchingRequestedProcedureInformationEntity.Parent; matchingImagingServiceRequestInformationEntity.CopyTo(returnTagTypeList, queryResponse); VisitInformationEntity matchingVisitInformationEntity = (VisitInformationEntity)matchingImagingServiceRequestInformationEntity.Parent; matchingVisitInformationEntity.CopyTo(returnTagTypeList, queryResponse); PatientInformationEntity matchingPatientInformationEntity = (PatientInformationEntity)matchingVisitInformationEntity.Parent; matchingPatientInformationEntity.CopyTo(returnTagTypeList, queryResponse); queryResponses.Add(queryResponse); } return queryResponses; }
/// <summary> /// Send all the images found in the given storage directory. /// </summary> /// <param name="storageDirectory">Given storage directory - containing storage DCM files.</param> /// <param name="modalityWorklistItem">Worklist Item used to provide overruling values for /// the Image headers.</param> /// <param name="withSingleAssociation">Boolean indicating whether the images should be sent in a single /// association or not.</param> /// <returns>Boolean indicating success or failure.</returns> public bool SendModalityImagesStored(System.String storageDirectory, DicomQueryItem modalityWorklistItem, bool withSingleAssociation) { if ((storageDirectory.Length == 0) || (modalityWorklistItem == null)) { return(false); } // Use a hash table to store the instance uid mappings // - the instance uids for the study, series and sop are going to be updated for all the datasets // read from the storageDirectory Hashtable instanceMapper = new Hashtable(); // Get the directory info for the storage directory - and make sure that it exists DirectoryInfo directoryInfo = new DirectoryInfo(storageDirectory); if (directoryInfo.Exists == false) { System.String message = System.String.Format("storageDirectory:\"{0}\" - does not exist.", storageDirectory); throw new System.Exception(message); } // Get a trigger DicomTrigger trigger = new DicomTrigger(TransactionNameEnum.RAD_8); trigger.HandleInSingleAssociation = withSingleAssociation; // Interate over all the DCM files found in the storage directory // - update the instances found with the worklist item contents and // set up the triggers for the Image Archive foreach (FileInfo fileInfo in directoryInfo.GetFiles()) { if ((fileInfo.Extension.ToLower().Equals(".dcm")) || (fileInfo.Extension == System.String.Empty)) { // Read the file meta information - it must be present for this actor DvtkData.Media.FileMetaInformation fileMetaInformation = Dvtk.DvtkDataHelper.ReadFMIFromFile(fileInfo.FullName); if (fileMetaInformation == null) { continue; } // Try to get the transfer syntax uid // - start with Implicit VR Little Endian System.String transferSyntaxUid = "1.2.840.10008.1.2"; DvtkData.Dimse.Attribute attribute = fileMetaInformation.GetAttribute(DvtkData.Dimse.Tag.TRANSFER_SYNTAX_UID); if (attribute != null) { UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue; if (uniqueIdentifier.Values.Count > 0) { transferSyntaxUid = uniqueIdentifier.Values[0]; } } // Read the dataset from the DCM file DvtkData.Dimse.DataSet dataset = Dvtk.DvtkDataHelper.ReadDataSetFromFile(fileInfo.FullName); if (dataset == null) { continue; } // Remove any Group Lengths from the dataset dataset.RemoveGroupLengthAttributes(); // Try to get the series instance uid System.String oldSeriesInstanceUid = System.String.Empty; DvtkData.Dimse.Attribute seriesInstanceUidAttribute = dataset.GetAttribute(Tag.SERIES_INSTANCE_UID); if (seriesInstanceUidAttribute != null) { UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)seriesInstanceUidAttribute.DicomValue; if (uniqueIdentifier.Values.Count > 0) { oldSeriesInstanceUid = uniqueIdentifier.Values[0]; } // Remove the old series instance from the dataset dataset.Remove(seriesInstanceUidAttribute); } // See if a mapping exists System.String newSeriesInstanceUid = (System.String)instanceMapper[oldSeriesInstanceUid]; if (newSeriesInstanceUid == null) { // Add a mapping DefaultValueManager.UpdateInstantiatedDefaultTagValues(AffectedEntityEnum.SeriesEntity); newSeriesInstanceUid = DefaultValueManager.GetInstantiatedValue(Tag.SERIES_INSTANCE_UID); instanceMapper.Add(oldSeriesInstanceUid, newSeriesInstanceUid); } // Add the new series instance uid to the dataset dataset.AddAttribute(Tag.SERIES_INSTANCE_UID.GroupNumber, Tag.SERIES_INSTANCE_UID.ElementNumber, VR.UI, newSeriesInstanceUid); // Try to get the sop instance uid System.String oldSopInstanceUid = System.String.Empty; DvtkData.Dimse.Attribute sopInstanceUidAttribute = dataset.GetAttribute(Tag.SOP_INSTANCE_UID); if (sopInstanceUidAttribute != null) { UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)sopInstanceUidAttribute.DicomValue; if (uniqueIdentifier.Values.Count > 0) { oldSopInstanceUid = uniqueIdentifier.Values[0]; } // Remove the old sop instance from the dataset dataset.Remove(sopInstanceUidAttribute); } // See if a mapping exists System.String newSopInstanceUid = (System.String)instanceMapper[oldSopInstanceUid]; if (newSopInstanceUid == null) { // Add a mapping DefaultValueManager.UpdateInstantiatedDefaultTagValues(AffectedEntityEnum.InstanceEntity); newSopInstanceUid = DefaultValueManager.GetInstantiatedValue(Tag.SOP_INSTANCE_UID); instanceMapper.Add(oldSopInstanceUid, newSopInstanceUid); } // Add the new sop instance uid to the dataset dataset.AddAttribute(Tag.SOP_INSTANCE_UID.GroupNumber, Tag.SOP_INSTANCE_UID.ElementNumber, VR.UI, newSopInstanceUid); // Use modality Worklist Item to help construct the Storage Message // Get the attribute values to copy DvtkHighLevelInterface.Comparator.Comparator worklistItemComparator = new DvtkHighLevelInterface.Comparator.Comparator("WorklistItemComparator"); DicomComparator dicomWorklistItemComparator = worklistItemComparator.InitializeDicomComparator(modalityWorklistItem.DicomMessage); // Also try to use the MPPS InProgress Message to help construct the Storage Message DvtkHighLevelInterface.Comparator.Comparator mppsInProgressComparator = new DvtkHighLevelInterface.Comparator.Comparator("MppsInProgressComparator"); DicomComparator dicomMppsInProgressComparator = null; if (_nCreateSetMppsInProgress != null) { dicomMppsInProgressComparator = mppsInProgressComparator.InitializeDicomComparator(_nCreateSetMppsInProgress); } // Create the Storage message DvtkHighLevelInterface.Comparator.Comparator storageComparator = new DvtkHighLevelInterface.Comparator.Comparator("StorageComparator"); DvtkHighLevelInterface.Dicom.Messages.DicomMessage cStoreInstance = new DvtkHighLevelInterface.Dicom.Messages.DicomMessage(DvtkData.Dimse.DimseCommand.CSTORERQ); GenerateTriggers.MakeCStoreInstance(DefaultValueManager, cStoreInstance, dataset); storageComparator.PopulateDicomMessage(cStoreInstance, dicomWorklistItemComparator); if (dicomMppsInProgressComparator != null) { storageComparator.PopulateDicomMessage(cStoreInstance, dicomMppsInProgressComparator); } // Try to get the sop class uid System.String sopClassUid = System.String.Empty; DvtkData.Dimse.Attribute sopClassUidAttribute = dataset.GetAttribute(Tag.SOP_CLASS_UID); if (sopClassUidAttribute != null) { UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)sopClassUidAttribute.DicomValue; if (uniqueIdentifier.Values.Count > 0) { sopClassUid = uniqueIdentifier.Values[0]; } } // Add trigger item to the trigger trigger.AddItem(cStoreInstance, sopClassUid, transferSyntaxUid); } } // RAD-8 - trigger the ImageArchive return(TriggerActorInstances(ActorTypeEnum.ImageArchive, trigger, true)); }
void HandleStudyRelatedSeries(TagType tagType, AttributeSet sourceDataset) { DvtkData.Dimse.Attribute sourceAttribute = sourceDataset.GetAttribute(tagType.Tag); if (sourceAttribute == null) { sourceAttribute = new DvtkData.Dimse.Attribute(); sourceAttribute.Tag = Tag.NUMBER_OF_STUDY_RELATED_SERIES; sourceAttribute.Name = "Number of Study related Series"; } DvtkData.Dimse.Attribute destinationAttribute = _dataset.GetAttribute(tagType.Tag); if (destinationAttribute != null) { _dataset.Remove(destinationAttribute); } IntegerString str = new IntegerString(); StringCollection colle = new StringCollection(); colle.Add(Children.Count.ToString()); str.Values = colle; System.UInt32 length = 0; foreach (String data in str.Values) { length += (System.UInt32)data.Length; } sourceAttribute.DicomValue = str; sourceAttribute.Length = length + (System.UInt32)str.Values.Count - 1; _dataset.Add(sourceAttribute); }
void HandlePatientRelatedSeries(TagType tagType, AttributeSet sourceDataset) { DvtkData.Dimse.Attribute sourceAttribute = sourceDataset.GetAttribute(tagType.Tag); if (sourceAttribute == null) { sourceAttribute = new DvtkData.Dimse.Attribute(); sourceAttribute.Tag = Tag.NUMBER_OF_PATIENT_RELATED_SERIES; sourceAttribute.Name = "Number of Patient related series"; } DvtkData.Dimse.Attribute destinationAttribute = _dataset.GetAttribute(tagType.Tag); if (destinationAttribute != null) { _dataset.Remove(destinationAttribute); } IntegerString str = new IntegerString(); StringCollection colle = new StringCollection(); int noOfSeries = 0; for (int i = 0; i < Children.Count; i++) { noOfSeries = noOfSeries + Children[i].Children.Count; } colle.Add(noOfSeries.ToString()); str.Values = colle; System.UInt32 length = 0; foreach (String data in str.Values) { length += (System.UInt32)data.Length; } sourceAttribute.DicomValue = str; sourceAttribute.Length = length + (System.UInt32)str.Values.Count - 1; _dataset.Add(sourceAttribute); //DvtkData.Dimse.Attribute sourceAttribute = sourceDataset.GetAttribute(tagType.Tag); //if (sourceAttribute != null) //{ // // if an entry already exists - remove it // DvtkData.Dimse.Attribute destinationAttribute = _dataset.GetAttribute(tagType.Tag); // if (destinationAttribute != null) // { // _dataset.Remove(destinationAttribute); // } // if (destinationAttribute != null && destinationAttribute.Tag == Tag.NUMBER_OF_PATIENT_RELATED_STUDIES) // { // IntegerString str = new IntegerString(); // StringCollection colle = new StringCollection(); // int noOfSeries = 0; // for (int i = 0; i < Children.Count; i++) // { // noOfSeries = noOfSeries + Children[i].Children.Count; // } // colle.Add(noOfSeries.ToString()); // str.Values = colle; // System.UInt32 length = 0; // foreach (String data in str.Values) // { // length += (System.UInt32)data.Length; // } // sourceAttribute.Length = length + (System.UInt32)str.Values.Count - 1; // } // _dataset.Add(sourceAttribute); //} //else //{ // sourceAttribute = new DvtkData.Dimse.Attribute(); // sourceAttribute.Tag = Tag.NUMBER_OF_PATIENT_RELATED_STUDIES; // sourceAttribute.Name = "Number of Patient related series"; // DvtkData.Dimse.Attribute destinationAttribute = _dataset.GetAttribute(tagType.Tag); // StringCollection values = null; // if (destinationAttribute != null) // { // _dataset.Remove(destinationAttribute); // } // values = new StringCollection(); // int noOfSeries = 0; // for (int i = 0; i < Children.Count; i++) // { // noOfSeries = noOfSeries + Children[i].Children.Count; // } // values.Add(noOfSeries.ToString()); // IntegerString IS = new IntegerString(); // IS.Values = values; // sourceAttribute.DicomValue = IS; // System.UInt32 length = 0; // foreach (String data in IS.Values) // { // length += (System.UInt32)data.Length; // } // sourceAttribute.Length = length + (System.UInt32)IS.Values.Count - 1; // _dataset.Add(sourceAttribute); //} }