# HG changeset patch # User Sebastien Jodogne # Date 1383837928 -3600 # Node ID 41b3e5ccb2918d89f95c08b8e3ca3b9b0615cdb8 # Parent 855adbdd75a613cf932d4fd5eab8d56cb6c0c331 fix for medInria diff -r 855adbdd75a6 -r 41b3e5ccb291 NEWS --- a/NEWS Wed Nov 06 17:20:31 2013 +0100 +++ b/NEWS Thu Nov 07 16:25:28 2013 +0100 @@ -2,6 +2,7 @@ =============================== +* Support of Query/Retrieve from medInria * Accept more transfer syntaxes for C-Store SCP and SCU (notably JPEG) * Create the meta-header when receiving files through C-Store SCP * Fixes and improvements thanks to the static analyzer cppcheck diff -r 855adbdd75a6 -r 41b3e5ccb291 OrthancServer/DicomProtocol/IFindRequestHandler.h --- a/OrthancServer/DicomProtocol/IFindRequestHandler.h Wed Nov 06 17:20:31 2013 +0100 +++ b/OrthancServer/DicomProtocol/IFindRequestHandler.h Thu Nov 07 16:25:28 2013 +0100 @@ -48,6 +48,7 @@ } virtual void Handle(DicomFindAnswers& answers, - const DicomMap& input) = 0; + const DicomMap& input, + const std::string& callingAETitle) = 0; }; } diff -r 855adbdd75a6 -r 41b3e5ccb291 OrthancServer/Internals/CommandDispatcher.cpp --- a/OrthancServer/Internals/CommandDispatcher.cpp Wed Nov 06 17:20:31 2013 +0100 +++ b/OrthancServer/Internals/CommandDispatcher.cpp Thu Nov 07 16:25:28 2013 +0100 @@ -238,6 +238,7 @@ if (server.HasMoveRequestHandlerFactory()) { knownAbstractSyntaxes.push_back(UID_MOVEStudyRootQueryRetrieveInformationModel); + knownAbstractSyntaxes.push_back(UID_MOVEPatientRootQueryRetrieveInformationModel); } cond = ASC_receiveAssociation(net, &assoc, @@ -266,13 +267,12 @@ std::vector transferSyntaxes; -#if 0 // This is the list of the transfer syntaxes that were supported up to Orthanc 0.7.1 transferSyntaxes.push_back(UID_LittleEndianExplicitTransferSyntax); transferSyntaxes.push_back(UID_BigEndianExplicitTransferSyntax); transferSyntaxes.push_back(UID_LittleEndianImplicitTransferSyntax); -#else - transferSyntaxes.push_back(UID_LittleEndianImplicitTransferSyntax); + + // New transfer syntaxes supported since Orthanc 0.7.2 transferSyntaxes.push_back(UID_DeflatedExplicitVRLittleEndianTransferSyntax); transferSyntaxes.push_back(UID_JPEGProcess1TransferSyntax); transferSyntaxes.push_back(UID_JPEGProcess2_4TransferSyntax); @@ -303,7 +303,6 @@ transferSyntaxes.push_back(UID_MPEG2MainProfileAtMainLevelTransferSyntax); transferSyntaxes.push_back(UID_MPEG2MainProfileAtHighLevelTransferSyntax); transferSyntaxes.push_back(UID_RLELosslessTransferSyntax); -#endif /* accept the Verification SOP Class if presented */ cond = ASC_acceptContextsWithPreferredTransferSyntaxes( assoc->params, &knownAbstractSyntaxes[0], knownAbstractSyntaxes.size(), &transferSyntaxes[0], transferSyntaxes.size()); @@ -580,7 +579,7 @@ { std::auto_ptr handler (server_.GetFindRequestHandlerFactory().ConstructFindRequestHandler()); - cond = Internals::findScp(assoc_, &msg, presID, *handler); + cond = Internals::findScp(assoc_, &msg, presID, *handler, callingAETitle_); } break; @@ -595,6 +594,8 @@ // Bad status, which indicates the closing of the connection by // the peer or a network error finished = true; + + LOG(ERROR) << cond.text(); } if (finished) diff -r 855adbdd75a6 -r 41b3e5ccb291 OrthancServer/Internals/FindScp.cpp --- a/OrthancServer/Internals/FindScp.cpp Wed Nov 06 17:20:31 2013 +0100 +++ b/OrthancServer/Internals/FindScp.cpp Thu Nov 07 16:25:28 2013 +0100 @@ -49,6 +49,7 @@ DicomMap input_; DicomFindAnswers answers_; DcmDataset* lastRequest_; + const std::string* callingAETitle_; }; @@ -74,7 +75,7 @@ try { - data.handler_->Handle(data.answers_, data.input_); + data.handler_->Handle(data.answers_, data.input_, *data.callingAETitle_); } catch (OrthancException& e) { @@ -112,11 +113,13 @@ OFCondition Internals::findScp(T_ASC_Association * assoc, T_DIMSE_Message * msg, T_ASC_PresentationContextID presID, - IFindRequestHandler& handler) + IFindRequestHandler& handler, + const std::string& callingAETitle) { FindScpData data; data.lastRequest_ = NULL; data.handler_ = &handler; + data.callingAETitle_ = &callingAETitle; OFCondition cond = DIMSE_findProvider(assoc, presID, &msg->msg.CFindRQ, FindScpCallback, &data, diff -r 855adbdd75a6 -r 41b3e5ccb291 OrthancServer/Internals/FindScp.h --- a/OrthancServer/Internals/FindScp.h Wed Nov 06 17:20:31 2013 +0100 +++ b/OrthancServer/Internals/FindScp.h Thu Nov 07 16:25:28 2013 +0100 @@ -43,6 +43,7 @@ OFCondition findScp(T_ASC_Association * assoc, T_DIMSE_Message * msg, T_ASC_PresentationContextID presID, - IFindRequestHandler& handler); + IFindRequestHandler& handler, + const std::string& callingAETitle); } } diff -r 855adbdd75a6 -r 41b3e5ccb291 OrthancServer/OrthancFindRequestHandler.cpp --- a/OrthancServer/OrthancFindRequestHandler.cpp Wed Nov 06 17:20:31 2013 +0100 +++ b/OrthancServer/OrthancFindRequestHandler.cpp Thu Nov 07 16:25:28 2013 +0100 @@ -314,7 +314,8 @@ static void LookupCandidateResources(/* out */ std::list& resources, /* in */ ServerIndex& index, /* in */ ResourceType level, - /* in */ const DicomMap& query) + /* in */ const DicomMap& query, + /* in */ ModalityManufacturer manufacturer) { // TODO : Speed up using full querying against the MainDicomTags. @@ -337,7 +338,22 @@ break; case ResourceType_Instance: - done = LookupCandidateResourcesInternal(resources, index, level, query, DICOM_TAG_SOP_INSTANCE_UID); + if (manufacturer == ModalityManufacturer_MedInria) + { + std::list series; + + if (LookupCandidateResourcesInternal(series, index, ResourceType_Series, query, DICOM_TAG_SERIES_INSTANCE_UID) && + series.size() == 1) + { + index.GetChildInstances(resources, series.front()); + done = true; + } + } + else + { + done = LookupCandidateResourcesInternal(resources, index, level, query, DICOM_TAG_SOP_INSTANCE_UID); + } + break; default: @@ -359,9 +375,27 @@ void OrthancFindRequestHandler::Handle(DicomFindAnswers& answers, - const DicomMap& input) + const DicomMap& input, + const std::string& callingAETitle) { /** + * Retrieve the manufacturer of this modality. + **/ + + ModalityManufacturer manufacturer; + + { + std::string symbolicName, address; + int port; + + if (!LookupDicomModalityUsingAETitle(callingAETitle, symbolicName, address, port, manufacturer)) + { + throw OrthancException("Unknown modality"); + } + } + + + /** * Retrieve the query level. **/ @@ -373,11 +407,19 @@ ResourceType level = StringToResourceType(levelTmp->AsString().c_str()); - if (level != ResourceType_Patient && - level != ResourceType_Study && - level != ResourceType_Series) + switch (manufacturer) { - throw OrthancException(ErrorCode_NotImplemented); + case ModalityManufacturer_MedInria: + // MedInria makes FIND requests at the instance level before starting MOVE + break; + + default: + if (level != ResourceType_Patient && + level != ResourceType_Study && + level != ResourceType_Series) + { + throw OrthancException(ErrorCode_NotImplemented); + } } @@ -389,7 +431,7 @@ **/ std::list resources; - LookupCandidateResources(resources, context_.GetIndex(), level, input); + LookupCandidateResources(resources, context_.GetIndex(), level, input, manufacturer); /** diff -r 855adbdd75a6 -r 41b3e5ccb291 OrthancServer/OrthancFindRequestHandler.h --- a/OrthancServer/OrthancFindRequestHandler.h Wed Nov 06 17:20:31 2013 +0100 +++ b/OrthancServer/OrthancFindRequestHandler.h Thu Nov 07 16:25:28 2013 +0100 @@ -49,6 +49,7 @@ } virtual void Handle(DicomFindAnswers& answers, - const DicomMap& input); + const DicomMap& input, + const std::string& callingAETitle); }; } diff -r 855adbdd75a6 -r 41b3e5ccb291 OrthancServer/ServerEnumerations.cpp --- a/OrthancServer/ServerEnumerations.cpp Wed Nov 06 17:20:31 2013 +0100 +++ b/OrthancServer/ServerEnumerations.cpp Thu Nov 07 16:25:28 2013 +0100 @@ -248,6 +248,9 @@ case ModalityManufacturer_ClearCanvas: return "ClearCanvas"; + case ModalityManufacturer_MedInria: + return "MedInria"; + default: throw OrthancException(ErrorCode_ParameterOutOfRange); } @@ -296,6 +299,10 @@ { return ModalityManufacturer_ClearCanvas; } + else if (manufacturer == "MedInria") + { + return ModalityManufacturer_MedInria; + } else { throw OrthancException(ErrorCode_ParameterOutOfRange); diff -r 855adbdd75a6 -r 41b3e5ccb291 OrthancServer/ServerEnumerations.h --- a/OrthancServer/ServerEnumerations.h Wed Nov 06 17:20:31 2013 +0100 +++ b/OrthancServer/ServerEnumerations.h Thu Nov 07 16:25:28 2013 +0100 @@ -56,7 +56,8 @@ enum ModalityManufacturer { ModalityManufacturer_Generic, - ModalityManufacturer_ClearCanvas + ModalityManufacturer_ClearCanvas, + ModalityManufacturer_MedInria }; enum DicomRequestType diff -r 855adbdd75a6 -r 41b3e5ccb291 Resources/Configuration.json --- a/Resources/Configuration.json Wed Nov 06 17:20:31 2013 +0100 +++ b/Resources/Configuration.json Thu Nov 07 16:25:28 2013 +0100 @@ -100,8 +100,8 @@ /** * A fourth parameter is available to enable patches for a * specific PACS manufacturer. The allowed values are currently - * "Generic" (default value) and "ClearCanvas". This parameter is - * case-sensitive. + * "Generic" (default value), "ClearCanvas" and "MedInria". This + * parameter is case-sensitive. **/ // "clearcanvas" : [ "CLEARCANVAS", "192.168.1.1", 104, "ClearCanvas" ] },