Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
07/16/08 12:29:31 (6 months ago)
Author:
bwolfe
Message:

Merging trunk to the 1.3.x branch (sideporting) to get bug fixes into an RC5 release [4745]:[4946]

Files:

Legend:

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

    r4727 r4947  
    211211                         
    212212                } 
    213                          
    214                 return super.processFormSubmission(request, response, shortPatient, errors); 
     213                 
     214                // skip calling super.processFormSubmission so that setting up the page is done 
     215                // again in the onSubmit method 
     216                 
     217                return onSubmit(request, response, shortPatient, errors); 
    215218        } 
    216219 
     
    234237                        ShortPatientModel shortPatient = (ShortPatientModel)obj; 
    235238                        String view = getSuccessView(); 
    236                         boolean isError = false; 
     239                        boolean isError = errors.hasErrors(); // account for possible errors in the processFormSubmission method 
    237240                         
    238241                        String action = request.getParameter("action"); 
     
    375378                        } 
    376379                         
    377                         // save or add the patient 
    378380                        Patient newPatient = null; 
    379                         try { 
    380                                 newPatient = ps.savePatient(patient); 
    381                         } catch ( InvalidIdentifierFormatException iife ) { 
    382                                 log.error(iife); 
    383                                 patient.removeIdentifier(iife.getPatientIdentifier()); 
    384                                 httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "PatientIdentifier.error.formatInvalid"); 
    385                                 //errors = new BindException(new InvalidIdentifierFormatException(msa.getMessage("PatientIdentifier.error.formatInvalid")), "givenName"); 
    386                                 isError = true; 
    387                         } catch ( InvalidCheckDigitException icde ) { 
    388                                 log.error(icde); 
    389                                 patient.removeIdentifier(icde.getPatientIdentifier()); 
    390                                 httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "PatientIdentifier.error.checkDigit"); 
    391                                 //errors = new BindException(new InvalidCheckDigitException(msa.getMessage("PatientIdentifier.error.checkDigit")), "givenName"); 
    392                                 isError = true; 
    393                         } catch ( IdentifierNotUniqueException inue ) { 
    394                                 log.error(inue); 
    395                                 patient.removeIdentifier(inue.getPatientIdentifier()); 
    396                                 httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "PatientIdentifier.error.notUnique"); 
    397                                 //errors = new BindException(new IdentifierNotUniqueException(msa.getMessage("PatientIdentifier.error.notUnique")), "givenName"); 
    398                                 isError = true; 
    399                         } catch ( DuplicateIdentifierException die ) { 
    400                                 log.error(die); 
    401                                 patient.removeIdentifier(die.getPatientIdentifier()); 
    402                                 httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "PatientIdentifier.error.duplicate"); 
    403                                 //errors = new BindException(new DuplicateIdentifierException(msa.getMessage("PatientIdentifier.error.duplicate")), "givenName"); 
    404                                 isError = true; 
    405                         } catch ( InsufficientIdentifiersException iie ) { 
    406                                 log.error(iie); 
    407                                 patient.removeIdentifier(iie.getPatientIdentifier()); 
    408                                 httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "PatientIdentifier.error.insufficientIdentifiers"); 
    409                                 //errors = new BindException(new InsufficientIdentifiersException(msa.getMessage("PatientIdentifier.error.insufficientIdentifiers")), "givenName"); 
    410                                 isError = true; 
    411                         } catch ( PatientIdentifierException pie ) { 
    412                                 log.error(pie); 
    413                                 patient.removeIdentifier(pie.getPatientIdentifier()); 
    414                                 httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "PatientIdentifier.error.general"); 
    415                                 //errors = new BindException(new PatientIdentifierException(msa.getMessage("PatientIdentifier.error.general")), "givenName"); 
    416                                 isError = true; 
    417                         } 
     381                         
     382                        if ( !isError ) { 
     383                                // save or add the patient 
     384                                try { 
     385                                        newPatient = ps.savePatient(patient); 
     386                                } catch ( InvalidIdentifierFormatException iife ) { 
     387                                        log.error(iife); 
     388                                        patient.removeIdentifier(iife.getPatientIdentifier()); 
     389                                        httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "PatientIdentifier.error.formatInvalid"); 
     390                                        //errors = new BindException(new InvalidIdentifierFormatException(msa.getMessage("PatientIdentifier.error.formatInvalid")), "givenName"); 
     391                                        isError = true; 
     392                                } catch ( InvalidCheckDigitException icde ) { 
     393                                        log.error(icde); 
     394                                        patient.removeIdentifier(icde.getPatientIdentifier()); 
     395                                        httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "PatientIdentifier.error.checkDigit"); 
     396                                        //errors = new BindException(new InvalidCheckDigitException(msa.getMessage("PatientIdentifier.error.checkDigit")), "givenName"); 
     397                                        isError = true; 
     398                                } catch ( IdentifierNotUniqueException inue ) { 
     399                                        log.error(inue); 
     400                                        patient.removeIdentifier(inue.getPatientIdentifier()); 
     401                                        httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "PatientIdentifier.error.notUnique"); 
     402                                        //errors = new BindException(new IdentifierNotUniqueException(msa.getMessage("PatientIdentifier.error.notUnique")), "givenName"); 
     403                                        isError = true; 
     404                                } catch ( DuplicateIdentifierException die ) { 
     405                                        log.error(die); 
     406                                        patient.removeIdentifier(die.getPatientIdentifier()); 
     407                                        httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "PatientIdentifier.error.duplicate"); 
     408                                        //errors = new BindException(new DuplicateIdentifierException(msa.getMessage("PatientIdentifier.error.duplicate")), "givenName"); 
     409                                        isError = true; 
     410                                } catch ( InsufficientIdentifiersException iie ) { 
     411                                        log.error(iie); 
     412                                        patient.removeIdentifier(iie.getPatientIdentifier()); 
     413                                        httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "PatientIdentifier.error.insufficientIdentifiers"); 
     414                                        //errors = new BindException(new InsufficientIdentifiersException(msa.getMessage("PatientIdentifier.error.insufficientIdentifiers")), "givenName"); 
     415                                        isError = true; 
     416                                } catch ( PatientIdentifierException pie ) { 
     417                                        log.error(pie); 
     418                                        patient.removeIdentifier(pie.getPatientIdentifier()); 
     419                                        httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "PatientIdentifier.error.general"); 
     420                                        //errors = new BindException(new PatientIdentifierException(msa.getMessage("PatientIdentifier.error.general")), "givenName"); 
     421                                        isError = true; 
     422                                } 
    418423                                                 
    419                         // update patient's relationships and death reason 
    420                         if ( !isError ) { 
     424                                // update patient's relationships and death reason 
    421425                                String[] personAs = request.getParameterValues("personA"); 
    422426                                String[] types = request.getParameterValues("relationshipType"); 
     
    556560                        } 
    557561                         
    558                         if ( isError ) { 
     562                        if ( isError || errors.hasErrors()) { 
    559563                                log.error("Had an error during processing. Redirecting to " + this.getFormView()); 
    560564                                 
    561565                                Map<String, Object> model = new HashMap<String, Object>(); 
    562566                                model.put(getCommandName(), new ShortPatientModel(patient)); 
     567                                 
     568                                // evict from session so that nothing temporarily added here is saved 
     569                                Context.evictFromSession(patient); 
    563570                                 
    564571                                return this.showForm(request, response, errors, model); 
     
    651658                Map<String, Object> map = new HashMap<String, Object>(); 
    652659                 
    653                 // the list of identifiers to display  
    654                 Set<PatientIdentifier> identifiers = new TreeSet<PatientIdentifier>(); 
     660                // the list of identifiers to display 
     661                // this is a hashset so that the comparison is one with .equals() instead of .compareTo 
     662                Set<PatientIdentifier> identifiers = new HashSet<PatientIdentifier>(); 
    655663                 
    656664                Patient patient = null;