I've been working on a form to help chart prep. In one of the sections i am pulling immunizations and recently it has stopped working. Below is the code I'm using. If anyone has been more successful in pulling a list of immunizations into a letter please let me know and thank you.
{ procs = ""
immunList = IMMUN_GETLIST()
immunListArray = getfield(immunList,"|","|")
if size(immunListArray) > 0 then
for i=1, i<=size(immunListArray), i=i+1 do
immunComponents = getfield(immunListArray[i],"^","")
global pos = match(immunComponents[30], 5, " ")
global tmpstr = ", Not Given - "
if immunComponents[8] == "" then
tmpstr = ", Not Given"
endif
if immunComponents[6] > 0 then
if immunComponents[7] == "N" then
if pos > 0 then
procs = procs + toupper(immunComponents[3]) + ", Series " + immunComponents[6] + tmpstr + immunComponents[8] + ", " + sub(immunComponents[30], 1, pos-1) + "\r\n"
else
procs = procs + toupper(immunComponents[3]) + ", Series " + immunComponents[6] + tmpstr + immunComponents[8] + ", " + immunComponents[30] + "\r\n"
endif
else
if pos > 0 then
procs = procs + toupper(immunComponents[3]) + ", Series " + immunComponents[6] + ", " + sub(immunComponents[30], 1, pos-1) + "\r\n"
else
procs = procs + toupper(immunComponents[3]) + ", Series " + immunComponents[6] + ", " + immunComponents[30] + "\r\n"
endif
endif
else
if immunComponents[7] == "N" then
if pos > 0 then
procs = procs + toupper(immunComponents[3]) + tmpstr + immunComponents[8] + ", " + sub(immunComponents[30], 1, pos-1) + "\r\n"
else
procs = procs + toupper(immunComponents[3]) + tmpstr + immunComponents[8] + ", " + immunComponents[30] + "\r\n"
endif
else
if pos > 0 then
procs = procs + toupper(immunComponents[3]) + ", " + sub(immunComponents[30], 1, pos-1) + "\r\n"
else
procs = procs + toupper(immunComponents[3]) + ", " + immunComponents[30] + "\r\n"
endif
endif
endif
endfor
immunListArray2 = getfield(procs,"\r\n","\r\n")
sort(immunListArray2, TRUE)
procs = ""
for i=1, i<=size(immunListArray2), i=i+1 do
procs = procs + immunListArray2[i] + "\r\n"
endfor
procs
else
procs = ""
global obsstr =
GET_FLOWSHEET_VALUES_PRIOR('Enterprise\Printing\Chart_Summary\Immunizations')
if size(obsstr) > 0 then
procs = "(Immunizations from observation terms) \r\n"
procs = procs + obsstr
endif
procs
endif }
I have something built into one of my VFE form to display all immunizations. The area calls a function. It is only displaying fields 3, 4 and 30 that are returned from the function. Perhaps this will help you see a different approach.
(Sorry, do not have time to digest the sample coding you provided.)
{!fn fnTextTransImmunHx() {
local hold = getfield(IMMUN_GETLIST("", "all"), "|", "")
local temp
global rslt = ""
for i = 1, i <= size(hold), i = i + 1 do
temp = getfield(hold[i], "^", "")
if (rslt <> "") then
rslt = rslt + rtntype
endif
rslt = rslt + temp[3] + if temp[4] <> "" then " - " else "" endif + temp[4] + " on " + temp[30] + HRET
endfor
return rslt
}}
Actually, played with it a bit so that the following I made into a quicktext .immlist and have the following programming:
{local imma, temp
global rslt = ""
imma = getfield(IMMUN_GETLIST("", "all"), "|", "")
rslt = rslt + "Immunization Listing " + size(imma) + " entries" + HRET
for i = 1, i <= size(imma), i = i + 1 do
temp = getfield(imma[i], "^", "")
rslt = rslt + temp[3] + if temp[4] <> "" then " - " else "" endif + temp[4] + " on " + temp[30] + HRET
endfor
rslt
}
creating:
Immunization Listing 19 entries
Pneumococcal PPSV23 - PNEUMOVAX on 6/19/2014 11:25 AM
Pneumococcal PPSV23 - PNEUMOVAX on 9/29/2014 9:44 AM
Human Papillomavirus - HPV #3 on 6/19/2014 11:25 AM
Influenza - FLU VAX on 6/19/2014 1:08 PM
Influenza - FLU VAX on 8/20/2014 12:25 PM
Influenza - FLU VAX on 9/29/2014 9:44 AM
DTaP - Diphtheria-Tetanus Toxoids DT Intramuscular Suspension 25-5 LFU/0.5ML on 6/16/2015 12:14 PM
BCG - BCG Vaccine Injection Injectable on 6/9/2005 12:00 AM
Human Papillomavirus - Gardasil Intramuscular Suspension on 6/16/2015 1:45 PM
Influenza - Flu Vax on 12/25/2015 12:00 AM
Influenza - Flu Vax on 12/25/2015 12:00 AM
Influenza - Fluzone High-Dose Intramuscular Suspension on 1/26/2016 4:04 PM
DTaP on 2/9/2016 10:33 AM
MMR - Unspecified Formulation on 1/2/2014 12:00 AM
Influenza - Unspecified Formulation on 12/31/2015 12:00 AM
Influenza - Flu Vax on 2/1/2016 12:00 AM
PneumoPCV on 9/2/2019 12:00 AM
Influenza - Flu Vax on 10/13/2019 12:00 AM
Influenza - Afluria Intramuscular Suspension on 11/15/2019 8:49 AM