Class FixFieldDataType

java.lang.Object
ca.uhn.hl7v2.parser.FixFieldDataType

public final class FixFieldDataType extends Object
Utility class that provides methods for fixing OBX-5 data type. This has been refactored out of Varies.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    System property key: The value may be set to provide a default datatype ("ST", "NM", etc) for an MFE segment with a missing MFE-5 value.
    static final String
    System property key: The value may be set to provide a default datatype ("ST", "NM", etc) for an OBX segment with a missing OBX-2 value.
    static final String
    System property key: If this is not set, or set to "true", and a subcomponent delimiter is found within the value of a Varies of a primitive type, this subcomponent delimiter will be treated as a literal character instead of a subcomponent delimiter, and will therefore be escaped if the message is re-encoded.
    static final String
    System property key: The value may be set to provide a default datatype ("ST", "NM", etc) for an MFE segment with an invalid MFE-5 value type.
    static final String
    System property key: The value may be set to provide a default datatype ("ST", "NM", etc) for an OBX segment with an invalid OBX-2 value type.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    fix(Segment segment, int typeField, int dataField, String defaultType, String invalidType, ModelClassFactory factory, ParserConfiguration parserConfiguration)
    A more generic version of the task of adapting a varies field to a given type
    static void
    fixMFE4(Segment segment, ModelClassFactory factory, ParserConfiguration parserConfiguration)
    Sets the data type of field 4 in the given MFE segment to the value of MFE-5.
    static void
    fixOBX5(Segment segment, ModelClassFactory factory, ParserConfiguration parserConfiguration)
    Sets the data type of field 5 in the given OBX segment to the value of OBX-2.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_OBX2_TYPE_PROP

      public static final String DEFAULT_OBX2_TYPE_PROP
      System property key: The value may be set to provide a default datatype ("ST", "NM", etc) for an OBX segment with a missing OBX-2 value.
      See Also:
    • INVALID_OBX2_TYPE_PROP

      public static final String INVALID_OBX2_TYPE_PROP
      System property key: The value may be set to provide a default datatype ("ST", "NM", etc) for an OBX segment with an invalid OBX-2 value type. In other words, if OBX-2 has a value of "ZYZYZ", which is not a valid value, but this property is set to "ST", then OBX-5 will be parsed as an ST.
      See Also:
    • DEFAULT_MFE5_TYPE_PROP

      public static final String DEFAULT_MFE5_TYPE_PROP
      System property key: The value may be set to provide a default datatype ("ST", "NM", etc) for an MFE segment with a missing MFE-5 value.
      See Also:
    • INVALID_MFE5_TYPE_PROP

      public static final String INVALID_MFE5_TYPE_PROP
      System property key: The value may be set to provide a default datatype ("ST", "NM", etc) for an MFE segment with an invalid MFE-5 value type. In other words, if MFE-5 has a value of "ZYZYZ", which is not a valid value, but this property is set to "ST", then MFE-4 will be parsed as an ST.
      See Also:
    • ESCAPE_SUBCOMPONENT_DELIM_IN_PRIMITIVE

      System property key: If this is not set, or set to "true", and a subcomponent delimiter is found within the value of a Varies of a primitive type, this subcomponent delimiter will be treated as a literal character instead of a subcomponent delimiter, and will therefore be escaped if the message is re-encoded. This is handy when dealing with non-conformant sending systems which do not correctly escape ampersands in OBX-5 values.

      For example, consider the following OBX-5 segment:

          OBX||ST|||Apples, Pears & Bananas|||
       
      In this example, the data type is a primitive ST and does not support subcomponents, and the ampersand is obviously not intended to represent a subcomponent delimiter. If this property is set to true, the entire string will be treated as the value of OBX-5, and if the message is re-encoded the string will appear as "Apples, Pears \T\ Bananas".

      If this property is set to anything other than "true", the subcomponent delimiter is treated as a component delimiter, so the value after the ampersand is placed into an extra component.

      See Also:
  • Method Details

    • fixOBX5

      public static void fixOBX5(Segment segment, ModelClassFactory factory, ParserConfiguration parserConfiguration) throws HL7Exception

      Sets the data type of field 5 in the given OBX segment to the value of OBX-2. The argument is a Segment as opposed to a particular OBX because it is meant to work with any version.

      Note that if no value is present in OBX-2, or an invalid value is present in OBX-2, this method will throw an error. This behaviour can be corrected by using the following system properties: DEFAULT_OBX2_TYPE_PROP and INVALID_OBX2_TYPE_PROP or by using configuration in ParserConfiguration

      Parameters:
      segment - OBX segment instance to be modified
      factory - ModelClassFactory to be used
      parserConfiguration - configuration that influences setting OBX-5
      Throws:
      HL7Exception - if the operation fails
    • fixMFE4

      public static void fixMFE4(Segment segment, ModelClassFactory factory, ParserConfiguration parserConfiguration) throws HL7Exception

      Sets the data type of field 4 in the given MFE segment to the value of MFE-5. The argument is a Segment as opposed to a particular MFE because it is meant to work with any version.

      Note that if no value is present in MFE-5, or an invalid value is present in MFE-5, this method will throw an error. This behaviour can be corrected by using the following system properties: DEFAULT_MFE5_TYPE_PROP and INVALID_MFE5_TYPE_PROP or by using configuration in ParserConfiguration

      Parameters:
      segment - MFE segment instance to be modified
      factory - ModelClassFactory to be used
      parserConfiguration - configuration that influences setting MFE-5
      Throws:
      HL7Exception - if the operation fails
    • fix

      public static void fix(Segment segment, int typeField, int dataField, String defaultType, String invalidType, ModelClassFactory factory, ParserConfiguration parserConfiguration) throws HL7Exception
      A more generic version of the task of adapting a varies field to a given type
      Parameters:
      segment - segment instance
      typeField - field number of the specified data type
      dataField - field number of the varies data field
      defaultType - default type if the typeField is empty
      invalidType - default type if the typeField is invalid
      factory - ModelClassFactory to be used
      parserConfiguration - parser config
      Throws:
      HL7Exception - if the operation fails