-[div .prescription
- [h2 $(l10n therapy_prescription)]
- [span .insurance . $(MPX insurance |HTML)]
- [span .date [label $(l10n date):] $(MPX date |HTML)]
+[div .therapies
+ [h2 $(l10n therapies)]
+ $(
+ (cd "$_DATA/therapies/"; printf '%s\n' "${id%%.*}".*.tpy) \
+ | while read tpyfile; do
+ [ "$tpyfile" = "${id%%.*}.*.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); - ;;'
+ )"
+ if [ "${tpy%.*}.${tpy#*.}" = "${id}" ]; then
+ printf '[a .item .therapy .current href="/therapies/%s" . %s] ' \
+ "${tpy%.*}/${tpy#*.}" "$(HTML "${tpydates:--}")"
+ else
+ printf '[a .item .therapy href="/therapies/%s" . %s] ' \
+ "${tpy%.*}/${tpy#*.}" "$(HTML "${tpydates:--}")"
+ fi
+ done |sort -n
+ )
+ [!-- a .item .therapy href="/therapies/${id%%.*}/new" . + --]
+]