/** * {@inheritDoc } */ @Override public String doEncode(Type type, EncodingCharacters encodingCharacters) throws HL7Exception { return encode(type, encodingCharacters, getParserConfiguration(), null); }
/** * {@inheritDoc } */ @Override public String doEncode(Type type, EncodingCharacters encodingCharacters) throws HL7Exception { return encode(type, encodingCharacters, getParserConfiguration(), null); }
/** * {@inheritDoc } */ @Override public String doEncode(Segment structure, EncodingCharacters encodingCharacters) throws HL7Exception { return encode(structure, encodingCharacters, getParserConfiguration(), null); }
/** * {@inheritDoc } */ @Override public String doEncode(Segment structure, EncodingCharacters encodingCharacters) throws HL7Exception { return encode(structure, encodingCharacters, getParserConfiguration(), null); }
throw new HL7Exception("Can't find version ID - MSH.12 is " + fields[11], ErrorCode.REQUIRED_FIELD_MISSING); } else if (getParserConfiguration().isAllowUnknownVersions()) { return Version.highestAvailableVersionOrDefault().getVersion(); } else {
/** * Formats a Message object into an HL7 message string using this parser's * default encoding ("VB"). * * @throws HL7Exception * if the data fields in the message do not permit encoding * (e.g. required fields are null) */ protected String doEncode(Message source) throws HL7Exception { // get encoding characters ... Segment msh = (Segment) source.get("MSH"); String fieldSepString = Terser.get(msh, 1, 0, 1, 1); if (fieldSepString == null) throw new HL7Exception("Can't encode message: MSH-1 (field separator) is missing"); char fieldSep = '|'; if (fieldSepString.length() > 0) fieldSep = fieldSepString.charAt(0); EncodingCharacters en = getValidEncodingCharacters(fieldSep, msh); // pass down to group encoding method which will operate recursively on // children ... return encode(source, en, getParserConfiguration(), ""); }
throw new HL7Exception("Can't find version ID - MSH.12 is " + fields[11], ErrorCode.REQUIRED_FIELD_MISSING); } else if (getParserConfiguration().isAllowUnknownVersions()) { return Version.highestAvailableVersionOrDefault().getVersion(); } else {
/** * Formats a Message object into an HL7 message string using this parser's * default encoding ("VB"). * * @throws HL7Exception * if the data fields in the message do not permit encoding * (e.g. required fields are null) */ protected String doEncode(Message source) throws HL7Exception { // get encoding characters ... Segment msh = (Segment) source.get("MSH"); String fieldSepString = Terser.get(msh, 1, 0, 1, 1); if (fieldSepString == null) throw new HL7Exception("Can't encode message: MSH-1 (field separator) is missing"); char fieldSep = '|'; if (fieldSepString.length() > 0) fieldSep = fieldSepString.charAt(0); EncodingCharacters en = getValidEncodingCharacters(fieldSep, msh); // pass down to group encoding method which will operate recursively on // children ... return encode(source, en, getParserConfiguration(), ""); }
/** * Fills a field with values from an unparsed string representing the field. * * @param destinationField * the field Type * @param data * the field string (including all components and subcomponents; * not including field delimiters) * @param encodingCharacters * the encoding characters used in the message */ @Override public void parse(Type destinationField, String data, EncodingCharacters encodingCharacters) throws HL7Exception { String[] components = split(data, String.valueOf(encodingCharacters.getComponentSeparator())); for (int i = 0; i < components.length; i++) { String[] subcomponents = split(components[i], String.valueOf(encodingCharacters.getSubcomponentSeparator())); for (int j = 0; j < subcomponents.length; j++) { String val = subcomponents[j]; if (val != null) { val = getParserConfiguration().getEscaping().unescape(val, encodingCharacters); } Terser.getPrimitive(destinationField, i + 1, j + 1).setValue(val); } } }
/** * Fills a field with values from an unparsed string representing the field. * * @param destinationField * the field Type * @param data * the field string (including all components and subcomponents; * not including field delimiters) * @param encodingCharacters * the encoding characters used in the message */ @Override public void parse(Type destinationField, String data, EncodingCharacters encodingCharacters) throws HL7Exception { String[] components = split(data, String.valueOf(encodingCharacters.getComponentSeparator())); for (int i = 0; i < components.length; i++) { String[] subcomponents = split(components[i], String.valueOf(encodingCharacters.getSubcomponentSeparator())); for (int j = 0; j < subcomponents.length; j++) { String val = subcomponents[j]; if (val != null) { val = getParserConfiguration().getEscaping().unescape(val, encodingCharacters); } Terser.getPrimitive(destinationField, i + 1, j + 1).setValue(val); } } }