I don't know what I am doing wrong here. I have tried a combination of things (see below) but I cannot get this to work. I want the OBSPREV to populate if it is less than 1 day old. We have an intake process that pulls this data in from a tablet. The below has been also been tried in a form with just these values and no other code as well.
the below code seems to work however the last value (BP DIASTOLIC) appears no matter what. So I tried removing the code to the BP DIASTOLIC and then the next last value populated instead (BP SYSTOLIC) and so on and so forth
{
if OBSPREV("WEIGHT") <> "" AND OBSNOW("WEIGHT") == "" AND (DURATIONDAYS(LASTOBSDATE("WEIGHT"),STR(._TODAYSDATE))<2)
then OBSNOW("WEIGHT",OBSPREV("WEIGHT"))
ELSE ""
ENDIF
}
{
if OBSPREV("HEIGHT") <> "" AND OBSNOW("HEIGHT") == "" AND (DURATIONDAYS(LASTOBSDATE("HEIGHT"),STR(._TODAYSDATE))<2)
then OBSNOW("HEIGHT",OBSPREV("HEIGHT"))
ELSE ""
ENDIF
}
{
if OBSPREV("BP SYSTOLIC") <> "" AND OBSNOW("BP SYSTOLIC") == "" AND (DURATIONDAYS(LASTOBSDATE("BP SYSTOLIC"),STR(._TODAYSDATE))<2)
then OBSNOW("BP SYSTOLIC",OBSPREV("BP SYSTOLIC"))
ELSE ""
ENDIF
}
{
if OBSPREV("BP DIASTOLIC") <> "" AND OBSNOW("BP DIASTOLIC") == "" AND (DURATIONDAYS(LASTOBSDATE("BP SYSTOLIC"),STR(._TODAYSDATE))<2)
then OBSNOW("BP DIASTOLIC",OBSPREV("BP DIASTOLIC"))
ELSE ""
ENDIF
}
I tried the below code and had the same result (only pasted the last one for reading sake)
{
if (DURATIONDAYS(LASTOBSDATE("BP DIASTOLIC"),STR(._TODAYSDATE))>2) or OBSNOW("BP DIASTOLIC")<>""
then ""
ELSE OBSNOW("BP DIASTOLIC",OBSPREV("BP DIASTOLIC"))
ENDIF
}
I then tried the below code and instead of the last obs value populating, the first one did!
{
if OBSPREV("WEIGHT") <> "" AND OBSNOW("WEIGHT") == "" AND (DURATIONDAYS(LASTOBSDATE("WEIGHT"),STR(._TODAYSDATE))<2)
then OBSNOW("WEIGHT",OBSPREV("WEIGHT"))
and if OBSPREV("HEIGHT") <> "" AND OBSNOW("HEIGHT") == "" AND (DURATIONDAYS(LASTOBSDATE("HEIGHT"),STR(._TODAYSDATE))<2)
then OBSNOW("HEIGHT",OBSPREV("HEIGHT"))
and if OBSPREV("BP SYSTOLIC") <> "" AND OBSNOW("BP SYSTOLIC") == "" AND (DURATIONDAYS(LASTOBSDATE("BP SYSTOLIC"),STR(._TODAYSDATE))<2) then OBSNOW("BP SYSTOLIC",OBSPREV("BP SYSTOLIC")) and if (DURATIONDAYS(LASTOBSDATE("BP DIASTOLIC"),STR(._TODAYSDATE))>2) or OBSNOW("BP DIASTOLIC")<>""
then ""
ELSE OBSNOW("BP DIASTOLIC",OBSPREV("BP DIASTOLIC"))
ENDIF ENDIF ENDIF ENDIF
}
I'm at a loss...
Posted : April 11, 2017 4:37 am