Hi,
Can we post our code to get looked at and see how we can improve it?
Thanks
Hi,
Can we post our code to get looked at and see how we can improve it?
Thanks
Please feel free to post your code.
Dave is way nicer than me. But I’m more judgmental. Post away lol.
Best way to learn. Go for it.
Thank you, here is my code. I am creating a patient and scheduling an appointment and checking that appointment in.
put “yes” into newpatient //new patient will be created
put “80000” into Dept
//Call open_tst which opens tst and verifies it opens, pass Modeluser and dept as parameters
open_tst_for_appt ModelUser, Dept
//click appointment button
Wait[16]
typetext controlkey, “1”
if [newpatient =“no”] then
wait(2)
typetext mrn
Wait(1)
typetext returnkey
Wait(1)
typetext altkey, A
//Click on book it
Wait(5)
typetext altkey, B
else if [newpatient =“yes”] then
//new patient needs to be created
//Enter a name and add the date and time to make the name unique and sex, birthdate, and phone number
Wait(1)
enter_patient_info
//Click on book it
Wait(5)
typetext altkey, B
//enter address
wait[17]
typetext "123 Street"
wait(1)
typetext tabkey
wait(1)
//enter zipcode
typetext "90212", tabkey
wait(1)
//enter phone number
Click (Image:"a04/HomePhone", WaitFor:5)
wait(1)
typetext "954-444-2342"
wait(1)
typetext tabkey
//add a guarantor
Click (Image:"a04/PatGuarandCvg", WaitFor:4)
//click add guarantor
wait[3]
typetext altkey, r
//click search/create
wait[3]
typetext altkey, a
//click create
wait[3]
typetext altkey, r
//add a coverage
wait(2)
Click (Image:"a04/Coverages", WaitFor:4)
//click add coverage
wait(1)
typetext altkey, d
wait(1)
//type in a coverage
typetext "AAE", tabkey
wait(1)
//accept the coverage
typetext altkey, a
wait(1)
//click on patient as subscriber
typetext returnkey
//override query
wait(1)
typetext altkey, o
wait(8)
//click accept
Wait[3]
Click (Image:"a04/Accept_4", WaitFor:5)
//click continue anyway
wait(1)
Click (Image:"a04/ContinueAnyway_1", WaitFor:3)
end if
//tab to visit type
wait(10)
typetext tabkey
wait(1)
//enter new as the visit type
typetext “new”, tabkey
wait(1)
//enter all for the provider
if ImageFound(text:“Providers”, WaitFor:9) then
Wait(1)
typetext “all”, tabkey
wait(1)
typetext returnkey
wait(1)
//select a time
wait(1)
Click (Image:“a04/Selectatime”, WaitFor:5)
//type E1000 for fammd
wait(1)
typetext “E1000”, tabkey
wait(1)
//enter today for the appt date
typetext “t”
wait(1)
typetext tabkey
//enter now for the time
wait(1)
typetext “n”
wait(1)
typetext tabkey
wait(1)
//click check mark
wait(1)
Click {Image:“a04/checkmark”, WaitFor:4}
end if
if ImageFound(Image:“a04/personsicon”, WaitFor:9) then
//click the time field
Click {text:“Select a time”, WaitFor:5}
wait(1)
//enter today for the appt date
typetext “t”
wait(1)
typetext tabkey
//enter now for the time
wait(1)
typetext “n”
wait(1)
typetext tabkey
wait(1)
//click check mark if there
if ImageFound(Image:“a04/personsicon”, WaitFor:9) then
Click (Image:“a04/checkmark”, WaitFor:4)
end if
end if
wait(1)
//click continue
typetext altkey, n
//click schedule
wait[2]
typetext altkey, s
//click schedule
wait[2]
typetext altkey, s
//click accept
Click {Image:“a04/Accept_3”, WaitFor:20}
//click continue anyway
Click {Image:“a04/ContinueAnyway”, WaitFor:3}
(*
//If registration wizard shows up, click finish
if ImageFound(Image:“a04/RegistrationWizard”, WaitFor:9) then
Wait(1)
typetext altkey, f
end if*)
//press pagedown to go to latest appointment
wait(1)
typetext pagedown
//check in the patient
Wait(3)
Click (Image:“a04/CheckIn”, WaitFor:7)
Wait[2]
//add a visitor’s account
//click Enc Guar and Cvgs
Click (Image:“a04/EncGuarCvgs”, WaitFor:4)
wait(1)
//select the visit guarantor
Click (Image:“a04/VisitGuarantor”, WaitFor:4)
//add lanuage, ethnicity and race
wait(2)
//click on demographics
Click {text:“demographics”, WaitFor:4}
wait[4]
typetext pagedown, pagedown
wait(1)
//click on preferred language and enter a value
Click (Image:“a04/PreferredLanguage”, WaitFor:4)
wait(1)
typetext “17”, tabkey
wait(1)
//tab to ethnicity and enter a value
typetext tabkey, tabkey, tabkey, tabkey
wait(1)
typetext “2”, tabkey
//tab to race and enter a value
wait(1)
typetext tabkey, tabkey
wait(1)
typetext “1002”, tabkey
//click check in again
wait(2)
Click {Image:“a04/CheckIn1”, WaitFor:5}
//click ask later
wait(2)
if ImageFound(text:“Ask Later”, waitFor:7) then
Typetext altkey, L
end if
//click continue anyway
wait(2)
Click {Image:“a04/ContinueAnyway”, WaitFor:3}
//put mrn into variable
Wait[7]
typetext altkey, “f”
put readtext(“a13/MRN_a_TL”, “a13/MRN_a_BR”) into CreatedMRN
log createdMRN
//verify if patient shows arrived
if ImageFound(imageName:“a04/arrived”, waitFor:7) then
logsuccess “Patient is checked in and the appointment desk screen is displayed.”
else
logerror “Patient is not checked in and the appointment desk screen is displayed.”
end if
//click close epic
closeepic
//returning MRN
return createdMRN
Hey @shah,
Here are my findings and an optimized version.
As you did not mention what particularly you’d like to optimize in your code I generally reviewed it with common sense and based on best practices. Check this link Eggplant best practices
textEntry "My Name", "Karsten","200,0" # This will click 100 pixel right to the center of the text "My Name"
to textEntry label, input, offset:(100,0)
click text: label + offset
typetext controlkey,"a" #fail safe if the box has already text in it
typetext input
end textEntry
Here the reviewed code: (Welcome the others to post their review and feedback) There is more than one solution.
put "yes" into newpatient //new patient will be created
put "80000" into Dept
set the remoteworkinterval to 1 // Default is 0.7 set Seconds
//Call open_tst which opens tst and verifies it opens, pass Modeluser and dept as parameters
open_tst_for_appt ModelUser, Dept
//click appointment button
Waitfor 20, Text:"Appointment"##wait 16
typetext controlkey, "1"
if newpatient ="no" then
wait 2
typetext mrn
#wait 1
typetext returnkey
#wait 1
typetext altkey, A
//Click on book it
Waitfor 5, text:"Text"#wait 5
typetext altkey, B
else #if newpatient ="yes" then Not required if its just yes or no
//new patient needs to be created
//Enter a name and add the date and time to make the name unique and sex, birthdate, and phone number
#wait 1
enter_patient_info
//Click on book it
Waitfor 5, text:"Text"
typetext altkey, B
//enter address
Waitfor 20, IMage:"Address"#wait 17
typetext "123 Street"
#wait 1
typetext tabkey
#wait 1
//enter zipcode
typetext "90212", tabkey
#wait 1
//enter phone number
Click (Image:"a04/HomePhone", WaitFor:5)
#wait 1
typetext "954-444-2342"
#wait 1
typetext tabkey
//add a guarantor
Click (Image:"a04/PatGuarandCvg", WaitFor:4)
//click add guarantor
Waitfor 5, image:"AddedGuarantorIcon"#wait 3
typetext altkey, r
//click search/create
waitfor 20, image:"CreatePopup"#wait 3
typetext altkey, a
//click create
Waitfor 5, image:"validatorPic"#wait 3
typetext altkey, r
//add a coverage
Waitfor 5, image:"validatorPic"#wait 2
Click (Image:"a04/Coverages", WaitFor:4)
//click add coverage
#wait 1
typetext altkey, d
#wait 1
//type in a coverage
typetext "AAE", tabkey
#wait 1
//accept the coverage
typetext altkey, a
#wait 1
//click on patient as subscriber
typetext returnkey
//override query
#wait 1
typetext altkey, o
Waitfor 8, image:"validatorPic"#wait 8
//click accept
#wait 3
Click {Image:"a04/Accept_4", WaitFor:5} // This commands waits already for the image. no need to add another hard wait before. It will search multiple times within the 5 seconds until it finds it.
//click continue anyway
#wait 1
Click (Image:"a04/ContinueAnyway_1", WaitFor:3)
end if
//tab to visit type
Waitfor 10, TExt: "My visit"#wait 10
# Tabkey is not ideal. In case your UI changes you might end up another field and enter the wrong data
typetext tabkey
#wait 1
//enter new as the visit type
typetext "new", tabkey
#wait 1
//enter all for the provider
if ImageFound(text:"Providers", WaitFor:9) then
#wait 1
typetext "all", tabkey
#wait 1
typetext returnkey
#wait 1
//select a time
#wait 1
Click (Image:"a04/Selectatime", WaitFor:5)
//type E1000 for fammd
#wait 1
typetext "E1000", tabkey
#wait 1
//enter today for the appt date
typetext "t"
#wait 1
typetext tabkey
//enter now for the time
#wait 1
typetext "n"
#wait 1
typetext tabkey
#wait 1
//click check mark
#wait 1
Click {Image:"a04/checkmark", WaitFor:4}
end if
if ImageFound(Image:"a04/personsicon", WaitFor:9) then
//click the time field
Click {text:"Select a time", WaitFor:5}
#wait 1
//enter today for the appt date
typetext "t"
#wait 1
typetext tabkey
//enter now for the time
#wait 1
typetext "n"
#wait 1
typetext tabkey
#wait 1
//click check mark if there
if ImageFound(Image:"a04/personsicon", WaitFor:9) then
Click (Image:"a04/checkmark", WaitFor:4)
end if
end if
#wait 1
//click continue
typetext altkey, n
//click schedule
wait 2
typetext altkey, s
//click schedule
wait 2
typetext altkey, s
//click accept
Click {Image:"a04/Accept_3", WaitFor:20}
//click continue anyway
Click {Image:"a04/ContinueAnyway", WaitFor:3}
(*
//If registration wizard shows up, click finish
if ImageFound(Image:"a04/RegistrationWizard", WaitFor:9) then
#wait 1
typetext altkey, f
end if*)
//press pagedown to go to latest appointment
#wait 1
typetext pagedown
//check in the patient
wait 3
Click (Image:"a04/CheckIn", WaitFor:7)
#wait 2 The waitfor in the click already has an included wait.
//add a visitor's account
//click Enc Guar and Cvgs
Click (Image:"a04/EncGuarCvgs", WaitFor:4)
#wait 1
//select the visit guarantor
Click (Image:"a04/VisitGuarantor", WaitFor:4)
//add lanuage, ethnicity and race
wait 2
//click on demographics
Click {text:"demographics", WaitFor:4}
wait 4
typetext pagedown, pagedown // validate that the content is visible . in the future it might be 2 pagedown
#wait 1
//click on preferred language and enter a value
Click (Image:"a04/PreferredLanguage", WaitFor:4)
#wait 1
typetext "17", tabkey
#wait 1
//tab to ethnicity and enter a value
typetext tabkey, tabkey, tabkey, tabkey # .... Use text or images to identify the fields you'd like to click and fill. You can use the hostspot to click at another location in respect to the found center location
#wait 1
typetext "2", tabkey
//tab to race and enter a value
#wait 1
typetext tabkey, tabkey
#wait 1
typetext "1002", tabkey
//click check in again
wait 2
Click {Image:"a04/CheckIn1", WaitFor:5}
//click ask later
wait 2
if ImageFound(text:"Ask Later", waitFor:7) then
Typetext altkey, L
# Alternative in case the text "ask later " is clickable
# click foundimagelocation() # this contains the last image search location, In this case the one from the imagefound within the if statement
end if
//click continue anyway
wait 2
Click {Image:"a04/ContinueAnyway", WaitFor:3}
//put mrn into variable
waitfor 7, text: "Mytest" #Wait 7
typetext altkey, "f"
put readtext("a13/MRN_a_TL", "a13/MRN_a_BR") into CreatedMRN
log createdMRN
//verify if patient shows arrived
if ImageFound(imageName:"a04/arrived", waitFor:7) then
logsuccess "Patient is checked in and the appointment desk screen is displayed."
else
logerror "Patient is not checked in and the appointment desk screen is displayed."
end if
//click close epic
closeepic // assume this is another handler you haven't shared
//returning MRN
return createdMRN # Why do you return it at the end of the script you do log it already?
Thank you Karsten for the review. Appreciate it, very helpful!