Similar yes, the major difference is that it looks up snomed codes in a file system, I thought it would be easier to build and maintain than trying to keep it all in a form -
White space
{fn Add_Fhx(member,prob,comm,unkn,nkr){
local tmp = getfield(MEL_RELATIVES_FHX(),"|","")
local temp
local hold = getfield(member,",","")
local sno = array()
local probset = getfield(prob,",","")
local path = "//cpssql/UserLib/SnomedCT_Release_US1000124_20140301/EMR Snomed Files"
local fhnd
cond
case(unkn <> "")
MEL_ADD_FHX("No Known Family History", "22", "407559004", comm)
return ""
case (nkr <> "")
MEL_ADD_FHX("No Known Relative", "22", "224089000", comm)
return ""
endcond
//replace member names with family codes
for i = 1, i <= size(hold), i = i + 1 do
for j = 1, j <=size(tmp), j = j + 1 do
temp = getfield(tmp[j],"^","")
//from utility
if (temp[2] == nobeginspace(hold[i])) then
set(hold,i,temp[1])
endif
endfor
endfor
for i = 1, i <=size(probset), i = i + 1 do
fhnd = FILEOPEN(path + "/" + nobeginspace(replacestr(probset[i],"/","_")) + ".txt","r")
if (fhnd <> "") then
insert(sno,i,FILEREAD(fhnd))
FILECLOSE(fhnd)
else
insert(sno,i,"")
endif
set(probset,i,nobeginspace(replacestr(probset[i],"FH:","Family history of")))
endfor
//Add codes
for i = 1, i <=size(hold), i = i + 1 do
for j = 1, j <= size(probset), j = j + 1 do
FHx_Add_Error(MEL_ADD_FHX(probset[j],hold[i],sno[j],comm))
endfor
endfor
ClearFHXFields()
return ""
}}
{fn FHx_Add_Error(add){
if (add >= 0) then
return ""
endif
cond
case (add == "-1") userok("Description is blank or too long")
case (add == "-2") userok("Relationship ID is invalid empty, or too long")
case (add == "-3") userok("Invalid code or code is too long")
case (add == "-4") userok("Comment is too long")
case (add == "-5") userok("Cannot get clinical list lock")
case (add == "-6") userok("Cannot add FHX for some other reason")
case (add == "-21") userok("Service Layer Error")
else
userok("Unknown Error")
endcond
}}
{!fn List_Fhx_Rel(){
local hold = getfield(MEL_RELATIVES_FHX(),"|","")
local tmp
local rslt = array()
local j = 1
for i = 1, i <=size(hold), i = i + 1 do
tmp = getfield(hold[i],"^","")
if val(tmp[3])<3 then
insert(rslt,size(rslt) + 1,tmp[2])
endif
endfor
//shift grand parents up
while j <5 do
insert(rslt,5,rslt[12])
remove(rslt,13,1)
j = j + 1
endwhile
return str(rslt)
}}
{fn fnCommaCombine(){
local rslt = ""
for i = 1, i <= getnargs(), i = i + 1 do
rslt = fncombineutility(rslt,getarg(i))
endfor
return rslt
}}
{fn fnCombineutility(one,two){
if (one <> "") and (two <> "") then
return (one + ", " + two)
else
return (one + two)
endif
}}
Button -
Add_Fhx(document.FAMILY_MEMBE,fncommacombine(DOCUMENT.FM_PROB,DOCUMENT.FM_PROB1),Document.FHXComments,document.NKFHX,document.nkr)
document.currFHXList = fnDisplayFamHx(",",MEL_LIST_FHX_AFTER())
RefreshFHX()
Problems are in the listboxes FM_PROB and FM_PROB1, Comments is an edit field, FAMILY_MEMBE is a listbox (you can do multiple additions at one time) NKFHX and NKR are check boxes for no known relative and no known family history.
The path variable is just a spot on the server that I use to store these files. An example of a file is a text file named "High Cholesterol.txt" the content of the file is just the snomed code '160314003' Pretty easy to set up and it avoids a long condition statement or array to look it up, just a preference I guess.