Logo Search packages:      
Sourcecode: pixelmed version File versions  Download package

void com::pixelmed::dicom::DicomDirectory::addAttributeListFromDicomFileToDirectory ( AttributeList  list,
String  fileName 
) throws DicomException, IOException [inline, private]

Parameters:
list 
fileName 
Exceptions:
DicomException 

Definition at line 372 of file DicomDirectory.java.

References com::pixelmed::dicom::Attribute::addValue(), findAttributeAndIfPresentAddToDifferentAttributeList(), findAttributeAndIfPresentAddToDifferentAttributeListElseAddEmpty(), findAttributeAndIfPresentWithValueAddToDifferentAttributeList(), findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(), findExistingDirectoryRecordOrMakeNewOne(), com::pixelmed::dicom::DicomDirectoryRecord::getAttributeList(), com::pixelmed::dicom::DicomDirectoryRecordFactory::getNewEncapsulatedDocumentDirectoryRecord(), com::pixelmed::dicom::DicomDirectoryRecordFactory::getNewFiducialDirectoryRecord(), com::pixelmed::dicom::DicomDirectoryRecordFactory::getNewImageDirectoryRecord(), com::pixelmed::dicom::DicomDirectoryRecordFactory::getNewKODocumentDirectoryRecord(), com::pixelmed::dicom::DicomDirectoryRecordFactory::getNewPatientDirectoryRecord(), com::pixelmed::dicom::DicomDirectoryRecordFactory::getNewPresentationStateDirectoryRecord(), com::pixelmed::dicom::DicomDirectoryRecordFactory::getNewRawDataDirectoryRecord(), com::pixelmed::dicom::DicomDirectoryRecordFactory::getNewRealWorldValueMappingDirectoryRecord(), com::pixelmed::dicom::DicomDirectoryRecordFactory::getNewRegistrationDirectoryRecord(), com::pixelmed::dicom::DicomDirectoryRecordFactory::getNewRTDoseDirectoryRecord(), com::pixelmed::dicom::DicomDirectoryRecordFactory::getNewRTPlanDirectoryRecord(), com::pixelmed::dicom::DicomDirectoryRecordFactory::getNewRTStructureSetDirectoryRecord(), com::pixelmed::dicom::DicomDirectoryRecordFactory::getNewRTTreatmentRecordDirectoryRecord(), com::pixelmed::dicom::DicomDirectoryRecordFactory::getNewSeriesDirectoryRecord(), com::pixelmed::dicom::DicomDirectoryRecordFactory::getNewSpectroscopyDirectoryRecord(), com::pixelmed::dicom::DicomDirectoryRecordFactory::getNewSRDocumentDirectoryRecord(), com::pixelmed::dicom::DicomDirectoryRecordFactory::getNewStereometricRelationshipDirectoryRecord(), com::pixelmed::dicom::DicomDirectoryRecordFactory::getNewStudyDirectoryRecord(), com::pixelmed::dicom::DicomDirectoryRecordFactory::getNewWaveformDirectoryRecord(), com::pixelmed::dicom::AttributeList::put(), and com::pixelmed::dicom::DicomDirectoryRecord::setParent().

Referenced by readDicomFileAndAddToDirectory().

                                                                                                                                   {
System.err.println("DicomDirectory adding "+fileName);
            DicomDirectoryRecordFactory.PatientDirectoryRecord patientDirectoryRecord;
            {
                  AttributeList recordList = new AttributeList();
                  findAttributeAndIfPresentAddToDifferentAttributeListElseAddEmpty(TagFromName.PatientName,list,recordList);              // should probably trim trailing carets etc as in dcdirmk :(
                  findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.PatientID,list,recordList,"000000");
                  findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.PatientBirthDate,list,recordList);            // (DVD:1C if present with value in image)
                  findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.PatientSex,list,recordList);                        // (DVD:1C if present with value in image)
                  
                  { AttributeTag t = TagFromName.DirectoryRecordType; Attribute a = new CodeStringAttribute(t); a.addValue(DicomDirectoryRecordType.patient); recordList.put(t,a); }
                  
                  findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.SpecificCharacterSet,list,recordList);
                  { AttributeTag t = TagFromName.NextDirectoryRecordOffset; Attribute a = new UnsignedLongAttribute(t); a.addValue(0); recordList.put(t,a); }
                  { AttributeTag t = TagFromName.LowerLevelDirectoryOffset; Attribute a = new UnsignedLongAttribute(t); a.addValue(0); recordList.put(t,a); }
                  { AttributeTag t = TagFromName.RecordInUseFlag; Attribute a = new UnsignedShortAttribute(t); a.addValue(0xffff); recordList.put(t,a); }
                  
                  patientDirectoryRecord = nodeFactory.getNewPatientDirectoryRecord(null,recordList);
                  patientDirectoryRecord = (DicomDirectoryRecordFactory.PatientDirectoryRecord)findExistingDirectoryRecordOrMakeNewOne(root,patientDirectoryRecord);
//System.err.println("DicomDirectory.readDicomFileAndAddToDirectory(): PatientDirectoryRecord = "+patientDirectoryRecord);
            }

            DicomDirectoryRecordFactory.StudyDirectoryRecord studyDirectoryRecord;
            {
                  AttributeList recordList = new AttributeList();
                  findAttributeAndIfPresentAddToDifferentAttributeList(TagFromName.StudyInstanceUID,list,recordList);
                  findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.StudyID,list,recordList,"000000");
                  findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.StudyDate,list,recordList,"19000101");
                  findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.StudyTime,list,recordList,"000000");
                  findAttributeAndIfPresentAddToDifferentAttributeListElseAddEmpty(TagFromName.StudyDescription,list,recordList);
                  findAttributeAndIfPresentAddToDifferentAttributeListElseAddEmpty(TagFromName.AccessionNumber,list,recordList);
                  
                  { AttributeTag t = TagFromName.DirectoryRecordType; Attribute a = new CodeStringAttribute(t); a.addValue(DicomDirectoryRecordType.study); recordList.put(t,a); }
                  
                  findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.SpecificCharacterSet,list,recordList);
                  { AttributeTag t = TagFromName.NextDirectoryRecordOffset; Attribute a = new UnsignedLongAttribute(t); a.addValue(0); recordList.put(t,a); }
                  { AttributeTag t = TagFromName.LowerLevelDirectoryOffset; Attribute a = new UnsignedLongAttribute(t); a.addValue(0); recordList.put(t,a); }
                  { AttributeTag t = TagFromName.RecordInUseFlag; Attribute a = new UnsignedShortAttribute(t); a.addValue(0xffff); recordList.put(t,a); }
                  
                  studyDirectoryRecord = nodeFactory.getNewStudyDirectoryRecord(null,recordList);
                  studyDirectoryRecord = (DicomDirectoryRecordFactory.StudyDirectoryRecord)findExistingDirectoryRecordOrMakeNewOne(patientDirectoryRecord,studyDirectoryRecord);
//System.err.println("DicomDirectory.readDicomFileAndAddToDirectory(): StudyDirectoryRecord = "+studyDirectoryRecord);
            }

            DicomDirectoryRecordFactory.SeriesDirectoryRecord seriesDirectoryRecord;
            {
                  AttributeList recordList = new AttributeList();
                  findAttributeAndIfPresentAddToDifferentAttributeList(TagFromName.SeriesInstanceUID,list,recordList);
                  findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.Modality,list,recordList,"OT");
                  findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.SeriesNumber,list,recordList,"0");
                  findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.SeriesDate,list,recordList);
                  findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.SeriesTime,list,recordList);
                  findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.SeriesDescription,list,recordList);
                  
                  findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.InstitutionName,list,recordList);                   // (DVD:1C if present with value in image)
                  findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.InstitutionAddress,list,recordList);                // (DVD:1C if present with value in image)
                  findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.PerformingPhysicianName,list,recordList);           // (DVD:1C if present with value in image)
                  
                  { AttributeTag t = TagFromName.DirectoryRecordType; Attribute a = new CodeStringAttribute(t); a.addValue(DicomDirectoryRecordType.series); recordList.put(t,a); }
                  
                  findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.SpecificCharacterSet,list,recordList);
                  { AttributeTag t = TagFromName.NextDirectoryRecordOffset; Attribute a = new UnsignedLongAttribute(t); a.addValue(0); recordList.put(t,a); }
                  { AttributeTag t = TagFromName.LowerLevelDirectoryOffset; Attribute a = new UnsignedLongAttribute(t); a.addValue(0); recordList.put(t,a); }
                  { AttributeTag t = TagFromName.RecordInUseFlag; Attribute a = new UnsignedShortAttribute(t); a.addValue(0xffff); recordList.put(t,a); }
                  
                  seriesDirectoryRecord = nodeFactory.getNewSeriesDirectoryRecord(null,recordList);
                  seriesDirectoryRecord = (DicomDirectoryRecordFactory.SeriesDirectoryRecord)findExistingDirectoryRecordOrMakeNewOne(studyDirectoryRecord,seriesDirectoryRecord);
//System.err.println("DicomDirectory.readDicomFileAndAddToDirectory(): SeriesDirectoryRecord = "+seriesDirectoryRecord);
            }
            
            String sopClassUID = Attribute.getSingleStringValueOrEmptyString(list,TagFromName.SOPClassUID);
            String sopInstanceUID = Attribute.getSingleStringValueOrEmptyString(list,TagFromName.SOPInstanceUID);
            String transferSyntaxUID = Attribute.getSingleStringValueOrEmptyString(list,TagFromName.TransferSyntaxUID);
            {
                  AttributeList recordList = new AttributeList();
                  findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.InstanceNumber,list,recordList,"0");  // Type 1 in images, SR, KO, RT dose and most others (Type 2 in raw data)
                  
                  String directoryRecordType = "";
                  if (SOPClass.isImageStorage(sopClassUID)) {
                        directoryRecordType = DicomDirectoryRecordType.image;
                  
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.ContentDate,list,recordList);                                   // optional
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.ContentTime,list,recordList);                                   // optional

                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.ImageComments,list,recordList);                           // optional
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.PhotometricInterpretation,list,recordList);         // optional
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.AcquisitionDate,list,recordList);                         // optional
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.AcquisitionTime,list,recordList);                         // optional
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.VolumetricProperties,list,recordList);              // optional
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.VolumeBasedCalculationTechnique,list,recordList);   // optional
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.ComplexImageComponent,list,recordList);             // optional
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.AcquisitionContrast,list,recordList);                     // optional
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.PixelPresentation,list,recordList);                       // optional
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.ConcatenationUID,list,recordList);                        // optional
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.ConcatenationFrameOffsetNumber,list,recordList);    // optional
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.InConcatenationNumber,list,recordList);             // optional
            
                        // could try and extract ImagePositionPatient, ImageOrientationPatient and PixelSpacing from within SharedFunctionalGroupsSequence :(
                        
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.ImageType,list,recordList,"UNKNOWN"); // (XABC-CD,XA1K-CD:1); (DVD:1C if present with value in image)
                        findAttributeAndIfPresentAddToDifferentAttributeListElseAddEmpty(TagFromName.CalibrationImage,list,recordList);                           // (XABC-CD,XA1K-CD:2); (DVD:1C if present with value in image)
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.ReferencedImageSequence,list,recordList);                       // (XABC-CD,XA1K-CD:1C if ImageType value 3 is BIPLANE A or B); (CTMR:1C if present in image); (DVD:1C if present with value in image)
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.ImagePositionPatient,list,recordList);                    // (CTMR:1C if present in image); (DVD:1C if present with value in image)
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.ImageOrientationPatient,list,recordList);                       // (CTMR:1C if present in image); (DVD:1C if present with value in image)
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.FrameOfReferenceUID,list,recordList);                           // (CTMR:1C if present in image)
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.PixelSpacing,list,recordList);                                  // (CTMR:1C if present in image); (DVD:1C if present with value in image)
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.TableHeight,list,recordList);                                         // (CTMR:1C if present in image)
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.Rows,list,recordList);                                                // (CTMR:1); (DVD:1)
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.Columns,list,recordList);                                             // (CTMR:1); (DVD:1)
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.LossyImageCompressionRatio,list,recordList);              // (DVD:1C if present with value in image)
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.SynchronizationFrameOfReferenceUID,list,recordList);      // (DVD:1C if present with value in image)
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.NumberOfFrames,list,recordList);                                // (DVD:1C if present with value in image)
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.AcquisitionTimeSynchronized,list,recordList);             // (DVD:1C if present with value in image)
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.AcquisitionDateTime,list,recordList);                           // (DVD:1C if present with value in image)
                  }
                  else if (SOPClass.isSpectroscopy(sopClassUID)) {
                        directoryRecordType = DicomDirectoryRecordType.spectroscopy;
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.ImageType,list,recordList,"UNKNOWN");       // Type 1
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.ContentDate,list,recordList,"19000101");    // Type 1
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.ContentTime,list,recordList,"000000");            // Type 1
                        findAttributeAndIfPresentAddToDifferentAttributeList(TagFromName.ReferencedImageEvidenceSequence,list,recordList);                              // Type 1C
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.NumberOfFrames,list,recordList);                                      // Type 1 but no reasonable default
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.Rows,list,recordList);                                                      // Type 1 but no reasonable default
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.Columns,list,recordList);                                                   // Type 1 but no reasonable default
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.DataPointRows,list,recordList);                                       // Type 1 but no reasonable default
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.DataPointColumns,list,recordList);                                    // Type 1 but no reasonable default
                  }
                  else if (SOPClass.isRawData(sopClassUID)) {
                        directoryRecordType = DicomDirectoryRecordType.rawData;
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.ContentDate,list,recordList,"19000101");    // Type 1
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.ContentTime,list,recordList,"000000");            // Type 1
                  }
                  else if (SOPClass.isStructuredReport(sopClassUID)) {
                        if (SOPClass.isKeyObjectSelectionDocument(sopClassUID)) {
                              directoryRecordType = DicomDirectoryRecordType.keyObjectDocument;
                        }
                        else {
                              directoryRecordType = DicomDirectoryRecordType.srDocument;
                              findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.CompletionFlag,list,recordList,"PARTIAL");        // Type 1 in SR but not KO
                              findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.VerificationFlag,list,recordList,"UNVERIFIED");   // Type 1 in SR but not KO
                        }
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.ContentDate,list,recordList,"19000101");          // Type 1
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.ContentTime,list,recordList,"000000");                  // Type 1
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.VerificationDateTime,list,recordList);                                // Type 1C
                        findAttributeAndIfPresentAddToDifferentAttributeList(TagFromName.ConceptNameCodeSequence,list,recordList);                                            // Type 1
                        // Should also do ContentSequence with HAS CONCEPT MOD Relationship Type :(
                  }
                  else if (SOPClass.isEncapsulatedDocument(sopClassUID)) {
                        directoryRecordType = DicomDirectoryRecordType.encapsulatedDocument;
                        findAttributeAndIfPresentAddToDifferentAttributeListElseAddEmpty(TagFromName.ContentDate,list,recordList);                                                                          // Type 2
                        findAttributeAndIfPresentAddToDifferentAttributeListElseAddEmpty(TagFromName.ContentTime,list,recordList);                                                                          // Type 2
                        findAttributeAndIfPresentAddToDifferentAttributeListElseAddEmpty(TagFromName.DocumentTitle,list,recordList);                                                                        // Type 2
                        findAttributeAndIfPresentAddToDifferentAttributeList(TagFromName.HL7InstanceIdentifier,list,recordList);                                                                            // Type 1C
                        findAttributeAndIfPresentAddToDifferentAttributeList(TagFromName.ConceptNameCodeSequence,list,recordList);                                                                          // Type 2
                        String defaultMimeType = sopClassUID.equals(SOPClass.EncapsulatedPDFStorage) ? "application/pdf" : (sopClassUID.equals(SOPClass.EncapsulatedCDAStorage) ? "text/XML" : "application/octet-stream");
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.MIMETypeOfEncapsulatedDocument,list,recordList,defaultMimeType);    // Type 1
                  }
                  else if (SOPClass.isPresentationState(sopClassUID)) {
                        directoryRecordType = DicomDirectoryRecordType.presentationState;
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.PresentationCreationDate,list,recordList,"19000101");   // Type 1
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.PresentationCreationTime,list,recordList,"000000");           // Type 1
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.ContentLabel,list,recordList,"NONE");                         // Type 1
                        findAttributeAndIfPresentAddToDifferentAttributeListElseAddEmpty(TagFromName.ContentDescription,list,recordList);                                           // Type 2
                        findAttributeAndIfPresentAddToDifferentAttributeListElseAddEmpty(TagFromName.ContentCreatorsName,list,recordList);                                                // Type 2
                        findAttributeAndIfPresentAddToDifferentAttributeList(TagFromName.ContentCreatorsIdentificationCodeSequence,list,recordList);                          // Type 3
                        findAttributeAndIfPresentAddToDifferentAttributeList(TagFromName.ReferencedSeriesSequence,list,recordList);                                                       // Type 1C
                        findAttributeAndIfPresentAddToDifferentAttributeList(TagFromName.BlendingSequence,list,recordList);                                                                     // Type 1C
                  }
                  else if (sopClassUID.equals(SOPClass.SpatialRegistrationStorage)
                         || sopClassUID.equals(SOPClass.DeformableSpatialRegistrationStorage)
                         || sopClassUID.equals(SOPClass.SpatialFiducialsStorage)
                         ||  sopClassUID.equals(SOPClass.RealWorldValueMappingStorage)) {
                        directoryRecordType = sopClassUID.equals(SOPClass.SpatialFiducialsStorage)
                              ? DicomDirectoryRecordType.fiducial
                              : (sopClassUID.equals(SOPClass.RealWorldValueMappingStorage)
                                    ? DicomDirectoryRecordType.realWorldValueMapping
                                    : DicomDirectoryRecordType.registration);
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.ContentDate,list,recordList,"19000101");                // Type 1
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.ContentTime,list,recordList,"000000");                        // Type 1
                        // all use Content Identification Macro ...
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.ContentLabel,list,recordList,"NONE");                   // Type 1
                        findAttributeAndIfPresentAddToDifferentAttributeListElseAddEmpty(TagFromName.ContentDescription,list,recordList);                                     // Type 2
                        findAttributeAndIfPresentAddToDifferentAttributeListElseAddEmpty(TagFromName.ContentCreatorsName,list,recordList);                                          // Type 2
                        findAttributeAndIfPresentAddToDifferentAttributeList(TagFromName.ContentCreatorsIdentificationCodeSequence,list,recordList);                    // Type 3
                  }
                  else if (sopClassUID.equals(SOPClass.StereometricRelationshipStorage)) {
                        directoryRecordType = DicomDirectoryRecordType.stereometricRelationship;
                  }
                  else if (sopClassUID.equals(SOPClass.RTDoseStorage)) {
                        directoryRecordType = DicomDirectoryRecordType.rtDose;
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.DoseSummationType,list,recordList,"UNKNOWN");           // Type 1
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.DoseComment,list,recordList);                                                           // Type 3
                  }
                  else if (sopClassUID.equals(SOPClass.RTStructureSetStorage)) {
                        directoryRecordType = DicomDirectoryRecordType.rtStructureSet;
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.StructureSetLabel,list,recordList,"NONE");              // Type 1
                        findAttributeAndIfPresentAddToDifferentAttributeListElseAddEmpty(TagFromName.StructureSetDate,list,recordList);                                             // Type 2
                        findAttributeAndIfPresentAddToDifferentAttributeListElseAddEmpty(TagFromName.StructureSetTime,list,recordList);                                             // Type 2
                  }
                  else if (sopClassUID.equals(SOPClass.RTPlanStorage) || sopClassUID.equals(SOPClass.RTIonPlanStorage)) {
                        directoryRecordType = DicomDirectoryRecordType.rtPlan;
                        findAttributeAndIfPresentWithValueAddToDifferentAttributeListElseAddDefault(TagFromName.RTPlanLabel,list,recordList,"NONE");                    // Type 1
                        findAttributeAndIfPresentAddToDifferentAttributeListElseAddEmpty(TagFromName.RTPlanDate,list,recordList);                                                   // Type 2
                        findAttributeAndIfPresentAddToDifferentAttributeListElseAddEmpty(TagFromName.RTPlanTime,list,recordList);                                                   // Type 2
                  }
                  else if (sopClassUID.equals(SOPClass.RTBeamsTreatmentRecordStorage)
                          || sopClassUID.equals(SOPClass.RTIonBeamsTreatmentRecordStorage)
                          || sopClassUID.equals(SOPClass.RTBrachyTreatmentRecordStorage)
                          || sopClassUID.equals(SOPClass.RTTreatmentSummaryRecordStorage)) {
                        directoryRecordType = DicomDirectoryRecordType.rtTreatmentRecord;
                        findAttributeAndIfPresentAddToDifferentAttributeListElseAddEmpty(TagFromName.TreatmentDate,list,recordList);                                                // Type 2
                        findAttributeAndIfPresentAddToDifferentAttributeListElseAddEmpty(TagFromName.TreatmentTime,list,recordList);                                                // Type 2
                  }
                  // don't do HL7 Structured Document Directory Record here, because it would not be read in as a DICOM instance
                  
                  { AttributeTag t = TagFromName.DirectoryRecordType; Attribute a = new CodeStringAttribute(t); a.addValue(directoryRecordType); recordList.put(t,a); }
                  
                  { AttributeTag t = TagFromName.ReferencedSOPClassUIDInFile; Attribute a = new UniqueIdentifierAttribute(t); a.addValue(sopClassUID); recordList.put(t,a); }
                  { AttributeTag t = TagFromName.ReferencedSOPInstanceUIDInFile; Attribute a = new UniqueIdentifierAttribute(t); a.addValue(sopInstanceUID); recordList.put(t,a); }
                  { AttributeTag t = TagFromName.ReferencedTransferSyntaxUIDInFile; Attribute a = new UniqueIdentifierAttribute(t); a.addValue(transferSyntaxUID); recordList.put(t,a); }
                  
                  {
                        AttributeTag t = TagFromName.ReferencedFileID; Attribute a = new CodeStringAttribute(t);
                        StringTokenizer fileNameComponents = new StringTokenizer(new File(fileName).getPath().toUpperCase(),File.separator);
                        while (fileNameComponents.hasMoreTokens()) {
                              a.addValue(fileNameComponents.nextToken());
                        }
                        recordList.put(t,a);
                  }
                  
                  findAttributeAndIfPresentWithValueAddToDifferentAttributeList(TagFromName.SpecificCharacterSet,list,recordList);
                  { AttributeTag t = TagFromName.NextDirectoryRecordOffset; Attribute a = new UnsignedLongAttribute(t); a.addValue(0); recordList.put(t,a); }
                  { AttributeTag t = TagFromName.LowerLevelDirectoryOffset; Attribute a = new UnsignedLongAttribute(t); a.addValue(0); recordList.put(t,a); }
                  { AttributeTag t = TagFromName.RecordInUseFlag; Attribute a = new UnsignedShortAttribute(t); a.addValue(0xffff); recordList.put(t,a); }
                  
                  DicomDirectoryRecord instanceDirectoryRecord = null;
                  // cannot do this earlier, since may extract values of various attributes from recordList
                  if (directoryRecordType.equals(DicomDirectoryRecordType.image)) {
                        instanceDirectoryRecord = nodeFactory.getNewImageDirectoryRecord(null,recordList);
                  }
                  else if (directoryRecordType.equals(DicomDirectoryRecordType.spectroscopy)) {
                        instanceDirectoryRecord = nodeFactory.getNewSpectroscopyDirectoryRecord(null,recordList);
                  }
                  else if (directoryRecordType.equals(DicomDirectoryRecordType.rawData)) {
                        instanceDirectoryRecord = nodeFactory.getNewRawDataDirectoryRecord(null,recordList);
                  }
                  else if (directoryRecordType.equals(DicomDirectoryRecordType.waveform)) {
                        instanceDirectoryRecord = nodeFactory.getNewWaveformDirectoryRecord(null,recordList);
                  }
                  else if (directoryRecordType.equals(DicomDirectoryRecordType.keyObjectDocument)) {
                        instanceDirectoryRecord = nodeFactory.getNewKODocumentDirectoryRecord(null,recordList);
                  }
                  else if (directoryRecordType.equals(DicomDirectoryRecordType.srDocument)) {
                        instanceDirectoryRecord = nodeFactory.getNewSRDocumentDirectoryRecord(null,recordList);
                  }
                  else if (directoryRecordType.equals(DicomDirectoryRecordType.presentationState)) {
                        instanceDirectoryRecord = nodeFactory.getNewPresentationStateDirectoryRecord(null,recordList);
                  }
                  else if (directoryRecordType.equals(DicomDirectoryRecordType.registration)) {
                        instanceDirectoryRecord = nodeFactory.getNewRegistrationDirectoryRecord(null,recordList);
                  }
                  else if (directoryRecordType.equals(DicomDirectoryRecordType.fiducial)) {
                        instanceDirectoryRecord = nodeFactory.getNewFiducialDirectoryRecord(null,recordList);
                  }
                  else if (directoryRecordType.equals(DicomDirectoryRecordType.realWorldValueMapping)) {
                        instanceDirectoryRecord = nodeFactory.getNewRealWorldValueMappingDirectoryRecord(null,recordList);
                  }
                  else if (directoryRecordType.equals(DicomDirectoryRecordType.stereometricRelationship)) {
                        instanceDirectoryRecord = nodeFactory.getNewStereometricRelationshipDirectoryRecord(null,recordList);
                  }
                  else if (directoryRecordType.equals(DicomDirectoryRecordType.encapsulatedDocument)) {
                        instanceDirectoryRecord = nodeFactory.getNewEncapsulatedDocumentDirectoryRecord(null,recordList);
                  }
                  else if (directoryRecordType.equals(DicomDirectoryRecordType.rtDose)) {
                        instanceDirectoryRecord = nodeFactory.getNewRTDoseDirectoryRecord(null,recordList);
                  }
                  else if (directoryRecordType.equals(DicomDirectoryRecordType.rtStructureSet)) {
                        instanceDirectoryRecord = nodeFactory.getNewRTStructureSetDirectoryRecord(null,recordList);
                  }
                  else if (directoryRecordType.equals(DicomDirectoryRecordType.rtPlan)) {
                        instanceDirectoryRecord = nodeFactory.getNewRTPlanDirectoryRecord(null,recordList);
                  }
                  else if (directoryRecordType.equals(DicomDirectoryRecordType.rtTreatmentRecord)) {
                        instanceDirectoryRecord = nodeFactory.getNewRTTreatmentRecordDirectoryRecord(null,recordList);
                  }
                  
                  if (instanceDirectoryRecord != null) {
                        int existingIndex = seriesDirectoryRecord.getIndex(instanceDirectoryRecord);
                        if (existingIndex != -1) {
                              DicomDirectoryRecord existingInstanceDirectoryRecord = (DicomDirectoryRecord)seriesDirectoryRecord.getChildAt(existingIndex);
                              AttributeList existingInstanceDirectoryRecordList = existingInstanceDirectoryRecord == null ? null : existingInstanceDirectoryRecord.getAttributeList();
                              String existingFileName = existingInstanceDirectoryRecordList == null ? "-unknown-" : Attribute.getDelimitedStringValuesOrDefault(existingInstanceDirectoryRecordList,TagFromName.ReferencedFileID,"-unknown-");
                              throw new DicomException("Instance already exists within series for UID "+sopInstanceUID+" from file "+existingFileName+" - not adding file "+fileName);
                        }
                        instanceDirectoryRecord.setParent(seriesDirectoryRecord);
                        seriesDirectoryRecord.addChild(instanceDirectoryRecord);
                  }
                  else {
                        throw new DicomException("Unrecognized SOP Class "+sopClassUID+" - cannot create directory record - not adding file "+fileName);
                  }
//System.err.println("DicomDirectory.readDicomFileAndAddToDirectory(): instance DirectoryRecord = "+instanceDirectoryRecord);
            }
      }


Generated by  Doxygen 1.6.0   Back to index