Script: "Pat Test Andrii"
Language: "en-us male"
# Help I can't get up ..
# Next: Execute - Remind me to take my medicine, Log patient stats and symptoms, Play Chopin, Play game, ..
# Secondary non-emergency options .. "I need a nurse" .. "I'm hungry" .. "I'm hungary"
# Next: Option to exit and test the Covid-19 screening script
# Email the patient assistant information and/or Pat script
## Play back to the patient what they said ("You said .." is that correct?)
## Send alert #1-PatientAssistanceRequest to nursing/caregiving administration with stt, recording and photo
## Tell patient their caregiver has been alerted, provide cancel option
## LATER: Enable interactive administrator to respond with automated and/or custom reply, with stt .. and deactivate
# Ask for details
## Do you have a life threatening emergency?
## If yes then sound alarm and send alert #2-Emergency
## Do you have bleeding .. problems breathing .. weakness .. fever .. coughing .. pulse slow or racing ..
## Send alert #3
# Later: sub-script execution and return (signal?)
## LATER: Keep talking, recoding, sending alerts
## I hope you can talk to me. What's your name? Tell me a few word about your situation
## LATER: Enable administrator to take snapshots, turn on audio, video,
## LATER: Light up Patient Assistant Device, and turn on patient room door sign
### Later: Add flexible calls for help .. eg. contains emergency or help twice, I feel xyz, I'm going to xyz
# Later:
# Check if camera available and take a photo if available
# Execute: Neon take a photo
# Later:
# photoTime = CURRENT_TIME()
# email alert with photo to care administrator
# Later:
# Begin recording audio in an emergency
# Sending alerts with recordings to caregiver administrator on a schedule (eg every 2 minutes)
## SOON .. (Next - Make Timeout wait time and time out label optional parameters for the user_input function)
# Set up wait time for patient responses
Variable: timeoutReturnLabel = AnnounceVersion
Timeout: 30, TIMEOUT
# Announce version ("Testing" is displayed as text and is not spoken)
@AnnounceVersion
Name Speak: Pat, "Neon Patient Assistant Application Demonstration Version 2020 07 09 18:22 </speak> Testing"
Variable: True = 1
Variable: False = 0
Variable: exitList = "exit", "cancel", "never mind"
Variable: noList
Variable: yesList
Variable: alertsPhraseList
Variable: inProgressList
Variable: heyPatList
Variable: askPrompt
Variable: returnLabel
Variable: heardSilence
Variable: falseAlarmCount
Variable: askReturnValue = ""
Variable: userName
Variable: moreAppInfo
Variable: customizeSettings
Variable: customizeLanguage
Variable: customizeProsody
Variable: photoTime
Variable: enableNeonApps
Variable: emailScriptList
Variable: alarmScriptList
Variable: conversationTranscript = "Our conversation went like this \n"
Variable: userSymptoms
Variable: gatherSymptomsList
@StartUp
# Initialize
# exitList = "exit", "cancel", "never mind"
noList = "no", "not now", "never mind", "nope", "n"
yesList = "yes", "yup", "y"
alertsPhraseList = "help", "I need help", "help me", "emergency", "this is an emergency", "i need a doctor", "i need a doctor", "i need a doctor", "i need a doctor", "i need a doctor", "i need a nurse", "i need aid", "i need a caregiver", "i need assistance", "i fell", "i can't get up", "fire"
inProgressList = "hey pat", "pat are you there", "is anybody listening", "what time is it", "Remind me to", "Play", "Email", "Record"
heyPatList = "hey pat", "pat are you there", "is anybody listening", "what time is it"
speechGenderList = "female", "male"
speechRateList = "medium", "fast", "slow"
speechAccentList = "American", "British" or "Australian"
askPrompt = ""
returnLabel = ""
heardSilence = ""
falseAlarmCount = 0
askReturnValue = ""
userName = ""
moreAppInfo = ""
customizeSettings = ""
customizeLanguage = ""
customProsody = "rate='medium'"
photoTime = ""
enableNeonApps = {True}
emailScriptList = "send script", "email script", "send my the script", "email me the script"
alarmScriptList = "alarm", "alarms", "remind", "reminder", "reminders", "timer", "timers", "time is left", "quiet", "go to sleep", "wake up", "snooze", "stop"
gatherSymptomsList = "headache", "pain", "feel bad", "not feel good", "don't feel good", "I think I got"
# Ask to install assistant
@PromptInstallAssistant
returnLabel = InstallAssistant
timeoutReturnLabel = PromptInstallAssistant
Name Speak: Pat, "Hi, I'm Pat. I'm a demonstration patient assistant from Neon AI. Thank you for helping test my conversational skills."
askPrompt = "Please tell me your name, or you can say cancel to exit."
Goto : ASK
@InstallAssistant
userName = {askReturnValue}
Name Speak: Pat, "Hi {userName}. I am glad you chose to install the Neon Patient Assistant Application."
## Offer additional information
@ReAskMoreInfo
Name Speak: Pat, "Before starting the Patient Assistant would you like more information on the Neon conversational patient assistance application?"
timeoutReturnLabel = ReAskMoreInfo
voice_input(moreAppInfo)
if {moreAppInfo} IN {noList[*]}:
Goto: PromptCustomize
Name Speak: Pat, "Hi {userName}. I'm Pat the demonstration conversational patient assistant from Neon AI. I am an artificial intelligence personal assistant. I'm augmented with Neon Gecko open source code and CPI Corp patented technology. Neon AI makes the Patient Assistant application to enable patients to alert their caregivers to emergencies and other needs, and to get simple information. As your automated patient assistant I listen for calls for help and send alerts to the patient care administrator. For example, you can say help, or I fell. Another thing you can say is what time is it .. </speak> In the future you will be able to play your favorite music, turn the lights on or off, and even ask to send a text message .. And if you don't want to call me Pat, someday you will be able to change my name."
# Customize
@PromptCustomize
## Offer customization of settings for administrator, voice and system settings
## Set up PA voice: name, gender, accent, pitch, speed, [Later: language, diction, empathy]
## Set up system settings: timeoutSeconds (wait time for user input)
## Set up administrator (password, email, name, phone, [Later: staff names, secondary contacts] ..)
## Set up nurse (password, email, name, phone, [Later: staff names, secondary contacts] ..)
customLanguage = ""
enableNeonApps = {True}
Name Speak: Pat, "Would you like to customize the Patient Assistant settings to disable non-emergency Neon AI patient applications, or to change my voice?"
# Name Speak: Pat, "Would you like to customize the Patient Assistant settings for administrator, voice and PAT system settings?"
timeoutReturnLabel = PromptCustomize
voice_input(customizeSettings)
if {customizeSettings} !IN {yesList[*]}:
Goto: BeginAssistant
Name Speak: Pat, "Hi {userName}. You can customize the voice for the Neon demonstration conversational patient assistant. You can say no change, or say female, male, normal, fast, slow, American, British or Australian. </speak> In the future you will be able to set up information for the administrator, staff members and the patient, and change my name and other PAT system settings."
@ReAskCustomize
# Name Speak: Pat, "Would you like to change the voice of the Neon conversational patient assistance application?"
timeoutReturnLabel = ReAskCustomize
voice_input(customizeSettings)
if {customizeSettings} == "":
Goto: PromptCustomize
if {customizeSettings} CONTAINS "no change":
Goto: BeginAssistant
if {customizeSettings} IN {noList[*]}:
Goto: BeginAssistant
# Variable: britWords = british, gb, uk
if {customizeSettings} CONTAINS british, gb, uk:
customLanguage = "'en-GB'"
else
if {customizeSettings} CONTAINS "Australian, AU, aussie":
customLanguage = "en-AU"
else
customLanguage = "en-us"
if {customizeSettings} CONTAINS "female":
customLanguage = "{customLanguage} female"
else
customLanguage = "{customLanguage} male"
Language: {customLanguage}
if {customizeSettings} CONTAINS "fast":
customProsody = "rate='fast'"
else
if {customizeSettings} CONTAINS "slow":
customProsody = "rate='slow'"
else
customProsody = "rate='medium'"
# Later: Provide example of new Language/Prosody and offer reset
# Later: Make settings into a case statement and error check:
# split_words(wordList, customizeSettings)
# customSettingCount = length({wordList})
# wordListIndex = 0
# LOOP
# Case
# LOOP END
@ReAskApps
Name Speak: Pat, "Would you like to enable more Neon patient assistance applications including playing music, playing games, reminders for medicine, hydration, meals and sleep, requests to record symptoms or other stats, and to request general information or assistance with math?"
timeoutReturnLabel = ReAskApps
voice_input(customizeSettings)
if {customizeSettings} == "":
Goto: ReAskApps
if {customizeSettings} IN {noList[*]}:
enableNeonApps = {False}
Goto: BeginAssistant
@BeginAssistant
timeoutReturnLabel = WaitForAlertPhrase
Name Speak: Pat, "<prosody {customProsody}> Your demonstration patient assistant has signed in. If you want to know if I am listening, you can say, hey Pat, or, Pat are you there. </prosody>"
# Wait for alert
@WaitForAlertPhrase
askPrompt = ""
returnLabel = GotPatientPhrase
### Name Speak: Pat, "PA 1 pre ask"
Goto : ASK
@GotPatientPhrase
# Saving conversation
conversationTranscript = "{conversationTranscript}, Prompt {askPrompt} Reply {askReturnValue}\n"
## Did patient ask for "help"
if {askReturnValue} !IN {alertsPhraseList[*]}:
## Not an emergency alert, check for secondary (in progress)
#if {enableNeonApps}:
## if {askReturnValue} CONTAINS {inProgressList[*]}:
#if {askReturnValue} STARTSWITH {inProgressList[*]}:
#Case:
#Name Speak: Pat, "I'm sorry {userName} that is under construction."
# inProgressList = "hey pat", "pat are you there", "is anybody listening", "what time is it", "Remind me to", "Play", "Email", "Record"
if {askReturnValue} CONTAINS {gatherSymptomsList}:
Name Speak: Pat, "Gathering Symptoms"
returnLabel = AskingSymptoms
askPrompt = "Please describe me your symptoms"
Goto : ASK
@AskingSymptoms
userSymptoms = "{userSymptoms}, {askReturnValue}"
Name Speak: Pat, "I heard you say {userSymptoms}"
# Reconvey: {userSymptoms}
Name Speak: Pat, "Thank you. I am sending these symptoms to your caregiver."
conversationTranscript = "{conversationTranscript}, Prompt {askPrompt} Reply {askReturnValue}\n"
returnLabel = GotPatientPhrase
askPrompt = ""
# Email: "{userName} has Symptoms", userSymptoms
# testing how transcript works
if {askReturnValue} == "transcript":
Name Speak: Pat, "{conversationTranscript}"
# Email the transcript of the conversation
# TODO Think about how to limit the number of phrases sent
if {askReturnValue} CONTAINS {emailScriptList[*]}:
Name Speak: Pat, "About to send you the transcript of our conversation"
Email: "Conversation Transcript", conversationTranscript
# Set an alarm delegating execution to the alert.neon skill
# TODO: Checkout the alerts __init__ for handle_snooze alerts error
if {askReturnValue} CONTAINS {alarmScriptList}:
Name Speak: Pat, "I heard you want to set up an alarm"
Execute: {askReturnValue}
### Later: Add flexible calls for help .. eg. contains emergency or help twice, I feel xyz, I'm going to xyz
### Name Speak: Pat, "Not alert, listen again"
Goto: WaitForAlertPhrase
# Possible EMERGENCY
Name Speak: Pat, "Pat the Patient Assistant heard an emergency alert. I heard {askReturnValue}"
Reconvey : askReturnValue
Name Speak: Pat, "</speak>PA 6 did reconvey"
@PromptConfirmHelp
askPrompt = "Please say just kidding if this is not an emergency"
returnLabel = ConfirmHelp
Goto : ASK
@ConfirmHelp
## Did patient REALLY ask for "help"?
if {askReturnValue} == "":
Name Speak: Pat, "Pat the Patient Assistant heard nothing. I heard"
Reconvey : askReturnValue
Name Speak: Pat, "</speak>PA 8 did reconvey of nothing heard"
## PA heard nothing after emergency request .. if second time then this is an emergency
if {heardSilence} == {True} :
Goto: Emergency
heardSilence = {True}
## Increase volume and speak slowly
Name Speak: Pat, "<prosody volume='+100%' rate='slow'>{userName}! I need to hear from you! Is this an emergency?</prosody>"
Goto: PromptConfirmHelp
if {askReturnValue} CONTAINS "just kidding", "never mind","not an emergency":
Name Speak: Pat, "Pat the Patient Assistant heard you say this is not an emergency. I heard"
Reconvey : askReturnValue
### Name Speak: Pat, "</speak>Did reconvey of jk"
## Patient said jk so restart listening
Name Speak: Pat, "Please say help again if this is an emergency."
Python: falseAlarmCount = {falseAlarmCount} + 1
Goto: WaitForAlertPhrase
# EMERGENCY
@Emergency
Name Speak: Pat, "<prosody volume='+100%' rate='normal'>{userName}! Needs! Help! This is an EMERGENCY</prosody>"
Name Speak: Pat, "Pat the Patient Assistant would now send an emergency alert, sound an alarm, keep engaged with the patient, and send updated alerts to the caregiver."
Name Speak: Pat, "Pat test completed. Say start again to start again?"
voice_input(askReturnValue)
if {askReturnValue} == "start again":
Name Speak: Pat, "</speak>Pat is restarting. Thanks again."
Goto: StartUp
Name Speak: Pat, "Pat exiting. Thanks again for helping test my skills."
exit
# ========== Subroutines
@ASK
# The ASK subroutine speaks the askPrompt and waits for a response. If the response is a command to Pat to perform an action, then the request is effected and Pat continues waiting for a response, otherwise, the response is returned to the caller in the askReturnValue.
# Input parameters: askPrompt, returnLabel and timeOutReturnLabel
# Result parameter: askReturnValue
### Name Speak: Pat, "Ask 1 Starting"
if {askPrompt}:
Name Speak: Pat, " {askPrompt} "
### Name Speak: Pat, "Ask 2 Starting ask subroutine"
voice_input(askReturnValue)
### Name Speak: Pat, "Ask 3 got input"
if {askReturnValue} IN {exitList[*]}:
Name Speak: Pat, "Say yes to confirm exiting Pat, the Neon AI Patient Assistant"
voice_input(askReturnValue)
if {askReturnValue} IN {yesList[*]}:
Name Speak: Pat, "Pat, the Neon AI Patient Assistant, signing off"
exit
else
goto: ASK
### Name Speak: Pat, "Ask 4 not cancel command {askReturnValue}"
if {askReturnValue} IN {heyPatList[*]}:
Name Speak: Pat, "<prosody {customProsody}> {userName}, Pat the AI Patient Assistant demo here. I'm listening all the time but I don't <phoneme alphabet='x-sampa' ph='rikord'>record</phoneme> everything you say. I only make recordings of calls for help or in an emergency. </prosody>"
# Note - Disambiguation for the pronunciations of "record": <phoneme alphabet="x-sampa" ph="rikord">record</phoneme> Verb as in "I record everything you say" vs. Noun as in "Make a record of the conversation".
Name Speak: Pat, "The time is"
Execute : "Neon what time is it"
if {falseAlarmCount} != 0:
Name Speak: Pat, "The false alarm count is {falseAlarmCount}!"
goto : ASK
### Name Speak: Pat, "Ask 5 About to return to {returnLabel}"
Goto: {returnLabel}
@TIMEOUT
Goto: {timeoutReturnLabel}