Exemplo n.º 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;
  }
Exemplo n.º 2
0
 public void visible(final boolean mode) {
   if (mode) {
     tv.refresh(true);
     ElexisEventDispatcher.getInstance().addListeners(eeli_fall, eeli_pat);
   } else {
     ElexisEventDispatcher.getInstance().removeListeners(eeli_fall, eeli_pat);
   }
 }
Exemplo n.º 3
0
 public void visible(boolean mode) {
   if (mode) {
     ElexisEventDispatcher.getInstance().addListeners(this);
     catchElexisEvent(template);
   } else {
     ElexisEventDispatcher.getInstance().removeListeners(this);
   }
 }
Exemplo n.º 4
0
 @Override
 public void setFocus() {
   Fall currentFall = (Fall) ElexisEventDispatcher.getSelected(Fall.class);
   if (currentFall != null) {
     tv.setSelection(new StructuredSelection(currentFall));
   }
 }
Exemplo n.º 5
0
  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);
      }
    }
  }
Exemplo n.º 6
0
  private void loadArticlesUsedOnSelectedDay() {
    String date =
        dtDate.getYear()
            + String.format("%02d", dtDate.getMonth() + 1)
            + String.format("%02d", dtDate.getDay());

    Query<Konsultation> qbe = new Query<Konsultation>(Konsultation.class);
    qbe.add(Konsultation.FLD_DATE, Query.EQUALS, date);
    List<Konsultation> cons = qbe.execute();

    StringBuilder sb = new StringBuilder();

    for (Konsultation c : cons) {
      List<Verrechnet> leistungen = c.getLeistungen();
      for (Verrechnet v : leistungen) {
        IVerrechenbar vv = v.getVerrechenbar();
        if (vv instanceof Artikel) {
          Artikel art = (Artikel) vv;
          Mandant mandator = ElexisEventDispatcher.getSelectedMandator();
          IStockEntry stockEntry =
              CoreHub.getStockService()
                  .findPreferredStockEntryForArticle(
                      art.storeToString(), (mandator != null) ? mandator.getId() : null);
          if (stockEntry != null) {
            StockEntry se = (StockEntry) stockEntry;
            currOrder.addBestellungEntry(
                se.getArticle(), se.getStock(), se.getProvider(), v.getZahl());
          } else {
            sb.append(art.getLabel() + " ist kein Lagerartikel.\n");
          }
        }
      }
    }
  }
 public WhichPatientDialog(Shell parentShell, Patient sysmexPat) {
   super(parentShell);
   this.sysmexPat = sysmexPat;
   // only add selected pat if he/she is not null and not equal the sysmex patient
   Patient tmpPat = ElexisEventDispatcher.getSelectedPatient();
   if (tmpPat != null && !tmpPat.equals(sysmexPat)) {
     selectedPat = tmpPat;
   }
 }
Exemplo n.º 8
0
 public void selectionChanged(SelectionChangedEvent event) {
   Object[] sel = getSelection();
   if (sel != null && sel.length != 0) {
     if (sel[0] instanceof Tree<?>) {
       sel[0] = ((Tree<?>) sel[0]).contents;
     }
     if (sel[0] instanceof PersistentObject) {
       ElexisEventDispatcher.fireSelectionEvent((PersistentObject) sel[0]);
     }
   }
   if (selChangeListener != null) selChangeListener.selectionChanged(event);
 }
Exemplo n.º 9
0
 @Override
 public void visible(boolean mode) {
   if (mode == true) {
     Problem problem = IatrixEventHelper.getSelectedProblem();
     if (problem != null) {
       // check whether Problem matches the currently selected patient
       Patient selectedPatient = ElexisEventDispatcher.getSelectedPatient();
       if (selectedPatient != null
           && problem.getPatient().getId().equals(selectedPatient.getId())) {
         setProblem(problem);
       } else {
         setProblem(null);
       }
     } else {
       setProblem(null);
     }
     ElexisEventDispatcher.getInstance().addListeners(eeli_problem, eeli_patient);
   } else {
     ElexisEventDispatcher.getInstance().removeListeners(eeli_problem, eeli_patient);
   }
 }
Exemplo n.º 10
0
  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$
      }
    }
  }
Exemplo n.º 11
0
 public boolean accept(PersistentObject o) {
   if (ElexisEventDispatcher.getSelectedPatient() != null) {
     if (o instanceof Artikel) {
       return !((Artikel) o).isProduct();
     }
     if (o instanceof IVerrechenbar) {
       return true;
     }
     if (o instanceof Leistungsblock) {
       return true;
     }
     if (o instanceof Prescription) {
       Prescription p = ((Prescription) o);
       return (p.getArtikel() != null && !p.getArtikel().isProduct());
     }
   }
   return false;
 }
Exemplo n.º 12
0
 public void runInUi(ElexisEvent ev) {
   tv.refresh();
   Fall currentFall = (Fall) ElexisEventDispatcher.getSelected(Fall.class);
   if (currentFall != null) tv.setSelection(new StructuredSelection(currentFall));
 }
Exemplo n.º 13
0
 void setFall(final Fall fall) {
   mine = fall;
   ElexisEventDispatcher.reload(Konsultation.class);
 }
Exemplo n.º 14
0
  /** print a bill into a text container */
  public Result<Rechnung> doPrint(final Rechnung rn) {
    nf.setMinimumFractionDigits(2);
    nf.setMaximumFractionDigits(2);

    Result<Rechnung> ret = new Result<Rechnung>();
    fall = rn.getFall();
    ElexisEventDispatcher.fireSelectionEvent(fall);
    Kontakt adressat = fall.getGarant(); // .getRequiredContact("Rechnungsempfänger");
    if (!adressat.isValid()) {
      adressat = fall.getPatient();
    }
    tc.createFromTemplateName(
        null,
        PrivaterechnungTextTemplateRequirement.getBillTemplate(),
        Brief.RECHNUNG,
        adressat,
        rn.getNr());
    fillFields();
    List<Konsultation> kons = rn.getKonsultationen();
    Collections.sort(
        kons,
        new Comparator<Konsultation>() {
          TimeTool t0 = new TimeTool();
          TimeTool t1 = new TimeTool();

          public int compare(final Konsultation arg0, final Konsultation arg1) {
            t0.set(arg0.getDatum());
            t1.set(arg1.getDatum());
            return t0.compareTo(t1);
          }
        });
    Object pos = null;
    // Das Wort Leistungen soll jeder selbst in die Vorlage nehmen:
    // pos = tc.getPlugin().insertText("[Leistungen]", "Leistungen\n\n", SWT.LEFT);
    pos = tc.getPlugin().insertText("[Leistungen]", "", SWT.LEFT);
    Money sum = new Money();
    VatRateSum vatSummer = new VatRateSum();
    for (Konsultation k : kons) {
      tc.getPlugin().setStyle(SWT.BOLD);
      // print date
      pos =
          tc.getPlugin()
              .insertText(
                  pos, new TimeTool(k.getDatum()).toString(TimeTool.DATE_GER) + "\n", SWT.LEFT);
      tc.getPlugin().setStyle(SWT.NORMAL);
      // print header for Leistungen
      StringBuilder header = new StringBuilder();
      header
          .append("Anzahl")
          .append("\t")
          .append("MWSt.")
          .append("\t")
          .append("Einzelpreis")
          .append("\t")
          .append("Betrag")
          .append("\n\n");
      pos = tc.getPlugin().insertText(pos, header.toString(), SWT.LEFT);
      // print info for each Leistung
      for (Verrechnet vv : k.getLeistungen()) {
        tc.getPlugin().setStyle(SWT.BOLD);
        pos = tc.getPlugin().insertText(pos, "- " + vv.getText() + "\n", SWT.LEFT);
        tc.getPlugin().setStyle(SWT.NORMAL);

        Money preis = vv.getNettoPreis();
        int zahl = vv.getZahl();
        Money subtotal = new Money(preis);
        subtotal.multiply(zahl);
        StringBuilder sb = new StringBuilder();
        sb.append(zahl)
            .append("\t")
            .append(getVatRate(vv, subtotal, vatSummer))
            .append("\t")
            .append(preis.getAmountAsString())
            .append("\t")
            .append(subtotal.getAmountAsString())
            .append("\n");
        pos = tc.getPlugin().insertText(pos, sb.toString(), SWT.LEFT);
        sum.addMoney(subtotal);
      }
    }
    pos =
        tc.getPlugin()
            .insertText(
                pos,
                "____________________________________________________________________\nTotal:\t\t\t"
                    + sum.getAmountAsString(),
                SWT.LEFT);

    // print vat info of whole bill
    String vatNumber = rn.getMandant().getRechnungssteller().getInfoString(VAT_MANDANTVATNUMBER);
    tc.getPlugin().setStyle(SWT.BOLD);
    pos = tc.getPlugin().insertText(pos, "\n\nMWSt.Nr. \t", SWT.LEFT);
    tc.getPlugin().setStyle(SWT.NORMAL);
    if (vatNumber != null && vatNumber.length() > 0)
      pos = tc.getPlugin().insertText(pos, vatNumber + "\n", SWT.LEFT);
    else pos = tc.getPlugin().insertText(pos, "keine\n", SWT.LEFT);

    tc.getPlugin().setStyle(SWT.BOLD);
    pos = tc.getPlugin().insertText(pos, "\nSatz\tBetrag\tMWSt\n", SWT.LEFT);
    tc.getPlugin().setStyle(SWT.NORMAL);

    VatRateElement[] vatValues = vatSummer.rates.values().toArray(new VatRateElement[0]);
    Arrays.sort(vatValues);
    for (VatRateElement rate : vatValues) {
      StringBuilder sb = new StringBuilder();
      sb.append(nf.format(rate.scale))
          .append("\t")
          .append(nf.format(rate.sumamount))
          .append("\t")
          .append(nf.format(rate.sumvat))
          .append("\n");
      pos = tc.getPlugin().insertText(pos, sb.toString(), SWT.LEFT);
    }

    tc.getPlugin().setStyle(SWT.BOLD);
    pos =
        tc.getPlugin()
            .insertText(
                pos,
                "\nTotal\t" + sum.getAmountAsString() + "\t" + nf.format(vatSummer.sumvat) + "\n",
                SWT.LEFT);
    tc.getPlugin().setStyle(SWT.NORMAL);

    String toPrinter = CoreHub.localCfg.get("Drucker/A4/Name", null);
    tc.getPlugin().print(toPrinter, null, false);
    tc.createFromTemplateName(null, templateESR, Brief.RECHNUNG, adressat, rn.getNr());
    fillFields();
    ESR esr =
        new ESR(
            CoreHub.globalCfg.get(PreferenceConstants.esrIdentity, ""),
            CoreHub.globalCfg.get(PreferenceConstants.esrUser, ""),
            rn.getRnId(),
            27);
    Kontakt bank = Kontakt.load(CoreHub.globalCfg.get(PreferenceConstants.cfgBank, ""));
    if (!bank.isValid()) {
      SWTHelper.showError("Keine Bank", "Bitte geben Sie eine Bank für die Zahlungen ein");
    }
    esr.printBESR(bank, adressat, rn.getMandant(), sum.getCentsAsString(), tc);
    tc.replace("\\[Leistungen\\]", sum.getAmountAsString());
    tc.getPlugin().print(CoreHub.localCfg.get("Drucker/A4ESR/Name", null), null, false);
    tc.getPlugin().setFont(null, SWT.NORMAL, 0.0f);
    return ret;
  }
Exemplo n.º 15
0
  public VerrechnungsDisplay(final IWorkbenchPage p, Composite parent, int style) {
    super(parent, style);
    setLayout(new GridLayout());
    this.page = p;
    defaultRGB = UiDesk.createColor(new RGB(255, 255, 255));

    hVer =
        UiDesk.getToolkit()
            .createHyperlink(this, Messages.VerrechnungsDisplay_billing, SWT.NONE); // $NON-NLS-1$
    hVer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    hVer.addHyperlinkListener(
        new HyperlinkAdapter() {
          @Override
          public void linkActivated(HyperlinkEvent e) {
            try {
              if (StringTool.isNothing(LeistungenView.ID)) {
                SWTHelper.alert(
                    Messages.VerrechnungsDisplay_error,
                    "LeistungenView.ID"); //$NON-NLS-1$ //$NON-NLS-2$
              }
              page.showView(LeistungenView.ID);
              CodeSelectorHandler.getInstance().setCodeSelectorTarget(dropTarget);
            } catch (Exception ex) {
              ElexisStatus status =
                  new ElexisStatus(
                      ElexisStatus.ERROR,
                      Hub.PLUGIN_ID,
                      ElexisStatus.CODE_NONE,
                      Messages.VerrechnungsDisplay_errorStartingCodeWindow + ex.getMessage(),
                      ex,
                      ElexisStatus.LOG_ERRORS);
              StatusManager.getManager().handle(status, StatusManager.SHOW);
            }
          }
        });
    makeActions();
    tVerr = UiDesk.getToolkit().createTable(this, SWT.MULTI);
    tVerr.setLayoutData(new GridData(GridData.FILL_BOTH));
    tVerr.setMenu(createVerrMenu());
    // dummy table viewer needed for SelectionsProvider for Menu
    viewer = new TableViewer(tVerr);
    // add selection event to table which provides selection to ElexisEventDispatcher
    tVerr.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            TableItem[] selection = tVerr.getSelection();
            Verrechnet verrechnet = (Verrechnet) selection[0].getData();
            ElexisEventDispatcher.fireSelectionEvent(verrechnet);

            applyMedicationAction.setEnabled(false);

            IVerrechenbar verrechenbar = verrechnet.getVerrechenbar();
            if (verrechenbar != null && (verrechenbar instanceof Artikel)) {
              applyMedicationAction.setEnabled(true);
            }
          }
        });
    tVerr.addKeyListener(
        new KeyListener() {
          @Override
          public void keyReleased(KeyEvent e) {}

          @Override
          public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.DEL) {
              if (tVerr.getSelectionIndices().length >= 1 && removeAction != null) {
                removeAction.run();
              }
            }
          }
        });
    dropTarget =
        new PersistentObjectDropTarget(
            Messages.VerrechnungsDisplay_doBill, tVerr, new DropReceiver()); // $NON-NLS-1$
    // refresh the table if a update to a Verrechnet occurs
    ElexisEventDispatcher.getInstance()
        .addListeners(
            new ElexisUiEventListenerImpl(Verrechnet.class, ElexisEvent.EVENT_UPDATE) {
              @Override
              public void runInUi(ElexisEvent ev) {
                Konsultation actKons =
                    (Konsultation) ElexisEventDispatcher.getSelected(Konsultation.class);
                setLeistungen(actKons);
              }
            });

    ElexisEventDispatcher.getInstance().addListeners(eeli_update);
  }
Exemplo n.º 16
0
 @Override
 public void runInUi(ElexisEvent ev) {
   Konsultation actKons =
       (Konsultation) ElexisEventDispatcher.getSelected(Konsultation.class);
   setLeistungen(actKons);
 }