DcmElement* DcmtkHelper::searchElement(DcmObject* _object, unsigned int _group, unsigned int _element) { try { if (_object == NULL) { throw DicomLibException("No data!", __FILE__, __LINE__); } DcmTagKey searchKey; searchKey.set(_group, _element); DcmStack stack; _object -> search(searchKey, stack, ESM_fromHere, OFTrue); DcmElement* element = NULL; element = reinterpret_cast<DcmElement*>(stack.elem(0)); return element; } catch (...) { throw; } }
void query_series_from_net(const std::string& studyinstanceuid, const std::string& server, const std::string& local_aet, const sigc::slot< void, const Glib::RefPtr< ImagePool::Series >& >& resultslot) { DcmDataset query; DcmElement* e = NULL; e = newDicomElement(DCM_QueryRetrieveLevel); e->putString("SERIES"); query.insert(e); e = newDicomElement(DCM_SpecificCharacterSet); query.insert(e); e = newDicomElement(DCM_StudyInstanceUID); e->putString(studyinstanceuid.c_str()); query.insert(e); e = newDicomElement(DCM_SeriesInstanceUID); query.insert(e); e = newDicomElement(DCM_SeriesNumber); query.insert(e); e = newDicomElement(DCM_Modality); query.insert(e); e = newDicomElement(DCM_SeriesDescription); query.insert(e); e = newDicomElement(DCM_SeriesTime); query.insert(e); e = newDicomElement(DCM_StationName); query.insert(e); e = newDicomElement(DCM_NumberOfSeriesRelatedInstances); query.insert(e); std::cout << "NEW QUERY:" << std::endl; query.print(COUT); NetClient<FindAssociation> a; a.QueryServer(&query, server, local_aet, UID_FINDStudyRootQueryRetrieveInformationModel); DcmStack* result = a.GetResultStack(); for(unsigned int i=0; i<result->card(); i++) { DcmDataset* dset = (DcmDataset*)result->elem(i); dset->print(COUT); resultslot(create_query_series(dset)); } }
/* * query all seriesinstanceuid's and the number series of a study */ int query_study_series(const std::string& studyinstanceuid, const std::string& server, const std::string& local_aet, std::list<std::string>& seriesinstanceuids) { DcmDataset query; DcmElement* e = NULL; e = newDicomElement(DCM_QueryRetrieveLevel); e->putString("SERIES"); query.insert(e); e = newDicomElement(DCM_StudyInstanceUID); e->putString(studyinstanceuid.c_str()); query.insert(e); e = newDicomElement(DCM_SeriesInstanceUID); query.insert(e); e = newDicomElement(DCM_SeriesNumber); query.insert(e); e = newDicomElement(DCM_Modality); query.insert(e); std::cout << "NEW QUERY:" << std::endl; query.print(COUT); NetClient<FindAssociation> a; a.QueryServer(&query, server, local_aet, UID_FINDStudyRootQueryRetrieveInformationModel); DcmStack* result = a.GetResultStack(); DcmDataset* dset; OFString ofstr; seriesinstanceuids.clear(); for(int i = 0; i < result->card(); i++) { dset = (DcmDataset*)result->elem(i); if(dset->findAndGetOFString(DCM_SeriesInstanceUID, ofstr).good()) { seriesinstanceuids.push_back(ofstr.c_str()); } } std::cout << result->card() << " Responses" << std::endl; int count = result->card(); return count; }