These functions will get you a list of names based on the document's location of care and the security roles. In this example it would provide users with the roles of Physician and Resident whose home locations were the same as the documents. ii_get_provs() would be what you call
/* Sets document Location of care abbrev name */
{!fn outGetLOCAbbrevName(locFullName)
{
local lCounter = 0
local lResult = ""
local lValue = ""
local LOCAbbrevName = "Not Found"
local lNumLOCs = getRowCount("ActiveLOCs")
for lCounter = 0, lCounter < lNumLOCs, lCounter = lCounter + 1 do
lValue = getRow("ActiveLOCs", lCounter, "LOCID", "searchName", "Name", "abbrevName")
if lValue[3] == locFullName then
LOCAbbrevName = lValue[4]
break
else
""
endif
endfor
return LOCAbbrevName
}
}
/* Provider (Ordered by) drop down function based on document location of care */
{!fn ii_get_provs(){
local uname
local result = ""
local final_result = ""
local formatted_list = ""
local alpha_list = ""
local count = ""
/* Get the delimited user list using the location abbreviation */
local user_list = getfield(get_user_list(outGetLOCAbbrevName(DOCUMENT.LOCOFCARENAME), "Physician,Resident", "delimited"), "|", "")
for count = 1, count <= size(user_list), count = count + 1
do uname = getfield(user_list[count], "^", "")
if result <> "" then
result = result + "|" + uname[2]
else
result = uname[2]
endif
endfor
/* Strip out any commas in user names */
if result <> "" then
final_result = replacestr(result, ",", "")
else
""
endif
/* Put commas back in where pipes were for the drop down */
if final_result <> "" then
formatted_list = "," + replacestr(final_result, "|", ",")
else
""
endif
alpha_list = str(sort(getfield(formatted_list, ",", ""), TRUE))
return alpha_list
}
}
You posted this a long time ago, but it was incredibly helpful to me. Where did you find documentation for the functions getrow and getrowcount? They are not in the help file in CEMR 9.8. Thanks for posting this.
I don't think David is active on this forum anymore, I can try to help you. The short answer is that there is no documentation. Those two functions are used to extract data from the objects found in the mldefs.txt files in the client folder (or EMR directory, it may be different in EMR 9.8). The GETROWCOUNT() function you pass an object as the onyl parameter and it will return the number of rows currently in the object as a number. Typically when using these you will use a for loop like this
for i = 1, i<=getrowcount("_MasterMed"), i = i + 1 do
This example will let you loop through each row in the patients medication history. While you are in the loop, you would want to get some info from each row, that is when you use getrow(). Getrow uses three or more parameters, the first is the object (in our example "_MasterMed") the second is the row index (in our example, the variable i) and the rest are the names of the fields you want to return. Getrow returns an array with the requested fields.
temp = getrow("_MasterMed",i,"Description","Instructions")
In this example temp[1] return the description of the medication in the first row of the object, temp[2] returns the instructions.
A few other notes, some objects are 0 based, most are 1 based. I don't know why, some just are. You would have to run traces to figure it out. If you get an invalid row then GETROW() will just return NULL. Also, be careful with large objects, a lot of calls to getrow() can be very slow. If you need any more help feel free to reach out to me, my email is in my profile.