public List<MakeCall> GetListToCall(MakeCall extras)
        {
            List<CallingRecord> callingRecords = new List<CallingRecord>();
            PatientRecords patientRecords = new PatientRecords();
            List<MakeCall> makeCalls = new List<MakeCall>();

            if (extras.Type == "R")
            {
                callingRecords = patientRecords.GetListOfCallingRecords();
            }
            else if (extras.Type == "M")
            {
                callingRecords = patientRecords.GetListOfCallingRecordsMonitor();
            }

            for (int i = 0; i < callingRecords.Count; i++)
            {
                MakeCall makeCall = new MakeCall();
                makeCall.CallerName = callingRecords[i].TelephoneID.ToString();
                makeCall.AnswerMethod = "GET";
                makeCall.FromNumber = extras.FromNumber;
                makeCall.ToNumber = callingRecords[i].TelephoneNumber1;
                makeCall.AnswerURL = extras.AnswerURL;
                makeCall.HangUpURL = extras.HangUpURL;
                makeCalls.Add(makeCall);
            }
            return makeCalls;
        }
 private static string GetProviderName(string providerID)
 {
     PatientRecords patientRecords = new PatientRecords();
     return patientRecords.GetProviderNameFromID(providerID);
 }
        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 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";
            WaldenEasyNotes.Model.Voicing voicing = new WaldenEasyNotes.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 WaldenEasyNotes.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());
            }
        }
 public static string GetLocationString(string locationID)
 {
     PatientRecords patientRecords = new PatientRecords();
     return patientRecords.GetLocationNameFromID(locationID);
 }