public List<CallingRecord> GetListOfPatientsToCallFromFileFamily(CallingRecordsParameters parameters)
        {
            string reason = string.Empty;
            StreamReader importFile = null;
            string line = string.Empty;
            string[] sdelimStr = null;
            string delimStr = ",";
            char[] delimiter = delimStr.ToCharArray();
            string[] sdelimStr2 = null;
            string delimStr2 = " ";
            char[] delimiter2 = delimStr2.ToCharArray();
            string reminderConnectionNET = string.Empty;
            long nameID = 20000;
            long telephoneID = 1;
            string _sql = string.Empty;
            int count = 1;
            //int count2 = 1;
            List<Appointments> appointments = new List<Appointments>();
            List<CallingRecord> callingRecords = new List<CallingRecord>();
            try
            {

                importFile = File.OpenText(parameters.Parameter1);

                while ((line = importFile.ReadLine()) != null)
                {
                    if (line.Length > 15)
                    {
                        sdelimStr = line.Split(delimiter, 20);
                        sdelimStr2 = sdelimStr[2].Split(delimiter2, 20);
                        bool bReturn = false;
                        try
                        {
                            // bReturn = CheckToSeeIfCallIsCompleted(Common.ConvertTelephoneNumber2(sdelimStr[4]), sdelimStr[3]);
                        }
                        catch (Exception er)
                        {
                            string dd = er.Message;
                        }

                        if (bReturn)
                        {
                            string ff = string.Empty;
                        }
                        else
                        {
                            try
                            {
                                //reason = sdelimStr[11].Replace("'", "''").Trim().Substring(0, 13);
                                reason = sdelimStr[11];
                                reason = reason.Replace("\"", "");
                            }
                            catch
                            {
                                reason = string.Empty;
                            }
                        }
                    }

                    CallingRecord callingRecord = new CallingRecord();

                    try
                    {
                        callingRecord.FirstName = sdelimStr[1].Replace("\"", "").Trim();
                    }
                    catch
                    {
                        callingRecord.FirstName = string.Empty;
                    }

                    try
                    {
                        callingRecord.LastName = sdelimStr[0].Replace("\"", "").Trim();
                    }
                    catch
                    {
                        callingRecord.LastName = string.Empty;
                    }
                    try
                    {
                        callingRecord.Provider = sdelimStr[6].Replace("\"", "").Trim();
                        //appointment.D
                    }
                    catch
                    {
                        callingRecord.Provider = string.Empty;
                    }
                    //EntityID
                    callingRecord.Company_ID = int.Parse(System.Configuration.ConfigurationManager.AppSettings["companyID"]);
                    callingRecord.NameID = (int)nameID;
                    callingRecord.TelephoneID = (int)telephoneID;

                    callingRecord.MessageTime = 0;
                    try
                    {
                        callingRecord.DateOfAppointment = sdelimStr[3].Replace("\"", "").Trim();
                    }
                    catch
                    {
                        callingRecord.DateOfAppointment = string.Empty;
                    }

                    try
                    {
                        callingRecord.TimeOfAppointment = sdelimStr[4].Replace("\"", "").Trim();
                    }
                    catch
                    {
                        callingRecord.TimeOfAppointment = string.Empty;
                    }

                    try
                    {
                        callingRecord.ApTime = callingRecord.TimeOfAppointment.Replace(":", "");
                    }
                    catch
                    {
                        callingRecord.ApTime = string.Empty;
                    }

                    try
                    {
                        callingRecord.Date1 = Common.GetMonthFromDate(sdelimStr[3].Replace("\"", ""));
                    }
                    catch
                    {
                        callingRecord.Date1 = string.Empty;
                    }

                    try
                    {
                        DateTime appointmentDay = DateTime.Parse(callingRecord.DateOfAppointment);
                    }
                    catch
                    {

                    }

                    try
                    {
                        callingRecord.Date2 = Common.GetDayNumberFromDate(sdelimStr[4].Replace("\"", ""));
                    }
                    catch
                    {
                        callingRecord.Date2 = string.Empty;
                    }
                    try
                    {
                        callingRecord.TimeForDelete = DateTime.Parse(sdelimStr[4].Replace("\"", ""));
                        //callingRecord.TimeForDelete = DateTime.Parse(ConvertTimeOfAppointment3(sdelimStr[6]));
                    }
                    catch (Exception er)
                    {
                        string s1 = er.Message;
                        //callingRecord.TimeForDelete = string.Empty;
                    }
                    try
                    {
                        callingRecord.Day = Common.GetDayFromDate(sdelimStr[3].Replace("\"", ""));
                    }
                    catch
                    {
                        callingRecord.Day = string.Empty;
                    }
                    try
                    {

                        callingRecord.TelephoneNumber1 = Common.ConvertTelephoneNumber(sdelimStr[2].Replace("\"", "").Trim())
                            .Replace("-", "")
                            .Replace("(", "")
                            .Replace(")", "")
                            .Replace(" ", "");
                        callingRecord.TelephoneNumber1 = CheckTelephoneNumber(callingRecord.TelephoneNumber1);
                    }
                    catch
                    {
                        callingRecord.TelephoneNumber1 = string.Empty;
                    }
                    callingRecord.TelephoneNumber2 = "0";

                    try
                    {
                        callingRecord.TelephoneFile = sdelimStr[2].Replace("\"", "").Trim()
                            .Replace("-", "")
                            .Replace("(", "")
                            .Replace(")", "")
                            .Replace(" ", "");
                    }
                    catch
                    {
                        callingRecord.TelephoneFile = string.Empty;
                    }
                    try
                    {
                        callingRecord.ReasonCode = sdelimStr[7].Replace("\"", "").Trim();
                    }
                    catch
                    {
                        callingRecord.ReasonCode = string.Empty;
                    }

                    try
                    {
                        callingRecord.ReasonForAppointment = string.Empty;
                    }
                    catch
                    {
                        callingRecord.ReasonForAppointment = string.Empty;
                    }

                    try
                    {
                        callingRecord.Location = sdelimStr[8].Replace("\"", "").Trim();
                    }
                    catch
                    {
                        callingRecord.Location = string.Empty;
                    }

                    callingRecord.Charge = "FAMILY";
                    callingRecord.InUse = "N";
                    callingRecord.Completed = "N";
                    callingRecord.CallWait = 0;
                    callingRecord.MessageTime = 0;
                    callingRecord.Busy = 0;
                    callingRecord.ResultDescription = "Waiting To Call";

                    //callingRecord.Acknowledge
                    //callingRecord.CallBack
                    //callingRecord.Cancel

                    //callingRecords.Add(callingRecord);

                    InsertCallingRecord(callingRecord);
                    nameID++;
                    telephoneID++;
                    count++;
                    Console.WriteLine(count.ToString());
                }
                importFile.Close();
                return callingRecords;

            }
            catch (Exception er)
            {
                //Log.WhichProgram = "Labcorp Interface";
                Log.LogMessage(er.ToString());
                importFile.Close();
                return callingRecords;
            }
        }
        public void InsertCallingRecord(CallingRecord callingRecord)
        {
            using (MySqlConnection db = new MySqlConnection(Database.ReminderConnection))
            {
                try
                {
                    const string query =
                        "insert into pendingtelephone(TelephoneID,Company_ID,MessageTime,"
                        + "NameID,FirstName,LastName,Provider,DateOfAppointment,"
                        + "TimeOfAppointment,TimeForDelete,Day,Date1,Date2,ApTime,Location,"
                        + "TelephoneNumber1,TelephoneNumber2,TelephoneFile,ReasonCode,ReasonForAppointment,"
                        + "Completed,InUse,CallWait,ResultDescription,Acknowledge,"
                        + "CallBack,Cancel,Busy,Call_Count,Time_Of_Call,Charge)values("
                        + "@TelephoneID,@Company_ID,@MessageTime,"
                        + "@NameID,@FirstName,@LastName,@Provider,@DateOfAppointment,"
                        + "@TimeOfAppointment,@TimeForDelete,@Day,@Date1,@Date2,@ApTime,@Location,"
                        + "@TelephoneNumber1,@TelephoneNumber2,@TelephoneFile,@ReasonCode,@ReasonForAppointment,"
                        + "@Completed,@InUse,@CallWait,@ResultDescription,@Acknowledge,"
                        + "@CallBack,@Cancel,@Busy,@Call_Count,@Time_Of_Call,@Charge)";

                    int rowsAffectd = db.Execute(query, callingRecord);
                }
                catch (Exception er)
                {
                    string s1 = er.Message;
                    //Log.WhichProgram = "Labcorp Interface";
                    Log.LogMessage(er.ToString());
                }
            }
        }
        public void GetListOfPatientsToCallPenChart(string dates)
        {

            int nameId = 200;
            int telephoneId = 5000;

            List<Appointments> appointments = new List<Appointments>();

            try
            {
                using (IDbConnection db = new SqlConnection(Database.PenChart))
                {
                    const string query = "select * from appointments A,Patients B "
                        + " Where A.Patid = B.Patid "
                        + " and A.Apptdate = @dates";

                    //return db.Query<Appointments>(query, new { @dates = dates }).ToList();
                    appointments = db.Query<Appointments>(query, new { @dates = dates }).ToList();
                }
            }
            catch (Exception er)
            {
                //Log.WhichProgram = "Labcorp Interface";
                Log.LogMessage(er.ToString());
                //return false;
                //return appointments;
            }

            try
            {
                for (int i = 0; i < appointments.Count; i++)
                {
                    CallingRecord callingRecord = new CallingRecord();
                    callingRecord.FirstName = appointments[i].firstname;

                    callingRecord.LastName = appointments[i].LastName;
                    callingRecord.Provider = Common.GetProviderNamePenchart(appointments[i].EntityID.ToString());
                    //EntityID
                    callingRecord.Company_ID = int.Parse(System.Configuration.ConfigurationManager.AppSettings["companyID"]);

                    callingRecord.NameID = nameId;
                    callingRecord.TelephoneID = telephoneId;

                    callingRecord.MessageTime = 0;
                    //ApptDate
                    callingRecord.DateOfAppointment = Common.GetAppointmentDatePenchart(appointments[i].ApptDate);

                    callingRecord.TimeOfAppointment = Common.GetAppointmentTimePenchart(appointments[i].StartTime);

                    callingRecord.ApTime = callingRecord.TimeOfAppointment.Replace(":", "");

                    callingRecord.Date1 = Common.GetMonthPenchart(DateTime.Parse(callingRecord.DateOfAppointment).Month);

                    DateTime appointmentDay = DateTime.Parse(callingRecord.DateOfAppointment);

                    callingRecord.Date2 = Common.GetDayOfMonthPenchart(appointmentDay.Day);
                    // callingRecord.Date2 = Common.GetDayOfMonth(appointmentDay.Day);

                    callingRecord.TimeForDelete = DateTime.Parse(callingRecord.TimeOfAppointment);


                    callingRecord.Day = Common.GetDayOfWeekPenChart(appointmentDay);

                    //***********************************************
                    //for testing
                    //telephone number that is out of order 8602644624
                    //telephone number that is out of order 8602644622
                    callingRecord.TelephoneNumber1 = "8602325449";
                    callingRecord.TelephoneNumber2 = "0";
                    callingRecord.TelephoneFile = "8602325449";

                    //testing for now answer and busy
                    //callingRecord.TelephoneNumber1 = "8602644622";
                    //callingRecord.TelephoneNumber2 = "0";
                    //callingRecord.TelephoneFile = "8602644622";

                    /*
                    callingRecord.TelephoneNumber1 = appointments[i].homephone
                        .Replace("-", "")
                        .Replace("(", "")
                        .Replace(")", "")
                        .Replace(" ", "");
                    callingRecord.TelephoneNumber2 = "0";
                    callingRecord.TelephoneFile = appointments[i].homephone
                        .Replace("-", "")
                        .Replace("(", "")
                        .Replace(")", "")
                        .Replace(" ", "");
                     */
                    callingRecord.ReasonCode = appointments[i].VisitTypeID.ToString();
                    callingRecord.InUse = "N";
                    callingRecord.Completed = "N";
                    callingRecord.Location = Common.GetLocationNamePenchart(appointments[i].LocationID.ToString());

                    callingRecord.CallWait = 0;
                    callingRecord.MessageTime = 0;
                    callingRecord.Busy = 0;

                    callingRecord.Charge = "CENTER";
                    callingRecord.ResultDescription = "Waiting To Call";

                    //callingRecord.Acknowledge
                    //callingRecord.CallBack
                    //callingRecord.Cancel

                    InsertCallingRecord(callingRecord);
                    nameId++;
                    telephoneId++;
                }
            }
            catch (Exception er)
            {
                Log.LogMessage(er.ToString());
            }
            //return appointments;
        }