Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-4867

Do not allow person/patient to have death date before birth date

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Should
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Core 2.1.0
    • Component/s: None
    • Labels:
      None
    • Complexity:
      Low

      Description

      Currently in the Person.java class, it is permitted to manually set a person's deathdate before their birthdate. To do this, by creating a new person object, and then calling setBirthdate on a date after setDeathdate, results in permitted behavior. This should be prevented or checked by some helper methods. I have written a test that exposes this bug and will paste it below:

      /* 
       * Test that one cannot set the deathdate before the birthdate
       * 
       * @throws Exception
       */
      @Test
      public void shouldNotSetDeathBeforeBirth() throws Exception {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        Person p = new Person();
        
        Date birthdate = new Date(2000, 10, 26);
        df.format(birthdate);
        p.setBirthdate(birthdate);
        Date deathdate = new Date(1998, 10, 26);
        df.format(deathdate);
        p.setDeathDate(deathdate);
        // this should throw an exception that deathdate cannot be before the birthdate
      }
      

      I could also submit a pull request for the test if necessary.

        Gliffy Diagrams

          Attachments

            Attachments-Category-Modification

              Activity

                People

                • Assignee:
                  reubenv Reuben Varghese
                  Reporter:
                  hirschf2 Kyle Hirschfelder
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - 0 minutes
                    0m
                    Remaining:
                    Remaining Estimate - 0 minutes
                    0m
                    Logged:
                    Time Spent - 1 week
                    1w