Ejemplo n.º 1
0
  public PregnancyOutcome evaluatePregnancyOutcome(PregnancyOutcome entityItem)
      throws ConstraintViolations {

    int age;

    if (entityItem.getOutcomeDate() == null) {
      age =
          (int)
              (CalendarUtil.daysBetween(
                      entityItem.getMother().getDob(), entityItem.getVisit().getVisitDate())
                  / 365.25);
    } else {
      age =
          (int)
              (CalendarUtil.daysBetween(
                      entityItem.getMother().getDob(), entityItem.getOutcomeDate())
                  / 365.25);
    }
    if (age < siteProperties.getMinimumAgeOfPregnancy())
      throw new ConstraintViolations(
          "The Mother specified is younger than the minimum age required to have a Pregnancy Outcome.");
    if (individualService.getLatestEvent(entityItem.getMother()).equals("Death"))
      throw new ConstraintViolations(
          "A Pregnancy Outcome cannot be created for a Mother who has a Death event.");
    if (entityItem.getOutcomes().size() == 0)
      throw new ConstraintViolations(
          "A Pregnancy Outcome cannot be created unless it has at least 1 outcome.");
    if (entityItem.getMother().getCurrentResidency() == null)
      throw new ConstraintViolations(
          "A Pregnancy Outcome cannot be created because a Residency record cannot be found for the mother.");

    return entityItem;
  }
Ejemplo n.º 2
0
  public PregnancyObservation evaluatePregnancyObservation(PregnancyObservation entityItem)
      throws ConstraintViolations {

    int age =
        (int)
            (CalendarUtil.daysBetween(
                    entityItem.getMother().getDob(), entityItem.getExpectedDeliveryDate())
                / 365.25);
    if (age < siteProperties.getMinimumAgeOfPregnancy())
      throw new ConstraintViolations(
          "The Mother specified is younger than the minimum age required to have a Pregnancy Observation.");
    if (!checkDuplicatePregnancyObservation(entityItem.getMother()))
      throw new ConstraintViolations(
          "The Mother specified already has a pending Pregnancy Observation.");
    if (individualService.getLatestEvent(entityItem.getMother()).equals("Death"))
      throw new ConstraintViolations(
          "A Pregnancy Observation cannot be created for a Mother who has a Death event.");

    return entityItem;
  }