# HG changeset patch # User Sebastien Jodogne # Date 1443798558 -7200 # Node ID f079f3efe33b726962f4aea8c57173e3ca9aa070 # Parent 131136aeeaa7175cfd26b69dd88f7faddebf3f9d patient tags reported in studies diff -r 131136aeeaa7 -r f079f3efe33b OrthancServer/DicomProtocol/DicomServer.cpp --- a/OrthancServer/DicomProtocol/DicomServer.cpp Fri Oct 02 13:57:54 2015 +0200 +++ b/OrthancServer/DicomProtocol/DicomServer.cpp Fri Oct 02 17:09:18 2015 +0200 @@ -61,48 +61,48 @@ void DicomServer::ServerThread(DicomServer* server, T_ASC_Network *network) { - LOG(INFO) << "DICOM server started"; + LOG(INFO) << "DICOM server started"; - while (server->continue_) + while (server->continue_) + { + /* receive an association and acknowledge or reject it. If the association was */ + /* acknowledged, offer corresponding services and invoke one or more if required. */ + std::auto_ptr dispatcher(Internals::AcceptAssociation(*server, network)); + + try { - /* receive an association and acknowledge or reject it. If the association was */ - /* acknowledged, offer corresponding services and invoke one or more if required. */ - std::auto_ptr dispatcher(Internals::AcceptAssociation(*server, network)); - - try + if (dispatcher.get() != NULL) { - if (dispatcher.get() != NULL) + if (server->isThreaded_) { - if (server->isThreaded_) - { - server->bagOfDispatchers_.Add(dispatcher.release()); - } - else - { - IRunnableBySteps::RunUntilDone(*dispatcher); - } + server->bagOfDispatchers_.Add(dispatcher.release()); + } + else + { + IRunnableBySteps::RunUntilDone(*dispatcher); } } - catch (OrthancException& e) - { - LOG(ERROR) << "Exception in the DICOM server thread: " << e.What(); - } } - - LOG(INFO) << "DICOM server stopping"; - - if (server->isThreaded_) + catch (OrthancException& e) { - server->bagOfDispatchers_.StopAll(); + LOG(ERROR) << "Exception in the DICOM server thread: " << e.What(); } + } + + LOG(INFO) << "DICOM server stopping"; - /* drop the network, i.e. free memory of T_ASC_Network* structure. This call */ - /* is the counterpart of ASC_initializeNetwork(...) which was called above. */ - OFCondition cond = ASC_dropNetwork(&network); - if (cond.bad()) - { - LOG(ERROR) << "Error while dropping the network: " << cond.text(); - } + if (server->isThreaded_) + { + server->bagOfDispatchers_.StopAll(); + } + + /* drop the network, i.e. free memory of T_ASC_Network* structure. This call */ + /* is the counterpart of ASC_initializeNetwork(...) which was called above. */ + OFCondition cond = ASC_dropNetwork(&network); + if (cond.bad()) + { + LOG(ERROR) << "Error while dropping the network: " << cond.text(); + } } diff -r 131136aeeaa7 -r f079f3efe33b OrthancServer/ServerIndex.cpp --- a/OrthancServer/ServerIndex.cpp Fri Oct 02 13:57:54 2015 +0200 +++ b/OrthancServer/ServerIndex.cpp Fri Oct 02 17:09:18 2015 +0200 @@ -881,8 +881,38 @@ { DicomMap tags; db_.GetMainDicomTags(tags, resourceId); - target["MainDicomTags"] = Json::objectValue; - FromDcmtkBridge::ToJson(target["MainDicomTags"], tags, true); + + if (resourceType == ResourceType_Study) + { + DicomMap t1, t2; + tags.ExtractStudyInformation(t1); + tags.ExtractPatientInformation(t2); + + target["MainDicomTags"] = Json::objectValue; + FromDcmtkBridge::ToJson(target["MainDicomTags"], t1, true); + + target["PatientMainDicomTags"] = Json::objectValue; + FromDcmtkBridge::ToJson(target["PatientMainDicomTags"], t2, true); + + int64_t patient; + if (!db_.LookupParent(patient, resourceId)) + { + throw OrthancException(ErrorCode_InternalError); + } + + tags.Clear(); + db_.GetMainDicomTags(tags, patient); + + if (tags.HasTag(DICOM_TAG_PATIENT_ID)) + { + target["PatientMainDicomTags"]["PatientID"] = tags.GetValue(DICOM_TAG_PATIENT_ID).AsString(); + } + } + else + { + target["MainDicomTags"] = Json::objectValue; + FromDcmtkBridge::ToJson(target["MainDicomTags"], tags, true); + } } bool ServerIndex::LookupResource(Json::Value& result,