I am trying to create a simple menu by radio button that allows for only one selection, which then would open up the appropriate form. I can get that part to work, but I am having issues trying to figure out how to remove the form and add another form if that particular button is no longer selected, and/or another button is selected. This is what I have so far, which will add the form but only after I click it twice. I need to know how to add and remove the form if something changes.
{
if DOCUMENT.PROCEDURE==ESI then
ADD_FORM_COMP("Enterprise\Testing\Prior Auth","ESI Prior Auth")
else
""
endif
}
It might just be that you don't have quotes around ESI???
This is what I use for loading multiple forms for my chemotherapy forms. The code is placed in the first form and could add up to 3 more forms based on a global variable, but you could base it on a form field. The DOCUMENT.FORM_? fields are hidden fields that just keep track of which forms have been added.
{/* load forms based on periods in protocol */}
{if gblPeriod2=="" then
if DOCUMENT.FORM_2<>"" then
REMOVE_FORM_COMP("Oncology Chemo Orders 2 PP")
REMOVE_FORM_COMP("Oncology Chemo Orders 2 TS")
DOCUMENT.FORM_2 = ""
endif
else
if DOCUMENT.FORM_2=="" then
AddOpenForm("Enterprise\Hematology&Oncology^Oncology Chemo Orders 2 TS", "Oncology Chemo Orders 1 TS", "AFTER_CURRENT", "")
AddOpenForm("Enterprise\Hematology&Oncology^Oncology Chemo Orders 2 PP", "Oncology Chemo Orders 1 TS", "AFTER_CURRENT", "")
DOCUMENT.FORM_2 = "added"
endif
endif}
{if gblPeriod3=="" then
if DOCUMENT.FORM_3<>"" then
REMOVE_FORM_COMP("Oncology Chemo Orders 3 PP")
REMOVE_FORM_COMP("Oncology Chemo Orders 3 TS")
DOCUMENT.FORM_3 = ""
endif
else
if DOCUMENT.FORM_3=="" then
if DOCUMENT.FORM_2<>"" then
REMOVE_FORM_COMP("Oncology Chemo Orders 2 PP")
REMOVE_FORM_COMP("Oncology Chemo Orders 2 TS")
endif
AddOpenForm("Enterprise\Hematology&Oncology^Oncology Chemo Orders 3 TS", "Oncology Chemo Orders 1 TS", "AFTER_CURRENT", "")
AddOpenForm("Enterprise\Hematology&Oncology^Oncology Chemo Orders 3 PP", "Oncology Chemo Orders 1 TS", "AFTER_CURRENT", "")
DOCUMENT.FORM_3 = "added"
AddOpenForm("Enterprise\Hematology&Oncology^Oncology Chemo Orders 2 TS", "Oncology Chemo Orders 1 TS", "AFTER_CURRENT", "")
AddOpenForm("Enterprise\Hematology&Oncology^Oncology Chemo Orders 2 PP", "Oncology Chemo Orders 1 TS", "AFTER_CURRENT", "")
DOCUMENT.FORM_2 = "added"
endif
endif}
{if gblPeriod4=="" then
if DOCUMENT.FORM_4<>"" then
REMOVE_FORM_COMP("Oncology Chemo Orders 4 PP")
REMOVE_FORM_COMP("Oncology Chemo Orders 4 TS")
DOCUMENT.FORM_4 = ""
endif
else
if DOCUMENT.FORM_4=="" then
if DOCUMENT.FORM_2<>"" then
REMOVE_FORM_COMP("Oncology Chemo Orders 2 PP")
REMOVE_FORM_COMP("Oncology Chemo Orders 2 TS")
endif
if DOCUMENT.FORM_3<>"" then
REMOVE_FORM_COMP("Oncology Chemo Orders 3 PP")
REMOVE_FORM_COMP("Oncology Chemo Orders 3 TS")
endif
AddOpenForm("Enterprise\Hematology&Oncology^Oncology Chemo Orders 4 TS", "Oncology Chemo Orders 1 TS", "AFTER_CURRENT", "")
AddOpenForm("Enterprise\Hematology&Oncology^Oncology Chemo Orders 4 PP", "Oncology Chemo Orders 1 TS", "AFTER_CURRENT", "")
DOCUMENT.FORM_4 = "added"
AddOpenForm("Enterprise\Hematology&Oncology^Oncology Chemo Orders 3 TS", "Oncology Chemo Orders 1 TS", "AFTER_CURRENT", "")
AddOpenForm("Enterprise\Hematology&Oncology^Oncology Chemo Orders 3 PP", "Oncology Chemo Orders 1 TS", "AFTER_CURRENT", "")
DOCUMENT.FORM_3 = "added"
AddOpenForm("Enterprise\Hematology&Oncology^Oncology Chemo Orders 2 TS", "Oncology Chemo Orders 1 TS", "AFTER_CURRENT", "")
AddOpenForm("Enterprise\Hematology&Oncology^Oncology Chemo Orders 2 PP", "Oncology Chemo Orders 1 TS", "AFTER_CURRENT", "")
DOCUMENT.FORM_2 = "added"
endif
endif}
{!fn AddOpenForm(newform, oldform, position, addopen)
/* newform = form to add (path^form)
oldform = form to which newform's position will be based
position = "AT_BEGINNING", "BEFORE_CURRENT", "AFTER_CURRENT", "AT_END"
addopen = "", "OPEN" */
{
local newlist
local formpath
local formname
local forms
local numforms
local count = 1
local loaded = 0
local locoldform = 0
local insertpos
/* get path and name of newform */
newlist = GETFIELD(newform, "^", "")
formpath = newlist[1]
formname = newlist[2]
/* get forms loaded for current update */
forms = GETFIELD(GET_FORM_LIST(), "|", "")
/* check if newform is already loaded */
numforms = SIZE(forms)
while count<=numforms
and loaded==0 do
if MATCH(TOUPPER(forms[count]), TOUPPER(newform))>0 then
loaded = count
endif
count = count + 1
endwhile
if loaded<>0 then
/* newform already loaded */
if addopen=="OPEN" then
/* open form */
OPEN_FORM_COMP(formpath + formname)
endif
else
/* new form not loaded, proceed with loading */
/* find position of oldform */
count = 1
while count<=numforms
and locoldform==0 do
if MATCH(TOUPPER(forms[count]), TOUPPER(oldform))>0 then
locoldform = count
endif
count = count + 1
endwhile
/* determine where to add newform in relation to oldform */
cond
case locoldform==0
insertpos = numforms + 1
case TOUPPER(position)=="AFTER_CURRENT"
insertpos = locoldform + 1
case TOUPPER(position)=="AT_END"
insertpos = numforms + 1
case TOUPPER(position)=="BEFORE_CURRENT"
insertpos = locoldform
case TOUPPER(position)=="AT_BEGINNING"
insertpos = 1
else
insertpos = numforms + 1
endcond
/* add newform and open if addopen=="OPEN" */
ADD_FORM_COMP(formpath, formname, STR(insertpos), addopen)
endif
return ""
}
}