Hi!
I know this is a very easy question, I really appreciate in advanced your help!
I have a commit button to record obs term:
OBSNOW("PAP SMEAR", DOCUMENT.LP_RESPAP, str(DOCUMENT.LP_DATEPAP))
but if the user clicks several times that button I will have the obs term saved several times on the same visit, is there a way to avoid saving the same obs term several times, but at the same time, letting the user to update the obs term value if it is needed?
I was thinking to add a condition that if the value is different than the current one save it, if not, don't save it, but there are a bunch of obs terms in this form, so I am hoping there is another way.
Thank you for your help!
If it would be atypical for a user to click the button multiple times, I can’t help but ask the question: why would they do that? In any event, you could modify the button’s function so that it first checked to see if the “PAP SMEAR” value existed for the date entered and then display a yes/no prompt to force the user to confirm their intention to either replace a previously recorded value or do nothing because the button press was a mistake. It might be helpful to better understand the workflow in your practice as there may be better solutions. For example, if this is happening because the variable is being cleared after the button is pressed and then the user can’t remember later on if they entered data for that parameter for a specific date, then perhaps a simple data display showing the data that has already been captured/saved during the current encounter would keep them from re-entering data that was already captured. You could do this by setting up a hidden variable to record any entered values in pipe/caret delimited format and then display these values on the form in a data display. Write the button’s function so that the data display would refresh every single time the button was pressed. There are likely multiple ways to accomplish the desired result, but I think I would need to understand the overall workflow in your practice. I hope this is helpful in some way.
The issue is related to your use of the third argument for the OBSNOW function (data symbol).
Argument 1 = ObsName
Argument 2 = Value
Argument 3 = Value Date
When argument 3 is invoked, it will store the value in the obsterm dated for the date specified by argument 3. I suspect that this is your intent, however the 'draw back' is that each execution of the function call using argument 3 will store the value, as you are seeing. This actually has advantages when it is understood properly, but unless careful coding methods are used, it can be frustrating.
To be clear, when argument 3 is used, the most common way to 'clear' the value is via the flow sheet 'change back' functionality. Unless really advance methods are used, these values cannot be removed via MEL.
To control this, you might consider one of three options:
1) Checking the OBS_LIST_CHANGES data symbol for the existence of the value and date using 'match' and a loop.
2) Clearing the value from the field after recording to prevent recording a second time.
3) Set a variable as a flag that prevents the button from doing anything once it has been clicked once.
There are several ways to control it, but these are the three that come to mind right now.
Thank you for your answer! They would like to replace instead of adding again another obs term, I will show the values as you recommended, I really appreciate it!
Thank you for your answer! I followed the option 2 and it's working! I really appreciate it!!
Happy to help. If you need any additional guidance, I’d be happy to provide coding examples if you can post or send me the .dlg file.