1 # Copyright 2014 - 2016 Paul Hänsch
3 # This file is part of Confetti.
5 # Confetti is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # Confetti is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Affero General Public License for more details.
15 # You should have received a copy of the GNU Affero General Public License
16 # along with Confetti. If not, see <http://www.gnu.org/licenses/>.
18 n=$(printf %s "$values[N]" \
19 | sed -rn 's:^([^;]*)(\;[^;]*)(\;[^;]*)?(\;[^;]*)?(\;[^;]*)?$:\4 \2 \3 \1 \5:gp' \
20 | sed -r 's:,: :;s:\;: :g;s: +: :g;s:^ $::;'
22 fullname="${n:-${values[FN]:-${values[NICKNAME]}}}"
24 hi_company="$(printf %s "${values[X-HEALTH-INSURANCE]}" |cut -d\; -f1)"
25 hi_number="$(printf %s "${values[X-HEALTH-INSURANCE]}" |cut -d\; -f2)"
26 hi_status="$(printf %s "${values[X-HEALTH-INSURANCE]}" |cut -d\; -f3)"
30 <div class="section basic">
31 <h2 class="item FN">$fullname</h2>
32 ${values[GENDER]:+<span class="\""item GENDER"\"">$(l10n $values[GENDER])</span>}
34 $(for n in NICKNAME NICKNAME{0..10}; do
35 echo "${values[$n]:+<span class="\""item NICKNAME"\"">aka. $values[$n]</span>}"
38 ${values[BDAY]:+<span class="\""item BDAY"\""><label>*:</label> ${values[BDAY]}</span>}
39 ${values[SOUND]:+<audio controls="controls" class="\""item SOUND"\""><source type="audio/ogg" src="\""data:audio/ogg;base64,$values[SOUND]"\"" /></audio>}
40 ${values[PHOTO]:+<img class="\""item PHOTO"\"" src="\""data:image/$values[PHOTO_TYPE];base64,$values[PHOTO]"\"" />}
41 ${values[LOGO]:+<img class="\""item LOGO"\"" src="\""data:image/$values[LOGO_TYPE];base64,$values[LOGO]"\"" />}
44 $(for n in ADR ADR{0..10}; do
45 echo "${values[$n]:+<span class="\""item ADR"\"">$values[$n]</span>}"
47 ${values[URL]:+<h3>$(l10n URL)</h3>}
48 $(for n in URL URL{0..10}; do
49 echo "${values[$n]:+<span class="\""item URL"\""><a href="\""$values[$n]"\"">$values[$n]</a></span>}"
53 --><div class="section phone">
55 $(for n in TEL TEL{0..10}; do
56 echo "${values[$n]:+<span class="\""item TEL"\"">$(l10n t${values[${n}_TYPE]}) $values[$n]</span>}"
58 ${values[EMAIL]:+<h3>$(l10n EMAIL)</h3>}
59 $(for n in EMAIL EMAIL{0..10}; do
60 echo "${values[$n]:+<span class="\""item EMAIL"\""><a href="\""mailto:$values[$n]"\"">$values[$n]</a></span>}"
62 ${values[IMPP]:+<h3>$(l10n IMPP)</h3>}
63 $(for n in IMPP IMPP{0..10}; do
64 echo "${values[$n]:+<span class="\""item IMPP"\"">$values[${n}_TYPE] <a href="\""$values[$n]"\"">$values[$n]</a></span>}"
68 --><div class="section insurance">
69 <h3>$(l10n X-HEALTH-INSURANCE)</h3>
70 ${hi_company:+<span class="\""item hi_comapany"\"">${hi_company}</span>}
71 ${hi_number:+<span class="\""item hi_number"\""><label>$(l10n hi_number):</label> ${hi_number}</span>}
72 ${hi_status:+<span class="\""item hi_status"\""><label>$(l10n hi_status):</label> ${hi_status}</span>}
75 --><div class="section note">
76 ${values[NOTE]:+<h3>$(l10n NOTE)</h3>}
77 $(for n in NOTE NOTE{0..10}; do
78 echo "${values[$n]:+<span class="\""item NOTE"\"">$values[$n]</span>}"
80 ${values[X-CLIENT-REFERRAL]:+<h3>$(l10n X-CLIENT-REFERRAL)</h3>}
81 $(for n in X-CLIENT-REFERRAL X-CLIENT-REFERRAL{0..10}; do
82 echo "${values[$n]:+<span class="\""item X-CLIENT-REFERRAL"\"">$values[$n]</span>}"
86 --><div class="section prescriptions">
87 <h3>$(l10n prescriptions)</h3>
90 find "$_DATA/prescriptions/" -name "${id%.vcf}.*.mpx" \
91 | while read pfile; do
92 mpx=(); cat "$pfile" |while read -r line; do
94 mpx[${line%%:*}]="$(htmlsafe "${val//\\n/$BR}")"
96 printf '<li><a href="?p=prescriptions&client=%s#%s" >%s: %s - %s</a></li>' \
97 "${id}" "${pfile##*/}" "${mpx[date]}" "${mpx[indicator]}" \
98 "$([ -n "${mpx[remidy]}" ] && printf '%s %s' "${mpx[quantity]}" "${mpx[remidy]}"
100 [ -n "${mpx[remidy${n}]}" ] && printf ', %s %s' "${mpx[quantity${n}]}" "${mpx[remidy${n}]}"