From 8536e089bb0d5f7af527aacc63d435e45b7e6770 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Wed, 8 Jan 2020 22:54:24 +0100 Subject: [PATCH] Link to therapies without relying on prescriptions --- cards/l10n.sh | 1 + cards/widgets.sh | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cards/l10n.sh b/cards/l10n.sh index ec02d65..b0930c1 100755 --- a/cards/l10n.sh +++ b/cards/l10n.sh @@ -85,6 +85,7 @@ l10n(){ prescriptions) printf %s "Verordnungen";; new_prescription) printf %s "Neue Verordnung";; no_icd) printf %s "Kein ICD Code";; + therapy) printf %s "Therapie";; therapies) printf %s "Therapien";; X-ZACK-JOINDATE) printf %s "An­mel­de­da­tum";; diff --git a/cards/widgets.sh b/cards/widgets.sh index d2ed326..ac04d9f 100755 --- a/cards/widgets.sh +++ b/cards/widgets.sh @@ -135,12 +135,16 @@ 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")" + (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 %s]' \ + "${tpy%.*}/${tpy#*.}" "$(l10n therapy)" "$(HTML "${tpydates:--}")" done |sort -r ;; *)[ $cnt -gt 0 ] && printf '[h3 %s]' "$(l10n "$item")" -- 2.39.2