2015年8月28日金曜日

GDCM memo

Find Scu

PatID>>StudyInstansUID>>SeriesInstanceUID>>SOPInstanceUID
患者番号からSOPInstanceUIDを抽出

ushort port = 11112;
string aetcalled = "DCM4CHEE";
string aetcalling = "any";
string host = "192.168.0.1";
//Patient Number
string patId="123";
//Study Level
gdcm.PresentationContextGenerator generator = new PresentationContextGenerator();
gdcm.KeyValuePairArrayType theTagPair = new KeyValuePairArrayType();
theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0010, 0x0020), patId));
theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0010, 0x0010), "*"));    //Name
theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0010, 0x0030), "*"));    //Birthday
theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0010, 0x0040), "*"));    //Sex
theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0020, 0x000D), "*"));    //StudyInstanceUID
theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0008, 0x0050), "*"));    //AccessionNumber
var query = gdcm.CompositeNetworkFunctions.ConstructQuery(gdcm.ERootType.ePatientRootType,
    gdcm.EQueryLevel.eStudy, theTagPair);
var ret = new DataSetArrayType();
bool b = gdcm.CompositeNetworkFunctions.CFind(host, port, query, ret, aetcalling, aetcalled);
List studyInsUidList = new List();
for (int i = 0; i < ret.Count; i++)
{
    var ds = ret[i];
    Console.WriteLine("StudyInsUid:" + ds.GetDataElement(new gdcm.Tag(0x0020, 0x000D)).GetValue().toString());
    studyInsUidList.Add(ds.GetDataElement(new gdcm.Tag(0x0020, 0x000D)).GetValue().toString());
}
//Series Level
string studyInsUid = studyInsUidList[0].Trim(); //Select First Series                 
theTagPair = new KeyValuePairArrayType();
theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0020, 0x000D), studyInsUid));    //StudyInstanceUID
theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0020, 0x000E), "*"));            //SeriesInstanceUID
theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0008, 0x0060), "*"));            //Modality
theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0020, 0x0011), "*"));            //SeriesNumber
query = gdcm.CompositeNetworkFunctions.ConstructQuery(gdcm.ERootType.eStudyRootType,
    gdcm.EQueryLevel.eSeries, theTagPair);
ret = new DataSetArrayType();
gdcm.CompositeNetworkFunctions.CFind(host, port, query, ret, aetcalling, aetcalled);
List seriesInsUidList = new List();
for (int i = 0; i < ret.Count; i++)
{
    var ds = ret[i];
    Console.WriteLine("SeriesInsUid:" + ds.GetDataElement(new gdcm.Tag(0x0020, 0x000E)).GetValue().toString());
    seriesInsUidList.Add(ds.GetDataElement(new gdcm.Tag(0x0020, 0x000E)).GetValue().toString());
}
//Image Level
string seriesInsUid = seriesInsUidList[0].Trim(); //Select First Series                 
theTagPair = new KeyValuePairArrayType();
theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0020, 0x000E), seriesInsUid));   //SeriesInstanceUID
theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0020, 0x0013), "*"));            //InstanceNumber
theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0008, 0x0018), "*"));            //SOPInstanceUID
query = gdcm.CompositeNetworkFunctions.ConstructQuery(gdcm.ERootType.eStudyRootType,
    gdcm.EQueryLevel.eImage, theTagPair);
ret = new DataSetArrayType();
gdcm.CompositeNetworkFunctions.CFind(host, port, query, ret, aetcalling, aetcalled);

for (int i = 0; i < ret.Count; i++)
{
    var ds = ret[i];
    Console.WriteLine("SopInsUid:" + ds.GetDataElement(new gdcm.Tag(0x0008, 0x0018)).GetValue().toString());
}

0 件のコメント :

コメントを投稿