I'm trying to see if a certain obs term is blank or the last time it was recorded is over 365 days ago OR if another obs term is blank or if it was last recorded over 365 days ago.
Here is what I have for Missing:
(LASTOBSVALUE("MALCR") == "" OR durationdays(last_signed_obs_date("MALCR"), str(._TODAYSDATE)) >=365) OR (LASTOBSVALUE("MICROALB/CRE") == "" OR durationdays(last_signed_obs_date("MICROALB/CRE"), str(._TODAYSDATE)) >=365)
Here is what I have for not missing:
LASTOBSVALUE("MALCR") <> "" AND durationdays(last_signed_obs_date("MALCR"), str(._TODAYSDATE)) <=365 OR LASTOBSVALUE("MICROABL/CRE") <> "" AND durationdays(last_signed_obs_date("MICROABL/CRE"), str(._TODAYSDATE)) <=365
Missing works when I first load the form. Then I go put in the obs of MALCR, and "Done!" shows up but Missing doesn't go away.
Can anyone let me know what I'm missing? I tried uploading screenshots but I'm getting an error.
My guess is that the Missing section needs to track the current value for the two obsterms.
Try adding:
and (obsnow("MALCR")=="" or obsnow("MICROALB/CRE")=="")
If something is entered today, it will drop the "Missing" flag.
-James
You are missing grouping parenthesis to put the OR statements together. (MALCR conditions) and (MICROALB/CRE conditions). Without this grouping, the code will return FALSE (it is all true or false (1 or 0) in the result).
You could refine it by remaining consistent in your 'tense' as well. LASTOBSVALUE and LAST_SIGNED_OBS_DATE can return two different 'time frames'. LASTOBVALUE returns the current unsigned value OR the last signed value if no 'new' value exist. LAST_SIGNED_OBS_DATE will only return the date of the last signed value. Use of lastobsvalue is appropriate in both situations.
I would go a step further and suggest a single use of lastobsdate for both obsterms:
if durationdays(lastobsdate(OBS1),str(._TODAYSDATE)) >= 365 AND durationdays(lastobsdate(OBS2,str(._TODAYSDATE)) >= 365 then 'Missing" else "Satisfied" endif
By using lastobsdate, you are basically saying 'no date = no value' which is true (excepting some advanced methods), so no need to evaluate both. This makes the code as efficient and compact (without using MEL shorthand) as it can be.
Hope this helps.