Esempio n. 1
0
        /// <summary> Sets the string value of the field specified.  See class docs for location spec syntax.</summary>
        public virtual void  Set(System.String spec, System.String value_Renamed)
        {
            Tokenizer tok     = new Tokenizer(spec, "-", false);
            Segment   segment = getSegment(tok.NextToken());

            int[] ind = getIndices(spec);
            if (log.DebugEnabled)
            {
                log.debug("Setting " + spec + " seg: " + segment.getStructureName() + " ind: " + ind[0] + " " + ind[1] + " " + ind[2] + " " + ind[3]);
            }
            Set(segment, ind[0], ind[1], ind[2], ind[3], value_Renamed);
        }
Esempio n. 2
0
        /* for configurability (maybe to add later, replacing hard-coded options
         * in nextFromEndOfGroup) ...
         * public void setSearchLevel(String level) {
         * if (WHOLE_GROUP.equals(level)) {
         * this.findUpToFirstRequired = false;
         * this.findFirstDescendentsOnly = false;
         * } else if (FIRST_DESCENDENTS_ONLY.equals(level)) {
         * this.findUpToFirstRequired = false;
         * this.findFirstDescendentsOnly = true;
         * } else if (UP_TO_FIRST_REQUIRED.equals(level)) {
         * this.findUpToFirstRequired = true;
         * this.findFirstDescendentsOnly = false;
         * } else {
         * throw IllegalArgumentException(level + " is not a valid search level.  Should be WHOLE_GROUP, etc.");
         * }
         * }
         *
         * public String getSearchLevel() {
         * String level = WHOLE_GROUP;
         * if (this.findFirstDescendentsOnly) {
         * level = FIRST_DESCENDENTS_ONLY;
         * } else if (this.findUpTpFirstRequired) {
         * level = UP_TO_FIRST_REQUIRED;
         * }
         * return level;
         * }*/


        /// <summary> Returns true if another object exists in the iteration sequence.  </summary>
        public virtual bool MoveNext()
        {
            bool has = true;

            if (next_Renamed_Field == null)
            {
                if (typeof(Group).IsAssignableFrom(currentStructure.GetType()))
                {
                    groupNext((Group)currentStructure);
                }
                else
                {
                    Group    parent          = currentStructure.ParentGroup;
                    Index    i               = getIndex(parent, currentStructure);
                    Position currentPosition = new Position(parent, i);

                    try
                    {
                        if (parent.isRepeating(i.name) && currentStructure.getStructureName().Equals(direction))
                        {
                            nextRep(currentPosition);
                        }
                        else
                        {
                            has = nextPosition(currentPosition, this.direction, this.handleUnexpectedSegments);
                        }
                    }
                    catch (HL7Exception e)
                    {
                        //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                        throw new System.ApplicationException("HL7Exception arising from bad index: " + e.Message);
                    }
                }
            }
            log.debug("MessageIterator.hasNext() in direction " + this.direction + "? " + has);
            return(has);
        }
Esempio n. 3
0
        /// <summary> Populates the given error segment with information from this Exception.</summary>
        public virtual void  populate(Segment errorSegment)
        {
            //make sure it's an ERR
            if (!errorSegment.getStructureName().Equals("ERR"))
            {
                throw new HL7Exception("Can only populate an ERR segment with an exception -- got: " + errorSegment.GetType().FullName);
            }

            int rep = errorSegment.getField(1).Length;             //append after existing reps

            if (this.SegmentName != null)
            {
                Terser.Set(errorSegment, 1, rep, 1, 1, this.SegmentName);
            }

            if (this.SegmentRepetition >= 0)
            {
                Terser.Set(errorSegment, 1, rep, 2, 1, System.Convert.ToString(this.SegmentRepetition));
            }

            if (this.FieldPosition >= 0)
            {
                Terser.Set(errorSegment, 1, rep, 3, 1, System.Convert.ToString(this.FieldPosition));
            }

            Terser.Set(errorSegment, 1, rep, 4, 1, System.Convert.ToString(this.errCode));
            Terser.Set(errorSegment, 1, rep, 4, 3, "hl70357");
            //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
            Terser.Set(errorSegment, 1, rep, 4, 5, this.Message);

            //try to get error condition text
            try
            {
                System.String desc = TableRepository.Instance.getDescription(357, System.Convert.ToString(this.errCode));
                Terser.Set(errorSegment, 1, rep, 4, 2, desc);
            }
            catch (LookupException e)
            {
                ourLog.debug("Warning: LookupException getting error condition text (are we connected to a TableRepository?)", e);
            }
        }