}
String pid;
String styuid;
String seruid;
String iuid;
DicomInputStream din = null;
try {
din = new DicomInputStream(f);
din.setIncludeBulkData(IncludeBulkData.NO);
Attributes fmi = din.readFileMetaInformation();
Attributes dataset = din.readDataset(-1, Tag.StudyID);
iuid = (fmi != null)
? fmi.getString(Tag.MediaStorageSOPInstanceUID, null)
: dataset.getString(Tag.SOPInstanceUID, null);
if (iuid == null) {
System.out.println();
System.out.println(MessageFormat.format(
rb.getString("skip-file"), f));
return 0;
}
pid = dataset.getString(Tag.PatientID, null);
styuid = dataset.getString(Tag.StudyInstanceUID, null);
seruid = dataset.getString(Tag.SeriesInstanceUID, null);
} catch (IOException e) {
System.out.println();
System.out.println(
MessageFormat.format(rb.getString("failed-to-parse"),
f, e.getMessage()));
return 0;
} finally {
if (din != null)
try { din.close(); } catch (Exception ignore) {}
}
Attributes instRec;
if (styuid != null && seruid != null) {
Attributes patRec =
in.findPatientRecord(pid == null ? styuid : pid);