@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; }
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."); }
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()); }