private CallingDates GetCallingDates()
        {
            CallingDates callingDates = new CallingDates();

            DateTime dateToCall = DateTime.Now;

            if (DateTime.Now.DayOfWeek == DayOfWeek.Monday)
            {
                callingDates.BeginCallingDate = dateToCall.AddDays(-3).ToShortDateString();
                callingDates.EndCallingDate = dateToCall.AddDays(-2).ToShortDateString();
                return callingDates;
            }
            else if (DateTime.Now.DayOfWeek == DayOfWeek.Tuesday)
            {
                callingDates.BeginCallingDate = dateToCall.AddDays(-1).ToShortDateString();
                callingDates.EndCallingDate = dateToCall.AddDays(0).ToShortDateString();
                return callingDates;
            }
            else if (DateTime.Now.DayOfWeek == DayOfWeek.Wednesday)
            {
                callingDates.BeginCallingDate = dateToCall.AddDays(-1).ToShortDateString();
                callingDates.EndCallingDate = dateToCall.AddDays(0).ToShortDateString();
                return callingDates;
            }
            else if (DateTime.Now.DayOfWeek == DayOfWeek.Thursday)
            {
                callingDates.BeginCallingDate = dateToCall.AddDays(-1).ToShortDateString();
                callingDates.EndCallingDate = dateToCall.AddDays(0).ToShortDateString();
                return callingDates;
            }
            else if (DateTime.Now.DayOfWeek == DayOfWeek.Friday)
            {
                callingDates.BeginCallingDate = dateToCall.AddDays(-1).ToShortDateString();
                callingDates.EndCallingDate = dateToCall.AddDays(0).ToShortDateString();
                return callingDates;
            }
            else if (DateTime.Now.DayOfWeek == DayOfWeek.Saturday)
            {
                callingDates.BeginCallingDate = dateToCall.AddDays(-1).ToShortDateString();
                callingDates.EndCallingDate = dateToCall.AddDays(0).ToShortDateString();
                return callingDates;
            }
            else if (DateTime.Now.DayOfWeek == DayOfWeek.Sunday)
            {
                callingDates.BeginCallingDate = dateToCall.AddDays(2).ToShortDateString();
                callingDates.EndCallingDate = dateToCall.AddDays(3).ToShortDateString();
                return callingDates;
            }
            return callingDates;
        }
        public List<SignedDocument> GetListOfOrthoNowDocumentssToSendViaFax()
        {
            List<SignedDocument> documentsList = new List<SignedDocument>();

            string beginDate = DateTime.Now.AddDays(-1).ToShortDateString();
            string endDate = DateTime.Now.ToShortDateString();

            CallingDates callingDates = new CallingDates();
            callingDates = GetCallingDates();

            try
            {
                using (IDbConnection db = new SqlConnection(ConfigurationValues.GreenwayConnection))
                {
                    string query = "select 'Y' as Proccess,  ClinicalDocumentSignatures.SequenceNumber as SequenceNumber, CareProviderLocation.LocationName as Location, vVisit.VisitID,"
                        + " ClinicalDocuments.DocumentID as DocumentID,"
                        + " ClinicalDocumentSignatures.DateSigned as DateSigned,"
                        + " patient.PatientID as PatientID,"
                        + " person.FirstName +' '+ person.LastName as PatientName,"
                        + " vVisit.BillableCareProviderID as CareProviderID,"
                        + " vvisit.BillableFirstName + ' ' + vvisit.BillableLastName + ', ' + vVisit.BillableCredentials as CareProviderName,"
                        + " vVisit.PrimaryCareProviderID as PrimaryCareProviderID,"
                        + " vVisit.PrimaryFirstName + ' ' + vVisit.PrimaryLastName + ', ' + vVisit.PrimaryCredentials as PrimaryCareProvider,"
                        + " vVisit.ReferringProviderID as ReferringCareProviderID,"
                        + " vVisit.ReferringFirstName + ' ' + vVisit.ReferringLastName + ', ' +  vVisit.ReferringCredentials as ReferringCareProvider,"
                        + " ClinicalDocTypes.DocTypeName as DocTypeName,"
                        + " ClinicalDocumentSignatures.SignerID as SignerID,"
                        + " ClinicalDocuments.Createdby as CreatedByID"
                        + " from ClinicalDocumentSignatures"
                        + " inner JOIN ClinicalDocuments"
                        + " on ClinicalDocuments.DocumentID = ClinicalDocumentSignatures.DocumentID"
                        + " inner JOIN Visit"
                        + " on visit.VisitID = ClinicalDocuments.VisitID"
                        + " inner JOIN vVisit"
                        + " on  vVisit.VisitID = visit.VisitID"
                        + " inner JOIN patient "
                        + " on ClinicalDocuments.PatientID = patient.PatientID"
                        + " inner JOIN person"
                        + " on patient.PersonID = person.PersonID"
                        + " inner JOIN CareProvider"
                        + " on CareProvider.CareProviderID = visit.CareProviderID"
                        + " inner JOIN ClinicalDocTypes"
                        + " on ClinicalDocTypes.DocTypeID = ClinicalDocuments.DocTypeID"
                        + " inner JOIN CareProviderLocation"
                        + " on CareProviderLocation.Locationid = Visit.ServiceLocationID"
                        + " inner JOIN vApptInfo"
                        + " on vApptInfo.VisitID = Visit.VisitID"
                        + " inner JOIN ScheduleStepList"
                        + " on ScheduleStepList.StepId = vApptInfo.StepID"
                        //+ " where ClinicalDocumentSignatures.DateSigned between '" + callingDates.BeginCallingDate + "' and '" + callingDates.EndCallingDate + "'"
                        + " and ClinicalDocumentSignatures.DateSigned between '5/18/2015' and '5/19/2015'"
                        //+ " where ClinicalDocumentSignatures.Signerid = 1024"
                        + " where ClinicalDocTypes.DocTypeID in (1,7)"
                        + " and CareProviderLocation.LocationName in ('HMDN2408','BRFD84','ORNG330')"
                        //+ " and CareProviderLocation.LocationName in ('HMDN2408ON','BRFD84ON','ORNG330ON')"
                        + " and ClinicalDocumentSignatures.SignerID = 1024"
                        //+ listOfLocations
                        //+ listOfProviderIds
                        + " and ScheduleStepList.StepId NOT IN (1038,1018,1035)";

                    documentsList = db.Query<SignedDocument>(query).ToList();

                    return CheckBusinessRulesForSendingFaxes(documentsList);
                }
            }
            catch (Exception er)
            {
                Utility.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString());
                return documentsList;
            }
        }