Ejemplo n.º 1
0
  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append(labItem.getLabel()).append(", date ").append(getDate().toString(TimeTool.TIMESTAMP));

    if (refMale != null) {
      sb.append(" refm ").append(refMale);
    }
    if (refFemale != null) {
      sb.append(" reff ").append(refFemale);
    }
    if (unit != null) {
      sb.append(" unit ").append(unit);
    }
    if (analyseTime != null) {
      sb.append(" aTime ").append(analyseTime.toString(TimeTool.TIMESTAMP));
    }
    if (observationTime != null) {
      sb.append(" oTime ").append(observationTime.toString(TimeTool.TIMESTAMP));
    }
    if (transmissionTime != null) {
      sb.append(" tTime ").append(transmissionTime.toString(TimeTool.TIMESTAMP));
    }

    sb.append(" res ").append(getResult());
    return sb.toString();
  }
Ejemplo n.º 2
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);
 }
  @Override
  public Patient resolvePatient(String firstname, String lastname, String birthDate) {
    // resolve with full data
    Patient pat =
        KontaktMatcher.findPatient(
            lastname, firstname, birthDate, "", "", "", "", "", CreateMode.FAIL);
    // try to resolve with only the beginning of the name
    if (pat == null) {
      String shortLastname = lastname;
      String shortFirstname = firstname;
      if (lastname.length() > 3) {
        shortLastname = lastname.substring(0, 3);
      }
      if (firstname.length() > 3) {
        shortFirstname = firstname.substring(0, 3);
      }
      pat =
          KontaktMatcher.findPatient(
              shortLastname, shortFirstname, birthDate, "", "", "", "", "", CreateMode.FAIL);
    }
    // user decides
    if (pat == null) {
      convertTool.set(birthDate);
      String birthStr = convertTool.toString(TimeTool.DATE_GER);
      pat =
          (Patient)
              KontaktSelektor.showInSync(
                  Patient.class,
                  Messages.HL7_SelectPatient,
                  Messages.HL7_WhoIs + lastname + " " + firstname + " ," + birthStr + "?");
    }

    return pat;
  }
  @Override
  public void okPressed() {
    // Eingaben pruefen
    Date d = datum.getDate();
    if (d == null || d.compareTo(new Date()) > 0) {
      setMessage("Es muss ein Datum ausgewählt werden. Darf nicht in " + "der Zukunft liegen.");
      return;
    }
    TimeTool tt;
    try {
      String sZeit = zeit.getText();
      validateTime(sZeit);
      tt = new TimeTool(sZeit);
    } catch (TimeFormatException tfe) {
      setMessage("Es muss eine gültige Startzeit (hh:mm) eingegeben " + "werden.");
      return;
    }

    // Neue kons anlegen falls noetig
    if (kons == null) {
      kons = fall.neueKonsultation();
      data = new KonsData(kons);
      ElexisEventDispatcher.fireSelectionEvent(kons);
    }

    // Eingaben speichern
    data.setKonsBeginn(tt.getTimeInMillis());
    kons.setDatum(new TimeTool(d.getTime()).toString(TimeTool.DATE_GER), false);
    data.setKonsTyp(typenI[typ.getSelectionIndex()]);
    close();
  }
Ejemplo n.º 5
0
  public static ch.elexis.data.Patient getElexisPatient(Patient ehcPatient) {
    // try to look up via ids
    List<Identificator> ids = ehcPatient.getIds();
    for (Identificator identificator : ids) {
      String idRoot = identificator.getRoot();
      if (idRoot.equals(CodeSystems.SwissSSNDeprecated.getCodeSystemId())
          || idRoot.equals(CodeSystems.SwissSSN.getCodeSystemId())) {
        IPersistentObject ret = Xid.findObject(Xid.DOMAIN_AHV, identificator.getExtension());
        if (ret instanceof Kontakt) {
          if (((Kontakt) ret).istPatient()) {
            return ch.elexis.data.Patient.load(ret.getId());
          }
        }
        System.out.println("foud ret " + ret);
        if (ret instanceof ch.elexis.data.Patient) {
          return (ch.elexis.data.Patient) ret;
        }
      }
    }

    Query<ch.elexis.data.Patient> qpa =
        new Query<ch.elexis.data.Patient>(ch.elexis.data.Patient.class);
    // initialize data
    Name ehcName = ehcPatient.getName();
    Date ehcBirthdate = ehcPatient.getBirthday();
    String gender =
        ehcPatient.getAdministrativeGenderCode() == AdministrativeGender.FEMALE
            ? Person.FEMALE
            : Person.MALE;
    TimeTool ttBirthdate = new TimeTool();
    // add data to query
    if (ehcName.getFamilyName() != null && !ehcName.getFamilyName().isEmpty()) {
      qpa.add(ch.elexis.data.Patient.FLD_NAME, Query.EQUALS, ehcName.getFamilyName());
    }
    if (ehcName.getGivenNames() != null && !ehcName.getGivenNames().isEmpty()) {
      qpa.add(ch.elexis.data.Patient.FLD_FIRSTNAME, Query.EQUALS, ehcName.getGivenNames());
    }
    if (ehcBirthdate != null) {
      ttBirthdate.setTime(ehcBirthdate);
      qpa.add(Person.BIRTHDATE, Query.EQUALS, ttBirthdate.toString(TimeTool.DATE_COMPACT));
    }
    List<ch.elexis.data.Patient> existing = qpa.execute();
    // create or overwrite Patient
    ch.elexis.data.Patient ret = null;
    if (existing.isEmpty()) {
      ret =
          new ch.elexis.data.Patient(
              ehcName.getFamilyName(),
              ehcName.getGivenNames(),
              ttBirthdate.toString(TimeTool.DATE_COMPACT),
              gender);
    } else {
      ret = existing.get(0);
    }

    return ret;
  }
Ejemplo n.º 6
0
  @Override
  protected void okPressed() {
    ArrayList<String> al = new ArrayList<String>();
    Money mFrom = miVon.getMoney(true);
    Money mUntil = miBis.getMoney(true);

    if (mFrom != null) {
      // String sFrom=StringTool.pad(SWT.LEFT, '0', mFrom.getCentsAsString(), 9);
      al.add(
          PersistentObject.getConnection()
              .translateFlavor(
                  "cast(Betrag as SIGNED) >=" + mFrom.getCentsAsString())); // $NON-NLS-1$
    }
    if (mUntil != null) {
      // String sUntil=StringTool.pad(SWT.LEFT, '0', mUntil.getCentsAsString(), 9);
      al.add(
          PersistentObject.getConnection()
              .translateFlavor(
                  "cast(Betrag as SIGNED) <=" + mUntil.getCentsAsString())); // $NON-NLS-1$
    }
    TimeTool tt = diRnVon.getDate();
    if (tt != null) {
      al.add(
          "RnDatum >="
              + PersistentObject.getConnection()
                  .wrapFlavored(tt.toString(TimeTool.DATE_COMPACT))); // $NON-NLS-1$
    }
    tt = diRnBis.getDate();
    if (tt != null) {
      al.add(
          "RnDatum <="
              + PersistentObject.getConnection()
                  .wrapFlavored(tt.toString(TimeTool.DATE_COMPACT))); // $NON-NLS-1$
    }
    tt = diStatVon.getDate();
    if (tt != null) {
      al.add(
          "StatusDatum >="
              + PersistentObject.getConnection()
                  .wrapFlavored(tt.toString(TimeTool.DATE_COMPACT))); // $NON-NLS-1$
    }
    tt = diStatBis.getDate();
    if (tt != null) {
      al.add(
          "StatusDatum <="
              + PersistentObject.getConnection()
                  .wrapFlavored(tt.toString(TimeTool.DATE_COMPACT))); // $NON-NLS-1$
    }
    if (al.size() > 0) {
      ret = al.toArray(new String[0]);
    } else {
      ret = null;
    }

    super.okPressed();
  }
Ejemplo n.º 7
0
 public void setGebucht(TimeTool date) {
   if (date == null) {
     date = new TimeTool();
   }
   set("Gebucht", date.toString(TimeTool.DATE_GER)); // $NON-NLS-1$
   set(FLD_REJECT_CODE, "0"); // $NON-NLS-1$
 }
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite comp = new Composite(parent, 0);
    comp.setLayout(new GridLayout(2, false));

    new Label(comp, SWT.NONE).setText("Patient");
    new Label(comp, SWT.NONE).setText(fall.getPatient().getLabel());

    new Label(comp, SWT.NONE).setText("Fall");
    new Label(comp, SWT.NONE).setText(fall.getLabel());

    new Label(comp, SWT.NONE).setText("Datum");
    datum = new DatePickerCombo(comp, SWT.NONE);

    new Label(comp, SWT.NONE).setText("Zeit");
    zeit = SWTHelper.createText(comp, 1, SWT.BORDER);

    new Label(comp, SWT.NONE).setText("Typ");
    typ = new Combo(comp, SWT.DROP_DOWN);
    for (String s : typenS) {
      typ.add(s);
    }

    // Datum- und Zeitfelder initialisieren
    if (kons == null) {
      setTitle("Neue Konsultation erstellen");
      datum.setDate(new Date());
      zeit.setText(new TimeTool().toString(TimeTool.TIME_SMALL));
    } else {
      setTitle("Konsultation modifizieren");
      TimeTool tt = new TimeTool(kons.getDatum());
      datum.setDate(tt.getTime());
      zeit.setText(data.getKonsBeginn());
      neuTyp = data.getKonsTyp();
    }

    for (int i = 0; i < typenI.length; i++) {
      if (neuTyp == typenI[i]) {
        typ.select(i);
        break;
      }
    }

    return comp;
  }
Ejemplo n.º 9
0
 /**
  * Check if observation time is valid, by comparing it with the transmission time.
  *
  * @return
  */
 public boolean isObservationTime() {
   if (observationTime == null) {
     return false;
   }
   if (transmissionTime != null) {
     return !observationTime.isEqual(transmissionTime);
   } else {
     return true;
   }
 }
Ejemplo n.º 10
0
 /**
  * Check if analyse time is valid, by comparing it with the transmission time.
  *
  * @return
  */
 public boolean isAnalyseTime() {
   if (analyseTime == null) {
     return false;
   }
   if (transmissionTime != null) {
     return !analyseTime.isEqual(transmissionTime);
   } else {
     return true;
   }
 }
Ejemplo n.º 11
0
  /** Der Konstruktor liest eine ESR-Zeile ein und konstruiert daraus den Datensatz. */
  public ESRRecord(final String file, final String codeline) {
    super.create(null);
    Mandant m;
    Rechnung rn = null;
    String mandantID;
    REJECT rejectCode;

    String[] vals = new String[11];
    vals[0] = new TimeTool().toString(TimeTool.DATE_COMPACT);
    vals[10] = file;

    rejectCode = REJECT.OK;

    // Code/Modus.
    MODE mode = MODE.Unbekannt;
    String smd = codeline.substring(0, 3);
    if (smd.equals("002")) { // $NON-NLS-1$
      mode = MODE.Gutschrift_edv;
    } else if (smd.equals("012")) { // $NON-NLS-1$
      mode = MODE.Gutschrift_Schalter;
    } else if (smd.equals("005")) { // $NON-NLS-1$
      mode = MODE.Storno_edv;
    } else if (smd.equals("015")) { // $NON-NLS-1$
      mode = MODE.Storno_Schalter;
    } else if (smd.equals("008")) { // $NON-NLS-1$
      mode = MODE.Korrektur_edv;
    } else if (smd.equals("018")) { // $NON-NLS-1$
      mode = MODE.Korrektur_Schalter;
    } else if (smd.equals("999")) { // $NON-NLS-1$
      mode = MODE.Summenrecord;
    }
    vals[5] = Integer.toString(mode.ordinal());

    // Daten parsen. Der ESR-Record liefert 6-stellige Daten, wir wollen 8-stellige
    String prefix = vals[0].substring(0, 2);
    // TODO Das funktioniert nur bis ins Jahr 2099 :-)
    TimeTool dat = new TimeTool(prefix + codeline.substring(59, 65));
    vals[1] = dat.toString(TimeTool.DATE_GER);
    dat.set(prefix + codeline.substring(65, 71));
    vals[2] = dat.toString(TimeTool.DATE_GER);
    dat.set(prefix + codeline.substring(71, 77));
    vals[3] = (dat.toString(TimeTool.DATE_GER));

    if (mode.equals(MODE.Summenrecord)) {
      // Betrag (führende Nullen entfernen)
      vals[4] =
          Integer.toString(Integer.parseInt(codeline.substring(39, 51).trim())); // Totalbetrag
      // 12-stellig
    } else {
      vals[4] =
          Integer.toString(Integer.parseInt(codeline.substring(39, 49).trim())); // Zeilenbetrag
      // 10-stellig
      String esrline = codeline.substring(12, 39);

      // Von der RechnungsNummer führende Nullen wegbringen
      int rnnr = Integer.parseInt(esrline.substring(POSITION_RN_NR, 26));
      Query<Rechnung> qbe_r = new Query<Rechnung>(Rechnung.class);
      String rnid =
          qbe_r.findSingle("RnNummer", "=", Integer.toString(rnnr)); // $NON-NLS-1$ //$NON-NLS-2$
      if (rnid == null) {
        rejectCode = REJECT.RN_NUMMER;
        vals[6] = ""; // $NON-NLS-1$
        mandantID = ""; // $NON-NLS-1$
      } else {
        vals[6] = rnid;
        rn = Rechnung.load(rnid);
        if (rn == null) {
          rejectCode = REJECT.RN_NUMMER;
          vals[6] = ""; // $NON-NLS-1$
          mandantID = ""; // $NON-NLS-1$
        } else {
          m = rn.getMandant();
          if (m == null) {
            rejectCode = REJECT.MANDANT;
            vals[6] = ""; // $NON-NLS-1$
            mandantID = ""; // $NON-NLS-1$
          } else {
            mandantID = m.getId();
          }
        }
      }
      String PatNr = esrline.substring(POSITION_PAT_NR, POSITION_RN_NR);
      long patnr = Long.parseLong(PatNr); // führende Nullen wegbringen
      String PatID =
          new Query<Patient>(Patient.class)
              .findSingle("PatientNr", "=", Long.toString(patnr)); // $NON-NLS-1$ //$NON-NLS-2$
      if (PatID == null) {
        if (rejectCode == REJECT.OK) {
          rejectCode = REJECT.PAT_NUMMER;
        }
        vals[7] = ""; // $NON-NLS-1$
      } else if ((rn != null) && (!rn.getFall().getPatient().getId().equals(PatID))) {
        if (rejectCode == REJECT.OK) {
          rejectCode = REJECT.PAT_FALSCH;
        }
        vals[7] = ""; // $NON-NLS-1$
      } else {

        vals[7] = PatID;
      }
      vals[8] = mandantID;
    }
    vals[9] = Integer.toString(rejectCode.ordinal());
    set(
        new String[] {
          "Datum",
          "Eingelesen",
          "Verarbeitet",
          "Gutgeschrieben", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
          "BetragInRp",
          CODE,
          RECHNUNGS_ID,
          PATIENT_ID,
          MANDANT_ID,
          FLD_REJECT_CODE,
          "File"
        },
        vals); //$NON-NLS-1$ //$NON-NLS-2$
  }
Ejemplo n.º 12
0
  @Override
  protected IStatus createContent(IProgressMonitor monitor) {
    int total = 10000000;
    Query<AccountTransaction> qbe = new Query<AccountTransaction>(AccountTransaction.class);
    TimeTool ttStart = new TimeTool(this.getStartDate().getTimeInMillis());
    TimeTool ttEnd = new TimeTool(this.getEndDate().getTimeInMillis());
    qbe.add(
        AccountTransaction.FLD_DATE,
        Query.GREATER_OR_EQUAL,
        ttStart.toString(TimeTool.DATE_COMPACT)); // $NON-NLS-1$ //$NON-NLS-2$
    qbe.add(
        AccountTransaction.FLD_DATE,
        Query.LESS_OR_EQUAL,
        ttEnd.toString(TimeTool.DATE_COMPACT)); // $NON-NLS-1$ //$NON-NLS-2$
    monitor.beginTask(NAME, total);
    monitor.subTask(Messages.FakturaJournal_DatabaseQuery);
    List<AccountTransaction> transactions = qbe.execute();
    int sum = transactions.size();
    final ArrayList<Comparable<?>[]> result = new ArrayList<Comparable<?>[]>();
    if (sum == 0) {
      monitor.done();
      this.dataSet.setContent(result);
      return Status.OK_STATUS;
    }
    int step = total / sum;
    monitor.worked(20 * step);
    PatientIdFormatter pif = new PatientIdFormatter(8);
    String actMnId = CoreHub.actMandant.getId();
    for (AccountTransaction at : transactions) {
      Patient pat = at.getPatient();
      if (pat != null) {
        if (bOnlyActiveMandator) {
          Rechnung rn = at.getRechnung();
          if (rn == null) {
            continue;
          }
          Mandant mn = rn.getMandant();
          if (mn != null) {
            if (!mn.getId().equals(actMnId)) {
              continue;
            }
          }
        }
        Comparable<?>[] row = new Comparable<?>[this.dataSet.getHeadings().size()];
        row[0] = pif.format(pat.get(Patient.FLD_PATID));
        row[1] = new DateTool(at.getDate());
        row[2] = at.getAmount();
        row[4] = at.getRemark();
        if (((Money) row[2]).isNegative()) {
          row[3] = Messages.FakturaJournal_FA;
        } else {
          if (((String) row[4]).toLowerCase().contains("storno")) { // $NON-NLS-1$
            row[3] = Messages.FakturaJournal_ST;
          } else {
            row[3] = Messages.FakturaJournal_GU;
          }
        }
        if (monitor.isCanceled()) {
          return Status.CANCEL_STATUS;
        }
        result.add(row);
      }
      monitor.worked(step);
    }

    // Set content.
    this.dataSet.setContent(result);

    // Job finished successfully
    monitor.done();

    return Status.OK_STATUS;
  }
Ejemplo n.º 13
0
 public static Date getDate(String elexisDate) {
   timeTool.set(elexisDate);
   return timeTool.getTime();
 }
Ejemplo n.º 14
0
  /**
   * Return a row of data from the sheet.
   *
   * @param rowNr zero based index of the desired row
   * @return a List of Strings with the row values or null if no such row exists.
   */
  public List<String> getRow(final int rowNr) {
    HSSFRow row = sheet.getRow(rowNr);
    if (row == null) {
      return null;
    }
    ArrayList<String> ret = new ArrayList<String>();
    short first = 0;
    short last = 100;
    if (types != null) {
      last = (short) (types.length);
    } else {
      first = row.getFirstCellNum();
      last = row.getLastCellNum();
    }
    for (short i = first; i < last; i++) {
      HSSFCell cell = row.getCell(i);
      if (cell != null) {
        switch (cell.getCellType()) {
          case HSSFCell.CELL_TYPE_BLANK:
            ret.add(""); // $NON-NLS-1$
            break;
          case HSSFCell.CELL_TYPE_BOOLEAN:
            ret.add(Boolean.toString(cell.getBooleanCellValue()));
            break;
          case HSSFCell.CELL_TYPE_NUMERIC:
            if (types != null) {
              if (types[i].equals(Integer.class)) {
                ret.add(Long.toString(Math.round(cell.getNumericCellValue())));
              } else if (types[i].equals(TimeTool.class)) {
                Date date = cell.getDateCellValue();
                if (date != null) {
                  TimeTool tt = new TimeTool(date.getTime());
                  ret.add(tt.toString(TimeTool.FULL_MYSQL));
                } else {
                  ret.add(""); // $NON-NLS-1$
                }
              } else if (types[i].equals(Double.class)) {
                ret.add(Double.toString(cell.getNumericCellValue()));
                break;
              } else /* if(types[i].equals(String.class)) */ {
                double cv = cell.getNumericCellValue();
                // String r=Double.toString(cv);
                String r = NumberFormat.getNumberInstance().format(cv);
                ret.add(r);
              }
              break;
            } // else fall thru
          case HSSFCell.CELL_TYPE_FORMULA:
            ret.add(Double.toString(cell.getNumericCellValue()));
            break;
          case HSSFCell.CELL_TYPE_STRING:
            ret.add(cell.toString());
            break;
          default:
            ret.add(Messages.ExcelWrapper_ErrorUnknownCellType);
        }

      } else {
        // empty cell
        ret.add(""); // $NON-NLS-1$
      }
    }
    return ret;
  }