X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=pages%2Ftherapy.sh;fp=pages%2Ftherapy.sh;h=6127b4dfd5979011f2b94aeb6a9484999185afe2;hp=571333ec7008d98720597bb42ea5f9c6020033ef;hb=c8980226006bdd5a9d518e7d3221dc3d527be321;hpb=aedb6776919b351df7df7c310c238c41317ddc44 diff --git a/pages/therapy.sh b/pages/therapy.sh index 571333e..6127b4d 100755 --- a/pages/therapy.sh +++ b/pages/therapy.sh @@ -18,6 +18,7 @@ # along with Confetti. If not, see . declare -A tpy +declare -A mpx BR=' ' @@ -25,8 +26,26 @@ BR=' id="$_GET[id]" tpyfile="$_DATA/therapies/$id" +mpxfile="$_DATA/prescriptions/${id%.tpy}.mpx" +client="$_DATA/vcard/${id%%.*}.vcf" + +card_N="$(sed -nr 's:^(N)(;[^"\:]+|;"[^"]+")*\:(.*)$:\3:gp' "$client")" +card_FN="$(sed -nr 's:^(FN)(;[^"\:]+|;"[^"]+")*\:(.*)$:\3:gp' "$client")" +card_NICK="$(sed -nr 's:^(NICKNAME)(;[^"\:]+|;"[^"]+")*\:(.*)$:\3:gp' "$client")" + +n=$(printf %s "$card_N" \ + | sed -rn 's:^([^;]*)(\;[^;]*)(\;[^;]*)?(\;[^;]*)?(\;[^;]*)?$:\4 \2 \3 \1 \5:gp' \ + | sed -r 's:,: :;s:\;: :g;s: +: :g;s:^ $::;' + ) +client_name="${n:-${card_FN:-${card_NICK}}}" mpx=() +cat "$mpxfile" |while read -r line; do + val="${line#*:}" + mpx[${line%%:*}]="${val//\\n/$BR}" +done + +tpy=() cat "$tpyfile" |while read -r line; do val="${line#*:}" tpy[${line%%:*}]="${val//\\n/$BR}"