[SOLVED] How do I ensure that an HTML form is entered only once

I have a couple of HTML forms and would like to set one up such that it is entered first and is entered only once, though can be updated with new information.

FWIW at AMPATH we are developing an angular application that implements visits in which once a form is filled, it does not show up in the available forms section and this form can be edited by selecting the associated entry in the list of entered forms.

@arbaughj has definitely done this before, and I think he shared his approach on Talk. I recommend searching the archives for it.

Yes @ssmusoke, I’ve done this before using JavaScript. If there is already an encounter of that type filled out, edit the existing one rather than creating a new one. I documented this at… https://wiki.openmrs.org/display/docs/HTML+Form+Entry+JavaScript+Reference

@arbaughj Thanks a bunch, trying it out now

@arbaughj I am having trouble obtaining the context path for the page so that I can build a URL - currently the example is hardcoded to http://localhost:8080/openmrs-standalone, yet there is a dev, staging and production environment to consider.

Good evening @ssmusoke. Did you find a solution yet? I saw your message earlier but didn’t have time to think on it or research it until now. Have you tried “location.origin” in JavaScript? http://www.w3schools.com/jsref/prop_loc_origin.asp

If it works, please add it as a comment on the JavaScript Reference Page.

@arbaughj I have added it to the Javascript page, probably its an issue of not knowing where to put the velocity templates

Dear Stephen,

I’m sorry to hear you are still having troubles with this. You should be able to just put this code in the top of your HTML Form. I wonder if there is something “funny” going on with the < signs, using the < You’re using the tag, so it should know it’s a script. If it’s showing the #set lines too, then it’s maybe something funny with the . My recommendation would be to try simplifying it, and then adding in a little bit at a time until you get it.

Good luck.

@ssmusoke, Did you finally have it work?? If it works this will solve the summary page problem

@arbaughj - I finally got it to work after hours of troubleshooting, the root cause was that I had a comment in the Javascript, which caused the whole line to be commented out…

2 Likes