X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=cards%2Fwidgets.sh;h=c0ecfb09e5bf78019189325443c320382ab57bca;hb=638d268ba4eff001614d065396572a6d1c03efae;hp=d2ed32611932d5fd9bf7067b904679892f797e69;hpb=705c924c81dd8a77706c6c37543f0da8af5aec41;p=lobster diff --git a/cards/widgets.sh b/cards/widgets.sh index d2ed326..c0ecfb0 100755 --- a/cards/widgets.sh +++ b/cards/widgets.sh @@ -135,13 +135,18 @@ card_item(){ therapies) client="$(pdi_value "$card" UID)" printf '[h3 %s]' "$(l10n therapies)" - (cd "$_DATA/prescriptions/"; printf '%s\n' "${client}".*.mpx) \ - | while read mpxfile; do - [ "$mpxfile" = "${client}.*.mpx" ] && break - mpx="${mpxfile%.mpx}"; - printf '[a .item .therapy href="/therapies/%s" . Therapy - %s]' \ - "${mpx%.*}/${mpx#*.}" "$(sed -E '/^date:.*/{s;^date:;;;q;};d;' "$_DATA/prescriptions/$mpxfile")" - done |sort -r + (cd "$_DATA/therapies/"; printf '%s\n' "${client}".*.tpy) \ + | while read tpyfile; do + [ "$tpyfile" = "${client}.*.tpy" ] && break + tpy="${tpyfile%.tpy}"; + tpydates="$(sed -En 's;^session[0-9]+_date:;;p;' "$_DATA/therapies/$tpyfile" \ + | sort \ + | sed -E ':X;N;$!bX; s;^[\n ]+;;; s;[\n ]+$;;; s;(\n.*\n|\n); - ;;' + )" + printf '[a .item .therapy href="/therapies/%s" . %s] ' \ + "${tpy%.*}/${tpy#*.}" "$(HTML "${tpydates:--}")" + done |sort -n + printf '[a .item .therapy href="/therapies/%s/new" . +]' "${client}" ;; *)[ $cnt -gt 0 ] && printf '[h3 %s]' "$(l10n "$item")" shy="$(printf '\302\255')"