public override StudyItemList Query(QueryParameters queryParams, object targetServer) { ApplicationEntity selectedServer = (ApplicationEntity)targetServer; StudyItemList list = new StudyItemList(); foreach (var key in MINTApi.GetStudies(selectedServer.Host)) { var item = new StudyItem(key.StudyUid, key, MINTApi.LoaderName); MINTApi.FillStudyItem(item, key); list.Add(item); } return(list); }
public override StudyItemList Query(QueryParameters queryParams, IApplicationEntity server) { Platform.CheckForNullReference(queryParams, "queryParams"); //.NET strings are unicode, therefore, so is all the query data. const string utf8 = "ISO_IR 192"; var collection = new DicomAttributeCollection { SpecificCharacterSet = utf8 }; collection[DicomTags.SpecificCharacterSet].SetStringValue(utf8); collection[DicomTags.QueryRetrieveLevel].SetStringValue("STUDY"); collection[DicomTags.PatientId].SetStringValue(queryParams["PatientId"]); collection[DicomTags.AccessionNumber].SetStringValue(queryParams["AccessionNumber"]); collection[DicomTags.PatientsName].SetStringValue(queryParams["PatientsName"]); collection[DicomTags.ReferringPhysiciansName].SetStringValue(queryParams["ReferringPhysiciansName"]); collection[DicomTags.StudyDate].SetStringValue(queryParams["StudyDate"]); collection[DicomTags.StudyTime].SetStringValue(""); collection[DicomTags.StudyDescription].SetStringValue(queryParams["StudyDescription"]); collection[DicomTags.PatientsBirthDate].SetStringValue(""); collection[DicomTags.ModalitiesInStudy].SetStringValue(queryParams["ModalitiesInStudy"]); collection[DicomTags.StudyInstanceUid].SetStringValue(queryParams["StudyInstanceUid"]); collection[DicomTags.NumberOfStudyRelatedInstances].SetStringValue(""); collection[DicomTags.InstanceAvailability].SetEmptyValue(); // must not be included in request collection[DicomTags.PatientSpeciesDescription].SetStringValue(GetString(queryParams, "PatientSpeciesDescription")); var codeValue = GetString(queryParams, "PatientSpeciesCodeSequenceCodeValue"); var codeMeaning = GetString(queryParams, "PatientSpeciesCodeSequenceCodeMeaning"); if (codeValue != null || codeMeaning != null) { var codeSequenceMacro = new CodeSequenceMacro { CodingSchemeDesignator = "", CodeValue = codeValue, CodeMeaning = codeMeaning }; collection[DicomTags.PatientSpeciesCodeSequence].AddSequenceItem(codeSequenceMacro.DicomSequenceItem); } collection[DicomTags.PatientBreedDescription].SetStringValue(GetString(queryParams, "PatientBreedDescription")); codeValue = GetString(queryParams, "PatientBreedCodeSequenceCodeValue"); codeMeaning = GetString(queryParams, "PatientBreedCodeSequenceCodeMeaning"); if (codeValue != null || codeMeaning != null) { var codeSequenceMacro = new CodeSequenceMacro { CodingSchemeDesignator = "", CodeValue = codeValue, CodeMeaning = codeMeaning }; collection[DicomTags.PatientBreedCodeSequence].AddSequenceItem(codeSequenceMacro.DicomSequenceItem); } collection[DicomTags.ResponsiblePerson].SetStringValue(GetString(queryParams, "ResponsiblePerson")); collection[DicomTags.ResponsiblePersonRole].SetStringValue(""); collection[DicomTags.ResponsibleOrganization].SetStringValue(GetString(queryParams, "ResponsibleOrganization")); var localServer = ServerDirectory.GetLocalServer(); var studyItemList = new StudyItemList(); using (var context = new DataAccessContext()) { foreach (DicomAttributeCollection result in context.GetStudyStoreQuery().Query(collection)) { var item = new StudyItem(result[DicomTags.StudyInstanceUid].ToString(), localServer); item.SpecificCharacterSet = result.SpecificCharacterSet; item.PatientId = result[DicomTags.PatientId].ToString(); item.PatientsName = new PersonName(result[DicomTags.PatientsName].ToString()); item.ReferringPhysiciansName = new PersonName(result[DicomTags.ReferringPhysiciansName].GetString(0, "")); item.PatientsBirthDate = result[DicomTags.PatientsBirthDate].ToString(); item.StudyDate = result[DicomTags.StudyDate].ToString(); item.StudyTime = result[DicomTags.StudyTime].ToString(); item.StudyDescription = result[DicomTags.StudyDescription].ToString(); item.ModalitiesInStudy = DicomStringHelper.GetStringArray(result[DicomTags.ModalitiesInStudy].ToString()); item.AccessionNumber = result[DicomTags.AccessionNumber].ToString(); item.NumberOfStudyRelatedInstances = result[DicomTags.NumberOfStudyRelatedInstances].GetInt32(0, 0); item.InstanceAvailability = result[DicomTags.InstanceAvailability].GetString(0, ""); if (String.IsNullOrEmpty(item.InstanceAvailability)) { item.InstanceAvailability = "ONLINE"; } item.PatientSpeciesDescription = result[DicomTags.PatientSpeciesDescription].GetString(0, ""); var patientSpeciesCodeSequence = result[DicomTags.PatientSpeciesCodeSequence]; if (!patientSpeciesCodeSequence.IsNull && patientSpeciesCodeSequence.Count > 0) { var codeSequenceMacro = new CodeSequenceMacro(((DicomSequenceItem[])result[DicomTags.PatientSpeciesCodeSequence].Values)[0]); item.PatientSpeciesCodeSequenceCodingSchemeDesignator = codeSequenceMacro.CodingSchemeDesignator; item.PatientSpeciesCodeSequenceCodeValue = codeSequenceMacro.CodeValue; item.PatientSpeciesCodeSequenceCodeMeaning = codeSequenceMacro.CodeMeaning; } item.PatientBreedDescription = result[DicomTags.PatientBreedDescription].GetString(0, ""); var patientBreedCodeSequence = result[DicomTags.PatientBreedCodeSequence]; if (!patientBreedCodeSequence.IsNull && patientBreedCodeSequence.Count > 0) { var codeSequenceMacro = new CodeSequenceMacro(((DicomSequenceItem[])result[DicomTags.PatientBreedCodeSequence].Values)[0]); item.PatientBreedCodeSequenceCodingSchemeDesignator = codeSequenceMacro.CodingSchemeDesignator; item.PatientBreedCodeSequenceCodeValue = codeSequenceMacro.CodeValue; item.PatientBreedCodeSequenceCodeMeaning = codeSequenceMacro.CodeMeaning; } item.ResponsiblePerson = new PersonName(result[DicomTags.ResponsiblePerson].GetString(0, "")); item.ResponsiblePersonRole = result[DicomTags.ResponsiblePersonRole].GetString(0, ""); item.ResponsibleOrganization = result[DicomTags.ResponsibleOrganization].GetString(0, ""); studyItemList.Add(item); } } AuditHelper.LogQueryIssued(null, null, EventSource.CurrentUser, EventResult.Success, SopClass.StudyRootQueryRetrieveInformationModelFindUid, collection); return(studyItemList); }
public override StudyItemList Query(QueryParameters queryParams, IApplicationEntity targetServer) { Platform.CheckForNullReference(queryParams, "queryParams"); Platform.CheckForNullReference(targetServer, "targetServer"); var selectedServer = targetServer.ToServiceNode(); //.NET strings are unicode, therefore, so is all the query data. const string utf8 = "ISO_IR 192"; var requestCollection = new DicomAttributeCollection { SpecificCharacterSet = utf8 }; requestCollection[DicomTags.SpecificCharacterSet].SetStringValue(utf8); requestCollection[DicomTags.QueryRetrieveLevel].SetStringValue("STUDY"); requestCollection[DicomTags.StudyInstanceUid].SetStringValue(""); requestCollection[DicomTags.PatientId].SetStringValue(queryParams["PatientId"]); requestCollection[DicomTags.AccessionNumber].SetStringValue(queryParams["AccessionNumber"]); requestCollection[DicomTags.PatientsName].SetStringValue(queryParams["PatientsName"]); requestCollection[DicomTags.ReferringPhysiciansName].SetStringValue(queryParams["ReferringPhysiciansName"]); requestCollection[DicomTags.StudyDate].SetStringValue(queryParams["StudyDate"]); requestCollection[DicomTags.StudyTime].SetStringValue(""); requestCollection[DicomTags.StudyDescription].SetStringValue(queryParams["StudyDescription"]); requestCollection[DicomTags.PatientsBirthDate].SetStringValue(""); requestCollection[DicomTags.ModalitiesInStudy].SetStringValue(queryParams["ModalitiesInStudy"]); requestCollection[DicomTags.NumberOfStudyRelatedInstances].SetStringValue(""); requestCollection[DicomTags.InstanceAvailability].SetEmptyValue(); // must not be included in request requestCollection[DicomTags.PatientSpeciesDescription].SetStringValue(GetString(queryParams, "PatientSpeciesDescription")); var codeValue = GetString(queryParams, "PatientSpeciesCodeSequenceCodeValue"); var codeMeaning = GetString(queryParams, "PatientSpeciesCodeSequenceCodeMeaning"); if (codeValue != null || codeMeaning != null) { var codeSequenceMacro = new CodeSequenceMacro { CodingSchemeDesignator = "", CodeValue = codeValue, CodeMeaning = codeMeaning }; requestCollection[DicomTags.PatientSpeciesCodeSequence].AddSequenceItem(codeSequenceMacro.DicomSequenceItem); } requestCollection[DicomTags.PatientBreedDescription].SetStringValue(GetString(queryParams, "PatientBreedDescription")); codeValue = GetString(queryParams, "PatientBreedCodeSequenceCodeValue"); codeMeaning = GetString(queryParams, "PatientBreedCodeSequenceCodeMeaning"); if (codeValue != null || codeMeaning != null) { var codeSequenceMacro = new CodeSequenceMacro { CodingSchemeDesignator = "", CodeValue = codeValue, CodeMeaning = codeMeaning }; requestCollection[DicomTags.PatientBreedCodeSequence].AddSequenceItem(codeSequenceMacro.DicomSequenceItem); } requestCollection[DicomTags.ResponsiblePerson].SetStringValue(GetString(queryParams, "ResponsiblePerson")); requestCollection[DicomTags.ResponsiblePersonRole].SetStringValue(""); requestCollection[DicomTags.ResponsibleOrganization].SetStringValue(GetString(queryParams,"ResponsibleOrganization")); IList<DicomAttributeCollection> results = Query(selectedServer, requestCollection); StudyItemList studyItemList = new StudyItemList(); foreach (DicomAttributeCollection result in results) { StudyItem item = new StudyItem(result[DicomTags.StudyInstanceUid].GetString(0, ""), selectedServer); //TODO: add DicomField attributes to the StudyItem class (implement typeconverter for PersonName class). item.PatientsBirthDate = result[DicomTags.PatientsBirthDate].GetString(0, ""); item.AccessionNumber = result[DicomTags.AccessionNumber].GetString(0, ""); item.StudyDescription = result[DicomTags.StudyDescription].GetString(0, ""); item.StudyDate = result[DicomTags.StudyDate].GetString(0, ""); item.StudyTime = result[DicomTags.StudyTime].GetString(0, ""); item.PatientId = result[DicomTags.PatientId].GetString(0, ""); item.PatientsName = new PersonName(result[DicomTags.PatientsName].GetString(0, "")); item.ReferringPhysiciansName = new PersonName(result[DicomTags.ReferringPhysiciansName].GetString(0, "")); item.ModalitiesInStudy = DicomStringHelper.GetStringArray(result[DicomTags.ModalitiesInStudy].ToString()); DicomAttribute attribute = result[DicomTags.NumberOfStudyRelatedInstances]; if (!attribute.IsEmpty && !attribute.IsNull) item.NumberOfStudyRelatedInstances = attribute.GetInt32(0, 0); item.SpecificCharacterSet = result.SpecificCharacterSet; item.InstanceAvailability = result[DicomTags.InstanceAvailability].GetString(0, ""); if (String.IsNullOrEmpty(item.InstanceAvailability)) item.InstanceAvailability = "ONLINE"; item.PatientSpeciesDescription = result[DicomTags.PatientSpeciesDescription].GetString(0, ""); var patientSpeciesCodeSequence = result[DicomTags.PatientSpeciesCodeSequence]; if (!patientSpeciesCodeSequence.IsNull && patientSpeciesCodeSequence.Count > 0) { var codeSequenceMacro = new CodeSequenceMacro(((DicomSequenceItem[])result[DicomTags.PatientSpeciesCodeSequence].Values)[0]); item.PatientSpeciesCodeSequenceCodingSchemeDesignator = codeSequenceMacro.CodingSchemeDesignator; item.PatientSpeciesCodeSequenceCodeValue = codeSequenceMacro.CodeValue; item.PatientSpeciesCodeSequenceCodeMeaning = codeSequenceMacro.CodeMeaning; } item.PatientBreedDescription = result[DicomTags.PatientBreedDescription].GetString(0, ""); var patientBreedCodeSequence = result[DicomTags.PatientBreedCodeSequence]; if (!patientBreedCodeSequence.IsNull && patientBreedCodeSequence.Count > 0) { var codeSequenceMacro = new CodeSequenceMacro(((DicomSequenceItem[])result[DicomTags.PatientBreedCodeSequence].Values)[0]); item.PatientBreedCodeSequenceCodingSchemeDesignator = codeSequenceMacro.CodingSchemeDesignator; item.PatientBreedCodeSequenceCodeValue = codeSequenceMacro.CodeValue; item.PatientBreedCodeSequenceCodeMeaning = codeSequenceMacro.CodeMeaning; } item.ResponsiblePerson = new PersonName(result[DicomTags.ResponsiblePerson].GetString(0, "")); item.ResponsiblePersonRole = result[DicomTags.ResponsiblePersonRole].GetString(0, ""); item.ResponsibleOrganization = result[DicomTags.ResponsibleOrganization].GetString(0, ""); studyItemList.Add(item); } AuditHelper.LogQueryIssued(selectedServer.AETitle, selectedServer.ScpParameters.HostName, EventSource.CurrentUser, EventResult.Success, SopClass.StudyRootQueryRetrieveInformationModelFindUid, requestCollection); return studyItemList; }
public override StudyItemList Query(QueryParameters queryParams, IApplicationEntity targetServer) { Platform.CheckForNullReference(queryParams, "queryParams"); Platform.CheckForNullReference(targetServer, "targetServer"); var selectedServer = targetServer.ToServiceNode(); //.NET strings are unicode, therefore, so is all the query data. const string utf8 = "ISO_IR 192"; var requestCollection = new DicomAttributeCollection { SpecificCharacterSet = utf8 }; requestCollection[DicomTags.SpecificCharacterSet].SetStringValue(utf8); requestCollection[DicomTags.QueryRetrieveLevel].SetStringValue("STUDY"); requestCollection[DicomTags.StudyInstanceUid].SetStringValue(""); requestCollection[DicomTags.PatientId].SetStringValue(queryParams["PatientId"]); requestCollection[DicomTags.AccessionNumber].SetStringValue(queryParams["AccessionNumber"]); requestCollection[DicomTags.PatientsName].SetStringValue(queryParams["PatientsName"]); requestCollection[DicomTags.ReferringPhysiciansName].SetStringValue(queryParams["ReferringPhysiciansName"]); requestCollection[DicomTags.StudyDate].SetStringValue(queryParams["StudyDate"]); requestCollection[DicomTags.StudyTime].SetStringValue(""); requestCollection[DicomTags.StudyDescription].SetStringValue(queryParams["StudyDescription"]); requestCollection[DicomTags.PatientsBirthDate].SetStringValue(""); requestCollection[DicomTags.ModalitiesInStudy].SetStringValue(queryParams["ModalitiesInStudy"]); requestCollection[DicomTags.NumberOfStudyRelatedInstances].SetStringValue(""); requestCollection[DicomTags.InstanceAvailability].SetEmptyValue(); // must not be included in request requestCollection[DicomTags.PatientSpeciesDescription].SetStringValue(GetString(queryParams, "PatientSpeciesDescription")); var codeValue = GetString(queryParams, "PatientSpeciesCodeSequenceCodeValue"); var codeMeaning = GetString(queryParams, "PatientSpeciesCodeSequenceCodeMeaning"); if (codeValue != null || codeMeaning != null) { var codeSequenceMacro = new CodeSequenceMacro { CodingSchemeDesignator = "", CodeValue = codeValue, CodeMeaning = codeMeaning }; requestCollection[DicomTags.PatientSpeciesCodeSequence].AddSequenceItem(codeSequenceMacro.DicomSequenceItem); } requestCollection[DicomTags.PatientBreedDescription].SetStringValue(GetString(queryParams, "PatientBreedDescription")); codeValue = GetString(queryParams, "PatientBreedCodeSequenceCodeValue"); codeMeaning = GetString(queryParams, "PatientBreedCodeSequenceCodeMeaning"); if (codeValue != null || codeMeaning != null) { var codeSequenceMacro = new CodeSequenceMacro { CodingSchemeDesignator = "", CodeValue = codeValue, CodeMeaning = codeMeaning }; requestCollection[DicomTags.PatientBreedCodeSequence].AddSequenceItem(codeSequenceMacro.DicomSequenceItem); } requestCollection[DicomTags.ResponsiblePerson].SetStringValue(GetString(queryParams, "ResponsiblePerson")); requestCollection[DicomTags.ResponsiblePersonRole].SetStringValue(""); requestCollection[DicomTags.ResponsibleOrganization].SetStringValue(GetString(queryParams, "ResponsibleOrganization")); IList <DicomAttributeCollection> results = Query(selectedServer, requestCollection); StudyItemList studyItemList = new StudyItemList(); foreach (DicomAttributeCollection result in results) { StudyItem item = new StudyItem(result[DicomTags.StudyInstanceUid].GetString(0, ""), selectedServer); //TODO: add DicomField attributes to the StudyItem class (implement typeconverter for PersonName class). item.PatientsBirthDate = result[DicomTags.PatientsBirthDate].GetString(0, ""); item.AccessionNumber = result[DicomTags.AccessionNumber].GetString(0, ""); item.StudyDescription = result[DicomTags.StudyDescription].GetString(0, ""); item.StudyDate = result[DicomTags.StudyDate].GetString(0, ""); item.StudyTime = result[DicomTags.StudyTime].GetString(0, ""); item.PatientId = result[DicomTags.PatientId].GetString(0, ""); item.PatientsName = new PersonName(result[DicomTags.PatientsName].GetString(0, "")); item.ReferringPhysiciansName = new PersonName(result[DicomTags.ReferringPhysiciansName].GetString(0, "")); item.ModalitiesInStudy = DicomStringHelper.GetStringArray(result[DicomTags.ModalitiesInStudy].ToString()); DicomAttribute attribute = result[DicomTags.NumberOfStudyRelatedInstances]; if (!attribute.IsEmpty && !attribute.IsNull) { item.NumberOfStudyRelatedInstances = attribute.GetInt32(0, 0); } item.SpecificCharacterSet = result.SpecificCharacterSet; item.InstanceAvailability = result[DicomTags.InstanceAvailability].GetString(0, ""); if (String.IsNullOrEmpty(item.InstanceAvailability)) { item.InstanceAvailability = "ONLINE"; } item.PatientSpeciesDescription = result[DicomTags.PatientSpeciesDescription].GetString(0, ""); var patientSpeciesCodeSequence = result[DicomTags.PatientSpeciesCodeSequence]; if (!patientSpeciesCodeSequence.IsNull && patientSpeciesCodeSequence.Count > 0) { var codeSequenceMacro = new CodeSequenceMacro(((DicomSequenceItem[])result[DicomTags.PatientSpeciesCodeSequence].Values)[0]); item.PatientSpeciesCodeSequenceCodingSchemeDesignator = codeSequenceMacro.CodingSchemeDesignator; item.PatientSpeciesCodeSequenceCodeValue = codeSequenceMacro.CodeValue; item.PatientSpeciesCodeSequenceCodeMeaning = codeSequenceMacro.CodeMeaning; } item.PatientBreedDescription = result[DicomTags.PatientBreedDescription].GetString(0, ""); var patientBreedCodeSequence = result[DicomTags.PatientBreedCodeSequence]; if (!patientBreedCodeSequence.IsNull && patientBreedCodeSequence.Count > 0) { var codeSequenceMacro = new CodeSequenceMacro(((DicomSequenceItem[])result[DicomTags.PatientBreedCodeSequence].Values)[0]); item.PatientBreedCodeSequenceCodingSchemeDesignator = codeSequenceMacro.CodingSchemeDesignator; item.PatientBreedCodeSequenceCodeValue = codeSequenceMacro.CodeValue; item.PatientBreedCodeSequenceCodeMeaning = codeSequenceMacro.CodeMeaning; } item.ResponsiblePerson = new PersonName(result[DicomTags.ResponsiblePerson].GetString(0, "")); item.ResponsiblePersonRole = result[DicomTags.ResponsiblePersonRole].GetString(0, ""); item.ResponsibleOrganization = result[DicomTags.ResponsibleOrganization].GetString(0, ""); studyItemList.Add(item); } AuditHelper.LogQueryIssued(selectedServer.AETitle, selectedServer.ScpParameters.HostName, EventSource.CurrentUser, EventResult.Success, SopClass.StudyRootQueryRetrieveInformationModelFindUid, requestCollection); return(studyItemList); }
public override StudyItemList Query(QueryParameters queryParams, IApplicationEntity server) { Platform.CheckForNullReference(queryParams, "queryParams"); //.NET strings are unicode, therefore, so is all the query data. const string utf8 = "ISO_IR 192"; var collection = new DicomAttributeCollection {SpecificCharacterSet = utf8}; collection[DicomTags.SpecificCharacterSet].SetStringValue(utf8); collection[DicomTags.QueryRetrieveLevel].SetStringValue("STUDY"); collection[DicomTags.PatientId].SetStringValue(queryParams["PatientId"]); collection[DicomTags.AccessionNumber].SetStringValue(queryParams["AccessionNumber"]); collection[DicomTags.PatientsName].SetStringValue(queryParams["PatientsName"]); collection[DicomTags.ReferringPhysiciansName].SetStringValue(queryParams["ReferringPhysiciansName"]); collection[DicomTags.StudyDate].SetStringValue(queryParams["StudyDate"]); collection[DicomTags.StudyTime].SetStringValue(""); collection[DicomTags.StudyDescription].SetStringValue(queryParams["StudyDescription"]); collection[DicomTags.PatientsBirthDate].SetStringValue(""); collection[DicomTags.ModalitiesInStudy].SetStringValue(queryParams["ModalitiesInStudy"]); collection[DicomTags.StudyInstanceUid].SetStringValue(queryParams["StudyInstanceUid"]); collection[DicomTags.NumberOfStudyRelatedInstances].SetStringValue(""); collection[DicomTags.InstanceAvailability].SetEmptyValue(); // must not be included in request collection[DicomTags.PatientSpeciesDescription].SetStringValue(GetString(queryParams, "PatientSpeciesDescription")); var codeValue = GetString(queryParams, "PatientSpeciesCodeSequenceCodeValue"); var codeMeaning = GetString(queryParams, "PatientSpeciesCodeSequenceCodeMeaning"); if (codeValue != null || codeMeaning != null) { var codeSequenceMacro = new CodeSequenceMacro { CodingSchemeDesignator = "", CodeValue = codeValue, CodeMeaning = codeMeaning }; collection[DicomTags.PatientSpeciesCodeSequence].AddSequenceItem(codeSequenceMacro.DicomSequenceItem); } collection[DicomTags.PatientBreedDescription].SetStringValue(GetString(queryParams, "PatientBreedDescription")); codeValue = GetString(queryParams, "PatientBreedCodeSequenceCodeValue"); codeMeaning = GetString(queryParams, "PatientBreedCodeSequenceCodeMeaning"); if (codeValue != null || codeMeaning != null) { var codeSequenceMacro = new CodeSequenceMacro { CodingSchemeDesignator = "", CodeValue = codeValue, CodeMeaning = codeMeaning }; collection[DicomTags.PatientBreedCodeSequence].AddSequenceItem(codeSequenceMacro.DicomSequenceItem); } collection[DicomTags.ResponsiblePerson].SetStringValue(GetString(queryParams, "ResponsiblePerson")); collection[DicomTags.ResponsiblePersonRole].SetStringValue(""); collection[DicomTags.ResponsibleOrganization].SetStringValue(GetString(queryParams, "ResponsibleOrganization")); var localServer = ServerDirectory.GetLocalServer(); var studyItemList = new StudyItemList(); using (var context = new DataAccessContext()) { foreach (DicomAttributeCollection result in context.GetStudyStoreQuery().Query(collection)) { var item = new StudyItem(result[DicomTags.StudyInstanceUid].ToString(), localServer); item.SpecificCharacterSet = result.SpecificCharacterSet; item.PatientId = result[DicomTags.PatientId].ToString(); item.PatientsName = new PersonName(result[DicomTags.PatientsName].ToString()); item.ReferringPhysiciansName = new PersonName(result[DicomTags.ReferringPhysiciansName].GetString(0, "")); item.PatientsBirthDate = result[DicomTags.PatientsBirthDate].ToString(); item.StudyDate = result[DicomTags.StudyDate].ToString(); item.StudyTime = result[DicomTags.StudyTime].ToString(); item.StudyDescription = result[DicomTags.StudyDescription].ToString(); item.ModalitiesInStudy = DicomStringHelper.GetStringArray(result[DicomTags.ModalitiesInStudy].ToString()); item.AccessionNumber = result[DicomTags.AccessionNumber].ToString(); item.NumberOfStudyRelatedInstances = result[DicomTags.NumberOfStudyRelatedInstances].GetInt32(0, 0); item.InstanceAvailability = result[DicomTags.InstanceAvailability].GetString(0, ""); if (String.IsNullOrEmpty(item.InstanceAvailability)) item.InstanceAvailability = "ONLINE"; item.PatientSpeciesDescription = result[DicomTags.PatientSpeciesDescription].GetString(0, ""); var patientSpeciesCodeSequence = result[DicomTags.PatientSpeciesCodeSequence]; if (!patientSpeciesCodeSequence.IsNull && patientSpeciesCodeSequence.Count > 0) { var codeSequenceMacro = new CodeSequenceMacro(((DicomSequenceItem[]) result[DicomTags.PatientSpeciesCodeSequence].Values)[0]); item.PatientSpeciesCodeSequenceCodingSchemeDesignator = codeSequenceMacro.CodingSchemeDesignator; item.PatientSpeciesCodeSequenceCodeValue = codeSequenceMacro.CodeValue; item.PatientSpeciesCodeSequenceCodeMeaning = codeSequenceMacro.CodeMeaning; } item.PatientBreedDescription = result[DicomTags.PatientBreedDescription].GetString(0, ""); var patientBreedCodeSequence = result[DicomTags.PatientBreedCodeSequence]; if (!patientBreedCodeSequence.IsNull && patientBreedCodeSequence.Count > 0) { var codeSequenceMacro = new CodeSequenceMacro(((DicomSequenceItem[])result[DicomTags.PatientBreedCodeSequence].Values)[0]); item.PatientBreedCodeSequenceCodingSchemeDesignator = codeSequenceMacro.CodingSchemeDesignator; item.PatientBreedCodeSequenceCodeValue = codeSequenceMacro.CodeValue; item.PatientBreedCodeSequenceCodeMeaning = codeSequenceMacro.CodeMeaning; } item.ResponsiblePerson = new PersonName(result[DicomTags.ResponsiblePerson].GetString(0, "")); item.ResponsiblePersonRole = result[DicomTags.ResponsiblePersonRole].GetString(0, ""); item.ResponsibleOrganization = result[DicomTags.ResponsibleOrganization].GetString(0, ""); studyItemList.Add(item); } } AuditHelper.LogQueryIssued(null, null, EventSource.CurrentUser, EventResult.Success, SopClass.StudyRootQueryRetrieveInformationModelFindUid, collection); return studyItemList; }
public override PriorStudyFinderResult FindPriorStudies() { _cancel = false; var priorsServerQueries = new List <IStudyRootQuery>(); foreach (ServerPartition partition in ServerPartitionMonitor.Instance) { using (IReadContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { IDeviceEntityBroker broker = ctx.GetBroker <IDeviceEntityBroker>(); DeviceSelectCriteria criteria = new DeviceSelectCriteria(); criteria.DeviceTypeEnum.EqualTo(DeviceTypeEnum.PriorsServer); criteria.ServerPartitionKey.EqualTo(partition.Key); IList <Device> list = broker.Find(criteria); foreach (Device theDevice in list) { // Check the settings and log for debug purposes if (!theDevice.Enabled) { Platform.Log(LogLevel.Debug, "Prior Server '{0}' on partition '{1}' is disabled in the device setting", theDevice.AeTitle, partition.AeTitle); continue; } DicomStudyRootQuery remoteQuery = new DicomStudyRootQuery(partition.AeTitle, theDevice.AeTitle, theDevice.IpAddress, theDevice.Port); priorsServerQueries.Add(remoteQuery); } } } // Log the prior servers for debug purpose if (Platform.IsLogLevelEnabled(LogLevel.Debug) && priorsServerQueries.Count > 0) { StringBuilder log = new StringBuilder(); log.Append("Searching for priors on the following servers:"); StringBuilder serverList = new StringBuilder(); foreach (DicomStudyRootQuery server in priorsServerQueries) { if (serverList.Length > 0) { serverList.Append(","); } serverList.AppendFormat("{0}", server); } log.Append(serverList.ToString()); Platform.Log(LogLevel.Debug, log.ToString()); } StudyItemList results = new StudyItemList(); DefaultPatientReconciliationStrategy reconciliationStrategy = new DefaultPatientReconciliationStrategy(); List <string> patientIds = new List <string>(); foreach (Patient patient in Viewer.StudyTree.Patients) { if (_cancel) { break; } IPatientData reconciled = reconciliationStrategy.ReconcileSearchCriteria(patient); if (!patientIds.Contains(reconciled.PatientId)) { patientIds.Add(reconciled.PatientId); } } //Note: we don't catch the exception for this one because it's just querying the other //partitions, so if it fails we want an outright failure to occur. Besides, it should never happen //if the server is functioning correctly. using (StudyRootQueryBridge bridge = new StudyRootQueryBridge(Platform.GetService <IStudyRootQuery>())) { foreach (string patientId in patientIds) { StudyRootStudyIdentifier identifier = new StudyRootStudyIdentifier { PatientId = patientId }; IList <StudyRootStudyIdentifier> studies = bridge.StudyQuery(identifier); foreach (StudyRootStudyIdentifier study in studies) { if (_cancel) { break; } StudyItem studyItem = ConvertToStudyItem(study); if (studyItem != null) { results.Add(studyItem); } } } } bool complete = true; foreach (IStudyRootQuery query in priorsServerQueries) { foreach (string patientId in patientIds) { try { var identifier = new StudyRootStudyIdentifier { PatientId = patientId }; IList <StudyRootStudyIdentifier> list = query.StudyQuery(identifier); foreach (StudyRootStudyIdentifier i in list) { if (_cancel) { break; } StudyItem studyItem = ConvertToStudyItem(i); if (studyItem != null) { results.Add(studyItem); } } } catch (FaultException <DataValidationFault> ex) { complete = false; Platform.Log(LogLevel.Error, ex, "An error has occurred when searching for prior studies on server '{0}'", query.ToString()); } catch (FaultException <QueryFailedFault> ex) { complete = false; Platform.Log(LogLevel.Error, ex, "An error has occurred when searching for prior studies on server '{0}'", query.ToString()); } } } return(new PriorStudyFinderResult(results, complete)); }
public override PriorStudyFinderResult FindPriorStudies() { _cancel = false; var priorsServerQueries = new List<IStudyRootQuery>(); foreach (ServerPartition partition in ServerPartitionMonitor.Instance) { using (IReadContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { IDeviceEntityBroker broker = ctx.GetBroker<IDeviceEntityBroker>(); DeviceSelectCriteria criteria = new DeviceSelectCriteria(); criteria.DeviceTypeEnum.EqualTo(DeviceTypeEnum.PriorsServer); criteria.ServerPartitionKey.EqualTo(partition.Key); IList<Device> list = broker.Find(criteria); foreach (Device theDevice in list) { // Check the settings and log for debug purposes if (!theDevice.Enabled) { Platform.Log(LogLevel.Debug, "Prior Server '{0}' on partition '{1}' is disabled in the device setting", theDevice.AeTitle, partition.AeTitle); continue; } DicomStudyRootQuery remoteQuery = new DicomStudyRootQuery(partition.AeTitle, theDevice.AeTitle, theDevice.IpAddress, theDevice.Port); priorsServerQueries.Add(remoteQuery); } } } // Log the prior servers for debug purpose if (Platform.IsLogLevelEnabled(LogLevel.Debug) && priorsServerQueries.Count > 0) { StringBuilder log = new StringBuilder(); log.Append("Searching for priors on the following servers:"); StringBuilder serverList = new StringBuilder(); foreach (DicomStudyRootQuery server in priorsServerQueries) { if (serverList.Length > 0) serverList.Append(","); serverList.AppendFormat("{0}", server); } log.Append(serverList.ToString()); Platform.Log(LogLevel.Debug, log.ToString()); } StudyItemList results = new StudyItemList(); DefaultPatientReconciliationStrategy reconciliationStrategy = new DefaultPatientReconciliationStrategy(); List<string> patientIds = new List<string>(); foreach (Patient patient in Viewer.StudyTree.Patients) { if (_cancel) break; IPatientData reconciled = reconciliationStrategy.ReconcileSearchCriteria(patient); if (!patientIds.Contains(reconciled.PatientId)) patientIds.Add(reconciled.PatientId); } //Note: we don't catch the exception for this one because it's just querying the other //partitions, so if it fails we want an outright failure to occur. Besides, it should never happen //if the server is functioning correctly. using (StudyRootQueryBridge bridge = new StudyRootQueryBridge(Platform.GetService<IStudyRootQuery>())) { foreach (string patientId in patientIds) { StudyRootStudyIdentifier identifier = new StudyRootStudyIdentifier {PatientId = patientId}; IList<StudyRootStudyIdentifier> studies = bridge.StudyQuery(identifier); foreach (StudyRootStudyIdentifier study in studies) { if (_cancel) break; StudyItem studyItem = ConvertToStudyItem(study); if (studyItem != null) results.Add(studyItem); } } } bool complete = true; foreach (IStudyRootQuery query in priorsServerQueries) { foreach (string patientId in patientIds) { try { var identifier = new StudyRootStudyIdentifier { PatientId = patientId }; IList<StudyRootStudyIdentifier> list = query.StudyQuery(identifier); foreach (StudyRootStudyIdentifier i in list) { if (_cancel) break; StudyItem studyItem = ConvertToStudyItem(i); if (studyItem != null) results.Add(studyItem); } } catch (FaultException<DataValidationFault> ex) { complete = false; Platform.Log(LogLevel.Error, ex, "An error has occurred when searching for prior studies on server '{0}'", query.ToString()); } catch (FaultException<QueryFailedFault> ex) { complete = false; Platform.Log(LogLevel.Error, ex, "An error has occurred when searching for prior studies on server '{0}'", query.ToString()); } } } return new PriorStudyFinderResult(results, complete); }