/** * Inserts a repetition of a given Structure into repetitions of that structure by name. For * example, if the Group contains 10 repititions an OBX segment and an OBX is supplied with an * index of 2, then this call would insert the new repetition at index 2. Note that in this * case, the Set ID field in the OBX segments would also need to be renumbered manually. * * @param name structure name * @param index repetition to insert the structure * @return The inserted structure * @throws HL7Exception if the named Structure is not part of this Group. */ public Structure insertRepetition(String name, int index) throws HL7Exception { if (name == null || name.length() == 0) { throw new NullPointerException("Name may not be null/empty"); } Class<? extends Structure> structureClass = this.classes.get(name); if (structureClass == null) { throw new HL7Exception("Group " + this.getClass().getName() + " has no structure named " + name + ": Valid names: " + this.classes.keySet()); } Structure rep = tryToInstantiateStructure(structureClass, name); insertRepetition(name, rep, index); return rep; }
/** * Inserts a repetition of a given Structure into repetitions of that structure by name. For * example, if the Group contains 10 repititions an OBX segment and an OBX is supplied with an * index of 2, then this call would insert the new repetition at index 2. Note that in this * case, the Set ID field in the OBX segments would also need to be renumbered manually. * * @param name structure name * @param index repetition to insert the structure * @return The inserted structure * @throws HL7Exception if the named Structure is not part of this Group. */ public Structure insertRepetition(String name, int index) throws HL7Exception { if (name == null || name.length() == 0) { throw new NullPointerException("Name may not be null/empty"); } Class<? extends Structure> structureClass = this.classes.get(name); if (structureClass == null) { throw new HL7Exception("Group " + this.getClass().getName() + " has no structure named " + name + ": Valid names: " + this.classes.keySet()); } Structure rep = tryToInstantiateStructure(structureClass, name); insertRepetition(name, rep, index); return rep; }
ret = tryToInstantiateStructure(c, name); list.add(ret); } else {
ret = tryToInstantiateStructure(c, name); list.add(ret); } else {
public String addNonstandardSegment(String theName, int theIndex) throws HL7Exception { if (this instanceof Message && theIndex == 0) { throw new HL7Exception("Can not add nonstandard segment \"" + theName + "\" to start of message."); } String version = this.getMessage().getVersion(); if (version == null) throw new HL7Exception("Need message version to add segment by name; message.getVersion() returns null"); Class<? extends Segment> c = myFactory.getSegmentClass(theName, version); if (c == null) { c = GenericSegment.class; } tryToInstantiateStructure(c, theName); // may throw exception String newName = insert(c, false, true, theIndex, theName); if (this.nonStandardNames == null) { this.nonStandardNames = new HashSet<String>(); } this.nonStandardNames.add(newName); return newName; }
public String addNonstandardSegment(String theName, int theIndex) throws HL7Exception { if (this instanceof Message && theIndex == 0) { throw new HL7Exception("Can not add nonstandard segment \"" + theName + "\" to start of message."); } String version = this.getMessage().getVersion(); if (version == null) throw new HL7Exception("Need message version to add segment by name; message.getVersion() returns null"); Class<? extends Segment> c = myFactory.getSegmentClass(theName, version); if (c == null) { c = GenericSegment.class; } tryToInstantiateStructure(c, theName); // may throw exception String newName = insert(c, false, true, theIndex, theName); if (this.nonStandardNames == null) { this.nonStandardNames = new HashSet<String>(); } this.nonStandardNames.add(newName); return newName; }
/** * Expands the group definition to include a segment that is not defined by HL7 to be part of * this group (eg an unregistered Z segment). The new segment is slotted at the end of the * group. Thenceforward if such a segment is encountered it will be parsed into this location. * If the segment name is unrecognized a GenericSegment is used. The segment is defined as * repeating and not required. */ public String addNonstandardSegment(String name) throws HL7Exception { String version = this.getMessage().getVersion(); if (version == null) throw new HL7Exception("Need message version to add segment by name; message.getVersion() returns null"); Class<? extends Segment> c = myFactory.getSegmentClass(name, version); if (c == null) c = GenericSegment.class; int index = this.getNames().length; tryToInstantiateStructure(c, name); // may throw exception String newName = insert(c, false, true, index, name); if (this.nonStandardNames == null) { this.nonStandardNames = new HashSet<String>(); } this.nonStandardNames.add(newName); return newName; }
/** * Expands the group definition to include a segment that is not defined by HL7 to be part of * this group (eg an unregistered Z segment). The new segment is slotted at the end of the * group. Thenceforward if such a segment is encountered it will be parsed into this location. * If the segment name is unrecognized a GenericSegment is used. The segment is defined as * repeating and not required. */ public String addNonstandardSegment(String name) throws HL7Exception { String version = this.getMessage().getVersion(); if (version == null) throw new HL7Exception("Need message version to add segment by name; message.getVersion() returns null"); Class<? extends Segment> c = myFactory.getSegmentClass(name, version); if (c == null) c = GenericSegment.class; int index = this.getNames().length; tryToInstantiateStructure(c, name); // may throw exception String newName = insert(c, false, true, index, name); if (this.nonStandardNames == null) { this.nonStandardNames = new HashSet<String>(); } this.nonStandardNames.add(newName); return newName; }
Structure structure = tryToInstantiateStructure(nextClass, nextName); ((AbstractGroup) structure).appendStructureDescription(theStringBuilder, theIndent + PS_INDENT, nextOptional, nextRepeating, true, true, thePrintEmpty);
Structure structure = tryToInstantiateStructure(nextClass, nextName); ((AbstractGroup) structure).appendStructureDescription(theStringBuilder, theIndent + PS_INDENT, nextOptional, nextRepeating, true, true, thePrintEmpty);