Limit Creation of Encounters when using HTMLFORMs

Does HTML form entry currently support a user only being able to create 1 observation (For an Active Visit) and subsequently only being able to edit it? Scenario: For example. User A Logs in and clicks on Patient A with an active visit and clicks on the Visit Note link on the patient dashboard and enters a diagnosis. User A Logs out. Next time User A logs in and clicks on the same active visit for Patient A and clicks on the Visit Note link, they are presented with the previous Encounter and any changes made are adjusted on the previous Encounter.

@arbaughj, this question is asked pretty often, and I think you have a quick answer for it. Could you add that to a FAQ or Tips and Tricks wiki page for HFE and Link it here?

@darius, I’ve already added some sample code as comments on the HTML Form Entry JavaScript Reference Page to accomplish something like this. See the comments there starting with… “Imagine you have an encounter type (HTML Form) that you only want filled out once per patient”. That can be a good starting point for you @whiscard.

Another thing, in your example, you’re using the integrated Visit Note form. Changes made to the integrated HTML forms don’t persist, so as a workaround, you can create a new implementation defined form, based on the HTML code from the integrated form. Eventually, you will be able to disable the default Visit Note form (which would no longer be used). See… https://issues.openmrs.org/browse/RA-923

This just a solution to a situation where someone would want to fill only one encounter for the patient in his/her life time and only be able to edit if one already exists other than creating new. I have tested that and it works! But another question is related to this Single encounter per visit, have you attempted accomplishing that in refApp?

Hi @ningosi, I haven’t tried that exact use-case before. In thinking about it, it would make sense to try to configure this in the “Show if” field when editing custom forms. Don’t know if there are any ways to determine if that form has already been filled. See the documentation on editing custom forms at… https://wiki.openmrs.org/display/docs/Reference+Application+2.5#ReferenceApplication2.5-ManageForms

Also, you could try to address the once-per-visit use-case with JavaScript starting with my script you’re using. I don’t know if the <lookup complexExpression> tag has a way to access the visit ID or a way to get the current visit info.

Hi @arbaughj thanks for your feedback.