Lobster: time sheet on therapy note
[confetti] / templates / therapy.html.sh
1 # Copyright 2016, 2017 Paul Hänsch
2 #
3 # This file is part of Confetti.
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 # Confetti 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 Confetti.  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)</h1>
107
108 <div class="patient">
109   <h2>$client_name</h2>
110   <a href="?p=prescriptions&amp;client=${id%%.*}.vcf">&lt; $(l10n prescriptionlist)</a>
111 </div>
112
113 <div class="prescription">
114   <h2>$(l10n therapy_prescription)</h2>
115   <span class="insurance">${mpx[insurance]}</span>
116   <span class="date"><label>$(l10n date):</label>${mpx[date]}</span>
117
118   <label class="checkbox ${mpx[prescreviewed]:+checked}" for="prescreviewed">
119     $([ -n "${mpx[prescreviewed]}" ] && printf %s "$(l10n prescreviewed)" \
120                                      || printf %s "$(l10n prescreview)" )
121   </label>
122
123        ${mpx[prescno]:+<span class="prescno">$(l10n presc${mpx[prescno]})</span>}
124   ${mpx[grouptherapy]:+<span class="catalogue">$(l10n grouptherapy)</span>}
125      ${mpx[housecall]:+<span class="catalogue">$(l10n housecall)</span>}
126         ${mpx[report]:+<span class="catalogue">$(l10n report)</span>}
127
128   <ul>$(for n in '' {0..10}; do
129     [ -n "${mpx[remidy$n]}" ] && \
130     printf '<li>%s %s %s</li>' "${mpx[quantity$n]}" \
131                                "${mpx[remidy$n]}" \
132                                "${mpx[quantity_weekly$n]:+($mpx[quantity_weekly$n] $(l10n weekly))}"
133   done)</ul>
134
135   ${mpx[indicator]:+<span class="indicator"><label>$(l10n indicator):</label>${mpx[indicator]}</span>}
136       ${mpx[icd10]:+<span class="icd10">    <label>$(l10n icd10):</label>${mpx[icd10]}</span>}
137
138   ${mpx[addcontrib]:+
139   <label class='checkbox ${mpx[contribconfirm]:+checked}' for="addcontrib">
140     $([ -n "${mpx[contribconfirm]}" ] && printf %s "$(l10n contribconfirm)" ${mpx[contribconfirm]} \
141                                       || printf %s "$(l10n addcontrib)" )
142   </label>
143   }
144
145   <input class="tab" type="checkbox" id="indicator_reading">
146   <label class="tab" for="indicator_reading">$(l10n indicator_reading)</label>
147   <div class="tab">${mpx[indicator_reading]}</div>
148 </div>
149
150 <form id="report" method="POST" action="?action=update_therapy">
151   <input type="hidden" name="id" value="${id}">
152
153   <input class="stickynote" type="checkbox" name="c_stickynote" id="show_stickynote">
154   <fieldset class="stickynote">
155     <label for="show_stickynote">$(l10n notes)</label>
156     <h2>$(l10n notes)</h2>
157     <textarea name="stickynote">${tpy[stickynote]}</textarea>
158     <button type="submit">$(l10n save)</button>
159   </fieldset>
160
161   <input class="stickynote" type="checkbox" name="c_timesheet" id="show_timesheet">
162   <fieldset class="stickynote">
163     <label for="show_timesheet">$(l10n timesheet)</label>
164     <h2>$(l10n timesheet)</h2>
165     <table><thead>
166       <tr><th>$(l10n time_goal)</th><th>$(l10n time_actual)</th><th>$(l10n time_difference)</th></tr>
167     </thead><tbody>
168       $(for n in '' {0..10}; do
169         printf '<tr><td><input type="number" name="tsgoal" value="%s"/></td>
170                     <td><input type="number" name="tsactual" value="%s"/></td>
171                     <td>%s</td>
172                 </tr>\n' \
173                 "$mpx[tsgoal${n}]" "$mpx[tsactual${n}]" "$((${mpx[tsgoal${n}]:-0} - ${mpx[tsactual${n}]:-0}))"
174       done)
175     </tbody></table>
176     <button type="submit">$(l10n save)</button>
177   </fieldset>
178
179   <!--input class="tab" type="checkbox" id="lookout">
180   <label class="tab" for="lookout">$(l10n indicator_reading)</label>
181   <div class="tab"><textarea name="lookout">${mpx[lookout]}</textarea -->
182
183   <label class="tab heading">
184     <span class=no>$(l10n number)</span><!--
185  --><span class=date>$(l10n date)</span><!--
186  --><span class=therapist>$(l10n therapist)</span><!--
187  --><span class=signature>$(l10n signature)</span>
188   </label>
189 EOF
190
191 therapy_sessions
192
193 _checked="$(validate "$tpy[penwidth]" '(4|12|36)' '4')"
194 cat <<EOF
195   <fieldset class="penwidth">
196     <input type="radio" name="penwidth" value="4"  id="pw1" $(checked  4)><label for="pw2"></label>
197     <input type="radio" name="penwidth" value="12" id="pw2" $(checked 12)><label for="pw3"></label>
198     <input type="radio" name="penwidth" value="36" id="pw3" $(checked 36)><label for="pw1"></label>
199   </fieldset>
200 EOF
201
202 _checked="$(validate "$tpy[color]" '#(0[0A]{2}|A00|A0A|AA0|FFF)' '#000')"
203 cat <<EOF
204   <fieldset class="color">
205     <input class="color" type="radio" name="color" value="#000" id="c000" $(checked \#000)><label for="c000"></label>
206     <input class="color" type="radio" name="color" value="#00A" id="c001" $(checked \#00A)><label for="c001"></label>
207     <input class="color" type="radio" name="color" value="#0A0" id="c010" $(checked \#0A0)><label for="c010"></label>
208     <input class="color" type="radio" name="color" value="#0AA" id="c011" $(checked \#0AA)><label for="c011"></label>
209     <input class="color" type="radio" name="color" value="#A00" id="c100" $(checked \#A00)><label for="c100"></label>
210     <input class="color" type="radio" name="color" value="#A0A" id="c101" $(checked \#A0A)><label for="c101"></label>
211     <input class="color" type="radio" name="color" value="#AA0" id="c110" $(checked \#AA0)><label for="c110"></label>
212     <input class="color" type="radio" name="color" value="#FFF" id="c111" $(checked \#FFF)><label for="c111"></label>
213   </fieldset>
214   <img class="dotmark bg" src="?static=therapy_background.png" alt="WARNING: Background Image not available!">
215   <canvas id="canvas" class="dotmark ov" width="${bg_dim%x*}" height="${bg_dim#*x}"></canvas>
216
217   <input type=hidden id=image_serialize name=imagedata value="">
218
219   <button type="submit">$(l10n save)</button>
220 </form>
221
222 <span id="jsdebug" style="display: none; position: fixed; right:0; bottom:0">Debug</span>
223
224 <script type="text/javascript" src="?static=therapy_draw.js"></script>
225 EOF
226
227 # vi:set filetype=html: