Example #1
0
 private void btnRemove_Click(object sender, EventArgs e)
 {
     try
     {
         var rows =
             dgvValues.Rows.OfType <DataGridViewRow>().Where(row => Convert.ToBoolean(row.Cells[0].Value));
         if (rows.Any())
         {
             foreach (DataGridViewRow row in rows)
             {
                 dgvValues.Rows.Remove(row);
                 if (!lbRcDe.Items.Contains(row.Cells[2].Value))
                 {
                     lbRcDe.Items.Add(row.Cells[2].Value);
                 }
             }
         }
         else
         {
             CommonData.ShowMessage("Please select atleast one row from the grid.", CommonData.MsgBoxType.Error);
         }
     }
     catch (Exception ex)
     {
         Log.WriteToErrorLog(ex);
     }
 }
Example #2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvValues.Rows.Count > 0)
         {
             var mapList = new List <Settings.Mappings>();
             foreach (DataGridViewRow row in dgvValues.Rows)
             {
                 var map = new Settings.Mappings
                 {
                     ConfigId     = _configId,
                     DataSource   = _datasource,
                     ApiFieldName = Convert.ToString(row.Cells["clmRcde"].Value),
                     NbsFieldName = Convert.ToString(row.Cells["clmNbsDe"].Value),
                     TableName    = Convert.ToString(row.Cells["clmNbsTn"].Value),
                     ColumnName   = Convert.ToString(row.Cells["clmNbsCn"].Value)
                 };
                 mapList.Add(map);
             }
             if (_objSql.SaveMappings(mapList))
             {
                 CommonData.ShowMessage("Successfully saved.", CommonData.MsgBoxType.Info);
             }
             else
             {
                 CommonData.ShowMessage("Not successfully saved.", CommonData.MsgBoxType.Info);
             }
         }
     }
     catch (Exception ex)
     {
         Log.WriteToErrorLog(ex);
     }
 }
Example #3
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtServerName.Text) && !string.IsNullOrEmpty(txtDBName.Text) &&
         !string.IsNullOrEmpty(txtPassword.Text) && !string.IsNullOrEmpty(txtUserName.Text))
     {
         if (
             CommonData.ShowMessage(
                 "This action will delete the configuration which you have already created. Do you want to continue?",
                 CommonData.MsgBoxType.Question) == DialogResult.Yes)
         {
             Settings s = new Settings(Application.StartupPath);
             s.UpdateApiSettings("");
             txtServerName.Text       = "";
             txtDBName.Text           = "";
             txtPassword.Text         = "";
             txtUserName.Text         = "";
             txtPassword.PasswordChar = '\0';
             EnableFields();
         }
     }
     else
     {
         System.Windows.Forms.MessageBox.Show("Please enter valid connection", "NBS", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information, System.Windows.Forms.MessageBoxDefaultButton.Button1);
     }
 }
Example #4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvConfig.Rows.Count == 0)
                {
                    return;
                }
                var rows = dgvConfig.Rows.OfType <DataGridViewRow>().Where(row => Convert.ToBoolean(row.Cells[0].Value));
                if (rows.Any())
                {
                    if (
                        CommonData.ShowMessage(
                            "This action will delete the configuration which you have already created. Do you want to continue?",
                            CommonData.MsgBoxType.Question) == DialogResult.Yes)
                    // if(System.Windows.Forms.MessageBox.Show("Success", "Red Cap", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Question, System.Windows.Forms.MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                    {
                        var configIds = new List <string>();
                        foreach (DataGridViewRow row in rows)
                        {
                            string configId = Convert.ToString(row.Cells["clmConfigId"].Value);
                            configIds.Add(configId);
                        }

                        if (configIds.Count > 0)
                        {
                            if (_objSql.DeleteConfiguration(configIds))
                            {
                            }
                        }
                        try
                        {
                            if (rows.Any())
                            {
                                foreach (DataGridViewRow row in rows)
                                {
                                    dgvConfig.Rows.Remove(row);
                                }
                            }
                            ResetValues();
                        }
                        catch (Exception ex)
                        {
                            Log.WriteToErrorLog(ex);
                        }
                    }
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Please Select atleast one row", "Red Cap", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information, System.Windows.Forms.MessageBoxDefaultButton.Button1);
                }
            }
            catch (Exception ex)
            {
                Log.WriteToErrorLog(ex);
            }
        }
Example #5
0
        private void btnDelFromDb_Click(object sender, EventArgs e)
        {
            try
            {
                var rows = dgvValues.Rows.OfType <DataGridViewRow>().Where(row => Convert.ToBoolean(row.Cells[0].Value));

                if (rows.Any())
                {
                    if (
                        CommonData.ShowMessage(
                            "This action will delete the configuration which you have already created. Do you want to continue?",
                            CommonData.MsgBoxType.Question) == DialogResult.Yes)
                    {
                        var fldMapIds = new List <string>();
                        foreach (DataGridViewRow row in rows)
                        {
                            string fldId = Convert.ToString(row.Cells["clmFldMapId"].Value);
                            fldMapIds.Add(fldId);
                        }

                        if (fldMapIds.Count > 0)
                        {
                            if (_objSql.DeleteMappings(fldMapIds))
                            {
                            }
                        }

                        try
                        {
                            foreach (DataGridViewRow row in rows)
                            {
                                dgvValues.Rows.Remove(row);
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.WriteToErrorLog(ex);
                        }
                    }
                }
                else
                {
                    CommonData.ShowMessage("Please select atleast one row from the grid.", CommonData.MsgBoxType.Error);
                }
            }
            catch (Exception ex)
            {
                Log.WriteToErrorLog(ex);
            }
        }
Example #6
0
        private void cmbConfigList_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                dgvValues.Rows.Clear();
                string formName = Convert.ToString(cmbConfigList.SelectedItem);
                if (_configList.Count > 0)
                {
                    foreach (Settings.Credentials c in _configList)
                    {
                        if (c.FormName == formName)
                        {
                            _configId   = c.ConfigId;
                            _datasource = c.DataSource;
                            break;
                        }
                    }
                }
                Reset();
                redCapElemList.Clear();
                lbNbsDe.Items.Clear();
                lbRcDe.Items.Clear();
                FillGrid(formName);



                try
                {
                    if (cmbConfigList.SelectedIndex == -1)
                    {
                        CommonData.ShowMessage("Please select configuration first.", CommonData.MsgBoxType.Error);
                        return;
                    }
                    //dgvValues.Rows.Clear();
                    EnableControls(true);
                    FillValues(formName);
                    FillMsgQuestions();
                    FillTableNames();
                }
                catch (Exception ex)
                {
                    Log.WriteToErrorLog(ex);
                }
            }
            catch (Exception ex)
            {
                Log.WriteToErrorLog(ex);
            }
        }
Example #7
0
 private void btnReset_Click(object sender, EventArgs e)
 {
     try
     {
         if (
             CommonData.ShowMessage(
                 "This action will remove all the data you have added. Do you want to continue?",
                 CommonData.MsgBoxType.Question) == DialogResult.Yes)
         {
             Reset();
         }
     }
     catch (Exception ex)
     {
         Log.WriteToErrorLog(ex);
     }
 }
        private void btn_Save_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtQuesCode.Text) && !string.IsNullOrEmpty(txtQuesIdentifier.Text) && !string.IsNullOrEmpty(txtQuesDsc.Text) && !string.IsNullOrEmpty(txtQuesDisName.Text))
            {
                if (drp_Datatype.Text != "CODED" || drp_Datatype.Text == "CODED" & !string.IsNullOrEmpty(txtAnsSysCode.Text) & !string.IsNullOrEmpty(txtAnsCodeDis.Text) & !string.IsNullOrEmpty(txtAnsDisName.Text))
                {
                    var lookup = new Settings.QuestioLookup
                    {
                        DocTypeId          = "PHDC",
                        DocTypeVersionTxt  = "1.3",
                        QuesCodeSysCD      = txtQuesCode.Text,
                        QuesCodeSysDescTxt = txtQuesDsc.Text,
                        Data_Type          = drp_Datatype.Text,
                        QuesIdentifier     = txtQuesIdentifier.Text,
                        QuesDisplayName    = txtQuesDisName.Text,
                        SendingSysCD       = Datasource,

                        AnsFromCode           = txtAnsCode.Text,
                        AnsFromCodeSysCD      = txtAnsSysCode.Text,
                        AnsFromCodeSysDecsTxt = txtAnsCodeDis.Text,
                        AnsFromDisNM          = txtAnsDisName.Text,
                        CodeTransReq          = "NO",
                        InvestigationFormCd   = "INV_FORM_GEN"
                    };

                    if (_objSql.SaveLookup(lookup))
                    {
                        CommonData.ShowMessage("Look up is created successfully in NBS database.",
                                               CommonData.MsgBoxType.Info);
                        this.Close();
                    }
                }
                else
                {
                    CommonData.ShowMessage("Please enter the required values.",
                                           CommonData.MsgBoxType.Info);
                }
            }
            else
            {
                CommonData.ShowMessage("Please enter the required values.",
                                       CommonData.MsgBoxType.Info);
            }
        }
Example #9
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                string rcde = Convert.ToString(lbRcDe.SelectedItem);
                if (string.IsNullOrEmpty(rcde))
                {
                    CommonData.ShowMessage("Please select Data Element.", CommonData.MsgBoxType.Error);
                    return;
                }

                string nbsde = Convert.ToString(lbNbsDe.SelectedItem);
                if (string.IsNullOrEmpty(nbsde))
                {
                    CommonData.ShowMessage("Please select NBS Data Element.", CommonData.MsgBoxType.Error);
                    return;
                }

                string nbstn = Convert.ToString(cmbNbsTn.SelectedItem);
                if (string.IsNullOrEmpty(nbstn))
                {
                    CommonData.ShowMessage("Please select NBS Table Name.", CommonData.MsgBoxType.Error);
                    return;
                }

                string nbscn = Convert.ToString(cmbNbsCn.SelectedItem);
                if (string.IsNullOrEmpty(nbscn))
                {
                    CommonData.ShowMessage("Please select NBS Column Name.", CommonData.MsgBoxType.Error);
                    return;
                }

                dgvValues.Rows.Add(new object[] { false, "", rcde, nbsde, nbstn, nbscn });
                if (lbRcDe.Items.Contains(rcde))
                {
                    lbRcDe.Items.Remove(rcde);
                }
            }
            catch (Exception ex)
            {
                Log.WriteToErrorLog(ex);
            }
        }
        private void btnLoad_Click(object sender, EventArgs e)
        {
            try
            {
                dgvOrders.DataSource = null;
                dgvOrders.Columns.Clear();
                if (cmbConfigList.SelectedIndex == -1)
                {
                    CommonData.ShowMessage("Please select the configuration first.", CommonData.MsgBoxType.Error);
                    UpdateStatus("Please select the configuration first.");
                    return;
                }

                UpdateStatus("Please wait.. it is loading....");
                string    formName = Convert.ToString(cmbConfigList.SelectedItem);
                DataTable tbl      = _objSql.ReadSettings(formName);

                if (tbl != null && tbl.Rows.Count > 0)
                {
                    foreach (DataRow row in tbl.Rows)
                    {
                        string url               = Convert.ToString(row["redcapurl"]);
                        string token             = Convert.ToString(row["token"]);
                        string formname          = Convert.ToString(row["form_nm"]);
                        string excludeConditions = Convert.ToString(row["exclude_conditions"]);
                        string datasource        = Convert.ToString(row["datasource"]);
                        string lastimported      = Convert.ToString(row["LastImported"]);
                        string configid          = Convert.ToString(row["Config_id"]);

                        _siteOid = Convert.ToString(row["site_oid"]);
                        if (datasource == "Epi Info")
                        {
                            var       objClient = new Project(url, false);
                            DataTable datatable = objClient.GetData();

                            if (!string.IsNullOrEmpty(excludeConditions))
                            {
                                string qry  = "condition not in (" + excludeConditions + ")";
                                var    rows = datatable.Select(qry);
                                if (rows.Length > 0)
                                {
                                    DataTable newtbl = datatable.Clone();
                                    foreach (DataRow row1 in rows)
                                    {
                                        if (datatable.Columns.Contains("PAT_NAME_FIRST_TXT") && datatable.Columns.Contains("PAT_NAME_LAST_TXT") && datatable.Columns.Contains("INV_CONDITION_CD"))
                                        {
                                            if (!string.IsNullOrEmpty(row1["PAT_NAME_FIRST_TXT"].ToString()) && !string.IsNullOrEmpty(row1["PAT_NAME_LAST_TXT"].ToString()) && !string.IsNullOrEmpty(row1["INV_CONDITION_CD"].ToString()))
                                            {
                                                newtbl.ImportRow(row1);
                                            }
                                        }
                                        else
                                        {
                                            newtbl.ImportRow(row1);
                                        }
                                    }
                                    dgvOrders.DataSource = newtbl;
                                    if (!string.IsNullOrEmpty(lastimported))
                                    {
                                        DateTime importdt = Convert.ToDateTime(lastimported);
                                        foreach (DataGridViewRow r in dgvOrders.Rows)
                                        {
                                            DateTime lastsave = Convert.ToDateTime(r.Cells["LastSaveTime"].Value.ToString());
                                            if (lastsave <= importdt)
                                            {
                                                r.DefaultCellStyle.ForeColor = Color.Gray;
                                                if (CommonData.Credentials.HideImported != null && CommonData.Credentials.HideImported.ToLower() == "true")
                                                {
                                                    CurrencyManager currencyManager1 = (CurrencyManager)BindingContext[dgvOrders.DataSource];
                                                    currencyManager1.SuspendBinding();
                                                    dgvOrders.CurrentCell = null;
                                                    r.Visible             = false;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                dgvOrders.DataSource = datatable;
                                if (!string.IsNullOrEmpty(lastimported))
                                {
                                    DateTime importdt = Convert.ToDateTime(lastimported);
                                    foreach (DataGridViewRow r in dgvOrders.Rows)
                                    {
                                        if (!string.IsNullOrEmpty(r.Cells["LastSaveTime"].Value.ToString()))
                                        {
                                            DateTime lastsave = Convert.ToDateTime(r.Cells["LastSaveTime"].Value.ToString());
                                            if (lastsave <= importdt)
                                            {
                                                r.DefaultCellStyle.ForeColor = Color.Gray;
                                                if (CommonData.Credentials.HideImported != null && CommonData.Credentials.HideImported.ToLower() == "true")
                                                {
                                                    CurrencyManager currencyManager1 = (CurrencyManager)BindingContext[dgvOrders.DataSource];
                                                    currencyManager1.SuspendBinding();
                                                    dgvOrders.CurrentCell = null;
                                                    r.Visible             = false;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            var       objClient = new RedCapClient();
                            DataTable apitbl    = objClient.GetData(url, token, formname);
                            if (!string.IsNullOrEmpty(excludeConditions))
                            {
                                string qry = "condition not in (" + excludeConditions + ")";

                                var rows = apitbl.Select(qry);
                                if (rows.Length > 0)
                                {
                                    DataTable newtbl = apitbl.Clone();
                                    foreach (DataRow row1 in rows)
                                    {
                                        if (apitbl.Columns.Contains("patient_fname") && apitbl.Columns.Contains("patient_lname") && apitbl.Columns.Contains("condition"))
                                        {
                                            if (!string.IsNullOrEmpty(row1["patient_fname"].ToString()) && !string.IsNullOrEmpty(row1["patient_lname"].ToString()) && !string.IsNullOrEmpty(row1["condition"].ToString()))
                                            {
                                                newtbl.ImportRow(row1);
                                            }
                                        }
                                        else
                                        {
                                            newtbl.ImportRow(row1);
                                        }
                                    }
                                    newtbl.DefaultView.Sort = "record_id asc";
                                    dgvOrders.DataSource    = newtbl;
                                }
                            }
                            else
                            {
                                dgvOrders.DataSource = apitbl;
                            }
                            string locId = "";
                            foreach (DataGridViewRow r in dgvOrders.Rows)
                            {
                                string recId = Convert.ToString(r.Cells["record_id"].Value);
                                locId = "REDCap_" + configid + "_" + recId;
                                if (_objSql.Get_MSG_CONTAINER_Qry1(locId))
                                {
                                    r.DefaultCellStyle.ForeColor = Color.Gray;
                                    if (CommonData.Credentials.HideImported != null && CommonData.Credentials.HideImported.ToLower() == "true")
                                    {
                                        CurrencyManager currencyManager1 = (CurrencyManager)BindingContext[dgvOrders.DataSource];
                                        currencyManager1.SuspendBinding();
                                        dgvOrders.CurrentCell = null;
                                        r.Visible             = false;
                                    }
                                }
                            }
                        }
                        InsertCheckBoxColumn();
                        UpdateStatus("Completed.");
                    }
                }
            }
            catch (Exception ex)
            {
                Log.WriteToErrorLog(ex);
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                bool anyerrors = false;
                if (dgvOrders.Rows.Count > 0)
                {
                    DataTable tbl = _objSql.LoadFieldMappings1(Convert.ToString(cmbConfigList.SelectedItem));
                    if (tbl != null && tbl.Rows.Count > 0)
                    {
                        var rows =
                            dgvOrders.Rows.OfType <DataGridViewRow>().Where(row => Convert.ToBoolean(row.Cells[0].Value));
                        if (rows.Any())
                        {
                            foreach (DataGridViewRow dgrow in rows)
                            {
                                var mapList = new List <Settings.Mappings>();
                                foreach (DataRow drow in tbl.Rows)
                                {
                                    try
                                    {
                                        string tblName      = Convert.ToString(drow["Table_NM"]);
                                        string columnNm     = Convert.ToString(drow["Column_NM"]);
                                        string apiFieldName = Convert.ToString(drow["Source_Fld_NM"]);
                                        string nbsFldNm     = Convert.ToString(drow["NBS_Fld_NM"]);
                                        string datasource   = Convert.ToString(drow["DataSource"]);
                                        string configid     = Convert.ToString(drow["Config_id"]);
                                        string value        = Convert.ToString(dgrow.Cells[apiFieldName].Value);
                                        string modvalue     = value;
                                        if (tblName == "MSG_PATIENT" && datasource == "Epi Info" && columnNm == "PAT_ETHNIC_GROUP_IND_CD" || columnNm == "PAT_RACE_CATEGORY_CD" && !string.IsNullOrEmpty(value))
                                        {
                                            modvalue = value.Replace(":", "-");
                                        }
                                        if (!string.IsNullOrEmpty(value))
                                        {
                                            var mapping = new Settings.Mappings
                                            {
                                                TableName  = tblName,
                                                ColumnName = columnNm,
                                                ApiValue   = modvalue.Replace("_", "-")
                                            };
                                            mapping.NbsFieldName = nbsFldNm;
                                            mapping.RecordId     = Convert.ToString(dgrow.Cells["record_id"].Value);
                                            mapping.DocumentId   = _siteOid + "^" +
                                                                   Convert.ToString(dgrow.Cells["record_id"].Value);
                                            mapping.DocTypeCd           = _siteOid + "^" + DateTime.Now.ToString("yyyy-MM-dd");
                                            mapping.EffectiveTime       = DateTime.Now.ToString();
                                            mapping.RecordStatusCd      = CommonData.Credentials.RecordStatus;
                                            mapping.RecordStatusTime    = DateTime.Now.ToString();
                                            mapping.MsgContainerStartId = CommonData.Credentials.MsgContainerStartId;
                                            mapping.PatLocalId          = CommonData.Credentials.PatLocalId;
                                            mapping.InvLocalId          = CommonData.Credentials.InvLocalId;
                                            mapping.HideImported        = CommonData.Credentials.HideImported;
                                            mapping.DataSource          = datasource;
                                            mapping.ConfigId            = configid;
                                            mapping.Ongoing_case        = toStringYesNo(Convert.ToBoolean(dgrow.Cells[2].Value));
                                            mapList.Add(mapping);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                    }
                                }

                                if (_objSql.InsertApiValues1(mapList))
                                {
                                    string    formName = Convert.ToString(cmbConfigList.SelectedItem);
                                    DataTable dt       = _objSql.ReadSettings(formName);
                                    if (dt != null && dt.Rows.Count > 0)
                                    {
                                        foreach (DataRow row in dt.Rows)
                                        {
                                            string formname   = Convert.ToString(row["form_nm"]);
                                            string datasource = Convert.ToString(row["datasource"]);
                                            string id         = Convert.ToString(row["Config_id"]);
                                            _objSql.UpdateConfig(id);
                                            dgrow.DefaultCellStyle.ForeColor = Color.Gray;
                                            if (CommonData.Credentials.HideImported != null && CommonData.Credentials.HideImported.ToLower() == "true")
                                            {
                                                CurrencyManager currencyManager1 = (CurrencyManager)BindingContext[dgvOrders.DataSource];
                                                currencyManager1.SuspendBinding();
                                                dgvOrders.CurrentCell = null;
                                                dgrow.Visible         = false;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    anyerrors = true;
                                }

                                dgrow.Cells[0].Value = false;
                            }
                        }
                    }
                    else
                    {
                        CommonData.ShowMessage("Not all the selected records were exported successfully. See error log.",
                                               CommonData.MsgBoxType.Error);
                        UpdateStatus("No Mappings creatd. See error log.");
                    }
                }

                if (anyerrors)
                {
                    CommonData.ShowMessage("Not all the selected records were exported successfully. See error log.",
                                           CommonData.MsgBoxType.Error);
                    UpdateStatus("Not all the selected records were exported successfully. See error log.");
                }
                else
                {
                    CommonData.ShowMessage("All the selected records were successfully exported to NBS database.",
                                           CommonData.MsgBoxType.Info);
                    UpdateStatus("All the selected records were successfully exported to NBS database.");
                }
            }
            catch (Exception ex)
            {
                Log.WriteToErrorLog(ex);
            }
        }