From 167a515068b4c4b2c1b3f095dc2572a4abe6d1c9 Mon Sep 17 00:00:00 2001 From: markleeds Date: Mon, 8 Oct 2007 15:17:05 +0000 Subject: [PATCH] General cleanup, mainly regarding making cloning work in a more appropriate an intuitive way. There is still a problem with the new logic in retrieving clone data due to changes in the queries to get the previous encounter by last encounter rather than last date. --- interface/forms/CAMOS/new.php | 192 +++++++++++++++++++++++------------------- 1 file changed, 106 insertions(+), 86 deletions(-) diff --git a/interface/forms/CAMOS/new.php b/interface/forms/CAMOS/new.php index c2bd7c742..145ffc8a8 100755 --- a/interface/forms/CAMOS/new.php +++ b/interface/forms/CAMOS/new.php @@ -26,7 +26,13 @@ $previous_encounter_data = ''; if (!$out_of_encounter) { //do not do stuff that is encounter specific if not in an encounter $previous_encounter_data = '

'.xl('Previous Encounter CAMOS entries').'


'; //get data from previous encounter to show at bottom of form for reference - $query = "SELECT t1.category, t1.subcategory, t1.item, t1.content FROM form_CAMOS as t1 JOIN forms as t2 on (t1.id = t2.form_id) where t2.encounter=(select max(encounter) from forms where form_name like 'CAMOS%' and encounter < ".$_SESSION['encounter']." and pid=".$_SESSION['pid'].") and t1.pid=".$_SESSION['pid']; + $tmp = sqlQuery("SELECT max(encounter) AS max FROM forms WHERE " . + "form_name LIKE 'CAMOS%' AND encounter < '" . $_SESSION['encounter'] . + "' AND pid = '" . $_SESSION['pid'] . "'"); + $last_encounter_id = $tmp['max'] ? $tmp['max'] : 0; + $query = "SELECT t1.category, t1.subcategory, t1.item, t1.content " . + "FROM form_CAMOS as t1 JOIN forms as t2 on (t1.id = t2.form_id) where " . + "t2.encounter = '$last_encounter_id' and t1.pid = " . $_SESSION['pid']; $statement = sqlStatement($query); while ($result = sqlFetchArray($statement)) { $previous_encounter_data .= $result['category']." | ".$result['subcategory']. @@ -178,66 +184,6 @@ else if ($_POST['hidden_mode'] == 'alter') { else { $preselect_mode = 'by number'; } -if (!$out_of_encounter) { //do not do stuff that is encounter specific if not in an encounter - //cloning - similar process to preselect set to first time starting CAMOS - //as above - $clone_category = ''; - $clone_subcategory = ''; - $clone_item = ''; - $clone_content = ''; - $clone_data1 = ''; - $clone_data2 = ''; - $clone_data_array = array(); - if (substr($_POST['hidden_mode'],0,5) == 'clone') { - $clone_category = $_POST['category']; - $query = "SELECT subcategory, item, content FROM form_CAMOS WHERE category like '".$clone_category."' and pid=".$_SESSION['pid']." order by id"; -// if ($_POST['hidden_mode'] == 'clone last visit') { -// $query = "SELECT category, subcategory, item, content FROM form_CAMOS WHERE date(date) like (SELECT -// date(MAX(date)) FROM form_CAMOS where date(date) < date(now()) and pid=".$_SESSION['pid'].") and pid=".$_SESSION['pid']." order by id"; -// } - - if ($_POST['hidden_mode'] == 'clone last visit') { - $query = "SELECT category, subcategory, item, content FROM form_CAMOS left join forms on (form_CAMOS.id = forms.form_id) where forms.encounter = (select max(encounter) from forms where encounter < ".$_SESSION['encounter']." and pid = ".$_SESSION['pid']." and form_name like 'CAMOS%') and form_CAMOS.pid=".$_SESSION['pid']." order by form_CAMOS.id"; - } - - - $statement = sqlStatement($query); - while ($result = sqlFetchArray($statement)) { - if (preg_match('/^[\s\r\n]*$/',$result['content']) == 0) { - if ($_POST['hidden_mode'] == 'clone last visit') { - $clone_category = $result['category']; - } - $clone_subcategory = $result['subcategory']; - $clone_item = $result['item']; - $clone_content = $result['content']; - $clone_data1 = "/* camos :: $clone_category :: $clone_subcategory :: $clone_item :: "; - $clone_data2 = "$clone_content */"; - if ($_POST['hidden_mode'] == 'clone last visit') { - //figure out how to make two orders of same category/subcat/item in same last visit appear - } - $clone_data_array[$clone_data1] = $clone_data2; - } - if ($_POST['hidden_mode'] == 'clone last visit') { - $query = "SELECT code_type, code, code_text, modifier, units, fee FROM billing WHERE encounter = (SELECT max(encounter) FROM billing where encounter < ".$_SESSION['encounter']." and pid=".$_SESSION['pid'].") and pid=".$_SESSION['pid']." and activity=1 order by id";} - $statement = sqlStatement($query); - while ($result = sqlFetchArray($statement)) { - $clone_code_type = $result['code_type']; - $clone_code = $result['code']; - $clone_code_text = $result['code_text']; - $clone_modifier = $result['modifier']; - $clone_units = $result['units']; - $clone_fee = $result['fee']; - $clone_billing_data = "/* billing :: $clone_code_type :: $clone_code :: $clone_code_text :: $clone_modifier :: $clone_units :: $clone_fee */"; - $clone_data_array[$clone_billing_data] = ''; - } - } - //foreach($clone_data_array as $key => $val) { - // print "

$key

\n"; - //} - - } - //end preselect column items -} //end of 'do only if in an encounter stuff ?> @@ -253,7 +199,13 @@ var preselect_off = false; var content_change_flag = false; var lock_override_flag = false; var switchbox_status = 'main'; +var clone_mode = false; + function addbox() { f2 = document.CAMOS; @@ -394,9 +346,87 @@ function select_word(mode, mystring, myselect) { //take a string and select it i } return 1; } + function init() { var f2 = document.CAMOS; + if (clone_mode) { + clone_mode = false; + $val) { + echo "f2.textarea_multibox.value += \"".fixquotes(str_replace($quote_search,$quote_replace,$val))."\\n\"\n"; + } + echo "switchbox();\n"; +} + +?> + } for (i1=0;i1 $val) { - print "f2.textarea_content.value += \"\\n".fixquotes(str_replace($quote_search,$quote_replace,$key.$val))."\\n\"\n"; - } -} - -?> } } } @@ -497,7 +518,7 @@ function selectContains(myselect, str) { function js_button(mode,selection) { var f2 = document.CAMOS; -//check lock first +//check lock next if ( (mode == 'add') && (selection == 'change_content') && (isLocked()) ) { alert("You have attempted to alter content which is locked.\nRemove the lock if you want to do this.\nTo unlock, remove the line, '/*lock::*/'"); return; @@ -582,6 +603,18 @@ if ( (mode == 'add') || (mode == 'alter') ) { else { item = f2.select_item.options[item_index].value; } +//deal with clone buttons + if (mode.substr(0,5) == 'clone') { + f2.category.value = f2.select_category.options[f2.select_category.selectedIndex].text; + f2.hidden_mode.value = mode; + f2.hidden_selection.value = selection; + f2.hidden_category.value = category; + f2.hidden_subcategory.value = subcategory; + f2.hidden_item.value = item; + f2.action = '/interface/patient_file/encounter/load_form.php?formname=CAMOS'; + f2.target = '_self'; + f2.submit(); + } if (mode == 'submit') { f2.category.value = f2.select_category.options[f2.select_category.selectedIndex].text; f2.subcategory.value = f2.select_subcategory.options[f2.select_subcategory.selectedIndex].text; @@ -594,19 +627,6 @@ if ( (mode == 'add') || (mode == 'alter') ) { f2.action = '/forms/CAMOS/save.php?mode=new'; f2.submit(); } - else { - if (mode.substr(0,5) == 'clone') { - f2.category.value = f2.select_category.options[f2.select_category.selectedIndex].text; - } - f2.hidden_mode.value = mode; - f2.hidden_selection.value = selection; - f2.hidden_category.value = category; - f2.hidden_subcategory.value = subcategory; - f2.hidden_item.value = item; - f2.action = '/interface/patient_file/encounter/load_form.php?formname=CAMOS'; - f2.target = '_self'; - f2.submit(); - } } function selectItem () { @@ -622,6 +642,8 @@ function selectItem () { + + [".xl('do not save')."]"; ?> @@ -698,8 +720,6 @@ if (myAuth() == 1) {//root user only can see administration option if (!$out_of_encounter) { //do not do stuff that is encounter specific if not in an encounter ?> - - -- 2.11.4.GIT