@RequestMapping("/pregnancy-observ-reconciliation.report")
  public ModelAndView getPregnancyObservReconciliation() {
    ModelAndView mv = new ModelAndView("pregnancyObservReconciliation");
    Collection<PregObservReconciliationBean> beans = new ArrayList<PregObservReconciliationBean>();

    PregObservReconciliationBean bean = new PregObservReconciliationBean();
    bean.setCurrentDate(calendarUtil.formatDate(Calendar.getInstance()));

    // grab all Pregnancy Observations
    List<PregnancyObservation> list =
        genericDao.findListByProperty(
            PregnancyObservation.class, "status", properties.getDataStatusPendingCode());
    Collections.sort(list, new PregnancyObservationComparator());

    for (PregnancyObservation item : list) {

      if (item.getExpectedDeliveryDate().before(Calendar.getInstance())) {
        bean.setDate(calendarUtil.formatDate(item.getRecordedDate()));
        bean.setIndivId(item.getMother().getExtId());
        beans.add(bean);
      }
    }

    if (list.size() == 0) {
      bean.setDate("");
      bean.setIndivId("");
      beans.add(bean);
    }

    mv.addObject("theData", beans);
    return mv;
  }
예제 #2
0
 public boolean checkDuplicatePregnancyObservation(Individual mother) {
   List<PregnancyObservation> list =
       genericDao.findListByProperty(PregnancyObservation.class, "mother", mother);
   for (PregnancyObservation item : list) {
     if (item.getStatus().equals(siteProperties.getDataStatusPendingCode())) return false;
   }
   return true;
 }
예제 #3
0
  @Transactional(rollbackFor = Exception.class)
  public void closePregnancyObservation(Individual mother) {
    List<PregnancyObservation> obs =
        genericDao.findListByProperty(PregnancyObservation.class, "mother", mother);

    for (PregnancyObservation ob : obs) {
      if (ob.getStatus().equals(siteProperties.getDataStatusPendingCode())) {
        // found the corresponding pregnancy observation
        // now close it
        ob.setStatus(siteProperties.getDataStatusClosedCode());
        genericDao.update(ob);
        break;
      }
    }
  }
예제 #4
0
 public void validateGeneralPregnancyObservation(PregnancyObservation entityItem)
     throws ConstraintViolations {
   List<PregnancyObservation> list =
       genericDao.findListByMultiProperty(
           PregnancyObservation.class,
           getValueProperty("mother", entityItem.getMother()),
           getValueProperty("status", siteProperties.getDataStatusPendingCode()));
   if (list.size() > 1)
     throw new ConstraintViolations(
         "The Mother specified already has a pending Pregnancy Observation.");
 }
예제 #5
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;
  }
 public int compare(PregnancyObservation po1, PregnancyObservation po2) {
   return po1.getMother().getExtId().compareTo(po2.getMother().getExtId());
 }