cdac.medinfo.sdk.hl7282.baselibs.messages

## Class Group

- java.lang.Object
- - cdac.medinfo.sdk.hl7282.baselibs.messages.Group

- All Implemented Interfaces:
    IGroup

      public class Group
      extends java.lang.Object
      implements IGroup

  Group class contains multi valued paired collection of segments and groups of HL7 message group. This class provides mechanism to serialize, parse and validate message against HL7 v 2.8.2 standard. The class provides accessors & mutators for the elements mentioned above. These elements can be easily populated & populated values can be easily retrieved. The class has validate method which validates Message against HL7 v 2.8.2 standard. It provides user with serialize method to serialize message object to any stream & parse method to obtain fully populated & validated Message object from any stream.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Group(ISegmentKey enumGroups, IMap objMessageMap)` This constructor creates object of MultiValuedPairedCollection and initializes the Group Name with enumGroups.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addGroup(ISegmentKey enumSegments, IGroup objGroup)` Adds the group in Collection of data value.
    `void` | `addSegment(ISegmentKey enumSegments, ISegment objSegment)` Adds segment in multi valued paired collection.
    `ISingleCollection<IGroup>` | `getGroup(ISegmentKey enumGroup)` Gives collection of group of name enumGroup as passed by user.
    `IMap` | `getGroupMap(ISegmentKey enumGroupName)` Retrieves Map of specified Group name
    `ISegmentKey` | `getName()` Return SegmentKey.
    `ISingleCollection<ISegment>` | `getSegment(ISegmentKey enumSegments)` Gives collection of segment of name enumSegments as passed by user.
    `ISingleCollection<ISegment>` | `getSegmentCollection()` Retrieves collection of ISegment.
    `ISegmentSet` | `getSegmentSet()` Retrieves all segments present in this group
    `int` | `populate(ISegmentSet objSegmentSet)` Populates the Segment Set.
    `void` | `setName(ISegmentKey enumName)` Sets the name of group.
    `int` | `size()` Returns the size of the group
    `boolean` | `validate()` Validates HL7 Message objects.
    `int` | `writeToXML(javax.xml.stream.XMLEventWriter eventWriter)` Uses to write to XML

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

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

- - ### Constructor Detail

    - #### Group

          public Group(ISegmentKey enumGroups,
               IMap objMessageMap)

      This constructor creates object of MultiValuedPairedCollection and initializes the Group Name with enumGroups.
      Parameters:
        `enumGroups` - Name of the Group.

  - ### Method Detail

    - #### getGroup

          public ISingleCollection<IGroup> getGroup(ISegmentKey enumGroup)

      Gives collection of group of name enumGroup as passed by user.
      Specified by:
        `getGroup` in interface `IGroup`
      Parameters:
        `enumGroup` - Name of group.
      Returns:
        ISingleCollection - Collection of Group .

    - #### getName

          public ISegmentKey getName()

      Return SegmentKey.
      Specified by:
        `getName` in interface `IGroup`
      Returns:
        SegmentKey.

    - #### setName

          public void setName(ISegmentKey enumName)

      Sets the name of group.
      Specified by:
        `setName` in interface `IGroup`
      Parameters:
        `enumName` - - object of enumName.

    - #### getSegment

          public ISingleCollection<ISegment> getSegment(ISegmentKey enumSegments)

      Gives collection of segment of name enumSegments as passed by user.
      Specified by:
        `getSegment` in interface `IGroup`
      Parameters:
        `enumSegments` - Name of Segment.
      Returns:
        ISingleCollection - Collection of Segments .

    - #### addGroup

          public void addGroup(ISegmentKey enumSegments,
                      IGroup objGroup)

      Adds the group in Collection of data value.
      Specified by:
        `addGroup` in interface `IGroup`
      Parameters:
        `enumSegments` - - object of enumSegment .
        `objGroup` - - object of Group.

    - #### addSegment

          public void addSegment(ISegmentKey enumSegments,
                        ISegment objSegment)

      Adds segment in multi valued paired collection.
      Specified by:
        `addSegment` in interface `IGroup`
      Parameters:
        `enumSegments` - Key that is to be added to collection
        `objSegment` - Value of the key.

    - #### getSegmentSet

          public ISegmentSet getSegmentSet()

      Retrieves all segments present in this group
      Specified by:
        `getSegmentSet` in interface `IGroup`
      Returns:
        ISingleCollection - List of Segments

    - #### getSegmentCollection

          public ISingleCollection<ISegment> getSegmentCollection()

      Retrieves collection of ISegment.
      Specified by:
        `getSegmentCollection` in interface `IGroup`
      Returns:
        ISingleCollection -return collection of ISegment.

    - #### populate

          public int populate(ISegmentSet objSegmentSet)
                       throws GroupMissingException

      Populates the Segment Set.
      Specified by:
        `populate` in interface `IGroup`
      Returns:
        int - return HL7_FUNCTION_SUCCESS after success.
      Throws:
        `GroupMissingException`

    - #### validate

          public boolean validate()
                           throws InvalidMessageException

      Validates HL7 Message objects. Validate method checks for validation each and every segments in side the Message object against specified message Structure. Validation checks include optionality of segment or group. It also verifies the number of times segment or group is repeated in message. e.g {PSH} while parsing PSH segment validate method will check for its mandatory presence. [PSH] in this case validate will throw exception if one tries to enter more than one PSH segment.
      Specified by:
        `validate` in interface `IGroup`
      Returns:
        boolean - true If Message and all segments in side it are validated properly - false If segment in side it is not validated properly and if compulsory segments are not present.
      Throws:
        `InvalidMessageException` - Thrown when Message validation fails.

    - #### getGroupMap

          public IMap getGroupMap(ISegmentKey enumGroupName)

      Retrieves Map of specified Group name
      Specified by:
        `getGroupMap` in interface `IGroup`
      Parameters:
        `enumGroupName` - Object of ISegmentKey provides name of Group.
      Returns:
        IMap - Object of IMap.

    - #### size

          public int size()

      Returns the size of the group
      Specified by:
        `size` in interface `IGroup`
      Returns:
        int - return size.

    - #### writeToXML

          public int writeToXML(javax.xml.stream.XMLEventWriter eventWriter)
                         throws java.io.IOException,
                                javax.xml.stream.XMLStreamException

      Uses to write to XML
      Specified by:
        `writeToXML` in interface `IGroup`
      Parameters:
        `eventWriter` - object of eventWriter.
      Returns:
        int - return integer
      Throws:
        `java.io.IOException`
        `javax.xml.stream.XMLStreamException`