Mercurial > hg > orthanc
changeset 1676:f079f3efe33b db-changes
patient tags reported in studies
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 02 Oct 2015 17:09:18 +0200 |
parents | 131136aeeaa7 |
children | a903d57d9f0c |
files | OrthancServer/DicomProtocol/DicomServer.cpp OrthancServer/ServerIndex.cpp |
diffstat | 2 files changed, 64 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- 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<Internals::CommandDispatcher> 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<Internals::CommandDispatcher> 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(); + } }
--- 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,