* @see Validator#validate
*/
public HL7Exception[] validate(Message message, StaticDef profile) throws ProfileException,
HL7Exception {
List<HL7Exception> exList = new ArrayList<HL7Exception>();
Terser t = new Terser(message);
// check msg type, event type, msg struct ID
String msgType = t.get("/MSH-9-1");
if (!msgType.equals(profile.getMsgType())) {
HL7Exception e = new ProfileNotFollowedException("Message type " + msgType
+ " doesn't match profile type of " + profile.getMsgType());
exList.add(e);
}
String evType = t.get("/MSH-9-2");
if (!evType.equals(profile.getEventType())
&& !profile.getEventType().equalsIgnoreCase("ALL")) {
HL7Exception e = new ProfileNotFollowedException("Event type " + evType
+ " doesn't match profile type of " + profile.getEventType());
exList.add(e);
}
String msgStruct = t.get("/MSH-9-3");
if (msgStruct == null || !msgStruct.equals(profile.getMsgStructID())) {
HL7Exception e = new ProfileNotFollowedException("Message structure " + msgStruct
+ " doesn't match profile type of " + profile.getMsgStructID());
exList.add(e);
}