private string GetMessageText(string theMessage, VoicingParameters voicingParameters)
        {
            string theText = string.Empty;
            string function = string.Empty;
            string s1 = string.Empty;
            function = Walden.Utility.Common.Between(theMessage,"%","%");
            //Between

            switch (function)
            {
                case "NAME":
                    theText = voicingParameters.FirstName;
                    break;
                case "PROVIDER":
                    theText = GetProviderName(voicingParameters.Provider);
                    break;
                case "DAYDATETIME":
                    theText = GetDayDateTime(voicingParameters);
                    break;
                case "LOCATION":
                    theText = GetLocationString(voicingParameters.Location);
                    break;
            }
            s1 = " " + theMessage.Replace("%" + function + "%", theText + " ");

            return " " + theMessage.Replace("%" + function + "%",theText + " ");
        }
        public CreateVoiceFiles(VoicingParameters  voicingParameters)
        {
            message = patientRecords.GetReminderMessage(voicingParameters.MessageName);
            for (int i = 0; i < message.Count; i++)
            {

                toBeVoiced = message[0].MessageText;

                string callUs = string.Empty;                
                string dayDateTime = ", " + voicingParameters.DayOfAppointment + ", " + voicingParameters.DateOfAppointment1 + " , " + voicingParameters.DateOfAppointment2 + ", at " + "\"" + voicingParameters.TimeOfAppointment + "\"" + " ,";
                string location = GetLocationString(voicingParameters.Location);
                string name = voicingParameters.FirstName;
                string provider = GetProviderName(voicingParameters.Provider);

                toBeVoiced = toBeVoiced.Replace("^CALLUS^",callUs);
                toBeVoiced = toBeVoiced.Replace("^DAYDATETIME^",dayDateTime);
                toBeVoiced = toBeVoiced.Replace("^LOCATION^",location);
                toBeVoiced = toBeVoiced.Replace("^NAME^",name);
                toBeVoiced = toBeVoiced.Replace("^PROVIDER^",provider);

                //toBeVoiced = "\"" + " 8:15AM " + "\"" + toBeVoiced;

                CreateVoiceFile(voicingParameters, toBeVoiced, voicingParameters.DateOfAppointment, voicingParameters.TimeOfAppointment);
            }
        }
        private static void CreateVoiceFile(VoicingParameters voicingParameters, string toBeVoiced,string dateOfApplication,string timeOfApplication)
        {
            string fileName = string.Empty;
            string mp3FileName = string.Empty;
            SpeechSynthesizer reader;
            string sequence = string.Empty;
            string liveOrVoice = string.Empty;
            fileName = Common.GetFileNameFromDateTimeString() + ".wav";

            //Create voice file 
            //Save voice file
            //Insert live into voicing table
            //Insert vouce mail into voicing table
            reader = new SpeechSynthesizer();
            //  reader.
            reader.Volume = 100;
            reader.Rate = voicingParameters.Rate;
            reader.SelectVoice(voicingParameters.VoiceName);
            
            //reader.Rate = -2;
            //reader.SelectVoice("Microsoft Zira Desktop");
            
            try
            {
                //reader.SetOutputToWaveFile(voiceFilePath + fileName, new SpeechAudioFormatInfo(11025, AudioBitsPerSample.Sixteen, AudioChannel.Mono));
                //reader.SetOutputToWaveFile(voicingParameters.VoiceFilePath + fileName, new SpeechAudioFormatInfo(16025, AudioBitsPerSample.Sixteen, AudioChannel.Mono));
                reader.SetOutputToWaveFile(voicingParameters.VoiceFilePath + fileName, new SpeechAudioFormatInfo(48000, AudioBitsPerSample.Sixteen,AudioChannel.Stereo));
                //********************************************************************************
                //used for testing
                //reader.SetOutputToWaveFile("\\\\1lake-reminder2\\c\\Waldenltd\\voicetest\\" + department + ".wav", new SpeechAudioFormatInfo(11025, AudioBitsPerSample.Eight, AudioChannel.Mono));
                //****************************************************************************************
                reader.Speak(toBeVoiced);
                reader.Dispose();
                mp3FileName = fileName.Replace(".wav",".mp3");
                ConvertWavFileTOMP3.WaveToMP3(voicingParameters.VoiceFilePath + fileName
                    , voicingParameters.VoiceFilePath + mp3FileName);
                File.Delete(voicingParameters.VoiceFilePath + fileName);
            }
            catch (Exception er)
            {
                string s1 = er.Message;
            }

            //insert live
            sequence = "1";
            liveOrVoice = "L";
            PatientCommunication.Model.Voicing voicing = new Model.Voicing();
            PatientRecords patientRecords = new PatientRecords();
            try
            {
                voicing.NameID = int.Parse(voicingParameters.NameID);
                voicing.TelephoneID = int.Parse(voicingParameters.TelephoneID);
                voicing.CompanyID = int.Parse(voicingParameters.CompanyId);
                voicing.AppDate = dateOfApplication;
                voicing.AppTime = timeOfApplication;
                voicing.FileName = mp3FileName;
                voicing.Sequence = int.Parse(sequence);
                voicing.pPrevious = "Null";
                voicing.nNext = "Null";
                voicing.LiveorVoice = liveOrVoice;
                patientRecords.InsertVoiceRecord(voicing);
            }
            catch (Exception er)
            {
                //Log.WhichProgram = "Labcorp Interface";
                Log.LogMessage(er.ToString());
            }

            //insert voice
            sequence = "1";
            liveOrVoice = "V";

            try
            {
                voicing = new Model.Voicing();
                voicing.NameID = int.Parse(voicingParameters.NameID);
                voicing.TelephoneID = int.Parse(voicingParameters.TelephoneID);
                voicing.CompanyID = int.Parse(voicingParameters.CompanyId);
                voicing.AppDate = dateOfApplication;
                voicing.AppTime = timeOfApplication;
                voicing.FileName = mp3FileName;
                voicing.Sequence = int.Parse(sequence);
                voicing.pPrevious = "Null";
                voicing.nNext = "Null";
                voicing.LiveorVoice = liveOrVoice;
                patientRecords.InsertVoiceRecord(voicing);
            }
            catch (Exception er)
            {
                //Log.WhichProgram = "Labcorp Interface";
                Log.LogMessage(er.ToString());
            }
        }
        private static void CROM(VoicingParameters voicingParameters)
        {
            string toBeVoiced = string.Empty;
            string theLocation = string.Empty;
            string theCallUs = string.Empty;
            string newOfficelocation = string.Empty;

            theLocation = GetLocationString(voicingParameters.Location);

            theCallUs = ", if you have any questions regarding your appointment please call or office at 8,6,0,6,3,5,2,8,1,0";
            //theLocation = "  located at 185 East Street in Plianville";
            //if you are unable to keep your appointment please call the office at 8,6,0,3,4,8,4,2,4,2 to reschedule as soon as possible
            toBeVoiced = "Hello, this is an automated message from the grove hill medical center department of internal medicine, for "
                + " " + voicingParameters.FirstName + " "
                + ", I am calling to confirm an appointment with, " + GetProviderName(voicingParameters.Provider) + ", on,"
                + voicingParameters.DayOfAppointment + ", " + voicingParameters.DateOfAppointment1 + " , " + voicingParameters.DateOfAppointment2 + ", at " + voicingParameters.TimeOfAppointment
                + " " + theLocation
                + newOfficelocation
                + " , please arrive fifteen minutes before your scheduled appointment time in order to complete the registration process   Please be sure to bring your current insurance cards and any co-pay if applicable. "
                + " , a fifty dollar fee may be assessed for appointments missed without cancelling twenty-four hours in advance"
                + theCallUs
                + ", to repeat this message press 2, thank you and have a great day";
            CreateVoiceFile(voicingParameters, toBeVoiced, voicingParameters.DateOfAppointment1, voicingParameters.TimeOfAppointment);
        }
        private static void PEDS(VoicingParameters voicingParameters)
        {
            string toBeVoiced = string.Empty;
            string theLocation = string.Empty;
            string theCallUs = string.Empty;
            string newOfficelocation = string.Empty;

            theLocation = GetLocationString(voicingParameters.Location);

            if (voicingParameters.Location == "536" && voicingParameters.Location == "539")
            {
                if (voicingParameters.Location == "375WI")
                {
                    newOfficelocation = "the office is now located in the rear of the building door number 4";
                }
            }

            theCallUs = ", if you have any questions regarding your appointment please call or office at 8,6,0,2,2,4,6,2,8,2";
            //theLocation = "  located at 185 East Street in Plianville";
            //if you are unable to keep your appointment please call the office at 8,6,0,3,4,8,4,2,4,2 to reschedule as soon as possible
            toBeVoiced = "Hello, this is an automated message from the grove hill medical center department of paediatric and adolescent medicine, for "
                + " " + voicingParameters.FirstName + " "
                + ", I am calling to confirm an appointment with, " + GetProviderName(voicingParameters.Provider) + ", on,"
                + voicingParameters.DayOfAppointment + ", " + voicingParameters.DateOfAppointment1 + " , " + voicingParameters.DateOfAppointment2 + ", at " + voicingParameters.TimeOfAppointment
                + " " + theLocation
                + newOfficelocation
                + " , Please arrive fifteen minutes before your scheduled appointment time in order to complete the registration process.  Please be sure to bring your insurance cards and any co-pay if applicable"
                + theCallUs
                + ", to repeat this message press 2, thank you and have a great day";
            CreateVoiceFile(voicingParameters, toBeVoiced, voicingParameters.DateOfAppointment1, voicingParameters.TimeOfAppointment);
        }
        private static void PAIN(VoicingParameters voicingParameters)
        {
            string toBeVoiced = string.Empty;
            string theLocation = string.Empty;
            string theCallUs = string.Empty;
            string newOfficelocation = string.Empty;

            theLocation = " located at 375 willard ave in newington";

            theCallUs = ", if you have any questions regarding your appointment please call or office at 8,6,0,7,6,8,1,1,6,6";
            //theLocation = "  located at 185 East Street in Plianville";
            //if you are unable to keep your appointment please call the office at 8,6,0,3,4,8,4,2,4,2 to reschedule as soon as possible
            toBeVoiced = "Hello, this is an automated message from the grove hill medical center department of interventional  pain management, for "
                + " " + voicingParameters.FirstName + " "
                + ", I am calling to confirm an appointment with, " + GetProviderName(voicingParameters.Provider) + ", on,"
                + voicingParameters.DayOfAppointment + ", " + voicingParameters.DateOfAppointment1 + " , " + voicingParameters.DateOfAppointment2 + ", at " + voicingParameters.TimeOfAppointment
                + " " + theLocation
                + newOfficelocation
                + " , Please arrive fifteen minutes before your scheduled appointment time in order to complete the registration process.  Please be sure to bring your insurance cards and any co-pay if applicable if you cannot keep this appointment twenty four hours notice of cancellation notice is required"
                //theCallUs = ",if you cannot keep this appointment twenty four hours notice of cancellation is required , if you have any questions regarding your appointment please contact our office at 8,6,0,8,3,2,4,6,6,6";
                + theCallUs
                + ", to repeat this message press 2, thank you and have a great day";
            CreateVoiceFile(voicingParameters, toBeVoiced, voicingParameters.DateOfAppointment1, voicingParameters.TimeOfAppointment);
        }
        public void CreateFirstVoiceFile(VoicingParameters voicingParameters, string toBeVoiced)
        {
            string fileName = string.Empty;
            string sequence = string.Empty;
            string liveOrVoice = string.Empty;
            SpeechSynthesizer reader;
            fileName = "first.wav";

            reader = new SpeechSynthesizer();
            //  reader.
            // reader.Volume = 200;
            // reader.Rate = 200;

            reader.Rate = voicingParameters.Rate;
            reader.SelectVoice(voicingParameters.VoiceName);
            try
            {
                //reader.SetOutputToWaveFile(voiceFilePath + fileName, new SpeechAudioFormatInfo(11025, AudioBitsPerSample.Sixteen, AudioChannel.Mono));
                reader.SetOutputToWaveFile(voicingParameters.VoiceFilePath + fileName, new SpeechAudioFormatInfo(16025, AudioBitsPerSample.Sixteen, AudioChannel.Mono));
                //********************************************************************************
                reader.Speak(toBeVoiced);
            }
            catch (Exception er)
            {
                string s1 = er.Message;
            }
        }
 private static string GetDayDateTime(VoicingParameters voicingParameters)
 {
     return "on ," + voicingParameters.DayOfAppointment + ", " + voicingParameters.DateOfAppointment1 + " , " + voicingParameters.DateOfAppointment2 + ", at " + voicingParameters.TimeOfAppointment;
 }
 public CreateVoiceFiles(VoicingParameters  voicingParameters,string toBeVoiced)
 {
    // CreateVoiceFileSample (voicingParameters, toBeVoiced);
 }
        private static void CARD(VoicingParameters voicingParameters)
        {
            string theGreeting = string.Empty;
            string thePatientName = string.Empty;
            string theProvider = string.Empty;
            string theDayDateTime = string.Empty;
            string theLocation = string.Empty;
            string theOfficeMessage = string.Empty;
            string theReturnMessage = string.Empty;
            string theRespondMessage = string.Empty;
            string theCallOfficeMessage = string.Empty;
            string theEndMessage = string.Empty;
            string theCode = string.Empty;
            string toBeVoiced = string.Empty;

            PatientRecords patientRecords = new PatientRecords();
            List<WhatToVoice> whatToVoice = patientRecords.GetVoicing("CARD");

            for (int i = 0; i < whatToVoice.Count; i++)
            {
                if (whatToVoice[i].MessageType == "PATIENTNAME")
                {
                    toBeVoiced = toBeVoiced + " " + voicingParameters.FirstName + " ";
                }
                else if (whatToVoice[i].MessageType == "PROVIDER")
                {
                    toBeVoiced = toBeVoiced + ", I am calling to confirm an appointment with, " + GetProviderName(voicingParameters.Provider) + ", on,";
                }
                else if (whatToVoice[i].MessageType == "DAYDATETIME")
                {
                    toBeVoiced = toBeVoiced + " " + "on, " + voicingParameters.DayOfAppointment + ", " + voicingParameters.DateOfAppointment1 + " , " + voicingParameters.DateOfAppointment2 + ", at " + voicingParameters.TimeOfAppointment + " ";
                }
                else if (whatToVoice[i].MessageType == "LOCATION")
                {
                    toBeVoiced = toBeVoiced + " " + GetLocationString(voicingParameters.Location) + " ";
                }
                else
                {
                    toBeVoiced = toBeVoiced + whatToVoice[i].Message;
                }
            }
                
            /*
            
            string toBeVoiced = string.Empty;
            //string theLocation = string.Empty;
            string theCallUs = string.Empty;
            string newOfficelocation = string.Empty;

            theLocation = GetLocationString(voicingParameters.Location);

            theCallUs = ", if you have any questions regarding your appointment please call or office at 8,6,0,2,2,3,0,2,2,0";
            //theLocation = "  located at 185 East Street in Plianville";
            //if you are unable to keep your appointment please call the office at 8,6,0,3,4,8,4,2,4,2 to reschedule as soon as possible
            toBeVoiced = "Hello, this is an automated message from the grove hill medical center department of cardiology, for "
                + " " + voicingParameters.FirstName + " "
                + ", I am calling to confirm an appointment with, " + GetProviderName(voicingParameters.Provider) + ", on,"
                + voicingParameters.DayOfAppointment + ", " + voicingParameters.DateOfAppointment1 + " , " + voicingParameters.DateOfAppointment2 + ", at " + voicingParameters.TimeOfAppointment
                + " " + theLocation
                + newOfficelocation
                + " , Please arrive fifteen minutes before your scheduled appointment time in order to complete the registration process.  Please be sure to bring your insurance cards and any co-pay if applicable"
                + theCallUs
                + ", to repeat this message press 2, thank you and have a great day";
             */
            CreateVoiceFile(voicingParameters, toBeVoiced, voicingParameters.DateOfAppointment1, voicingParameters.TimeOfAppointment);
        }
        private static void SURG(VoicingParameters voicingParameters)
        {

            string toBeVoiced = string.Empty;
            string theLocation = string.Empty;
            string theCallUs = string.Empty;
            string newOfficelocation = string.Empty;

            theLocation = GetLocationString(voicingParameters.Location);

            theCallUs = " , if you have any questions or are unable to keep this appointment please call oru office at 8,6,0,8,2,6,4,4,5,7";
            //theLocation = "  located at 185 East Street in Plianville";
            //if you are unable to keep your appointment please call the office at 8,6,0,3,4,8,4,2,4,2 to reschedule as soon as possible
            toBeVoiced = "Hello, this is an automated message from the Grove Hill Medical Center, Department of , surgery for ,"
                + " " + voicingParameters.FirstName + " "
                + ", I am calling to confirm an appointment with, " + GetProviderName(voicingParameters.Provider) + ", on,"
                + voicingParameters.DayOfAppointment + ", " + voicingParameters.DateOfAppointment1 + " , " + voicingParameters.DateOfAppointment2 + ", at " + voicingParameters.TimeOfAppointment
                + " " + theLocation
                + newOfficelocation
                + " , Please arrive fifteen minutes before your scheduled appointment time in order to complete the registration process.  Please be sure to bring your insurance cards and any co-pay if applicable"
                + theCallUs
                + ", to repeat this message press 2, thank you and have a great day";
            CreateVoiceFile(voicingParameters, toBeVoiced, voicingParameters.DateOfAppointment1, voicingParameters.TimeOfAppointment);
        }
        private static void PLVO(VoicingParameters voicingParameters)
        {

            string toBeVoiced = string.Empty;
            string theLocation = string.Empty;

            theLocation = "  located at 185 East Street in Plainville";
            //if you are unable to keep your appointment please call the office at 8,6,0,3,4,8,4,2,4,2 to reschedule as soon as possible
            toBeVoiced = "Hello, this is an automated message from the Grove Hill Medical Center Department of Obstetrics and Gynecology, for "
                + " " + voicingParameters.FirstName + " "
                    + ", I am calling to confirm an appointment with, " + GetProviderName(voicingParameters.Provider) + ", on,"
                + voicingParameters.DayOfAppointment + ", " + voicingParameters.DateOfAppointment1 + " , " + voicingParameters.DateOfAppointment2 + ", at " + voicingParameters.TimeOfAppointment
                + " " + theLocation
                + " Please arrive fifteen minutes before your scheduled appointment time, in order to complete the registration process.  Please be sure to bring your insurance cards and any co-pay if applicable"
                + " if you have any questions concerning your appointment please contact our office at 8,6,0,7,4,7,0,7,3,0 "
                + ", to repeat this message press 2, thank you and have a great day";
            CreateVoiceFile(voicingParameters, toBeVoiced, voicingParameters.DateOfAppointment1, voicingParameters.TimeOfAppointment);
        }
        private static void RAD(VoicingParameters voicingParameters)
        {

            string toBeVoiced = string.Empty;
            string theLocation = string.Empty;

            theLocation = GetLocationString(voicingParameters.Location);

            toBeVoiced = "hello, this is a computerized reminder message from the Grove Hill Medical Center department of Radiology for "
                + " " + voicingParameters.FirstName + " "
                + ", I am calling to confirm an appointment with, " + GetProviderName(voicingParameters.Provider) + ", on,"
                + voicingParameters.DayOfAppointment + ", " + voicingParameters.DateOfAppointment1 + " , " + voicingParameters.DateOfAppointment2 + ", at " + voicingParameters.TimeOfAppointment
                + " " + theLocation
                + " please arrive fifteen minutes before your scheduled appointment time in order to complete the registration process   Please be sure to bring your current insurance cards and any co-pay if applicable. A fifty dollar fee is charged for appointments missed without cancelling 24 hours in advance"
                + " if you have any questions or are unable to keep this appointment please call our office at 8,6,0,2,2,4,6,2,2,2"
                + ", to repeat this message press 2, thank you and have a great day";
            CreateVoiceFile(voicingParameters, toBeVoiced, voicingParameters.DateOfAppointment1, voicingParameters.TimeOfAppointment);
        }
        private static void URO(VoicingParameters voicingParameters)
        {

            string toBeVoiced = string.Empty;
            string theLocation = string.Empty;

            theLocation = GetLocationString(voicingParameters.Location);

            toBeVoiced = "Hello, this is an automated message from the Grove Hill Medical Center Department of Urology for "
                + " " + voicingParameters.FirstName + " "
                + ", I am calling to confirm an appointment with, " + GetProviderName(voicingParameters.Provider) + ", on,"
                + voicingParameters.DayOfAppointment + ", " + voicingParameters.DateOfAppointment1 + " , " + voicingParameters.DateOfAppointment2 + ", at " + voicingParameters.TimeOfAppointment
                + " " + theLocation
                + " Please arrive fifteen minutes before your scheduled appointment time in order to complete the registration process.  Please be sure to bring your insurance cards and any co-pay if applicable"
                + " if you have any questions regarding your appointment please call our office at 8,6,0,8,2,6,4,4,5,3"
                + ", to repeat this message press 2, thank you and have a great day";
            CreateVoiceFile(voicingParameters, toBeVoiced, voicingParameters.DateOfAppointment1, voicingParameters.TimeOfAppointment);
        }
        private static void CENTER(VoicingParameters voicingParameters)
        {
            string toBeVoiced = string.Empty;
            string theLocation = string.Empty;
            string theCallUs = string.Empty;
            string newOfficelocation = string.Empty;

            theLocation = GetLocationString(voicingParameters.Location);

            theCallUs = ", if you have any questions regarding your appointment please call or office at 8,6,0,6,3,5,2,8,1,0";

            toBeVoiced = "This is the Center for Orthopedics calling to remind "
                + " " + voicingParameters.FirstName + ", "
                + " of their appointment,  scheduled for, "
                + voicingParameters.DayOfAppointment 
                + ", " + voicingParameters.DateOfAppointment1 
                + " , " + voicingParameters.DateOfAppointment2 
                + ", at " + voicingParameters.TimeOfAppointment
                //+ " with " + voicingParameters.Provider
                //+ " in our " + voicingParameters.Location + " location "
                + " Please remember to bring your current insurance card and photo identification, If you are a new patient or have a new problem please allow time to fill out new patient paper work, Please call 7, 5, 2, 3, 1, 0, 0, if you have any additional questions, Thank you and have a great day";
                //+" Please remember to bring your current insurance card and photo identification, If you are a new patient or have a new problem please allow time to fill out new patient paper work, To confirm this appointment press 1, To cancel this appointment press 2 ,if you would like someone from our staff to call you back press 3, To repeat this message press 4 Please call 7, 5, 2, 3, 1, 0, 0, if you have any additional questions Thank you and have a great day";
            CreateVoiceFile(voicingParameters, toBeVoiced, voicingParameters.DateOfAppointment1, voicingParameters.TimeOfAppointment);
        }
        //new code 5/2/2014
        //***********************************************************************************
        private static void ENT(VoicingParameters voicingParameters)
        {
            string toBeVoiced = string.Empty;
            string theLocation = string.Empty;
            string theCallUs = string.Empty;
            string newOfficelocation = string.Empty;

            theLocation = GetLocationString(voicingParameters.Location);

            if (voicingParameters.Location == "209MA")
            {
                theCallUs = ", if you have any questions regarding your appointment please contact our office at 8,6,0,6,2,1,6,7,6,1";
            }
            else if (voicingParameters.Location == "292WM")
            {
                theCallUs = ", if you have any questions regarding your appointment please contact our office at 8,6,0,2,2,4,2,6,3,1";
            }
            else
            {
                theCallUs = ", if you have any questions regarding your appointment please contact our office at 8,6,0,2,2,4,2,6,3,1";
            }

            //theLocation = "  located at 185 East Street in Plianville";
            //if you are unable to keep your appointment please call the office at 8,6,0,3,4,8,4,2,4,2 to reschedule as soon as possible
            toBeVoiced = "Hello, this is an automated message from the grove hill medical center department of ears nose and throat, for "
                + " " + voicingParameters.FirstName + " "
                + ", I am calling to confirm an appointment with, " + GetProviderName(voicingParameters.Provider) + ", on,"
                + voicingParameters.DayOfAppointment + ", " + voicingParameters.DateOfAppointment1 + " , " + voicingParameters.DateOfAppointment2 + ", at " + voicingParameters.TimeOfAppointment
                + " " + theLocation
                + newOfficelocation
                + " , Please arrive fifteen minutes before your scheduled appointment time in order to complete the registration process.  Please be sure to bring your insurance cards and any co-pay if applicable"
                + theCallUs
                + ", to repeat this message press 2, thank you and have a great day";
            CreateVoiceFile(voicingParameters, toBeVoiced, voicingParameters.DateOfAppointment1, voicingParameters.TimeOfAppointment);
        }
        private static void FAMILY(VoicingParameters voicingParameters)
        {
            string toBeVoiced = string.Empty;
            string toBeVoiced2 = string.Empty;
            string theLocation = string.Empty;
            string theCallUs = string.Empty;
            string newOfficelocation = string.Empty;
            string provider = string.Empty;

            if (voicingParameters.Location == "CFOD")
            {
                theLocation = "in the Danbury office";
            }
            else if (voicingParameters.Location == "CFOR")
            {
                theLocation = "in the Ridgefield office";
            }
            else if (voicingParameters.Location == "CFOS")
            {
                theLocation = "in the Southbury office";
            }

            if (voicingParameters.Provider == "JD")
            {
                provider = "Dr. Deapau";
            }
            else if (voicingParameters.Provider == "KM")
            {
                provider = "Dr. Kennith Miller";
            }
            else if (voicingParameters.Provider == "LS")
            {
                provider = "Dr. Swhietzer";
            }
            else if (voicingParameters.Provider == "MR")
            {
                provider = "Dr. Rogel";
            }
            else if (voicingParameters.Provider == "SG")
            {
                provider = "Dr. Grey";
            }
            else if (voicingParameters.Provider == "SP")
            {
                provider = "Physican Assistant Sydney Page";
            }
            else if (voicingParameters.Provider == "DE")
            {
                provider = "";
            }
            else if (voicingParameters.Provider == "RR")
            {
                provider = "Ripps";
            }


            toBeVoiced = "This is Connecticut Family Orthopedics calling to remind you that "
                + ", " + voicingParameters.FirstName + ","
                + " has an appointment with "
                + provider
                + ", on, "
                + voicingParameters.DayOfAppointment
                + ", " + voicingParameters.DateOfAppointment1
                + " , " + voicingParameters.DateOfAppointment2
                + ", at " + voicingParameters.TimeOfAppointment
                + theLocation
                + " Please arrive 15 minutes early to complete paperwork., Please bring your insurance cards, photo I.D. and required copay or deductible., It is Connecticut Family Orthopedics' policy to require all personal financial obligations be satisfied at the time of the visit., We now require a credit card to be placed on file to cover unreimbursed charges., Please bring a credit card."
                + " Bring any X Rays, CAT scans, MRIs or medical records pertinent to the visit., For Workers' Comp or motor vehicle accidents please bring the necessary contact information including the name and address of your carrier and the claim number., Thank you."
                + " To reschedule or cancel this appointment please call our office at least 24 hours in advance to avoid no-show fees."
                + " This message will repeat if you stay on the line.";

            toBeVoiced2 = ",,,This is Connecticut Family Orthopedics calling to remind you that "
                + ", " + voicingParameters.FirstName + ","
                + " has an appointment with "
                + provider
                + ", on, "
                + voicingParameters.DayOfAppointment
                + ", " + voicingParameters.DateOfAppointment1
                + " , " + voicingParameters.DateOfAppointment2
                + ", at " + voicingParameters.TimeOfAppointment
                + theLocation
                + " Please arrive 15 minutes early to complete paperwork., Please bring your insurance cards, photo I.D. and required copay or deductible., It is Connecticut Family Orthopedics' policy to require all personal financial obligations be satisfied at the time of the visit., We now require a credit card to be placed on file to cover unreimbursed charges., Please bring a credit card."
                + " Bring any X Rays, CAT scans, MRIs or medical records pertinent to the visit., For Workers' Comp or motor vehicle accidents please bring the necessary contact information including the name and address of your carrier and the claim number., Thank you."
                + " To reschedule or cancel this appointment please call our office at least 24 hours in advance to avoid no-show fees.";


            CreateVoiceFile(voicingParameters, toBeVoiced + toBeVoiced2, voicingParameters.DateOfAppointment1, voicingParameters.TimeOfAppointment);
        }
        private static void HEM(VoicingParameters voicingParameters)
        {
            string toBeVoiced = string.Empty;
            string theLocation = string.Empty;
            string theCallUs = string.Empty;
            string newOfficelocation = string.Empty;

            theLocation = GetLocationString(voicingParameters.Location);

            theCallUs = ", if you have any questions regarding your appointment please call or office at 8,6,0,2,2,4,6,2,5,4";
            //theLocation = "  located at 185 East Street in Plianville";
            //if you are unable to keep your appointment please call the office at 8,6,0,3,4,8,4,2,4,2 to reschedule as soon as possible
            toBeVoiced = "Hello, this is an automated message from the grove hill medical center department of hematology and oncology, for "
                + " " + voicingParameters.FirstName + " "
                + ", I am calling to confirm an appointment with, " + GetProviderName(voicingParameters.Provider) + ", on,"
                + voicingParameters.DayOfAppointment + ", " + voicingParameters.DateOfAppointment1 + " , " + voicingParameters.DateOfAppointment2 + ", at " + voicingParameters.TimeOfAppointment
                + " " + theLocation
                + newOfficelocation
                + " , Please arrive 15 minutes before your scheduled appointment in order to complete the registration process Please be sure to bring your current insurance card Insurance copays are expected at the time of your visit If you are not able to your provide a copay at this scheduled appointment we will be happy to reschedule you appointment"
                + theCallUs
                + ", to repeat this message press 2, thank you and have a great day";
            CreateVoiceFile(voicingParameters, toBeVoiced, voicingParameters.DateOfAppointment1, voicingParameters.TimeOfAppointment);
        }
        private static void CreateVoiceFiles()
        {
            int voiceNumber = 1;

            patientRecords.DeleteVoicingRecords();

            try
            {
                CreateVoiceFiles createVoiceFiles = new Voicing.CreateVoiceFiles();

                VoicingParameters firstFileParameters = new VoicingParameters();
                firstFileParameters.VoiceFilePath = System.Configuration.ConfigurationManager.AppSettings["voiceFilePath"];
                firstFileParameters.VoiceName = System.Configuration.ConfigurationManager.AppSettings["voiceName"];
                firstFileParameters.Rate = int.Parse(System.Configuration.ConfigurationManager.AppSettings["rate"]);

                createVoiceFiles.CreateFirstVoiceFile(firstFileParameters,
                    System.Configuration.ConfigurationManager.AppSettings["firstMessage"]);

                List<CallingRecord> callingRecord = new List<CallingRecord>();
                callingRecord = patientRecords.GetListOfCallingRecords();

                for (int i = 0; i < callingRecord.Count; i++)
                {
                    VoicingParameters voicingParameters = new VoicingParameters();
                    voicingParameters.NameID = callingRecord[i].NameID.ToString();
                    voicingParameters.TelephoneID = callingRecord[i].TelephoneID.ToString();
                    voicingParameters.FirstName = callingRecord[i].FirstName.ToString();
                    voicingParameters.LastName = callingRecord[i].LastName.ToString();
                    voicingParameters.Provider = callingRecord[i].Provider.ToString();
                    voicingParameters.Location = callingRecord[i].Location.ToString();
                    voicingParameters.DateOfAppointment = callingRecord[i].DateOfAppointment;
                    voicingParameters.DayOfAppointment = callingRecord[i].Day.ToString();
                    voicingParameters.DateOfAppointment1 = callingRecord[i].Date1.ToString();
                    voicingParameters.DateOfAppointment2 = callingRecord[i].Date2.ToString();
                    voicingParameters.TimeOfAppointment = callingRecord[i].TimeOfAppointment.ToString();
                    voicingParameters.CompanyId = callingRecord[i].Company_ID.ToString();
                    voicingParameters.VoiceMethod = callingRecord[i].Charge.ToString();
                    voicingParameters.VoiceFilePath = System.Configuration.ConfigurationManager.AppSettings["voiceFilePath"];
                    voicingParameters.VoiceName = System.Configuration.ConfigurationManager.AppSettings["voiceName"];
                    voicingParameters.Rate = int.Parse(System.Configuration.ConfigurationManager.AppSettings["rate"]);
                    voicingParameters.MessageName = callingRecord[i].Charge.ToString();

                    CreateVoiceFiles CreateVoiceFiles = new CreateVoiceFiles(voicingParameters);
                    Console.WriteLine(DateTime.Now.ToShortTimeString() + "  " + "voice record: " + voiceNumber.ToString());

                    //System.Threading.Thread.Sleep(1000);
                    System.Threading.Thread.Sleep(1000);

                    voiceNumber++;
                }
            }
            catch (Exception er)
            {
                string s1 = er.Message;
                //return 0;
            }
        }
        public void CreateVoiceFileSample(VoicingParameters voicingParameters, string toBeVoiced)
        {
            string fileName = string.Empty;
            fileName = voicingParameters.VoiceFileName;

            readerSample = new SpeechSynthesizer();
            readerSample.Rate = voicingParameters.Rate;

            readerSample.SelectVoice(voicingParameters.VoiceName);
            try
            {
                readerSample.SetOutputToWaveFile(voicingParameters.VoiceFilePath + fileName, new SpeechAudioFormatInfo(16025, AudioBitsPerSample.Sixteen, AudioChannel.Mono));
                readerSample.Speak(toBeVoiced);
            }
            catch (Exception er)
            {
                Log.LogMessage(er.ToString());
            }
        }