| 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 | } |
|---|