Exemple #1
0
        /// <summary> Generates source code for all data types, segments, groups, and messages.</summary>
        /// <param name="baseDirectory">the directory where source should be written
        /// </param>
        public static void  makeAll(System.String baseDirectory, System.String version)
        {
            //load driver and set DB URL

            /*if (System.getProperty("ca.on.uhn.hl7.database.url") == null) {
             * System.setProperty("ca.on.uhn.hl7.database.url", "jdbc:odbc:hl7");
             * }*/

            try
            {
                System.Type.GetType("sun.jdbc.odbc.JdbcOdbcDriver");
                NuGenDataTypeGenerator.makeAll(baseDirectory, version);
                NuGenSegmentGenerator.makeAll(baseDirectory, version);
                NuGenMessageGenerator.makeAll(baseDirectory, version);
                // group and message not implemented
            }
            catch (System.Exception e)
            {
                SupportClass.WriteStackTrace(e, Console.Error);
            }
        }
Exemple #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 NuGenSegmentDef[] getSegments(System.String message, System.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";*/
            System.String sql = getSegmentListQuery(message, version);
            //System.out.println(sql.toString());
            NuGenSegmentDef[] segments             = new NuGenSegmentDef[200]; //presumably there won't be more than 200
            System.Data.OleDb.OleDbConnection conn = NuGenNormativeDatabase.Instance.Connection;
            System.Data.OleDb.OleDbCommand    stmt = SupportClass.TransactionManager.manager.CreateStatement(conn);
            System.Data.OleDb.OleDbCommand    temp_OleDbCommand;
            temp_OleDbCommand             = stmt;
            temp_OleDbCommand.CommandText = sql;
            System.Data.OleDb.OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();
            int c = -1;

            while (rs.Read())
            {
                System.String name      = NuGenSegmentGenerator.altSegName(System.Convert.ToString(rs[1 - 1]));
                bool          repeating = rs.GetBoolean(2 - 1);
                bool          optional  = rs.GetBoolean(3 - 1);
                System.String desc      = System.Convert.ToString(rs[4 - 1]);
                System.String groupName = version.ToUpper().Equals("2.3.1".ToUpper())?null:System.Convert.ToString(rs[6 - 1]);                 //group names are defined in DB for 2.3.1 but not used in the schema

                //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 NuGenSegmentDef(name, groupName, !optional, repeating, desc);
                }
            }
            NuGenSegmentDef[] ret = new NuGenSegmentDef[c + 1];
            Array.Copy(segments, 0, ret, 0, c + 1);

            return(ret);
        }