Is there anyway, either in a form or a text component, to load a new form in the encounter only if there is a new medication that was started in the last 30 days?
I would do something like the following. I generate an array that contains all the patient's prior meds. Each row consists of a med, and each column contains details about the med. See the help topic for MEDS_PRIOR(). Column 1 is the name and column 9 is the onset date.
{
local med_list = MEDS_PRIOR("delimited")
if(med_list<>"")then
med_list = getfield(med_list,"|","")
FOR i=1, i<=size(med_list), i=i+1
DO
med_list[i] = getfield(med_list[i],"^","")
if(
med_list[i][1] == "VITAMIN D3 (ERGOCALCIFEROL) 50000 UNIT CAPS" AND
val(DURATIONDAYS(med_list[i][9],str(._TODAYSDATE)))<=30
)then
//see the help topic for ADD_FORM_COMP()
ADD_FORM_COMP("YOUR FORM HERE")
endif
ENDFOR
endif
}
So, just modify this code and paste it in the function area.
thank you! When I put this in a text component and try to use it when the encounter loads, all I get is "FALSE" in the note??
This code doesn't return anything, which is why it says "FALSE." The code doesn't need to go in an object of any sort. It should just be placed in the function editor (white space on the right) area of any form in the encounter.
Add an exclamation point right before:
!if(med_list<>"")then
This will make the code run as soon as soon as the visit loads. If your med is present in the patient's med list, the form you desire will be added.
I'm sorry to keep going on with all of the questions...
I'd like this to run if ANY med on the active med list has a start date in the last 30, not just a specific med.
I removed
"VITAMIN D3 (ERGOCALCIFEROL) 50000 UNIT CAPS" AND
but that doesn't seem to do the trick...any suggestions?
Thanks for much for your help - if I can get this working, there will be some very happy people:)
No worries, sorry for my misunderstanding. I pasted the following into the function area on random form in an office visit. It loads the form I specify if and only if ANY med has been added in the last 30 days....
{
!if(MEDS_PRIOR("delimited")<>"")then
med_list = getfield(MEDS_PRIOR("delimited"),"|","")
FOR i=1,i<=size(med_list),i=i+1
DO
med_list[i] = getfield(med_list[i],"^","")
if(val(DURATIONDAYS(med_list[i][9],str(._TODAYSDATE)))<=30)then
//You'll need to change this part
ADD_FORM_COMP("Enterprise\Your_folder_here","Your Form Name Here","AT_END")
endif
ENDFOR
endif
}
One more note....you could use MEDS_AFTER in place of MEDS_PRIOR if you want to also add your form if a med is entered today....
I FINALLY got back to this and it works beautifully! Thank you SOOOO much for your help...I don't know what I would do without CHUG.
No problem...