/// <summary> /// Initializes an instance of the <see cref="DicomCFindRequest"/> class. /// </summary> /// <param name="level">Query/Retrieve level.</param> /// <param name="priority">Command priority.</param> public DicomCFindRequest(DicomQueryRetrieveLevel level, DicomPriority priority = DicomPriority.Medium) : base(DicomCommandField.CFindRequest, GetAffectedSOPClassUID(level), priority) { // when creating requests, one may be forced to use invalid UIDs. So turn off validation Dataset = new DicomDataset().NotValidated(); Level = level; }
/// <summary> /// Initializes an instance of the <see cref="DicomCFindRequest"/> class. /// </summary> /// <param name="affectedSopClassUid">Affected SOP Class UID.</param> /// <param name="level">Query/Retrieve level.</param> /// <param name="priority">Command priority.</param> public DicomCFindRequest(DicomUID affectedSopClassUid, DicomQueryRetrieveLevel level, DicomPriority priority = DicomPriority.Medium) : base(DicomCommandField.CFindRequest, affectedSopClassUid, priority) { // should we check combination between affectedSopClassUid and level? // should we allow PatientRoot and StudyRoot only ? if (affectedSopClassUid != DicomUID.ModalityWorklistInformationModelFIND && affectedSopClassUid != DicomUID.PatientRootQueryRetrieveInformationModelFIND && affectedSopClassUid != DicomUID.StudyRootQueryRetrieveInformationModelFIND && affectedSopClassUid != DicomUID.UnifiedProcedureStepPullSOPClass && affectedSopClassUid != DicomUID.UnifiedProcedureStepWatchSOPClass) { throw new DicomNetworkException("Overloaded constructor does not support Affected SOP Class UID: {0}", affectedSopClassUid.Name); } Dataset = new DicomDataset(); Level = level; }
/// <summary> /// Gets affected SOP class UID corresponding to specified Query/Retrieve <paramref name="level"/>. /// </summary> /// <param name="level">Query/Retrieve level.</param> /// <returns>Affected SOP class UID corresponding to specified Query/Retrieve <paramref name="level"/>.</returns> private static DicomUID GetAffectedSOPClassUID(DicomQueryRetrieveLevel level) { switch (level) { case DicomQueryRetrieveLevel.Patient: return(DicomUID.PatientRootQueryRetrieveInformationModelFIND); case DicomQueryRetrieveLevel.Study: case DicomQueryRetrieveLevel.Series: case DicomQueryRetrieveLevel.Image: return(DicomUID.StudyRootQueryRetrieveInformationModelFIND); case DicomQueryRetrieveLevel.Worklist: return(DicomUID.ModalityWorklistInformationModelFIND); default: throw new ArgumentOutOfRangeException(nameof(level), level, null); } }
public DicomCFindRequest(DicomQueryRetrieveLevel level, DicomPriority priority = DicomPriority.Medium) : base(DicomCommandField.CFindRequest, DicomUID.StudyRootQueryRetrieveInformationModelFIND, priority) { Dataset = new DicomDataset(); Level = level; }
/// <summary> /// Initializes an instance of the <see cref="DicomCFindRequest"/> class. /// </summary> /// <param name="affectedSopClassUid">Affected SOP Class UID.</param> /// <param name="level">Query/Retrieve level.</param> /// <param name="priority">Command priority.</param> public DicomCFindRequest(DicomUID affectedSopClassUid, DicomQueryRetrieveLevel level, DicomPriority priority = DicomPriority.Medium) : this(affectedSopClassUid, priority) { Level = level; }
public void Level_Getter_ReturnsCorrectQueryRetrieveLevel(DicomCMoveRequest request, DicomQueryRetrieveLevel expected) { var actual = request.Level; Assert.Equal(expected, actual); }
/// <summary> /// Initializes an instance of the <see cref="DicomCFindRequest"/> class. /// </summary> /// <param name="level">Query/Retrieve level.</param> /// <param name="priority">Command priority.</param> public DicomCFindRequest(DicomQueryRetrieveLevel level, DicomPriority priority = DicomPriority.Medium) : base(DicomCommandField.CFindRequest, GetAffectedSOPClassUID(level), priority) { Dataset = new DicomDataset(); Level = level; }
public void find(QueryObject query, string level) { if (level != "Study" && level != "Series" && level != "Image") { MessageBox.Show("incorrect level"); return; } DicomQueryRetrieveLevel queryLevel = (DicomQueryRetrieveLevel)Enum.Parse(typeof(DicomQueryRetrieveLevel), level); DicomCFindRequest cfind = new DicomCFindRequest(queryLevel); Type tipo = query.GetType(); PropertyInfo[] properties1 = tipo.GetProperties(); foreach (PropertyInfo property in properties1) { var tag = typeof(DicomTag).GetField(property.Name).GetValue(null); DicomTag theTag = (DicomTag.Parse(tag.ToString())); var variabile = property.GetValue(query); if (variabile.GetType().ToString() == "System.String") { String a = (String)variabile; cfind.Dataset.Add(theTag, a); } if (variabile.GetType().ToString() == "Dicom.DicomDateRange") { DicomDateRange a = (DicomDateRange)variabile; cfind.Dataset.Add(theTag, a); } } cfind.OnResponseReceived = (DicomCFindRequest rq, DicomCFindResponse rp) => { if (rp.HasDataset) { var type = Type.GetType("QueryRetrieveService." + level + "ResponseQuery"); var response = (QueryObject)Activator.CreateInstance(type); queryResponses.Add(response); PropertyInfo[] properties = response.GetType().GetProperties(); foreach (PropertyInfo property in properties) { var tag = typeof(DicomTag).GetField(property.Name).GetValue(null); DicomTag myTag = DicomTag.Parse(tag.ToString()); try { property.SetValue(response, rp.Dataset.GetValues <string>(myTag)[0]); } catch (Exception e) { // MessageBox.Show("tag " + myTag.ToString() + " not found in this dataset"); } } RaiseEvent(response); } }; var client = new DicomClient(); client.AddRequest(cfind); client.AssociationReleased += (sender, e) => { // non può inviare la lista 'queryResponses' prima // che 'cfind.OnResponseReceived' abbia finito di riempirla!! Thread.Sleep(5); RaiseConnectionClosed(queryResponses); }; try { client.Send(GUILogic.readFromFile("server"), Int32.Parse(GUILogic.readFromFile("serverPort")), false, GUILogic.readFromFile("thisMachineAE"), GUILogic.readFromFile("serverAE"), 1000); } catch (Exception e) { MessageBox.Show("impossible connect to server"); } }
public List <Pathmodel> CMove(DicomDataset ds, DicomQueryRetrieveLevel level) { List <Pathmodel> pathList = new List <Pathmodel>(); switch (level) { case DicomQueryRetrieveLevel.Patient: Patient patient = new Patient(); patient.PatientBirthDate = ds.Get <string>(DicomTag.PatientBirthDate); patient.PatientID = ds.Get <string>(DicomTag.PatientID); patient.PatientName = ds.Get <string>(DicomTag.PatientName); patient.PatientSex = ds.Get <string>(DicomTag.PatientSex); List <Patient> pList = m.GetList <Patient>(patient, "tb_patient"); foreach (Patient p in pList) { Pathmodel pathmodel = new Pathmodel(); pathmodel.ID = p.PID; pathList.AddRange(m.GetList <Pathmodel>(pathmodel, "tb_path")); } break; case DicomQueryRetrieveLevel.Study: Study study = new Study(); study.ReferringPhysiciansName = ds.Get <string>(DicomTag.ReferringPhysicianName); study.StudyDate = ds.Get <string>(DicomTag.StudyDate); study.StudyID = ds.Get <string>(DicomTag.StudyID); study.StudyInstanceUID = ds.Get <string>(DicomTag.StudyInstanceUID); study.StudyTime = ds.Get <string>(DicomTag.StudyTime); List <Study> studyList = m.GetList <Study>(study, "tb_study"); foreach (Study s in studyList) { Pathmodel pathmodel = new Pathmodel(); pathmodel.ID = s.PID; pathList.AddRange(m.GetList <Pathmodel>(pathmodel, "tb_path")); } break; case DicomQueryRetrieveLevel.Series: Series series = new Series(); series.Modality = ds.Get <string>(DicomTag.Modality); series.SeriesInstanceUID = ds.Get <string>(DicomTag.SeriesInstanceUID); series.SeriesNumber = ds.Get <string>(DicomTag.SeriesNumber); List <Series> seriesList = m.GetList <Series>(series, "tb_series"); foreach (Series s in seriesList) { Pathmodel pathmodel = new Pathmodel(); pathmodel.ID = s.PID; pathList.AddRange(m.GetList <Pathmodel>(pathmodel, "tb_path")); } break; case DicomQueryRetrieveLevel.Image: Image image = new Image(); image.InstanceNumber = ds.Get <string>(DicomTag.InstanceNumber); image.ContentDate = ds.Get <string>(DicomTag.ContentDate); image.ContentTime = ds.Get <string>(DicomTag.ContentTime); image.PatientOrientation = ds.Get <string>(DicomTag.PatientOrientation); List <Image> ImageList = m.GetList <Image>(image, "tb_image"); foreach (Image i in ImageList) { Pathmodel pathmodel = new Pathmodel(); pathmodel.ID = i.PID; pathList.AddRange(m.GetList <Pathmodel>(pathmodel, "tb_path")); } break; default: break; } return(pathList); }
public IList <DicomDataset> CFind(DicomDataset ds, DicomQueryRetrieveLevel level) { IList <DicomDataset> queryResults = new List <DicomDataset>(); switch (level) { case DicomQueryRetrieveLevel.Patient: Patient patient = new Patient(); patient.PatientBirthDate = ds.Get <string>(DicomTag.PatientBirthDate); patient.PatientID = ds.Get <string>(DicomTag.PatientID); patient.PatientName = ds.Get <string>(DicomTag.PatientName); patient.PatientSex = ds.Get <string>(DicomTag.PatientSex); List <Patient> pList = m.GetList <Patient>(patient, "tb_patient"); foreach (Patient p in pList) { DicomDataset dds = p.ToDicomDataset(); queryResults.Add(dds); } break; case DicomQueryRetrieveLevel.Study: Study study = new Study(); study.ReferringPhysiciansName = ds.Get <string>(DicomTag.ReferringPhysicianName); study.StudyDate = ds.Get <string>(DicomTag.StudyDate); study.StudyID = ds.Get <string>(DicomTag.StudyID); study.StudyInstanceUID = ds.Get <string>(DicomTag.StudyInstanceUID); study.StudyTime = ds.Get <string>(DicomTag.StudyTime); List <Study> studyList = m.GetList <Study>(study, "tb_study"); foreach (Study s in studyList) { DicomDataset dds = s.ToDicomDataset(); queryResults.Add(dds); } break; case DicomQueryRetrieveLevel.Series: Series series = new Series(); series.Modality = ds.Get <string>(DicomTag.Modality); series.SeriesInstanceUID = ds.Get <string>(DicomTag.SeriesInstanceUID); series.SeriesNumber = ds.Get <string>(DicomTag.SeriesNumber); List <Series> seriesList = m.GetList <Series>(series, "tb_series"); foreach (Series s in seriesList) { DicomDataset dds = s.ToDicomDataset(); queryResults.Add(dds); } break; case DicomQueryRetrieveLevel.Image: Image image = new Image(); image.InstanceNumber = ds.Get <string>(DicomTag.InstanceNumber); image.ContentDate = ds.Get <string>(DicomTag.ContentDate); image.ContentTime = ds.Get <string>(DicomTag.ContentTime); image.PatientOrientation = ds.Get <string>(DicomTag.PatientOrientation); List <Image> ImageList = m.GetList <Image>(image, "tb_image"); foreach (Image i in ImageList) { DicomDataset dds = i.ToDicomDataset(); queryResults.Add(dds); } break; default: break; } return(queryResults); }