FINAL SOLUTION
After making the last block of code work, my thought was to take those two final array variables, break them apart, and then put those pieces together to put each ICD10 code after their matching diagnosis. While thinking about that, however, I realized that in order to break these variables into arrays, I'd have to add a delimiting mark so the getfield() function knew where to make the split. It had to be something unique, something like a... "~"...
So I started over and tried something that I didn't think was going to work. Inside my outer loop (the first loop that broke up the orders), I made variable arrays out of the diagnoses (temp[6]) and the ICD10 codes (temp[7]). I put those arrays into two variables, allDx and allICD10. Then I started a loop that ran through every element in allDx. I figured that, since allDx and allICD10 were the same size, I could use allDx's for loop to count us through allICD10's for loop and it worked.
I then added an if statement that filtered for orders with multiple diagnoses by looking for "~" and I rebuilt the other text and data that was needed. I also added a count variable that increases on every round of the outer loop. This adds a number to the beginning of each listed order.
If anyone has any questions about this, ever, please feel free to ask. I'm happy to explain further.
{
!fn getOrderPieces() {
local tests = getfield(ORDERS_NEW("delimited",""),"|","")
local count = 0
local temp = ""
local testrslt = ""
local refrslt = ""
local endrslt = ""
local dx = ""
local allDx = ""
local splitDx = ""
local totalDx = ""
local finalDx = ""
local ICD10 = ""
local allICD10 = ""
local splitICD10 = ""
local totalICD10 = ""
local finalICD10 = ""
local i = 1
for i = 1, i 0 then
allDx = getfield(dx, "~", "")
allICD10 = getfield(ICD10, "~", "")
for i = 1, i <= size(allDx), i = i + 1 do
for i = 1, i <= size(allICD10), i = i + 1 do
totalICD10 = totalICD10 + allDx[i] + " (" + allICD10[i] + ")" + HRET
endfor
endfor
testrslt = testrslt + "Order " + count + HRET +
"Order Description: " + HRET + temp[1] + ", " + temp[3] + " on " + temp[4] + HRET + HRET +
"Diagnoses: " + HRET + totalICD10 + HRET +
"Auth Provider: " + HRET + temp[21] + HRET + HRET + HRET
else
testrslt = testrslt + "Order " + count + HRET +
"Order Description: " + HRET + temp[1] + ", " + temp[3] + " on " + temp[4] + HRET + HRET +
"Diagnosis: " + HRET + temp[6] + " (" + temp[7] + ")" + HRET + HRET +
"Auth Provider: " + HRET + temp[21] + HRET + HRET + HRET
endif
endfor
if testrslt "" then
testrslt = testrslt
else
testrslt = "No tests or referrals ordered in this update."
endif
}
}
Posted : May 12, 2017 6:07 am