我正在尝试从本地Dicom工作列表服务器填充MWL(模态工作列表),但无法获得:
计划的电台AE标题(位置)(0040,0001)
模式名称(0008,0060)
我正在使用fo-dicom.Desktop v4.0.1库。
有人可以帮忙吗?我尝试了另一个客户端(DicomObject.Net),它确实填充了模态名称和计划的工作站AE标题。
private List<DicomDataset> GetAllItemsFromWorklist(string serverIP, int serverPort, string serverAET, string clientAET,string modalityName)
{
var worklistItems = new List<DicomDataset>();
var cfind = DicomCFindRequest.CreateWorklistQuery(modality: modalityName);
cfind.OnResponseReceived = (DicomCFindRequest rq, DicomCFindResponse rp) =>
{
//Console.WriteLine("Study UID: {0}", rp.Dataset.GetSingleValue<string>(DicomTag.StudyInstanceUID));
// rp.Dataset.AddOrUpdate(DicomTag.Modality, modalityName);
worklistItems.Add(rp.Dataset);
};
var client = new DicomClient();
client.AddRequest(cfind);
//client.SendAsync(serverIP, serverPort, false, clientAET, serverAET).GetAwaiter().GetResult();
client.Send(serverIP, serverPort, false, clientAET, serverAET,500);
return worklistItems;
}
public List<WorklistItem> GetWorklist(string serverIP,
int serverPort,
string serverAET,
string clientAET,
string ModalityName)
{
List<WorklistItem> worklistItems = new List<WorklistItem>();
try
{
// query all worklist items from worklist server
var list = GetAllItemsFromWorklist(serverIP, serverPort, serverAET, clientAET, ModalityName);
foreach(DicomDataset item in list)
{
WorklistItem workitem = new WorklistItem();
// --------------------------------------------------------------------------------------------
// PATIENT ID (0010,0020)
// --------------------------------------------------------------------------------------------
workitem.PatientID = item.GetSingleValueOrDefault(DicomTag.PatientID, String.Empty);
string patientName = item.GetSingleValueOrDefault(DicomTag.PatientName, String.Empty);
if (patientName != null)
{
string[] arr = patientName.Split(' ');
if (arr.Length > 1)
{
workitem.FirstName = arr[0];
workitem.LastName = arr[1];
}
else
{
//at least firstname
workitem.FirstName = string.Empty;
workitem.LastName = patientName;
}
Console.WriteLine("Patient Name = {0} {1}", workitem.FirstName, workitem.LastName);
}
// --------------------------------------------------------------------------------------------
// PATIENT DOB (0010,0030)
// --------------------------------------------------------------------------------------------
string dob = item.GetSingleValueOrDefault(DicomTag.PatientBirthDate, String.Empty);
if (dob != null)
{
if (dob.Length==8)
{
workitem.BirthYear = Convert.ToInt32(dob.Substring(0, 4));
workitem.BirthMonth = Convert.ToInt32(dob.Substring(4, 2));
workitem.BirthDay= Convert.ToInt32(dob.Substring(6, 2));
Console.WriteLine("Patient BirthDate = Year={0} Month={1} Date={2}", workitem.BirthYear, workitem.BirthMonth, workitem.BirthDay);
}
}
// --------------------------------------------------------------------------------------------
// PATIENT SEX (0010,0040)
// --------------------------------------------------------------------------------------------
string sex = item.GetSingleValueOrDefault(DicomTag.PatientSex, String.Empty);
workitem.Sex = sex == "M" ? 1 : sex == "F" ? 0 : 2;
Console.WriteLine("Patient Gender={0}", workitem.Sex);
// --------------------------------------------------------------------------------------------
// PATIENT WEIGHT (0010,1030)
// --------------------------------------------------------------------------------------------
string weight = item.GetSingleValueOrDefault(DicomTag.PatientWeight, String.Empty);
int weightAsNum = 0;
if (Int32.TryParse(weight,out weightAsNum))
{
workitem.Weight = weightAsNum;
Console.WriteLine("Patient Weight={0}", workitem.Weight);
}
// --------------------------------------------------------------------------------------------
// PATIENT HEIGHT (0010,1020)
// --------------------------------------------------------------------------------------------
string height = item.GetSingleValueOrDefault(DicomTag.PatientSize, String.Empty);
int heighttAsNum = 0;
if (Int32.TryParse(weight, out heighttAsNum))
{
workitem.Weight = weightAsNum * 100; //to centimeters
Console.WriteLine("Patient Height={0} cm", workitem.Weight);
}
// --------------------------------------------------------------------------------------------
// PATIENT ADRRESS (0010,0040)
// --------------------------------------------------------------------------------------------
workitem.Address = item.GetSingleValueOrDefault(DicomTag.PatientAddress, String.Empty);
Console.WriteLine("Patient Address={0}", workitem.Address);
// --------------------------------------------------------------------------------------------
// PATIENT PHONE (0010,2154)
// --------------------------------------------------------------------------------------------
workitem.Phone1 = item.GetSingleValueOrDefault(DicomTag.PatientTelephoneNumbers, String.Empty);
Console.WriteLine("Patient Phone={0}", workitem.Phone1);
// --------------------------------------------------------------------------------------------
// PATIENT EMAIL (0010,2155)
// --------------------------------------------------------------------------------------------
workitem.EMail = item.GetSingleValueOrDefault(DicomTag.PatientTelecomInformation, String.Empty);
Console.WriteLine("Patient Email={0}", workitem.EMail);
// --------------------------------------------------------------------------------------------
// Procedure performing person (0008,1050)
// --------------------------------------------------------------------------------------------
workitem.TechName = item.GetSingleValueOrDefault(DicomTag.PerformingPhysicianName, String.Empty);
Console.WriteLine("Patient Technician Name={0}", workitem.TechName);
// --------------------------------------------------------------------------------------------
// Procedur Attending doctor (0008,0090)
// --------------------------------------------------------------------------------------------
workitem.PhysName = item.GetSingleValueOrDefault(DicomTag.ReferringPhysicianName, String.Empty);
Console.WriteLine("Patient Physician Name={0}", workitem.PhysName);
// --------------------------------------------------------------------------------------------
// IDR - Accession number (0008,0050)
// --------------------------------------------------------------------------------------------
workitem.IDR = item.GetSingleValueOrDefault(DicomTag.AccessionNumber, String.Empty);
Console.WriteLine("Patient Accession Number={0}", workitem.IDR);
// --------------------------------------------------------------------------------------------
// CASE ID - VISIT NUMBER (0020,000D)
// --------------------------------------------------------------------------------------------
workitem.Case_Id = item.GetSingleValueOrDefault(DicomTag.PatientID, String.Empty);
Console.WriteLine("Patient Visit Number={0}", workitem.Case_Id);
// --------------------------------------------------------------------------------------------
// Modality (0008,0060)
// --------------------------------------------------------------------------------------------
workitem.Modality = item.GetSingleValueOrDefault(DicomTag.Modality, String.Empty);
Console.WriteLine("Test Modality={0}", workitem.Modality);
// --------------------------------------------------------------------------------------------
// Examination status (0040,0253) [0-not started, 1-in process, 2-completed [1] Examination status]
// --------------------------------------------------------------------------------------------
workitem.Status = 0;
// --------------------------------------------------------------------------------------------
// ScheduledDate - Test appointment date (0008,0020) (0008,0030)
// --------------------------------------------------------------------------------------------
string studyDate = item.GetSingleValueOrDefault(DicomTag.ScheduledProcedureStepStartDate, String.Empty);
string studyTime = item.GetSingleValueOrDefault(DicomTag.ScheduledProcedureStepStartTime, String.Empty);
if (studyDate.Length >= 8 && studyTime.Length >= 4)
{
studyDate = studyDate.Replace(".", "");
studyTime = studyTime.Replace(":", "");
studyTime = studyTime.Substring(0, 4);
workitem.ScheduledDate = string.Format(string.Format("{0}{1}", studyDate, studyTime));
Console.WriteLine("Test Scheduled Date={0}", workitem.ScheduledDate);
}
// --------------------------------------------------------------------------------------------
// Scheduled Station AE Title (Location) (0040,0001)
// --------------------------------------------------------------------------------------------
workitem.Location = item.GetSingleValueOrDefault(DicomTag.ScheduledStationAETitle, String.Empty);
Console.WriteLine("Test Location={0}", workitem.Location);
worklistItems.Add(workitem);
}
}
catch (Exception ex)
{
throw ex;
}
return worklistItems;
}