TIPS Prescription Refill Service

edlentz

Member
Joined
Aug 11, 2013
Messages
94
Reaction score
6
I am in need of something like a prescrition refill voicemail/IVR. Here is what the idea is.

Patient calls a DID or accesses through an IVR. The system asks a series of questions.
Name and phone number >>>>> Caller responds verbally (system is recording this) then presses # to advance to the next question(s), each time they press # to advance.. When all done the whole recording is available in a voicemail box for the Dr or Nurse to act on. Does anyone know if there is a module out there that does this or failing that can someone point me in the direction of how I can accomplish this?

Thanks
 
Hi @edlentz. Don't know of any open source software designed specifically for this, but you may want to take a look at the new Voice Dialer script which will point you in the right direction. It could even transcribe the responses and include those with the voice recordings. Or it could store the information in a database for retrieval by the doctor or nurse.
 
Hi Ward,

Yeah I have done some searching around and there isn't much out there. I am wondering if I can home grow something. I thought about running the caller through a series of IVR entries going into another series of mailboxes and doing a call recording of it all. Then presenting the call recording to the staff to listen to over a PC. But the more I think about it the more I think that won't work
 
Some of us do heavily discounted consulting work when you agree to open source the resulting code and license it under the GPL. :sorcerer:
 
Hmmm,

That sounds interesting. Are you offering to help for the GPL ? It seems to me (neophite that I am) that some kind of hybrid between an IVR and a voicemail box could work
 
@edlentz: Here is a rough cut at what you're looking for. You can take it from here. This assumes you have an extension 701 enabled on your PBX with voicemail, and that extension will be used to accept calls from doctor/pharmacist. Patients should dial 1234, and this option could be added to an IVR. The dialplan code is straight-forward. It prompts the caller for their name and then their password and then a message. Caller gets a beep after each voice prompt, and caller presses # to continue. The dialplan then consolidates the 3 .wav files into a single file and generates a .call file to send the consolidated .wav file to the voicemail account for extension 701 where the doctor/pharmacist can retrieve it by dialing *98701.

Insert the following code in /etc/asterisk/extensions_custom.conf just below [from-internal-custom]. Delete the old 1234 context from the file if it exists. You would need to adjust the Record parameters to meet your needs. As configured, 3,10 means to accept the recording after 3 seconds of silence without caller pressing # and accept no recording longer than 10 seconds. The Playback commands with vm-rec-name, vm-password, and vm-message are what you would replace with your voice prompts. You can add as many blocks of the 5 lines of code (lines 3,4,5,6,7) as you need. Be sure to increment RANDFILE1 to the correct number in each iteration. Once all the recordings are collected, they are consolidated into a single .wav file with the sox command. yum install sox if it's not on your server. If you have more than 3 recordings, just add the additional filenames in the sox command. When the aggregated .wav file is created, it is played to the caller. I've added code to confirm the entries before continuing. Then the dialplan generates a .call file to *701 (voicemail account for extension 701) using the 12345 context. The 12345 dialplan waits 10 seconds for the initial voicemail prompt from Allison to play. Then it plays the aggregated .wav file into the voicemail message and hangs up. Extension 701 then will show a voicemail has been delivered. In the FreePBX GUI, you can configure the voicemail settings for 701 to deliver an email or text message as desired when the new voicemail arrives. It probably should not include the recording itself because of HIPPA.

Keep in mind that random numbers from nearly simultaneous callers may not be unique so calls should be limited to one at a time unless the numbering scheme is revised to use something such as the caller's CallerID number-1, -2, etc. Good luck!

Code:
; Copyright (c) 2017, Ward Mundy & Associates, LLC. Licensed pursuant to GPL2 license.
exten => 1234,1,Answer
exten => 1234,n,Playback(please-answer-the-following)
exten => 1234,n(startagain),Playback(vm-rec-name)
exten => 1234,n,Set(RANDFILE1=${RAND(8000,8599)})
exten => 1234,n,Record(/tmp/${RANDFILE1}.wav,3,10)
exten => 1234,n,Playback(/tmp/${RANDFILE1})
exten => 1234,n,NoOp(File name: /tmp/${RANDFILE1})
exten => 1234,n,Playback(vm-password)
exten => 1234,n,Set(RANDFILE2=${RAND(8000,8599)})
exten => 1234,n,Record(/tmp/${RANDFILE2}.wav,3,10)
exten => 1234,n,Playback(/tmp/${RANDFILE2})
exten => 1234,n,NoOp(File name: /tmp/${RANDFILE2})
exten => 1234,n,Playback(vm-message)
exten => 1234,n,Set(RANDFILE3=${RAND(8000,8599)})
exten => 1234,n,Record(/tmp/${RANDFILE3}.wav,3,10)
exten => 1234,n,Playback(/tmp/${RANDFILE3})
exten => 1234,n,NoOp(File name: /tmp/${RANDFILE3})
exten => 1234,n,System(/usr/bin/sox /tmp/${RANDFILE1}.wav /tmp/${RANDFILE2}.wav /tmp/${RANDFILE3}.wav /tmp/recordingsox.wav)
exten => 1234,n,System(rm -f /tmp/8*.wav)
exten => 1234,n,Set(TIMEOUT(response)=10)
exten => 1234,n(askagain),Playback(/tmp/recordingsox)
exten => 1234,n,Playback(to-rerecord-yr-message)
exten => 1234,n,Playback(press)
exten => 1234,n,Playback(digits/star)
exten => 1234,n,Playback(otherwise-press)
exten => 1234,n,Playback(digits/1)
exten => 1234,n,Read(MYCHOICE,beep,1)
exten => 1234,n,GotoIf($["${MYCHOICE}" = "1"]?notagain)
exten => 1234,n,GotoIf($["${MYCHOICE}" = "*"]?startagain)
exten => 1234,n,Goto(askagain)
exten => 1234,n(notagain),System(echo "Channel: local/*701@from-internal" > /tmp/alert.call)
exten => 1234,n,System(echo "MaxRetries: 0" >> /tmp/alert.call)
exten => 1234,n,System(echo "RetryTime: 0" >> /tmp/alert.call)
exten => 1234,n,System(echo "WaitTime: 30" >> /tmp/alert.call)
exten => 1234,n,System(echo "Context: from-internal-custom" >> /tmp/alert.call)
exten => 1234,n,System(echo "Extension: 12345" >> /tmp/alert.call)
exten => 1234,n,System(echo "Priority: 1" >> /tmp/alert.call)
exten => 1234,n,System(mv /tmp/alert.call /var/spool/asterisk/outgoing)
exten => 1234,n,Playback(your-msg-has-been-saved)
exten => 1234,n,Playback(goodbye)
exten => 1234,n,Hangup()

exten => 12345,1,Answer
exten => 12345,n,Wait(10)
exten => 12345,n,Playback(/tmp/recordingsox)
exten => 12345,n,Hangup
 
Last edited:
@edlentz: I've embellished the code above a little to require confirmation and also modified the notes a bit to warn of a potential problem if multiple calls arrived simultaneously. You would not want to use the code above with multiple simultaneous calls, or you'd risk having one request stepping on the other one. Using CallerID numbers plus a suffix of 1, 2, 3, 4 for the questions would avoid the problem so long as the filename for the aggregated file also used the same scheme to make those files unique as well.
 
Thanks Ward, I haven't had time to play with it yet, I will this morning I hope. We wil need simultaneous call capability, I can see that happening quite readily. This is a busy office, probably handle 2k of calls a day
 
Ward,
I just about have this working the way I need it, with the exception of the final recording being sent to the voicemailbox. With it the way it is now I will get two messages in the mailbox but with the LAST message to be recorded since the ultimate recorded wav file is the same for every call. I tried to setup a variable with the channel for the name of the wav file but to no avail. What can I do to make that unique? Did I miss understand something in your tip?

; Copyright (c) 2017, Ward Mundy & Associates, LLC. Licensed pursuant to GPL2 license.
exten => 1234,1,Answer
exten => 1234,n,Set(refillmsg=${CHANNEL})
exten => 1234,n(startagain),Playback(custom/script_intro)
exten => 1234,n,Playback(custom/script_name_dob)
exten => 1234,n,Set(${CALLERID(num)}-1)
exten => 1234,n,Record(/tmp/${CALLERID(num)}-1.wav,10,20)
exten => 1234,n,NoOp(File name: /tmp/${CALLERID(num)}-1)
exten => 1234,n,Playback(custom/script_phone_number)
exten => 1234,n,Set(${CALLERID(num)}-2)
exten => 1234,n,Record(/tmp/${CALLERID(num)}-2.wav,10,20)
exten => 1234,n,NoOp(File name: /tmp/${CALLERID(num)}-2)
exten => 1234,n,Playback(custom/script_drug)
exten => 1234,n,Set(${CALLERID(num)}-3)
exten => 1234,n,Record(/tmp/${CALLERID(num)}-3.wav,10,20)
exten => 1234,n,NoOp(File name: /tmp/${CALLERID(num)}-3)
exten => 1234,n,Playback(custom/script_strength_refills)
exten => 1234,n,Set(${CALLERID(num)}-4)
exten => 1234,n,Record(/tmp/${CALLERID(num)}-4.wav,10,20)
exten => 1234,n,NoOp(File name: /tmp/${CALLERID(num)}-4)
exten => 1234,n,Playback(custom/script_pharmacy)
exten => 1234,n,Set(${CALLERID(num)}-5)
exten => 1234,n,Record(/tmp/${CALLERID(num)}-5.wav,10,20)
exten => 1234,n,NoOp(File name: /tmp/${CALLERID(num)}-5)
exten => 1234,n,System(/usr/bin/sox /tmp/${CALLERID(num)}-1.wav /tmp/${CALLERID(num)}-2.wav /tmp/${CALLERID(num)}-3.wav /tmp/${CALLERID(num)}-4.wav /tmp/${CALLERID(num)}-5.wav /tmp/refillmsg.wav)
exten => 1234,n,System(rm -f /tmp/${CALLERID(num)}-*.wav)
exten => 1234,n,Set(TIMEOUT(response)=10)
exten => 1234,n(askagain),Playback(/tmp/refillmsg)
exten => 1234,n,Playback(to-rerecord-yr-message)
exten => 1234,n,Playback(press)
exten => 1234,n,Playback(digits/star)
exten => 1234,n,Playback(otherwise-press)
exten => 1234,n,Playback(digits/1)
exten => 1234,n,Read(MYCHOICE,beep,1)
exten => 1234,n,GotoIf($["${MYCHOICE}" = "1"]?notagain)
exten => 1234,n,GotoIf($["${MYCHOICE}" = "*"]?startagain)
exten => 1234,n,Goto(askagain)
exten => 1234,n(notagain),System(echo "Channel: local/*124@from-internal" > /tmp/alert.call)
exten => 1234,n,System(echo "MaxRetries: 0" >> /tmp/alert.call)
exten => 1234,n,System(echo "RetryTime: 0" >> /tmp/alert.call)
exten => 1234,n,System(echo "WaitTime: 30" >> /tmp/alert.call)
exten => 1234,n,System(echo "Context: from-internal-custom" >> /tmp/alert.call)
exten => 1234,n,System(echo "Extension: 12345" >> /tmp/alert.call)
exten => 1234,n,System(echo "Priority: 1" >> /tmp/alert.call)
exten => 1234,n,System(mv /tmp/alert.call /var/spool/asterisk/outgoing)
exten => 1234,n,Playback(your-msg-has-been-saved)
exten => 1234,n,Playback(goodbye)
exten => 1234,n,Hangup()

;Send the call to the voicemail box
exten => 12345,1,Answer
exten => 12345,n,Wait(10)
exten => 12345,n,Playback(/tmp/refillmsg)
exten => 12345,n,Hangup
 
I know I am missing something terribly easy, but just can't see it.

I changed this line: exten => 1234,n,System(/usr/bin/sox /tmp/${CALLERID(num)}-1.wav /tmp/${CALLERID(num)}-2.wav /tmp/${CALLERID(num)}-3.wav /tmp/${CALLERID(num)}-4.wav /tmp/${CALLERID(num)}-5.wav /tmp/refillmsg.wav)

To this: exten => 1234,n,System(/usr/bin/sox /tmp/${RANDFILE1}.wav /tmp/${RANDFILE2}.wav /tmp/${RANDFILE3}.wav /tmp/${RANDFILE4}.wav /tmp/${RANDFILE5}.wav /tmp/refillmsg${CALLERID(num)}.wav) This way I get a unique file name, so I can get multiple callers at the same time. Which is what I need.

And the playback into the voicemail box to: exten => 12345,n,Playback(/tmp/refillmsg${CALLERID(num)})

So when extension 125 calls 1234 and goes through the process all is well all the way UNTIL it comes time to playback to the voicemailbox. The system cannot find the file, even tho it created refillmsg125.wav in the tmp directory. Just for grins if I change: exten => 12345,n,Playback(/tmp/refillmsg${CALLERID(num)}) to exten => 12345,n,Playback(/tmp/refillmsg125) The call is recorded into mailbox 124 and all is good.
 
Code:
exten => 1234,n,System(/usr/bin/sox /tmp/${CALLERID(num)}-1.wav /tmp/${CALLERID(num)}-2.wav /tmp/${CALLERID(num)}-3.wav /tmp/${CALLERID(num)}-4.wav /tmp/${CALLERID(num)}-5.wav /tmp/refillmsg.wav)

To this:
Code:
exten => 1234,n,System(/usr/bin/sox /tmp/${RANDFILE1}.wav /tmp/${RANDFILE2}.wav /tmp/${RANDFILE3}.wav /tmp/${RANDFILE4}.wav /tmp/${RANDFILE5}.wav /tmp/refillmsg${CALLERID(num)}.wav)

Code tags are too difficult then?
 
I apologize for the code tags. I will have to re-read the "before you post" Thank you for your help
 
ostridge,

I applied your suggestion, also changing the two playback file names with the same results. The file gets created in /tmp but the playback into the voicemailbox doesn't happen. Could it be that the refillmsg${CALLERID(num)} is still a concanated name of a file instead of a real file name ie:refillmsg124 ?
 
Here is my up to date code that does not send the complied message into the voicemail box. If anyone can comment, help me get this working it is much appreciated.
Code:
; Copyright (c) 2017, Ward Mundy & Associates, LLC. Licensed pursuant to GPL2 license.
; Extra content added by Ed Lentz Oct 2017
; Script to elicit audio responses from callers and send to a voicemail box.
exten => 1234,1,Answer
exten => 1234,n(startagain),Playback(custom/script_intro)
exten => 1234,n,Playback(custom/script_name_dob)
exten => 1234,n,Set(RANDFILE1=${CALLERID(num)}-1)
exten => 1234,n,Record(/tmp/${RANDFILE1}.wav,3,10)
exten => 1234,n,NoOp(File name: /tmp/${RANDFILE1})
exten => 1234,n,Playback(custom/script_phone_number)
exten => 1234,n,Set(RANDFILE2=${CALLERID(num)}-2)
exten => 1234,n,Record(/tmp/${RANDFILE2}.wav,10,20)
exten => 1234,n,NoOp(File name: /tmp/${RANDFILE2})
exten => 1234,n,Playback(custom/script_drug)
exten => 1234,n,Set(RANDFILE3=${CALLERID(num)}-3)
exten => 1234,n,Record(/tmp/${RANDFILE3}.wav,10,20)
exten => 1234,n,NoOp(File name: /tmp/${RANDFILE3})
exten => 1234,n,Playback(custom/script_strength_refills)
exten => 1234,n,Set(RANDFILE4=${CALLERID(num)}-4)
exten => 1234,n,Record(/tmp/${RANDFILE4}.wav,10,20)
exten => 1234,n,NoOp(File name: /tmp/${RANDFILE4})
exten => 1234,n,Playback(custom/script_pharmacy)
exten => 1234,n,Set(RANDFILE5=${CALLERID(num)}-5)
exten => 1234,n,Record(/tmp/${RANDFILE5}.wav,10,20)
exten => 1234,n,NoOp(File name: /tmp/${RANDFILE5})
exten => 1234,n,System(/usr/bin/sox /tmp/${RANDFILE1}.wav /tmp/${RANDFILE2}.wav /tmp/${RANDFILE3}.wav /tmp/${RANDFILE4}.wav /tmp/${RANDFILE5}.wav /tmp/msg${CALLERID(num)}.wav)
exten => 1234,n,System(rm -f /tmp/8*.wav)
exten => 1234,n,Set(TIMEOUT(response)=10)
exten => 1234,n(askagain),Playback(/tmp/msg${CALLERID(num)})
exten => 1234,n,Playback(to-rerecord-yr-message)
exten => 1234,n,Playback(press)
exten => 1234,n,Playback(digits/star)
exten => 1234,n,Playback(otherwise-press)
exten => 1234,n,Playback(digits/1)
exten => 1234,n,Read(MYCHOICE,beep,1)
exten => 1234,n,GotoIf($["${MYCHOICE}" = "1"]?notagain)
exten => 1234,n,GotoIf($["${MYCHOICE}" = "*"]?startagain)
exten => 1234,n,Goto(askagain)
exten => 1234,n(notagain),System(echo "Channel: local/*124@from-internal" > /tmp/alert.call)
exten => 1234,n,System(echo "MaxRetries: 0" >> /tmp/alert.call)
exten => 1234,n,System(echo "RetryTime: 0" >> /tmp/alert.call)
exten => 1234,n,System(echo "WaitTime: 30" >> /tmp/alert.call)
exten => 1234,n,System(echo "Context: from-internal-custom" >> /tmp/alert.call)
exten => 1234,n,System(echo "Extension: 12345" >> /tmp/alert.call)
exten => 1234,n,System(echo "Priority: 1" >> /tmp/alert.call)
exten => 1234,n,System(mv /tmp/alert.call /var/spool/asterisk/outgoing)
exten => 1234,n,Playback(your-msg-has-been-saved)
exten => 1234,n,Playback(goodbye)
exten => 1234,n,Hangup()

exten => 12345,1,Answer
exten => 12345,n,Wait(10)
exten => 12345,n,Playback(/tmp/msg${CALLERID(num)})
exten => 12345,n,Hangup

This is from the asterisk log file
Code:
[2017-10-24 16:05:23] VERBOSE[32424][C-000000ae] pbx.c: Executing [12345@from-internal-custom:3] Playback("Local/*124@from-internal-0000002c;1", "/tmp/msg") in new stack
[2017-10-24 16:05:23] WARNING[32424][C-000000ae] file.c: File /tmp/msg does not exist in any format
[2017-10-24 16:05:23] WARNING[32424][C-000000ae] file.c: Unable to open /tmp/msg (format (slin)): No such file or directory
[2017-10-24 16:05:23] WARNING[32424][C-000000ae] app_playback.c: Playback failed on Local/*124@from-internal-0000002c;1 for /tmp/msg
[2017-10-24 16:05:23] VERBOSE[32424][C-000000ae] pbx.c: Executing [12345@from-internal-custom:4] Hangup("Local/*124@from-internal-0000002c;1", "") in new stack
[2017-10-24 16:05:23] VERBOSE[32424][C-000000ae] pbx.c: Spawn extension (from-internal-custom, 12345, 4) exited non-zero on 'Local/*124@from-internal-0000002c;1'
[2017-10-24 16:05:23] VERBOSE[32425][C-000000ad] app.c: User hung up
 
Any ideas how to make this work with multiple callers? I tried to set a variable in the .call file to make the final .wav file but when two callers call in only the last callers message is played into the mailbox. I tied renaming the msg${CALLERID(num)} to recording and placing it into the /tmp file, and it does get there but to no avail when there are two callers.

Thanks for any ideas I am fresh out :(
 

Members online

No members online now.

Forum statistics

Threads
26,687
Messages
174,410
Members
20,257
Latest member
Dempan
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Back
Top