comparison OrthancServer/main.cpp @ 559:e0cfb413c86b find-move-scp

find scp
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 18 Sep 2013 16:22:21 +0200
parents c9a5d72f8481
children c931ac02db82
comparison
equal deleted inserted replaced
556:b26a7c397c34 559:e0cfb413c86b
85 85
86 virtual void Handle(const DicomMap& input, 86 virtual void Handle(const DicomMap& input,
87 DicomFindAnswers& answers) 87 DicomFindAnswers& answers)
88 { 88 {
89 LOG(WARNING) << "Find-SCU request received"; 89 LOG(WARNING) << "Find-SCU request received";
90 DicomArray a(input); 90
91 a.Print(stdout); 91 /**
92 * Retrieve the query level.
93 **/
94
95 const DicomValue* levelTmp = input.TestAndGetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL);
96 if (levelTmp == NULL)
97 {
98 throw OrthancException(ErrorCode_BadRequest);
99 }
100
101 ResourceType level = StringToResourceType(levelTmp->AsString().c_str());
102
103 if (level != ResourceType_Patient &&
104 level != ResourceType_Study &&
105 level != ResourceType_Series)
106 {
107 throw OrthancException(ErrorCode_NotImplemented);
108 }
109
110
111 /**
112 * Retrieve the constraints of the query.
113 **/
114
115 DicomArray query(input);
116
117 DicomMap constraintsTmp;
118 DicomMap wildcardConstraintsTmp;
119
120 for (size_t i = 0; i < query.GetSize(); i++)
121 {
122 if (!query.GetElement(i).GetValue().IsNull() &&
123 query.GetElement(i).GetTag() != DICOM_TAG_QUERY_RETRIEVE_LEVEL &&
124 query.GetElement(i).GetTag() != DICOM_TAG_SPECIFIC_CHARACTER_SET)
125 {
126 DicomTag tag = query.GetElement(i).GetTag();
127 std::string value = query.GetElement(i).GetValue().AsString();
128
129 if (value.find('*') != std::string::npos ||
130 value.find('?') != std::string::npos ||
131 value.find('\\') != std::string::npos ||
132 value.find('-') != std::string::npos)
133 {
134 wildcardConstraintsTmp.SetValue(tag, value);
135 }
136 else
137 {
138 constraintsTmp.SetValue(tag, value);
139 }
140 }
141 }
142
143 DicomArray constraints(constraintsTmp);
144 DicomArray wildcardConstraints(wildcardConstraintsTmp);
145
146 // http://www.itk.org/Wiki/DICOM_QueryRetrieve_Explained
147 // http://dicomiseasy.blogspot.be/2012/01/dicom-queryretrieve-part-i.html
148
149 constraints.Print(stdout);
150 printf("\n"); fflush(stdout);
151 wildcardConstraints.Print(stdout);
152 printf("\n"); fflush(stdout);
92 } 153 }
93 }; 154 };
94 155
95 156
96 class MyMoveRequestHandler : public IMoveRequestHandler 157 class MyMoveRequestHandler : public IMoveRequestHandler
367 context.GetIndex().SetMaximumStorageSize(0); 428 context.GetIndex().SetMaximumStorageSize(0);
368 } 429 }
369 430
370 MyDicomServerFactory serverFactory(context); 431 MyDicomServerFactory serverFactory(context);
371 432
372
373 { 433 {
374 // DICOM server 434 // DICOM server
375 DicomServer dicomServer; 435 DicomServer dicomServer;
376 dicomServer.SetCalledApplicationEntityTitleCheck(GetGlobalBoolParameter("DicomCheckCalledAet", false)); 436 dicomServer.SetCalledApplicationEntityTitleCheck(GetGlobalBoolParameter("DicomCheckCalledAet", false));
377 dicomServer.SetStoreRequestHandlerFactory(serverFactory); 437 dicomServer.SetStoreRequestHandlerFactory(serverFactory);
378 //dicomServer.SetMoveRequestHandlerFactory(serverFactory); 438 dicomServer.SetMoveRequestHandlerFactory(serverFactory);
379 //dicomServer.SetFindRequestHandlerFactory(serverFactory); 439 dicomServer.SetFindRequestHandlerFactory(serverFactory);
380 dicomServer.SetPortNumber(GetGlobalIntegerParameter("DicomPort", 4242)); 440 dicomServer.SetPortNumber(GetGlobalIntegerParameter("DicomPort", 4242));
381 dicomServer.SetApplicationEntityTitle(GetGlobalStringParameter("DicomAet", "ORTHANC")); 441 dicomServer.SetApplicationEntityTitle(GetGlobalStringParameter("DicomAet", "ORTHANC"));
382 442
383 // HTTP server 443 // HTTP server
384 MyIncomingHttpRequestFilter httpFilter(context); 444 MyIncomingHttpRequestFilter httpFilter(context);