Пример #1
0
        //find all the segments in a specific range
        //used to clear out a section when it is getting rechecked
        //need to expand selection from these bounds out around full words
        public IHighlightSegmentRaw[] GetSegments(IMarkupPointerRaw start, IMarkupPointerRaw end)
        {
            if (list.Count == 0)
            {
                return(null);
            }
            int  firstSegmentInd = -1;
            int  lastSegmentInd  = list.Count;
            bool test;

            //find the first segment after the start pointer
            do
            {
                firstSegmentInd++;
                //check if we have gone through the whole selection
                if (firstSegmentInd >= lastSegmentInd)
                {
                    return(null);
                }
                SegmentDef x = (SegmentDef)list.GetByIndex(firstSegmentInd);
                start.IsRightOf(x.startPtr, out test);
            } while (test);
            do
            {
                lastSegmentInd--;
                //check if we have gone through the whole selection
                if (lastSegmentInd < firstSegmentInd)
                {
                    return(null);
                }
                SegmentDef x = (SegmentDef)list.GetByIndex(lastSegmentInd);
                end.IsLeftOf(x.startPtr, out test);
            } while (test);
            return(Subarray(firstSegmentInd, lastSegmentInd));
        }
Пример #2
0
        public void ConstructorTests()
        {
            SegmentDef pd = new SegmentDef(1, UrlDefinitionDataTypes.Data, "value");

            Assert.AreEqual <int>(pd.Order, 1);
            Assert.AreEqual <string>(pd.Type.ToString(), UrlDefinitionDataTypes.Data.ToString());
            Assert.AreEqual <string>(pd.Value, "value");
        }
Пример #3
0
        public SegmentDef[] GetSegments(string message, string version)
        {
            ArrayList returnValue = new ArrayList();

            foreach (MessageDefinitionContainerMock messageDefinition in Messages)
            {
                if (messageDefinition.Message.Equals(message))
                {
                    returnValue = messageDefinition.Segments;
                }
            }
            SegmentDef[] ret = new SegmentDef[returnValue.Count];
            Array.Copy(returnValue.ToArray(), ret, returnValue.Count);
            return(ret);
        }
Пример #4
0
        public SegmentDef[] GetSegments(string message, string version)
        {
            LoadXmlFile();
            var hl7Grammar = _hl7Versions.HL7Version.Where(v => v.Version.Equals(version)).SingleOrDefault()
                             .Grammars.Where(g => g.Message.Equals(message)).SingleOrDefault();
            ArrayList segments = new ArrayList();

            if (null != hl7Grammar)
            {
                foreach (var segment in hl7Grammar.Segments)
                {
                    segments.Add(new SegmentDef(segment.Name, segment.Group, segment.Required, segment.Repeating, segment.Description));
                }
            }
            SegmentDef[] ret = new SegmentDef[segments.Count];
            Array.Copy(segments.ToArray(), ret, segments.Count);
            return(ret);
        }
Пример #5
0
        //find all the segments with a specific misspelled word
        //used to clear for ignore all, add to dictionary
        public MatchingSegment[] GetSegments(string word, CheckWordSpelling checkSpelling)
        {
            ArrayList segments = new ArrayList();

            for (int i = 0; i < list.Count; i++)
            {
                SegmentDef x = (SegmentDef)list.GetByIndex(i);
                //TODO: Change with new cultures added!!!
                if (0 == String.Compare(word, x.word, true, CultureInfo.InvariantCulture))
                {
                    //check spelling--capitalized word may be ok, but not mixed case, etc.
                    if (!checkSpelling(x.word))
                    {
                        segments.Add(new MatchingSegment(x.segment, x.startPtr));
                    }
                }
            }
            return((MatchingSegment[])segments.ToArray(typeof(MatchingSegment)));
        }
Пример #6
0
        /// <summary> Queries the normative database for a list of segments comprising
        /// the message structure.  The returned list may also contain strings
        /// that denote repetition and optionality.  Choice indicators (i.e. begin choice,
        /// next choice, end choice) for alternative segments are ignored, so that the class
        /// structure allows all choices.  The matter of enforcing that only a single choice is
        /// populated can't be handled by the class structure, and should be handled elsewhere.
        /// </summary>
        public SegmentDef[] GetSegments(string message, string version)
        {
            /*String sql = "select HL7Segments.seg_code, repetitional, optional, description " +
             * "from (HL7MsgStructIDSegments inner join HL7Segments on HL7MsgStructIDSegments.seg_code = HL7Segments.seg_code " +
             * "and HL7MsgStructIDSegments.version_id = HL7Segments.version_id) " +
             * "where HL7Segments.version_id = 6 and message_structure = '" + message + "' order by seq_no";*/
            String sql = getSegmentListQuery(message, version);

            //System.out.println(sql.toString());
            SegmentDef[]    segments = new SegmentDef[200];                   //presumably there won't be more than 200
            OleDbConnection conn     = NormativeDatabase.Instance.Connection;
            OleDbCommand    stmt     = SupportClass.TransactionManager.manager.CreateStatement(conn);
            OleDbCommand    temp_OleDbCommand;

            temp_OleDbCommand             = stmt;
            temp_OleDbCommand.CommandText = sql;
            OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();
            int             c  = -1;

            while (rs.Read())
            {
                String name      = SegmentGenerator.altSegName(Convert.ToString(rs[1 - 1]));
                bool   repeating = rs.GetBoolean(2 - 1);
                bool   optional  = rs.GetBoolean(3 - 1);
                String desc      = Convert.ToString(rs[4 - 1]);
                String groupName = Convert.ToString(rs[6 - 1]);

                //ignore the "choice" directives ... the message class structure has to include all choices ...
                //  if this is enforced (i.e. exception thrown if >1 choice populated) this will have to be done separately.
                if (!(name.Equals("<") || name.Equals("|") || name.Equals(">")))
                {
                    c++;
                    segments[c] = new SegmentDef(name, groupName, !optional, repeating, desc);
                }
            }
            rs.Close();
            SegmentDef[] ret = new SegmentDef[c + 1];
            Array.Copy(segments, 0, ret, 0, c + 1);
            return(ret);
        }
Пример #7
0
        public MisspelledWordInfo FindSegment(MshtmlMarkupServices markupServices, IMarkupPointerRaw current)
        {
            //binary search
            int start = 0;
            int end   = list.Count - 1;
            int i     = Middle(start, end);

            while (-1 != i)
            {
                SegmentDef x = (SegmentDef)list.GetByIndex(i);
                bool       startTest;
                current.IsRightOfOrEqualTo(x.startPtr, out startTest);
                if (startTest)
                {
                    bool endTest;
                    current.IsLeftOfOrEqualTo(x.endPtr, out endTest);
                    if (endTest)
                    {
                        MarkupPointer pStart = markupServices.CreateMarkupPointer(x.startPtr);
                        MarkupPointer pEnd   = markupServices.CreateMarkupPointer(x.endPtr);
                        MarkupRange   range  = markupServices.CreateMarkupRange(pStart, pEnd);
                        //this could be a "phantom" range...no more content due to uncommitted damage or other reasons
                        //if it is phantom, remove it from the tracker and return null
                        if (range.Text == null)
                        {
                            list.RemoveAt(i);
                            return(null);
                        }
                        return(new MisspelledWordInfo(range, x.word));
                    }
                    start = i + 1;
                }
                else
                {
                    end = i - 1;
                }
                i = Middle(start, end);
            }
            return(null);
        }