select
    '6301' as "KEY_8000",
    '_length_' as "KEY_8100",
    standort.bsnr as "KEY_4218",
    standort.lanr as "KEY_4242",
    patient_id as "KEY_3000",
    nachname as "KEY_3101",
    vorname as "KEY_3102",
    geburtsdatum as "KEY_3103",
    titel as "KEY_3104",
    kv_versicherungs_nr as "KEY_3105",
    trim(coalesce(plz,'')||' '||coalesce(ort,'')) as "KEY_3106",
    strasse as "KEY_3107",
    case
        when kv_familienstand=1 then 'M'
        when kv_familienstand=2 then 'F'
        when kv_familienstand=3 then 'R'
    end as "KEY_3108",
    2 as "KEY_3110",
    manamnese.groesse as "KEY_3622",
    manamnese.gewicht as "KEY_3623",
    case
        when abrechnungsart=1 then 'K'
        when abrechnungsart=2 then 'P'
        when abrechnungsart=3 then 'E'
    end as "KEY_8609",
    krankenkasse as "KEY_2002",
    f_quarter(current_date)||f_year(current_date) as "KEY_4101",
    kv_nr as "KEY_4104",
    kik_id as "KEY_4111"
from person
join manamnese on manamnese.mann_id=person.person_id
join rd$zentrum_standorte standort on standort.zs_id=:STANDORT_ID
where person_id=:PERSON_ID