protected void checkDataType(String dataType, Type type, List<HL7Exception> exList) { // check datatype String typeName = type.getName(); if (!(type instanceof Varies || typeName.equals(dataType))) { exList.add(new ProfileNotHL7CompliantException("HL7 datatype " + typeName + " doesn't match profile datatype " + dataType)); } }
protected void checkDataType(String dataType, Type type, List<HL7Exception> exList) { // check datatype String typeName = type.getName(); if (!(type instanceof Varies || typeName.equals(dataType))) { exList.add(new ProfileNotHL7CompliantException("HL7 datatype " + typeName + " doesn't match profile datatype " + dataType)); } }
/** * Tests a structure (segment or group) against the corresponding part of a profile. */ public List<HL7Exception> testStructure(Structure s, ProfileStructure profile, String profileID) throws ProfileException { List<HL7Exception> exList = new ArrayList<HL7Exception>(); if (profile instanceof Seg) { if (Segment.class.isAssignableFrom(s.getClass())) { exList.addAll(doTestSegment((Segment) s, (Seg) profile, profileID, validateChildren)); } else { exList.add(new ProfileNotHL7CompliantException( "Mismatch between a segment in the profile and the structure " + s.getClass().getName() + " in the message")); } } else if (profile instanceof SegGroup) { if (Group.class.isAssignableFrom(s.getClass())) { exList.addAll(testGroup((Group) s, (SegGroup) profile, profileID)); } else { exList.add(new ProfileNotHL7CompliantException( "Mismatch between a group in the profile and the structure " + s.getClass().getName() + " in the message")); } } return exList; }
/** * Tests a structure (segment or group) against the corresponding part of a profile. */ public List<HL7Exception> testStructure(Structure s, ProfileStructure profile, String profileID) throws ProfileException { List<HL7Exception> exList = new ArrayList<HL7Exception>(); if (profile instanceof Seg) { if (Segment.class.isAssignableFrom(s.getClass())) { exList.addAll(doTestSegment((Segment) s, (Seg) profile, profileID, validateChildren)); } else { exList.add(new ProfileNotHL7CompliantException( "Mismatch between a segment in the profile and the structure " + s.getClass().getName() + " in the message")); } } else if (profile instanceof SegGroup) { if (Group.class.isAssignableFrom(s.getClass())) { exList.addAll(testGroup((Group) s, (SegGroup) profile, profileID)); } else { exList.add(new ProfileNotHL7CompliantException( "Mismatch between a group in the profile and the structure " + s.getClass().getName() + " in the message")); } } return exList; }
exList.addAll(doTestComponent(child, childProfile, profileID, validateChildren)); } catch (DataTypeException de) { exList.add(new ProfileNotHL7CompliantException( "More components in profile than allowed in message: " + de.getMessage())); exList.add(new ProfileNotHL7CompliantException("A field has type primitive " + type.getClass().getName() + " but the profile defines components"));
exList.addAll(doTestComponent(child, childProfile, profileID, validateChildren)); } catch (DataTypeException de) { exList.add(new ProfileNotHL7CompliantException( "More components in profile than allowed in message: " + de.getMessage())); exList.add(new ProfileNotHL7CompliantException("A field has type primitive " + type.getClass().getName() + " but the profile defines components"));
protected List<HL7Exception> doTestComponent(Type type, Component profile, String profileID, boolean theValidateChildren) throws ProfileException, HL7Exception { List<HL7Exception> exList = new ArrayList<HL7Exception>(); exList.addAll(testType(type, profile, null, profileID)); // test children if (profile.getSubComponents() > 0 && !profile.getUsage().equals("X") && (!type.isEmpty())) { if (Composite.class.isAssignableFrom(type.getClass())) { Composite comp = (Composite) type; if (theValidateChildren) { for (int i = 1; i <= profile.getSubComponents(); i++) { SubComponent childProfile = profile.getSubComponent(i); try { Type child = comp.getComponent(i - 1); exList.addAll(testType(child, childProfile, null, profileID)); } catch (DataTypeException de) { exList.add(new ProfileNotHL7CompliantException( "More subcomponents in profile than allowed in message: " + de.getMessage())); } } } checkExtraComponents(comp, profile.getSubComponents(), exList); } else { exList.add(new ProfileNotFollowedException("A component has primitive type " + type.getClass().getName() + " but the profile defines subcomponents")); } } return exList; }
protected List<HL7Exception> doTestComponent(Type type, Component profile, String profileID, boolean theValidateChildren) throws ProfileException, HL7Exception { List<HL7Exception> exList = new ArrayList<HL7Exception>(); exList.addAll(testType(type, profile, null, profileID)); // test children if (profile.getSubComponents() > 0 && !profile.getUsage().equals("X") && (!type.isEmpty())) { if (Composite.class.isAssignableFrom(type.getClass())) { Composite comp = (Composite) type; if (theValidateChildren) { for (int i = 1; i <= profile.getSubComponents(); i++) { SubComponent childProfile = profile.getSubComponent(i); try { Type child = comp.getComponent(i - 1); exList.addAll(testType(child, childProfile, null, profileID)); } catch (DataTypeException de) { exList.add(new ProfileNotHL7CompliantException( "More subcomponents in profile than allowed in message: " + de.getMessage())); } } } checkExtraComponents(comp, profile.getSubComponents(), exList); } else { exList.add(new ProfileNotFollowedException("A component has primitive type " + type.getClass().getName() + " but the profile defines subcomponents")); } } return exList; }
exList.add(new ProfileNotHL7CompliantException(struct.getName() + " not found in message"));
exList.add(new ProfileNotHL7CompliantException(struct.getName() + " not found in message"));
exList.add(new ProfileNotHL7CompliantException("Field " + i + " not found in message"));
exList.add(new ProfileNotHL7CompliantException("Field " + i + " not found in message"));