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("В отделении уже оформлен случай родов!!");
   }
 }
  public void intercept(IEntityForm aForm, Object aEntity, InterceptorContext aContext) {
    PrescriptListForm form = (PrescriptListForm) aForm;
    PrescriptList prescriptList = (PrescriptList) aEntity;
    prescriptList.setCreateUsername(aContext.getSessionContext().getCallerPrincipal().toString());
    java.sql.Date cur = new java.sql.Date(new java.util.Date().getTime());
    prescriptList.setCreateDate(cur);
    prescriptList.setEditDate(cur);

    ModePrescriptionForm modeForm = form.getModeForm();
    // Сохранение режима
    if (aContext
            .getSessionContext()
            .isCallerInRole("/Policy/Mis/Prescription/ModePrescription/Create")
        && modeForm != null
        && modeForm.getModePrescription() != null
        && !modeForm.equals(Long.valueOf(0))
        && modeForm.getPlanStartDate() != null
        && !modeForm.getPlanStartDate().equals("")) {

      modeForm.setPrescriptionList(prescriptList.getId());
      try {

        EjbInjection.getInstance().getLocalService(IParentEntityFormService.class).create(modeForm);
      } catch (Exception e) {
      }
    }
    DietPrescriptionForm dietForm = form.getDietForm();
    // Сохранение диеты
    if (aContext
            .getSessionContext()
            .isCallerInRole("/Policy/Mis/Prescription/DietPrescription/Create")
        && dietForm != null
        && dietForm.getDiet() != null
        && !dietForm.getDiet().equals(Long.valueOf(0))
        && dietForm.getPlanStartDate() != null
        && !dietForm.getPlanStartDate().equals("")) {
      dietForm.setPrescriptionList(prescriptList.getId());
      try {
        EjbInjection.getInstance().getLocalService(IParentEntityFormService.class).create(dietForm);
      } catch (Exception e) {
      }
    }
    // Сохранение назначение лекарственных средств

  }
示例#3
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();
  }