Example #1
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>
        private static SegmentDef[] GetSegments(string message, string version)
        {
            var sql = GetSegmentListQuery(message, version);

            // System.out.println(sql.toString());
            var segments = new SegmentDef[200]; // presumably there won't be more than 200
            var conn = NormativeDatabase.Instance.Connection;
            var stmt = TransactionManager.Manager.CreateStatement(conn);
            DbCommand temp_OleDbCommand;
            temp_OleDbCommand = stmt;
            temp_OleDbCommand.CommandText = sql;
            var rs = temp_OleDbCommand.ExecuteReader();
            var c = -1;
            while (rs.Read())
            {
                var name = SegmentGenerator.AltSegName(Convert.ToString(rs[1 - 1]));
                var repeating = rs.GetBoolean(2 - 1);
                var optional = rs.GetBoolean(3 - 1);
                var desc = Convert.ToString(rs[4 - 1]);
                var 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();
            var ret = new SegmentDef[c + 1];
            Array.Copy(segments, 0, ret, 0, c + 1);
            return ret;
        }
Example #2
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>
        private static 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
            OdbcConnection conn     = NormativeDatabase.Instance.Connection;
            DbCommand      stmt     = TransactionManager.manager.CreateStatement(conn);
            DbCommand      temp_OleDbCommand;

            temp_OleDbCommand             = stmt;
            temp_OleDbCommand.CommandText = sql;
            DbDataReader 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);
        }