public void InsertData(string currUser, PatientDiagnosisModel oClass)
        {
            strSql = strSql + "INSERT INTO " + TABLE_NAME + " (" +
                     COLUMN_ENCOUNTER_NO + ", " +
                     COLUMN_CASE_NO + ", " +
                     COLUMN_PATIENT_NO + ", " +
                     COLUMN_DATE + ", " +
                     COLUMN_CODE + ", " +
                     COLUMN_DESCRIPTION + ", " +
                     COLUMN_NOTES + ", " +
                     "created_by, created_date, updated_by, updated_date) ";
            strSql = strSql + "values ('" +
                     oClass.EncounterNo + "', '" +
                     oClass.CaseNo + "', '" +
                     oClass.PatientNo + "', '" +
                     oClass.StartDate.ToString("yyyy-MM-d HH:MM:ss") + "', '" +
                     oClass.Code + "', '" +
                     oClass.Description + "', '" +
                     oClass.Notes.Replace("'", "") + "', '" +
                     currUser + "', " +
                     "CurDate(), '" +
                     currUser + "', " +
                     "CurDate() " +
                     ") ";

            SaveData(strSql);
        }
        public DataSet SeachData(PatientDiagnosisModel oClass)
        {
            string fname     = "";
            string lname     = "";
            string patientNo = oClass.PatientNo;
            string caseNo    = oClass.CaseNo;

            strSql = "SELECT A.*, Concat(B.FirstName, ' ', B.LastName) as PatientName  " +
                     "FROM " + TABLE_NAME + " A INNER JOIN " + TABLE_PATIENT + " B on A.PatientNo = B.PatientNo  Where 1=1 and A.IsDeleted = 0 ";

            if (fname != "")
            {
                strSql = strSql + "AND B." + COLUMN_FIRSTNAME + " like '%" + fname + "%' ";
            }
            if (lname != "")
            {
                strSql = strSql + "AND B." + COLUMN_LASTNAME + " like '%" + lname + "%' ";
            }
            if (patientNo != "")
            {
                strSql = strSql + "AND A." + COLUMN_PATIENT_NO + " = '" + patientNo + "' ";
            }
            if (caseNo != "")
            {
                strSql = strSql + "AND A." + COLUMN_CASE_NO + " like '%" + caseNo + "%' ";
            }

            return(Select(strSql));
        }
        public DataSet SelectByEncounterNo(PatientDiagnosisModel oClass)
        {
            strSql = "SELECT * " +
                     "FROM " + TABLE_NAME + " " +
                     "WHERE " + COLUMN_ENCOUNTER_NO + " = '" + oClass.EncounterNo + "' ";

            return(Select(strSql));
        }
        public DataSet SelectByID(PatientDiagnosisModel oClass)
        {
            strSql = "SELECT * " +
                     "FROM " + TABLE_NAME + " " +
                     "WHERE " + COLUMN_ID + " = '" + oClass.ID + "' ";

            return(Select(strSql));
        }
        public void DeleteData(string user, PatientDiagnosisModel oClass)
        {
            strSql = "UPDATE " + TABLE_NAME + " SET " +
                     " isDeleted = 1, " +
                     " ReasonDelete = '" + oClass.ReasonDelete.Replace("'", "''") + "', " +
                     " updated_by = '" + user + "', " +
                     " updated_date = '" + DateTime.Now.ToString("yyyy-MM-d HH:MM:ss") + "' " +
                     " WHERE " + COLUMN_ID + " = '" + oClass.ID + "' ";

            SaveData(strSql);
        }
        private void PopulateDiagnosis(string encounterNo)
        {
            PatientDiagnosisDAL   diagnosisDAL   = new PatientDiagnosisDAL();
            PatientDiagnosisModel diagnosisModel = new PatientDiagnosisModel();

            oDs = new DataSet();
            diagnosisModel.EncounterNo = encounterNo;
            oDs = diagnosisDAL.SelectByEncounterNo(diagnosisModel);

            gvDiagnosis.DataSource = oDs.Tables[0];
            gvDiagnosis.DataBind();
        }
        public void UpdateData(string user, PatientDiagnosisModel oClass)
        {
            strSql = "UPDATE " + TABLE_NAME + " SET " +
                     COLUMN_ENCOUNTER_NO + " = '" + oClass.EncounterNo + "', " +
                     COLUMN_CASE_NO + " = '" + oClass.CaseNo + "', " +
                     COLUMN_PATIENT_NO + " = '" + oClass.PatientNo + "', " +
                     COLUMN_DATE + " = '" + oClass.StartDate.ToString("yyyy-MM-d HH:MM:ss") + "', " +
                     COLUMN_CODE + " = '" + oClass.Code + "', " +
                     COLUMN_DESCRIPTION + " = '" + oClass.Description + "', " +
                     COLUMN_NOTES + " = '" + oClass.Notes.Replace("'", "''") + "', " +
                     " updated_by = '" + user + "', " +
                     " updated_date = '" + DateTime.Now.ToString("yyyy-MM-d HH:MM:ss") + "' " +
                     " WHERE " + COLUMN_ID + " = '" + oClass.ID + "' ";

            SaveData(strSql);
        }
        protected void DeleteDiagnosis_ServerClick(object sender, EventArgs e)
        {
            string UserName = Session["User"].ToString();
            int    ID       = Convert.ToInt32(HiddenFieldPatientDiagnosis.Value);

            PatientDiagnosisDAL   oDiagnosisDAL   = new PatientDiagnosisDAL();
            PatientDiagnosisModel oDiagnosisClass = new PatientDiagnosisModel();

            oDiagnosisClass.IsDeleted    = true;
            oDiagnosisClass.ReasonDelete = itemname.InnerText;
            string lbl = lblPatientDiagnosis.Text;

            oDiagnosisClass.ID = ID;
            oDiagnosisDAL.DeleteData(UserName, oDiagnosisClass);

            PopulateDiagnosis(EncounterNo.Value);
        }
        protected void AddDiagnosis_ServerClick(object sender, EventArgs e)
        {
            string sUserName = Session["User"].ToString();

            PatientDiagnosisDAL   oDiagnosisDAL   = new PatientDiagnosisDAL();
            PatientDiagnosisModel oDiagnosisClass = new PatientDiagnosisModel();

            oDiagnosisClass.CaseNo      = RefNo.Value;
            oDiagnosisClass.Code        = txtICDCode.Value;
            oDiagnosisClass.Description = txtICDDescription.Value;
            oDiagnosisClass.PatientNo   = PatientNo.Value;
            oDiagnosisClass.StartDate   = DateTime.Now;
            oDiagnosisClass.Notes       = "";
            oDiagnosisDAL.InsertData(sUserName, oDiagnosisClass);

            PopulateDiagnosis(RefNo.Value);
        }
        private void PopulateDiagnosis(string caseNo)
        {
            PatientDiagnosisDAL   diagnosisDAL   = new PatientDiagnosisDAL();
            PatientDiagnosisModel diagnosisModel = new PatientDiagnosisModel();

            oDs = new DataSet();

            diagnosisModel.CaseNo    = caseNo;
            diagnosisModel.PatientNo = PatientNo.Value;

            oDs = diagnosisDAL.SeachData(diagnosisModel);

            if (oDs != null)
            {
                gvDiagnosis.DataSource = oDs.Tables[0];
                gvDiagnosis.DataBind();
            }
        }
        private void PopulateDiagnosis(string encounterNo)
        {
            lblDiagnosis.Text = "";
            PatientDiagnosisDAL   diagnosisDAL   = new PatientDiagnosisDAL();
            PatientDiagnosisModel diagnosisModel = new PatientDiagnosisModel();
            var oDs = new DataSet();

            diagnosisModel.EncounterNo = encounterNo;
            oDs = diagnosisDAL.SelectByEncounterNo(diagnosisModel);

            if (oDs != null)
            {
                if (oDs.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i <= oDs.Tables[0].Rows.Count - 1; i++)
                    {
                        lblDiagnosis.Text = lblDiagnosis.Text + "<br>" + oDs.Tables[0].Rows[i]["Description"].ToString();
                    }
                }
            }
        }