ok, so I tried to build a function that would take care of multiple cases so I don't have it written out everywhere but when I change everything to (obsterm) instead of say ("Chief Cmplnt") it doesn't work anymore. Here is the function:
fnrecent(obsterm)
{
if DURATIONDAYS(last_signed_obs_date(obsterm),STR(._TODAYSDATE)) <=2 AND OBSNOW(obsterm) == ""
THEN OBSNOW(obsterm,OBSPREV(obsterm))
ELSE ""
ENDIF
}
now if instead of building the function, I just put the obsterm in, it works
{
if DURATIONDAYS(last_signed_obs_date("Chief Cmplnt"),STR(._TODAYSDATE)) <=2 AND OBSNOW("Chief Cmplnt") == ""
THEN OBSNOW("Chief Cmplnt",OBSPREV("Chief Cmplnt"))
ELSE ""
ENDIF
}
thoughts?
Based upon your code, have you actually defined this function with the keyword "fn" then the name of your function? Your function should look like this:
fn fnrecent(obsterm){
if DURATIONDAYS(last_signed_obs_date(obsterm),STR(._TODAYSDATE)) <=2 AND OBSNOW(obsterm) == ""
THEN OBSNOW(obsterm,OBSPREV(obsterm))
ELSE ""
ENDIF
}
then invoke this function by calling it:
fnrecent("CHIEF COMPLNT")
doesn't work... I am so frustrated...
You code looks correct as long as you are calling the function with the observation name in double quotes. Also, observations are usually in all uppercase, at least on my system, and your example is mixed case.
If it is not working still, delete any existing MEL trace file on your PC and turn on mel tracing (CTRL-ALT-M). Trigger the function to run, open the mel trace file and then Seach for the word "error" in it and paste the lines before/after it here.
good call. I did a mel trace after pulling the form apart and found that
>{!fnrecent("InjurySustnd")}
execute>call FNRECENT("InjurySustnd")
>{fn fnrecent(obsterm)\par \{\par if DURATIONDAYS(last_signed_obs_date(OBSTERM),._TODAYSDATE) call LAST_SIGNED_OBS_DATE("InjurySustnd")
results>"07/06/2017"
execute>call DURATIONDAYS("07/06/2017", 07/06/2017)
results>ERROR: 32783 INVALID OPERATION OR BAD SYMBOL TYPE: DURATIONDAYS
ERROR: 32783 INVALID OPERATION OR BAD SYMBOL TYPE: DURATIONDAYS
any thoughts? Does it not like the quotes around the date?
The mel output shows that you are missing your str() on the second half of the function. Is that the case?
It should look like
STR(._TODAYSDATE)
I think the issue is that one of your dates is a string and the other is a date. DURATIONDAYS() is looking for strings.
EDIT: Just saw your question at the end of your comment. It requires the quotes around the date because the date needs to be a string.
what the... how the... ugh... it was there when I first wrote it...
This.