Anybody had success using this function. I can't seem to get it to work for me, I'm sure it's something simple. Here's what I have in a button:
{MEL_REMOVE_FHX ("65656005",DOCUMENT.COMMENTS123Z1)}
Any insight would be great. Thanks in advance!
Yes, white space functions -
{fn FHX_RemoveContent(which,reason){
local hold = getfield(MEL_LIST_FHX_AFTER("delimited", "active"), "|", "")
local temp
for i = 1, i <= size(hold), i = i + 1 do
temp = getfield(hold[i], "^", "")
if match(which,temp[5])>0 and match(which,temp[3])>0 and match(which,temp[11])>0 then
FHx_Remove_Error(MEL_REMOVE_FHX(temp[1],reason))
ClearFHXRemove()
return ""
endif
endfor
return userok("FHX not found\r\nFailed to update")
}
}
{fn FHx_Remove_Error(add){
if (add >= 0) then
return ""
endif
cond
case (add == "-1") userok("FHX ID contains invalid numeric value, the value is empty or too long")
case (add == "-2") userok("Removal reason too long or empty")
case (add == "-3") userok("Cannot acquire clinical list lock")
case (add == "-4") userok("Cannot remove FHX due to unknown reason")
case (add == "-21") userok("Service Layer Error")
else
userok("Unknown Error")
endcond
}}
{!fn fnDisplayFamHx(rtntype,firekey) {
local hold = getfield(MEL_LIST_FHX_AFTER("delimited", "active"), "|", "")
local temp
local 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[5] + ": " + temp[3] + (if temp[11] <> "" then " - " else "" endif) + temp[11]
endfor
return rslt
}
}
Action button -
FHX_RemoveContent(document.FHX_EDIT,document.FHX_REMREAS)
document.currFHXList = fnDisplayFamHx(",",MEL_LIST_FHX_AFTER())
RefreshFHX()
Then i have a single selection list box with dynamic list document.currFHXList, variable named document.FHX_EDIT, and a removal reason dropdown variable named document.FHX_REMREAS. The refresh function just jumps to a different tab and jumps back, since the screen will not refresh without it, its optional and will depend on your form setup. Works like a charm
Wow! Thank you. That was pretty painless to put in. Thank you for sharing that.
What order do you have your variables in that make the most since: button, listbox, dropdown?
I notice that the button has to be click to pull the FHx in right? Or I may have messed something up putting it into VFE.
I put two sections next to each other, the list box in the one to the left and the dropdown with the button under it in the one on the right.
I probably have a line like below somewhere in the white space to get it to load initially. If I remember correctly, the line also needs to be in the action button because MEL_LIST_FHX_AFTER() doesn't actually force the statement to evaluate like you would think it should.
{!document.currFHXList = fnDisplayFamHx(“,”,MEL_LIST_FHX_AFTER())}
Do you also use MEL_ADD_FHX in a similar way. I recently had another user help me with this and some me the structure within a button. So currently I have a button per FHx history. Only thing with this is I can see a form down the road with 100+ buttons.
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.
Wow amazing! You think this could work by reading off a text component in centricity? We have ran into permission issues on thin clients looking out into the server and reading a file.