Skip to content

Commit

Permalink
Code for Immunizations standarization/reporting:
Browse files Browse the repository at this point in the history
 -Immunizations now use the CVX codes which
  have been imported into the codes table.
 -Also supports previous custom immunization
  list in list_options.
    -If a previous immunization does not have
     a cvx identifier, then it will use the
     previous identifier from lists_options.
    -Can also force to only use the custom list
     in lists_options in Administration->Globals->
     Features->Use Custom Immunization List
    -Can also map the previous custom immunization
     list items to CVX codes in the
     Administration->Lists GUI.

 Primary author of this code is rammohan <[email protected]>.
 Significant modifications also contributed by bradymiller.
  • Loading branch information
rreddy70 authored and bradymiller committed Jun 9, 2011
1 parent ef64a8d commit 305b22d
Show file tree
Hide file tree
Showing 13 changed files with 963 additions and 15 deletions.
Binary file added Documentation/Complete_Vaccine_Listing.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions interface/main/left_nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,7 @@ function selpopup(selobj) {
<?php if (acl_check('patients', 'med') && !$GLOBALS['disable_prescriptions']) genMiscLink('RTop','rep','0',xl('Rx'),'reports/prescriptions_report.php'); ?>
<?php if (acl_check('patients', 'med')) genMiscLink('RTop','rep','0',xl('Clinical'),'reports/clinical_reports.php'); ?>
<?php genMiscLink('RTop','rep','0',xl('Referrals'),'reports/referrals_report.php'); ?>
<?php genMiscLink('RTop','rep','0',xl('Immunization Registry'),'reports/immunization_report.php'); ?>
</ul>
</li>
<li><a class="collapsed_lv2"><span><?php xl('Clinic','e') ?></span></a>
Expand Down
125 changes: 119 additions & 6 deletions interface/patient_file/summary/immunizations.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
if (isset($_GET['mode'])) {

if ($_GET['mode'] == "add" ) {

$sql = "REPLACE INTO immunizations set
id = ?,
administered_date = if(?,?,NULL),
immunization_id = ?,
cvx_code = ?,
manufacturer = ?,
lot_number = ?,
administered_by_id = if(?,?,NULL),
Expand All @@ -34,6 +36,7 @@
trim($_GET['id']),
trim($_GET['administered_date']), trim($_GET['administered_date']),
trim($_GET['form_immunization_id']),
trim($_GET['cvx_code']),
trim($_GET['manufacturer']),
trim($_GET['lot_number']),
trim($_GET['administered_by_id']), trim($_GET['administered_by_id']),
Expand All @@ -47,7 +50,7 @@
);
sqlStatement($sql,$sqlBindArray);
$administered_date=$education_date=date('Y-m-d');
$immunization_id=$manufacturer=$lot_number=$administered_by_id=$note=$id="";
$immunization_id=$cvx_code=$manufacturer=$lot_number=$administered_by_id=$note=$id="";
$administered_by=$vis_date="";
}
elseif ($_GET['mode'] == "delete" ) {
Expand All @@ -63,6 +66,16 @@
while ($row = sqlFetchArray($results)) {
$administered_date = $row['administered_date'];
$immunization_id = $row['immunization_id'];
$cvx_code = $row['cvx_code'];
$code_text = '';
if ( !(empty($cvx_code)) ) {
$query = "SELECT codes.code_text as `code_text`, codes.code as `code` " .
"FROM codes " .
"LEFT JOIN code_types on codes.code_type = code_types.ct_id " .
"WHERE code_types.ct_key = 'CVX' AND codes.code = ?";
$row = sqlQuery($query, array($cvx_code));
$code_text = $row['code_text'];
}
$manufacturer = $row['manufacturer'];
$lot_number = $row['lot_number'];
$administered_by_id = ($row['administered_by_id'] ? $row['administered_by_id'] : 0);
Expand All @@ -71,9 +84,31 @@
$vis_date = $row['vis_date'];
$note = $row['note'];
}

//set id for page
$id = $_GET['id'];

}
}

// Decide whether using the CVX list or the custom list in list_options
if ($GLOBALS['use_custom_immun_list']) {
// user forces the use of the custom list
$useCVX = false;
}
else {
if ($_GET['mode'] == "edit") {
//depends on if a cvx code is enterer already
if (empty($cvx_code)) {
$useCVX = false;
}
else {
$useCVX = true;
}
}
else { // $_GET['mode'] == "add"
$useCVX = true;
}
}

// set the default sort method for the list of past immunizations
Expand All @@ -88,6 +123,7 @@
$row = sqlQuery($stmt, array($_SESSION['authId']));
$administered_by = $row['full_name'];
}

?>
<html>
<head>
Expand All @@ -96,6 +132,8 @@
<!-- supporting javascript code -->
<script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script>
<script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js"></script>
<script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>


<!-- page styles -->
<link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
Expand Down Expand Up @@ -139,6 +177,7 @@
<br>
<table border=0 cellpadding=1 cellspacing=1>

<?php if (!($useCVX)) { ?>
<tr>
<td align="right">
<span class=text>
Expand All @@ -148,10 +187,29 @@
<td>
<?php
// Modified 7/2009 by BM to incorporate the immunization items into the list_options listings
generate_form_field(array('data_type'=>1,'field_id'=>'immunization_id','list_id'=>'immunizations','empty_title'=>'SKIP'), $immunization_id);
generate_form_field(array('data_type'=>1,'field_id'=>'immunization_id','list_id'=>'immunizations','empty_title'=>'SKIP'), $immunization_id);
?>
</td>
</tr>
<?php } else { ?>
<tr>
<td align="right" valign="top" style="padding-top:4px;">
<span class=text>
<?php echo htmlspecialchars( xl('Immunization'), ENT_NOQUOTES); ?> (<?php echo htmlspecialchars( xl('CVX Code'), ENT_NOQUOTES); ?>)
</span>
</td>
<td>
<input type='text' size='10' name='cvx_code' id='cvx_code'
value='<?php echo htmlspecialchars($cvx_code,ENT_QUOTES); ?>' onclick='sel_cvxcode(this)'
title='<?php echo htmlspecialchars( xl('Click to select or change CVX code'), ENT_QUOTES); ?>'
/>
<div id='cvx_description' style='display:inline; float:right; padding:3px; margin-left:3px; width:400px'>
<?php echo htmlspecialchars( xl( $code_text ), ENT_QUOTES); ?>
</div>
</td>
</tr>
<?php } ?>

<tr>
<td align="right">
<span class=text>
Expand Down Expand Up @@ -299,15 +357,21 @@
</tr>

<?php
$sql = "select i1.id ,i1.immunization_id ,i1.administered_date ".
$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 ".
" from immunizations i1 ".
" left join users u on i1.administered_by_id = u.id ".
" left join codes c on i1.cvx_code = c.code ".
" left join code_types ct on c.code_type = ct.ct_id ".
" where patient_id = ? ".
" AND ( i1.cvx_code = '0' ) OR ".
" ( i1.cvx_code != '0' AND ct.ct_key = 'CVX') ".
" order by ";
if ($sortby == "vacc") { $sql .= " i1.immunization_id, i1.administered_date DESC"; }
if ($sortby == "vacc") {
$sql .= " c.code_text_short, i1.immunization_id, i1.administered_date DESC";
}
else { $sql .= " administered_date desc"; }

$result = sqlStatement($sql, array($pid) );
Expand All @@ -318,8 +382,22 @@
else {
echo "<tr class='immrow text' id='".htmlspecialchars( $row["id"], ENT_QUOTES)."'>";
}
// Modified 7/2009 by BM to utilize immunization items from the pertinent list in list_options
echo "<td>" . generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']) . "</td>";

// 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']);
}

}
echo "<td>" . $vaccine_display . "</td>";

echo "<td>" . htmlspecialchars( $row["administered_date"], ENT_NOQUOTES) . "</td>";
echo "<td>" . htmlspecialchars( $row["manufacturer"], ENT_NOQUOTES) . "</td>";
echo "<td>" . htmlspecialchars( $row["lot_number"], ENT_NOQUOTES) . "</td>";
Expand Down Expand Up @@ -356,6 +434,14 @@
$(".immrow").mouseout(function() { $(this).toggleClass("highlight"); });

$("#administered_by_id").change(function() { $("#administered_by").val($("#administered_by_id :selected").text()); });

$("#form_immunization_id").change( function() {
if ( $(this).val() != "" ) {
$("#cvx_code").val( "" );
$("#cvx_description").text( "" );
$("#cvx_code").change();
}
});
});

var PrintForm = function(typ) {
Expand Down Expand Up @@ -386,6 +472,33 @@
}
}

//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) {
var f = document.forms[0][current_sel_name];
var s = f.value;

if (code) {
s = code;
}
else {
s = '';
}

f.value = s;
$("#cvx_description").text( codedesc );
$("#form_immunization_id").attr( "value", "" );
$("#form_immunization_id").change();
}


// This invokes the find-code popup.
function sel_cvxcode(e) {
current_sel_name = e.name;
dlgopen('../encounter/find_code_popup.php?codetype=CVX', '_blank', 500, 400);
}


</script>

</html>
23 changes: 20 additions & 3 deletions interface/patient_file/summary/shot_record.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
//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') . "' ".
Expand All @@ -37,7 +38,11 @@
" 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 ".
" where p.pid = ?";
" left join codes c on i1.cvx_code = c.code ".
" left join code_types ct on c.code_type = ct.ct_id ".
" where p.pid = ? ".
" AND ( i1.cvx_code = '0' ) OR ".
" ( i1.cvx_code != '0' AND ct.ct_key = 'CVX' ) ";

// sort the results, as they are on the user's screen
$sqlstmt .= " order by ";
Expand All @@ -48,11 +53,23 @@

while ($data[] = sqlFetchArray($res3)) {}

// added 7-2009 by BM to support immunization list in list_options
for ($i=0;$i<count($data);$i++) {
$data[$i][xl('Vaccine')] = generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $data[$i][xl('Vaccine')]);
// Figure out which name to use (ie. from cvx list or from the custom list)
if ($GLOBALS['use_custom_immun_list']) {
$data[$i][xl('Vaccine')] = generate_display_field(array('data_type'=>'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'] );
}


$title = xl('Shot Record as of:','','',' ') . date('m/d/Y h:i:s a');


Expand Down
29 changes: 24 additions & 5 deletions interface/patient_file/summary/stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,18 @@ function load_location( location ) {
<?php } ?>

<?php
$sql = "select i1.id as id, i1.immunization_id as immunization_id,".
$sql = "select i1.id as id, i1.immunization_id as immunization_id, i1.cvx_code as cvx_code, c.code_text_short as cvx_text, ".
" if (i1.administered_date, concat(i1.administered_date,' - '), substring(i1.note,1,20)) as immunization_data ".
//" from immunizations i1, code_types ct ".
" from immunizations i1 ".
" left join codes c on i1.cvx_code = c.code ".
" left join code_types ct on c.code_type = ct.ct_id ".
" where i1.patient_id = ? ".
" order by i1.immunization_id, i1.administered_date desc";
" AND ( cvx_code = '0' ) OR ".
" ( cvx_code != '0' AND ct.ct_key = 'CVX') ";
//" ( cvx_code != '0' AND ct.ct_key = 'CVX' AND c.code_type = ct.ct_id) ";
//" ( cvx_code != '0' AND c.code_type = '4') ";
" order by i1.administered_date desc";

$result = sqlStatement($sql, array($pid) );

Expand All @@ -216,9 +223,21 @@ function load_location( location ) {
echo "&nbsp;&nbsp;";
echo "<a class='link'";
echo "' href='javascript:;' onclick='javascript:load_location(\"immunizations.php?mode=edit&id=".htmlspecialchars($row['id'],ENT_QUOTES) . "\")'>" .
htmlspecialchars($row{'immunization_data'},ENT_NOQUOTES) .
generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']) .
"</a><br>\n";
htmlspecialchars($row{'immunization_data'},ENT_NOQUOTES);

// Figure out which name to use (ie. from cvx list or from the custom list)
if ($GLOBALS['use_custom_immun_list']) {
echo generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
}
else {
if (!(empty($row['cvx_text']))) {
echo htmlspecialchars( xl($row['cvx_text']), ENT_NOQUOTES );
}
else {
echo generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
}
}
echo "</a><br>\n";
}
?>

Expand Down
Loading

0 comments on commit 305b22d

Please sign in to comment.