コード例 #1
0
  @Override
  public void validate() {

    if (stillBirthRegistration.getDateOfEvent() != null
        && stillBirthRegistration.getDateOfEvent().after(DateUtils.today()))
      addActionError(getMessage("dateOfEvent.today.validate"));

    if (stillBirthRegistration.getRegistrationDate() != null
        && stillBirthRegistration.getDateOfEvent() != null
        && stillBirthRegistration
            .getDateOfEvent()
            .after(stillBirthRegistration.getRegistrationDate()))
      addActionError(getMessage("dateOfEvent.registration.validate"));

    if (placeTypeTemp != null
        && !EMPTY.equals(placeTypeTemp)
        && BndConstants.HOSPTIAL.equalsIgnoreCase(placeTypeTemp)
        && stillBirthRegistration.getEstablishment() == null)
      addActionError(getMessage("hospitalname.required"));
    // For Offline mode validating registration number....
    if (OFFLINE.equals(mode)
        && stillBirthRegistration.getRegistrationNo() != null
        && !EMPTY.equals(stillBirthRegistration.getRegistrationNo().trim()))
      if (stillBirthRegistration.getRegistrationUnit() != null
          && birthRegistrationService.checkUniqueRegistrationNumber(
              stillBirthRegistration.getRegistrationUnit().getId(),
              stillBirthRegistration.getId(),
              stillBirthRegistration.getRegistrationNo(),
              BndConstants.REGISTRATIONDATE.equalsIgnoreCase(numberGenKey)
                  ? stillBirthRegistration.getRegistrationDate()
                  : stillBirthRegistration.getDateOfEvent(),
              BndConstants.STILLBIRTHNUM)) addActionError(getMessage("registration.number.exists"));
      else if (BndUtils.isNum(stillBirthRegistration.getRegistrationNo().trim())) {
        final int eventYear =
            BndConstants.REGISTRATIONDATE.equalsIgnoreCase(numberGenKey)
                ? BndDateUtils.getCurrentYear(stillBirthRegistration.getRegistrationDate())
                : BndDateUtils.getCurrentYear(stillBirthRegistration.getDateOfEvent());
        final RegKeys regNumRange =
            regKeyService.getRegKeyByRegUnitAndDate(
                stillBirthRegistration.getRegistrationUnit(),
                eventYear,
                numberGenerationService.buildObjectType(
                    stillBirthRegistration, eventYear, BndConstants.STILLBIRTHNUM));
        if (regNumRange != null) {
          final Integer regNumber = Integer.valueOf(stillBirthRegistration.getRegistrationNo());
          if (regNumber >= regNumRange.getMinValue())
            addActionError(
                getMessage("regNumber.minvalue.validate")
                    .concat(" ")
                    .concat(regNumRange.getMinValue().toString()));
        }
      }
  }
コード例 #2
0
 @Override
 @Transactional
 protected void saveOrUpdate() {
   buildRegistration();
   if (stillBirthRegistration.getRegistrationNo() == null
       || "".equals(stillBirthRegistration.getRegistrationNo().trim()))
     stillBirthRegistration.setRegistrationNo(
         numberGenerationService.getStillBirthRegistrationNumber(
             stillBirthRegistration, birthHospitalUserFlag));
   stillBirthRegistration.setAdditionalRule(getAdditionalRule());
   birthRegistrationService.save(stillBirthRegistration, workFlowType);
   stillBirthRegistration.setPlaceType(bndCommonService.getPlaceType(placeTypeTemp));
   LOGGER.debug("Still Birth Registration Record ::::::::::" + stillBirthRegistration);
   mode = VIEW;
 }
コード例 #3
0
 @Override
 @Transactional
 @ValidationErrorPage(NEW)
 @Action(
     value = "/stillBirthRegistration-edit",
     results = {@Result(name = NEW, type = "dispatcher")})
 public String edit() {
   if (getMode().equals(LOCK)) {
     birthRegistrationService.buildAdoptionDetial(stillBirthRegistration);
     buildRegistration();
     stillBirthRegistration.setPlaceType(bndCommonService.getPlaceType(placeTypeTemp));
     stillBirthRegistration.setStatus(
         bndCommonService.getStatusByModuleAndCode(
             BndConstants.STILLBIRTHREGISTRATION, BndConstants.LOCK));
     final EgwSatuschange change = new EgwSatuschange();
     change.setFromstatus(
         bndCommonService
             .getStatusByModuleAndCode(BndConstants.STILLBIRTHREGISTRATION, BndConstants.APPROVED)
             .getId());
     change.setTostatus(
         bndCommonService
             .getStatusByModuleAndCode(BndConstants.STILLBIRTHREGISTRATION, BndConstants.LOCK)
             .getId());
     change.setModuleid(stillBirthRegistration.getId().intValue());
     change.setModuletype(BndConstants.STILLBIRTHREGISTRATIONMODULE);
     // change.setCreatedby(EgovThreadLocals.getUserId());
     // TODO egifix-hibernateutil
     // HibernateUtil.getCurrentSession().persist(change);
     entityManager.persist(change);
     birthRegistrationService.save(stillBirthRegistration, workFlowType);
   } else if (getMode().equals(UNLOCK)) {
     birthRegistrationService.buildAdoptionDetial(stillBirthRegistration);
     buildRegistration();
     stillBirthRegistration.setPlaceType(bndCommonService.getPlaceType(placeTypeTemp));
     stillBirthRegistration.setStatus(
         bndCommonService.getStatusByModuleAndCode(
             BndConstants.STILLBIRTHREGISTRATION, BndConstants.APPROVED));
     final EgwSatuschange change = new EgwSatuschange();
     change.setFromstatus(
         bndCommonService
             .getStatusByModuleAndCode(BndConstants.STILLBIRTHREGISTRATION, BndConstants.LOCK)
             .getId());
     change.setTostatus(
         bndCommonService
             .getStatusByModuleAndCode(BndConstants.STILLBIRTHREGISTRATION, BndConstants.APPROVED)
             .getId());
     change.setModuleid(stillBirthRegistration.getId().intValue());
     change.setModuletype(BndConstants.STILLBIRTHREGISTRATIONMODULE);
     //             change.setCreatedby(EgovThreadLocals.getUserId());
     // TODO egifix-hibernateutil
     // HibernateUtil.getCurrentSession().persist(change);
     entityManager.persist(change);
     birthRegistrationService.save(stillBirthRegistration, workFlowType);
   } else {
     saveOrUpdate();
     if (BndConstants.APPROVED.equalsIgnoreCase(stillBirthRegistration.getStatus().getCode())
         && stillBirthRegistration
             .getRegistrationNo()
             .contains(BndConstants.HOSPITALSTILLBIRTHSUFFIX))
       numberGenerationService.reGenerateStillBirthRegistrationNumber(stillBirthRegistration);
     if (remarksHistory != null && !"".equals(remarksHistory))
       bndCommonService.saveHistory(
           stillBirthRegistration, BndConstants.STILLBIRTHREGISTRATION, remarksHistory);
   }
   mode = VIEW;
   return NEW;
 }