I have a form (VFE) that I need to insert the previous values in every time the patient comes in and also update if any changes are made. It will insert the previous value, but if I change the value it keeps inserting the initial value. The form is using check boxes and edit fields.
1. in the initialization segment of your code, you can use the following:
{ ! obsnow("OBS TERM",obsprev("OBS TERM"))
}
2. However, if you reenter the form after putting it on hold, you will repopulate the obs term with the prior value. This requires setting a variable the first time you enter the form and checking the status of this variable when the form is reloaded.
{! if document.form_loaded<>"yes" then
obsnow("OBS TERM",obsprev("OBS TERM"))
document.form_loaded="yes"
endif
}
3. You can't enter a new null value into an obs term, i.e. there is no new "OBS TERM"="". If this is an issue, then enter a null placeholder such as "none". This will require dealing with "none" on your form and in subsequent code.
4. Form initialization is very iffy. If there is significant code in the initialization segment, then you need create a subroutine and monitor for it's completion. This can be done in the text translation of the document.form_loaded field as follows:
{ if document.form_loaded<>"yes" then Load_Form() "" else "" endif}
5. The last line of the subroutine Load_Form() should set document.form_loaded="yes"
{ fn Load_Form()
.
.
.
document.form_loaded="yes"
}