I'm working on a basic form to help our community health workers keep track of their patients' specialists appointments in hopes to better aid them in helping others. Essentially I have 9 different sections with obsterms to store a specialist appt name, phone #, date, address, time, and what mode of transport the pt will use and which CHW is responsible for reminder calls, etc.
If anyone has a form they are already using that serves a similar function, please share!
I first need to know if it is possible to use DURATIONDAYS to compare .TODAYSDATE with the LastObsValue that is a date field (vs the LastObsDate of that same obsterm)?
I'm trying to set up function or enable/disable expression that will grey out editfields when the date of a specialist appt is in a future date from today and will allow editing/overwriting when the date of the specialist appt is in the past.
Here's a function I've played with and it only ever keeps the edit field grey, even when the previous value of a date field has already passed.
I'm interested in other ways of approaching this form if my initial form instincts here aren't going to work out into a functional & useful form.
fn lastapp()
{local lastapp= 10000
lastspecapp= DURATIONDAYS(str(.TODAYSDATE),str(lastObsValue("DAT SPEC #1")))
IF lastspecapp <> 0 OR OBSNOW("DAT SPEC #1") <> "" AND lastspecapp < lastapp THEN
lastapp= lastspecapp ENDIF
IF lastapp < 0 THEN "FALSE" ELSE "TRUE" ENDIF}
Thansks, Caroline
Here are a couple things I see.
You have not defined your lastspecapp variable scope. Add a line that says "local lastspecapp" near the top of the function.
You do not need to run str(lastobsvalue(...) because observations are already strings, even if they are storing dates.
Functions need to return a value, you are not returning anything.
IF lastapp < 0 THEN
return “FALSE”
ELSE
return “TRUE”
ENDIF
Hi! Just curious - did you ever get this coding to work? If so, would you mind posting the coding? Thanks!!