ICD-9 Generator

| |
<%@ Page Language="C#"%>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.Collections.Specialized" %>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Data.Common" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Printing" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Net.Mail" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Text.RegularExpressions" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Windows.Forms" %>
<%@ Import Namespace="HealthPlus.ADAM.Server" %>
<%@ Import Namespace="HealthPlus.Cms.Custom" %>
<%@ Import Namespace="HealthPlus.Cms.Custom.Security" %>

<script runat="server">
    public static string connString = ConfigurationManager.ConnectionStrings["LDAP.DbConnection"].ToString();

    protected string GenerateSelectBox(string strCode)
    {
        string strSelectBoxText = "";
        string strCurrentPriCode = "";
        string strCurrentShortDesc = "";
        try
        {
            string query = "USE ektrontest SELECT * FROM icd9cm pr, icd9cm_group pa WHERE pr.icd9cm_group_id=pa.icd9cm_group_id AND pa.icd9cm_group_id = '" + strCode + "'";

          //  Response.Write(query + "<p>");

            using(SqlConnection conn = new SqlConnection(connString))
            {
                using(SqlCommand cmd = new SqlCommand(query, conn))
                {
                    conn.Open();
                    SqlDataReader rdr = cmd.ExecuteReader();
                    if(rdr.HasRows)
                    {
                        while(rdr.Read())
                        {
                            if(strCurrentPriCode == "")
                            {
                                strCurrentPriCode = rdr["icd9cm_pricode"].ToString();

                                    strCurrentShortDesc = rdr["icd9cm_shortdesc"].ToString();



                                    strSelectBoxText += "<tr><td colspan=3 align=center><strong>" + rdr["icd9cm_group_name"].ToString() + "</strong></td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
                                strSelectBoxText += "<tr><td><input type='checkbox' name='chk_" + rdr["icd9cm_pricode"].ToString() + "'></td><td><select style='width:80px;' size='1' name='sel_" + rdr["icd9cm_pricode"].ToString() + "'>";
                                strSelectBoxText += "<option value='" + rdr["icd9cm_id"].ToString() + "'>" + rdr["icd9cm_code"].ToString() + "</option>";
                            }
                            else
                            {
                                if(strCurrentPriCode != rdr["icd9cm_pricode"].ToString())
                                {

                                    strSelectBoxText += "</select></td><td>" + strCurrentShortDesc + "</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
                                    strCurrentPriCode = rdr["icd9cm_pricode"].ToString();
                                    strSelectBoxText += "<tr><td><input type='checkbox' name='chk_" + rdr["icd9cm_pricode"].ToString() + "'></td><td><select style='width:80px;' size='1' name='sel_" + rdr["icd9cm_pricode"].ToString() + "'>";
                                    strSelectBoxText += "<option value='" + rdr["icd9cm_id"].ToString() + "'>" + rdr["icd9cm_code"].ToString() + "</option>";
                                    if(strCurrentShortDesc != rdr["icd9cm_shortdesc"].ToString())
                                    {
                                        strCurrentShortDesc = rdr["icd9cm_shortdesc"].ToString();
                                    }
                                }
                                else
                                {

                                    strSelectBoxText += "<option value='" + rdr["icd9cm_id"].ToString() + "'>" + rdr["icd9cm_code"].ToString() + "</option>";
                                    if(strCurrentShortDesc != rdr["icd9cm_shortdesc"].ToString())
                                    {
                                        strCurrentShortDesc = rdr["icd9cm_shortdesc"].ToString();
                                    }
                                }
                            }


                        }
                        strSelectBoxText += "</select></td><td>" + strCurrentShortDesc + "</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
                        conn.Close();
                    }
                    else
                    {
                        Response.Write("Problem");
                    }
                }
            }
        }
        catch(Exception ee)
        {
            //  Response.Write("<p>Uh OH Problem</p>");
        }
        return strSelectBoxText;
    }


    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write("<form><table cellpadding='2' cellspacing='0' border='1'><tr><th colspan=2>ICD-9 CM Code</th><th>Diagnosis Description</th><th>&nbsp;</th><th colspan=2>ICD-9 CM Code</th><th>Diagnosis Description</th></tr>");
   Response.Write(GenerateSelectBox("1"));
        //Response.Write(GenerateSelectBox("2"));
        //Response.Write(GenerateSelectBox("3"));
        //Response.Write(GenerateSelectBox("4"));
        //Response.Write(GenerateSelectBox("5"));
        //Response.Write(GenerateSelectBox("6"));
        //Response.Write(GenerateSelectBox("7"));
        //Response.Write(GenerateSelectBox("8"));
        //Response.Write(GenerateSelectBox("9"));
        //Response.Write(GenerateSelectBox("10"));

      //  Response.Write(GenerateSelectBox("0"));
        Response.Write("</table></form>");

    }
</script>
Originally Posted on August 21, 2014
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.