org.openmrs.validator
Class PatientIdentifierValidator

java.lang.Object
  extended by org.openmrs.validator.PatientIdentifierValidator
All Implemented Interfaces:
org.springframework.validation.Validator

@Handler(supports=PatientIdentifier.class,
         order=50)
public class PatientIdentifierValidator
extends java.lang.Object
implements org.springframework.validation.Validator

This class validates a PatientIdentifier object.


Constructor Summary
PatientIdentifierValidator()
           
 
Method Summary
static void checkIdentifierAgainstFormat(java.lang.String identifier, java.lang.String format)
          Validates that a given identifier string is valid for a given regular expression format
static void checkIdentifierAgainstValidator(java.lang.String identifier, IdentifierValidator validator)
          Validates that a given identifier string is valid for a given IdentifierValidator
 boolean supports(java.lang.Class c)
           
 void validate(java.lang.Object obj, org.springframework.validation.Errors errors)
          Validates a PatientIdentifier.
static void validateIdentifier(PatientIdentifier pi)
          Checks that the given PatientIdentifier is valid
static void validateIdentifier(java.lang.String identifier, PatientIdentifierType pit)
          Validates that a given identifier string is valid for a given PatientIdentifierType Checks for things like blank identifiers, invalid check digits, and invalid format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PatientIdentifierValidator

public PatientIdentifierValidator()
Method Detail

supports

public boolean supports(java.lang.Class c)
Specified by:
supports in interface org.springframework.validation.Validator
See Also:
Validator.supports(java.lang.Class)

validate

public void validate(java.lang.Object obj,
                     org.springframework.validation.Errors errors)
Validates a PatientIdentifier.

Specified by:
validate in interface org.springframework.validation.Validator
See Also:
Validator.validate(java.lang.Object, org.springframework.validation.Errors)

validateIdentifier

public static void validateIdentifier(PatientIdentifier pi)
                               throws PatientIdentifierException
Checks that the given PatientIdentifier is valid

Parameters:
pi - - the PatientIdentifier to validate
Throws:
PatientIdentifierException - if the PatientIdentifier is invalid
See Also:
validateIdentifier(String, PatientIdentifierType)
Expected behavior:
fail validation if PatientIdentifier is null, pass validation if PatientIdentifier is voided, fail validation if another patient has a matching identifier of the same type

validateIdentifier

public static void validateIdentifier(java.lang.String identifier,
                                      PatientIdentifierType pit)
                               throws PatientIdentifierException
Validates that a given identifier string is valid for a given PatientIdentifierType Checks for things like blank identifiers, invalid check digits, and invalid format.

Parameters:
pit - - the PatientIdentifierType to validate against
identifier - - the identifier to check against the passed PatientIdentifierType
Throws:
PatientIdentifierException - if the identifier is invalid
See Also:
checkIdentifierAgainstFormat(String, String), checkIdentifierAgainstValidator(String, IdentifierValidator)
Expected behavior:
fail validation if PatientIdentifierType is null, fail validation if identifier is blank

checkIdentifierAgainstFormat

public static void checkIdentifierAgainstFormat(java.lang.String identifier,
                                                java.lang.String format)
                                         throws PatientIdentifierException
Validates that a given identifier string is valid for a given regular expression format

Parameters:
format - - the regular expression format to validate against
identifier - - the identifier to check against the passed PatientIdentifierType
Throws:
PatientIdentifierException - if the identifier is does not match the format
Expected behavior:
fail validation if identifier is blank, fail validation if identifier does not match the format, pass validation if identifier matches the format, pass validation if the format is blank

checkIdentifierAgainstValidator

public static void checkIdentifierAgainstValidator(java.lang.String identifier,
                                                   IdentifierValidator validator)
                                            throws PatientIdentifierException
Validates that a given identifier string is valid for a given IdentifierValidator

Parameters:
identifier - the identifier to check against the passed PatientIdentifierType
validator - the IdentifierValidator to use to check the identifier
Throws:
PatientIdentifierException - if the identifier is does not match the format
Expected behavior:
fail validation if identifier is blank, fail validation if identifier is invalid, pass validation if identifier is valid, pass validation if validator is null

OpenMRS-1.7.x

Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change