Beispiel #1
0
  /**
   * execute a script entered as string with the given interpreter
   *
   * @param objects optional Objects to replace in Variables like [Fall.Grund] in the script
   * @param params optional parameters. These can be of the form <i>name=value</i> or <i>value</i>.
   *     if no name is given, the variables will be inserted for $1, $2 ... in the script. If a name
   *     is given, $names in the script will be replaced with the respective values.
   * @return The result of the script interpreter
   * @throws ElexisException
   */
  public static Object execute(
      Interpreter scripter, String script, String params, PersistentObject... objects)
      throws ElexisException {
    if (!StringTool.isNothing(script)) {
      if (params != null) {
        String var = "\\$";
        String[] parameters = params.split("\\s*,\\s*");
        for (int i = 0; i < parameters.length; i++) {
          String parm = parameters[i].trim();
          String[] p = parm.split("=");
          if (p.length == 2) {
            script = script.replaceAll("\\" + p[0], p[1]);
          } else {
            script = script.replaceAll(var + i, p[0]);
          }
        }
      }
      String parsed = parse(script, objects);
      scripter.setValue("actPatient", ElexisEventDispatcher.getSelectedPatient());
      scripter.setValue("actFall", ElexisEventDispatcher.getSelected(Fall.class));
      scripter.setValue("actKons", ElexisEventDispatcher.getSelected(Konsultation.class));
      scripter.setValue("actMandant", CoreHub.actMandant);
      scripter.setValue("actUser", CoreHub.actUser);

      scripter.setValue("Elexis", CoreHub.plugin);
      return scripter.run(parsed, true);
    }
    return null;
  }
Beispiel #2
0
 @Override
 public void setFocus() {
   Fall currentFall = (Fall) ElexisEventDispatcher.getSelected(Fall.class);
   if (currentFall != null) {
     tv.setSelection(new StructuredSelection(currentFall));
   }
 }
  public void addPersistentObject(PersistentObject o) {
    Konsultation actKons = (Konsultation) ElexisEventDispatcher.getSelected(Konsultation.class);
    if (actKons != null) {
      if (o instanceof Prescription) {
        Prescription presc = (Prescription) o;
        o = presc.getArtikel();
      }
      if (o instanceof IVerrechenbar) {
        if (CoreHub.acl.request(AccessControlDefaults.LSTG_VERRECHNEN) == false) {
          SWTHelper.alert(
              Messages.VerrechnungsDisplay_missingRightsCaption, // $NON-NLS-1$
              Messages.VerrechnungsDisplay_missingRightsBody); // $NON-NLS-1$
        } else {
          Result<IVerrechenbar> result = actKons.addLeistung((IVerrechenbar) o);

          if (!result.isOK()) {
            SWTHelper.alert(
                Messages.VerrechnungsDisplay_imvalidBilling, result.toString()); // $NON-NLS-1$
          }
          setLeistungen(actKons);
        }
      } else if (o instanceof IDiagnose) {
        actKons.addDiagnose((IDiagnose) o);
      }
    }
  }
  private void changeQuantityDialog(String p, Verrechnet v) {
    InputDialog dlg =
        new InputDialog(
            UiDesk.getTopShell(),
            Messages.VerrechnungsDisplay_changeNumberCaption, // $NON-NLS-1$
            Messages.VerrechnungsDisplay_changeNumberBody, // $NON-NLS-1$
            p,
            null);
    if (dlg.open() == Dialog.OK) {
      try {
        String val = dlg.getValue();
        if (!StringTool.isNothing(val)) {
          int changeAnzahl;
          double secondaryScaleFactor = 1.0;
          String text = v.getVerrechenbar().getText();

          if (val.indexOf(StringConstants.SLASH) > 0) {
            changeAnzahl = 1;
            String[] frac = val.split(StringConstants.SLASH);
            secondaryScaleFactor = Double.parseDouble(frac[0]) / Double.parseDouble(frac[1]);
            text =
                v.getText()
                    + " ("
                    + val
                    + Messages.VerrechnungsDisplay_Orininalpackungen; // $NON-NLS-1$
          } else if (val.indexOf('.') > 0) {
            changeAnzahl = 1;
            secondaryScaleFactor = Double.parseDouble(val);
            text = v.getText() + " (" + Double.toString(secondaryScaleFactor) + ")";
          } else {
            changeAnzahl = Integer.parseInt(dlg.getValue());
          }

          IStatus ret = v.changeAnzahlValidated(changeAnzahl);
          if (ret.isOK()) {
            v.setSecondaryScaleFactor(secondaryScaleFactor);
            v.setText(text);
          } else {
            SWTHelper.showError(Messages.VerrechnungsDisplay_error, ret.getMessage());
          }
        }
        setLeistungen((Konsultation) ElexisEventDispatcher.getSelected(Konsultation.class));
      } catch (NumberFormatException ne) {
        SWTHelper.showError(
            Messages.VerrechnungsDisplay_invalidEntryCaption, // $NON-NLS-1$
            Messages.VerrechnungsDisplay_invalidEntryBody); // $NON-NLS-1$
      }
    }
  }
Beispiel #5
0
 public void runInUi(ElexisEvent ev) {
   tv.refresh();
   Fall currentFall = (Fall) ElexisEventDispatcher.getSelected(Fall.class);
   if (currentFall != null) tv.setSelection(new StructuredSelection(currentFall));
 }
 @Override
 public void runInUi(ElexisEvent ev) {
   Konsultation actKons =
       (Konsultation) ElexisEventDispatcher.getSelected(Konsultation.class);
   setLeistungen(actKons);
 }