Removed athletic_team code.
[openemr.git] / interface / patient_file / summary / add_edit_issue.php
blobab6251dae0431cdb10d0a1adbdcbf6c94a0b443d
1 <?php
2 /**
3 * add or edit a medical problem.
5 * Copyright (C) 2005-2011 Rod Roark <rod@sunsetsystems.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * @package OpenEMR
13 * @author Rod Roark <rod@sunsetsystems.com>
14 * @link http://www.open-emr.org
17 //SANITIZE ALL ESCAPES
18 $sanitize_all_escapes=true;
21 //STOP FAKE REGISTER GLOBALS
22 $fake_register_globals=false;
25 require_once('../../globals.php');
26 require_once($GLOBALS['srcdir'].'/lists.inc');
27 require_once($GLOBALS['srcdir'].'/patient.inc');
28 require_once($GLOBALS['srcdir'].'/acl.inc');
29 require_once($GLOBALS['srcdir'].'/options.inc.php');
30 require_once($GLOBALS['fileroot'].'/custom/code_types.inc.php');
31 require_once($GLOBALS['srcdir'].'/csv_like_join.php');
32 require_once($GLOBALS['srcdir'].'/htmlspecialchars.inc.php');
33 require_once($GLOBALS['srcdir'].'/formdata.inc.php');
35 if (isset($ISSUE_TYPES['football_injury'])) {
36 if ($ISSUE_TYPES['football_injury']) {
37 // Most of the logic for the "football injury" issue type comes from this
38 // included script. We might eventually refine this approach to support
39 // a plug-in architecture for custom issue types.
40 require_once($GLOBALS['srcdir'].'/football_injury.inc.php');
43 if (isset($ISSUE_TYPES['ippf_gcac'])) {
44 if ($ISSUE_TYPES['ippf_gcac']) {
45 // Similarly for IPPF issues.
46 require_once($GLOBALS['srcdir'].'/ippf_issues.inc.php');
50 $issue = $_REQUEST['issue'];
51 $thispid = 0 + (empty($_REQUEST['thispid']) ? $pid : $_REQUEST['thispid']);
52 $info_msg = "";
54 // A nonempty thisenc means we are to link the issue to the encounter.
55 $thisenc = 0 + (empty($_REQUEST['thisenc']) ? 0 : $_REQUEST['thisenc']);
57 // A nonempty thistype is an issue type to be forced for a new issue.
58 $thistype = empty($_REQUEST['thistype']) ? '' : $_REQUEST['thistype'];
60 if ($issue && !acl_check('patients','med','','write') ) die(xlt("Edit is not authorized!"));
61 if ( !acl_check('patients','med','',array('write','addonly') )) die(xlt("Add is not authorized!"));
63 $tmp = getPatientData($thispid, "squad");
64 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
65 die(xlt("Not authorized for this squad!"));
67 function QuotedOrNull($fld) {
68 if ($fld) return "'".add_escape_custom($fld)."'";
69 return "NULL";
73 // Do not use this function since quotes are added in query escaping mechanism
74 // Only keeping since used in the football injury code football_injury.inc.php that is included.
75 // If start using this function, then incorporate the add_escape_custom() function into it
76 function rbvalue($rbname) {
77 $tmp = $_POST[$rbname];
78 if (! $tmp) $tmp = '0';
79 return "'$tmp'";
82 function cbvalue($cbname) {
83 return $_POST[$cbname] ? '1' : '0';
86 function invalue($inname) {
87 return (int) trim($_POST[$inname]);
90 // Do not use this function since quotes are added in query escaping mechanism
91 // Only keeping since used in the football injury code football_injury.inc.php that is included.
92 // If start using this function, then incorporate the add_escape_custom() function into it
93 function txvalue($txname) {
94 return "'" . trim($_POST[$txname]) . "'";
97 function rbinput($name, $value, $desc, $colname) {
98 global $irow;
99 $ret = "<input type='radio' name='".attr($name)."' value='".attr($value)."'";
100 if ($irow[$colname] == $value) $ret .= " checked";
101 $ret .= " />".text($desc);
102 return $ret;
105 function rbcell($name, $value, $desc, $colname) {
106 return "<td width='25%' nowrap>" . rbinput($name, $value, $desc, $colname) . "</td>\n";
109 // Given an issue type as a string, compute its index.
110 function issueTypeIndex($tstr) {
111 global $ISSUE_TYPES;
112 $i = 0;
113 foreach ($ISSUE_TYPES as $key => $value) {
114 if ($key == $tstr) break;
115 ++$i;
117 return $i;
120 function ActiveIssueCodeRecycleFn($thispid2, $ISSUE_TYPES2) {
121 ///////////////////////////////////////////////////////////////////////
122 // Active Issue Code Recycle Function authored by epsdky (2014-2015) //
123 ///////////////////////////////////////////////////////////////////////
125 $modeIssueTypes = array();
126 $issueTypeIdx2 = array();
127 $idx2 = 0;
129 foreach ($ISSUE_TYPES2 as $issueTypeX => $isJunk) {
131 $modeIssueTypes[$idx2] = $issueTypeX;
132 $issueTypeIdx2[$issueTypeX] = $idx2;
133 ++$idx2;
137 $pe2 = array($thispid2);
138 $qs2 = str_repeat('?, ', count($modeIssueTypes) - 1) . '?';
139 $sqlParameters2 = array_merge($pe2, $modeIssueTypes);
141 $codeList2 = array();
143 $issueCodes2 = sqlStatement("SELECT diagnosis FROM lists WHERE pid = ? AND enddate is NULL AND type IN ($qs2)", $sqlParameters2);
145 while ($issueCodesRow2 = sqlFetchArray($issueCodes2)) {
147 if ($issueCodesRow2['diagnosis'] != "") {
149 $someCodes2 = explode(";", $issueCodesRow2['diagnosis']);
150 $codeList2 = array_merge($codeList2, $someCodes2);
156 if ($codeList2) {
158 $codeList2 = array_unique($codeList2);
159 sort($codeList2);
163 $memberCodes = array();
164 $memberCodes[0] = array();
165 $memberCodes[1] = array();
166 $memberCodes[2] = array();
168 $allowedCodes2 = array();
169 $allowedCodes2[0] = collect_codetypes("medical_problem");
170 $allowedCodes2[1] = collect_codetypes("diagnosis");
171 $allowedCodes2[2] = collect_codetypes("drug");
173 // Test membership of codes to each code type set
174 foreach ($allowedCodes2 as $akey1 => $allowCodes2) {
176 foreach ($codeList2 as $listCode2) {
178 list($codeTyX,) = explode(":", $listCode2);
180 if (in_array($codeTyX, $allowCodes2)) {
182 array_push($memberCodes[$akey1], $listCode2);
190 // output sets of display options
191 $displayCodeSets[0] = $memberCodes[0]; // medical_problem
192 $displayCodeSets[1] = array_merge($memberCodes[1], $memberCodes[2]); // allergy
193 $displayCodeSets[2] = array_merge($memberCodes[2], $memberCodes[1]); // medication
194 $displayCodeSets[3] = $memberCodes[1]; // default
196 echo "var listBoxOptionSets = new Array();\n\n";
198 foreach ($displayCodeSets as $akey => $displayCodeSet) {
200 echo "listBoxOptionSets[" . attr($akey) . "] = new Array();\n";
202 if ($displayCodeSet) {
204 foreach ($displayCodeSet as $dispCode2) {
206 $codeDesc2 = lookup_code_descriptions($dispCode2);
207 echo "listBoxOptionSets[" . attr($akey) . "][listBoxOptionSets[" . attr($akey) . "].length] = new Option('" . attr($dispCode2) . " (" . attr(trim($codeDesc2)) . ") ' ,'" . attr($dispCode2) . "' , false, false);\n";
215 // map issues to a set of display options
216 $modeIndexMapping = array();
218 foreach ($modeIssueTypes as $akey2 => $isJunk) $modeIndexMapping[$akey2] = 3;
220 if (array_key_exists("medical_problem", $issueTypeIdx2))
221 $modeIndexMapping[$issueTypeIdx2['medical_problem']] = 0;
222 if (array_key_exists("allergy", $issueTypeIdx2))
223 $modeIndexMapping[$issueTypeIdx2['allergy']] = 1;
224 if (array_key_exists("medication", $issueTypeIdx2))
225 $modeIndexMapping[$issueTypeIdx2['medication']] = 2;
227 echo "\nvar listBoxOptions2 = new Array();\n\n";
229 foreach ($modeIssueTypes as $akey2 => $isJunk) {
230 echo "listBoxOptions2[" . attr($akey2) . "] = listBoxOptionSets[" . attr($modeIndexMapping[$akey2]) . "];\n";
232 ///////////////////////////////////////////////////////////////////////
233 // End of Active Issue Code Recycle Function main code block //
234 ///////////////////////////////////////////////////////////////////////
237 // If we are saving, then save and close the window.
239 if ($_POST['form_save']) {
241 $i = 0;
242 $text_type = "unknown";
243 foreach ($ISSUE_TYPES as $key => $value) {
244 if ($i++ == $_POST['form_type']) $text_type = $key;
247 $form_begin = fixDate($_POST['form_begin'], '');
248 $form_end = fixDate($_POST['form_end'], '');
250 if ($text_type == 'football_injury') {
251 $form_injury_part = $_POST['form_injury_part'];
252 $form_injury_type = $_POST['form_injury_type'];
254 else {
255 $form_injury_part = $_POST['form_medical_system'];
256 $form_injury_type = $_POST['form_medical_type'];
259 if ($issue) {
261 $query = "UPDATE lists SET " .
262 "type = '" . add_escape_custom($text_type) . "', " .
263 "title = '" . add_escape_custom($_POST['form_title']) . "', " .
264 "comments = '" . add_escape_custom($_POST['form_comments']) . "', " .
265 "begdate = " . QuotedOrNull($form_begin) . ", " .
266 "enddate = " . QuotedOrNull($form_end) . ", " .
267 "returndate = " . QuotedOrNull($form_return) . ", " .
268 "diagnosis = '" . add_escape_custom($_POST['form_diagnosis']) . "', " .
269 "occurrence = '" . add_escape_custom($_POST['form_occur']) . "', " .
270 "classification = '" . add_escape_custom($_POST['form_classification']) . "', " .
271 "reinjury_id = '" . add_escape_custom($_POST['form_reinjury_id']) . "', " .
272 "referredby = '" . add_escape_custom($_POST['form_referredby']) . "', " .
273 "injury_grade = '" . add_escape_custom($_POST['form_injury_grade']) . "', " .
274 "injury_part = '" . add_escape_custom($form_injury_part) . "', " .
275 "injury_type = '" . add_escape_custom($form_injury_type) . "', " .
276 "outcome = '" . add_escape_custom($_POST['form_outcome']) . "', " .
277 "destination = '" . add_escape_custom($_POST['form_destination']) . "', " .
278 "reaction ='" . add_escape_custom($_POST['form_reaction']) . "', " .
279 "severity_al ='" . add_escape_custom($_POST['form_severity_id']) . "', " .
280 "erx_uploaded = '0', " .
281 "modifydate = NOW() " .
282 "WHERE id = '" . add_escape_custom($issue) . "'";
283 sqlStatement($query);
284 if ($text_type == "medication" && enddate != '') {
285 sqlStatement('UPDATE prescriptions SET '
286 . 'medication = 0 where patient_id = ? '
287 . " and upper(trim(drug)) = ? "
288 . ' and medication = 1', array($thispid,strtoupper($_POST['form_title'])) );
291 } else {
293 $issue = sqlInsert("INSERT INTO lists ( " .
294 "date, pid, type, title, activity, comments, begdate, enddate, returndate, " .
295 "diagnosis, occurrence, classification, referredby, user, groupname, " .
296 "outcome, destination, reinjury_id, injury_grade, injury_part, injury_type, " .
297 "reaction, severity_al " .
298 ") VALUES ( " .
299 "NOW(), " .
300 "'" . add_escape_custom($thispid) . "', " .
301 "'" . add_escape_custom($text_type) . "', " .
302 "'" . add_escape_custom($_POST['form_title']) . "', " .
303 "1, " .
304 "'" . add_escape_custom($_POST['form_comments']) . "', " .
305 QuotedOrNull($form_begin) . ", " .
306 QuotedOrNull($form_end) . ", " .
307 QuotedOrNull($form_return) . ", " .
308 "'" . add_escape_custom($_POST['form_diagnosis']) . "', " .
309 "'" . add_escape_custom($_POST['form_occur']) . "', " .
310 "'" . add_escape_custom($_POST['form_classification']) . "', " .
311 "'" . add_escape_custom($_POST['form_referredby']) . "', " .
312 "'" . add_escape_custom($$_SESSION['authUser']) . "', " .
313 "'" . add_escape_custom($$_SESSION['authProvider']) . "', " .
314 "'" . add_escape_custom($_POST['form_outcome']) . "', " .
315 "'" . add_escape_custom($_POST['form_destination']) . "', " .
316 "'" . add_escape_custom($_POST['form_reinjury_id']) . "', " .
317 "'" . add_escape_custom($_POST['form_injury_grade']) . "', " .
318 "'" . add_escape_custom($form_injury_part) . "', " .
319 "'" . add_escape_custom($form_injury_type) . "', " .
320 "'" . add_escape_custom($_POST['form_reaction']) . "', " .
321 "'" . add_escape_custom($_POST['form_severity_id']) . "' " .
322 ")");
326 // For record/reporting purposes, place entry in lists_touch table.
327 setListTouch($thispid,$text_type);
329 if ($text_type == 'football_injury') issue_football_injury_save($issue);
330 if ($text_type == 'ippf_gcac' ) issue_ippf_gcac_save($issue);
331 if ($text_type == 'contraceptive' ) issue_ippf_con_save($issue);
333 // If requested, link the issue to a specified encounter.
334 if ($thisenc) {
335 $query = "INSERT INTO issue_encounter ( " .
336 "pid, list_id, encounter " .
337 ") VALUES ( ?,?,? )";
338 sqlStatement($query, array($thispid,$issue,$thisenc));
341 $tmp_title = addslashes($ISSUE_TYPES[$text_type][2] . ": $form_begin " .
342 substr($_POST['form_title'], 0, 40));
344 // Close this window and redisplay the updated list of issues.
346 echo "<html><body><script language='JavaScript'>\n";
347 if ($info_msg) echo " alert('$info_msg');\n";
349 echo " var myboss = opener ? opener : parent;\n";
350 echo " if (myboss.refreshIssue) myboss.refreshIssue($issue,'$tmp_title');\n";
351 echo " else if (myboss.reloadIssues) myboss.reloadIssues();\n";
352 echo " else myboss.location.reload();\n";
353 echo " if (parent.$ && parent.$.fancybox) parent.$.fancybox.close();\n";
354 echo " else window.close();\n";
356 echo "</script></body></html>\n";
357 exit();
360 $irow = array();
361 if ($issue)
362 $irow = sqlQuery("SELECT * FROM lists WHERE id = ?",array($issue));
363 else if ($thistype)
364 $irow['type'] = $thistype;
366 $type_index = 0;
368 if (!empty($irow['type'])) {
369 foreach ($ISSUE_TYPES as $key => $value) {
370 if ($key == $irow['type']) break;
371 ++$type_index;
375 <html>
376 <head>
377 <?php html_header_show();?>
378 <title><?php echo $issue ? xlt('Edit') : xlt('Add New'); ?><?php echo " ".xlt('Issue'); ?></title>
379 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
381 <style>
383 td, input, select, textarea {
384 font-family: Arial, Helvetica, sans-serif;
385 font-size: 10pt;
388 div.section {
389 border: solid;
390 border-width: 1px;
391 border-color: #0000ff;
392 margin: 0 0 0 10pt;
393 padding: 5pt;
396 </style>
398 <style type="text/css">@import url(<?php echo $GLOBALS['webroot']; ?>/library/dynarch_calendar.css);</style>
399 <script type="text/javascript" src="<?php echo $GLOBALS['webroot']; ?>/library/dynarch_calendar.js"></script>
400 <?php require_once($GLOBALS['srcdir'].'/dynarch_calendar_en.inc.php'); ?>
401 <script type="text/javascript" src="<?php echo $GLOBALS['webroot']; ?>/library/dynarch_calendar_setup.js"></script>
402 <script type="text/javascript" src="<?php echo $GLOBALS['webroot']; ?>/library/textformat.js"></script>
403 <script type="text/javascript" src="<?php echo $GLOBALS['webroot']; ?>/library/dialog.js"></script>
405 <script language="JavaScript">
407 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
409 var aitypes = new Array(); // issue type attributes
410 var aopts = new Array(); // Option objects
411 <?php
412 $i = 0;
413 foreach ($ISSUE_TYPES as $key => $value) {
414 echo " aitypes[$i] = " . attr($value[3]) . ";\n";
415 echo " aopts[$i] = new Array();\n";
416 $qry = sqlStatement("SELECT * FROM list_options WHERE list_id = ?",array($key."_issue_list"));
417 while($res = sqlFetchArray($qry)){
418 echo " aopts[$i][aopts[$i].length] = new Option('".attr(trim($res['option_id']))."', '".attr(xl_list_label(trim($res['title'])))."', false, false);\n";
419 if ($res['codes']) {
420 echo " aopts[$i][aopts[$i].length-1].setAttribute('data-code','".attr(trim($res['codes']))."');\n";
423 ++$i;
426 ///////////
427 ActiveIssueCodeRecycleFn($thispid, $ISSUE_TYPES);
428 ///////////
431 <?php require($GLOBALS['srcdir'] . "/restoreSession.php"); ?>
433 ///////////////////////////
434 function codeBoxFunction2() {
435 var f = document.forms[0];
436 var x2 = f.form_codeSelect2.options[f.form_codeSelect2.selectedIndex].value;
437 f.form_codeSelect2.selectedIndex = -1;
438 var x6 = f.form_diagnosis.value;
439 if (x6.length > 0) x6 += ";";
440 x6 += x2;
441 f.form_diagnosis.value = x6;
443 ///////////////////////////
445 // React to selection of an issue type. This loads the associated
446 // shortcuts into the selection list of titles, and determines which
447 // rows are displayed or hidden.
448 function newtype(index) {
449 var f = document.forms[0];
450 var theopts = f.form_titles.options;
451 theopts.length = 0;
452 var i = 0;
453 for (i = 0; i < aopts[index].length; ++i) {
454 theopts[i] = aopts[index][i];
456 document.getElementById('row_titles').style.display = i ? '' : 'none';
458 ///////////////////////
459 var listBoxOpts2 = f.form_codeSelect2.options;
460 listBoxOpts2.length = 0;
461 var ix = 0;
462 for (ix = 0; ix < listBoxOptions2[index].length; ++ix) {
463 listBoxOpts2[ix] = listBoxOptions2[index][ix];
464 listBoxOpts2[ix].title = listBoxOptions2[index][ix].text;
466 document.getElementById('row_codeSelect2').style.display = ix ? '' : 'none';
467 //////////////////////
469 // Show or hide various rows depending on issue type, except do not
470 // hide the comments or referred-by fields if they have data.
471 var comdisp = (aitypes[index] == 1) ? 'none' : '';
472 var revdisp = (aitypes[index] == 1) ? '' : 'none';
473 var injdisp = (aitypes[index] == 2) ? '' : 'none';
474 var nordisp = (aitypes[index] == 0) ? '' : 'none';
475 // reaction row should be displayed only for medication allergy.
476 var alldisp = (index == <?php echo issueTypeIndex('allergy'); ?>) ? '' : 'none';
477 document.getElementById('row_enddate' ).style.display = comdisp;
478 // Note that by default all the issues will not show the active row
479 // (which is desired functionality, since then use the end date
480 // to inactivate the item.)
481 document.getElementById('row_active' ).style.display = revdisp;
482 document.getElementById('row_diagnosis' ).style.display = comdisp;
483 document.getElementById('row_occurrence' ).style.display = comdisp;
484 document.getElementById('row_classification').style.display = injdisp;
485 document.getElementById('row_reinjury_id' ).style.display = injdisp;
486 document.getElementById('row_severity' ).style.display = alldisp;
487 document.getElementById('row_reaction' ).style.display = alldisp;
488 document.getElementById('row_referredby' ).style.display = (f.form_referredby.value) ? '' : comdisp;
489 document.getElementById('row_comments' ).style.display = (f.form_comments.value ) ? '' : revdisp;
490 document.getElementById('row_referredby' ).style.display = (f.form_referredby.value) ? '' : comdisp;
492 <?php
493 if ($ISSUE_TYPES['football_injury']) {
494 // Generate more of these for football injury fields.
495 issue_football_injury_newtype();
497 if ($ISSUE_TYPES['ippf_gcac'] && !$_POST['form_save']) {
498 // Generate more of these for gcac and contraceptive fields.
499 if (empty($issue) || $irow['type'] == 'ippf_gcac' ) issue_ippf_gcac_newtype();
500 if (empty($issue) || $irow['type'] == 'contraceptive') issue_ippf_con_newtype();
505 // If a clickoption title is selected, copy it to the title field.
506 // If it has a code, add that too.
507 function set_text() {
508 var f = document.forms[0];
509 f.form_title.value = f.form_titles.options[f.form_titles.selectedIndex].text;
510 f.form_diagnosis.value = f.form_titles.options[f.form_titles.selectedIndex].getAttribute('data-code');
511 f.form_titles.selectedIndex = -1;
514 // Process click on Delete link.
515 function deleteme() {
516 dlgopen('../deleter.php?issue=<?php echo attr($issue) ?>', '_blank', 500, 450);
517 return false;
520 // Called by the deleteme.php window on a successful delete.
521 function imdeleted() {
522 closeme();
525 function closeme() {
526 if (parent.$) parent.$.fancybox.close();
527 window.close();
530 // Called when the Active checkbox is clicked. For consistency we
531 // use the existence of an end date to indicate inactivity, even
532 // though the simple verion of the form does not show an end date.
533 function activeClicked(cb) {
534 var f = document.forms[0];
535 if (cb.checked) {
536 f.form_end.value = '';
537 } else {
538 var today = new Date();
539 f.form_end.value = '' + (today.getYear() + 1900) + '-' +
540 (today.getMonth() + 1) + '-' + today.getDate();
544 // Called when resolved outcome is chosen and the end date is entered.
545 function outcomeClicked(cb) {
546 var f = document.forms[0];
547 if (cb.value == '1'){
548 var today = new Date();
549 f.form_end.value = '' + (today.getYear() + 1900) + '-' +
550 ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2);
551 f.form_end.focus();
555 // This is for callback by the find-code popup.
556 // Appends to or erases the current list of diagnoses.
557 function set_related(codetype, code, selector, codedesc) {
558 var f = document.forms[0];
559 var s = f.form_diagnosis.value;
560 var title = f.form_title.value;
561 if (code) {
562 if (s.length > 0) s += ';';
563 s += codetype + ':' + code;
564 } else {
565 s = '';
567 f.form_diagnosis.value = s;
568 if(title == '') f.form_title.value = codedesc;
571 // This invokes the find-code popup.
572 function sel_diagnosis() {
573 <?php
574 $url = '../encounter/find_code_popup.php?codetype=';
575 if($irow['type'] == 'medical_problem') {
576 $url .= collect_codetypes("medical_problem", "csv");
578 else {
579 $url .= collect_codetypes("diagnosis","csv");
580 $tmp = collect_codetypes("drug","csv");
581 if($irow['type'] == 'allergy') {
582 if ($tmp) $url .= ",$tmp";
584 else if($irow['type'] == 'medication') {
585 if ($tmp) $url .= ",$tmp&default=$tmp";
589 dlgopen('<?php echo $url; ?>', '_blank', 700, 500);
592 // Check for errors when the form is submitted.
593 function validate() {
594 var f = document.forms[0];
595 if(f.form_begin.value > f.form_end.value && (f.form_end.value)) {
596 alert("<?php echo addslashes(xl('Please Enter End Date greater than Begin Date!')); ?>");
597 return false;
599 if (! f.form_title.value) {
600 alert("<?php echo addslashes(xl('Please enter a title!')); ?>");
601 return false;
603 top.restoreSession();
604 return true;
607 // Supports customizable forms (currently just for IPPF).
608 function divclick(cb, divid) {
609 var divstyle = document.getElementById(divid).style;
610 if (cb.checked) {
611 divstyle.display = 'block';
612 } else {
613 divstyle.display = 'none';
615 return true;
618 </script>
620 </head>
622 <body class="body_top" style="padding-right:0.5em">
624 <form method='post' name='theform'
625 action='add_edit_issue.php?issue=<?php echo attr($issue); ?>&thispid=<?php echo attr($thispid); ?>&thisenc=<?php echo attr($thisenc); ?>'
626 onsubmit='return validate()'>
628 <table border='0' width='100%'>
630 <tr>
631 <td valign='top' width='1%' nowrap><b><?php echo xlt('Type'); ?>:</b></td>
632 <td>
633 <?php
634 $index = 0;
635 foreach ($ISSUE_TYPES as $value) {
636 if ($issue || $thistype) {
637 if ($index == $type_index) {
638 echo text($value[1]);
639 echo "<input type='hidden' name='form_type' value='".attr($index)."'>\n";
641 } else {
642 echo " <input type='radio' name='form_type' value='".attr($index)."' onclick='newtype($index)'";
643 if ($index == $type_index) echo " checked";
644 echo " />" . text($value[1]) . "&nbsp;\n";
646 ++$index;
649 </td>
650 </tr>
652 <tr id='row_titles'>
653 <td valign='top' nowrap>&nbsp;</td>
654 <td valign='top'>
655 <select name='form_titles' size='4' onchange='set_text()'>
656 </select> <?php echo xlt('(Select one of these, or type your own title)'); ?>
657 </td>
658 </tr>
660 <tr>
661 <td valign='top' id='title_diagnosis' nowrap><b><?php echo xlt('Title'); ?>:</b></td>
662 <td>
663 <input type='text' size='40' name='form_title' value='<?php echo attr($irow['title']) ?>' style='width:100%' />
664 </td>
665 </tr>
667 <tr id='row_codeSelect2'>
668 <td><b><?php echo xlt('Active Issue Codes'); ?>:</b>
669 </td>
670 <td>
671 <select name='form_codeSelect2' size='4' onchange="codeBoxFunction2()" style="max-width:100%;">
672 </select>
673 </td>
674 </tr>
676 <tr id='row_diagnosis'>
677 <td valign='top' nowrap><b><?php echo xlt('Coding'); ?>:</b></td>
678 <td>
679 <input type='text' size='50' name='form_diagnosis'
680 value='<?php echo attr($irow['diagnosis']) ?>' onclick='sel_diagnosis()'
681 title='<?php echo xla('Click to select or change coding'); ?>'
682 style='width:100%' readonly />
683 </td>
684 </tr>
686 <tr>
687 <td valign='top' nowrap><b><?php echo xlt('Begin Date'); ?>:</b></td>
688 <td>
690 <input type='text' size='10' name='form_begin' id='form_begin'
691 value='<?php echo attr($irow['begdate']) ?>'
692 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
693 title='<?php echo xla('yyyy-mm-dd date of onset, surgery or start of medication'); ?>' />
694 <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22'
695 id='img_begin' border='0' alt='[?]' style='cursor:pointer'
696 title='<?php echo xla('Click here to choose a date'); ?>' />
697 </td>
698 </tr>
700 <tr id='row_enddate'>
701 <td valign='top' nowrap><b><?php echo xlt('End Date'); ?>:</b></td>
702 <td>
703 <input type='text' size='10' name='form_end' id='form_end'
704 value='<?php echo attr($irow['enddate']) ?>'
705 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
706 title='<?php echo xla('yyyy-mm-dd date of recovery or end of medication'); ?>' />
707 <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22'
708 id='img_end' border='0' alt='[?]' style='cursor:pointer'
709 title='<?php echo xla('Click here to choose a date'); ?>' />
710 &nbsp;(<?php echo xlt('leave blank if still active'); ?>)
711 </td>
712 </tr>
714 <tr id='row_active'>
715 <td valign='top' nowrap><b><?php echo xlt('Active'); ?>:</b></td>
716 <td>
717 <input type='checkbox' name='form_active' value='1' <?php echo attr($irow['enddate']) ? "" : "checked"; ?>
718 onclick='activeClicked(this);'
719 title='<?php echo xla('Indicates if this issue is currently active'); ?>' />
720 </td>
721 </tr>
723 <tr id='row_occurrence'>
724 <td valign='top' nowrap><b><?php echo xlt('Occurrence'); ?>:</b></td>
725 <td>
726 <?php
727 // Modified 6/2009 by BM to incorporate the occurrence items into the list_options listings
728 generate_form_field(array('data_type'=>1,'field_id'=>'occur','list_id'=>'occurrence','empty_title'=>'SKIP'), $irow['occurrence']);
730 </td>
731 </tr>
733 <tr id='row_classification'>
734 <td valign='top' nowrap><b><?php echo xlt('Classification'); ?>:</b></td>
735 <td>
736 <select name='form_classification'>
737 <?php
738 foreach ($ISSUE_CLASSIFICATIONS as $key => $value) {
739 echo " <option value='".attr($key)."'";
740 if ($key == $irow['classification']) echo " selected";
741 echo ">".text($value)."\n";
744 </select>
745 </td>
746 </tr>
748 <!-- Reaction For Medication Allergy -->
749 <tr id='row_severity'>
750 <td valign='top' nowrap><b><?php echo xlt('Severity'); ?>:</b></td>
751 <td><?php
752 $severity=$irow['severity_al'];
753 generate_form_field(array('data_type'=>1,'field_id'=>'severity_id','list_id'=>'severity_ccda','empty_title'=>'SKIP'), $severity);
755 </td>
756 </tr>
757 <tr id='row_reaction'>
758 <td valign='top' nowrap><b><?php echo xlt('Reaction'); ?>:</b></td>
759 <td>
760 <?php
761 echo generate_select_list('form_reaction', 'reaction', $irow['reaction'], '', '', '', '');
763 </td>
764 </tr>
765 <!-- End of reaction -->
767 <tr id='row_referredby'>
768 <td valign='top' nowrap><b><?php echo xlt('Referred by'); ?>:</b></td>
769 <td>
770 <input type='text' size='40' name='form_referredby' value='<?php echo attr($irow['referredby']) ?>'
771 style='width:100%' title='<?php echo xla('Referring physician and practice'); ?>' />
772 </td>
773 </tr>
775 <tr id='row_comments'>
776 <td valign='top' nowrap><b><?php echo xlt('Comments'); ?>:</b></td>
777 <td>
778 <textarea name='form_comments' rows='4' cols='40' wrap='virtual' style='width:100%'><?php echo text($irow['comments']) ?></textarea>
779 </td>
780 </tr>
782 <tr<?php if ($GLOBALS['ippf_specific']) echo " style='display:none;'"; ?>>
783 <td valign='top' nowrap><b><?php echo xlt('Outcome'); ?>:</b></td>
784 <td>
785 <?php
786 echo generate_select_list('form_outcome', 'outcome', $irow['outcome'], '', '', '', 'outcomeClicked(this);');
788 </td>
789 </tr>
791 <tr<?php if ($GLOBALS['ippf_specific']) echo " style='display:none;'"; ?>>
792 <td valign='top' nowrap><b><?php echo xlt('Destination'); ?>:</b></td>
793 <td>
794 <?php if (true) { ?>
795 <input type='text' size='40' name='form_destination' value='<?php echo attr($irow['destination']) ?>'
796 style='width:100%' title='GP, Secondary care specialist, etc.' />
797 <?php } else { // leave this here for now, please -- Rod ?>
798 <?php echo rbinput('form_destination', '1', 'GP' , 'destination') ?>&nbsp;
799 <?php echo rbinput('form_destination', '2', 'Secondary care spec', 'destination') ?>&nbsp;
800 <?php echo rbinput('form_destination', '3', 'GP via physio' , 'destination') ?>&nbsp;
801 <?php echo rbinput('form_destination', '4', 'GP via podiatry' , 'destination') ?>
802 <?php } ?>
803 </td>
804 </tr>
806 </table>
808 <?php
809 if ($ISSUE_TYPES['football_injury']) {
810 issue_football_injury_form($issue);
812 if ($ISSUE_TYPES['ippf_gcac']) {
813 if (empty($issue) || $irow['type'] == 'ippf_gcac')
814 issue_ippf_gcac_form($issue, $thispid);
815 if (empty($issue) || $irow['type'] == 'contraceptive')
816 issue_ippf_con_form($issue, $thispid);
820 <center>
823 <input type='submit' name='form_save' value='<?php echo xla('Save'); ?>' />
825 <?php if ($issue && acl_check('admin', 'super')) { ?>
826 &nbsp;
827 <input type='button' value='<?php echo xla('Delete'); ?>' style='color:red' onclick='deleteme()' />
828 <?php } ?>
830 &nbsp;
831 <input type='button' value='<?php echo xla('Cancel'); ?>' onclick='closeme();' />
833 </p>
834 </center>
836 </form>
837 <script language='JavaScript'>
838 newtype(<?php echo $type_index ?>);
839 Calendar.setup({inputField:"form_begin", ifFormat:"%Y-%m-%d", button:"img_begin"});
840 Calendar.setup({inputField:"form_end", ifFormat:"%Y-%m-%d", button:"img_end"});
841 Calendar.setup({inputField:"form_return", ifFormat:"%Y-%m-%d", button:"img_return"});
842 </script>
843 </body>
844 </html>