1 # Copyright 2016, 2017, 2020 Paul Hänsch
3 # This file is part of Lobster.
5 # Confetti is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # Lobster is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Affero General Public License for more details.
15 # You should have received a copy of the GNU Affero General Public License
16 # along with Lobster. If not, see <http://www.gnu.org/licenses/>.
22 color=session${session_n}_note${note_n}_color
24 if [ "$note_n" -eq 1 -o "$(TPY "session${session_n}_note${note_n}")" ]; then
25 printf '[input type="checkbox" .trailbtn checked="checked"]'
27 printf '[input type="checkbox" .trailbtn]'
30 check="$(TPY "$color" |grep -xE -m1 '#(888|00A|0A0|0AA|A00|A0A|AA0)' || printf '#FFF')"
32 [fieldset .note .trailbox
33 [radio "$color" "#888" .color #${color}_000 $(checked "$check" '#888') ][label for=${color}_000]
34 [radio "$color" "#00A" .color #${color}_001 $(checked "$check" '#00A') ][label for=${color}_001]
35 [radio "$color" "#0A0" .color #${color}_010 $(checked "$check" '#0A0') ][label for=${color}_010]
36 [radio "$color" "#0AA" .color #${color}_011 $(checked "$check" '#0AA') ][label for=${color}_011]
37 [radio "$color" "#A00" .color #${color}_100 $(checked "$check" '#A00') ][label for=${color}_100]
38 [radio "$color" "#A0A" .color #${color}_101 $(checked "$check" '#A0A') ][label for=${color}_101]
39 [radio "$color" "#AA0" .color #${color}_110 $(checked "$check" '#AA0') ][label for=${color}_110]
40 [radio "$color" "#FFF" .color #${color}_111 $(checked "$check" '#FFF') ][label for=${color}_111]
41 [textarea name="session${session_n}_note${note_n}" . $(TPY "session${session_n}_note${note_n}" |HTML)]
47 n=1; while [ "$(TPY session$n)" ]; do n=$((n + 1)); done
52 [submit "new_session" "$sid" .no . +]
53 [input .date name="${sid}_date" value="" placeholder=$(l10n date)]
54 [input .therapist name="${sid}_therapist" value="" placeholder=$(l10n therapist)]
56 [hidden "${sid}_note1" ""]
60 seq $((n - 1)) -1 1 | while read n; do
62 sid=session${session_n}
65 [hidden "$sid" "exists"]
66 [checkbox "${sid}_open" "checked" #${sid}_open .tab $(checked "$(TPY "${sid}_open")" checked)]
67 [label .tab for="${sid}_open"
68 [span .no ${session_n}.]
69 [span .date . $(TPY "${sid}_date" |HTML)]
70 [input .date name="${sid}_date" value="$(TPY "${sid}_date" |HTML)" placeholder="$(l10n date)"]
71 [span .therapist . $(TPY "${sid}_therapist" |HTML)]
72 [input .therapist name="${sid}_therapist" value="$(TPY "${sid}_therapist" |HTML)" placeholder="$(l10n therapist)"]
73 [span .signature [checkbox "${sid}_sigset" "pos" $(checked "$(TPY "${sid}_sigset")" "pos")]]
76 [img .dotmark .ov src="/therapies/${id}_${sid}.png?${_DATE}" alt=""]
77 $(n=1; while TPY "session${session_n}_note${n}" >/dev/null; do
78 [ "$(TPY "session${session_n}_note${n}")" ] && x=$n
81 for n in $(seq 1 $((${x:-0} + 3)) ); do
82 t_session_note $session_n $n
85 [button type="submit" .trailbtn $(l10n trailbtn)]
86 [button type="submit" name=delete_session value="$session_n" .delete $(l10n delete_session)]
96 [h2 . [a "/cards/#${id%.*}.vcf" ⬅ $(VCF FN |HTML)]]
100 [h2 $(l10n therapies)]
102 (cd "$_DATA/therapies/"; printf '%s\n' "${id%%.*}".*.tpy) \
103 | while read tpyfile; do
104 [ "$tpyfile" = "${id%%.*}.*.tpy" ] && break
105 tpy="${tpyfile%.tpy}";
106 tpydates="$(sed -En 's;^session[0-9]+_date:;;p;' "$_DATA/therapies/$tpyfile" \
108 | sed -E ':X;N;$!bX; s;^[\n ]+;;; s;[\n ]+$;;; s;(\n.*\n|\n); - ;;'
110 if [ "${tpy%.*}.${tpy#*.}" = "${id}" ]; then
111 printf '[a .item .therapy .current href="/therapies/%s" . %s] ' \
112 "${tpy%.*}/${tpy#*.}" "$(HTML "${tpydates:--}")"
114 printf '[a .item .therapy href="/therapies/%s" . %s] ' \
115 "${tpy%.*}/${tpy#*.}" "$(HTML "${tpydates:--}")"
119 [a .item .therapy href="/therapies/${id%%.*}/new" . +]
124 printf '[div .prescription [h2 %s]' "$(l10n therapy_prescription)"
127 for n in '' 0 1 2 3 4 5 6 7 8 9 10; do
128 remidy="$(MPX remidy$n)"
129 quantity="$(MPX quantity$n)"
130 quantity_weekly="$(MPX quantity_weekly$n)"
132 if [ "$remidy" -a "$quantity_weekly" ]; then
133 printf '[li %s %s %s]' "$(HTML "$quantity")" "$(HTML "$remidy")" "$(HTML "$quantity_weekly") $(l10n weekly)"
134 elif [ "$remidy" ]; then
135 printf '[li %s %s]' "$(HTML "$quantity")" "$(HTML "$remidy")"
140 for field in indicator icd10; do
141 val="$(MPX "$field")"
142 [ "$val" ] && printf '[span .%s [label . %s:]%s]' "$field" "$(l10n "$field")" "$(HTML "$val")"
145 if [ "$(MPX indicator_reading)" ]; then
146 printf '[h3 %s][p . %s]' \
147 "$(l10n indicator_reading)" "$(MPX indicator_reading |HTML)"
154 [form #report method=POST action="/therapies/update_therapy.sh"
157 [input .stickynote type=checkbox name=c_stickynote #show_stickynote]
158 [fieldset .stickynote
159 [label for="show_stickynote" $(l10n notes)]
161 [textarea name=stickynote . $(TPY stickynote |HTML)]
162 [button type=submit $(l10n save)]
167 # [input .stickynote type=checkbox name=c_timesheet #show_timesheet]
168 # [fieldset .stickynote
169 # [label for="show_timesheet" $(l10n timesheet)]
170 # [h2 $(l10n timesheet)]
172 # [th $(l10n time_goal)][th $(l10n time_actual)][th $(l10n time_difference)]
174 # $(for n in '' 0 1 2 3 4 5 6 7 8 9 10; do
175 # tsgoal="$(TPY tsgoal$n |grep -m1 -xE '[0-9]+')"
176 # tsactual="$(TPY tsactual$n |grep -m1 -xE '[0-9]+')"
177 # printf '[tr [td [input type=number name=tsgoal value="%s"]][td [input type=number name=tsactual value="%s"]][td %s]]' \
178 # "$tsgoal" "$tsactual" "$(( ${tsgoal:-0} - ${tsactual:-0} ))"
181 # [button type=submit $(l10n save)]
187 [span .no $(l10n number)][span .date $(l10n date)][span .therapist $(l10n therapist)][span .signature $(l10n signature)]
193 ## ==== Drawing canvas ==== ##
194 ### ====================== ###
196 penwidth="$(TPY penwidth |grep -xE -m1 '(4|12|36)' || printf '4')"
197 color="$(TPY color |grep -xE -m1 '#(000|00A|0A0|0AA|A00|A0A|AA0|FFF)' || printf '#000')"
200 [radio "penwidth" "4" #pw1 $(checked "$penwidth" 4) ][label for="pw2"]
201 [radio "penwidth" "12" #pw2 $(checked "$penwidth" 12)][label for="pw3"]
202 [radio "penwidth" "36" #pw3 $(checked "$penwidth" 36)][label for="pw1"]
205 [radio "color" "#000" .color #c000 $(checked "$color" '#000') ][label for=c000 ]
206 [radio "color" "#00A" .color #c001 $(checked "$color" '#00A') ][label for=c001 ]
207 [radio "color" "#0A0" .color #c010 $(checked "$color" '#0A0') ][label for=c010 ]
208 [radio "color" "#0AA" .color #c011 $(checked "$color" '#0AA') ][label for=c011 ]
209 [radio "color" "#A00" .color #c100 $(checked "$color" '#A00') ][label for=c100 ]
210 [radio "color" "#A0A" .color #c101 $(checked "$color" '#A0A') ][label for=c101 ]
211 [radio "color" "#AA0" .color #c110 $(checked "$color" '#AA0') ][label for=c110 ]
212 [radio "color" "#FFF" .color #c111 $(checked "$color" '#FFF') ][label for=c111 ]
214 [img .dotmark .bg src="/therapies/therapy_background.png" alt="WARNING: Missing background image!"]
215 [canvas #canvas .dotmark .ov width="${bg_dim%x*}" height="${bg_dim#*x}" ]
216 [input type=hidden #image_serialize name=imagedata value=""]
218 [button #savebutton type=submit $(l10n save)]
221 [span #jsdebug style="display: none; position: fixed; right:0; bottom:0" Debug]
223 [script type="text/javascript" src="/therapies/therapy_draw.js"]
224 [script type="text/javascript" src="/therapies/autosave.js"]