2015年8月28日金曜日

GDCM memo

Find Scu

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

  1. ushort port = 11112;
  2. string aetcalled = "DCM4CHEE";
  3. string aetcalling = "any";
  4. string host = "192.168.0.1";
  5. //Patient Number
  6. string patId="123";
  7. //Study Level
  8. gdcm.PresentationContextGenerator generator = new PresentationContextGenerator();
  9. gdcm.KeyValuePairArrayType theTagPair = new KeyValuePairArrayType();
  10. theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0010, 0x0020), patId));
  11. theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0010, 0x0010), "*")); //Name
  12. theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0010, 0x0030), "*")); //Birthday
  13. theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0010, 0x0040), "*")); //Sex
  14. theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0020, 0x000D), "*")); //StudyInstanceUID
  15. theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0008, 0x0050), "*")); //AccessionNumber
  16. var query = gdcm.CompositeNetworkFunctions.ConstructQuery(gdcm.ERootType.ePatientRootType,
  17. gdcm.EQueryLevel.eStudy, theTagPair);
  18. var ret = new DataSetArrayType();
  19. bool b = gdcm.CompositeNetworkFunctions.CFind(host, port, query, ret, aetcalling, aetcalled);
  20. List studyInsUidList = new List();
  21. for (int i = 0; i < ret.Count; i++)
  22. {
  23. var ds = ret[i];
  24. Console.WriteLine("StudyInsUid:" + ds.GetDataElement(new gdcm.Tag(0x0020, 0x000D)).GetValue().toString());
  25. studyInsUidList.Add(ds.GetDataElement(new gdcm.Tag(0x0020, 0x000D)).GetValue().toString());
  26. }
  27. //Series Level
  28. string studyInsUid = studyInsUidList[0].Trim(); //Select First Series
  29. theTagPair = new KeyValuePairArrayType();
  30. theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0020, 0x000D), studyInsUid)); //StudyInstanceUID
  31. theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0020, 0x000E), "*")); //SeriesInstanceUID
  32. theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0008, 0x0060), "*")); //Modality
  33. theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0020, 0x0011), "*")); //SeriesNumber
  34. query = gdcm.CompositeNetworkFunctions.ConstructQuery(gdcm.ERootType.eStudyRootType,
  35. gdcm.EQueryLevel.eSeries, theTagPair);
  36. ret = new DataSetArrayType();
  37. gdcm.CompositeNetworkFunctions.CFind(host, port, query, ret, aetcalling, aetcalled);
  38. List seriesInsUidList = new List();
  39. for (int i = 0; i < ret.Count; i++)
  40. {
  41. var ds = ret[i];
  42. Console.WriteLine("SeriesInsUid:" + ds.GetDataElement(new gdcm.Tag(0x0020, 0x000E)).GetValue().toString());
  43. seriesInsUidList.Add(ds.GetDataElement(new gdcm.Tag(0x0020, 0x000E)).GetValue().toString());
  44. }
  45. //Image Level
  46. string seriesInsUid = seriesInsUidList[0].Trim(); //Select First Series
  47. theTagPair = new KeyValuePairArrayType();
  48. theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0020, 0x000E), seriesInsUid)); //SeriesInstanceUID
  49. theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0020, 0x0013), "*")); //InstanceNumber
  50. theTagPair.Add(new KeyValuePairType(new gdcm.Tag(0x0008, 0x0018), "*")); //SOPInstanceUID
  51. query = gdcm.CompositeNetworkFunctions.ConstructQuery(gdcm.ERootType.eStudyRootType,
  52. gdcm.EQueryLevel.eImage, theTagPair);
  53. ret = new DataSetArrayType();
  54. gdcm.CompositeNetworkFunctions.CFind(host, port, query, ret, aetcalling, aetcalled);
  55. for (int i = 0; i < ret.Count; i++)
  56. {
  57. var ds = ret[i];
  58. Console.WriteLine("SopInsUid:" + ds.GetDataElement(new gdcm.Tag(0x0008, 0x0018)).GetValue().toString());
  59. }

0 件のコメント :

コメントを投稿