I would like to build a dynamic drop down list that I can train a staff member to modify without giving them access to VFE. Preferably a text file they have access to. Any thoughts? I tried using the below code but struck out. Any other thoughts?
Basically, sometimes we have to change medications and the medication isn't listed in our existing drop down menu for our injection administration form or maybe an NDC update or LOT number update... it would be nice to be able to update them when they come in or just add to the existing list.
{
local fname = "c:/temp/data.txt"
local fhnd = FILEOPEN(fname, "r")
if fhnd NULL then
text = FILEREAD(fhnd)
FILECLOSE(fhnd)
endif
}
We are doing this in our clinic for a department called MSS. I have saved several text files in a folder that is in the same place as our CCC content, so that I can push it out to our terminal servers in the same way I push CCC updates.
here is the code that gets the file and reads the comma separated list inside. The listName argument tells it which file out of the 4 to grab:
{fn getMSSList(listName){
retList = ""
//this filepath can point anywhere, but we are saving the list in our EMR Client folder
fpath = DIR_EMR() + "/MSS/" + listName + ".txt"
fhnd = FILEOPEN(fpath,"r")
if (fhnd <> "") then
retList = FILEREAD(fhnd)
endif
FILECLOSE(fhnd)
return retList
}}
It basically does the same as your code, but my function is returning the data from a function.
The dropdown list then simply runs this code:
getMSSList("RN")
and it will display all my RNs names in the dropdown list.
Let me know if you have any questions on how this works.
Thanks,
Daniel C.
I use basically that exact code to allow all users to customize their own options, if using a small amount of data it works pretty well. As long as the file exists and has one line of text that should work as is, put a '!' inside the opening bracket and add userok(text) after the FILEREAD and see if it gets the result, it should. If you have more than one row in the file then you would need to use a while loop.
If you are doing more of a managed approach you could allow a few users to update a text file containing MEL code, and load it every form open using {load(path)}. I use that for more of clinic defaults, it requires less setup but better superusers.
For the case you mentioned though, if you are using this for administered medications you should use the MEL_GET_CONTENT() which loads administered medication data from the custom list. Then the users can maintain the custom list and changes are automatically reflected in the form.
I use editable text files extensively. The files are on a shared directory. I have also created a system within forms to allow user editing of text files. This particular application was used in an echocardiogram program to allow users to edit text components. Contact me directly.
thanks everyone, still can't get it to work and its giving me this error in the MEL trace
{!gDYNAMIC_5772152596013828619 = (
fname = "c:/CPS-files/data.txt"
fhnd = FILEOPEN(fname, "r")
if fhnd "" then
text = FILEREAD(fhnd)
FILECLOSE(fhnd)
endif
}
COMPILER ERROR NEARBY: Expect RIGHT PAREN. Instead had IDENTIFIER after STRING
I don't understand where its getting that error from.