class MediServ::API::Invoice

Constants

BehandlungStatus
BehandlungTyp
Sprache

Public Instance Methods

to_h() click to toggle source
# File lib/mediserv/api/types.rb, line 169
def to_h
  h = {
    RechNr: nummer,
    RechDat: datum.strftime('%d.%m.%Y'),
    BehBeginn: behandlungsbeginn.strftime('%d.%m.%Y'),
    BehEnde: behandlungsende.strftime('%d.%m.%Y'),
    BehStatus: behandlungstatus,
    BehTyp: behandlungstyp,
    RechBetrag: rechnungsbetrag,
    TotalLeis: total_leis,
    TotalMed: total_med,
    TotalLabor: total_labor,
    TotalDiverse: total_diverse,
    TotalRabatt: total_rabatt,
    TotalVZ: total_vz,
    TotalNetto: total_netto,
    Sprache: sprache,
    PatNr: patient.nummer,
    PatAnrede: fmt_string(patient.anrede, max: 4),
    PatTitel: fmt_string(patient.titel, max: 20),
    PatName: fmt_string(patient.name, max: 40),
    PatVorname: fmt_string(patient.vorname, max: 40),
    PatStrasse: fmt_string(patient.strasse, max: 30),
    PatZusatz: fmt_string(patient.zusatz, max: 20),
    PatLand: fmt_string(patient.land, max: 3),
    PatPLZ: fmt_string(patient.plz, max: 10),
    PatOrt: fmt_string(patient.ort, max: 40),
    PatGebDatum: fmt_date(patient.geburtsdatum),
  }
  h[:RechTitel] = rech_titel[0..180] unless rech_titel.nil?
  h[:VersNr] = versicherungsnummer unless versicherungsnummer.nil?
  h[:Rabatt] = rabatt unless rabatt.nil?
  h[:VerfügungsDat] = verfugungs_datum unless verfugungs_datum.nil?
  h[:VerfügungsNr] = verfugungs_nummer unless verfugungs_nummer.nil?
  if empfanger
    h[:EmpfNr] = empfanger.nummer
    h[:EmpfArt] = fmt_string(empfanger.art, max: 20)
    h[:EmpfAnrede] = fmt_string(empfanger.anrede, max: 4)
    h[:EmpfTitel] = fmt_string(empfanger.titel, max: 20)
    h[:EmpfName] = fmt_string(empfanger.name, max: 40)
    h[:EmpfVorname] = fmt_string(empfanger.vorname, max: 40)
    h[:EmpfStrasse] = fmt_string(empfanger.strasse, max: 20)
    h[:EmpfLand] = fmt_string(empfanger.land, max: 3)
    h[:EmpfPLZ] = fmt_string(empfanger.plz, max: 10)
    h[:EmpfOrt] = fmt_string(empfanger.ort, max: 40)
    h[:EmpfGebDatum] = fmt_date(empfanger.geburtsdatum)
  end
  anhange.each.with_index(1) do |a, i|
    # Path to attachment file
    h["Anhang#{i}"] = a
  end
  rech_text.scan(/.{1,180}/).each.with_index(1) do |s, i|
    # A line will go up to 180 characters, but could be shorter in case of a
    # new line or simply a short line.
    h["RechText[#{i}]"] = s
  end unless rech_text.nil?
  leistungen.each.with_index(1) do |l, i|
    # Total der Punkt von Ansatz
    # h["TotalPkt[#{i}]"] = l.punkte || 0.0
    # Ansatz für Punkte
    # h["TotalAnsatz[#{i}]"] = l.ansatz || 0.0

    h["LeisDatum[#{i}]"] = fmt_date(l.datum)
    h["LeisAnz[#{i}]"] = fmt_amount(l.anzahl)
    h["LeisZahnNr[#{i}]"] = l.zahnnummer
    h["LeisArt[#{i}]"] = l.art
    h["LeisPosNr[#{i}]"] = l.nummer
    h["LeisBez[#{i}]"] = l.bezeichnung
    h["LeisAnsatz[#{i}]"] = l.ansatz
    h["LeisPkt[#{i}]"] = l.punkte
    h["LeisRabatt[#{i}]"] = l.rabatt ? 1 : 0
    h["LeisBetrag[#{i}]"] = l.betrag
    h["LeisTotal[#{i}]"] = l.total
  end
  h
end
total_punkte() click to toggle source
# File lib/mediserv/api/types.rb, line 165
def total_punkte
  leistungen.select{|l| l.punkte != nil }.map(&:punkte).reduce(0.0, :+)
end