- printf '%s\t%s\t%s\n'
- printf '<li><a href="?p=prescriptions&client=%s" >%s: %s - %s%s</a></li>' \
- "${id}" \
- "$(sed -nr 's;^date:(.+)$;\1;p' "$pfile")" \
- "$(sed -nr 's;^indicator:(.+)$;\1;p' "$pfile")" \
- "$(sed -nr 's;^quantity:(.+) ?$;\1x ;p' "$pfile")$(sed -nr 's;^remidy:(.+)$;\1;p' "$pfile")" \
- "$(sed -nr 's;^quantity1:(.+) ?$;,\1x ;p' "$pfile")$(sed -nr 's;^remidy1:(.+)$;\1;p' "$pfile")"
+ mpx=(); cat "$pfile" |while read -r line; do
+ val="${line#*:}"
+ mpx[${line%%:*}]="$(htmlsafe "${val//\\n/$BR}")"
+ done
+ printf '<li><a href="?p=prescriptions&client=%s#%s" >%s: %s - %s</a></li>' \
+ "${id}" "${pfile##*/}" "${mpx[date]}" "${mpx[indicator]}" \
+ "$([ -n "${mpx[remidy]}" ] && printf '%s %s' "${mpx[quantity]}" "${mpx[remidy]}"
+ for n in {0..10}; do
+ [ -n "${mpx[remidy${n}]}" ] && printf ', %s %s' "${mpx[quantity${n}]}" "${mpx[remidy${n}]}"
+ done
+ )"