cdac.medinfo.sdk.hl7282.commoninterface

## Interface ISegment

- All Known Implementing Classes:
    ABS, ACC, ADD, ADJ, AFF, AIG, AIL, AIP, AIS, AL1, APR, ARQ, ARV, AUT, BHS, BLC, BLG, BPO, BPX, BTS, BTX, BUI, CDM, CDO, CER, CM0, CM1, CM2, CNS, ConsentSeg, CSP, CSR, CSS, CTD, CTI, DB1, DG1, DMI, DON, DPS, DRG, DSC, DSP, ECD, ECR, EDU, EQL, EQP, EQU, ERQ, ERR, EVN, FAC, FHS, FT1, FTS, GOL, GP1, GP2, GT1, IAM, IAR, IIM, ILT, IN1, IN2, IN3, INV, IPC, IPR, ISD, ITM, IVC, IVT, LAN, LCC, LCH, LDP, LOC, LRL, MCP, MFA, MFE, MFI, MRG, MSA, MSH, NCK, NDS, NK1, NPU, NSC, NST, NTE, OBR, OBX, ODS, ODT, OM1, OM2, OM3, OM4, OM5, OM6, OM7, OMC, ORC, ORG, OVR, PAC, PCE, PCR, PD1, PDA, PDC, PEO, PES, PID, PKG, PM1, PMT, PR1, PRA, PRB, PRC, PRD, PRT, PSG, PSH, PSL, PSS, PTH, PV1, PV2, PYE, QAK, QID, QPD, QRI, RCP, RDF, RDT, REL, RF1, RFI, RGS, RMI, ROL, RQ1, RQD, RXA, RXC, RXD, RXE, RXG, RXO, RXR, RXV, SAC, SCD, SCH, SCP, SDD, Segment, SFT, SGH, SGT, SHP, SID, SLT, SPM, SPR, STF, STZ, TCC, TCD, TQ1, TQ2, TXA, UAC, UB2, VAR, VND

      public interface ISegment

  This is Parent Interface of segment in model layer.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addUnRecognizedField(UnRecognizedField objUnRecognizedField)` Adds UnRecognizedField in list.
    `void` | `dumpSegment(IHL7Stream objIHL7Stream, IDelimiter objIDelimiter, int iLevel)` Dumps information of segments like Attribute Name and its value.
    `IMultiValuedPairedCollection<java.lang.Integer,IDataType>` | `getFields()` Get the Fields collection of Segment
    `ISegmentKey` | `getName()` Returns Segment Name.
    `ISingleCollection<UnRecognizedField>` | `getUnrecognizedFields()` Retrieves list of Unrecognized field.
    `void` | `moveToNextSegment(java.lang.String strFieldStream)` Moves to next Segment.
    `int` | `parse(java.lang.String strHL7segmentString, IDelimiter objIDelimiter)` Parses HL7 Segment Strings from any Stream into HL7 Segment object.
    `int` | `removeDataElement(int iItemIDToBeRemoved, boolean isForcefullyRemove)` Removes Data Element from Data Element List.
    `int` | `removeDataElement(java.lang.String strAttributeName, boolean isForcefullyRemove)` Removes Data Element from Data Element List.
    `int` | `serialize(IHL7Stream objIHL7Stream, IDelimiter objIDelimiter)` Serializes HL7 Message objects.
    `void` | `setName(ISegmentKey enumName)` Sets Segment Name.
    `int` | `updateDataElement(int iItemIDToBeUpdated, IDataType objIDataType)` Updates Data Element from Data Element List.
    `int` | `updateDataElement(int iItemIDToBeUpdated, java.lang.String strSegmentString, IDelimiter objDelimiter)` Updates Data Element from Data Element List.
    `boolean` | `validate()` Validates HL7 Message objects .
    `int` | `writeToXML(javax.xml.stream.XMLEventWriter eventWriter)` Writes the data to the Stream.

- - ### Method Detail

    - #### serialize

          int serialize(IHL7Stream objIHL7Stream,
                      IDelimiter objIDelimiter)
                        throws java.io.IOException

      Serializes HL7 Message objects. Before serialization it validates Message as per HL7 v2.8.2 standard. For successfully serialization , Message Object should follow order of segments as per its corresponding Message Structure. Serialize method fails if given stream is null. It mandates presence of required segments and the number of occurrences specified by the standard. This method also checks for presence of Mandatory Groups.It also verifies repeatability of Group.
      Parameters:
        `objIHL7Stream` - Object of HL7Stream class
        `objIDelimiter` - Object of Delimiter class present as inner class in MSG class
      Returns:
        int - function status [success/failure]
      Throws:
        `SerializeException` - Thrown when serialization of Message fails
        `java.io.IOException` - Signals that an I/O exception of some sort has occurred

    - #### validate

          boolean validate()

      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.
      Returns:
        boolean - true or false
      Throws:
        `InvalidSegmentException` - Throws when Segment Validation fails

    - #### parse

          int parse(java.lang.String strHL7segmentString,
                  IDelimiter objIDelimiter)
                    throws java.io.IOException

      Parses HL7 Segment Strings from any Stream into HL7 Segment object. This method checks for the Repetition of the fields in the Segment. It also checks for the optionality of the fields as whether they are mandatory or optional. Successful parsing of the segment populates the object with the data present on the stream and provides easy accessor and mutator methods to navigate the message. It also leads to failure if version of given HL7 Message is not 2.8.2. This method raises exception if there is Segment which is not valid as per HL7 v 2.8.2 standard.
      Parameters:
        `strHL7segmentString` - Object of HL7Stream
        `objIDelimiter` - Object of class Delimiter
      Returns:
        int - Success if segment is valid - Fail if segment in not valid
      Throws:
        `InvalidSegmentException` - Thrown when Segment Validation Fails
        `java.io.IOException` - Signals that an I/O exception of some sort has occurred

    - #### getName

          ISegmentKey getName()

      Returns Segment Name.
      Returns:
        EnumSegments - enum used for SegmentName

    - #### setName

          void setName(ISegmentKey enumName)

      Sets Segment Name.
      Parameters:
        `enumName` -

    - #### moveToNextSegment

          void moveToNextSegment(java.lang.String strFieldStream)

      Moves to next Segment.
      Parameters:
        `strFieldStream` - String from HL7Stream

    - #### dumpSegment

          void dumpSegment(IHL7Stream objIHL7Stream,
                         IDelimiter objIDelimiter,
                         int iLevel)
                           throws DumpException,
                                  java.io.IOException

      Dumps information of segments like Attribute Name and its value.
      Parameters:
        `objIHL7Stream` - Object of HL7Stream class
        `objIDelimiter` - Object of IDelimiter
      Throws:
        `DumpException`
        `java.io.IOException`

    - #### removeDataElement

          int removeDataElement(java.lang.String strAttributeName,
                              boolean isForcefullyRemove)

      Removes Data Element from Data Element List.
      Parameters:
        `strAttributeName` - String value of Attribute Name
      Returns:
        True - if attrbute removed successfully, else returns false

    - #### removeDataElement

          int removeDataElement(int iItemIDToBeRemoved,
                              boolean isForcefullyRemove)

      Removes Data Element from Data Element List.
      Parameters:
        `iItemIDToBeRemoved` - Integer value for attribute which is Item ID specified by HL7
      Returns:
        True - if attrbute removed successfully, else returns false

    - #### updateDataElement

          int updateDataElement(int iItemIDToBeUpdated,
                              java.lang.String strSegmentString,
                              IDelimiter objDelimiter)
                                throws java.io.IOException

      Updates Data Element from Data Element List.
      Parameters:
        `iItemIDToBeRemoved` - Integer value for attribute which is Item ID specified by HL7
        `objIHL7Stream` - Object of IHL7Stream
        `objDelimiter` - Object of IDelimiter
      Returns:
        True - if attribute removed successfully, else returns false
      Throws:
        `java.io.IOException`

    - #### updateDataElement

          int updateDataElement(int iItemIDToBeUpdated,
                              IDataType objIDataType)
                                throws java.io.IOException

      Updates Data Element from Data Element List.
      Parameters:
        `iItemIDToBeUpdated` - Integer value for attribute which is Item ID specified by HL7
        `objIDataType` - Object of DataType
      Returns:
        True - if attribute removed successfully, else returns false
      Throws:
        `java.io.IOException`

    - #### getFields

          IMultiValuedPairedCollection<java.lang.Integer,IDataType> getFields()

      Get the Fields collection of Segment
      Returns:
        ISingleCollection<Integer, IDataType> - Collection of DataType of the Segment.

    - #### writeToXML

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

      Writes the data to the Stream.
      Parameters:
        `XMLEventWriter` - Object of XMLEventWriter
      Returns:
        int - Success or failure of the read
      Throws:
        `java.io.IOException` - - if IO operation fails
        `javax.xml.stream.XMLStreamException` - - The base exception for unexpected processing errors. This Exception class is used to report well-formed errors as well as unexpected processing conditions.

    - #### addUnRecognizedField

          void addUnRecognizedField(UnRecognizedField objUnRecognizedField)

      Adds UnRecognizedField in list.
      Parameters:
        `objUnRecognizedField` - object of UnRecognizedField

    - #### getUnrecognizedFields

          ISingleCollection<UnRecognizedField> getUnrecognizedFields()

      Retrieves list of Unrecognized field.
      Returns:
        Isinglecollection - list of UnRecognized field