]> git.plutz.net Git - lobster/blob - therapies/page.sh
c3f3c5c40097dbb2da10d94246d1581cff97f553
[lobster] / therapies / page.sh
1 # Copyright 2016, 2017, 2020 Paul Hänsch
2 #
3 # This file is part of Lobster.
4
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.
9
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.
14
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/>. 
17
18 # t_session_note(){
19 #   session_n="$1"
20 #   note_n="$2"
21 #   
22 #   color=session${session_n}_note${note_n}_color
23 #   unset c0 c1 c2 c3 c4 c5 c6 c7
24 #   
25 #   if [ "$note_n" -eq 1 -o -n "${tpy[session${session_n}_note${note_n}]}" ]; then
26 #     printf '<input class="trailbtn" type="checkbox" checked="checked">'
27 #   else
28 #     printf '<input class="trailbtn" type="checkbox">'
29 #   fi
30
31 #   _checked="$(validate "$tpy[$color]" '#(888|00A|0A0|0AA|A00|A0A|AA0)' '#FFF')"
32 #       cat <<-EOF
33 #         <fieldset class="note trailbox">
34 #           <input class=color type=radio name="$color" value="#888" id=${color}_000 $(checked \#888)><label for=${color}_000></label>
35 #           <input class=color type=radio name="$color" value="#00A" id=${color}_001 $(checked \#00A)><label for=${color}_001></label>
36 #           <input class=color type=radio name="$color" value="#0A0" id=${color}_010 $(checked \#0A0)><label for=${color}_010></label>
37 #           <input class=color type=radio name="$color" value="#0AA" id=${color}_011 $(checked \#0AA)><label for=${color}_011></label>
38 #           <input class=color type=radio name="$color" value="#A00" id=${color}_100 $(checked \#A00)><label for=${color}_100></label>
39 #           <input class=color type=radio name="$color" value="#A0A" id=${color}_101 $(checked \#A0A)><label for=${color}_101></label>
40 #           <input class=color type=radio name="$color" value="#AA0" id=${color}_110 $(checked \#AA0)><label for=${color}_110></label>
41 #           <input class=color type=radio name="$color" value="#FFF" id=${color}_111 $(checked \#FFF)><label for=${color}_111></label>
42 #           <textarea name="session${session_n}_note${note_n}">${tpy[session${session_n}_note${note_n}]}</textarea>
43 #         </fieldset>
44 #       EOF
45 # }
46
47 # t_session(){
48 #   session_n="$1"
49
50 #   sid=session${session_n}
51
52 #   if [ "$tpy[${sid}_sigset]" = pos ]; then
53 #     sigcheck=checked
54 #   else
55 #     unset sigcheck
56 #   fi
57
58 #       cat <<-EOF
59 #         <input type=hidden name=$sid value=exists>
60 #         <input class="tab" type="checkbox" id=${sid}_open name="${sid}_open" value="checked" ${tpy[${sid}_open]}>
61 #         <label class="tab" for="${sid}_open">
62 #           <span class=no>${session_n}.</span><!--
63 #        --><span class=date>${tpy[${sid}_date]}</span><!--
64 #        --><input class="date" name="${sid}_date" value="${tpy[${sid}_date]}" placeholder="$(l10n date)"><!--
65 #        --><span class=therapist>${tpy[${sid}_therapist]}</span><!--
66 #        --><input class="therapist" name="${sid}_therapist" value="${tpy[${sid}_therapist]}" placeholder="$(l10n therapist)"><!--
67 #        --><span class=signature><input type="checkbox" name="${sid}_sigset" value="pos" $sigcheck></span>
68 #         </label>
69 #         <div class=tab>
70 #           <img class="dotmark ov" src="/therapies/${id%.tpy}_${sid}.png" alt="">
71 #           $(n=1;
72 #               while [ -n "${tpy[session${session_n}_note${n}]+x}" ]; do
73 #                 if [ -n "${tpy[session${session_n}_note${n}]}" ]; then
74 #                   x=$n
75 #                 fi
76 #                 n=$(($n + 1))
77 #               done
78 #               for n in $(seq 1 $((${x:-0} + 3)) ); do t_session_note $session_n $n; done
79 #              )
80 #           <button class="trailbtn" type="submit">$(l10n trailsave)</button>
81 #           <button class=delete type=submit name=delete_session value=${session_n}>$(l10n delete_session)</button>
82 #         </div>
83 #       EOF
84 # }
85
86 # therapy_sessions(){
87 #   n=1; while [ -n "${tpy[session${n}]}" ]; do
88 #     t_session $n
89 #     n=$(($n+1))
90 #   done
91
92 #   sid=session$n
93
94 #       cat <<-EOF
95 #         <fieldset class="tab">
96 #           <button class=no type=submit name=new_session value=$sid>+</button><!--
97 #        --><input class=date name=${sid}_date value="" placeholder="$(l10n date)" /><!--
98 #        --><input class=therapist name=${sid}_therapist value="" placeholder="$(l10n therapist)" /><!--
99 #        --><span class=signature><span></span>
100 #           <input type=hidden name="${sid}_note1" value="">
101 #         </fieldset>
102 #       EOF
103 # }
104
105 cat <<EOF
106 [h1 $(l10n therapy)]
107
108 [div .patient
109   [h2 . $(pdi_value "$vcf" FN)]
110   [a href="/cards/#${id%.*}.vcf" \< $(l10n client)]
111 ]
112
113 [div .prescription
114   [h2 $(l10n therapy_prescription)]
115   [span .insurance . $(pdi_value "$mpx" INSURANCE)]
116   [span .date [label $(l10n date):] $(pdi_value "$mpx" DATE)]
117 EOF
118
119   if [ "$(pdi_value "$mpx" PRESCREVIEWED)" ]; then
120     printf '[label .checkbox .checked for=prescreviewed . %s]' "$(l10n prescreviewed)"
121   else
122     printf '[label .checkbox for=prescreviewed . %s]' "$(l10n prescreview)"
123   fi
124
125   field="$(pdi_value "$mpx" PRESCNO)"
126   [ "$field" ] && printf '[span .prescno . %s]' "$(l10n "presc$field")"
127   for field in grouptherapy housecall report; do
128     [ "$(pdi_value "$mpx" "$field")" ] && printf '[span .catalogue . %s]' "$(l10n "$field")"
129   done
130
131   printf '[ul'
132   for n in '' 0 1 2 3 4 5 6 7 8 9 10; do
133     remidy="$(pdi_value "$mpx" REMIDY$n)"
134     quantity="$(pdi_value "$mpx" QUANTITY$n)"
135     quantity_weekly="$(pdi_value "$mpx" QUANTITY_WEEKLY$n)"
136
137     if [ "$remidy" -a "$quantity_weekly" ]; then
138       printf '[li %s %s %s]' "$quantity" "$remidy" "$quantity_weekly $(l10n weekly)"
139     elif [ "$remidy" ]; then
140       printf '[li %s %s]' "$quantity" "$remidy"
141     fi
142   done
143   printf ']'
144
145   for field in indicator icd10; do
146     val="$(pdi_value "$mpx" "$field")"
147     [ "$val" ] && printf '[span .%s [label . %s:]%s]' "$field" "$(l10n "$field")" "$val"
148   done
149
150   addcontrib="$(pdi_value "$mpx" ADDCONTRIB)"
151   contribconfirm="$(pdi_value "$mpx" CONTRIBCONFIRM)"
152
153   if [ "$addcontrib" -a "$contribconfirm" ]; then
154     printf '[label .checkbox .checked for=addcontrib . %s %s]' "$(l10n contribconfirm)" "$contribconfirm"
155   elif [ "$addcontrib" ]; then
156     printf '[label .checkbox for=addcontrib . %s]' "$(l10n addcontrib)"
157   fi
158
159 cat <<EOF
160   [input .tab type="checkbox" #indicator_reading][label .tab for=indicator_reading $(l10n indicator_reading)]
161   [div .tab . $(pdi_value "$mpx" INDICATOR_READING)]
162 ]
163
164 [form #report method=POST action="/therapies/update_therapy.sh"
165   [input type=hidden name=id value="$id"]
166
167   [input .stickynote type=checkbox name=c_stickynote #show_stickynote]
168   [fieldset .stickynote
169     [label for="show_stickynote" $(l10n notes)]
170     [h2 $(l10n notes)]
171     [textarea name=stickynote . $(pdi_value "$tpy" STICKYNOTE)]
172     [button type=submit $(l10n save)]
173   ]
174
175   [input .stickynote type=checkbox name=c_timesheet #show_timesheet]
176   [fieldset .stickynote
177     [label for="show_timesheet" $(l10n timesheet)]
178     [h2 $(l10n timesheet)]
179     [table [thead [tr
180       [th $(l10n time_goal)][th $(l10n time_actual)][th $(l10n time_difference)]
181     ]][tbody
182       $(for n in '' 0 1 2 3 4 5 6 7 8 9 10; do
183         tsgoal="$(pdi_value "$tpy" TSGOAL$n)"
184         tsactual="$(pdi_value "$tpy" TSACTUAL$n)"
185         printf '[tr [td [input type=number name=tsgoal value="%s"]][td [input type=number name=tsactual value="%s"]][td %s]]' \
186                "$tsgoal" "$tsactual" "$(( ${tsgoal:-0} - ${tsactual:-0} ))"
187       done)
188     ]]
189     [button type=submit $(l10n save)]
190   ]
191
192   [label .tab .heading
193     [span .no $(l10n number)][span .date $(l10n date)][span .therapist $(l10n therapist)][span .signature $(l10n signature)]
194   ]
195 EOF
196
197 # therapy_sessions
198
199 penwith="$(pdi_value "$tpy" PENWITH |grep -xE -m1 '(4|12|36)' || printf '4')"
200 color="$(pdi_value "$tpy" COLOR |grep -xE -m1 '#(000|00A|0A0|0AA|A00|A0A|AA0|FFF)' || printf '#000')"
201 cat <<EOF
202   [fieldset .penwidth
203     [radio "penwidth" "4"  #pw1 $(checked $penwidth 4) ][label for="pw2"]
204     [radio "penwidth" "12" #pw2 $(checked $penwidth 12)][label for="pw3"]
205     [radio "penwidth" "36" #pw3 $(checked $penwidth 36)][label for="pw1"]
206   ]
207   [fieldset .color
208     [radio "color" "#000" .color #c000 $(checked $color '#000') ][label for=c000 ]
209     [radio "color" "#00A" .color #c001 $(checked $color '#00A') ][label for=c001 ]
210     [radio "color" "#0A0" .color #c010 $(checked $color '#0A0') ][label for=c010 ]
211     [radio "color" "#0AA" .color #c011 $(checked $color '#0AA') ][label for=c011 ]
212     [radio "color" "#A00" .color #c100 $(checked $color '#A00') ][label for=c100 ]
213     [radio "color" "#A0A" .color #c101 $(checked $color '#A0A') ][label for=c101 ]
214     [radio "color" "#AA0" .color #c110 $(checked $color '#AA0') ][label for=c110 ]
215     [radio "color" "#FFF" .color #c111 $(checked $color '#FFF') ][label for=c111 ]
216   ]
217   [img .dotmark .bg src="/therapies/therapy_background.png" alt="WARNING: Missing background image!"]
218   [canvas #canvas .dotmark .ov width="${bg_dim%x*}" height="${bg_dim#*x}" ]
219   [input type=hidden #image_serialize name=imagedata value=""]
220
221   [button type=submit $(l10n save)]
222 ]
223
224 [span #jsdebug style="display: none; position: fixed; right:0; bottom:0" Debug]
225
226 [script type="text/javascript" src="/therapies/therapy_draw.js"]
227 EOF