PageRenderTime 54ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/contrib/forms/psychiatrySet/psychiatrisch_onderzoek/autosave.php

https://github.com/sunsetsystems/openemr
PHP | 81 lines | 50 code | 14 blank | 17 comment | 6 complexity | 216a928cf873e1e4d004a14346115a88 MD5 | raw file
  1. <?php
  2. ////////////////////////////////////////////////////////////////////
  3. // Form: Psychiatrisch Onderzoek - Autosave
  4. // Package: Psychiatric Research - Dutch specific form
  5. // Created by: Larry Lart
  6. // Version: 1.0 - 29-03-2008
  7. ////////////////////////////////////////////////////////////////////
  8. //local includes
  9. include_once("../../globals.php");
  10. include_once("$srcdir/api.inc");
  11. include_once("$srcdir/forms.inc");
  12. // escape the strings
  13. foreach ($_POST as $k => $var)
  14. {
  15. $_POST[$k] = add_escape_custom($var);
  16. // echo "$var\n";
  17. }
  18. /////////////////
  19. // here we check to se if there was an autosave version prior to the real save
  20. $vectAutosave = sqlQuery( "SELECT id, autosave_flag, autosave_datetime FROM form_psychiatrisch_onderzoek
  21. WHERE pid = ".$_SESSION["pid"].
  22. " AND groupname='".$_SESSION["authProvider"].
  23. "' AND user='".$_SESSION["authUser"]."' AND
  24. authorized=$userauthorized AND activity=1
  25. AND autosave_flag=1
  26. ORDER by id DESC limit 1" );
  27. // if yes then update this else insert
  28. if( $vectAutosave['autosave_flag'] == 1 || $_POST["mode"] == "update" )
  29. {
  30. if( $_POST["mode"] == "update" )
  31. $newid = $_POST["id"];
  32. else
  33. $newid = $vectAutosave['id'];
  34. $strSql = "UPDATE form_psychiatrisch_onderzoek
  35. SET pid = ".$_SESSION["pid"].", groupname='".$_SESSION["authProvider"]."', user='".$_SESSION["authUser"]."',
  36. authorized=$userauthorized, activity=1, date = NOW(),
  37. datum_onderzoek='".$_POST["datum_onderzoek"]."',
  38. reden_van_aanmelding='".$_POST["reden_van_aanmelding"]."',
  39. conclusie_van_intake='".$_POST["conclusie_van_intake"]."',
  40. medicatie='".$_POST["medicatie"]."',
  41. anamnese='".$_POST["anamnese"]."',
  42. psychiatrisch_onderzoek='".$_POST["psychiatrisch_onderzoek"]."',
  43. beschrijvende_conclusie='".$_POST["beschrijvende_conclusie"]."',
  44. behandelvoorstel='".$_POST["behandelvoorstel"]."',
  45. autosave_flag=1,
  46. autosave_datetime=NOW()
  47. WHERE id = ".$newid.";";
  48. sqlQuery( $strSql );
  49. //echo "DEBUG :: id=$newid, sql=$strSql<br>";
  50. } else
  51. {
  52. $newid = formSubmit( "form_psychiatrisch_onderzoek", $_POST, $_GET["id"], $userauthorized );
  53. addForm( $encounter, "Psychiatric Examination", $newid, "psychiatrisch_onderzoek", $pid, $userauthorized );
  54. //echo "Debug :: insert<br>";
  55. }
  56. //get timestamp
  57. $result = sqlQuery("SELECT autosave_datetime FROM form_psychiatrisch_onderzoek
  58. WHERE pid = ".$_SESSION["pid"].
  59. " AND groupname='".$_SESSION["authProvider"].
  60. "' AND user='".$_SESSION["authUser"]."' AND
  61. authorized=$userauthorized AND activity=1 AND id=$newid
  62. AND autosave_flag=1
  63. ORDER by id DESC limit 1" );
  64. //$timestamp = mysql_result($result, 0);
  65. //output timestamp
  66. echo xl('Last Saved') . ': '.$result['autosave_datetime'];
  67. ?>