/* * query the number instances of a series */ int query_series_instances(const std::string& studyinstanceuid, const std::string& seriesinstanceuid, const std::string& server, const std::string& local_aet) { DcmDataset query; DcmElement* e = NULL; e = newDicomElement(DCM_QueryRetrieveLevel); e->putString("IMAGE"); query.insert(e); e = newDicomElement(DCM_StudyInstanceUID); e->putString(studyinstanceuid.c_str()); query.insert(e); e = newDicomElement(DCM_SeriesInstanceUID); e->putString(seriesinstanceuid.c_str()); query.insert(e); e = newDicomElement(DCM_SOPInstanceUID); query.insert(e); e = newDicomElement(DCM_InstanceNumber); 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(); std::cout << "query_series_instances = " << result->card() << std::endl; return result->card(); }
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)); } }
inline void InsertTagRecord(const DcmTagKey& key, const std::string& value, DcmDirectoryRecord* record) { DcmTag tag(key); DcmElement* e = newDicomElement(tag); e->putString(value.c_str()); record->insert(e, true, false); }
/* * 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; }
/** Check whether given type 1 attribute is present and has a length > 0. * @param key - [in] The attribute tag check * @param targetDset - [out] targetDset * @param defaultValue - [in] value to be inserted if attribute is missing * (needs invent option for type 1 attributes enabled) * @return A string with an error message if attribute is not present * or has length of 0 */ OFString D2DCommon::checkAndInventType1Attrib(const DcmTagKey& key, DcmDataset* targetDset, const OFString& defaultValue) const { OFString err; OFBool exists = targetDset->tagExists(key); if (!exists) { OFString err = "Document2Dcm: Missing type 1 attribute: "; err += DcmTag(key).getTagName(); err += "\n"; return err; } DcmElement *elem; OFCondition cond = targetDset->findAndGetElement(key, elem); if (cond.bad() || !elem || (elem->getLength() == 0)) { if (!m_inventMissingType1Attribs) { err += "Document2Dcm: Empty value for type 1 attribute: "; err += DcmTag(key).getTagName(); err += "\n"; return err; } //holds element to insert in item DcmElement *elem = NULL; DcmTag tag(key); OFBool wasError = OFFalse; //if dicom element could be created, insert in to item and modify to value if (newDicomElement(elem, tag).good()) { if (targetDset->insert(elem, OFTrue).good()) { if (elem->putString(defaultValue.c_str()).good()) { if (m_debug) { OFString msg = "Document2Dcm: Inserting missing type 1 attribute "; msg += tag.getTagName(); msg += " with value "; msg += defaultValue; printMessage(m_logStream, msg); return err; } } else wasError = OFTrue; } else wasError = OFTrue; } else wasError = OFTrue; if (wasError) { err += "Unable to insert type 1 attribute "; err += tag.getTagName(); err += " with value "; err += defaultValue; err += "\n"; } } return err; }
DcmDataset* RetrieveDICOMFilesFromPACS::getDcmDatasetOfImagesToRetrieve(const QString &studyInstanceUID, const QString &seriesInstanceUID, const QString &sopInstanceUID) { DcmDataset *dcmDatasetToRetrieve = new DcmDataset(); QString retrieveLevel = "STUDY"; DcmElement *elemSpecificCharacterSet = newDicomElement(DCM_SpecificCharacterSet); // ISO_IR 100 és Latin1 elemSpecificCharacterSet->putString("ISO_IR 100"); dcmDatasetToRetrieve->insert(elemSpecificCharacterSet, OFTrue); DcmElement *elem = newDicomElement(DCM_StudyInstanceUID); elem->putString(qPrintable(studyInstanceUID)); dcmDatasetToRetrieve->insert(elem, OFTrue); if (!seriesInstanceUID.isEmpty()) { DcmElement *elem = newDicomElement(DCM_SeriesInstanceUID); elem->putString(qPrintable(seriesInstanceUID)); dcmDatasetToRetrieve->insert(elem, OFTrue); retrieveLevel = "SERIES"; } if (!sopInstanceUID.isEmpty()) { DcmElement *elem = newDicomElement(DCM_SOPInstanceUID); elem->putString(qPrintable(sopInstanceUID)); dcmDatasetToRetrieve->insert(elem, OFTrue); retrieveLevel = "IMAGE"; } // Especifiquem a quin nivell es fa el QueryRetrieve DcmElement *elemQueryRetrieveLevel = newDicomElement(DCM_QueryRetrieveLevel); elemQueryRetrieveLevel->putString(qPrintable(retrieveLevel)); dcmDatasetToRetrieve->insert(elemQueryRetrieveLevel, OFTrue); return dcmDatasetToRetrieve; }
void query_from_net( const std::string& patientid, const std::string& name, const std::string& modality, const std::string& date_from, const std::string& date_to, const std::string& studydescription, const std::string& accessionnumber, const std::string& local_aet, const std::set<std::string>& groups, const sigc::slot< void, const Glib::RefPtr< ImagePool::Study >& >& resultslot ) { // get encodings std::string dicom_enc = ImagePool::get_encoding(); std::string system_enc = ImagePool::get_system_encoding(dicom_enc); // create patientsname querystring std::string patientsname; if(name.empty()) { patientsname = "*"; } else { patientsname = convert_string_to(name.c_str(), system_enc); } std::string description; if(!studydescription.empty()) { description = convert_string_to(studydescription.c_str(), system_enc); } // create date querystring std::string date; if(date_from.empty() && date_to.empty()) { date = ""; } else if(date_to.empty()) { date = date_from + "-"; } else if(date_from.empty()) { date = "-" + date_to; } else { date = date_from + "-" + date_to; } if(date_from == date_to) { date = date_from; } /*std::string station; if(!stationname.empty()) { station = "*" + convert_string_to(stationname.c_str(), system_enc) + "*"; }*/ DcmDataset query; DcmElement* e = NULL; e = newDicomElement(DCM_QueryRetrieveLevel); e->putString("STUDY"); query.insert(e); e = newDicomElement(DCM_SpecificCharacterSet); e->putString(dicom_enc.c_str()); query.insert(e); e = newDicomElement(DCM_PatientsName); e->putString(patientsname.c_str()); query.insert(e); e = newDicomElement(DCM_PatientID); e->putString(convert_string_to(patientid.c_str(), system_enc).c_str()); query.insert(e); e = newDicomElement(DCM_SOPClassesInStudy); query.insert(e); e = newDicomElement(DCM_ModalitiesInStudy); e->putString(modality.c_str()); query.insert(e); e = newDicomElement(DCM_PatientsBirthDate); query.insert(e); e = newDicomElement(DCM_PatientsSex); query.insert(e); e = newDicomElement(DCM_StudyDate); e->putString(date.c_str()); query.insert(e); e = newDicomElement(DCM_StudyTime); query.insert(e); e = newDicomElement(DCM_NumberOfStudyRelatedSeries); query.insert(e); e = newDicomElement(DCM_NumberOfStudyRelatedInstances); query.insert(e); e = newDicomElement(DCM_AccessionNumber); e->putString(accessionnumber.c_str()); query.insert(e); e = newDicomElement(DCM_StudyID); query.insert(e); e = newDicomElement(DCM_StudyInstanceUID); query.insert(e); e = newDicomElement(DCM_StudyDescription); e->putString(description.c_str()); query.insert(e); // StationName not allowed in StudyRoot /*e = newDicomElement(DCM_StationName); e->putString(station.c_str()); query.insert(e);*/ std::cout << "NEW QUERY:" << std::endl; query.print(COUT); NetClient<FindAssociation> a; a.signal_server_result.connect(sigc::bind(sigc::ptr_fun(on_query_from_net_result), resultslot)); //std::set<std::string> groups = get_servergroups(); std::set<std::string>::iterator i = groups.begin(); // do we have groups defined ? if(groups.size() > 0) { while(i != groups.end()) { a.QueryServerGroup(&query, *i, local_aet, UID_FINDStudyRootQueryRetrieveInformationModel); i++; } } // no query all servers else { a.QueryServerGroup(&query, "", local_aet, UID_FINDStudyRootQueryRetrieveInformationModel); } }