File: TestFindStudyRootQuery.cxx

package info (click to toggle)
gdcm 3.0.21-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 26,880 kB
  • sloc: cpp: 203,477; ansic: 78,582; xml: 48,129; python: 3,459; cs: 2,308; java: 1,629; lex: 1,290; sh: 334; php: 128; makefile: 117
file content (218 lines) | stat: -rw-r--r-- 7,429 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/*=========================================================================

  Program: GDCM (Grassroots DICOM). A DICOM library

  Copyright (c) 2006-2011 Mathieu Malaterre
  All rights reserved.
  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
#include "gdcmFindStudyRootQuery.h"

#include "gdcmCompositeNetworkFunctions.h"
#include "gdcmTrace.h"

/*
 * STUDY:
 * $ findscu --call GDCM_STORE --aetitle GDCMDASH -P server 11112 -k 8,52="PATIENT" -k 10,20="1*"
 * $ findscu --call GDCM_STORE --aetitle GDCMDASH -S server 11112 -k 8,52="STUDY"   -k 10,20="FOO"
 *
 * SERIES:
 * $ findscu --call GDCM_STORE --aetitle GDCMDASH -S lirispat 11112 -k 8,52="SERIES" -k 20,d="1.2.3" -k 8,60 
 */

int TestFindStudyRootQuery(int , char *[])
{
  //gdcm::Trace::DebugOn();
  gdcm::Trace::WarningOff();

  // STUDY:
  gdcm::ERootType theRoot = gdcm::eStudyRootType;
  gdcm::EQueryLevel theLevel = gdcm::eStudy;

    {
    std::vector< std::pair<gdcm::Tag, std::string> > keys;
    gdcm::SmartPointer<gdcm::BaseRootQuery> theQuery =
      gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys);
    if( theQuery->ValidateQuery( true ) )
      {
      // No key found is an error
      return 1;
      }
    }
    {
    std::vector< std::pair<gdcm::Tag, std::string> > keys;
    keys.emplace_back( gdcm::Tag(0x10,0x10), "PATIENT" ) ;
    gdcm::SmartPointer<gdcm::BaseRootQuery> theQuery =
      gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys);
    if( theQuery->ValidateQuery( true ) )
      {
      // Patient Id is a Required Key in Study
      return 1;
      }
    }
    {
    std::vector< std::pair<gdcm::Tag, std::string> > keys;
    keys.emplace_back( gdcm::Tag(0x20,0x10), "studyid" ) ;
    gdcm::SmartPointer<gdcm::BaseRootQuery> theQuery =
      gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys);
    if( theQuery->ValidateQuery( true ) )
      {
      // Study Id is a required tag
      return 1;
      }
    }
    {
    std::vector< std::pair<gdcm::Tag, std::string> > keys;
    keys.emplace_back( gdcm::Tag(0x8,0x90), "physician" ) ;
    gdcm::SmartPointer<gdcm::BaseRootQuery> theQuery =
      gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys);
    if( theQuery->ValidateQuery( true ) )
      {
      // ref physician's name is optional
      return 1;
      }
    }
    {
    std::vector< std::pair<gdcm::Tag, std::string> > keys;
    keys.emplace_back( gdcm::Tag(0x20,0xd), "studyuid" ) ;
    gdcm::SmartPointer<gdcm::BaseRootQuery> theQuery =
      gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys);
    if( !theQuery->ValidateQuery( true ) )
      {
      // Study UID is the unique tag
      return 1;
      }
    }

  // SERIES:

  theLevel = gdcm::eSeries;

    {
    std::vector< std::pair<gdcm::Tag, std::string> > keys;
    gdcm::SmartPointer<gdcm::BaseRootQuery> theQuery =
      gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys);
    if( theQuery->ValidateQuery( true ) )
      {
      // No key found is an error
      return 1;
      }
    }
    {
    std::vector< std::pair<gdcm::Tag, std::string> > keys;
    keys.emplace_back( gdcm::Tag(0x20,0xd), "1.2.3" ) ;
    gdcm::SmartPointer<gdcm::BaseRootQuery> theQuery =
      gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys);
    if( theQuery->ValidateQuery( true ) )
      {
      // No key at level Series
      return 1;
      }
    }
    {
    std::vector< std::pair<gdcm::Tag, std::string> > keys;
    keys.emplace_back( gdcm::Tag(0x20,0xd), "1.2.3" ) ;
    keys.emplace_back( gdcm::Tag(0x8,0x60), "" ) ;
    gdcm::SmartPointer<gdcm::BaseRootQuery> theQuery =
      gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys);
    if( theQuery->ValidateQuery( true ) )
      {
      // missing unique at series level
      return 1;
      }
    }
    {
    std::vector< std::pair<gdcm::Tag, std::string> > keys;
    keys.emplace_back( gdcm::Tag(0x20,0xd), "1.2.3" ) ;
    keys.emplace_back( gdcm::Tag(0x20,0xe), "4.5.6" ) ;
    gdcm::SmartPointer<gdcm::BaseRootQuery> theQuery =
      gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys);
    if( !theQuery->ValidateQuery( true ) )
      {
      // all unique keys present
      return 1;
      }
    }
    {
    std::vector< std::pair<gdcm::Tag, std::string> > keys;
    keys.emplace_back( gdcm::Tag(0x20,0xd), "1.2.3" ) ;
    keys.emplace_back( gdcm::Tag(0x20,0xe), "4.5.6" ) ;
    keys.emplace_back( gdcm::Tag(0x8,0x60), "" ) ;
    gdcm::SmartPointer<gdcm::BaseRootQuery> theQuery =
      gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys);
    if( !theQuery->ValidateQuery( true ) )
      {
      // all unique keys present and required is correct level
      return 1;
      }
    }
    {
    std::vector< std::pair<gdcm::Tag, std::string> > keys;
    keys.emplace_back( gdcm::Tag(0x20,0xd), "1.2.3" ) ;
    keys.emplace_back( gdcm::Tag(0x20,0xe), "4.5.6" ) ;
    keys.emplace_back( gdcm::Tag(0x8,0x20), "" ) ;
    gdcm::SmartPointer<gdcm::BaseRootQuery> theQuery =
      gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys);
    if( theQuery->ValidateQuery( true ) )
      {
      // all unique keys present and required is incorrect level
      return 1;
      }
    }

  // IMAGES:

  theLevel = gdcm::eImage;
    {
    std::vector< std::pair<gdcm::Tag, std::string> > keys;
    keys.emplace_back( gdcm::Tag(0x20,0xd), "1.2.3" ) ;
    keys.emplace_back( gdcm::Tag(0x20,0xe), "4.5.6" ) ;
    keys.emplace_back( gdcm::Tag(0x8,0x18), "7.8.9" ) ;
    gdcm::SmartPointer<gdcm::BaseRootQuery> theQuery =
      gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys);
    if( !theQuery->ValidateQuery( true ) )
      {
      // all unique keys present
      return 1;
      }
    }

    {
    std::vector< std::pair<gdcm::Tag, std::string> > keys;
    keys.emplace_back( gdcm::Tag(0x20,0xd), "1.2.3" ) ;
    keys.emplace_back( gdcm::Tag(0x20,0xe), "4.5.6" ) ;
    keys.emplace_back( gdcm::Tag(0x8,0x18), "7.8.9" ) ;
    keys.emplace_back( gdcm::Tag(0x20,0x13), "" ) ;
    gdcm::SmartPointer<gdcm::BaseRootQuery> theQuery =
      gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys);
    if( !theQuery->ValidateQuery( true ) )
      {
      // all unique keys present + required correct level
      return 1;
      }
    }

    {
    std::vector< std::pair<gdcm::Tag, std::string> > keys;
    keys.emplace_back( gdcm::Tag(0x20,0xd), "1.2.3" ) ;
    keys.emplace_back( gdcm::Tag(0x20,0xe), "4.5.6" ) ;
    keys.emplace_back( gdcm::Tag(0x8,0x18), "7.8.9" ) ;
    keys.emplace_back( gdcm::Tag(0x20,0x13), "" ) ;
    keys.emplace_back( gdcm::Tag(0x20,0x11), "" ) ; // series level
    gdcm::SmartPointer<gdcm::BaseRootQuery> theQuery =
      gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys);
    if( theQuery->ValidateQuery( true ) )
      {
      // all unique keys present + required correct level + one incorrect
      return 1;
      }
    }

  //std::cout << "success" << std::endl;
  return 0;
}