]> git.plutz.net Git - lobster/blobdiff - therapies/page.sh
auto submit therapy form data
[lobster] / therapies / page.sh
index ecf113ae8f6c150213609909961a200db38dd1c8..c3d8078567331ca783385b8db8462e38e030c148 100755 (executable)
@@ -93,34 +93,42 @@ cat <<EOF
 [h1 $(l10n therapy)]
 
 [div .patient
-  [h2 . $(VCF FN |HTML)]
-  [a href="/cards/#${id%.*}.vcf" \< $(l10n client)]
+  [h2 . [a "/cards/#${id%.*}.vcf" &#x2b05; $(VCF FN |HTML)]]
 ]
 
-[div .prescription
-  [h2 $(l10n therapy_prescription)]
-  [span .insurance . $(MPX insurance |HTML)]
-  [span .date [label $(l10n date):] $(MPX date |HTML)]
+[div .therapies
+  [h2 $(l10n therapies)]
+  $(
+  (cd "$_DATA/therapies/"; printf '%s\n' "${id%%.*}".*.tpy) \
+  | while read tpyfile; do
+    [ "$tpyfile" = "${id%%.*}.*.tpy" ] && break
+    tpy="${tpyfile%.tpy}";
+    tpydates="$(sed -En 's;^session[0-9]+_date:;;p;' "$_DATA/therapies/$tpyfile" \
+                | sort \
+                | sed -E ':X;N;$!bX; s;^[\n ]+;;; s;[\n ]+$;;; s;(\n.*\n|\n); - ;;'
+               )"
+    if [ "${tpy%.*}.${tpy#*.}" = "${id}" ]; then
+      printf '[a .item .therapy .current href="/therapies/%s" . %s] ' \
+             "${tpy%.*}/${tpy#*.}" "$(HTML "${tpydates:--}")"
+    else
+      printf '[a .item .therapy href="/therapies/%s" . %s] ' \
+             "${tpy%.*}/${tpy#*.}" "$(HTML "${tpydates:--}")"
+    fi
+  done |sort -n
+  )
+  [a .item .therapy href="/therapies/${id%%.*}/new" . +]
+]
 EOF
 
-  if [ "$(MPX prescreviewed)" ]; then
-    printf '[label .checkbox .checked for=prescreviewed . %s]' "$(l10n prescreviewed)"
-  else
-    printf '[label .checkbox for=prescreviewed . %s]' "$(l10n prescreview)"
-  fi
-
-  field="$(MPX prescno)"
-  [ "$field" ] && printf '[span .prescno . %s]' "$(l10n "presc$field")"
-  for field in grouptherapy housecall report; do
-    [ "$(MPX "$field")" ] && printf '[span .catalogue . %s]' "$(l10n "$field")"
-  done
-
+if [ "$mpx" ]; then
+  printf '[div .prescription [h2 %s]' "$(l10n therapy_prescription)"
+  
   printf '[ul'
   for n in '' 0 1 2 3 4 5 6 7 8 9 10; do
     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]' "$(HTML "$quantity")" "$(HTML "$remidy")" "$(HTML "$quantity_weekly") $(l10n weekly)"
     elif [ "$remidy" ]; then
@@ -128,26 +136,21 @@ EOF
     fi
   done
   printf ']'
-
+  
   for field in indicator icd10; do
     val="$(MPX "$field")"
     [ "$val" ] && printf '[span .%s [label . %s:]%s]' "$field" "$(l10n "$field")" "$(HTML "$val")"
   done
-
-  addcontrib="$(MPX addcontrib)"
-  contribconfirm="$(MPX contribconfirm)"
-
-  if [ "$addcontrib" -a "$contribconfirm" ]; then
-    printf '[label .checkbox .checked for=addcontrib . %s %s]' "$(l10n contribconfirm)" "$(HTML $contribconfirm)"
-  elif [ "$addcontrib" ]; then
-    printf '[label .checkbox for=addcontrib . %s]' "$(l10n addcontrib)"
+  
+  if [ "$(MPX indicator_reading)" ]; then
+    printf '[h3 %s][p . %s]' \
+           "$(l10n indicator_reading)" "$(MPX indicator_reading |HTML)"
   fi
 
-cat <<EOF
-  [input .tab type="checkbox" #indicator_reading][label .tab for=indicator_reading $(l10n indicator_reading)]
-  [div .tab . $(MPX indicator_reading |HTML)]
-]
+  printf ']'
+fi
 
+cat <<EOF
 [form #report method=POST action="/therapies/update_therapy.sh"
   [hidden "id" "$id"]
 
@@ -208,10 +211,11 @@ cat <<EOF
   [canvas #canvas .dotmark .ov width="${bg_dim%x*}" height="${bg_dim#*x}" ]
   [input type=hidden #image_serialize name=imagedata value=""]
 
-  [button type=submit $(l10n save)]
+  [button #savebutton type=submit $(l10n save)]
 ]
 
 [span #jsdebug style="display: none; position: fixed; right:0; bottom:0" Debug]
 
 [script type="text/javascript" src="/therapies/therapy_draw.js"]
+[script type="text/javascript" src="/therapies/autosave.js"]
 EOF