From 120a5514c20338efe15518f1a817f4f94ccec30d Mon Sep 17 00:00:00 2001 From: jajalla23 Date: Thu, 11 Apr 2013 23:29:24 -0700 Subject: [PATCH] Immunization_information_(MU2) changes, take 5. -Change Date Administered to Date/Time Administered -Add an Amount Administered field -Add an Immunization Expiration Date field -Add a Route field -Add a Administration Site field -Add a erroneously added field/mechanism Some additional integration work by bradymiller. --- interface/patient_file/report/custom_report.php | 12 +- interface/patient_file/summary/immunizations.php | 295 +++++++++++++++-------- interface/patient_file/summary/shot_record.php | 153 +++++++----- interface/patient_file/summary/stats.php | 1 + interface/reports/immunization_report.php | 5 +- library/clinical_rules.php | 10 +- library/immunization_helper.php | 59 +++++ library/sql-ccr.inc | 4 +- sql/4_1_1-to-4_1_2_upgrade.sql | 36 +++ sql/database.sql | 8 +- version.php | 2 +- 11 files changed, 407 insertions(+), 178 deletions(-) create mode 100644 library/immunization_helper.php diff --git a/interface/patient_file/report/custom_report.php b/interface/patient_file/report/custom_report.php index b58fbd5c5..87975f3e7 100644 --- a/interface/patient_file/report/custom_report.php +++ b/interface/patient_file/report/custom_report.php @@ -473,19 +473,19 @@ else { // not printable - - + + + + + "; + echo ""; } else { - echo ""; + echo ""; } // Figure out which name to use (ie. from cvx list or from the custom list) @@ -390,17 +446,48 @@ var mypcc = ''1','list_id'=>'immunizations'), $row['immunization_id']); } - } - echo ""; - - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + + if ($isError) { + $del_tag_open = ""; + $del_tag_close = ""; + } else { + $del_tag_open = ""; + $del_tag_close = ""; + } + + echo ""; + + if ($row["administered_date"]) { + $administered_date_summary = new DateTime($row['administered_date']); + $administered_date_summary = $administered_date_summary->format('Y-m-d H:i'); + } else { + $administered_date_summary = ""; + } + echo ""; + if ($row["amount_administered"] > 0) { + echo ""; + } + else { + echo ""; + } + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + if ($isError) { + $checkbox = "checked"; + } else { + $checkbox = ""; + } + + echo ""; + + echo ""; echo ""; } @@ -413,7 +500,8 @@ var mypcc = ' /* required for popup calendar */ -Calendar.setup({inputField:"administered_date", ifFormat:"%Y-%m-%d", button:"img_administered_date"}); +Calendar.setup({inputField:"administered_date", ifFormat:"%Y-%m-%d %H:%M", button:"img_administered_date", showsTime:true}); +Calendar.setup({inputField:"immuniz_exp_date", ifFormat:"%Y-%m-%d", button:"img_immuniz_exp_date"}); Calendar.setup({inputField:"education_date", ifFormat:"%Y-%m-%d", button:"img_education_date"}); Calendar.setup({inputField:"vis_date", ifFormat:"%Y-%m-%d", button:"img_vis_date"}); @@ -435,6 +523,7 @@ $(document).ready(function(){ $("#print").click(function() { PrintForm("pdf"); }); $("#printHtml").click(function() { PrintForm("html"); }); $(".immrow").click(function() { EditImm(this); }); + $(".error").click(function(event) { ErrorImm(this); event.stopPropagation(); }); $(".delete").click(function(event) { DeleteImm(this); event.stopPropagation(); }); $(".immrow").mouseover(function() { $(this).toggleClass("highlight"); }); @@ -454,12 +543,7 @@ $(document).ready(function(){ var PrintForm = function(typ) { top.restoreSession(); newURL='shot_record.php?output='+typ+'&sortby='; - if (typ=="pdf") { - location.href=newURL; - } - else { // typ=html - window.open(newURL, '_blank', "menubar=1,toolbar=1,scrollbars=1,resizable=1,width=600,height=450"); - } + window.open(newURL, '_blank', "menubar=1,toolbar=1,scrollbars=1,resizable=1,width=600,height=450"); } var SaveForm = function() { @@ -479,6 +563,11 @@ var DeleteImm = function(imm) { } } +var ErrorImm = function(imm) { + top.restoreSession(); + location.href='immunizations.php?mode=added_error&id='+imm.id+'&isError='+imm.checked; +} + //This is for callback by the find-code popup. //Appends to or erases the current list of diagnoses. function set_related(codetype, code, selector, codedesc) { diff --git a/interface/patient_file/summary/shot_record.php b/interface/patient_file/summary/shot_record.php index 74a29bf1b..2ef9eb206 100644 --- a/interface/patient_file/summary/shot_record.php +++ b/interface/patient_file/summary/shot_record.php @@ -11,6 +11,7 @@ $fake_register_globals=false; include_once("../../globals.php"); include_once("$srcdir/sql.inc"); include_once("$srcdir/options.inc.php"); +include_once("$srcdir/immunization_helper.php"); //collect facility data $res = sqlQuery("select concat(f.name,'\n',f.street,'\n',f.city,', ',f.state,' ',f.postal_code) as facility_address ". @@ -27,51 +28,102 @@ $res2 = sqlQuery("select concat(p.lname,', ',p.fname,' ',p.mname) patient_name " ); //collect immunizations -$sqlstmt = "select date_format(i1.administered_date,'%Y-%m-%d') as '" . xl('Date') . "\n" . xl('Administered') . "' ". - ",i1.immunization_id as '" . xl('Vaccine') . "' ". - ",c.code_text_short as cvx_text ". - ",i1.manufacturer as '" . xl('Manufacturer') . "' ". - ",i1.lot_number as '" . xl('Lot') . "\n" . xl('Number') . "' ". - ",concat(u.lname,', ',u.fname) as '" . xl('Administered By') . "' ". - ",date_format(i1.education_date,'%Y-%m-%d') as '" . xl('Patient') . "\n" . xl('Education') . "\n" . xl('Date') . "' ". - ",i1.note as '" . xl('Comments') . "'". - " from immunizations i1 ". - " left join users u on i1.administered_by_id = u.id ". - " left join patient_data p on i1.patient_id = p.pid ". - " left join code_types ct on ct.ct_key = 'CVX' ". - " left join codes c on c.code_type = ct.ct_id AND i1.cvx_code = c.code ". - " where p.pid = ? "; +$res3 = getImmunizationList($pid, $_GET['sortby'], false); +$data_array = convertToDataArray($res3); -// sort the results, as they are on the user's screen -$sqlstmt .= " order by "; -if ($_GET['sortby'] == "vacc") { $sqlstmt .= " i1.immunization_id, i1.administered_date DESC"; } -else { $sqlstmt .= " i1.administered_date desc"; } +$title = xl('Shot Record as of:','','',' ') . date('m/d/Y h:i:s a'); -$res3 = sqlStatement($sqlstmt, array($pid) ); +if ($_GET['output'] == "html") { + printHTML($res, $res2, $data_array); +} +else { + printPDF($res, $res2, $data_array); +} -while ($data[] = sqlFetchArray($res3)) {} -for ($i=0;$i'1','list_id'=>'immunizations'), $data[$i][xl('Vaccine')]); - } - else { - if (!(empty($data[$i]['cvx_text']))) { - $data[$i][xl('Vaccine')] = htmlspecialchars( xl($data[$i]['cvx_text']), ENT_NOQUOTES); - } - else { - $data[$i][xl('Vaccine')] = generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $data[$i][xl('Vaccine')]); - } - } - unset( $data[$i]['cvx_text'] ); -} +function convertToDataArray($data_array) { + $current = 0; + while ($row = sqlFetchArray($data_array)) { + //admin date + $temp_date = new DateTime($row['administered_date']); + $data[$current][xl('Date') . "\n" . xl('Admin')] = $temp_date->format('Y-m-d H:i'); //->format('%Y-%m-%d %H:%i'); + //Vaccine + // Figure out which name to use (ie. from cvx list or from the custom list) + if ($GLOBALS['use_custom_immun_list']) { + $vaccine_display = generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']); + } + else { + if (!empty($row['code_text_short'])) { + $vaccine_display = htmlspecialchars( xl($row['code_text_short']), ENT_NOQUOTES); + } + else { + $vaccine_display = generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']); + } + } + $data[$current][xl('Vaccine')] = $vaccine_display; + + //Amount + if ($row['amount_administered'] > 0) { + $data[$current][xl('Amount') . "\n" . xl('Admin')] = $row['amount_administered'] . " " . + generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'), $row['amount_administered_unit']); + } + else { + $data[$current][xl('Amount') . "\n" . xl('Admin')] = ""; + } + + //expiration date + $temp_date = new DateTime($row['expiration_date']); + $data[$current][xl('Expiration') . "\n" . xl('Date')] = $temp_date->format('Y-m-d'); + + //Manufacturer + $data[$current][xl('Manufacturer')] = $row['manufacturer']; + + //Lot Number + $data[$current][xl('Lot') . "\n" . xl('Number')] = $row['lot_number']; -$title = xl('Shot Record as of:','','',' ') . date('m/d/Y h:i:s a'); + //Admin By + $data[$current][xl('Admin') . "\n" . xl('By')] = $row['administered_by']; + + //education date + $temp_date = new DateTime($row['education_date']); + $data[$current][xl('Patient') . "\n" . xl('Education') . "\n" . xl('Date')] = $temp_date->format('Y-m-d'); + //Route + $data[$current][xl('Route')] = generate_display_field(array('data_type'=>'1','list_id'=>'drug_route'), $row['route']); + + //Admin Site + $data[$current][xl('Admin') . "\n" . xl('Site')] = generate_display_field(array('data_type'=>'1','list_id'=>'proc_body_site'), $row['administration_site']); + + //Comments + $data[$current][xl('Comments')] = $row['note']; + $current ++; + } + return $data; +} + +function printPDF($res, $res2, $data) { + require_once ($GLOBALS['fileroot'] . "/library/classes/class.ezpdf.php"); + + $pdf =& new Cezpdf("LETTER"); + $pdf->ezSetMargins(72,30,50,30); + $pdf->selectFont($GLOBALS['fileroot'] . "/library/fonts/Helvetica.afm"); + + $opts = array('justification' => "center"); + $pdf->ezText($res['facility_address'] ,"",$opts); + + $pdf->ezText("\n" . $res2['patient_name'] . "\n" . xl('Date of Birth') . ": " . $res2['patient_DOB'] . "\n" . $res2['patient_address']); + $pdf->ezText("\n"); + + $opts = array('maxWidth' => 550, 'fontSize' => 8); + + $pdf->ezTable($data, "", $title, $opts); + $pdf->ezText("\n\n\n\n" . xl('Signature') . ":________________________________","",array('justification' => 'right')); + $pdf->ezStream(); +} -if ($_GET['output'] == "html") { //print html css +function printHTML($res, $res2, $data) { +//print html css //convert end of line characters to html (escape for html output first) $patterns = array ('/\n/'); @@ -82,7 +134,7 @@ if ($_GET['output'] == "html") { //print html css $res2['patient_address'] = preg_replace($patterns, $replace, $res2['patient_address']); //deal with bug (last array index is empty) - array_pop($data); + //array_pop($data); ?> @@ -175,6 +227,7 @@ if ($_GET['output'] == "html") { //print html css //display header echo "\n"; foreach ($data[0] as $key => $value) { + //convert end of line characters to space $patterns = array ('/\n/'); $replace = array (' '); @@ -204,7 +257,6 @@ if ($_GET['output'] == "html") { //print html css echo ($value == "") ? " " : htmlspecialchars($value, ENT_NOQUOTES); echo ""; } - echo "\n"; } else { //done displaying shot data, so leave loop @@ -235,31 +287,8 @@ if ($_GET['output'] == "html") { //print html css - ezSetMargins(72,30,50,30); -$pdf->selectFont($GLOBALS['fileroot'] . "/library/fonts/Helvetica.afm"); - -$opts = array('justification' => "center"); -$pdf->ezText($res['facility_address'] ,"",$opts); - -$pdf->ezText("\n" . $res2['patient_name'] . "\n" . xl('Date of Birth') . ": " . $res2['patient_DOB'] . "\n" . $res2['patient_address']); -$pdf->ezText("\n"); - -$opts = array('maxWidth' => 504, 'fontSize' => 8); - -$pdf->ezTable($data, "", $title, $opts); - -$pdf->ezText("\n\n\n\n" . xl('Signature') . ":________________________________","",array('justification' => 'right')); - -$pdf->ezStream(); - -} # end pdf print ?> diff --git a/interface/patient_file/summary/stats.php b/interface/patient_file/summary/stats.php index ba0d0d6c6..7d89f8f0a 100644 --- a/interface/patient_file/summary/stats.php +++ b/interface/patient_file/summary/stats.php @@ -285,6 +285,7 @@ else { ?> " left join code_types ct on ct.ct_key = 'CVX' ". " left join codes c on c.code_type = ct.ct_id AND i1.cvx_code = c.code ". " where i1.patient_id = ? ". + " and i1.added_erroneously = 0". " order by i1.administered_date desc"; $result = sqlStatement($sql, array($pid) ); diff --git a/interface/reports/immunization_report.php b/interface/reports/immunization_report.php index 03f9a7a44..91ae89235 100644 --- a/interface/reports/immunization_report.php +++ b/interface/reports/immunization_report.php @@ -124,7 +124,10 @@ function format_ethnicity($ethnicity) { } $query .= "i.patient_id=p.pid and ". $query_codes . - "i.cvx_code = c.code "; + "i.cvx_code = c.code and "; + + //do not show immunization added erroneously + $query .= "i.added_erroneously = 0"; //echo "

DEBUG query: $query

\n"; // debugging diff --git a/library/clinical_rules.php b/library/clinical_rules.php index 145c54b35..c2448ce75 100644 --- a/library/clinical_rules.php +++ b/library/clinical_rules.php @@ -1519,19 +1519,25 @@ function exist_database_item($patient_id,$table,$column='',$data_comp,$data='',$ // get the appropriate sql comparison operator $compSql = convertCompSql($data_comp); + // custom issues per table can be placed here + $customSQL = ''; + if ($table == 'immunizations') { + $customSQL = " AND `added_erroneously` = '0' "; + } + // check for items if (empty($column)) { // simple search for any table entries $sql = sqlStatementCdrEngine("SELECT * " . "FROM `" . add_escape_custom($table) . "` " . - "WHERE `" . add_escape_custom($patient_id_label) . "`=?", array($patient_id) ); + "WHERE `" . add_escape_custom($patient_id_label) . "`=? " . $customSQL, array($patient_id) ); } else { // search for number of specific items $sql = sqlStatementCdrEngine("SELECT `" . add_escape_custom($column) . "` " . "FROM `" . add_escape_custom($table) . "` " . "WHERE `" . add_escape_custom($column) ."`" . $compSql . "? " . - "AND `" . add_escape_custom($patient_id_label) . "`=? " . + "AND `" . add_escape_custom($patient_id_label) . "`=? " . $customSQL . $dateSql, array($data,$patient_id) ); } diff --git a/library/immunization_helper.php b/library/immunization_helper.php new file mode 100644 index 000000000..bfdbde713 --- /dev/null +++ b/library/immunization_helper.php @@ -0,0 +1,59 @@ + + * + * LICENSE: This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see ;. + * + * @package OpenEMR + * @author Jan Jajalla + * @link http://www.open-emr.org + */ + +/** + * Return listing of immunizations for a patient. + * + * @param string $pid person id + * @param string $sortby sorting field ('vacc' sorts by name, otherwise will sort by date) + * @param boolean $showError indicator whether to retrieve the records that were added erroneously + * @return recordset listing of immunizations for a patient + */ +function getImmunizationList($pid,$sortby,$showError) { + $sql = "select i1.id ,i1.immunization_id, i1.cvx_code, i1.administered_date, c.code_text_short, c.code". + ",i1.manufacturer ,i1.lot_number ". + ",ifnull(concat(u.lname,', ',u.fname),'Other') as administered_by ". + ",i1.education_date ,i1.note ". + ",i1.amount_administered, i1.amount_administered_unit, i1.route, i1.administration_site, i1.added_erroneously". + " from immunizations i1 ". + " left join users u on i1.administered_by_id = u.id ". + " left join code_types ct on ct.ct_key = 'CVX' ". + " left join codes c on c.code_type = ct.ct_id AND i1.cvx_code = c.code ". + " where i1.patient_id = ? "; + if (!$showError) { + $sql .= "and i1.added_erroneously = 0 "; + } + + $sql .= " order by "; + + if ($sortby == "vacc") { + $sql .= " c.code_text_short, i1.immunization_id, i1.administered_date DESC"; + } + else { + $sql .= " administered_date desc"; + } + + $results = sqlStatement($sql,array($pid)); + return $results; +} + +?> diff --git a/library/sql-ccr.inc b/library/sql-ccr.inc index 20677bd6d..36698517d 100644 --- a/library/sql-ccr.inc +++ b/library/sql-ccr.inc @@ -149,7 +149,7 @@ function getImmunizationData() { FROM immunizations LEFT JOIN codes ON immunizations.cvx_code = codes.code LEFT JOIN code_types ON codes.code_type = code_types.ct_id - WHERE immunizations.patient_id = ? AND code_types.ct_key = 'CVX' + WHERE immunizations.patient_id = ? AND code_types.ct_key = 'CVX' AND immunizations.added_erroneously = 0 AND create_date BETWEEN ? AND ?" ; $result = sqlStatement($sql, array($pid,$start,$end) ); }else{ @@ -164,7 +164,7 @@ function getImmunizationData() { FROM immunizations LEFT JOIN codes ON immunizations.cvx_code = codes.code LEFT JOIN code_types ON codes.code_type = code_types.ct_id - WHERE immunizations.patient_id = ? AND code_types.ct_key = 'CVX'"; + WHERE immunizations.patient_id = ? AND immunizations.added_erroneously = 0 AND code_types.ct_key = 'CVX'"; $result = sqlStatement($sql, array($pid) ); } return $result; diff --git a/sql/4_1_1-to-4_1_2_upgrade.sql b/sql/4_1_1-to-4_1_2_upgrade.sql index 9a8866140..c06e8b5cf 100644 --- a/sql/4_1_1-to-4_1_2_upgrade.sql +++ b/sql/4_1_1-to-4_1_2_upgrade.sql @@ -406,3 +406,39 @@ INSERT INTO issue_types(`ordering`,`category`,`type`,`plural`,`singular`,`abbrev ALTER TABLE `issue_types` ADD COLUMN `active` tinyint(1) NOT NULL DEFAULT '1'; #EndIf +#IfNotColumnType immunizations administered_date datetime +ALTER TABLE `immunizations` + MODIFY COLUMN administered_date datetime DEFAULT NULL; +#EndIf + +#IfMissingColumn immunizations amount_administered +ALTER TABLE `immunizations` + ADD COLUMN `amount_administered` int(11) DEFAULT NULL; +#EndIf + + +#IfMissingColumn immunizations amount_administered_unit +ALTER TABLE `immunizations` + ADD COLUMN `amount_administered_unit` varchar(50) DEFAULT NULL; +#EndIf + +#IfMissingColumn immunizations expiration_date +ALTER TABLE `immunizations` + ADD COLUMN `expiration_date` date DEFAULT NULL; +#EndIf + +#IfMissingColumn immunizations route +ALTER TABLE `immunizations` + ADD COLUMN `route` varchar(100) DEFAULT NULL; +#EndIf + +#IfMissingColumn immunizations administration_site +ALTER TABLE `immunizations` + ADD COLUMN `administration_site` varchar(100) DEFAULT NULL; +#EndIf + +#IfMissingColumn immunizations added_erroneously +ALTER TABLE `immunizations` + ADD COLUMN `added_erroneously` tinyint(1) NOT NULL DEFAULT '0'; +#EndIf + diff --git a/sql/database.sql b/sql/database.sql index 4e3a0cab4..a27b78cae 100644 --- a/sql/database.sql +++ b/sql/database.sql @@ -2222,7 +2222,7 @@ DROP TABLE IF EXISTS `immunizations`; CREATE TABLE `immunizations` ( `id` bigint(20) NOT NULL auto_increment, `patient_id` int(11) default NULL, - `administered_date` date default NULL, + `administered_date` datetime default NULL, `immunization_id` int(11) default NULL, `cvx_code` int(11) default NULL, `manufacturer` varchar(100) default NULL, @@ -2236,6 +2236,12 @@ CREATE TABLE `immunizations` ( `update_date` timestamp NOT NULL, `created_by` bigint(20) default NULL, `updated_by` bigint(20) default NULL, + `amount_administered` int(11) DEFAULT NULL, + `amount_administered_unit` varchar(50) DEFAULT NULL, + `expiration_date` date DEFAULT NULL, + `route` varchar(100) DEFAULT NULL, + `administration_site` varchar(100) DEFAULT NULL, + `added_erroneously` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `patient_id` (`patient_id`) ) ENGINE=MyISAM AUTO_INCREMENT=1 ; diff --git a/version.php b/version.php index 0fb437665..e4cc9759f 100644 --- a/version.php +++ b/version.php @@ -17,7 +17,7 @@ $v_realpatch = '0'; // is a database change in the course of development. It is used // internally to determine when a database upgrade is needed. // -$v_database = 93; +$v_database = 94; // Access control version identifier, this is to be incremented whenever there // is a access control change in the course of development. It is used -- 2.11.4.GIT
- + - + - + - + - + @@ -665,7 +665,7 @@ foreach ($ar as $key => $val) { " from immunizations i1 ". " left join code_types ct on ct.ct_key = 'CVX' ". " left join codes c on c.code_type = ct.ct_id AND i1.cvx_code = c.code ". - " where i1.patient_id = '$pid' ". + " where i1.patient_id = '$pid' and i1.added_erroneously = 0 ". " order by administered_date desc"; $result = sqlStatement($sql); while ($row=sqlFetchArray($result)) { diff --git a/interface/patient_file/summary/immunizations.php b/interface/patient_file/summary/immunizations.php index f89a375f7..fcd600923 100644 --- a/interface/patient_file/summary/immunizations.php +++ b/interface/patient_file/summary/immunizations.php @@ -11,11 +11,15 @@ $fake_register_globals=false; include_once("../../globals.php"); include_once("$srcdir/sql.inc"); include_once("$srcdir/options.inc.php"); +include_once("$srcdir/immunization_helper.php"); if (isset($_GET['mode'])) { - - if ($_GET['mode'] == "add" ) { - + /* + * THIS IS A BUG. IF NEW IMMUN IS ADDED AND USER PRINTS PDF, + * WHEN BACK IS CLICKED, ANOTHER ITEM GETS ADDED + */ + + if ($_GET['mode'] == "add") { $sql = "REPLACE INTO immunizations set id = ?, administered_date = if(?,?,NULL), @@ -31,7 +35,12 @@ if (isset($_GET['mode'])) { patient_id = ?, created_by = ?, updated_by = ?, - create_date = now() "; + create_date = now(), + amount_administered = ?, + amount_administered_unit = ?, + expiration_date = if(?,?,NULL), + route = ?, + administration_site = ? "; $sqlBindArray = array( trim($_GET['id']), trim($_GET['administered_date']), trim($_GET['administered_date']), @@ -46,12 +55,19 @@ if (isset($_GET['mode'])) { trim($_GET['note']), $pid, $_SESSION['authId'], - $_SESSION['authId'] + $_SESSION['authId'], + trim($_GET['immuniz_amt_adminstrd']), + trim($_GET['form_drug_units']), + trim($_GET['immuniz_exp_date']), trim($_GET['immuniz_exp_date']), + trim($_GET['immuniz_route']), + trim($_GET['immuniz_admin_ste']) ); sqlStatement($sql,$sqlBindArray); - $administered_date=$education_date=date('Y-m-d'); + $administered_date=date('Y-m-d H:i'); + $education_date=date('Y-m-d'); $immunization_id=$cvx_code=$manufacturer=$lot_number=$administered_by_id=$note=$id=""; $administered_by=$vis_date=""; + } elseif ($_GET['mode'] == "delete" ) { // log the event @@ -59,13 +75,31 @@ if (isset($_GET['mode'])) { // delete the immunization $sql="DELETE FROM immunizations WHERE id =? LIMIT 1"; sqlStatement($sql, array($_GET['id'])); + } + elseif ($_GET['mode'] == "added_error" ) { + $sql = "UPDATE immunizations " . + "SET added_erroneously=? " . + "WHERE id=?"; + $sql_arg_array = array( + ($_GET['isError'] === 'true'), + $_GET['id'] + ); + sqlStatement($sql, $sql_arg_array); + } elseif ($_GET['mode'] == "edit" ) { $sql = "select * from immunizations where id = ?"; $result = sqlQuery($sql, array($_GET['id'])); - $administered_date = $result['administered_date']; - $immunization_id = $result['immunization_id']; - $cvx_code = $result['cvx_code']; + + $administered_date = new DateTime($result['administered_date']); + $administered_date = $administered_date->format('Y-m-d H:i'); + + $immuniz_amt_adminstrd = $result['amount_administered']; + $drugunitselecteditem = $result['amount_administered_unit']; + $immunization_id = $result['immunization_id']; + $immuniz_exp_date = $result['expiration_date']; + + $cvx_code = $result['cvx_code']; $code_text = ''; if ( !(empty($cvx_code)) ) { $query = "SELECT codes.code_text as `code_text`, codes.code as `code` " . @@ -78,11 +112,23 @@ if (isset($_GET['mode'])) { $manufacturer = $result['manufacturer']; $lot_number = $result['lot_number']; $administered_by_id = ($result['administered_by_id'] ? $result['administered_by_id'] : 0); - $administered_by = $result['administered_by']; + + $administered_by = ""; + if (!$result['administered_by'] && !$row['administered_by_id']) { + $stmt = "select concat(lname,', ',fname) as full_name ". + "from users where ". + "id=?"; + $user_result = sqlQuery($stmt, array($result['administered_by_id'])); + $administered_by = $user_result['full_name']; + } + $education_date = $result['education_date']; $vis_date = $result['vis_date']; + $immuniz_route = $result['route']; + $immuniz_admin_ste = $result['administration_site']; $note = $result['note']; - + $isAddedError = $result['added_erroneously']; + //set id for page $id = $_GET['id']; @@ -163,7 +209,7 @@ var mypcc = ' - + @@ -174,85 +220,93 @@ var mypcc = '">
+ " . xlt("Entered in Error") . ""; + } + ?> + + ?> + + () + - + + + + + + + + + - + [?]'> + + + + + + + + + /> + (?) + /> + + + + + + + + + + +
- - - 1,'field_id'=>'immunization_id','list_id'=>'immunizations','empty_title'=>'SKIP'), $immunization_id); - ?> -
- () - - ' />
- -
-
- - - - - ' + + + + +
' + title='' + onKeyUp='datekeyup(this,mypcc)' onBlur='dateblur(this,mypcc);' + /> + [?]'> +
+ + +
' title='' onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc);' /> - [?]'> - -
- - - - -
- - - - -
- - - @@ -271,13 +325,11 @@ var mypcc = ''; } ?> - -
- - ' @@ -287,14 +339,12 @@ var mypcc = '/pic/show_calendar.gif' align='absbottom' width='24' height='22' id='img_education_date' border='0' alt='[?]' style='cursor:pointer;' title='' - /> -
- (?) - ' @@ -304,16 +354,25 @@ var mypcc = '/pic/show_calendar.gif' align='absbottom' width='24' height='22' id='img_vis_date' border='0' alt='[?]' style='cursor:pointer;' title='' - /> -
+ +
+ +
- - - -
@@ -324,11 +383,10 @@ var mypcc = '"> - -
- +
@@ -346,37 +404,35 @@ var mypcc = ' +
  
" . $vaccine_display . "" . htmlspecialchars( $row["administered_date"], ENT_NOQUOTES) . "" . htmlspecialchars( $row["manufacturer"], ENT_NOQUOTES) . "" . htmlspecialchars( $row["lot_number"], ENT_NOQUOTES) . "" . htmlspecialchars( $row["administered_by"], ENT_NOQUOTES) . "" . htmlspecialchars( $row["education_date"], ENT_NOQUOTES) . "" . htmlspecialchars( $row["note"], ENT_NOQUOTES) . "" . $del_tag_open . $vaccine_display . $del_tag_close . "" . $del_tag_open . htmlspecialchars( $administered_date_summary, ENT_NOQUOTES) . $del_tag_close . "" . $del_tag_open . htmlspecialchars( $row["amount_administered"] . " " . generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'), $row['amount_administered_unit']) , ENT_NOQUOTES) . $del_tag_close . " " . $del_tag_open . htmlspecialchars( $row["manufacturer"], ENT_NOQUOTES) . $del_tag_close . "" . $del_tag_open . htmlspecialchars( $row["lot_number"], ENT_NOQUOTES) . $del_tag_close . "" . $del_tag_open . htmlspecialchars( $row["administered_by"], ENT_NOQUOTES) . $del_tag_close . "" . $del_tag_open . htmlspecialchars( $row["education_date"], ENT_NOQUOTES) . $del_tag_close . "" . $del_tag_open . generate_display_field(array('data_type'=>'1','list_id'=>'drug_route'), $row['route']) . $del_tag_close . "" . $del_tag_open . generate_display_field(array('data_type'=>'1','list_id'=>'proc_body_site'), $row['administration_site']) . $del_tag_close . "" . $del_tag_open . htmlspecialchars( $row["note"], ENT_NOQUOTES) . $del_tag_close . "