Ejemplo n.º 1
0
 /**
  * This constructor is more critical than the previous one
  *
  * @param name will be checked for non-alphabetic characters and may not be empty
  * @param vorname will be checked for non alphabetic characters but may be empty
  * @param gebDat will be checked for unplausible values but may be null
  * @param s will be checked for undefined values and may not be empty
  * @throws PersonDataException
  */
 public Person(String name, String vorname, TimeTool gebDat, String s) throws PersonDataException {
   name = name.trim();
   vorname = vorname.trim();
   if ((StringTool.isNothing(name))
       || (!name.matches("[" + StringTool.wordChars + "\\s-]+"))) { // $NON-NLS-1$ //$NON-NLS-2$
     throw new PersonDataException(PersonDataException.CAUSE.LASTNAME);
   }
   if ((!StringTool.isNothing(vorname))
       && (!vorname.matches("[" + StringTool.wordChars + "\\s-]+"))) { // $NON-NLS-1$ //$NON-NLS-2$
     throw new PersonDataException(PersonDataException.CAUSE.FIRSTNAME);
   }
   String dat = StringTool.leer;
   if (gebDat != null) {
     TimeTool now = new TimeTool();
     int myYear = now.get(TimeTool.YEAR);
     int oYear = gebDat.get(TimeTool.YEAR);
     if (oYear > myYear || oYear < myYear - 120) {
       throw new PersonDataException(PersonDataException.CAUSE.BIRTHDATE);
     }
     dat = gebDat.toString(TimeTool.DATE_COMPACT);
   }
   if (!s.equalsIgnoreCase(Person.MALE) && !s.equalsIgnoreCase(Person.FEMALE)) {
     throw new PersonDataException(PersonDataException.CAUSE.SEX);
   }
   create(null);
   String[] fields = new String[] {NAME, FIRSTNAME, BIRTHDATE, SEX};
   String[] vals = new String[] {name, vorname, dat, s};
   set(fields, vals);
 }
Ejemplo n.º 2
0
 /**
  * Return externals references associated with this Note
  *
  * @return a List with urls of external refs
  */
 public List<String> getRefs() {
   String all = get(FLD_REFS);
   if (StringTool.isNothing(all)) {
     return new ArrayList<String>();
   }
   return StringTool.splitAL(all, StringConstants.COMMA);
 }
Ejemplo n.º 3
0
  public boolean importKK(final String file) {
    ExcelWrapper exw = new ExcelWrapper();
    exw.setFieldTypes(
        new Class[] {
          Integer.class,
          String.class,
          String.class,
          String.class,
          String.class,
          Integer.class,
          Integer.class
        });
    exw.load(file, 0);

    String[] row;
    for (int i = exw.getFirstRow() + 1; i <= exw.getLastRow(); i++) {
      row = exw.getRow(i).toArray(new String[0]);
      if (row == null) {
        continue;
      }
      if (row.length != 7) {
        continue;
      }
      log.info(Messages.KontaktImporterBlatt_Importing + StringTool.join(row, " "));
      // Please keep in sync with doc/import.textile !!
      String bagnr = StringTool.getSafe(row, 0);
      String name = StringTool.getSafe(row, 1);
      String zweig = StringTool.getSafe(row, 2);
      String adresse = StringTool.getSafe(row, 3);
      String typ = StringTool.getSafe(row, 4);
      String EANInsurance = StringTool.getSafe(row, 5);
      String EANReceiver = StringTool.getSafe(row, 6);
      String[] adr = splitAdress(adresse);
      Organisation kk =
          KontaktMatcher.findOrganisation(name, null, adr[0], adr[1], adr[2], CreateMode.CREATE);
      if (kk == null) {
        return false;
      }
      kk.setInfoElement("EAN", EANInsurance); // $NON-NLS-1$
      kk.setInfoElement("BAGNr", bagnr); // $NON-NLS-1$
      kk.set("Bezeichnung2", zweig); // $NON-NLS-1$
      kk.set(
          "Kuerzel",
          StringTool.limitLength(
              Messages.KontaktImporterBlatt_KKKuerzel // $NON-NLS-1$
                  + StringTool.getFirstWord(name),
              39));
    }
    return true;
  }
Ejemplo n.º 4
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;
  }
Ejemplo n.º 5
0
 public VerifierContentProvider() {
   // TODO remove job from JobPool when it has finished.
   // for now, we just use unique names.
   String jobName = BASE_JOBNAME + " " + StringTool.unique(BASE_JOBNAME); // $NON-NLS-1$
   job = new DataLoader(jobName);
   globalJob = job;
   if (JobPool.getJobPool().getJob(job.getJobname()) == null) {
     JobPool.getJobPool().addJob(job);
   }
   job.addListener(this);
 }
Ejemplo n.º 6
0
  public Color getBackground(Object element, int columnIndex) {
    ESRRecord rec = (ESRRecord) element;

    if (rec.getRejectCode().equals(ESRRecord.REJECT.OK)) {
      if (StringTool.isNothing(rec.getGebucht())) {
        return Desk.getColor(Desk.COL_GREY);
      }
      return Desk.getColor(Desk.COL_WHITE);
    } else {
      return Desk.getColor(Desk.COL_RED);
    }
  }
Ejemplo n.º 7
0
 @Override
 public boolean equals(Object o) {
   if (o instanceof Node) {
     Node other = (Node) o;
     if (StringTool.compare(ch, other.ch) == true) {
       if (lfreq == other.lfreq) {
         return true;
       }
     }
   }
   return false;
 }
 @Override
 public Integer convertToEntityAttribute(String dbData) {
   if (StringTool.isNothing(dbData)) {
     return null;
   }
   try {
     return Integer.parseInt(dbData.trim());
   } catch (NumberFormatException nfe) {
     log.warn("Invalid int value [{}], returning null.", dbData, nfe);
   }
   return null;
 }
Ejemplo n.º 9
0
 /*
  * Einen String mit den Personalien holen.
  *
  * Ein allfälliger Titel wie Dr. med. kommt nach Name und Vorname, damit die Suche bei der
  * Patientsicht nach Namen und Person funktioniert
  */
 public String getPersonalia() {
   StringBuffer ret = new StringBuffer(200);
   String[] fields = new String[] {NAME, FIRSTNAME, BIRTHDATE, SEX, TITLE};
   String[] vals = new String[fields.length];
   get(fields, vals);
   ret.append(vals[0]);
   if (!StringTool.isNothing(vals[1])) {
     ret.append(StringTool.space).append(vals[1]);
   }
   if (StringTool.isNothing(vals[3])) {
     ret.append(StringTool.space);
   } else {
     ret.append(StringTool.space + "(").append(vals[3]).append(")," + StringTool.space);
   }
   if (!StringTool.isNothing(vals[2])) {
     ret.append(new TimeTool(vals[2]).toString(TimeTool.DATE_GER));
   }
   if (!StringTool.isNothing(vals[4])) {
     ret.append("," + StringTool.space).append(vals[4]);
   }
   return ret.toString();
 }
Ejemplo n.º 10
0
 public static Script create(String name, String contents) throws ElexisException {
   String mid = PREFIX + name;
   Script ret = new Script(mid);
   if (ret.state() == INEXISTENT) {
     ret.create(mid);
   } else if (ret.state() == DELETED) {
     ret.undelete();
   }
   if (StringTool.isNothing(contents)) {
     contents = "/* !BSH! */";
   }
   ret.putString(contents);
   return ret;
 }
Ejemplo n.º 11
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$
      }
    }
  }
Ejemplo n.º 12
0
  private void doShakeNames(IProgressMonitor monitor, int workUnits) {
    monitor.subTask("Anonymisiere Patienten und Kontakte");
    Query<Kontakt> qbe = new Query<Kontakt>(Kontakt.class);
    List<Kontakt> list = qbe.execute();
    int workPerName = (Math.round(workUnits * .8f) / list.size());
    Namen n = null;
    if (zufallsnamen) {
      n = new Namen();
    }
    monitor.worked(Math.round(workUnits * .2f));
    for (Kontakt k : list) {
      String vorname = "";
      // Mandanten behalten
      // if(k.get(Kontakt.FLD_IS_MANDATOR).equalsIgnoreCase(StringConstants.ONE))
      // continue;

      if (zufallsnamen) {
        k.set("Bezeichnung1", n.getRandomNachname());
      } else {
        k.set("Bezeichnung1", getWord());
      }

      if (zufallsnamen) {
        vorname = n.getRandomVorname();
      } else {
        vorname = getWord();
      }
      k.set("Bezeichnung2", vorname);

      if (k.istPerson()) {
        Person p = Person.load(k.getId());
        p.set(Person.SEX, StringTool.isFemale(vorname) ? Person.FEMALE : Person.MALE);
      }
      k.set(Kontakt.FLD_ANSCHRIFT, "");
      k.set(Kontakt.FLD_PHONE1, getPhone());
      k.set(Kontakt.FLD_PHONE2, Math.random() > 0.6 ? getPhone() : "");
      k.set(Kontakt.FLD_MOBILEPHONE, Math.random() > 0.5 ? getPhone() : "");
      k.set(Kontakt.FLD_E_MAIL, "");
      k.set(Kontakt.FLD_PLACE, "");
      k.set(Kontakt.FLD_STREET, "");
      k.set(Kontakt.FLD_ZIP, "");
      k.set(Kontakt.FLD_FAX, Math.random() > 0.8 ? getPhone() : "");
      if (monitor.isCanceled()) {
        break;
      }
      monitor.worked(workPerName);
    }
  }
Ejemplo n.º 13
0
 /** TODO: Kommentar */
 public static File resolveFile(String filepath) {
   Pattern p = Pattern.compile("%(.+?)%");
   Matcher m = p.matcher(filepath);
   Settings env = CfgSettings.open(".environment", "System Environment für java");
   while (m.find() == true) {
     String f = m.group(1);
     String rep = env.get(f, "");
     if (StringTool.isNothing(rep)) {
       rep = System.getenv(f);
     }
     filepath = m.replaceFirst(rep);
   }
   // pathname=pathname.replaceAll("%(.+?)%",env.get("$1",""));
   log.log("Abgeleiteter Pfadname: " + filepath, Log.DEBUGMSG);
   return new File(filepath);
 }
Ejemplo n.º 14
0
  public String getColumnText(Object element, int columnIndex) {
    String text = ""; // $NON-NLS-1$

    ESRRecord rec = (ESRRecord) element;

    switch (columnIndex) {
      case ESRView.DATUM_INDEX:
        text = rec.get("Datum"); // $NON-NLS-1$
        break;
      case ESRView.RN_NUMMER_INDEX:
        Rechnung rn = rec.getRechnung();
        if (rn != null) {
          text = rn.getNr();
        }
        break;
      case ESRView.BETRAG_INDEX:
        text = rec.getBetrag().getAmountAsString();
        break;
      case ESRView.EINGELESEN_INDEX:
        text = rec.getEinlesedatatum();
        break;
      case ESRView.VERRECHNET_INDEX:
        text = rec.getVerarbeitungsdatum();
        break;
      case ESRView.GUTGESCHRIEBEN_INDEX:
        text = rec.getValuta();
        break;
      case ESRView.PATIENT_INDEX:
        text = rec.getPatient().getLabel();
        break;
      case ESRView.BUCHUNG_INDEX:
        String dat = rec.getGebucht();
        if (StringTool.isNothing(dat)) {
          text = Messages.ESRView2_notbooked;
        } else {
          text = new TimeTool(dat).toString(TimeTool.DATE_GER);
        }
        break;
      case ESRView.DATEI_INDEX:
        text = rec.getFile();
        break;
    }

    return text;
  }
Ejemplo n.º 15
0
 static {
   addMapping(
       TABLENAME,
       PersistentObject.DATE_COMPOUND,
       "Eingelesen=S:D:EINGELESEN", //$NON-NLS-1$
       "Verarbeitet=S:D:VERARBEITET", //$NON-NLS-1$
       "Gutgeschrieben=S:D:GUTSCHRIFT", //$NON-NLS-1$
       "BetragInRp=BETRAGINRP", //$NON-NLS-1$
       CODE,
       RECHNUNGS_ID,
       PATIENT_ID,
       MANDANT_ID,
       FLD_REJECT_CODE,
       "Gebucht=S:D:GEBUCHT",
       "File" //$NON-NLS-1$ //$NON-NLS-2$
       );
   ESRRecord init = load("1"); // $NON-NLS-1$
   if (init == null) {
     createOrModifyTable(createDB);
   } else {
     String v = init.get("File"); // $NON-NLS-1$
     if (StringTool.isNothing(v)) { // < version 1
       getConnection()
           .exec(
               "ALTER TABLE "
                   + TABLENAME
                   + " ADD deleted CHAR(1) default '0';"); //$NON-NLS-1$ //$NON-NLS-2$
       init.set("File", VERSION); // $NON-NLS-1$
     } else {
       VersionInfo vi = new VersionInfo(v);
       if (vi.isOlder("2.0.0")) { // $NON-NLS-1$
         createOrModifyTable(upd2);
       }
       init.set("File", VERSION); // $NON-NLS-1$
     }
   }
 }
Ejemplo n.º 16
0
 /**
  * Enter keywords for this note
  *
  * @param kw a string with a comma separated list of keywords (at most 250 chars)
  */
 public void setKeywords(String kw) {
   set(FLD_KEYWORDS, StringTool.limitLength(kw.toLowerCase(), 250));
 }
Ejemplo n.º 17
0
  /**
   * Import a medicament from one row of the BAG-Medi file
   *
   * @param row
   *     <pre>
   * 		row[0] = ID,bzw Name
   * 		row[1] = Generikum
   * 		row[2] = Pharmacode
   * 	 	row[3] = BAG-Dossier
   * 		row[4] = Swissmedic-Nr
   * 		row[5] = Swissmedic-Liste
   * 	 	row[6]
   * 		row[7] = Namen
   * 		row[8] = EK-Preis
   *      row[9] = VK-Preis
   *      row[10]= Limitatio (Y/N)
   *      row[11]= LimitatioPts
   *      row[12]= Gruppe (optional)
   *      row[13]= Substance (optional)
   * </pre>
   *
   * @return
   */
  public static boolean importUpdate(final String[] row) throws ElexisException {
    String pharmacode = "0";
    BAGMedi imp = null;
    // Kein Pharmacode, dann nach Name suchen
    if (StringTool.isNothing(row[2].trim())) {
      String mid = qbe.findSingle(Artikel.FLD_NAME, "=", row[7]);
      if (mid != null) {
        imp = BAGMedi.load(mid);
      }
    } else {
      try {
        // strip leading zeroes
        int pcode = Integer.parseInt(row[2].trim());
        pharmacode = Integer.toString(pcode);

      } catch (Exception ex) {
        ExHandler.handle(ex);
        log.log(Level.WARNING, "Pharmacode falsch: " + row[2]);
      }

      qbe.clear(true);
      qbe.add(Artikel.FLD_SUB_ID, "=", pharmacode);
      qbe.or();
      qbe.add(Artikel.FLD_SUB_ID, Query.EQUALS, row[2].trim());
      List<Artikel> lArt = qbe.execute();
      if (lArt == null) {
        throw new ElexisException(
            BAGMediImporter.class,
            "Article list was null while scanning for " + pharmacode,
            ElexisException.EE_UNEXPECTED_RESPONSE,
            true);
      }
      if (lArt.size() > 1) {
        // Duplikate entfernen, genau einen gültigen und existierenden Artikel behalten
        Iterator<Artikel> it = lArt.iterator();
        boolean hasValid = false;
        Artikel res = null;
        while (it.hasNext()) {
          Artikel ax = it.next();
          if (hasValid || (!ax.isValid())) {
            if (res == null) {
              res = ax;
            }
            it.remove();
          } else {
            hasValid = true;
          }
        }
        if (!hasValid) {
          if (res != null) {
            if (res.isDeleted()) {
              res.undelete();
              lArt.add(res);
            }
          }
        }
      }
      imp = lArt.size() > 0 ? BAGMedi.load(lArt.get(0).getId()) : null;
    }
    if (imp == null || (!imp.isValid())) {
      imp = new BAGMedi(row[7], pharmacode);

      String sql =
          new StringBuilder()
              .append("INSERT INTO ")
              .append(BAGMedi.EXTTABLE)
              .append(" (ID) VALUES (")
              .append(imp.getWrappedId())
              .append(");")
              .toString();
      PersistentObject.getConnection().exec(sql);

    } else {

      String sql =
          new StringBuilder()
              .append("SELECT ID FROM ")
              .append(BAGMedi.EXTTABLE)
              .append(" WHERE ID=")
              .append(imp.getWrappedId())
              .toString();
      String extid = PersistentObject.getConnection().queryString(sql);
      if (extid == null) {
        sql =
            new StringBuilder()
                .append("INSERT INTO ")
                .append(BAGMedi.EXTTABLE)
                .append(" (ID) VALUES (")
                .append(imp.getWrappedId())
                .append(");")
                .toString();
        PersistentObject.getConnection().exec(sql);
      }
    }
    imp.update(row);
    return true;
  }
Ejemplo n.º 18
0
 /**
  * remove an external reference
  *
  * @param ref the reference to remove
  */
 public void removeRef(String ref) {
   List<String> refs = getRefs();
   refs.remove(ref);
   set(FLD_REFS, StringTool.join(refs, StringConstants.COMMA));
 }
Ejemplo n.º 19
0
  /**
   * Diese Methode erledigt den eigentlichen Aufbau der Seite. Here we create the contents of the
   * preference page
   */
  @SuppressWarnings("unchecked")
  @Override
  protected Control createContents(final Composite parent) {
    Composite ret = new Composite(parent, SWT.NONE);
    ret.setLayout(new GridLayout());
    ctabs = new CTabFolder(ret, SWT.NONE);
    ctabs.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    ctabs.setLayout(new FillLayout());
    setup = Messwert.getSetup();
    fields = setup.getMap("Befunde"); // $NON-NLS-1$
    names = (String) fields.get("names"); // $NON-NLS-1$
    if (!StringTool.isNothing(names)) {
      for (String f : names.split(Messwert.SETUP_SEPARATOR)) {
        CTabItem ci = new CTabItem(ctabs, SWT.NONE);
        ci.setText(f);
        PrefsPage fp = new PrefsPage(ctabs, fields, f);
        ci.setControl(fp);
      }
    }
    ctabs.setSelection(0);
    lastIDX = 0;
    ctabs.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent e) {
            if (lastIDX != -1) {
              flush(lastIDX);
              lastIDX = ctabs.getSelectionIndex();
            }
          }
        });

    Composite cButtons = new Composite(ret, SWT.NONE);
    cButtons.setLayout(new FillLayout());
    Button bAdd = new Button(cButtons, SWT.PUSH);
    bAdd.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent e) {
            InputDialog id =
                new InputDialog(
                    getShell(),
                    Messages.getString("BefundePrefs.enterNameCaption"),
                    Messages.getString("BefundePrefs.enterNameMessage"),
                    "",
                    null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            if (id.open() == Dialog.OK) {
              String name = id.getValue();
              if (StringTool.isNothing(names)) {
                names = name;
              } else {
                names += Messwert.SETUP_SEPARATOR + name;
              }
              fields.put("names", names); // $NON-NLS-1$
              CTabItem ci = new CTabItem(ctabs, SWT.NONE);
              ci.setText(name);
              PrefsPage fp = new PrefsPage(ctabs, fields, name);
              ci.setControl(fp);
              ctabs.setSelection(ci);
            }
          }
        });
    bAdd.setText(Messages.getString("BefundePrefs.add")); // $NON-NLS-1$

    Button bRemove = new Button(cButtons, SWT.PUSH);
    bRemove.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent e) {
            CTabItem ci = ctabs.getSelection();
            if (ci != null) {
              PrefsPage pp = (PrefsPage) ci.getControl();
              if (pp.remove()) {
                names = names.replaceFirst(ci.getText(), ""); // $NON-NLS-1$
                names =
                    names.replaceAll(
                        Messwert.SETUP_SEPARATOR + Messwert.SETUP_SEPARATOR,
                        Messwert.SETUP_SEPARATOR);
                names.replaceFirst(Messwert.SETUP_SEPARATOR + "$", ""); // $NON-NLS-1$ //$NON-NLS-2$
                names =
                    names.replaceFirst(
                        "^" + Messwert.SETUP_SEPARATOR, ""); // $NON-NLS-1$ //$NON-NLS-2$
                fields.put("names", names); // $NON-NLS-1$
                lastIDX = -1;
                ci.dispose();
                ctabs.setSelection(0);
              }
            }
          }
        });
    bRemove.setText(Messages.getString("BefundePrefs.deleteText")); // $NON-NLS-1$
    if (!Hub.acl.request(ACLContributor.DELETE_PARAM)) {
      bRemove.setEnabled(false);
    }
    return ret;
  }