Package com.pixelmed.apps

## Class SetCharacteristicsFromSummary

- java.lang.Object
- - com.pixelmed.apps.SetCharacteristicsFromSummary

-     public class SetCharacteristicsFromSummary
      extends java.lang.Object

  A class containing an application for adding or replacing top level and shared multi-frame functional group attributes from a JSON summary description.

  The JSON file used to describe the changes is not encoded in the same format as the standard PS3.18 Annex F DICOM JSON Model, since (a) it allows the data elements to be changed by keyword in addition to the data element tag, and (b) it compactly specifies whether the changes are to the top level dataset ("top") or the keyword of the sequence corresponding to the functional group to be changed, and (c) list attributes in the top level data set to be removed ("remove"), and (d) lists options that control the process of modification.

  The required format of the JSON file is a single enclosing object containing a list of objects named by "remove", "options", a functional group sequence keyword or "top".

  The functional group sequence keyword or "top" entries each contains either a single string value, an array of string values (possibly empty) (for multi-valued attributes), or an array of objects (possibly empty) each of which is a sequence item consisting of a list of attributes, an object that contained a list of code sequence item attributes (named as cv for CodeValue, csd for CodingSchemeDesignator and cm for CodeMeaning) or null for an empty (type 2) attribute or sequence.

  The "remove" object contains a list of keywords and null values.

  The "options" object contains a list of options and boolean values. Current options are ReplaceCodingSchemeIdentificationSequence (default is true) and AppendToContributingEquipmentSequence (default is true)

  E.g.:

       {
              "options" : {
                      "AppendToContributingEquipmentSequence" : false
              },
       {
              "remove" : {
                      "ContributingEquipmentSequence" : null
              },
              "top" : {
                      "00204000" : "new value of ImageComments",
                      "InstitutionalDepartmentName" : "Radiology",
                      "ImageType" : [ "DERIVED", "PRIMARY", "DIXON", "WATER" ],
                      "PatientBreedCodeSequence" : null,
                      "BreedRegistrationSequence" : [
                              {
                                      "BreedRegistrationNumber" : "1234",
                                      "BreedRegistryCodeSequence" : { "cv" : "109200", "csd" : "DCM", "cm" : "America Kennel Club" }
                              },
                              {
                                      "BreedRegistrationNumber" : \"5678\",
                                      "BreedRegistryCodeSequence" : { "cv" : "109202", "csd" : "DCM", "cm" : "American Canine Association" }
                              }
                      ],
                      "StudyID" : null,
                      "AccessionNumber" : [],
                      "ReferencedStudySequence" : [],
                      "ContentCreatorName" : "Smith^John"
              },
              "FrameAnatomySequence" : {
                      "AnatomicRegionSequence" : { "cv" : "T-A0100", "csd" : "SRT", "cm" : "Brain" },
                      "FrameLaterality" : "B"
              },
              "ParametricMapFrameTypeSequence" : {
                      "FrameType" : [ "DERIVED", "PRIMARY", "DIXON", "WATER" ]
              },
              "FrameVOILUTSequence" : {
                      "WindowCenter" : "0.7",
                      "WindowWidth" : "0.7",
                      "VOILUTFunction" : "LINEAR_EXACT"
              }
       }

  Attributes are "merged" with the existing content of a functional group sequence, if any, otherwise a new functional group sequence is created.

  Currently only the shared functional group sequence can be updated, since non-progamatic use cases for repacing the content of the per-frame functional group sequence items have not yet been identified.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `protected class` | `SetCharacteristicsFromSummary.OurMediaImporter` |

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected DicomDictionary` | `dictionary` |
    `protected java.lang.String` | `dstFolderName` |
    `protected java.util.Map<AttributeTag,​AttributeList>` | `functionalGroupsReplacementsList` |
    `protected java.util.Map<java.lang.String,​java.lang.Boolean>` | `options` |
    `protected java.lang.String` | `ourAETitle` |
    `protected java.util.Set<AttributeTag>` | `topLevelRemovalList` |
    `protected AttributeList` | `topLevelReplacementsList` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `SetCharacteristicsFromSummary​(java.lang.String jsonfile, java.lang.String[] srcs, java.lang.String dstFolderName, MessageLogger logger)` | Update top level and shared multi-frame functional group attributes from a JSON summary description.
    `SetCharacteristicsFromSummary​(java.lang.String jsonfile, java.lang.String src, java.lang.String dstFolderName, MessageLogger logger)` | Update top level and shared multi-frame functional group attributes from a JSON summary description.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected AttributeTag` | `getAttributeTagFromKeywordOrGroupAndElement​(java.lang.String name)` |
    `static void` | `main​(java.lang.String[] arg)` | Update top level and shared multi-frame functional group attributes from a JSON summary description.
    `protected Attribute` | `makeNewAttribute​(java.lang.String name)` |
    `protected Attribute` | `parseAttributeFromJSON​(javax.json.JsonObject obj, java.lang.String name)` |
    `protected void` | `parseAttributesFromJSON​(javax.json.JsonObject functionalGroupEntries, AttributeList list)` |
    `protected void` | `parseAttributeTagsFromJSON​(javax.json.JsonObject entries, java.util.Set<AttributeTag> tags)` |
    `protected void` | `parseOptionsFromJSON​(javax.json.JsonObject entries)` |
    `protected void` | `parseSummaryFile​(java.lang.String jsonfile)` |
    `protected void` | `processAttributeListAfterReplacements​(AttributeList list)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### ourAETitle

          protected java.lang.String ourAETitle

    - #### dstFolderName

          protected java.lang.String dstFolderName

    - #### options

          protected java.util.Map<java.lang.String,​java.lang.Boolean> options

    - #### topLevelRemovalList

          protected java.util.Set<AttributeTag> topLevelRemovalList

    - #### topLevelReplacementsList

          protected AttributeList topLevelReplacementsList

    - #### functionalGroupsReplacementsList

          protected java.util.Map<AttributeTag,​AttributeList> functionalGroupsReplacementsList

    - #### dictionary

          protected DicomDictionary dictionary

  - ### Constructor Detail

    - #### SetCharacteristicsFromSummary

          public SetCharacteristicsFromSummary​(java.lang.String jsonfile,
                                               java.lang.String src,
                                               java.lang.String dstFolderName,
                                               MessageLogger logger)
                                        throws java.io.IOException,
                                               DicomException

      Update top level and shared multi-frame functional group attributes from a JSON summary description.

      Parameters:
        `jsonfile` - JSON file describing the functional groups and attributes and values to be added or replaced
        `src` - source folder or DICOMDIR
        `dstFolderName` - destination folder
        `logger` - logger to send progress, warnings and errors
      Throws:
        `java.io.IOException`
        `DicomException`

    - #### SetCharacteristicsFromSummary

          public SetCharacteristicsFromSummary​(java.lang.String jsonfile,
                                               java.lang.String[] srcs,
                                               java.lang.String dstFolderName,
                                               MessageLogger logger)
                                        throws java.io.IOException,
                                               DicomException

      Update top level and shared multi-frame functional group attributes from a JSON summary description.

      Parameters:
        `jsonfile` - JSON file describing the functional groups and attributes and values to be added or replaced
        `srcs` - source folders or DICOMDIRs
        `dstFolderName` - destination folder
        `logger` - logger to send progress, warnings and errors
      Throws:
        `java.io.IOException`
        `DicomException`

  - ### Method Detail

    - #### getAttributeTagFromKeywordOrGroupAndElement

          protected AttributeTag getAttributeTagFromKeywordOrGroupAndElement​(java.lang.String name)
                                                                      throws DicomException

      Throws:
        `DicomException`

    - #### makeNewAttribute

          protected Attribute makeNewAttribute​(java.lang.String name)
                                        throws DicomException

      Throws:
        `DicomException`

    - #### parseAttributeFromJSON

          protected Attribute parseAttributeFromJSON​(javax.json.JsonObject obj,
                                                     java.lang.String name)
                                              throws DicomException

      Throws:
        `DicomException`

    - #### parseAttributesFromJSON

          protected void parseAttributesFromJSON​(javax.json.JsonObject functionalGroupEntries,
                                                 AttributeList list)
                                          throws DicomException

      Throws:
        `DicomException`

    - #### parseAttributeTagsFromJSON

          protected void parseAttributeTagsFromJSON​(javax.json.JsonObject entries,
                                                    java.util.Set<AttributeTag> tags)
                                             throws DicomException

      Throws:
        `DicomException`

    - #### parseOptionsFromJSON

          protected void parseOptionsFromJSON​(javax.json.JsonObject entries)
                                       throws DicomException

      Throws:
        `DicomException`

    - #### parseSummaryFile

          protected void parseSummaryFile​(java.lang.String jsonfile)
                                   throws DicomException,
                                          java.io.FileNotFoundException

      Throws:
        `DicomException`
        `java.io.FileNotFoundException`

    - #### processAttributeListAfterReplacements

          protected void processAttributeListAfterReplacements​(AttributeList list)
                                                        throws DicomException

      Throws:
        `DicomException`

    - #### main

          public static void main​(java.lang.String[] arg)

      Update top level and shared multi-frame functional group attributes from a JSON summary description.

      Parameters:
        `arg` - array of three or more strings - a JSON file describing the functional groups and attributes and values to be added or replaced, followed by one or more source folders or DICOMDIR, and a destination folder