I am working on a program where the User inputs a Patient Name and if that patient name exists and matches the one in the dataset, it will fetch the details. Else, it won't. The DICOM file I had was anonymized so, I input few details on my own.
The following is the code.
char UID[100];
DcmFileFormat dfile;
DcmDataset* dataset = dfile.getDataset();
DcmObject* dset = &dfile;
if (readMode == ERM_autoDetect) dset = dfile.getDataset();
OFCondition status = dfile.loadFile("E:\\Aditya\\Telerad\\DICOMImages\\Img25.dcm");
dataset->putAndInsertString(DCM_StudyDate, "19-01-2013");
dataset->putAndInsertString(DCM_Manufacturer, "Philips Healthcare");
dataset->putAndInsertString(DCM_PatientName, "Adi");
dataset->putAndInsertString(DCM_PatientID, "0024");
dataset->putAndInsertString(DCM_PatientSex, "Male");
dataset->putAndInsertString(DCM_PatientAge, "20 Years");
dataset->putAndInsertString(DCM_PatientWeight, "65 Kilograms");
OFString studyDate;
OFString Modality;
OFString Manufacturer;
OFString PhotometricInterpretation;
OFString patientName;
OFString patientID;
OFString patientSex;
OFString patientAge;
OFString patientWeight;
char main();
std::cout << "Please enter Patient Name: ";
char patName = getchar();
std::getchar();
std::cin >> patName;
if (status.good())
{
if (patName == patientName)
{
if (dfile.getDataset()->findAndGetOFStringArray(DCM_StudyDate, studyDate).good())
{
COUT << "Study Date:" << studyDate << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_Modality, Modality).good())
{
COUT << "Modality: " << Modality << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_Manufacturer, Manufacturer).good())
{
COUT << "Manufacturer: " << Manufacturer << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_PhotometricInterpretation, PhotometricInterpretation).good())
{
COUT << "Photometric Interpretation: " << PhotometricInterpretation << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_PatientName, patientName).good())
{
COUT << "Patient Name: " << patientName << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_PatientID, patientID).good())
{
COUT << "Patient ID: " << patientID << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_PatientSex, patientSex).good())
{
COUT << "Patient Sex: " << patientSex << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_PatientAge, patientAge).good())
{
COUT << "Patient Age: " << patientAge << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_PatientWeight, patientWeight).good())
{
COUT << "Patient Weight: " << patientWeight << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
}
else {
CERR << "Cannot get the required Dataset/Patient Details." << OFendl;
}
}
exit(0);
The issue I am having is that, irrespective of what value/text I enter I am getting, "Cannot get the required Dataset/Patient Details.". Please guide and help me in next steps.
I am a beginner at this. Please bear with me.
Thanks,
Aditya
Fetching Patient Details
Moderator: Moderator Team
-
- DCMTK Developer
- Posts: 2049
- Joined: Fri, 2004-11-05, 13:47
- Location: Oldenburg, Germany
- Contact:
Re: Fetching Patient Details
Hi,
the variable patientName is not set at all, is it?
To try the rest of your code, maybe just turn "if (patName == patientName)" into "if (true)" for a test run.
Best regards,
Michael
the variable patientName is not set at all, is it?
To try the rest of your code, maybe just turn "if (patName == patientName)" into "if (true)" for a test run.
Best regards,
Michael
-
- Posts: 3
- Joined: Wed, 2019-06-05, 09:21
Re: Fetching Patient Details
Hey,
Yes, I made the changes as suggested by you. Unlike before, it is printing the required Patient Dataset/Details.
However, this happens regardless of what input is entered.
What is needed is ->
The Patient Name is set to "Adi" as an example.
So, only when "Adi" is entered by the user should it print out the Patient Dataset/Details.
Else, it should print out the message, "Cannot get the required Dataset/Patient Details." as the name entered by the user does not match the one in the Dataset (Adi).
Please help with further steps.
Thanks for responding, Michael.
Warm regards,
Aditya
Yes, I made the changes as suggested by you. Unlike before, it is printing the required Patient Dataset/Details.
However, this happens regardless of what input is entered.
What is needed is ->
The Patient Name is set to "Adi" as an example.
So, only when "Adi" is entered by the user should it print out the Patient Dataset/Details.
Else, it should print out the message, "Cannot get the required Dataset/Patient Details." as the name entered by the user does not match the one in the Dataset (Adi).
Please help with further steps.
Thanks for responding, Michael.
Warm regards,
Aditya
Last edited by aditya.nireesh on Thu, 2019-06-06, 06:52, edited 1 time in total.
-
- DCMTK Developer
- Posts: 2049
- Joined: Fri, 2004-11-05, 13:47
- Location: Oldenburg, Germany
- Contact:
Re: Fetching Patient Details
Hi Aditya,
the reason is still the same I guess: You do not set any value in patientName, so it is empty all the time. Maybe you want to add the line
before the first if statement?
Also, I don't know getchar() but maybe you want to use getline() instead? (why you use getchar() twice, by the way? the second in the form of std::getchar() probably does nothing?)
Best regards,
Michael
the reason is still the same I guess: You do not set any value in patientName, so it is empty all the time. Maybe you want to add the line
Code: Select all
dataset->findAndGetOFStringArray(DCM_PatientName, patientName)
Also, I don't know getchar() but maybe you want to use getline() instead? (why you use getchar() twice, by the way? the second in the form of std::getchar() probably does nothing?)
Best regards,
Michael
-
- Posts: 3
- Joined: Wed, 2019-06-05, 09:21
Re: Fetching Patient Details
Hi Michael,
Thank you for replying. I have arrived at the desired result, thought I'll share it here.
So, the issue was, patientName had no value in the code I shared earlier. It was empty and had not been set as you had asked me earlier.
And, I couldn't use 'getLine()' for some reason although the respective and necessary libraries were mentioned.
Anyhow, given below is the working/corrected code.
Thanks for your guidance, Michael.
char UID[100];
DcmFileFormat dfile;
DcmDataset* dataset = dfile.getDataset();
DcmObject* dset = &dfile;
if (readMode == ERM_autoDetect) dset = dfile.getDataset();
OFCondition status = dfile.loadFile("E:\\Aditya\\Telerad\\DICOMImages\\Img25.dcm");
dataset->putAndInsertString(DCM_StudyDate, "19-01-2013");
dataset->putAndInsertString(DCM_Manufacturer, "Philips Healthcare");
dataset->putAndInsertString(DCM_PatientName, "Adi");
dataset->putAndInsertString(DCM_PatientID, "0024");
dataset->putAndInsertString(DCM_PatientSex, "Male");
dataset->putAndInsertString(DCM_PatientAge, "20 Years");
dataset->putAndInsertString(DCM_PatientWeight, "65 Kilograms");
OFString studyDate;
OFString Modality;
OFString Manufacturer;
OFString PhotometricInterpretation;
OFString patientName;
if (dfile.getDataset()->findAndGetOFStringArray(DCM_PatientName, patientName).good());
OFString patientID;
OFString patientSex;
OFString patientAge;
OFString patientWeight;
char main();
std::cout << "Please enter Patient Name: ";
std::string patName;
std::cin >> patName;
if (status.good())
{
if (OFString(patName.c_str())==(patientName))
{
if (dfile.getDataset()->findAndGetOFStringArray(DCM_StudyDate, studyDate).good())
{
COUT << "Study Date:" << studyDate << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_Modality, Modality).good())
{
COUT << "Modality: " << Modality << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_Manufacturer, Manufacturer).good())
{
COUT << "Manufacturer: " << Manufacturer << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_PhotometricInterpretation, PhotometricInterpretation).good())
{
COUT << "Photometric Interpretation: " << PhotometricInterpretation << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_PatientName, patientName).good())
{
COUT << "Patient Name: " << patientName << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_PatientID, patientID).good())
{
COUT << "Patient ID: " << patientID << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_PatientSex, patientSex).good())
{
COUT << "Patient Sex: " << patientSex << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_PatientAge, patientAge).good())
{
COUT << "Patient Age: " << patientAge << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_PatientWeight, patientWeight).good())
{
COUT << "Patient Weight: " << patientWeight << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
}
else {
CERR << "Cannot get the required Dataset/Patient Details." << OFendl;
}
}
exit(0);
}
Thanks,
Aditya
Thank you for replying. I have arrived at the desired result, thought I'll share it here.
So, the issue was, patientName had no value in the code I shared earlier. It was empty and had not been set as you had asked me earlier.
And, I couldn't use 'getLine()' for some reason although the respective and necessary libraries were mentioned.
Anyhow, given below is the working/corrected code.
Thanks for your guidance, Michael.
char UID[100];
DcmFileFormat dfile;
DcmDataset* dataset = dfile.getDataset();
DcmObject* dset = &dfile;
if (readMode == ERM_autoDetect) dset = dfile.getDataset();
OFCondition status = dfile.loadFile("E:\\Aditya\\Telerad\\DICOMImages\\Img25.dcm");
dataset->putAndInsertString(DCM_StudyDate, "19-01-2013");
dataset->putAndInsertString(DCM_Manufacturer, "Philips Healthcare");
dataset->putAndInsertString(DCM_PatientName, "Adi");
dataset->putAndInsertString(DCM_PatientID, "0024");
dataset->putAndInsertString(DCM_PatientSex, "Male");
dataset->putAndInsertString(DCM_PatientAge, "20 Years");
dataset->putAndInsertString(DCM_PatientWeight, "65 Kilograms");
OFString studyDate;
OFString Modality;
OFString Manufacturer;
OFString PhotometricInterpretation;
OFString patientName;
if (dfile.getDataset()->findAndGetOFStringArray(DCM_PatientName, patientName).good());
OFString patientID;
OFString patientSex;
OFString patientAge;
OFString patientWeight;
char main();
std::cout << "Please enter Patient Name: ";
std::string patName;
std::cin >> patName;
if (status.good())
{
if (OFString(patName.c_str())==(patientName))
{
if (dfile.getDataset()->findAndGetOFStringArray(DCM_StudyDate, studyDate).good())
{
COUT << "Study Date:" << studyDate << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_Modality, Modality).good())
{
COUT << "Modality: " << Modality << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_Manufacturer, Manufacturer).good())
{
COUT << "Manufacturer: " << Manufacturer << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_PhotometricInterpretation, PhotometricInterpretation).good())
{
COUT << "Photometric Interpretation: " << PhotometricInterpretation << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_PatientName, patientName).good())
{
COUT << "Patient Name: " << patientName << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_PatientID, patientID).good())
{
COUT << "Patient ID: " << patientID << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_PatientSex, patientSex).good())
{
COUT << "Patient Sex: " << patientSex << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_PatientAge, patientAge).good())
{
COUT << "Patient Age: " << patientAge << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
if (dfile.getDataset()->findAndGetOFStringArray(DCM_PatientWeight, patientWeight).good())
{
COUT << "Patient Weight: " << patientWeight << OFendl;
}
else {
CERR << "This tag is not available in the Image Dataset." << OFendl;
}
}
else {
CERR << "Cannot get the required Dataset/Patient Details." << OFendl;
}
}
exit(0);
}
Thanks,
Aditya
Who is online
Users browsing this forum: No registered users and 1 guest