new HL7Value( message.getVersion(), rootGroup.getName(), group.getName(), structure.getName(), structureNumber, names[n - 1], coordinates, types[t].getName(), description, string ); values.add( value );
private void validate(Message message) throws HL7Exception { message.getVersion(); }
Structure structure = msg.get( "MSH" ); String messageType = null; String version = msg.getVersion();
private void initVersionIfNeeded() throws HL7Exception { if (myMessageClass != null && myVersion == null) { myVersion = ReflectionUtil.instantiateMessage(myMessageClass, this).getVersion(); } }
private void initVersionIfNeeded() throws HL7Exception { if (myMessageClass != null && myVersion == null) { myVersion = ReflectionUtil.instantiateMessage(myMessageClass, this).getVersion(); } }
public String getVersion() { return getDelegate().getVersion(); }
public String getVersion() { return getDelegate().getVersion(); }
public ValidationException[] apply(Message msg) { List<ValidationException> exceptions = new ArrayList<ValidationException>(); ValidationException ve = new ValidationException("Invalid version: " + msg.getVersion()); Location location = new Location() .withSegmentName("MSH") .withField(12); ve.setLocation(location); ve.setError(ErrorCode.UNSUPPORTED_VERSION_ID); exceptions.add(ve); return exceptions.toArray(new ValidationException[exceptions.size()]); }
public ValidationException[] apply(Message msg) { List<ValidationException> exceptions = new ArrayList<ValidationException>(); ValidationException ve = new ValidationException("Invalid version: " + msg.getVersion()); Location location = new Location() .withSegmentName("MSH") .withField(12); ve.setLocation(location); ve.setError(ErrorCode.UNSUPPORTED_VERSION_ID); exceptions.add(ve); return exceptions.toArray(new ValidationException[exceptions.size()]); }
public static void fixMFE4(Segment segment, ModelClassFactory factory, ParserConfiguration parserConfiguration) throws HL7Exception { if (!(segment.getName().contains("MFE")) && Version.versionOf(segment.getMessage().getVersion()).isGreaterThan(Version.V23)) { throw new IllegalArgumentException("Expected MFE segment, but was: " + segment.getName()); } fix(segment, 5, 4, null, null, factory, parserConfiguration); }
private EncodingCharacters getValidEncodingCharacters(char fieldSep, Segment msh) throws HL7Exception { String encCharString = Terser.get(msh, 2, 0, 1, 1); if (encCharString == null) { throw new HL7Exception("Can't encode message: MSH-2 (encoding characters) is missing"); } if (Version.V27.isGreaterThan(Version.versionOf(msh.getMessage().getVersion())) && encCharString.length() != 4) { throw new HL7Exception("Encoding characters (MSH-2) value '" + encCharString + "' invalid -- must be 4 characters", ErrorCode.DATA_TYPE_ERROR); } else if (encCharString.length() != 4 && encCharString.length() != 5) { throw new HL7Exception("Encoding characters (MSH-2) value '" + encCharString + "' invalid -- must be 4 or 5 characters", ErrorCode.DATA_TYPE_ERROR); } return new EncodingCharacters(fieldSep, encCharString); }
public static void fixMFE4(Segment segment, ModelClassFactory factory, ParserConfiguration parserConfiguration) throws HL7Exception { if (!(segment.getName().contains("MFE")) && Version.versionOf(segment.getMessage().getVersion()).isGreaterThan(Version.V23)) { throw new IllegalArgumentException("Expected MFE segment, but was: " + segment.getName()); } fix(segment, 5, 4, null, null, factory, parserConfiguration); }
/** * Formats a Message object into an HL7 message string using the given encoding. * * @param source a Message object from which to construct an encoded message string * @param encoding the name of the HL7 encoding to use (eg "XML"; most implementations support * only one encoding) * @return the encoded message * @throws HL7Exception if the data fields in the message do not permit encoding (e.g. required * fields are null) * @throws EncodingNotSupportedException if the requested encoding is not supported by this * parser. */ public String encode(Message source, String encoding) throws HL7Exception { assertMessageValidates(source); String result = doEncode(source, encoding); assertMessageValidates(result, encoding, source.getVersion()); return result; }
/** * Formats a Message object into an HL7 message string using the given encoding. * * @param source a Message object from which to construct an encoded message string * @param encoding the name of the HL7 encoding to use (eg "XML"; most implementations support * only one encoding) * @return the encoded message * @throws HL7Exception if the data fields in the message do not permit encoding (e.g. required * fields are null) * @throws EncodingNotSupportedException if the requested encoding is not supported by this * parser. */ public String encode(Message source, String encoding) throws HL7Exception { assertMessageValidates(source); String result = doEncode(source, encoding); assertMessageValidates(result, encoding, source.getVersion()); return result; }
private EncodingCharacters getValidEncodingCharacters(char fieldSep, Segment msh) throws HL7Exception { String encCharString = Terser.get(msh, 2, 0, 1, 1); if (encCharString == null) { throw new HL7Exception("Can't encode message: MSH-2 (encoding characters) is missing"); } if (Version.V27.isGreaterThan(Version.versionOf(msh.getMessage().getVersion())) && encCharString.length() != 4) { throw new HL7Exception("Encoding characters (MSH-2) value '" + encCharString + "' invalid -- must be 4 characters", ErrorCode.DATA_TYPE_ERROR); } else if (encCharString.length() != 4 && encCharString.length() != 5) { throw new HL7Exception("Encoding characters (MSH-2) value '" + encCharString + "' invalid -- must be 4 or 5 characters", ErrorCode.DATA_TYPE_ERROR); } return new EncodingCharacters(fieldSep, encCharString); }
private void testMessageRules(Message message, ValidationExceptionHandler<R> handler) throws HL7Exception { Terser t = new Terser(message); String messageType = t.get("MSH-9-1"); String triggerEvent = t.get("MSH-9-2"); List<MessageRule> rules = new ArrayList<MessageRule>(); if (getValidationContext() != null) { rules.addAll(getValidationContext().getMessageRules(message.getVersion(), messageType, triggerEvent)); } LOG.debug("Validating message against {} message rules", rules.size()); for (MessageRule rule : rules) { ValidationException[] ex = rule.apply(message); if (ex != null && ex.length > 0) { handler.onExceptions(ex); } } }
/** * Formats a Message object into an HL7 message string using this parser's default encoding. * * @param source a Message object from which to construct an encoded message string * @return the encoded message * @throws HL7Exception if the data fields in the message do not permit encoding (e.g. required * fields are null) */ public String encode(Message source) throws HL7Exception { assertMessageValidates(source); String result = doEncode(source); assertMessageValidates(result, getDefaultEncoding(), source.getVersion()); return result; }
/** * Formats a Message object into an HL7 message string using this parser's default encoding. * * @param source a Message object from which to construct an encoded message string * @return the encoded message * @throws HL7Exception if the data fields in the message do not permit encoding (e.g. required * fields are null) */ public String encode(Message source) throws HL7Exception { assertMessageValidates(source); String result = doEncode(source); assertMessageValidates(result, getDefaultEncoding(), source.getVersion()); return result; }
private void testPrimitive(Primitive p, ValidationExceptionHandler<R> handler, Location l) { List<PrimitiveTypeRule> rules = new ArrayList<PrimitiveTypeRule>(); Message m = p.getMessage(); if (getValidationContext() != null) { rules.addAll(getValidationContext().getPrimitiveRules(m.getVersion(), p.getName(), p)); } for (PrimitiveTypeRule rule : rules) { ValidationException[] exceptions = rule.apply(p.getValue()); for (ValidationException ve : exceptions) { ve.setLocation(l); } if (exceptions.length > 0) { handler.onExceptions(exceptions); } } }
private void testPrimitive(Primitive p, ValidationExceptionHandler<R> handler, Location l) { List<PrimitiveTypeRule> rules = new ArrayList<PrimitiveTypeRule>(); Message m = p.getMessage(); if (getValidationContext() != null) { rules.addAll(getValidationContext().getPrimitiveRules(m.getVersion(), p.getName(), p)); } for (PrimitiveTypeRule rule : rules) { ValidationException[] exceptions = rule.apply(p.getValue()); for (ValidationException ve : exceptions) { ve.setLocation(l); } if (exceptions.length > 0) { handler.onExceptions(exceptions); } } }