Chris,
sorry for the delayed response. Apparently my CHUG notifications were going to my junk folder. I understand what you are trying to do now. My initial thought is to define an array of all 84 obs terms first and then pass each array value. This method will be more efficient and easier to maintain should you need to add or remove obsterms from the list of allergy terms you are checking. You will just have to test it with all 84 terms to see how quickly it will run, but you can start by adding just 10 terms to the array, and then continue to build this list as you go. You will find this approach a whole lot easier to maintain and troubleshoot because you won't have to replicate an "if then endif" statement for every single obsterm. Keep in mind you are storing the name of the OBS term in the array and not the value itself. The function evalTerm() is what is actually pulling the value of the OBS term and checking it against a threshold to see whether or not to add it to the positive or negative list. To handle the heading text (e.g. Percutaneous tests positive to:) for each section, I would create two document variables (e.g. POSALLERGY and NEGALLERGY and hide them on your form using a visibility group) to store the results of the positive and negative values; and then set the pretext value of each document variable with the appropriate text and formatting you need. You will need a button or a watcher expression to call the function below to initiate the text translation function (i.e. evalTerm()). The code below assumes the same allergy obs terms are used for your positive and negative lists; if not, you can just create separate functions for each test. Hope that makes sense.
//Define your list of allergy OBS terms
global allergyTerms = array("ALLERGY1","ALLERGY2,"ALLERGY3",.....,"ALLERGY84")
//function to generate list of positive and negative tests
{fn evalTerm()
{
local numTerms = size(allergyTerms)
local i
for i=1, i <= numTerms, i=i+1
do
//positive allergy string construction
if (val(OBSNOW(allergyTerms[i])) > 3) then
if (DOCUMENT.POSALLERGY <> "") then
DOCUMENT.POSALLERGY = DOCUMENT.POSALLERGY + ', ' + allergyTerms[i]
else
DOCUMENT.POSALLERGY = allergyTerms[i]
endif
else
endif
//negative allergy string construction
if ((val(OBSNOW(allergyTerms[i])) < 3) AND (OBSNOW(allergyTerms[i]) <> UNDEFINED)) then
if (DOCUMENT.NEGALLERGY <> "") then
DOCUMENT.NEGALLERGY = DOCUMENT.NEGLLERGY + ', ' + allergyTerms[i]
else
DOCUMENT.NEGALLERGY = allergyTerms[i]
endif
else
endif
endfor
}
}
Posted : March 26, 2018 1:03 am