Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Ticket #805 (assigned enhancement)

Opened 1 year ago

Last modified 2 months ago

Regex validation on input fields.

Reported by: bmckown Assigned to: bmckown (accepted)
Priority: minor Milestone: OpenMRS Someday
Component: OpenMRS Code Base Keywords: regex, address, field, validation, latitude, longitude
Cc: ayeung, bmamlin Introductory Ticket: 0
Code Review Status: Needs Review

Description

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.

Attachments

address_regex.patch (10.3 kB) - added by bmckown on 06/06/08 23:39:29.
Address Regex Patch
address_regex2.patch (8.8 kB) - added by bmckown on 07/19/08 21:18:19.
adds regular expression validation to address fields - fix to previous patch

Change History

06/06/08 23:39:29 changed by bmckown

  • attachment address_regex.patch added.

Address Regex Patch

07/19/08 21:18:19 changed by bmckown

  • attachment address_regex2.patch added.

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

07/19/08 21:20:03 changed by bmckown

  • owner changed from somebody to bmckown.
  • status changed from new to assigned.

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.

09/15/08 19:37:35 changed by bwolfe

  • milestone changed from OpenMRS 1.3 to OpenMRS 1.4.

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:
    1. 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.
    2. 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.

01/13/09 22:17:54 changed by bwolfe

  • intro_ticket changed.
  • review_status changed.
  • milestone changed from OpenMRS 1.4 to OpenMRS Someday.

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

05/11/09 18:18:39 changed by jmiranda

  • review_status set to Needs Review.

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