@Handler(supports=PatientIdentifier.class, order=50) public class PatientIdentifierValidator extends Object implements org.springframework.validation.Validator
| Constructor and Description |
|---|
PatientIdentifierValidator() |
| Modifier and Type | Method and Description |
|---|---|
static void |
checkIdentifierAgainstFormat(String identifier,
String format,
String formatDescription)
Validates that a given identifier string is valid for a given regular expression format
|
static void |
checkIdentifierAgainstValidator(String identifier,
IdentifierValidator validator)
Validates that a given identifier string is valid for a given IdentifierValidator
|
boolean |
supports(Class<?> c) |
void |
validate(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(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. |
public boolean supports(Class<?> c)
supports in interface org.springframework.validation.ValidatorValidator.supports(java.lang.Class)public void validate(Object obj, org.springframework.validation.Errors errors)
validate in interface org.springframework.validation.ValidatorShould pass validation if field lengths are correct
Should fail validation if field lengths are not correctpublic static void validateIdentifier(PatientIdentifier pi) throws PatientIdentifierException
PatientIdentifier is validpi - - the PatientIdentifier to validatePatientIdentifierException - if the PatientIdentifier is invalid
Should fail validation if PatientIdentifier is null
Should pass validation if PatientIdentifier is voided
Should fail validation if another patient has a matching identifier of the same type
Should pass if in use and id type uniqueness is set to non uniquevalidateIdentifier(String, PatientIdentifierType)public static void validateIdentifier(String identifier, PatientIdentifierType pit) throws PatientIdentifierException
PatientIdentifierType
Checks for things like blank identifiers, invalid check digits, and invalid format.pit - - the PatientIdentifierType to validate againstidentifier - - the identifier to check against the passed PatientIdentifierTypePatientIdentifierException - if the identifier is invalid
Should fail validation if PatientIdentifierType is null
Should fail validation if identifier is blankcheckIdentifierAgainstFormat(String, String, String),
checkIdentifierAgainstValidator(String, IdentifierValidator)public static void checkIdentifierAgainstFormat(String identifier, String format, String formatDescription) throws PatientIdentifierException
identifier - - the identifier to check against the passed PatientIdentifierTypeformat - - the regular expression format to validate againstformatDescription - - user-friendly way of describing format (may be null)PatientIdentifierException - if the identifier is does not match the format
Should fail validation if identifier is blank
Should fail validation if identifier does not match the format
Should pass validation if identifier matches the format
Should pass validation if the format is blank
Should include format in error message if no formatDescription is specified
Should include formatDescription in error message if specifiedpublic static void checkIdentifierAgainstValidator(String identifier, IdentifierValidator validator) throws PatientIdentifierException
identifier - the identifier to check against the passed PatientIdentifierTypevalidator - the IdentifierValidator to use to check the identifierPatientIdentifierException - if the identifier is does not match the format
Should fail validation if identifier is blank
Should fail validation if identifier is invalid
Should pass validation if identifier is valid
Should pass validation if validator is nullCopyright © 2024 OpenMRS Inc.. All rights reserved.