Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 4156

Show
Ignore:
Timestamp:
05/09/08 13:36:21 (7 months ago)
Author:
djazayeri
Message:

Trim leading and trailing spaces from ID numbers in short patient form. (Already done in long patient form.)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs/trunk/src/web/org/openmrs/web/controller/patient/NewPatientFormController.java

    r4095 r4156  
    151151                                        for (int i=0; i<identifiers.length;i++) { 
    152152                                                // arguments for the spring error messages 
    153                                                 String[] args = {identifiers[i]}; 
     153                                                String id = identifiers[i].trim(); 
     154                                                String[] args = {id}; 
    154155                                                 
    155156                                                // add the new identifier only if they put in some identifier string 
    156                                                 if (identifiers[i].length() > 0) { 
     157                                                if (id.length() > 0) { 
    157158                                                         
    158159                                                        // set up the actual identifier java object 
     
    173174                                                                loc = es.getLocation(Integer.valueOf(locs[i])); 
    174175                                                         
    175                                                         PatientIdentifier pi = new PatientIdentifier(identifiers[i], pit, loc); 
    176                                                         pi.setPreferred(pref.equals(identifiers[i]+types[i])); 
     176                                                        PatientIdentifier pi = new PatientIdentifier(id, pit, loc); 
     177                                                        pi.setPreferred(pref.equals(id+types[i])); 
    177178                                                        newIdentifiers.add(pi); 
    178179                                                         
    179180                                                        if (log.isDebugEnabled()) { 
    180                                                                 log.debug("Creating patient identifier with identifier: " + identifiers[i]); 
     181                                                                log.debug("Creating patient identifier with identifier: " + id); 
    181182                                                                log.debug("and type: " + types[i]); 
    182183                                                                log.debug("and location: " + locs[i]); 
     
    184185                                                 
    185186                                                        try { 
    186                                                                 if (pit.hasCheckDigit() && !OpenmrsUtil.isValidCheckDigit(identifiers[i])) { 
    187                                                                         log.error("hasCheckDigit and is not valid: " + pit.getName() + " " + identifiers[i]); 
     187                                                                if (pit.hasCheckDigit() && !OpenmrsUtil.isValidCheckDigit(id)) { 
     188                                                                        log.error("hasCheckDigit and is not valid: " + pit.getName() + " " + id); 
    188189                                                                        String msg = getMessageSourceAccessor().getMessage("error.checkdigits.verbose", args); 
    189190                                                                        errors.rejectValue("identifier", msg); 
    190191                                                                } 
    191         //                                                      else if (pit.hasCheckDigit() == false && identifiers[i].contains("-")) { 
    192         //                                                              log.error("hasn't CheckDigit and contains '-': " + pit.getName() + " " + identifiers[i]); 
    193         //                                                              String[] args2 = {"-", identifiers[i]};  
     192        //                                                      else if (pit.hasCheckDigit() == false && id.contains("-")) { 
     193        //                                                              log.error("hasn't CheckDigit and contains '-': " + pit.getName() + " " + id); 
     194        //                                                              String[] args2 = {"-", id};  
    194195        //                                                              String msg = getMessageSourceAccessor().getMessage("error.character.invalid", args2); 
    195196        //                                                              errors.rejectValue("identifier", msg); 
    196197        //                                                      } 
    197198                                                        } catch (Exception e) { 
    198                                                                 log.error("exception thrown with: " + pit.getName() + " " + identifiers[i]); 
     199                                                                log.error("exception thrown with: " + pit.getName() + " " + id); 
    199200                                                                log.error("Error while adding patient identifiers to savedIdentifier list", e); 
    200201                                                                String msg = getMessageSourceAccessor().getMessage("error.checkdigits", args);