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); //} }
/// <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 STUDIES. BaseInformationEntityList studyInformationEntities = patientInformationEntity.ChildrenWithUniqueTagFoundIn(retrieveDataset); if (studyInformationEntities.Count > 0) { // Retrieve at the STUDY level if (queryRetrieveLevel == "STUDY") { foreach (StudyInformationEntity studyInformationEntity in studyInformationEntities) { foreach (String fileName in studyInformationEntity.FileNames) { fileList.Add(fileName); } } } else { // Find the matching SERIES. BaseInformationEntityList seriesInformationEntities = studyInformationEntities[0].ChildrenWithUniqueTagFoundIn(retrieveDataset); if (seriesInformationEntities.Count > 0) { // retrieve at the SERIES level if (queryRetrieveLevel == "SERIES") { foreach (SeriesInformationEntity seriesInformationEntity in seriesInformationEntities) { foreach (String fileName in seriesInformationEntity.FileNames) { fileList.Add(fileName); } } } else { // Find the matching IMAGE BaseInformationEntityList instanceInformationEntities = seriesInformationEntities[0].ChildrenWithUniqueTagFoundIn(retrieveDataset); // retrieve at the IMAGE level if ((instanceInformationEntities.Count > 0) && (queryRetrieveLevel == "IMAGE")) { foreach (InstanceInformationEntity instanceInformationEntity in instanceInformationEntities) { if (instanceInformationEntity.Filename != null) { fileList.Add(instanceInformationEntity.Filename); } } } } } } } } } return(fileList); }
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> /// 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 STUDIES. BaseInformationEntityList studyInformationEntities = patientInformationEntity.ChildrenWithUniqueTagFoundIn(retrieveDataset); if (studyInformationEntities.Count > 0) { // Retrieve at the STUDY level if (queryRetrieveLevel == "STUDY") { foreach (StudyInformationEntity studyInformationEntity in studyInformationEntities) { foreach (String fileName in studyInformationEntity.FileNames) { fileList.Add(fileName); } } } else { // Find the matching SERIES. BaseInformationEntityList seriesInformationEntities = studyInformationEntities[0].ChildrenWithUniqueTagFoundIn(retrieveDataset); if (seriesInformationEntities.Count > 0) { // retrieve at the SERIES level if (queryRetrieveLevel == "SERIES") { foreach (SeriesInformationEntity seriesInformationEntity in seriesInformationEntities) { foreach (String fileName in seriesInformationEntity.FileNames) { fileList.Add(fileName); } } } else { // Find the matching IMAGE BaseInformationEntityList instanceInformationEntities = seriesInformationEntities[0].ChildrenWithUniqueTagFoundIn(retrieveDataset); // retrieve at the IMAGE level if ((instanceInformationEntities.Count > 0) && (queryRetrieveLevel == "IMAGE")) { foreach (InstanceInformationEntity instanceInformationEntity in instanceInformationEntities) { if (instanceInformationEntity.Filename != null) fileList.Add(instanceInformationEntity.Filename); } } } } } } } } return fileList; }