public void intercept(
     IEntityForm aForm, Object aEntity, Object aParentId, InterceptorContext aContext) {
   if (aForm instanceof ChildBirthForm) {
     ChildBirthForm form = (ChildBirthForm) aForm;
     List<Object[]> list =
         aContext
             .getEntityManager()
             .createNativeQuery(
                 "select slo.id,ml.id from medcase slo left join mislpu ml on ml.id=slo.department_id where  slo.id='"
                     + form.getMedCase()
                     + "' and ml.isMaternityWard='1'")
             .getResultList();
     if (list.size() == 0)
       throw new IllegalStateException(
           "Описание родов может быть заведена только в родильном отделении!!!");
     list =
         aContext
             .getEntityManager()
             .createNativeQuery(
                 "select cb.id from childbirth cb where  cb.medcase_id='"
                     + form.getMedCase()
                     + "'")
             .getResultList();
     if (list.size() > 0)
       throw new IllegalStateException("В отделении уже оформлен случай родов!!");
   }
 }
예제 #2
0
  public void intercept(IEntityForm aForm, Object aEntity, InterceptorContext aContext) {
    DepartmentMedCaseForm form = (DepartmentMedCaseForm) aForm;
    if (CAN_DEBUG) LOG.debug("Проверка правильности введенных данных");
    EntityManager manager = aContext.getEntityManager();
    DepartmentMedCase medCase = (DepartmentMedCase) aEntity;
    String dateFinish = "null";
    if (medCase.getDateFinish() != null) {
      dateFinish =
          new StringBuilder()
              .append("to_date('")
              .append(DateFormat.formatToDate(medCase.getDateFinish()))
              .append("','dd.mm.yyyy')")
              .toString();
    }
    String timeFinish = "null";
    if (medCase.getDischargeTime() != null) {
      timeFinish =
          new StringBuilder()
              .append("'")
              .append(DateFormat.formatToTime(medCase.getDischargeTime()))
              .append("'")
              .toString();
    }
    StringBuilder sqlupdate = new StringBuilder();

    if (!isDiagnosisAllowed(
        form.getClinicalMkb(),
        form.getDepartment(),
        form.getPatient(),
        form.getServiceStream(),
        null,
        null,
        manager)) {
      throw new IllegalStateException("Данный диагноз запрещен в отделении!");
    }
    sqlupdate.append(
        "update MedCase set dateFinish="
            + dateFinish
            + ", dischargeTime="
            + timeFinish
            + " where parent_id=:parent and DTYPE='DepartmentMedCase' and (dateFinish is not null or (transferDate is null and dateFinish is null))");

    manager
        .createNativeQuery(sqlupdate.toString())
        .setParameter("parent", form.getId())
        .executeUpdate();
  }