Mercurial > hg > orthanc
diff 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 |
line wrap: on
line diff
--- a/OrthancServer/main.cpp Wed Sep 18 15:27:07 2013 +0200 +++ b/OrthancServer/main.cpp Wed Sep 18 16:22:21 2013 +0200 @@ -87,8 +87,69 @@ DicomFindAnswers& answers) { LOG(WARNING) << "Find-SCU request received"; - DicomArray a(input); - a.Print(stdout); + + /** + * Retrieve the query level. + **/ + + const DicomValue* levelTmp = input.TestAndGetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL); + if (levelTmp == NULL) + { + throw OrthancException(ErrorCode_BadRequest); + } + + ResourceType level = StringToResourceType(levelTmp->AsString().c_str()); + + if (level != ResourceType_Patient && + level != ResourceType_Study && + level != ResourceType_Series) + { + throw OrthancException(ErrorCode_NotImplemented); + } + + + /** + * Retrieve the constraints of the query. + **/ + + DicomArray query(input); + + DicomMap constraintsTmp; + DicomMap wildcardConstraintsTmp; + + for (size_t i = 0; i < query.GetSize(); i++) + { + if (!query.GetElement(i).GetValue().IsNull() && + query.GetElement(i).GetTag() != DICOM_TAG_QUERY_RETRIEVE_LEVEL && + query.GetElement(i).GetTag() != DICOM_TAG_SPECIFIC_CHARACTER_SET) + { + DicomTag tag = query.GetElement(i).GetTag(); + std::string value = query.GetElement(i).GetValue().AsString(); + + if (value.find('*') != std::string::npos || + value.find('?') != std::string::npos || + value.find('\\') != std::string::npos || + value.find('-') != std::string::npos) + { + wildcardConstraintsTmp.SetValue(tag, value); + } + else + { + constraintsTmp.SetValue(tag, value); + } + } + } + + DicomArray constraints(constraintsTmp); + DicomArray wildcardConstraints(wildcardConstraintsTmp); + + // http://www.itk.org/Wiki/DICOM_QueryRetrieve_Explained + // http://dicomiseasy.blogspot.be/2012/01/dicom-queryretrieve-part-i.html + + constraints.Print(stdout); + printf("\n"); fflush(stdout); + wildcardConstraints.Print(stdout); + printf("\n"); fflush(stdout); } }; @@ -369,14 +430,13 @@ MyDicomServerFactory serverFactory(context); - { // DICOM server DicomServer dicomServer; dicomServer.SetCalledApplicationEntityTitleCheck(GetGlobalBoolParameter("DicomCheckCalledAet", false)); dicomServer.SetStoreRequestHandlerFactory(serverFactory); - //dicomServer.SetMoveRequestHandlerFactory(serverFactory); - //dicomServer.SetFindRequestHandlerFactory(serverFactory); + dicomServer.SetMoveRequestHandlerFactory(serverFactory); + dicomServer.SetFindRequestHandlerFactory(serverFactory); dicomServer.SetPortNumber(GetGlobalIntegerParameter("DicomPort", 4242)); dicomServer.SetApplicationEntityTitle(GetGlobalStringParameter("DicomAet", "ORTHANC"));