public void TestSafePrivateGEMRRelated_CreatorFromList() throws Exception {
   {
     AttributeList list = new AttributeList();
     {
       Attribute a = new LongStringAttribute(new AttributeTag(0x0019, 0x0010));
       a.addValue("GEMS_ACQU_01");
       list.put(a);
     }
     assertTrue(
         "Internal Pulse Sequence Name is safe",
         ClinicalTrialsAttributes.isSafePrivateAttribute(new AttributeTag(0x0019, 0x109E), list));
   }
   {
     AttributeList list = new AttributeList();
     {
       Attribute a = new LongStringAttribute(new AttributeTag(0x0025, 0x0010));
       a.addValue("GEMS_SERS_01");
       list.put(a);
     }
     assertTrue(
         "Images In Series is safe",
         ClinicalTrialsAttributes.isSafePrivateAttribute(new AttributeTag(0x0025, 0x1007), list));
   }
   {
     AttributeList list = new AttributeList();
     {
       Attribute a = new LongStringAttribute(new AttributeTag(0x0043, 0x0010));
       a.addValue("GEMS_PARM_01");
       list.put(a);
     }
     assertTrue(
         "Scanner Table Entry + Gradient Coil Selected",
         ClinicalTrialsAttributes.isSafePrivateAttribute(new AttributeTag(0x0043, 0x106F), list));
   }
 }
 public void TestSafePrivatePhilipsPETRelated_ScaleFactors_FromTag() throws Exception {
   assertTrue(
       "Checking SUV Factor is safe",
       ClinicalTrialsAttributes.isSafePrivateAttribute(
           "Philips PET Private Group", new AttributeTag(0x7053, 0x1000)));
   assertTrue(
       "Checking Activity Concentration Factor is safe",
       ClinicalTrialsAttributes.isSafePrivateAttribute(
           "Philips PET Private Group", new AttributeTag(0x7053, 0x1009)));
 }
 public void TestSafePrivatePhilipsPETRelated_ScaleFactors_FromList() throws Exception {
   AttributeList list = new AttributeList();
   {
     Attribute a = new LongStringAttribute(new AttributeTag(0x7053, 0x0010));
     a.addValue("Philips PET Private Group");
     list.put(a);
   }
   assertTrue(
       "Checking SUV Factor is safe",
       ClinicalTrialsAttributes.isSafePrivateAttribute(new AttributeTag(0x7053, 0x1000), list));
   assertTrue(
       "Checking Activity Concentration Factor is safe",
       ClinicalTrialsAttributes.isSafePrivateAttribute(new AttributeTag(0x7053, 0x1009), list));
 }
 public void TestSafePrivateGEMRRelated_FromTag() throws Exception {
   assertTrue(
       "Internal Pulse Sequence Name",
       ClinicalTrialsAttributes.isSafePrivateAttribute(
           "GEMS_ACQU_01", new AttributeTag(0x0019, 0x109E)));
   assertTrue(
       "Images In Series",
       ClinicalTrialsAttributes.isSafePrivateAttribute(
           "GEMS_SERS_01", new AttributeTag(0x0025, 0x1007)));
   assertTrue(
       "Scanner Table Entry + Gradient Coil Selected",
       ClinicalTrialsAttributes.isSafePrivateAttribute(
           "GEMS_PARM_01", new AttributeTag(0x0043, 0x106F)));
 }
 public void TestSafePrivateGEPACSRelated_CreatorFromList() throws Exception {
   AttributeList list = new AttributeList();
   {
     Attribute a = new LongStringAttribute(new AttributeTag(0x0903, 0x0010));
     a.addValue("GEIIS PACS");
     list.put(a);
   }
   assertTrue(
       "Checking Reject Image Flag is safe",
       ClinicalTrialsAttributes.isSafePrivateAttribute(new AttributeTag(0x0903, 0x1010), list));
 }
 public void TestSafePrivateGEPACSRelated_AddedToList() throws Exception {
   AttributeList list = new AttributeList();
   {
     Attribute a = new LongStringAttribute(new AttributeTag(0x0903, 0x0010));
     a.addValue("GEIIS PACS");
     list.put(a);
   }
   {
     Attribute a = new UnsignedShortAttribute(new AttributeTag(0x0903, 0x1010));
     a.addValue(0);
     list.put(a);
   }
   list.removeUnsafePrivateAttributes();
   assertTrue(
       "Checking Creator is not removed", list.get(new AttributeTag(0x0903, 0x0010)) != null);
   assertTrue(
       "Checking Reject Image Flag is not removed",
       ClinicalTrialsAttributes.isSafePrivateAttribute(new AttributeTag(0x0903, 0x1010), list));
 }
    protected void doSomethingWithDicomFileOnMedia(String mediaFileName) {
      // logLn("OurFirstPassMediaImporter.doSomethingWithDicomFile(): "+mediaFileName);
      try {
        DicomInputStream i = new DicomInputStream(new File(mediaFileName));
        AttributeList list = new AttributeList();
        list.read(i);
        i.close();

        String sopInstanceUID =
            Attribute.getSingleStringValueOrEmptyString(list, TagFromName.SOPInstanceUID);
        if (sopInstanceUID.length() > 0) {
          Group group = mapOfSOPInstanceUIDToGroup.get(sopInstanceUID);

          // System.err.println("group = "+group);
          // System.err.println("Groups size = "+groups.size());
          if (group == null) {
            if (groups.size() == 1) {
              group = groups.toArray(singleGroupArray)[0];
            } else {
              throw new DicomException(
                  "Cannot merge context for second set if more than one group");
            }
          }

          if (group != null) {
            logLn("In group " + group.identity);
            if (group.context != null) {
              CompositeInstanceContext.removePatient(
                  list); // remove anything hanging around, such as empty attributes
              list.putAll(
                  group.context
                      .getAttributeList()); // overwrite all patient context in list that was read
                                            // in
            } else {
              throw new DicomException(
                  "Missing group context for SOPInstanceUID on second pass"); // should not be
                                                                              // possible
            }

            ClinicalTrialsAttributes.addContributingEquipmentSequence(
                list,
                true,
                new CodedSequenceItem("109103", "DCM", "Modifying Equipment"),
                "PixelMed", // Manufacturer
                "PixelMed", // Institution Name
                "Software Development", // Institutional Department Name
                "Bangor, PA", // Institution Address
                null, // Station Name
                "com.pixelmed.apps.MergeCompositeContext", // Manufacturer's Model Name
                null, // Device Serial Number
                "Vers. " + VersionAndConstants.getBuildDate(), // Software Version(s)
                "Merged patient context");

            list.removeGroupLengthAttributes();
            list.removeMetaInformationHeaderAttributes();
            list.remove(TagFromName.DataSetTrailingPadding);
            FileMetaInformation.addFileMetaInformation(
                list, TransferSyntax.ExplicitVRLittleEndian, ourAETitle);

            File dstFile =
                new File(
                    dstFolderName,
                    MoveDicomFilesIntoHierarchy.makeHierarchicalPathFromAttributes(list));
            if (dstFile.exists()) {
              throw new DicomException(
                  "\""
                      + mediaFileName
                      + "\": new file \""
                      + dstFile
                      + "\" already exists - not overwriting");
            } else {
              File dstParentDirectory = dstFile.getParentFile();
              if (!dstParentDirectory.exists()) {
                if (!dstParentDirectory.mkdirs()) {
                  throw new DicomException(
                      "\""
                          + mediaFileName
                          + "\": parent directory creation failed for \""
                          + dstFile
                          + "\"");
                }
              }
              logLn("Writing with new context file " + dstFile);
              list.write(dstFile, TransferSyntax.ExplicitVRLittleEndian, true, true);
            }
          } else {
            throw new DicomException(
                "Missing group for SOPInstanceUID on second pass"); // should not be possible for
                                                                    // single set case
          }
        } else {
          throw new DicomException("Missing SOPInstanceUID");
        }
      } catch (Exception e) {
        logLn("Error: File " + mediaFileName + " exception " + e);
      }
    }
 public void TestSafePrivateGEPACSRelated_FromTag() throws Exception {
   assertTrue(
       "Checking Reject Image Flag is safe",
       ClinicalTrialsAttributes.isSafePrivateAttribute(
           "GEIIS PACS", new AttributeTag(0x0903, 0x1010)));
 }