]> git.plutz.net Git - confetti/blob - templates/therapy.html.sh
05c50fd157f8338afa524c325cfbc568048703d2
[confetti] / templates / therapy.html.sh
1 # Copyright 2016 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   case "$tpy[$color]" in
26     \#888) c0=checked;;
27     \#00A) c1=checked;;
28     \#0A0) c2=checked;;
29     \#0AA) c3=checked;;
30     \#A00) c4=checked;;
31     \#A0A) c5=checked;;
32     \#AA0) c6=checked;;
33     *)    c7=checked;;
34   esac
35
36 cat <<EOF
37   <fieldset class=note>
38     <input class=color type=radio name="$color" value="#888" id=${color}_000 $c0><label for=${color}_000></label>
39     <input class=color type=radio name="$color" value="#00A" id=${color}_001 $c1><label for=${color}_001></label>
40     <input class=color type=radio name="$color" value="#0A0" id=${color}_010 $c2><label for=${color}_010></label>
41     <input class=color type=radio name="$color" value="#0AA" id=${color}_011 $c3><label for=${color}_011></label>
42     <input class=color type=radio name="$color" value="#A00" id=${color}_100 $c4><label for=${color}_100></label>
43     <input class=color type=radio name="$color" value="#A0A" id=${color}_101 $c5><label for=${color}_101></label>
44     <input class=color type=radio name="$color" value="#AA0" id=${color}_110 $c6><label for=${color}_110></label>
45     <input class=color type=radio name="$color" value="#FFF" id=${color}_111 $c7><label for=${color}_111></label>
46     <textarea name="session${session_n}_note${note_n}">${tpy[session${session_n}_note${note_n}]}</textarea>
47   </fieldset>
48 EOF
49 }
50
51 t_session(){
52   session_n="$1"
53
54   sid=session${session_n}
55
56   if [ "$tpy[${sid}_sigset]" = pos ]; then
57     sig=neg
58     sigcheck=checked
59   elif [ "$tpy[${sid}_sigset]" = neg ]; then
60     sig=pos
61     unset sigcheck
62   elif [ "$tpy[${sid}_signature]" = pos ]; then
63     sig=neg
64     sigcheck=checked
65   else
66     sig=pos
67     unset sigcheck
68   fi
69
70 cat <<EOF
71   <input type=hidden name=$sid value=exists>
72   <input class="tab" type="checkbox" id=${sid}_open name="${sid}_open" value="checked" ${tpy[${sid}_open]}>
73   <label class="tab" for="${sid}_open">
74     <span class=no>${session_n}.</span><!--
75  --><span class=date>${tpy[${sid}_date]}</span><!--
76  --><input class="date" name="${sid}_date" value="${tpy[${sid}_date]}" placeholder="$(l10n date)"><!--
77  --><span class=therapist>${tpy[${sid}_therapist]}</span><!--
78  --><input class="therapist" name="${sid}_therapist" value="${tpy[${sid}_therapist]}" placeholder="$(l10n therapist)"><!--
79  --><span class=signature><input type=checkbox name="${sid}_signature" value=pos $sigcheck><button type=submit name=${sid}_sigset value=$sig></button></span>
80   </label>
81   <div class=tab>
82     <img class="dotmark ov" src="/therapies/${id%.tpy}_${sid}.png" alt="">
83     $(n=1; while [ -n "${tpy[${sid}_note${n}]+x}" ]; do
84       t_session_note $session_n $n
85       n=$(($n+1))
86     done
87     printf '<button type=submit name=%s_note%s value="">+</button>' "$sid" "$n"
88     )
89
90     <button class=delete type=submit name=delete_session value=${session_n}>$(l10n delete_session)</button>
91     <button type=submit>$(l10n save)</button>
92   </div>
93 EOF
94 }
95
96 therapy_sessions(){
97   n=1; while [ -n "${tpy[session${n}]}" ]; do
98     t_session $n
99     n=$(($n+1))
100   done
101
102   sid=session$n
103
104 cat <<EOF
105   <fieldset class="tab">
106     <button class=no type=submit name=new_session value=$sid>+</button><!--
107  --><input class=date name=${sid}_date value="" placeholder="$(l10n date)" /><!--
108  --><input class=therapist name=${sid}_therapist value="" placeholder="$(l10n therapist)" /><!--
109  --><span class=signature><span></span>
110     <input type=hidden name="${sid}_note1" value="">
111   </fieldset>
112 EOF
113 }
114
115 unset c0 c1 c2 c3 c4 c5 c6 c7
116 case "$tpy[color]" in
117   \#00A) c1="checked";;
118   \#0A0) c2="checked";;
119   \#0AA) c3="checked";;
120   \#A00) c4="checked";;
121   \#A0A) c5="checked";;
122   \#AA0) c6="checked";;
123   \#FFF) c7="checked";;
124       *) c0="checked";;
125 esac
126
127 cat <<EOF
128 <h1>$(l10n therapy)</h1>
129
130 <div class="patient">
131   <h2>$client_name</h2>
132   <a href="?p=prescriptions&amp;client=${id%%.*}.vcf">&lt; $(l10n prescriptionlist)</a>
133 </div>
134
135 <div class="prescription">
136   <h2>$(l10n therapy_prescription)</h2>
137   <span class="insurance">${mpx[insurance]}</span>
138   <span class="date"><label>$(l10n date):</label>${mpx[date]}</span>
139
140   <label class="checkbox ${mpx[prescreviewed]:+checked}" for="prescreviewed">
141     $([ -n "${mpx[prescreviewed]}" ] && printf %s "$(l10n prescreviewed)" \
142                                      || printf %s "$(l10n prescreview)" )
143   </label>
144
145        ${mpx[prescno]:+<span class="prescno">$(l10n presc${mpx[prescno]})</span>}
146   ${mpx[grouptherapy]:+<span class="catalogue">$(l10n grouptherapy)</span>}
147      ${mpx[housecall]:+<span class="catalogue">$(l10n housecall)</span>}
148         ${mpx[report]:+<span class="catalogue">$(l10n report)</span>}
149
150   <ul>$(for n in '' {0..10}; do
151     [ -n "${mpx[remidy$n]}" ] && \
152     printf '<li>%s %s %s</li>' "${mpx[quantity$n]}" \
153                                "${mpx[remidy$n]}" \
154                                "${mpx[quantity_weekly$n]:+($mpx[quantity_weekly$n] $(l10n weekly))}"
155   done)</ul>
156
157   ${mpx[indicator]:+<span class="indicator"><label>$(l10n indicator):</label>${mpx[indicator]}</span>}
158       ${mpx[icd10]:+<span class="icd10">    <label>$(l10n icd10):</label>${mpx[icd10]}</span>}
159
160   ${mpx[addcontrib]:+
161   <label class='checkbox ${mpx[contribconfirm]:+checked}' for="addcontrib">
162     $([ -n "${mpx[contribconfirm]}" ] && printf %s "$(l10n contribconfirm)" ${mpx[contribconfirm]} \
163                                       || printf %s "$(l10n addcontrib)" )
164   </label>
165   }
166 </div>
167
168 <form method="POST" action="?action=update_therapy">
169   <input type="hidden" name="id" value="${id}">
170
171   <input class="stickynote" type="checkbox" name="c_stickynote" id="show_stickynote">
172   <fieldset class="stickynote">
173     <label for="show_stickynote">$(l10n notes)</label>
174     <textarea name="stickynote">${tpy[stickynote]}</textarea>
175     <button type=submit>$(l10n save)</button>
176   </fieldset>
177
178   <label class="tab heading">
179     <span class=no>$(l10n number)</span><!--
180  --><span class=date>$(l10n date)</span><!--
181  --><span class=therapist>$(l10n therapist)</span><!--
182  --><span class=signature>$(l10n signature)</span>
183   </label>
184 EOF
185
186 therapy_sessions
187
188 cat <<EOF
189   <fieldset class=color>
190     <input class=color type=radio name=color onclick="javascript:setcol('#000')" value="#000" id=c000 $c0><label for=c000></label>
191     <input class=color type=radio name=color onclick="javascript:setcol('#00A')" value="#00A" id=c001 $c1><label for=c001></label>
192     <input class=color type=radio name=color onclick="javascript:setcol('#0A0')" value="#0A0" id=c010 $c2><label for=c010></label>
193     <input class=color type=radio name=color onclick="javascript:setcol('#0AA')" value="#0AA" id=c011 $c3><label for=c011></label>
194     <input class=color type=radio name=color onclick="javascript:setcol('#A00')" value="#A00" id=c100 $c4><label for=c100></label>
195     <input class=color type=radio name=color onclick="javascript:setcol('#A0A')" value="#A0A" id=c101 $c5><label for=c101></label>
196     <input class=color type=radio name=color onclick="javascript:setcol('#AA0')" value="#AA0" id=c110 $c6><label for=c110></label>
197     <input class=color type=radio name=color onclick="javascript:setcol('#FFF')" value="#FFF" id=c111 $c7><label for=c111></label>
198   </fieldset>
199   <img class="dotmark bg" src="?static=therapy_background.png" alt="WARNING: Background Image not available!">
200   <canvas id="canvas" class="dotmark ov" width="${bg_dim%x*}" height="${bg_dim#*x}"></canvas>
201
202   <input type=hidden id=image_serialize name=imagedata value="">
203   <span id="jsdebug" style="display: none; position: fixed; right:0; bottom:0">Debug</span>
204
205   <script><!--
206   body = document.body
207   canvas = document.getElementById("canvas")
208   dbg = document.getElementById("jsdebug")
209   image = canvas.getContext("2d")
210   mouse = 0
211   image_serialize=""
212   data=document.getElementById("image_serialize")
213
214   function setcol(c) {
215     image.strokeStyle = c
216     if ( c == "#FFF" ) image.lineWidth = 32
217     else image.lineWidth = 4
218     image_serialize += " stroke " + c + " stroke-width " + image.lineWidth
219   }
220
221   setcol("$tpy[color]")
222
223   function draw(x, y) {
224     if ( mouse == 1){
225       if ( body.clientWidth >= 800 ){
226         sx=Math.floor(cscaleW * (x - canvas.offsetLeft))
227         sy=Math.floor(cscaleH * (y - canvas.offsetTop))
228       } else { 
229         sx=Math.floor(cscaleW * (x - canvas.offsetLeft + window.pageXOffset))
230         sy=Math.floor(cscaleH * (y - canvas.offsetTop + window.pageYOffset))
231       }
232       image.lineTo( sx, sy )
233       image.stroke()
234
235       image_serialize += " " + sx + "," + sy
236     }
237   }
238
239   function drawstart(x, y) {
240     mouse = 1
241
242     cscaleW = canvas.width / canvas.clientWidth
243     cscaleH = canvas.height / canvas.clientHeight
244
245     image_serialize += " polyline"
246     image.beginPath()
247     draw(x, y)
248   }
249   function drawstop() {
250    mouse = 0
251    image.closePath()
252    dbg.innerHTML = image_serialize
253    data.value = image_serialize
254   }
255
256   window.addEventListener( 'mouseup',   function()   { drawstop() } )
257   canvas.addEventListener( 'mousedown', function(e)  { drawstart(e.clientX, e.clientY) } )
258   canvas.addEventListener( 'mousemove', function(e)  {      draw(e.clientX, e.clientY) } )
259
260   window.addEventListener( 'touchend',   function()  { drawstop() } )
261   canvas.addEventListener( 'touchstart', function(e) { drawstart(e.touches[0].clientX, e.touches[0].clientY) } )
262   canvas.addEventListener( 'touchmove',  function(e) { e.preventDefault(); draw(e.touches[0].clientX, e.touches[0].clientY) } )
263
264   --></script>
265 </form>
266
267 EOF
268 # vi:set filetype=html: