Save ID of selected medical issue (#1797)
[openemr.git] / interface / patient_file / summary / add_edit_issue.php
blobd2e221641f8a83ad56da7cb3fc1cb55ba2b0215f
1 <?php
2 /**
3 * add or edit a medical problem.
5 * Copyright (C) 2005-2016 Rod Roark <rod@sunsetsystems.com>
6 * Copyright (C) 2017 Brady Miller <brady.g.miller@gmail.com>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * @package OpenEMR
14 * @author Rod Roark <rod@sunsetsystems.com>
15 * @author Brady Miller <brady.g.miller@gmail.com>
16 * @link http://www.open-emr.org
21 require_once('../../globals.php');
22 require_once($GLOBALS['srcdir'].'/lists.inc');
23 require_once($GLOBALS['srcdir'].'/patient.inc');
24 require_once($GLOBALS['srcdir'].'/acl.inc');
25 require_once($GLOBALS['srcdir'].'/options.inc.php');
26 require_once($GLOBALS['fileroot'].'/custom/code_types.inc.php');
27 require_once($GLOBALS['srcdir'].'/csv_like_join.php');
29 // TBD - Resolve functional issues if opener is included in Header
31 <script type="text/javascript" src="<?php echo $webroot ?>/interface/main/tabs/js/include_opener.js?v=<?php echo $v_js_includes; ?>"></script>
32 <?php
33 use OpenEMR\Core\Header;
35 if ($_POST['form_save']) {
36 // Following hidden field received in the form will be used to ensure integrity of form values
37 // 'issue', 'thispid', 'thisenc'
38 $issue = $_POST['issue'];
39 $thispid = $_POST['thispid'];
40 $thisenc = $_POST['thisenc'];
41 } else {
42 $issue = $_REQUEST['issue'];
43 $thispid = 0 + (empty($_REQUEST['thispid']) ? $pid : $_REQUEST['thispid']);
44 // A nonempty thisenc means we are to link the issue to the encounter.
45 $thisenc = 0 + (empty($_REQUEST['thisenc']) ? 0 : $_REQUEST['thisenc']);
48 if (isset($ISSUE_TYPES['football_injury'])) {
49 if ($ISSUE_TYPES['football_injury']) {
50 // Most of the logic for the "football injury" issue type comes from this
51 // included script. We might eventually refine this approach to support
52 // a plug-in architecture for custom issue types.
53 require_once($GLOBALS['srcdir'].'/football_injury.inc.php');
57 if (isset($ISSUE_TYPES['ippf_gcac'])) {
58 if ($ISSUE_TYPES['ippf_gcac']) {
59 // Similarly for IPPF issues.
60 require_once($GLOBALS['srcdir'].'/ippf_issues.inc.php');
64 $info_msg = "";
66 // A nonempty thistype is an issue type to be forced for a new issue.
67 $thistype = empty($_REQUEST['thistype']) ? '' : $_REQUEST['thistype'];
69 if ($thistype && !$issue && !acl_check_issue($thistype, '', array('write', 'addonly'))) {
70 die(xlt("Add is not authorized!"));
73 $tmp = getPatientData($thispid, "squad");
74 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad'])) {
75 die(xlt("Not authorized for this squad!"));
78 function QuotedOrNull($fld)
80 if ($fld) {
81 return "'".add_escape_custom($fld)."'";
84 return "NULL";
87 // Do not use this function since quotes are added in query escaping mechanism
88 // Only keeping since used in the football injury code football_injury.inc.php that is included.
89 // If start using this function, then incorporate the add_escape_custom() function into it
90 function rbvalue($rbname)
92 $tmp = $_POST[$rbname];
93 if (! $tmp) {
94 $tmp = '0';
97 return "'$tmp'";
100 function cbvalue($cbname)
102 return $_POST[$cbname] ? '1' : '0';
105 function invalue($inname)
107 return (int) trim($_POST[$inname]);
110 // Do not use this function since quotes are added in query escaping mechanism
111 // Only keeping since used in the football injury code football_injury.inc.php that is included.
112 // If start using this function, then incorporate the add_escape_custom() function into it
113 function txvalue($txname)
115 return "'" . trim($_POST[$txname]) . "'";
118 function rbinput($name, $value, $desc, $colname)
120 global $irow;
121 $ret = "<input type='radio' name='".attr($name)."' value='".attr($value)."'";
122 if ($irow[$colname] == $value) {
123 $ret .= " checked";
126 $ret .= " />".text($desc);
127 return $ret;
130 function rbcell($name, $value, $desc, $colname)
132 return "<td width='25%' nowrap>" . rbinput($name, $value, $desc, $colname) . "</td>\n";
135 // Given an issue type as a string, compute its index.
136 function issueTypeIndex($tstr)
138 global $ISSUE_TYPES;
139 $i = 0;
140 foreach ($ISSUE_TYPES as $key => $value) {
141 if ($key == $tstr) {
142 break;
145 ++$i;
148 return $i;
151 function ActiveIssueCodeRecycleFn($thispid2, $ISSUE_TYPES2)
153 ///////////////////////////////////////////////////////////////////////
154 // Active Issue Code Recycle Function authored by epsdky (2014-2015) //
155 ///////////////////////////////////////////////////////////////////////
157 $modeIssueTypes = array();
158 $issueTypeIdx2 = array();
159 $idx2 = 0;
161 foreach ($ISSUE_TYPES2 as $issueTypeX => $isJunk) {
162 $modeIssueTypes[$idx2] = $issueTypeX;
163 $issueTypeIdx2[$issueTypeX] = $idx2;
164 ++$idx2;
167 $pe2 = array($thispid2);
168 $qs2 = str_repeat('?, ', count($modeIssueTypes) - 1) . '?';
169 $sqlParameters2 = array_merge($pe2, $modeIssueTypes);
171 $codeList2 = array();
173 $issueCodes2 = sqlStatement("SELECT diagnosis FROM lists WHERE pid = ? AND enddate is NULL AND type IN ($qs2)", $sqlParameters2);
175 while ($issueCodesRow2 = sqlFetchArray($issueCodes2)) {
176 if ($issueCodesRow2['diagnosis'] != "") {
177 $someCodes2 = explode(";", $issueCodesRow2['diagnosis']);
178 $codeList2 = array_merge($codeList2, $someCodes2);
182 if ($codeList2) {
183 $codeList2 = array_unique($codeList2);
184 sort($codeList2);
187 $memberCodes = array();
188 $memberCodes[0] = array();
189 $memberCodes[1] = array();
190 $memberCodes[2] = array();
192 $allowedCodes2 = array();
193 $allowedCodes2[0] = collect_codetypes("medical_problem");
194 $allowedCodes2[1] = collect_codetypes("diagnosis");
195 $allowedCodes2[2] = collect_codetypes("drug");
197 // Test membership of codes to each code type set
198 foreach ($allowedCodes2 as $akey1 => $allowCodes2) {
199 foreach ($codeList2 as $listCode2) {
200 list($codeTyX,) = explode(":", $listCode2);
202 if (in_array($codeTyX, $allowCodes2)) {
203 array_push($memberCodes[$akey1], $listCode2);
208 // output sets of display options
209 $displayCodeSets[0] = $memberCodes[0]; // medical_problem
210 $displayCodeSets[1] = array_merge($memberCodes[1], $memberCodes[2]); // allergy
211 $displayCodeSets[2] = array_merge($memberCodes[2], $memberCodes[1]); // medication
212 $displayCodeSets[3] = $memberCodes[1]; // default
214 echo "var listBoxOptionSets = new Array();\n\n";
216 foreach ($displayCodeSets as $akey => $displayCodeSet) {
217 echo "listBoxOptionSets[" . attr($akey) . "] = new Array();\n";
219 if ($displayCodeSet) {
220 foreach ($displayCodeSet as $dispCode2) {
221 $codeDesc2 = lookup_code_descriptions($dispCode2);
222 echo "listBoxOptionSets[" . attr($akey) . "][listBoxOptionSets[" . attr($akey) . "].length] = new Option('" . attr($dispCode2) . " (" . attr(trim($codeDesc2)) . ") ' ,'" . attr($dispCode2) . "' , false, false);\n";
227 // map issues to a set of display options
228 $modeIndexMapping = array();
230 foreach ($modeIssueTypes as $akey2 => $isJunk) {
231 $modeIndexMapping[$akey2] = 3;
234 if (array_key_exists("medical_problem", $issueTypeIdx2)) {
235 $modeIndexMapping[$issueTypeIdx2['medical_problem']] = 0;
238 if (array_key_exists("allergy", $issueTypeIdx2)) {
239 $modeIndexMapping[$issueTypeIdx2['allergy']] = 1;
242 if (array_key_exists("medication", $issueTypeIdx2)) {
243 $modeIndexMapping[$issueTypeIdx2['medication']] = 2;
246 echo "\nvar listBoxOptions2 = new Array();\n\n";
248 foreach ($modeIssueTypes as $akey2 => $isJunk) {
249 echo "listBoxOptions2[" . attr($akey2) . "] = listBoxOptionSets[" . attr($modeIndexMapping[$akey2]) . "];\n";
252 ///////////////////////////////////////////////////////////////////////
253 // End of Active Issue Code Recycle Function main code block //
254 ///////////////////////////////////////////////////////////////////////
257 // If we are saving, then save and close the window.
259 if ($_POST['form_save']) {
260 $i = 0;
261 $text_type = "unknown";
262 foreach ($ISSUE_TYPES as $key => $value) {
263 if ($i++ == $_POST['form_type']) {
264 $text_type = $key;
268 $form_begin = fixDate($_POST['form_begin'], '');
269 $form_end = fixDate($_POST['form_end'], '');
271 if ($text_type == 'football_injury') {
272 $form_injury_part = $_POST['form_injury_part'];
273 $form_injury_type = $_POST['form_injury_type'];
274 } else {
275 $form_injury_part = $_POST['form_medical_system'];
276 $form_injury_type = $_POST['form_medical_type'];
279 if ($issue) {
280 $query = "UPDATE lists SET " .
281 "type = '" . add_escape_custom($text_type) . "', " .
282 "title = '" . add_escape_custom($_POST['form_title']) . "', " .
283 "comments = '" . add_escape_custom($_POST['form_comments']) . "', " .
284 "begdate = " . QuotedOrNull($form_begin) . ", " .
285 "enddate = " . QuotedOrNull($form_end) . ", " .
286 "returndate = " . QuotedOrNull($form_return) . ", " .
287 "diagnosis = '" . add_escape_custom($_POST['form_diagnosis']) . "', " .
288 "occurrence = '" . add_escape_custom($_POST['form_occur']) . "', " .
289 "classification = '" . add_escape_custom($_POST['form_classification']) . "', " .
290 "reinjury_id = '" . add_escape_custom($_POST['form_reinjury_id']) . "', " .
291 "referredby = '" . add_escape_custom($_POST['form_referredby']) . "', " .
292 "injury_grade = '" . add_escape_custom($_POST['form_injury_grade']) . "', " .
293 "injury_part = '" . add_escape_custom($form_injury_part) . "', " .
294 "injury_type = '" . add_escape_custom($form_injury_type) . "', " .
295 "outcome = '" . add_escape_custom($_POST['form_outcome']) . "', " .
296 "destination = '" . add_escape_custom($_POST['form_destination']) . "', " .
297 "reaction ='" . add_escape_custom($_POST['form_reaction']) . "', " .
298 "severity_al ='" . add_escape_custom($_POST['form_severity_id']) . "', " .
299 "list_option_id ='" . add_escape_custom($_POST['form_title_id']) . "', " .
300 "erx_uploaded = '0', " .
301 "modifydate = NOW() " .
302 "WHERE id = '" . add_escape_custom($issue) . "'";
303 sqlStatement($query);
304 if ($text_type == "medication" && enddate != '') {
305 sqlStatement('UPDATE prescriptions SET '
306 . 'medication = 0 where patient_id = ? '
307 . " and upper(trim(drug)) = ? "
308 . ' and medication = 1', array($thispid,strtoupper($_POST['form_title'])));
310 } else {
311 $issue = sqlInsert("INSERT INTO lists ( " .
312 "date, pid, type, title, activity, comments, begdate, enddate, returndate, " .
313 "diagnosis, occurrence, classification, referredby, user, groupname, " .
314 "outcome, destination, reinjury_id, injury_grade, injury_part, injury_type, " .
315 "reaction, severity_al, list_option_id " .
316 ") VALUES ( " .
317 "NOW(), " .
318 "'" . add_escape_custom($thispid) . "', " .
319 "'" . add_escape_custom($text_type) . "', " .
320 "'" . add_escape_custom($_POST['form_title']) . "', " .
321 "1, " .
322 "'" . add_escape_custom($_POST['form_comments']) . "', " .
323 QuotedOrNull($form_begin) . ", " .
324 QuotedOrNull($form_end) . ", " .
325 QuotedOrNull($form_return) . ", " .
326 "'" . add_escape_custom($_POST['form_diagnosis']) . "', " .
327 "'" . add_escape_custom($_POST['form_occur']) . "', " .
328 "'" . add_escape_custom($_POST['form_classification']) . "', " .
329 "'" . add_escape_custom($_POST['form_referredby']) . "', " .
330 "'" . add_escape_custom($$_SESSION['authUser']) . "', " .
331 "'" . add_escape_custom($$_SESSION['authProvider']) . "', " .
332 "'" . add_escape_custom($_POST['form_outcome']) . "', " .
333 "'" . add_escape_custom($_POST['form_destination']) . "', " .
334 "'" . add_escape_custom($_POST['form_reinjury_id']) . "', " .
335 "'" . add_escape_custom($_POST['form_injury_grade']) . "', " .
336 "'" . add_escape_custom($form_injury_part) . "', " .
337 "'" . add_escape_custom($form_injury_type) . "', " .
338 "'" . add_escape_custom($_POST['form_reaction']) . "', " .
339 "'" . add_escape_custom($_POST['form_severity_id']) . "', " .
340 "'" . add_escape_custom($_POST['form_title_id']) . "' " .
341 ")");
344 // For record/reporting purposes, place entry in lists_touch table.
345 setListTouch($thispid, $text_type);
347 if ($text_type == 'football_injury') {
348 issue_football_injury_save($issue);
351 if ($text_type == 'ippf_gcac') {
352 issue_ippf_gcac_save($issue);
355 if ($text_type == 'contraceptive') {
356 issue_ippf_con_save($issue);
359 // If requested, link the issue to a specified encounter.
360 if ($thisenc) {
361 $query = "INSERT INTO issue_encounter ( " .
362 "pid, list_id, encounter " .
363 ") VALUES ( ?,?,? )";
364 sqlStatement($query, array($thispid,$issue,$thisenc));
367 $tmp_title = addslashes($ISSUE_TYPES[$text_type][2] . ": $form_begin " .
368 substr($_POST['form_title'], 0, 40));
370 // Close this window and redisplay the updated list of issues.
372 echo "<html><body><script language='JavaScript'>\n";
373 if ($info_msg) {
374 echo " alert('$info_msg');\n";
377 echo " var myboss = opener ? opener : parent;\n";
378 echo " if (myboss.refreshIssue) myboss.refreshIssue('" . attr($issue) . "','$tmp_title');\n";
379 echo " else if (myboss.reloadIssues) myboss.reloadIssues();\n";
380 echo " else myboss.location.reload();\n";
381 echo " dlgclose();\n";
383 echo "</script></body></html>\n";
384 exit();
387 $irow = array();
388 if ($issue) {
389 $irow = sqlQuery("SELECT * FROM lists WHERE id = ?", array($issue));
390 if (!acl_check_issue($irow['type'], '', 'write')) {
391 die(xlt("Edit is not authorized!"));
393 } else if ($thistype) {
394 $irow['type'] = $thistype;
397 $type_index = 0;
399 if (!empty($irow['type'])) {
400 foreach ($ISSUE_TYPES as $key => $value) {
401 if ($key == $irow['type']) {
402 break;
405 ++$type_index;
409 <html>
410 <head>
411 <?php Header::setupHeader(['common', 'jquery-ui', 'datetime-picker', 'select2']); ?>
412 <title><?php echo ($issue ? xlt('Edit') : xlt('Add New')) . ' ' . xlt('Issue'); ?></title>
414 <style>
416 td, input, select, textarea {
417 font-family: Arial, Helvetica, sans-serif;
418 font-size: 10pt;
421 div.section {
422 border: solid;
423 border-width: 1px;
424 border-color: #0000ff;
425 margin: 0 0 0 10pt;
426 padding: 5pt;
429 /* Override theme's selected tab top color so it matches tab contents. */
430 ul.tabNav li.current a { background:#ffffff; }
432 </style>
434 <script language="JavaScript">
436 var aitypes = new Array(); // issue type attributes
437 var aopts = new Array(); // Option objects
438 <?php
439 $i = 0;
440 foreach ($ISSUE_TYPES as $key => $value) {
441 echo " aitypes[$i] = " . attr($value[3]) . ";\n";
442 echo " aopts[$i] = new Array();\n";
443 $qry = sqlStatement("SELECT * FROM list_options WHERE list_id = ? AND activity = 1", array($key."_issue_list"));
444 while ($res = sqlFetchArray($qry)) {
445 echo " aopts[$i][aopts[$i].length] = new Option('".attr(xl_list_label(trim($res['title'])))."', '".attr(trim($res['option_id']))."', false, false);\n";
446 if ($res['codes']) {
447 echo " aopts[$i][aopts[$i].length-1].setAttribute('data-code','".attr(trim($res['codes']))."');\n";
451 ++$i;
454 ///////////
455 ActiveIssueCodeRecycleFn($thispid, $ISSUE_TYPES);
456 ///////////
459 <?php require($GLOBALS['srcdir'] . "/restoreSession.php"); ?>
461 ///////////////////////////
462 function codeBoxFunction2() {
463 var f = document.forms[0];
464 var x2 = f.form_codeSelect2.options[f.form_codeSelect2.selectedIndex].value;
465 f.form_codeSelect2.selectedIndex = -1;
466 var x6 = f.form_diagnosis.value;
467 if (x6.length > 0) x6 += ";";
468 x6 += x2;
469 f.form_diagnosis.value = x6;
471 ///////////////////////////
473 // React to selection of an issue type. This loads the associated
474 // shortcuts into the selection list of titles, and determines which
475 // rows are displayed or hidden.
476 function newtype(index) {
477 var f = document.forms[0];
478 var theopts = f.form_titles.options;
479 theopts.length = 0;
480 var i = 0;
481 for (i = 0; i < aopts[index].length; ++i) {
482 theopts[i] = aopts[index][i];
484 document.getElementById('row_titles').style.display = i ? '' : 'none';
486 ///////////////////////
487 var listBoxOpts2 = f.form_codeSelect2.options;
488 listBoxOpts2.length = 0;
489 var ix = 0;
490 for (ix = 0; ix < listBoxOptions2[index].length; ++ix) {
491 listBoxOpts2[ix] = listBoxOptions2[index][ix];
492 listBoxOpts2[ix].title = listBoxOptions2[index][ix].text;
494 document.getElementById('row_codeSelect2').style.display = ix ? '' : 'none';
495 //////////////////////
497 // Show or hide various rows depending on issue type, except do not
498 // hide the comments or referred-by fields if they have data.
499 var comdisp = (aitypes[index] == 1) ? 'none' : '';
500 var revdisp = (aitypes[index] == 1) ? '' : 'none';
501 var injdisp = (aitypes[index] == 2) ? '' : 'none';
502 var nordisp = (aitypes[index] == 0) ? '' : 'none';
503 // reaction row should be displayed only for medication allergy.
504 var alldisp = (index == <?php echo issueTypeIndex('allergy'); ?>) ? '' : 'none';
505 document.getElementById('row_enddate' ).style.display = comdisp;
506 // Note that by default all the issues will not show the active row
507 // (which is desired functionality, since then use the end date
508 // to inactivate the item.)
509 document.getElementById('row_active' ).style.display = revdisp;
510 document.getElementById('row_diagnosis' ).style.display = comdisp;
511 document.getElementById('row_occurrence' ).style.display = comdisp;
512 document.getElementById('row_classification').style.display = injdisp;
513 document.getElementById('row_reinjury_id' ).style.display = injdisp;
514 document.getElementById('row_severity' ).style.display = alldisp;
515 document.getElementById('row_reaction' ).style.display = alldisp;
516 document.getElementById('row_referredby' ).style.display = (f.form_referredby.value) ? '' : comdisp;
517 document.getElementById('row_comments' ).style.display = (f.form_comments.value ) ? '' : revdisp;
518 document.getElementById('row_referredby' ).style.display = (f.form_referredby.value) ? '' : comdisp;
520 <?php
521 if ($ISSUE_TYPES['football_injury']) {
522 // Generate more of these for football injury fields.
523 issue_football_injury_newtype();
526 if ($ISSUE_TYPES['ippf_gcac'] && !$_POST['form_save']) {
527 // Generate more of these for gcac and contraceptive fields.
528 if (empty($issue) || $irow['type'] == 'ippf_gcac') {
529 issue_ippf_gcac_newtype();
532 if (empty($issue) || $irow['type'] == 'contraceptive') {
533 issue_ippf_con_newtype();
539 // If a clickoption title is selected, copy it to the title field.
540 // If it has a code, add that too.
541 function set_text() {
542 var f = document.forms[0];
543 f.form_title.value = f.form_titles.options[f.form_titles.selectedIndex].text;
544 f.form_title_id.value = f.form_titles.options[f.form_titles.selectedIndex].value;
545 f.form_diagnosis.value = f.form_titles.options[f.form_titles.selectedIndex].getAttribute('data-code');
546 f.form_titles.selectedIndex = -1;
549 // Process click on Delete link.
550 function deleteme() {
551 dlgopen('../deleter.php?issue=<?php echo attr($issue) ?>', '_blank', 500, 450);
552 return false;
555 // Called by the deleteme.php window on a successful delete.
556 function imdeleted() {
557 closeme();
560 function closeme() {
561 dlgclose();
564 // Called when the Active checkbox is clicked. For consistency we
565 // use the existence of an end date to indicate inactivity, even
566 // though the simple verion of the form does not show an end date.
567 function activeClicked(cb) {
568 var f = document.forms[0];
569 if (cb.checked) {
570 f.form_end.value = '';
571 } else {
572 var today = new Date();
573 f.form_end.value = '' + (today.getYear() + 1900) + '-' +
574 (today.getMonth() + 1) + '-' + today.getDate();
578 // Called when resolved outcome is chosen and the end date is entered.
579 function outcomeClicked(cb) {
580 var f = document.forms[0];
581 if (cb.value == '1'){
582 var today = new Date();
583 f.form_end.value = '' + (today.getYear() + 1900) + '-' +
584 ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2);
585 f.form_end.focus();
589 // This is for callback by the find-code popup.
590 // Appends to or erases the current list of diagnoses.
591 function set_related(codetype, code, selector, codedesc) {
592 var f = document.forms[0];
593 var s = f.form_diagnosis.value;
594 var title = f.form_title.value;
595 if (code) {
596 //disabled duplicate codes
597 if (s.indexOf(codetype + ':' + code) == -1){
598 if (s.length > 0) s += ';';
599 s += codetype + ':' + code;
601 } else {
602 s = '';
604 f.form_diagnosis.value = s;
605 if(title == '') f.form_title.value = codedesc;
608 // This is for callback by the find-code popup.
609 // Returns the array of currently selected codes with each element in codetype:code format.
610 function get_related() {
611 return document.forms[0].form_diagnosis.value.split(';');
614 // This is for callback by the find-code popup.
615 // Deletes the specified codetype:code from the currently selected list.
616 function del_related(s) {
617 my_del_related(s, document.forms[0].form_diagnosis, false);
620 // This invokes the find-code popup.
621 function sel_diagnosis() {
622 <?php
623 $url = '../encounter/find_code_dynamic.php?codetype=';
624 if ($irow['type'] == 'medical_problem') {
625 $url .= collect_codetypes("medical_problem", "csv");
626 } else {
627 $url .= collect_codetypes("diagnosis", "csv");
628 $tmp = collect_codetypes("drug", "csv");
629 if ($irow['type'] == 'allergy') {
630 if ($tmp) {
631 $url .= ",$tmp";
633 } else if ($irow['type'] == 'medication') {
634 if ($tmp) {
635 $url .= ",$tmp&default=$tmp";
640 dlgopen('<?php echo $url; ?>', '_blank', 800, 725);
643 // Check for errors when the form is submitted.
644 function validate() {
645 var f = document.forms[0];
646 if(f.form_begin.value > f.form_end.value && (f.form_end.value)) {
647 alert("<?php echo addslashes(xl('Please Enter End Date greater than Begin Date!')); ?>");
648 return false;
650 if (! f.form_title.value) {
651 alert("<?php echo addslashes(xl('Please enter a title!')); ?>");
652 return false;
654 top.restoreSession();
655 return true;
658 // Supports customizable forms (currently just for IPPF).
659 function divclick(cb, divid) {
660 var divstyle = document.getElementById(divid).style;
661 if (cb.checked) {
662 divstyle.display = 'block';
663 } else {
664 divstyle.display = 'none';
666 return true;
669 $(document).ready(function() {
670 $('.datepicker').datetimepicker({
671 <?php $datetimepicker_timepicker = false; ?>
672 <?php $datetimepicker_showseconds = false; ?>
673 <?php $datetimepicker_formatInput = false; ?>
674 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
675 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
679 </script>
681 </head>
683 <body class="body_top" style="padding-right:0.5em">
685 <ul class="tabNav">
686 <li class='current'><a href='#'><?php echo xlt('Issue'); ?></a></li>
687 <?php
688 // Build html tab data for each visit form linked to this issue.
689 $tabcontents = '';
690 if ($issue) {
691 $vres = sqlStatement(
692 "SELECT f.id, f.encounter, f.form_name, f.form_id, f.formdir, fe.date " .
693 "FROM forms AS f, form_encounter AS fe WHERE " .
694 "f.pid = ? AND f.issue_id = ? AND f.deleted = 0 AND " .
695 "fe.pid = f.pid and fe.encounter = f.encounter " .
696 "ORDER BY fe.date DESC, f.id DESC",
697 array($thispid, $issue)
699 while ($vrow = sqlFetchArray($vres)) {
700 $formdir = $vrow['formdir'];
701 $formid = $vrow['form_id'];
702 $visitid = $vrow['encounter'];
703 echo " <li><a href='#'>" . text(oeFormatShortDate(substr($vrow['date'], 0, 10))) . ' ' .
704 text($vrow['form_name']) . "</a></li>\n";
705 $tabcontents .= "<div class='tab' style='height:90%;width:98%;'>\n";
706 $tabcontents .= "<iframe frameborder='0' style='height:100%;width:100%;' " .
707 "src='../../forms/LBF/new.php?formname=$formdir&id=$formid&visitid=$visitid&from_issue_form=1'" .
708 ">Oops</iframe>\n";
709 $tabcontents .= "</div>\n";
713 </ul>
715 <div class="tabContainer">
716 <div class='tab current' style='height:auto;width:97%;'>
718 <form method='post' name='theform' onsubmit='return validate()'>
720 <?php
721 // action setting not required in html5. By default form will submit to itself.
722 // Provide key values previously passed as part of action string.
723 foreach (array('issue'=>$issue, 'thispid'=>$thispid, 'thisenc'=>$thisenc) as $fldName => $fldVal) {
724 printf('<input name="%s" type="hidden" value="%s"/>%s', $fldName, attr($fldVal), PHP_EOL);
728 <table border='0' width='100%'>
730 <tr>
731 <td valign='top' width='1%' nowrap><b><?php echo xlt('Type'); ?>:</b></td>
732 <td>
733 <?php
734 $index = 0;
735 foreach ($ISSUE_TYPES as $key => $value) {
736 if ($issue || $thistype) {
737 if ($index == $type_index) {
738 echo text($value[1]);
739 echo "<input type='hidden' name='form_type' value='".attr($index)."'>\n";
741 } else {
742 echo " <input type='radio' name='form_type' value='".attr($index)."' onclick='newtype($index)'";
743 if ($index == $type_index) {
744 echo " checked";
747 if (!acl_check_issue($key, '', array('write','addonly'))) {
748 echo " disabled";
751 echo " />" . text($value[1]) . "&nbsp;\n";
754 ++$index;
757 </td>
758 </tr>
760 <tr id='row_titles'>
761 <td valign='top' nowrap>&nbsp;</td>
762 <td valign='top'>
763 <select name='form_titles' size='4' onchange='set_text()'></select>
764 <p><?php echo xlt('(Select one of these, or type your own title)'); ?></p>
765 </td>
766 </tr>
768 <tr>
769 <td valign='top' id='title_diagnosis' nowrap><b><?php echo xlt('Title'); ?>:</b></td>
770 <td>
771 <input type='text' size='40' name='form_title' value='<?php echo attr($irow['title']) ?>' style='width:100%' />
772 <input type='hidden' name='form_title_id' value='<?php echo attr($irow['list_option_id']) ?>'/>
773 </td>
774 </tr>
776 <tr id='row_codeSelect2'>
777 <td><b><?php echo xlt('Active Issue Codes'); ?>:</b>
778 </td>
779 <td>
780 <select name='form_codeSelect2' size='4' onchange="codeBoxFunction2()" style="max-width:100%;">
781 </select>
782 </td>
783 </tr>
785 <tr id='row_diagnosis'>
786 <td valign='top' nowrap><b><?php echo xlt('Coding'); ?>:</b></td>
787 <td>
788 <input type='text' size='50' name='form_diagnosis'
789 value='<?php echo attr($irow['diagnosis']) ?>' onclick='sel_diagnosis()'
790 title='<?php echo xla('Click to select or change coding'); ?>'
791 style='width:100%' readonly />
792 </td>
793 </tr>
795 <tr>
796 <td valign='top' nowrap><b><?php echo xlt('Begin Date'); ?>:</b></td>
797 <td>
799 <input type='text' size='10' class='datepicker' name='form_begin' id='form_begin'
800 value='<?php echo attr($irow['begdate']) ?>'
801 title='<?php echo xla('yyyy-mm-dd date of onset, surgery or start of medication'); ?>' />
802 </td>
803 </tr>
805 <tr id='row_enddate'>
806 <td valign='top' nowrap><b><?php echo xlt('End Date'); ?>:</b></td>
807 <td>
808 <input type='text' size='10' class='datepicker' name='form_end' id='form_end'
809 value='<?php echo attr($irow['enddate']) ?>'
810 title='<?php echo xla('yyyy-mm-dd date of recovery or end of medication'); ?>' />
811 &nbsp;(<?php echo xlt('leave blank if still active'); ?>)
812 </td>
813 </tr>
815 <tr id='row_active'>
816 <td valign='top' nowrap><b><?php echo xlt('Active'); ?>:</b></td>
817 <td>
818 <input type='checkbox' name='form_active' value='1' <?php echo attr($irow['enddate']) ? "" : "checked"; ?>
819 onclick='activeClicked(this);'
820 title='<?php echo xla('Indicates if this issue is currently active'); ?>' />
821 </td>
822 </tr>
824 <tr id='row_returndate'>
825 <td>
826 <input type='hidden' name='form_return' id='form_return' />
827 <input type='hidden' name='row_reinjury_id' id='row_reinjury_id' />
828 <img
829 id='img_return'/>
830 </td>
831 </tr>
835 <tr id='row_occurrence'>
836 <td valign='top' nowrap><b><?php echo xlt('Occurrence'); ?>:</b></td>
837 <td>
838 <?php
839 // Modified 6/2009 by BM to incorporate the occurrence items into the list_options listings
840 generate_form_field(array('data_type'=>1,'field_id'=>'occur','list_id'=>'occurrence','empty_title'=>'SKIP'), $irow['occurrence']);
842 </td>
843 </tr>
845 <tr id='row_classification'>
847 <td valign='top' nowrap><b><?php echo xlt('Classification'); ?>:</b></td>
848 <td>
849 <select name='form_classification'>
850 <?php
851 foreach ($ISSUE_CLASSIFICATIONS as $key => $value) {
852 echo " <option value='".attr($key)."'";
853 if ($key == $irow['classification']) {
854 echo " selected";
857 echo ">".text($value)."\n";
860 </select>
861 </td>
862 </tr>
864 <!-- Reaction For Medication Allergy -->
865 <tr id='row_severity'>
866 <td valign='top' nowrap><b><?php echo xlt('Severity'); ?>:</b></td>
867 <td><?php
868 $severity=$irow['severity_al'];
869 generate_form_field(array('data_type'=>1,'field_id'=>'severity_id','list_id'=>'severity_ccda','empty_title'=>'SKIP'), $severity);
871 </td>
872 </tr>
873 <tr id='row_reaction'>
874 <td valign='top' nowrap><b><?php echo xlt('Reaction'); ?>:</b></td>
875 <td>
876 <?php
877 echo generate_select_list('form_reaction', 'reaction', $irow['reaction'], '', '', '', '');
879 </td>
880 </tr>
881 <!-- End of reaction -->
883 <tr id='row_referredby'>
884 <td valign='top' nowrap><b><?php echo xlt('Referred by'); ?>:</b></td>
885 <td>
886 <input type='text' size='40' name='form_referredby' value='<?php echo attr($irow['referredby']) ?>'
887 style='width:100%' title='<?php echo xla('Referring physician and practice'); ?>' />
888 </td>
889 </tr>
891 <tr id='row_comments'>
892 <td valign='top' nowrap><b><?php echo xlt('Comments'); ?>:</b></td>
893 <td>
894 <textarea name='form_comments' rows='4' cols='40' wrap='virtual' style='width:100%'><?php echo text($irow['comments']) ?></textarea>
895 </td>
896 </tr>
898 <tr<?php if ($GLOBALS['ippf_specific']) {
899 echo " style='display:none;'";
900 } ?>>
901 <td valign='top' nowrap><b><?php echo xlt('Outcome'); ?>:</b></td>
902 <td>
903 <?php
904 echo generate_select_list('form_outcome', 'outcome', $irow['outcome'], '', '', '', 'outcomeClicked(this);');
906 </td>
907 </tr>
909 <tr<?php if ($GLOBALS['ippf_specific']) {
910 echo " style='display:none;'";
911 } ?>>
912 <td valign='top' nowrap><b><?php echo xlt('Destination'); ?>:</b></td>
913 <td>
914 <?php if (true) { ?>
915 <input type='text' size='40' name='form_destination' value='<?php echo attr($irow['destination']) ?>'
916 style='width:100%' title='GP, Secondary care specialist, etc.' />
917 <?php } else { // leave this here for now, please -- Rod ?>
918 <?php echo rbinput('form_destination', '1', 'GP', 'destination') ?>&nbsp;
919 <?php echo rbinput('form_destination', '2', 'Secondary care spec', 'destination') ?>&nbsp;
920 <?php echo rbinput('form_destination', '3', 'GP via physio', 'destination') ?>&nbsp;
921 <?php echo rbinput('form_destination', '4', 'GP via podiatry', 'destination') ?>
922 <?php } ?>
923 </td>
924 </tr>
926 </table>
928 <?php
929 if ($ISSUE_TYPES['football_injury']) {
930 issue_football_injury_form($issue);
933 if ($ISSUE_TYPES['ippf_gcac']) {
934 if (empty($issue) || $irow['type'] == 'ippf_gcac') {
935 issue_ippf_gcac_form($issue, $thispid);
938 if (empty($issue) || $irow['type'] == 'contraceptive') {
939 issue_ippf_con_form($issue, $thispid);
944 <center>
947 <input type='submit' name='form_save' value='<?php echo xla('Save'); ?>' />
949 <?php if ($issue && acl_check('admin', 'super')) { ?>
950 &nbsp;
951 <input type='button' value='<?php echo xla('Delete'); ?>' style='color:red' onclick='deleteme()' />
952 <?php } ?>
954 &nbsp;
955 <input type='button' value='<?php echo xla('Cancel'); ?>' onclick='closeme();' />
957 </p>
958 </center>
960 </form>
962 </div>
964 <?php echo $tabcontents; ?>
966 </div>
968 <script language='JavaScript'>
969 newtype(<?php echo $type_index ?>);
970 // Set up the tabbed UI.
971 tabbify();
973 $(document).ready(function() {
974 // Include bs3 / bs4 classes here. Keep html tags functional.
975 $('table').addClass('table table-sm');
977 </script>
979 <?php validateUsingPageRules($_SERVER['PHP_SELF']);?>
982 </body>
983 </html>