/** * Inserts a repetition of * CTD-2: "Contact Name" at a specific index * * @param rep The repetition index (0-indexed) * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) */ public XPN insertCtd2_ContactName(int rep) throws HL7Exception { return (XPN) super.insertRepetition(2, rep); }
/** * Removes a repetition of * FAC-3: "Facility Address" at a specific index * * @param rep The repetition index (0-indexed) * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) */ public XAD removeFac3_FacilityAddress(int rep) throws HL7Exception { return (XAD) super.removeRepetition(3, rep); }
/** * Create an accessor for each field */ public NM getShoeSize() throws HL7Exception { return (NM) super.getField(1, 0); // 1=field num(numbered from 1) 0=repetition(numbered from 0) }
/** * Iterates over the contained fields and calls the visitor for each * of them. * * @param visitor MessageVisitor instance to be called back. * @param location location of the group * @return true if visiting shall continue, false if not * @throws HL7Exception */ public boolean accept(MessageVisitor visitor, Location location) throws HL7Exception { if (visitor.start(this, location)) { String[] names = getNames(); for (int i = 1; i <= names.length; i++) { Field f = new Field(getField(i), getMaxCardinality(i)); Location nextLocation = f.provideLocation(location, i, -1); if (!f.accept(visitor, nextLocation)) break; } } return visitor.end(this, location); }
ensureEnoughFields(number); + getName() + " - there are currently only " + fields.size() + " reps."); Type newType = createNewType(number); arr.add(newType);
/** * {@inheritDoc } * * <p> * <b>Note that this method will not currently work to parse an MSH segment * if the encoding characters are not already set. This limitation should be * resolved in a future version</b> * </p> */ public void parse(String string) throws HL7Exception { if (string == null) { throw new NullPointerException("String can not be null"); } EncodingCharacters encodingCharacters; try { encodingCharacters = EncodingCharacters.getInstance(getMessage()); } catch (HL7Exception e) { throw new HL7Exception(ERROR_MSH_1_OR_2_NOT_SET); } clear(); getMessage().getParser().parse(this, string, encodingCharacters); }
/** * Called from getField(...) methods. If a field has been requested that * doesn't exist (eg getField(15) when only 10 fields in segment) adds * Varies fields to the end of the segment up to the required number. */ private void ensureEnoughFields(int fieldRequested) { int fieldsToAdd = fieldRequested - this.numFields(); if (fieldsToAdd < 0) { fieldsToAdd = 0; } try { for (int i = 0; i < fieldsToAdd; i++) { this.add(Varies.class, false, 0, 65536, null); // using 65536 // following // example of // OBX-5 } } catch (HL7Exception e) { log.error( "Can't create additional generic fields to handle request for field " + fieldRequested, e); } }
/** * @deprecated Use {@link #add(Class, boolean, int, int, Object[], String)} */ protected void add(Class<? extends Type> c, boolean required, int maxReps, int length, Object[] constructorArgs) throws HL7Exception { add(c, required, maxReps, length, constructorArgs, null); }
/** * Inserts a repetition of a given Field into repetitions of that field by * name. * * @return The newly created and inserted field * @throws HL7Exception * if the named Structure is not part of this Group. */ public Type insertRepetition(int fieldNum, int index) throws HL7Exception { if (fieldNum < 1 || fieldNum > fields.size()) { throw new HL7Exception("The field " + fieldNum + " does not exist in the segment " + this.getClass().getName()); } List<Type> list = fields.get(fieldNum - 1); Type newType = createNewType(fieldNum); list.add(index, newType); return newType; }
/** * Iterates over the contained fields and calls the visitor for each * of them. * * @param visitor MessageVisitor instance to be called back. * @param location location of the group * @return true if visiting shall continue, false if not * @throws HL7Exception */ public boolean accept(MessageVisitor visitor, Location location) throws HL7Exception { if (visitor.start(this, location)) { String[] names = getNames(); for (int i = 1; i <= names.length; i++) { Field f = new Field(getField(i), getMaxCardinality(i)); Location nextLocation = f.provideLocation(location, i, -1); if (!f.accept(visitor, nextLocation)) break; } } return visitor.end(this, location); }
ensureEnoughFields(number); + getName() + " - there are currently only " + fields.size() + " reps."); Type newType = createNewType(number); arr.add(newType);
/** * {@inheritDoc } * * <p> * <b>Note that this method will not currently work to parse an MSH segment * if the encoding characters are not already set. This limitation should be * resolved in a future version</b> * </p> */ public void parse(String string) throws HL7Exception { if (string == null) { throw new NullPointerException("String can not be null"); } EncodingCharacters encodingCharacters; try { encodingCharacters = EncodingCharacters.getInstance(getMessage()); } catch (HL7Exception e) { throw new HL7Exception(ERROR_MSH_1_OR_2_NOT_SET); } clear(); getMessage().getParser().parse(this, string, encodingCharacters); }
/** * Called from getField(...) methods. If a field has been requested that * doesn't exist (eg getField(15) when only 10 fields in segment) adds * Varies fields to the end of the segment up to the required number. */ private void ensureEnoughFields(int fieldRequested) { int fieldsToAdd = fieldRequested - this.numFields(); if (fieldsToAdd < 0) { fieldsToAdd = 0; } try { for (int i = 0; i < fieldsToAdd; i++) { this.add(Varies.class, false, 0, 65536, null); // using 65536 // following // example of // OBX-5 } } catch (HL7Exception e) { log.error( "Can't create additional generic fields to handle request for field " + fieldRequested, e); } }
/** * @deprecated Use {@link #add(Class, boolean, int, int, Object[], String)} */ protected void add(Class<? extends Type> c, boolean required, int maxReps, int length, Object[] constructorArgs) throws HL7Exception { add(c, required, maxReps, length, constructorArgs, null); }
/** * Inserts a repetition of a given Field into repetitions of that field by * name. * * @return The newly created and inserted field * @throws HL7Exception * if the named Structure is not part of this Group. */ public Type insertRepetition(int fieldNum, int index) throws HL7Exception { if (fieldNum < 1 || fieldNum > fields.size()) { throw new HL7Exception("The field " + fieldNum + " does not exist in the segment " + this.getClass().getName()); } List<Type> list = fields.get(fieldNum - 1); Type newType = createNewType(fieldNum); list.add(index, newType); return newType; }
/** * Inserts a repetition of * FAC-6: "Contact Title" at a specific index * * @param rep The repetition index (0-indexed) * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) */ public ST insertFac6_ContactTitle(int rep) throws HL7Exception { return (ST) super.insertRepetition(6, rep); }
/** * Removes a repetition of * FAC-5: "Contact Person" at a specific index * * @param rep The repetition index (0-indexed) * @throws HL7Exception If the rep is invalid (below 0, or too high for the allowable repetitions) */ public XCN removeContactPerson(int rep) throws HL7Exception { return (XCN) super.removeRepetition(5, rep); }
/** * Create an accessor for each field */ public ST[] getPetName() throws HL7Exception { return (ST[]) super.getField(1); // 1 - field num( numbered from 1) }