Reminder: Create & find trunk-related issues here. Legacy Trac tickets are still available. Problems? Workflow feedback? Need a module project? Open a support ticket.

OpenMRS Trunk

Regex validation on input fields.

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Could Could
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: OpenMRS 1.5.0
  • Component/s: None
  • Description:
    Hide

    A general openmrs field validator could take in a regular expression and an input string to validate any input field. An administration section could allow the administrator to add a field type, a regular expression, and an example format for as many input fields as desired. The openmrs validator could take in a string and the regex in order to validate the field. It might also be able to parse the regex so that when the user enters a value, what is entered is actually what gets filtered from the parser.

    For person address, I am including a quick-fix patch that allows a regex and example format to be defined in the addressTemplate of openmrs-servlet.xml for any person address field. If the input does not match when editing a patient on the patient dashboard then the field(s) is/are highlighted, an error message is shown, and the page will not submit until the user enters the correct value. The patch directly applies to latitude and longitude values for the Kenya address template.

    Show
    A general openmrs field validator could take in a regular expression and an input string to validate any input field. An administration section could allow the administrator to add a field type, a regular expression, and an example format for as many input fields as desired. The openmrs validator could take in a string and the regex in order to validate the field. It might also be able to parse the regex so that when the user enters a value, what is entered is actually what gets filtered from the parser. For person address, I am including a quick-fix patch that allows a regex and example format to be defined in the addressTemplate of openmrs-servlet.xml for any person address field. If the input does not match when editing a patient on the patient dashboard then the field(s) is/are highlighted, an error message is shown, and the page will not submit until the user enters the correct value. The patch directly applies to latitude and longitude values for the Kenya address template.
  1. address_regex.patch
    (10 kB)
    Burke Mamlin
    2008-06-06 23:39:29 EDT
  2. address_regex2.patch
    (9 kB)
    Burke Mamlin
    2008-07-19 21:18:19 EDT

Activity

Hide
zBrian zMcKown added a comment - 2008-06-06 23:39:29 EDT

Address Regex Patch

Show
zBrian zMcKown added a comment - 2008-06-06 23:39:29 EDT Address Regex Patch
Hide
zBrian zMcKown added a comment - 2008-07-19 21:18:19 EDT

adds regular expression validation to address fields - fix to previous patch

Show
zBrian zMcKown added a comment - 2008-07-19 21:18:19 EDT adds regular expression validation to address fields - fix to previous patch
Hide
zBrian zMcKown added a comment - 2008-07-19 21:20:03 EDT

There is an error in address_regex.patch that pre-populates address fields when creating a new patient. This is fixed in address_regex2.patch. Please apply the latter instead of the former.

Show
zBrian zMcKown added a comment - 2008-07-19 21:20:03 EDT There is an error in address_regex.patch that pre-populates address fields when creating a new patient. This is fixed in address_regex2.patch. Please apply the latter instead of the former.
Hide
Ben Wolfe added a comment - 2008-09-15 19:37:35 EDT

Sorry for the delay in looking over your patch.

It looks good overall. I only have two suggestions:

  1. elementFormats in the xml would make more sense named "regexExample" or "formatExample".
  2. The overriding of removeBlankData() in addressLayout.jsp is kind of hacky. There are all kinds of separation of control rules broken. Making patientForm more extendable seems like the right path. I can only think of two possible solutions:
  3. Put a general continueSubmit var in patientForm and make the form tag have onSubmit="removeBlankData(); return continueSubmit". AddressLayout.jsp could then just manipulate the continueSubmit var as necessary.
  4. Make the patientForm form tag be onSubmit="removeBlankData()". In addressLayout.jsp, programmatically add a validation method to the containing form.onsubmit.
    If left as is, there are several weaknesses: 1) patientForm is changed and the overridden method in addressLayout is not would cause problems. 2) if addresslayout is used in another form, it won't prevent submission.
Show
Ben Wolfe added a comment - 2008-09-15 19:37:35 EDT Sorry for the delay in looking over your patch. It looks good overall. I only have two suggestions:
  1. elementFormats in the xml would make more sense named "regexExample" or "formatExample".
  2. The overriding of removeBlankData() in addressLayout.jsp is kind of hacky. There are all kinds of separation of control rules broken. Making patientForm more extendable seems like the right path. I can only think of two possible solutions:
  3. Put a general continueSubmit var in patientForm and make the form tag have onSubmit="removeBlankData(); return continueSubmit". AddressLayout.jsp could then just manipulate the continueSubmit var as necessary.
  4. Make the patientForm form tag be onSubmit="removeBlankData()". In addressLayout.jsp, programmatically add a validation method to the containing form.onsubmit. If left as is, there are several weaknesses: 1) patientForm is changed and the overridden method in addressLayout is not would cause problems. 2) if addresslayout is used in another form, it won't prevent submission.
Hide
Ben Wolfe added a comment - 2009-01-13 22:17:54 EST

Moving this to the 'someday' milestone until we have a final patch know when this will go in.

Show
Ben Wolfe added a comment - 2009-01-13 22:17:54 EST Moving this to the 'someday' milestone until we have a final patch know when this will go in.
Hide
Justin Miranda added a comment - 2009-05-11 18:18:39 EDT

Marked as Needs Review as a reminder that it needs to be dealt with.

Show
Justin Miranda added a comment - 2009-05-11 18:18:39 EDT Marked as Needs Review as a reminder that it needs to be dealt with.
Hide
Ben Wolfe added a comment - 2009-11-02 19:08:18 EST

I'll finish up this patch and get this into trunk. We've been using this in ampath for a while.

Show
Ben Wolfe added a comment - 2009-11-02 19:08:18 EST I'll finish up this patch and get this into trunk. We've been using this in ampath for a while.
Hide
Ben Wolfe added a comment - 2009-11-11 07:29:51 EST

Committed to 1.5.x in rev:11180/rev:11182 for 1.5.1 and to trunk in rev:11181

Show
Ben Wolfe added a comment - 2009-11-11 07:29:51 EST Committed to 1.5.x in rev:11180/rev:11182 for 1.5.1 and to trunk in rev:11181

People

Dates

  • Created:
    2008-06-06 23:38:48 EDT
    Updated:
    2010-07-08 16:22:08 EDT
    Resolved:
    2010-07-01 22:41:46 EDT