The Element and Group for Patient ID is 0x0010, 0x0020. You can foreach through the elements as you are, and stop the iteration when you find the values you're looking for.
string tag = "";
string op = "";
string val_rep = "";
string war = "";
if (DicomFile.IsDicomFile(f))
{
Sequence se = plik.GetJointDataSets().GetJointSubsequences();
foreach (DataElement el in se)
{
if (el.Tag.Element == "0010" && el.Tag.Group == "0020")
{
tag = el.Tag.ToString(); //tag group and element
op = el.VR.Tag.GetDictionaryEntry().Description;//tag description
val_rep = el.VR.ToString();//value representative
war = el.Value.ToString();//
break;
}
}
}
That should set the tag
, op
, val_rep
, and war
variables for you when it finds the Patient ID tag, and then break out of the foreach.
As I've mentioned several times on here, I'm not incredibly well versed with the openDicom library, but assuming the rest of your code is correct this should get you what you want. The openDICOM documentation for the Group and Element properties of the Tag class are somewhat strange, "Element is a hexadecimal string value of format 'eeee'.", so I'm assuming here that the compared values should be in that format, but there's a small possibility that the formatting won't be correct.
I will say that if you are just learning C#, and DICOM isn't something that you're being forced to do, find something easier to start with, because learning to use the DICOM standard can be at LEAST as confusing as learning a new programming language, and combining them at the same time is something I wouldn't recommend to ANYONE.