PageRenderTime 28ms CodeModel.GetById 45ms RepoModel.GetById 0ms app.codeStats 0ms

/interface/forms/functional_cognitive_status/new.php

https://github.com/tmccormi/openemr
PHP | 238 lines | 207 code | 18 blank | 13 comment | 10 complexity | f26713412f79deb6f05245cf5c1e042f MD5 | raw file
  1. <?php
  2. /**
  3. * Functional cognitive status form.
  4. *
  5. * @package OpenEMR
  6. * @link http://www.open-emr.org
  7. * @author Jacob T Paul <jacob@zhservices.com>
  8. * @author Vinish K <vinish@zhservices.com>
  9. * @author Brady Miller <brady.g.miller@gmail.com>
  10. * @copyright Copyright (c) 2015 Z&H Consultancy Services Private Limited <sam@zhservices.com>
  11. * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
  12. * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
  13. */
  14. require_once("../../globals.php");
  15. require_once("$srcdir/api.inc");
  16. require_once("$srcdir/patient.inc");
  17. require_once("$srcdir/options.inc.php");
  18. require_once($GLOBALS['srcdir'] . '/csv_like_join.php');
  19. require_once($GLOBALS['fileroot'] . '/custom/code_types.inc.php');
  20. use OpenEMR\Core\Header;
  21. $returnurl = 'encounter_top.php';
  22. $formid = 0 + (isset($_GET['id']) ? $_GET['id'] : 0);
  23. if ($formid) {
  24. $sql = "SELECT * FROM `form_functional_cognitive_status` WHERE id=? AND pid = ? AND encounter = ?";
  25. $res = sqlStatement($sql, array($formid,$_SESSION["pid"], $_SESSION["encounter"]));
  26. for ($iter = 0; $row = sqlFetchArray($res); $iter++) {
  27. $all[$iter] = $row;
  28. }
  29. $check_res = $all;
  30. }
  31. $check_res = $formid ? $check_res : array();
  32. ?>
  33. <html>
  34. <head>
  35. <title><?php echo xlt("Functional and Cognitive Status"); ?></title>
  36. <?php Header::setupHeader(['datetime-picker']);?>
  37. <style type="text/css" title="mystyles" media="all">
  38. @media only screen and (max-width: 768px) {
  39. [class*="col-"] {
  40. width: 100%;
  41. text-align:left!Important;
  42. }
  43. </style>
  44. <script type="text/javascript">
  45. function duplicateRow(e) {
  46. var newRow = e.cloneNode(true);
  47. e.parentNode.insertBefore(newRow, e.nextSibling);
  48. changeIds('tb_row');
  49. changeIds('description');
  50. changeIds('activity');
  51. changeIds('activity1');
  52. changeIds('code');
  53. changeIds('codetext');
  54. changeIds('code_date');
  55. changeIds('displaytext');
  56. removeVal(newRow.id);
  57. }
  58. function removeVal(rowid)
  59. {
  60. rowid1 = rowid.split('tb_row_');
  61. document.getElementById("description_" + rowid1[1]).value = '';
  62. document.getElementById("activity_" + rowid1[1]).checked = false;
  63. document.getElementById("activity_" + rowid1[1]).value = 0;
  64. document.getElementById("activity1_" + rowid1[1]).value = 0;
  65. document.getElementById("code_" + rowid1[1]).value = '';
  66. document.getElementById("codetext_" + rowid1[1]).value = '';
  67. document.getElementById("code_date_" + rowid1[1]).value = '';
  68. document.getElementById("displaytext_" + rowid1[1]).innerHTML = '';
  69. }
  70. function changeIds(class_val) {
  71. var elem = document.getElementsByClassName(class_val);
  72. for (var i = 0; i < elem.length; i++) {
  73. if (elem[i].id) {
  74. index = i + 1;
  75. elem[i].id = class_val + "_" + index;
  76. }
  77. }
  78. }
  79. function deleteRow(rowId)
  80. {
  81. if (rowId != 'tb_row_1') {
  82. var elem = document.getElementById(rowId);
  83. elem.parentNode.removeChild(elem);
  84. }
  85. }
  86. function sel_code(id)
  87. {
  88. id = id.split('tb_row_');
  89. var checkId = '_' + id[1];
  90. document.getElementById('clickId').value = checkId;
  91. dlgopen('<?php echo $GLOBALS['webroot'] . "/interface/patient_file/encounter/" ?>find_code_popup.php?codetype=SNOMED-CT', '_blank', 700, 400);
  92. }
  93. function set_related(codetype, code, selector, codedesc) {
  94. var checkId = document.getElementById('clickId').value;
  95. document.getElementById("code" + checkId).value = code;
  96. document.getElementById("codetext" + checkId).value = codedesc;
  97. document.getElementById("displaytext" + checkId).innerHTML = codedesc;
  98. }
  99. function checkVal(id)
  100. {
  101. var id1 = id.split('activity_')
  102. if (document.getElementById(id).checked)
  103. {
  104. document.getElementById(id).value = 1;
  105. document.getElementById('activity1_' + id1[1]).value = 1;
  106. }
  107. else
  108. {
  109. document.getElementById(id).value = 0;
  110. document.getElementById('activity1_' + id1[1]).value = 0;
  111. }
  112. }
  113. $(document).ready(function() {
  114. // special case to deal with static and dynamic datepicker items
  115. $(document).on('mouseover','.datepicker', function(){
  116. $(this).datetimepicker({
  117. <?php $datetimepicker_timepicker = false; ?>
  118. <?php $datetimepicker_showseconds = false; ?>
  119. <?php $datetimepicker_formatInput = false; ?>
  120. <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
  121. <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
  122. });
  123. });
  124. });
  125. </script>
  126. </head>
  127. <body class="body_top">
  128. <div class="container">
  129. <div class="row">
  130. <div class="page-header">
  131. <h2><?php echo xlt('Functional and Cognitive Status Form'); ?></h2>
  132. </div>
  133. </div>
  134. <div class="row">
  135. <form method='post' name='my_form' action='<?php echo $rootdir; ?>/forms/functional_cognitive_status/save.php?id=<?php echo attr($formid); ?>'>
  136. <fieldset>
  137. <legend><?php echo xlt('Enter Details'); ?></legend>
  138. <?php
  139. if (!empty($check_res)) {
  140. foreach ($check_res as $key => $obj) { ?>
  141. <div class="tb_row" id="tb_row_<?php echo attr($key) + 1; ?>">
  142. <div class="form-group">
  143. <div class=" forms col-xs-3">
  144. <label for="code_<?php echo attr($key) + 1; ?>" class="h5"><?php echo xlt('Code'); ?>:</label>
  145. <input type="text" id="code_<?php echo attr($key) + 1; ?>" name="code[]" class="form-control code" value="<?php echo text($obj{"code"}); ?>" onclick='sel_code(this.parentElement.parentElement.parentElement.id);'>
  146. <span id="displaytext_<?php echo attr($key) + 1; ?>" class="displaytext help-block"></span>
  147. <input type="hidden" id="codetext_<?php echo attr($key) + 1; ?>" name="codetext[]" class="codetext" value="<?php echo text($obj{"codetext"}); ?>">
  148. </div>
  149. <div class="forms col-xs-4">
  150. <label for="description_<?php echo attr($key) + 1; ?>" class="h5"><?php echo xlt('Description'); ?>:</label>
  151. <textarea name="description[]" id="description_<?php echo attr($key) + 1; ?>" class="form-control description" rows="3" ><?php echo text($obj{"description"}); ?></textarea>
  152. </div>
  153. <div class="forms col-xs-2">
  154. <label for="code_date_<?php echo attr($key) + 1; ?>" class="h5"><?php echo xlt('Date'); ?>:</label>
  155. <input type='text' id="code_date_<?php echo attr($key) + 1; ?>" name='code_date[]' class="form-control code_date datepicker" value='<?php echo attr($obj{"date"}); ?>' title='<?php echo xla('yyyy-mm-dd Date of service'); ?>' />
  156. </div>
  157. <div class="forms col-xs-2">
  158. <label for="activity_1" class="h5"><?php echo xlt('Active'); ?>:&nbsp;</label>
  159. <br>
  160. <input type="checkbox" name="activity[]" onclick="checkVal(this.id);" id="activity_<?php echo $key + 1; ?>" value="<?php echo attr($obj{"activity"}); ?>" <?php echo ($obj{"activity"} == 1) ? "checked='checked'" : ""; ?> class="activity">
  161. <input type="hidden" name="activity1[]" id="activity1_<?php echo $key + 1; ?>" value="<?php echo attr($obj{"activity"}); ?>" class="activity1">
  162. </div>
  163. <div class="forms col-xs-1" style="padding-top:35px">
  164. <i class="fa fa-plus-circle fa-2x" aria-hidden="true" onclick="duplicateRow(this.parentElement.parentElement.parentElement);" title='<?php echo xla('Click here to duplicate the row'); ?>'></i>
  165. <i class="fa fa-times-circle fa-2x text-danger" aria-hidden="true" onclick="deleteRow(this.parentElement.parentElement.parentElement.id);" title='<?php echo xla('Click here to delete the row'); ?>'></i>
  166. </div>
  167. <div class="clearfix"></div>
  168. <input type="hidden" name="count[]" id="count_<?php echo attr($key) + 1; ?>" class="count" value="<?php echo attr($key) + 1;?>">
  169. </div>
  170. </div>
  171. <?php
  172. }
  173. } else { ?>
  174. <div class="tb_row" id="tb_row_1">
  175. <div class="form-group">
  176. <div class=" forms col-xs-3">
  177. <label for="code_1" class="h5"><?php echo xlt('Code'); ?>:</label>
  178. <input type="text" id="code_1" name="code[]" class="form-control code" value="<?php echo text($obj{"code"}); ?>" onclick='sel_code(this.parentElement.parentElement.parentElement.id);'>
  179. <span id="displaytext_1" class="displaytext help-block"></span>
  180. <input type="hidden" id="codetext_1" name="codetext[]" class="codetext" value="<?php echo text($obj{"codetext"}); ?>">
  181. </div>
  182. <div class="forms col-xs-5">
  183. <label for="description_1" class="h5"><?php echo xlt('Description'); ?>:</label>
  184. <textarea name="description[]" id="description_1" class="form-control description" rows="3" ><?php echo text($obj{"description"}); ?></textarea>
  185. </div>
  186. <div class="forms col-xs-2">
  187. <label for="code_date_1" class="h5"><?php echo xlt('Date'); ?>:</label>
  188. <input type='text' id="code_date_1" name='code_date[]' class="form-control code_date datepicker" value='<?php echo attr($obj{"date"}); ?>' title='<?php echo xla('yyyy-mm-dd Date of service'); ?>' />
  189. </div>
  190. <div class="forms col-xs-1">
  191. <label for="activity_1" class="h5"><?php echo xlt('Active'); ?>:&nbsp;</label>
  192. <br>
  193. <input type="checkbox" name="activity[]" onclick="checkVal(this.id);" id="activity_1" value="0" class="activity">
  194. <input type="hidden" name="activity1[]" id="activity1_1" value="0" class="activity1">
  195. </div>
  196. <div class="forms col-xs-1 " style="padding-top:35px">
  197. <i class="fa fa-plus-circle fa-2x" aria-hidden="true" onclick="duplicateRow(this.parentElement.parentElement.parentElement);" title='<?php echo xla('Click here to duplicate the row'); ?>'></i>
  198. <i class="fa fa-times-circle fa-2x text-danger" aria-hidden="true" onclick="deleteRow(this.parentElement.parentElement.parentElement.id);" title='<?php echo xla('Click here to delete the row'); ?>'></i>
  199. </div>
  200. <div class="clearfix"></div>
  201. <input type="hidden" name="count[]" id="count_1" class="count" value="1">
  202. </div>
  203. </div>
  204. <?php }
  205. ?>
  206. </fieldset>
  207. <div class="form-group clearfix">
  208. <div class="col-sm-12 position-override">
  209. <div class="btn-group oe-opt-btn-group-pinch" role="group">
  210. <button type="submit" onclick="top.restoreSession()" class="btn btn-default btn-save"><?php echo xlt('Save'); ?></button>
  211. <button type="button" class="btn btn-link btn-cancel oe-opt-btn-separate-left" onclick="top.restoreSession(); parent.closeTab(window.name, false)"><?php echo xlt('Cancel');?></button>
  212. <input type="hidden" id="clickId" value="">
  213. </div>
  214. </div>
  215. </div>
  216. </form>
  217. </div>
  218. </div>
  219. </body>
  220. </html>