使用dcmtk查询worklist
DcmFindSCU findscu;
findscu.initializeNetwork(5);//初始化
OFList<OFString> overrideKeys;//在这个list中传入要查询的字段
OFCharacterEncoding encoding;
encoding.selectEncoding("","UTF-8");
OFString patientName;
encoding.convertString("PatientName=张三",patientName);//将要查询的字段名和值用等号连接,中文转码查询
overrideKeys.push_back(patientName);
overrideKeys.push_back("SpecificCharacterSet=ISO_IR 192");
overrideKeys.push_back("ScheduledProcedureStepSequence[0].ScheduledProcedureStepStartDate=20231116");//部分字段需使用这种方法,具体有哪些字段可查询dicom标准
findscu.performQuery(...);//调用该方法并传入对应参数即可查询worklist
//需要定义一个回调来接收查询到的数据,将这个回调传入findscu.performQuery();
class TestFindSCUCallback : public DcmFindSCUCallback {
public:
// 默认构造函数
TestFindSCUCallback();
// 析构函数
virtual ~TestFindSCUCallback();
// 实现回调函数
virtual void callback(T_DIMSE_C_FindRQ* request, int& responseCount, T_DIMSE_C_FindRSP* rsp, DcmDataset* responseIdentifiers);
// 设置关联对象
void setAssociation(T_ASC_Association* assoc);
// 设置呈现上下文ID
void setPresentationContextID(T_ASC_PresentationContextID presId);
private:
// 禁用复制构造函数和赋值运算符
TestFindSCUCallback(const TestFindSCUCallback& other);
TestFindSCUCallback& operator=(const TestFindSCUCallback& other);
// 添加其他私有成员或方法,如果有的话
};
void TestFindSCUCallback::callback(T_DIMSE_C_FindRQ* request, int& responseCount, T_DIMSE_C_FindRSP* rsp, DcmDataset* dataset) {
OFCondition r = dataset->convertCharacterSet("ISO_IR 192", "GB18030");//中文编码转换
OFString patientName;
if (dataset->findAndGetOFString(DCM_PatientName, patientName).good()) {
std::cout << "patientName: " << patientName << std::endl;
}
DcmItem* list = NULL;
if (dataset->findAndGetSequenceItem(DCM_ScheduledProcedureStepSequence, list).good())
{
OFString StartDate = "";
if (list->findAndGetOFString(DCM_ScheduledProcedureStepStartDate, StartDate).good())
{
}
}
}