private void openForReadOnly(File file) throws IOException { this.file = file; in = new DicomDirReader(file); }
protected boolean findNextPatient() throws IOException { if (patRec == null) patRec = ddr.findPatientRecord(keys, recFact, ignoreCaseOfPN, matchNoValue); else if (patIDs.length == 1) patRec = null; else patRec = ddr.findNextPatientRecord(patRec, keys, recFact, ignoreCaseOfPN, matchNoValue); return patRec != null; } }
protected boolean findNextSeries() throws IOException { if (studyRec == null) return false; if (seriesRec == null) seriesRec = ddr.findSeriesRecord(studyRec, keys, recFact, ignoreCaseOfPN, matchNoValue); else if (seriesIUIDs.length == 1) seriesRec = null; else seriesRec = ddr.findNextSeriesRecord(seriesRec, keys, recFact, ignoreCaseOfPN, matchNoValue); while (seriesRec == null && super.findNextStudy()) seriesRec = ddr.findSeriesRecord(studyRec, keys, recFact, ignoreCaseOfPN, matchNoValue); return seriesRec != null; } }
protected boolean findNextStudy() throws IOException { if (patRec == null) return false; if (studyRec == null) studyRec = ddr.findStudyRecord(patRec, keys, recFact, ignoreCaseOfPN, matchNoValue); else if (studyIUIDs.length == 1) studyRec = null; else studyRec = ddr.findNextStudyRecord(studyRec, keys, recFact, ignoreCaseOfPN, matchNoValue); while (studyRec == null && super.findNextPatient()) studyRec = ddr.findStudyRecord(patRec, keys, recFact, ignoreCaseOfPN, matchNoValue); return studyRec != null; } }
Attributes eventInfo = new Attributes(6); eventInfo.setString(Tag.RetrieveAETitle, VR.AE, calledAET); eventInfo.setString(Tag.StorageMediaFileSetID, VR.SH, ddReader.getFileSetID()); eventInfo.setString(Tag.StorageMediaFileSetUID, VR.SH, ddReader.getFileSetUID()); eventInfo.setString(Tag.TransactionUID, VR.UI, actionInfo.getString(Tag.TransactionUID)); Sequence successSeq = eventInfo.newSequence(Tag.ReferencedSOPSequence, size); Attributes patRec = ddr.findPatientRecord(); while (patRec != null) { Attributes studyRec = ddr.findStudyRecord(patRec); while (studyRec != null) { Attributes seriesRec = ddr.findSeriesRecord(studyRec); while (seriesRec != null) { Attributes instRec = ddr.findLowerInstanceRecord(seriesRec, true, sopIUIDs); while (instRec != null) { String iuid = instRec.getString(Tag.ReferencedSOPInstanceUIDInFile); else failedSeq.add(refSOP(iuid, cuid, Status.ClassInstanceConflict)); instRec = ddr.findNextInstanceRecord(instRec, true, sopIUIDs); seriesRec = ddr.findNextSeriesRecord(seriesRec); studyRec = ddr.findNextStudyRecord(studyRec); patRec = ddr.findNextPatientRecord(patRec);
String[] sopIUIDs = keys.getStrings(Tag.SOPInstanceUID); DicomDirReader ddr = ddReader; Attributes patRec = ddr.findPatientRecord(patIDs); while (patRec != null) { Attributes studyRec = ddr.findStudyRecord(patRec, studyIUIDs); while (studyRec != null) { Attributes seriesRec = ddr.findSeriesRecord(studyRec, seriesIUIDs); while (seriesRec != null) { Attributes instRec = ddr.findLowerInstanceRecord(seriesRec, true, sopIUIDs); while (instRec != null) { String cuid = instRec.getString(Tag.ReferencedSOPClassUIDInFile); String tsuid = instRec.getString(Tag.ReferencedTransferSyntaxUIDInFile); String[] fileIDs = instRec.getStrings(Tag.ReferencedFileID); String uri = ddr.toFile(fileIDs).toURI().toString(); list.add(new InstanceLocator(cuid, iuid, tsuid, uri)); if (sopIUIDs != null && sopIUIDs.length == 1) break; instRec = ddr.findNextInstanceRecord(instRec, true, sopIUIDs); seriesRec = ddr.findNextSeriesRecord(seriesRec, seriesIUIDs); studyRec = ddr.findNextStudyRecord(studyRec, studyIUIDs); patRec = ddr.findNextPatientRecord(patRec, patIDs);
if (styuid != null && seruid != null) { Attributes patRec = in.findPatientRecord(pid == null ? styuid : pid); if (patRec == null) { return 0; Attributes studyRec = in.findStudyRecord(patRec, styuid); if (studyRec == null) { return 0; Attributes seriesRec = in.findSeriesRecord(studyRec, seruid); if (seriesRec == null) { return 0; instRec = in.findLowerInstanceRecord(seriesRec, false, iuid); } else { instRec = in.findRootInstanceRecord(false, iuid);
private void compact(File f, File bak) throws IOException { File tmp = File.createTempFile("DICOMDIR", null, f.getParentFile()); DicomDirReader r = new DicomDirReader(f); try { fsInfo.setFilesetUID(r.getFileSetUID()); fsInfo.setFilesetID(r.getFileSetID()); fsInfo.setDescriptorFile( r.getDescriptorFile()); fsInfo.setDescriptorFileCharset( r.getDescriptorFileCharacterSet()); create(tmp); copyFrom(r); } finally { close(); try { r.close(); } catch (IOException ignore) {} } bak.delete(); rename(f, bak); rename(tmp, f); }
private void list(Attributes rec, StringBuilder index) throws IOException { int indexLen = index.length(); int i = 1; while (rec != null) { index.append(i++).append('.'); list(heading(rec, index), rec); list(inUse ? in.findLowerDirectoryRecordInUse(rec, false) : in.readLowerDirectoryRecord(rec), index); rec = inUse ? in.findNextDirectoryRecordInUse(rec, false) : in.readNextDirectoryRecord(rec); index.setLength(indexLen); }; }
private void list() throws IOException { checkIn(); list("File Meta Information:", in.getFileMetaInformation()); list("File-set Information:", in.getFileSetInformation()); list(inUse ? in.findFirstRootDirectoryRecordInUse(false) : in.readFirstRootDirectoryRecord(), new StringBuilder()); }
private void copyFrom(DicomDirReader r) throws IOException { Attributes rec = r.findFirstRootDirectoryRecordInUse(false); while (rec != null) { copyChildsFrom(r, rec, out.addRootDirectoryRecord(new Attributes(rec))); rec = r.findNextDirectoryRecordInUse(rec, false); } }
private void copyChildsFrom(DicomDirReader r, Attributes src, Attributes dst) throws IOException { Attributes rec = r.findLowerDirectoryRecordInUse(src, false); while (rec != null) { copyChildsFrom(r, rec, out.addLowerDirectoryRecord(dst, new Attributes(rec))); rec = r.findNextDirectoryRecordInUse(rec, false); } }
@Override protected Attributes adjust(Attributes match) { Attributes adjust = super.adjust(match); adjust.remove(Tag.DirectoryRecordType); if (keys.contains(Tag.SOPClassUID)) adjust.setString(Tag.SOPClassUID, VR.UI, match.getString(Tag.ReferencedSOPClassUIDInFile)); if (keys.contains(Tag.SOPInstanceUID)) adjust.setString(Tag.SOPInstanceUID, VR.UI, match.getString(Tag.ReferencedSOPInstanceUIDInFile)); adjust.setString(Tag.QueryRetrieveLevel, VR.CS, keys.getString(Tag.QueryRetrieveLevel)); adjust.setString(Tag.RetrieveAETitle, VR.AE, as.getCalledAET()); if (availability != null) adjust.setString(Tag.InstanceAvailability, VR.CS, availability); adjust.setString(Tag.StorageMediaFileSetID, VR.SH, ddr.getFileSetID()); adjust.setString(Tag.StorageMediaFileSetUID, VR.UI, ddr.getFileSetUID()); match.setString(Tag.SOPClassUID, VR.UI, match.getString(Tag.ReferencedSOPClassUIDInFile)); match.setString(Tag.SOPInstanceUID, VR.UI, match.getString(Tag.ReferencedSOPInstanceUIDInFile)); if (delayCFind > 0) try { Thread.sleep(delayCFind); } catch (InterruptedException ignore) {} return adjust; }
protected boolean findNextInstance() throws IOException { if (seriesRec == null) return false; if (instRec == null) instRec = ddr.findLowerInstanceRecord(seriesRec, keys, recFact, ignoreCaseOfPN, matchNoValue); else if (sopIUIDs.length == 1) instRec = null; else instRec = ddr.findNextInstanceRecord(instRec, keys, recFact, ignoreCaseOfPN, matchNoValue); while (instRec == null && super.findNextSeries()) instRec = ddr.findLowerInstanceRecord(seriesRec, keys, recFact, ignoreCaseOfPN, matchNoValue); return instRec != null; } }
public synchronized Attributes findOrAddSeriesRecord(Attributes studyRec, Attributes rec) throws IOException { Attributes seriesRec = super.findSeriesRecord(studyRec, rec.getString(Tag.SeriesInstanceUID)); return seriesRec != null ? seriesRec : addLowerDirectoryRecord(studyRec, rec); }
public synchronized Attributes findOrAddPatientRecord(Attributes rec) throws IOException { Attributes patRec = super.findPatientRecord(rec.getString(Tag.PatientID)); return patRec != null ? patRec : addRootDirectoryRecord(rec); }
public synchronized Attributes findOrAddStudyRecord(Attributes patRec, Attributes rec) throws IOException { Attributes studyRec = super.findStudyRecord(patRec, rec.getString(Tag.StudyInstanceUID)); return studyRec != null ? studyRec : addLowerDirectoryRecord(patRec, rec); }
private Attributes findFirstRootDirectoryRecordInUse(DicomDirReader reader) { try { return reader.findFirstRootDirectoryRecordInUse(true); } catch (IOException e) { LOGGER.error("Cannot find Patient in DICOMDIR !", e); //$NON-NLS-1$ } return null; }
private Attributes findFirstChildRecord(Attributes dcmObject, DicomDirReader reader) { try { return reader.findLowerDirectoryRecordInUse(dcmObject, true); } catch (IOException e) { LOGGER.error("Cannot read first DICOMDIR entry!", e); //$NON-NLS-1$ } return null; }
private Attributes findNextSiblingRecord(Attributes dcmObject, DicomDirReader reader) { try { return reader.findNextDirectoryRecordInUse(dcmObject, true); } catch (IOException e) { LOGGER.error("Cannot read next DICOMDIR entry!", e); //$NON-NLS-1$ } return null; }