HTML Form Entry: how to get autocompletion to work

Hi all,

Following the HTML Form Entry Module HTML Reference I tried to get the autocomplete feature to work without success.

Neither of <obs conceptId="1234" answerClasses="Drug" type="autocomplete"/> or

<obs conceptId="1234" answerDrugs="true"/> would work.

Am I missing something obvious? I’m using

  1. openmrs-core 1.11.4-SNAPSHOT
  2. HTML Form Entry 2.5

Thanks @dkayiwa for sorting me out with this on IRC. This was a combination of two issues:

So any builds of the HTML Widgets and HTML Form Entry modules based after the above commits should just do the trick (it did it for me).

1 Like

Hello, I am developing a drug order module and trying to implement the auto-complete functionality when the user enters the name of the drug. i e.g. When the user starts typing ‘Asp’, the form must automatically provide the option ‘Aspirin’

Given a Concept Set ID 162552 which stands for Reference Application Common Drug Allergens, I am trying to fetch all the Concepts (Allergens) in that set. Could you please suggest…

Hi @hariniparth,

I have an example using HFE and using a concept class for the possible set of answers. That is what we have done once for a medication order form, producing such result:

Here is the form and how it was done:

<fieldset >
  <legend>Drug</legend>
  <h3>Drug to order</h3>
  <p>
    <obs id="drug-ordered" conceptId="CIEL:1282" answerClasses="Drug" style="autocomplete" size="10"/>
  </p>
</fieldset>

I hope this helps.

Thank you! I am unable to get the text input field where I can enter some text (drug name) and neither am I able to see the list of Concepts… Here is what I have given where 162552 is the concept_id for common drug allergens

It would have been helpful to paste here your non-working HFE snippet…

As per the wiki at HTML Form Entry Module HTML Reference \ <obs> \ Attributes:

So following the example stated in the wiki, you should come up with something like this

<obs conceptId="your_coded_question" answerConceptSetIds="CIEL:162552" labelText="your_label" style="autocomplete" />

Where

  • your_coded_question is the concept mapping for your question.
  • your_label is the label you want for the <obs> tag.

Thank you…I need more help with this… At present I have the following form in my .gsp file

< form method=“post” > < div class=“fields”>Drug name < /div >
< button class=“confirm right” id=“btn-place” name=“confirmDrug” type=“submit” onclick=“showIndividualOrderDetailsWindow()” >${ ui.message(“Next”) }< /button > < /form >

Given that I do not see any concept mapping for ‘your_coded_question’ which should be something like ‘selected drug’, I am just attempting to fetch a list of dropdown options using < obs conceptId=“162552” /> within the above form. All I get is a blank rectangular box with no text input field or fetched data…Sorry if I am missing something obvious but I have not understood this right…

I have also included the dependencies for htmlformentry anf htmlwidgets modules (Ignore the space immediately before/after the tags < > symbols…had to give that space to allow the code to be displayed here - doesn’t display otherwise)

I haven’t been following this thread, but one thing that seems to be an issue is that you say you’re writing a GSP file (so, a UI Framework view), but that you’re trying to use the <obs> tag (which is part of HTML Form Entry), and these aren’t the same technology, and I wouldn’t naturally expect them to work together.

The current thread was about making autocompletion work within HFE forms. If that is not what you are doing, I would suggest to open a new thread explaining what you are trying to achieve.


See the code section in this Markdown cheatsheet.

Sure…just did that…Thank you