Does anyone know how I'd build a data display that would pull in all immunizations given today? (This is for a Clinical Summary form I am developing.)
I had originally tried this in the data display but it's too large (for space reasons, I'm not pasting the entire thing):
{if OBSNOW("HepBvax#1")<>"" then "Hep B Vaccine #1 given \n\r" else "" endif}{if OBSNOW("HepBvax#2")<>"" then "Hep B Vaccine #2 given \n\r" else "" endif}{if OBSNOW("HepBvax#3")<>"" then "Hep B Vaccine #3 given \n\r" else "" endif}{if OBSNOW("HepBvax#4")<>"" then "Hep B Vaccine #4 given \n\r" else "" endif}{if OBSNOW("HepBvax#5")<>"" then "Hep B Vaccine #5 given \n\r" else "" endif}{if OBSNOW("HepBvax#6")<>"" then "Hep B Vaccine #6 given \n\r" else "" endif}
Then I tried putting it in the side as a function:
{fn getimmz()
{if OBSNOW("HepBvax#1")<>"" then "Hep B Vaccine #1 given \n\r" else "" endif
if OBSNOW("HepBvax#2")<>"" then "Hep B Vaccine #2 given \n\r" else "" endif
if OBSNOW("HepBvax#3")<>"" then "Hep B Vaccine #3 given \n\r" else "" endif
if OBSNOW("HepBvax#4")<>"" then "Hep B Vaccine #4 given \n\r" else "" endif
if OBSNOW("HepBvax#5")<>"" then "Hep B Vaccine #5 given \n\r" else "" endif
if OBSNOW("HepBvax#6")<>"" then "Hep B Vaccine #6 given \n\r" else "" endif}}
and calling it with {fn getimmz()} but this isn't working either...
Any ideas? There are 58 different immunizations that I'm pulling in...
Thanks!
Amy
I would try using GET_FLOWSHEET_VALUES() if you have them built into a flowsheet view
call CombineImmuns() from your data display. this routine lists all immunizations chronologically.
to get just for the current update, change 'Pencil' to 'Update' in the FillArraysWithObs function.
{fn CombineImmuns()
{
local Types = array("HepBvax#1", "HepBvax#2") // add all obsterms you want to list
return CombineImmunizations(Types, 0) // 0 - list all, 1 - list only last, 2 - list last 2, etc.
}
}
{fn CombineImmunizations(Types, Last)
{
local aTypes = array("")
local aVals = array("")
local aDates = array("")
local aDatesConverted = array("")
local arraysize = size(Types)
local result
local index
local index2
local temp
local count
for index = 1, index <= arraysize, index = index + 1 do
FillArraysWithObs(Types[index], aTypes, aVals, aDates, aDatesConverted)
endfor
arraysize = size(aTypes) - 1
for index = 1, index < arraysize, index = index + 1 do
for index2 = 1, index2 <= arraysize - index, index2 = index2 + 1 do
if aDatesConverted[index2]>aDatesConverted[index2 + 1] then
temp = aTypes[index2]
aTypes[index2] = aTypes[index2 + 1]
aTypes[index2 + 1] = temp
temp = str(aVals[index2])
aVals[index2] = aVals[index2 + 1]
aVals[index2 + 1] = temp
temp = str(aDates[index2])
aDates[index2] = aDates[index2 + 1]
aDates[index2 + 1] = temp
temp = str(aDatesConverted[index2])
aDatesConverted[index2] = aDatesConverted[index2 + 1]
aDatesConverted[index2 + 1] = temp
endif
endfor
endfor
result = ""
count = 0
for index = 1, index <= arraysize, index = index + 1 do
if (Last == 0)
or (index > (arraysize - Last)) then
count = count + 1
if result<>"" then
result = result + hret
endif
result = result + count + " " + aDates[index] + " " + aVals[index]
endif
endfor
return result
}
}
{fn FillArraysWithObs(ObsTerm, aTypes, aVals, aDates, aDatesConverted)
{
local count
local length
if LIST_OBS(ObsTerm,'Pencil','list','valuedate')<>"" then
local obs_array1 = getfield(LIST_OBS(ObsTerm,'Pencil','list','valuedate'), hret, "")
length = size(obs_array1)
for count = 1, count <= length, count = count + 1 do
if size(obs_array1[count])>0
and match(obs_array1[count], 1, "(")>0 then
local obs_array2 = getfield(obs_array1[count], "(", "")
if size(obs_array2)>2 then
obs_array2[1] = obs_array2[1] + "(" + obs_array2[2]
obs_array2[2] = obs_array2[3]
endif
insert(aTypes, 1, ObsTerm)
insert(aVals, 1, trim(obs_array2[1]))
insert(aDates, 1, sub(obs_array2[2], 1, 10))
insert(aDatesConverted, 1, ConvertDate(obs_array2[2]))
endif
endfor
endif
}
}
{fn Trim(string)
{
local result = string
local dowhile = true
local sizeresult
while dowhile do
if size(result)==0 then
dowhile = false
else
if result[1]<>" " then
dowhile = false
else
result = remove(result, 1, 1)
endif
endif
endwhile
dowhile = true
sizeresult = size(result)
while dowhile do
if sizeresult==0 then
dowhile = false
else
if result[sizeresult]<>" " then
dowhile = false
else
result = remove(result, sizeresult, 1)
sizeresult = size(result)
endif
endif
endwhile
return result
}
}
{fn ConvertDate(date)
{
local newdate
newdate = sub(date, 7, 4)
newdate = newdate + "" + sub(date, 1, 2)
newdate = newdate + "" + sub(date, 4, 2)
return newdate
}
}
Hi jjordet,
I altered the function as below, but the data display is empty. Do you see anything I botched or missed from your directions? I'm calling it with {fn CombineImmuns()}.
{fn CombineImmuns()
{
local Types = array("HepBvax#1", "HepBvax#2", "HepBvax#3", "HepBvax#4", "HepBvax#5", "HepBvax#6", "rotavir#1", "rotavir#2", "rotavir#3", "DPT #1", "DPT #2", "DPT #3", "DPT #4", "DPT #5", "Td booster", "HemInfB#1", "HemInfB#2", "HemInfB#3", "HemInfB#4", "pneuped#1", "pneuped#2", "pneuped#3", "pneuped#4", "pneumovax", "IPV #1", "IPV #2", "IPV #3", "IPV #4", "IPV #5", "MMR #1", "MMR #2", "MMR #3", "Varicella#1", "Varicella#2", "Varicella#3", "HepAvax #1", "HepAvax #2", "HepAvax #3", "HepAvax #4", "HepAvax #5", "HPV VAX #1", "HPV #2", "HPV #3", "Meningoc vax", "BUN", "ZOSTAVAX", "Flu vax", "TB-PPD", "Rabies vax", "Rab vax#2", "Rab vax#3", "Rab vax#4", "BUN", "Typhoid vax", "Yellow f vac", "Jap Encep", "JapEnce#2", "JapEnce#3")
return CombineImmunizations(Types, 1)
}
}
{fn CombineImmunizations(Types, Last)
{
local aTypes = array("")
local aVals = array("")
local aDates = array("")
local aDatesConverted = array("")
local arraysize = size(Types)
local result
local index
local index2
local temp
local count
for index = 1, index <= arraysize, index = index + 1 do
FillArraysWithObs(Types[index], aTypes, aVals, aDates, aDatesConverted)
endfor
arraysize = size(aTypes) - 1
for index = 1, index < arraysize, index = index + 1 do
for index2 = 1, index2 <= arraysize - index, index2 = index2 + 1 do
if aDatesConverted[index2]>aDatesConverted[index2 + 1] then
temp = aTypes[index2]
aTypes[index2] = aTypes[index2 + 1]
aTypes[index2 + 1] = temp
temp = str(aVals[index2])
aVals[index2] = aVals[index2 + 1]
aVals[index2 + 1] = temp
temp = str(aDates[index2])
aDates[index2] = aDates[index2 + 1]
aDates[index2 + 1] = temp
temp = str(aDatesConverted[index2])
aDatesConverted[index2] = aDatesConverted[index2 + 1]
aDatesConverted[index2 + 1] = temp
endif
endfor
endfor
result = ""
count = 0
for index = 1, index <= arraysize, index = index + 1 do
if (Last == 0)
or (index > (arraysize - Last)) then
count = count + 1
if result<>"" then
result = result + hret
endif
result = result + count + " " + aDates[index] + " " + aVals[index]
endif
endfor
return result
}
}
{fn FillArraysWithObs(ObsTerm, aTypes, aVals, aDates, aDatesConverted)
{
local count
local length
if LIST_OBS(ObsTerm,'Update','list','valuedate')<>"" then
local obs_array1 = getfield(LIST_OBS(ObsTerm,'Update','list','valuedate'), hret, "")
length = size(obs_array1)
for count = 1, count <= length, count = count + 1 do
if size(obs_array1[count])>0
and match(obs_array1[count], 1, "(")>0 then
local obs_array2 = getfield(obs_array1[count], "(", "")
if size(obs_array2)>2 then
obs_array2[1] = obs_array2[1] + "(" + obs_array2[2]
obs_array2[2] = obs_array2[3]
endif
insert(aTypes, 1, ObsTerm)
insert(aVals, 1, trim(obs_array2[1]))
insert(aDates, 1, sub(obs_array2[2], 1, 10))
insert(aDatesConverted, 1, ConvertDate(obs_array2[2]))
endif
endfor
endif
}
}
{fn Trim(string)
{
local result = string
local dowhile = true
local sizeresult
while dowhile do
if size(result)==0 then
dowhile = false
else
if result[1]<>" " then
dowhile = false
else
result = remove(result, 1, 1)
endif
endif
endwhile
dowhile = true
sizeresult = size(result)
while dowhile do
if sizeresult==0 then
dowhile = false
else
if result[sizeresult]<>" " then
dowhile = false
else
result = remove(result, sizeresult, 1)
sizeresult = size(result)
endif
endif
endwhile
return result
}
}
{fn ConvertDate(date)
{
local newdate
newdate = sub(date, 7, 4)
newdate = newdate + "" + sub(date, 1, 2)
newdate = newdate + "" + sub(date, 4, 2)
return newdate
}
}
remove the fn from the function call. You're only going to get 1 immunization...return CombineImmunizations(Types, 1), not 1 of each...change back to 0, the 'Update' will get you what's given in the current update.
I cannot thank you enough. That worked perfectly!
I created the code for an immun review form/handout so we could show last 3 of one immun and last 2 of another and so on.
{fn CombineHeps()
{
local Types = array("HepBvax#1", "HepBvax#2", "HepBvax#3", "HepBvax#4", "HepBvax#5", "HepBvax#6"return CombineImmunizations(Types, 3)
}
}
{fn CombineRotas()
{
local Types = array("rotavir#1", "rotavir#2", "rotavir#3")
return CombineImmunizations(Types, 2)
}
}
but would want 'Pencil' to get past and present.
Is there a way to only get the flowsheet values from today? I like this method