# You should have received a copy of the GNU Affero General Public License
# along with Lobster. If not, see <http://www.gnu.org/licenses/>.
-# t_session_note(){
-# session_n="$1"
-# note_n="$2"
-#
-# color=session${session_n}_note${note_n}_color
-# unset c0 c1 c2 c3 c4 c5 c6 c7
-#
-# if [ "$note_n" -eq 1 -o -n "${tpy[session${session_n}_note${note_n}]}" ]; then
-# printf '<input class="trailbtn" type="checkbox" checked="checked">'
-# else
-# printf '<input class="trailbtn" type="checkbox">'
-# fi
-#
-# _checked="$(validate "$tpy[$color]" '#(888|00A|0A0|0AA|A00|A0A|AA0)' '#FFF')"
-# cat <<-EOF
-# <fieldset class="note trailbox">
-# <input class=color type=radio name="$color" value="#888" id=${color}_000 $(checked \#888)><label for=${color}_000></label>
-# <input class=color type=radio name="$color" value="#00A" id=${color}_001 $(checked \#00A)><label for=${color}_001></label>
-# <input class=color type=radio name="$color" value="#0A0" id=${color}_010 $(checked \#0A0)><label for=${color}_010></label>
-# <input class=color type=radio name="$color" value="#0AA" id=${color}_011 $(checked \#0AA)><label for=${color}_011></label>
-# <input class=color type=radio name="$color" value="#A00" id=${color}_100 $(checked \#A00)><label for=${color}_100></label>
-# <input class=color type=radio name="$color" value="#A0A" id=${color}_101 $(checked \#A0A)><label for=${color}_101></label>
-# <input class=color type=radio name="$color" value="#AA0" id=${color}_110 $(checked \#AA0)><label for=${color}_110></label>
-# <input class=color type=radio name="$color" value="#FFF" id=${color}_111 $(checked \#FFF)><label for=${color}_111></label>
-# <textarea name="session${session_n}_note${note_n}">${tpy[session${session_n}_note${note_n}]}</textarea>
-# </fieldset>
-# EOF
-# }
-#
-# t_session(){
-# session_n="$1"
-#
-# sid=session${session_n}
-#
-# if [ "$tpy[${sid}_sigset]" = pos ]; then
-# sigcheck=checked
-# else
-# unset sigcheck
-# fi
-#
-# cat <<-EOF
-# <input type=hidden name=$sid value=exists>
-# <input class="tab" type="checkbox" id=${sid}_open name="${sid}_open" value="checked" ${tpy[${sid}_open]}>
-# <label class="tab" for="${sid}_open">
-# <span class=no>${session_n}.</span><!--
-# --><span class=date>${tpy[${sid}_date]}</span><!--
-# --><input class="date" name="${sid}_date" value="${tpy[${sid}_date]}" placeholder="$(l10n date)"><!--
-# --><span class=therapist>${tpy[${sid}_therapist]}</span><!--
-# --><input class="therapist" name="${sid}_therapist" value="${tpy[${sid}_therapist]}" placeholder="$(l10n therapist)"><!--
-# --><span class=signature><input type="checkbox" name="${sid}_sigset" value="pos" $sigcheck></span>
-# </label>
-# <div class=tab>
-# <img class="dotmark ov" src="/therapies/${id%.tpy}_${sid}.png" alt="">
-# $(n=1;
-# while [ -n "${tpy[session${session_n}_note${n}]+x}" ]; do
-# if [ -n "${tpy[session${session_n}_note${n}]}" ]; then
-# x=$n
-# fi
-# n=$(($n + 1))
-# done
-# for n in $(seq 1 $((${x:-0} + 3)) ); do t_session_note $session_n $n; done
-# )
-# <button class="trailbtn" type="submit">$(l10n trailsave)</button>
-# <button class=delete type=submit name=delete_session value=${session_n}>$(l10n delete_session)</button>
-# </div>
-# EOF
-# }
-#
-# therapy_sessions(){
-# n=1; while [ -n "${tpy[session${n}]}" ]; do
-# t_session $n
-# n=$(($n+1))
-# done
-#
-# sid=session$n
-#
-# cat <<-EOF
-# <fieldset class="tab">
-# <button class=no type=submit name=new_session value=$sid>+</button><!--
-# --><input class=date name=${sid}_date value="" placeholder="$(l10n date)" /><!--
-# --><input class=therapist name=${sid}_therapist value="" placeholder="$(l10n therapist)" /><!--
-# --><span class=signature><span></span>
-# <input type=hidden name="${sid}_note1" value="">
-# </fieldset>
-# EOF
-# }
+t_session_note(){
+ session_n="$1"
+ note_n="$2"
+
+ color=session${session_n}_note${note_n}_color
+
+ if [ "$note_n" -eq 1 -o "$(TPY "session${session_n}_note${note_n}")" ]; then
+ printf '[input type="checkbox" .trailbtn checked="checked"]'
+ else
+ printf '[input type="checkbox" .trailbtn]'
+ fi
+
+ check="$(TPY "$color" |grep -xE -m1 '#(888|00A|0A0|0AA|A00|A0A|AA0)' || printf '#FFF')"
+ cat <<-EOF
+ [fieldset .note .trailbox
+ [radio "$color" "#888" .color #${color}_000 $(checked "$check" '#888') ][label for=${color}_000]
+ [radio "$color" "#00A" .color #${color}_001 $(checked "$check" '#00A') ][label for=${color}_001]
+ [radio "$color" "#0A0" .color #${color}_010 $(checked "$check" '#0A0') ][label for=${color}_010]
+ [radio "$color" "#0AA" .color #${color}_011 $(checked "$check" '#0AA') ][label for=${color}_011]
+ [radio "$color" "#A00" .color #${color}_100 $(checked "$check" '#A00') ][label for=${color}_100]
+ [radio "$color" "#A0A" .color #${color}_101 $(checked "$check" '#A0A') ][label for=${color}_101]
+ [radio "$color" "#AA0" .color #${color}_110 $(checked "$check" '#AA0') ][label for=${color}_110]
+ [radio "$color" "#FFF" .color #${color}_111 $(checked "$check" '#FFF') ][label for=${color}_111]
+ [textarea name="session${session_n}_note${note_n}" . $(TPY "session${session_n}_note${note_n}" |HTML)]
+ ]
+ EOF
+}
+
+therapy_sessions(){
+ n=1; while [ "$(TPY session$n)" ]; do
+ session_n="$n"
+ sid=session${session_n}
+
+ cat <<-EOF
+ [hidden "$sid" "exists"]
+ [checkbox "${sid}_open" "checked" #${sid}_open .tab $(checked "$(TPY "${sid}_open")" checked)]
+ [label .tab for="${sid}_open"
+ [span .no ${session_n}.]
+ [span .date . $(TPY "${sid}_date" |HTML)]
+ [input .date name="${sid}_date" value="$(TPY "${sid}_date" |HTML)" placeholder="$(l10n date)"]
+ [span .therapist . $(TPY "${sid}_therapist" |HTML)]
+ [input .therapist name="${sid}_therapist" value="$(TPY "${sid}_therapist" |HTML)" placeholder="$(l10n therapist)"]
+ [span .signature [checkbox "${sid}_sigset" "pos" $(checked "$(TPY "${sid}_sigset")" "pos")]]
+ ]
+ [div .tab
+ [img .dotmark .ov src="/therapies/${id}_${sid}.png" alt=""]
+ $(n=1; while TPY "session${session_n}_note${n}" >/dev/null; do
+ [ "$(TPY "session${session_n}_note${n}")" ] && x=$n
+ n=$(($n + 1))
+ done
+ for n in $(seq 1 $((${x:-0} + 3)) ); do
+ t_session_note $session_n $n
+ done
+ )
+ [button type="submit" .trailbtn $(l10n trailbtn)]
+ [button type="submit" name=delete_session value="$session_n" .delete $(l10n delete_session)]
+ ]
+ EOF
+ n=$(($n+1))
+ done
+
+ sid=session$n
+
+ cat <<-EOF
+ [fieldset .tab
+ [submit "new_session" "$sid" .no . +]
+ [input .date name="${sid}_date" value="" placeholder=$(l10n date)]
+ [input .therapist name="${sid}_therapist" value="" placeholder=$(l10n therapist)]
+ [span .signature]
+ [hidden "${sid}_note1" ""]
+ ]
+ EOF
+}
cat <<EOF
[h1 $(l10n therapy)]
[div .patient
- [h2 . $(pdi_value "$vcf" FN)]
+ [h2 . $(VCF FN |HTML)]
[a href="/cards/#${id%.*}.vcf" \< $(l10n client)]
]
[div .prescription
[h2 $(l10n therapy_prescription)]
- [span .insurance . $(pdi_value "$mpx" INSURANCE)]
- [span .date [label $(l10n date):] $(pdi_value "$mpx" DATE)]
+ [span .insurance . $(MPX insurance |HTML)]
+ [span .date [label $(l10n date):] $(MPX date |HTML)]
EOF
- if [ "$(pdi_value "$mpx" PRESCREVIEWED)" ]; then
+ if [ "$(MPX prescreviewed)" ]; then
printf '[label .checkbox .checked for=prescreviewed . %s]' "$(l10n prescreviewed)"
else
printf '[label .checkbox for=prescreviewed . %s]' "$(l10n prescreview)"
fi
- field="$(pdi_value "$mpx" PRESCNO)"
+ field="$(MPX prescno)"
[ "$field" ] && printf '[span .prescno . %s]' "$(l10n "presc$field")"
for field in grouptherapy housecall report; do
- [ "$(pdi_value "$mpx" "$field")" ] && printf '[span .catalogue . %s]' "$(l10n "$field")"
+ [ "$(MPX "$field")" ] && printf '[span .catalogue . %s]' "$(l10n "$field")"
done
printf '[ul'
for n in '' 0 1 2 3 4 5 6 7 8 9 10; do
- remidy="$(pdi_value "$mpx" REMIDY$n)"
- quantity="$(pdi_value "$mpx" QUANTITY$n)"
- quantity_weekly="$(pdi_value "$mpx" QUANTITY_WEEKLY$n)"
+ remidy="$(MPX remidy$n)"
+ quantity="$(MPX quantity$n)"
+ quantity_weekly="$(MPX quantity_weekly$n)"
if [ "$remidy" -a "$quantity_weekly" ]; then
- printf '[li %s %s %s]' "$quantity" "$remidy" "$quantity_weekly $(l10n weekly)"
+ printf '[li %s %s %s]' "$(HTML "$quantity")" "$(HTML "$remidy")" "$(HTML "$quantity_weekly") $(l10n weekly)"
elif [ "$remidy" ]; then
- printf '[li %s %s]' "$quantity" "$remidy"
+ printf '[li %s %s]' "$(HTML "$quantity")" "$(HTML "$remidy")"
fi
done
printf ']'
for field in indicator icd10; do
- val="$(pdi_value "$mpx" "$field")"
- [ "$val" ] && printf '[span .%s [label . %s:]%s]' "$field" "$(l10n "$field")" "$val"
+ val="$(MPX "$field")"
+ [ "$val" ] && printf '[span .%s [label . %s:]%s]' "$field" "$(l10n "$field")" "$(HTML "$val")"
done
- addcontrib="$(pdi_value "$mpx" ADDCONTRIB)"
- contribconfirm="$(pdi_value "$mpx" CONTRIBCONFIRM)"
+ addcontrib="$(MPX addcontrib)"
+ contribconfirm="$(MPX contribconfirm)"
if [ "$addcontrib" -a "$contribconfirm" ]; then
- printf '[label .checkbox .checked for=addcontrib . %s %s]' "$(l10n contribconfirm)" "$contribconfirm"
+ printf '[label .checkbox .checked for=addcontrib . %s %s]' "$(l10n contribconfirm)" "$(HTML $contribconfirm)"
elif [ "$addcontrib" ]; then
printf '[label .checkbox for=addcontrib . %s]' "$(l10n addcontrib)"
fi
cat <<EOF
[input .tab type="checkbox" #indicator_reading][label .tab for=indicator_reading $(l10n indicator_reading)]
- [div .tab . $(pdi_value "$mpx" INDICATOR_READING)]
+ [div .tab . $(MPX indicator_reading |HTML)]
]
[form #report method=POST action="/therapies/update_therapy.sh"
- [input type=hidden name=id value="$id"]
+ [hidden "id" "$id"]
[input .stickynote type=checkbox name=c_stickynote #show_stickynote]
[fieldset .stickynote
[label for="show_stickynote" $(l10n notes)]
[h2 $(l10n notes)]
- [textarea name=stickynote . $(pdi_value "$tpy" STICKYNOTE)]
+ [textarea name=stickynote . $(TPY stickynote |HTML)]
[button type=submit $(l10n save)]
]
[th $(l10n time_goal)][th $(l10n time_actual)][th $(l10n time_difference)]
]][tbody
$(for n in '' 0 1 2 3 4 5 6 7 8 9 10; do
- tsgoal="$(pdi_value "$tpy" TSGOAL$n)"
- tsactual="$(pdi_value "$tpy" TSACTUAL$n)"
+ tsgoal="$(TPY tsgoal$n |grep -m1 -xE '[0-9]+')"
+ tsactual="$(TPY tsactual$n |grep -m1 -xE '[0-9]+')"
printf '[tr [td [input type=number name=tsgoal value="%s"]][td [input type=number name=tsactual value="%s"]][td %s]]' \
"$tsgoal" "$tsactual" "$(( ${tsgoal:-0} - ${tsactual:-0} ))"
done)
]
EOF
-# therapy_sessions
+therapy_sessions
+
+## ==== Drawing canvas ==== ##
+### ====================== ###
-penwith="$(pdi_value "$tpy" PENWITH |grep -xE -m1 '(4|12|36)' || printf '4')"
-color="$(pdi_value "$tpy" COLOR |grep -xE -m1 '#(000|00A|0A0|0AA|A00|A0A|AA0|FFF)' || printf '#000')"
+penwidth="$(TPY penwidth |grep -xE -m1 '(4|12|36)' || printf '4')"
+color="$(TPY color |grep -xE -m1 '#(000|00A|0A0|0AA|A00|A0A|AA0|FFF)' || printf '#000')"
cat <<EOF
[fieldset .penwidth
- [radio "penwidth" "4" #pw1 $(checked $penwidth 4) ][label for="pw2"]
- [radio "penwidth" "12" #pw2 $(checked $penwidth 12)][label for="pw3"]
- [radio "penwidth" "36" #pw3 $(checked $penwidth 36)][label for="pw1"]
+ [radio "penwidth" "4" #pw1 $(selected $penwidth 4) ][label for="pw2"]
+ [radio "penwidth" "12" #pw2 $(selected $penwidth 12)][label for="pw3"]
+ [radio "penwidth" "36" #pw3 $(selected $penwidth 36)][label for="pw1"]
]
[fieldset .color
[radio "color" "#000" .color #c000 $(checked $color '#000') ][label for=c000 ]