In our demo for Query and Retrieve, we do a search based on a date range. I have copied and pasted the code below:
This starts on line#756 from the file CFind.cs in the project CSDicomFindMoveDemo found in the directory \LEADTOOLS 15\Examples\DotNet\CS\DicomFindMoveDemo
case FindType.Study:
{
ds.Initialize(DicomClassType.StudyRootQueryStudy, DicomDataSetInitializeType.ExplicitVRLittleEndian);
Utils.SetTag(ds, DicomTagType.QueryRetrieveLevel, "STUDY");
Utils.SetTag(ds, DicomTagType.StudyInstanceUID, query.StudyInstanceUid);
Utils.SetTag(ds, DicomTagType.StudyID, query.StudyID);
Utils.SetTag(ds, DicomTagType.AccessionNumber, query.AccessionNo);
Utils.SetTag(ds, DicomTagType.PatientName, query.PatientName);
Utils.SetTag(ds, DicomTagType.PatientID, query.PatientID);
if(DateTime.Compare(query.StudyStartDate, DateTime.MinValue) != 0 &&
DateTime.Compare(query.StudyEndDate, DateTime.MinValue) != 0)
{
StringBuilder range = new StringBuilder();
range.Append(query.StudyStartDate.ToString("yyyyMMdd"));
range.Append("-");
range.Append(query.StudyEndDate.ToString("yyyyMMdd"));
Utils.SetTag(ds, DicomTagType.StudyDate, Encoding.UTF8.GetBytes(range.ToString()));
}
else if(DateTime.Compare(query.StudyStartDate, DateTime.MinValue) == 0 &&
DateTime.Compare(query.StudyEndDate, DateTime.MinValue) != 0)
{
StringBuilder range = new StringBuilder();
range.Append("-");
range.Append(query.StudyEndDate.ToString("yyyyMMdd"));
Utils.SetTag(ds, DicomTagType.StudyDate, Encoding.UTF8.GetBytes(range.ToString()));
}
else if(DateTime.Compare(query.StudyStartDate, DateTime.MinValue) != 0 &&
DateTime.Compare(query.StudyEndDate, DateTime.MinValue) == 0)
{
StringBuilder range = new StringBuilder();
range.Append(query.StudyStartDate.ToString("yyyyMMdd"));
range.Append("-");
Utils.SetTag(ds, DicomTagType.StudyDate, Encoding.UTF8.GetBytes(range.ToString()));
}
}
break;
Travis Montgomery
Senior Sales Engineer