/** * {@inheritDoc} */ @Override public String toString() { return "SegGroup[" + getName() + "]"; }
@Override public String toString() { return "Component[" + getName() + "]"; }
protected void checkEventType(String evType, StaticDef profile, List<HL7Exception> exList) throws HL7Exception { 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); } }
private StaticDef parseStaticProfile(Element elem) throws ProfileException { StaticDef message = new StaticDef(); message.setMsgType(elem.getAttribute("MsgType")); message.setEventType(elem.getAttribute("EventType")); message.setMsgStructID(elem.getAttribute("MsgStructID")); message.setOrderControl(elem.getAttribute("OrderControl")); message.setEventDesc(elem.getAttribute("EventDesc")); message.setIdentifier(elem.getAttribute("Identifier")); message.setRole(elem.getAttribute("Role")); Element md = getFirstElementByTagName("MetaData", elem); if (md != null) message.setMetaData(parseMetaData(md)); message.setImpNote(getValueOfFirstElement("ImpNote", elem)); message.setDescription(getValueOfFirstElement("Description", elem)); message.setReference(getValueOfFirstElement("Reference", elem)); parseChildren(message, elem); return message; }
/** * Tests a Type against the corresponding section of a profile. * * @param encoded optional encoded form of type (if you want to specify this -- if null, default * pipe-encoded form is used to check length and constant val) */ public List<HL7Exception> testType(Type type, AbstractComponent<?> profile, String encoded, String profileID) { List<HL7Exception> exList = new ArrayList<HL7Exception>(); if (encoded == null) encoded = PipeParser.encode(type, this.enc); testUsage(encoded, profile.getUsage(), profile.getName(), exList); if (!profile.getUsage().equals("X")) { checkDataType(profile.getDatatype(), type, exList); checkLength(profile.getLength(), profile.getName(), encoded, exList); checkConstantValue(profile.getConstantValue(), encoded, exList); testTypeAgainstTable(type, profile, profileID, exList); } return exList; }
/** Parses a component profile */ private AbstractComponent<?> parseComponentProfile(Element elem, boolean isSubComponent) throws ProfileException { AbstractComponent<?> comp = null; if (isSubComponent) { log.debug(" Parsing subcomp profile: " + elem.getAttribute("Name")); comp = new SubComponent(); } else { log.debug(" Parsing comp profile: " + elem.getAttribute("Name")); comp = new Component(); int childIndex = 1; NodeList children = elem.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node n = children.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { Element child = (Element) n; if (child.getNodeName().equalsIgnoreCase("SubComponent")) { SubComponent subcomp = (SubComponent) parseComponentProfile(child, true); ((Component) comp).setSubComponent(childIndex++, subcomp); } } } } parseAbstractComponentData(comp, elem); return comp; }
protected void checkMessageStructure(String msgStruct, StaticDef profile, List<HL7Exception> exList) { 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); } }
protected void checkMessageType(String msgType, StaticDef profile, List<HL7Exception> exList) throws HL7Exception { if (!msgType.equals(profile.getMsgType())) { HL7Exception e = new ProfileNotFollowedException("Message type " + msgType + " doesn't match profile type of " + profile.getMsgType()); exList.add(e); } }
/** Parses a segment group profile */ private SegGroup parseSegmentGroupProfile(Element elem) throws ProfileException { SegGroup group = new SegGroup(); log.debug("Parsing segment group profile: " + elem.getAttribute("Name")); parseProfileStuctureData(group, elem); parseChildren(group, elem); return group; }
/** * @see Validator#validate */ public HL7Exception[] validate(Message message, StaticDef profile) throws ProfileException, HL7Exception { List<HL7Exception> exList = new ArrayList<HL7Exception>(); Terser t = new Terser(message); checkMessageType(t.get("/MSH-9-1"), profile, exList); checkEventType(t.get("/MSH-9-2"), profile, exList); checkMessageStructure(t.get("/MSH-9-3"), profile, exList); exList.addAll(doTestGroup(message, profile, profile.getIdentifier(), validateChildren)); return exList.toArray(new HL7Exception[exList.size()]); }
private StaticDef parseStaticProfile(Element elem) throws ProfileException { StaticDef message = new StaticDef(); message.setMsgType(elem.getAttribute("MsgType")); message.setEventType(elem.getAttribute("EventType")); message.setMsgStructID(elem.getAttribute("MsgStructID")); message.setOrderControl(elem.getAttribute("OrderControl")); message.setEventDesc(elem.getAttribute("EventDesc")); message.setIdentifier(elem.getAttribute("Identifier")); message.setRole(elem.getAttribute("Role")); Element md = getFirstElementByTagName("MetaData", elem); if (md != null) message.setMetaData(parseMetaData(md)); message.setImpNote(getValueOfFirstElement("ImpNote", elem)); message.setDescription(getValueOfFirstElement("Description", elem)); message.setReference(getValueOfFirstElement("Reference", elem)); parseChildren(message, elem); return message; }
/** * Tests a Type against the corresponding section of a profile. * * @param encoded optional encoded form of type (if you want to specify this -- if null, default * pipe-encoded form is used to check length and constant val) */ public List<HL7Exception> testType(Type type, AbstractComponent<?> profile, String encoded, String profileID) { List<HL7Exception> exList = new ArrayList<HL7Exception>(); if (encoded == null) encoded = PipeParser.encode(type, this.enc); testUsage(encoded, profile.getUsage(), profile.getName(), exList); if (!profile.getUsage().equals("X")) { checkDataType(profile.getDatatype(), type, exList); checkLength(profile.getLength(), profile.getName(), encoded, exList); checkConstantValue(profile.getConstantValue(), encoded, exList); testTypeAgainstTable(type, profile, profileID, exList); } return exList; }
/** Parses a component profile */ private AbstractComponent<?> parseComponentProfile(Element elem, boolean isSubComponent) throws ProfileException { AbstractComponent<?> comp = null; if (isSubComponent) { log.debug(" Parsing subcomp profile: " + elem.getAttribute("Name")); comp = new SubComponent(); } else { log.debug(" Parsing comp profile: " + elem.getAttribute("Name")); comp = new Component(); int childIndex = 1; NodeList children = elem.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node n = children.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { Element child = (Element) n; if (child.getNodeName().equalsIgnoreCase("SubComponent")) { SubComponent subcomp = (SubComponent) parseComponentProfile(child, true); ((Component) comp).setSubComponent(childIndex++, subcomp); } } } } parseAbstractComponentData(comp, elem); return comp; }
/** * {@inheritDoc} */ @Override public String toString() { return "SegGroup[" + getName() + "]"; }
@Override public String toString() { return "Component[" + getName() + "]"; }
protected void checkEventType(String evType, StaticDef profile, List<HL7Exception> exList) throws HL7Exception { 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); } }
protected void checkMessageStructure(String msgStruct, StaticDef profile, List<HL7Exception> exList) { 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); } }
protected void checkMessageType(String msgType, StaticDef profile, List<HL7Exception> exList) throws HL7Exception { if (!msgType.equals(profile.getMsgType())) { HL7Exception e = new ProfileNotFollowedException("Message type " + msgType + " doesn't match profile type of " + profile.getMsgType()); exList.add(e); } }
/** Parses a segment group profile */ private SegGroup parseSegmentGroupProfile(Element elem) throws ProfileException { SegGroup group = new SegGroup(); log.debug("Parsing segment group profile: " + elem.getAttribute("Name")); parseProfileStuctureData(group, elem); parseChildren(group, elem); return group; }
/** * @see Validator#validate */ public HL7Exception[] validate(Message message, StaticDef profile) throws ProfileException, HL7Exception { List<HL7Exception> exList = new ArrayList<HL7Exception>(); Terser t = new Terser(message); checkMessageType(t.get("/MSH-9-1"), profile, exList); checkEventType(t.get("/MSH-9-2"), profile, exList); checkMessageStructure(t.get("/MSH-9-3"), profile, exList); exList.addAll(doTestGroup(message, profile, profile.getIdentifier(), validateChildren)); return exList.toArray(new HL7Exception[exList.size()]); }