Skip to content

Commit

Permalink
CDR Module : Added feature for PQRI XML reports.
Browse files Browse the repository at this point in the history
1) "Generate pqri report" button at "Reports->Clinic->Quality Measures"
   (note need to hit the Submit button to see it)
2) Added "Administration->Globals->PQRI Registry" tab to hold the registry
   name and id number.
  • Loading branch information
rreddy70 authored and bradymiller committed Feb 19, 2011
1 parent 816cf8b commit b9cdbd7
Show file tree
Hide file tree
Showing 5 changed files with 373 additions and 1 deletion.
168 changes: 168 additions & 0 deletions custom/export_registry_xml.php
@@ -0,0 +1,168 @@
<?
// Copyright (C) 2011 Ensoftek
//
// 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 2
// of the License, or (at your option) any later version.

// This program exports report to PQRI 2009 XML format.

//SANITIZE ALL ESCAPES
$sanitize_all_escapes=true;
//

//STOP FAKE REGISTER GLOBALS
$fake_register_globals=false;
//


include_once("../interface/globals.php");
include_once("../library/patient.inc");
require_once "../library/options.inc.php";
require_once("../library/clinical_rules.php");
require_once("../library/classes/PQRIXml.class.php");

function getMeasureNumber($row) {
if (!empty($row['cqm_pqri_code']) || !empty($row['cqm_nqf_code']) ) {
if (!empty($row['cqm_pqri_code'])) {
return $row['cqm_pqri_code'];
}
if (!empty($row['cqm_nqf_code'])) {
return $row['cqm_nqf_code'];
}
}
else
{
return "";
}
}


// Collect parameters (set defaults if empty)
$target_date = (isset($_GET['target_date'])) ? trim($_GET['target_date']) : date('Y-m-d H:i:s');
$nested = (isset($_GET['nested'])) ? trim($_GET['nested']) : 'false';
$xml = new PQRIXml();

// Add the XML parent tag.
$xml->open_submission();

// Add the file audit data
$xml->add_file_audit_data();

// Add the registry entries
if ( $nested == 'false') {
$xml->add_registry('A');
}
else {
$xml->add_registry('E');
}


// Add the measure groups.
if ( $nested == 'false' ) {
$dataSheet = test_rules_clinic('collate_outer','cqm',$target_date,'report','','','');
}
else {
$dataSheet = test_rules_clinic('collate_inner','cqm',$target_date,'report','','cqm','plans');
}

$firstProviderFlag = TRUE;
$firstPlanFlag = TRUE;
$existProvider = FALSE;

if ( $nested == 'false' ){
$xml->open_measure_group('X');
}

foreach ($dataSheet as $row) {
//print_r($row);
if (isset($row['is_main']) || isset($row['is_sub'])) {
if (isset($row['is_main'])) {
// Add PQRI measures
$pqri_measures = array();
$pqri_measures['pqri-measure-number'] = getMeasureNumber($row);
$pqri_measures['eligible-instances'] = $row['pass_filter'];
$pqri_measures['meets-performance-instances'] = $row['pass_target'];
$pqri_measures['performance-exclusion-instances'] = $row['excluded'];
$performance_not_met_instances = (int)$row['pass_filter'] - (int)$row['pass_target'] - (int)$row['excluded'];
$pqri_measures['performance-not-met-instances'] = (string)$performance-not-met-instances;
$pqri_measures['performance-rate'] = $row['percentage'];
$pqri_measures['reporting-rate'] = '';
$xml->add_pqri_measures($pqri_measures);
}
else { // $row[0] == "sub"

}
}
else if (isset($row['is_provider'])) {
if ( $firstProviderFlag == FALSE ){
$xml->close_provider();
}
// Add the provider
$physician_ids = array();
if (!empty($row['npi']) || !empty($row['federaltaxid'])) {
if (!empty($row['npi'])) {
$physician_ids['npi'] = $row['npi'];
}
if (!empty($row['federaltaxid'])) {
$physician_ids['tin'] = $row['federaltaxid'];
}
}

$xml->open_provider($physician_ids);
$firstProviderFlag = FALSE;
$existProvider = TRUE;
}
else { // isset($row['is_plan'])

if ( $firstPlanFlag == FALSE ) {
if ( $firstProviderFlag == FALSE ) {
$xml->close_provider();
}
if ( $nested == 'true' ) {
$xml->close_measure_group();
}
}

if ( $nested == 'true' ){
$xml->open_measure_group($row['cqm_measure_group']);
}
$firstPlanFlag = FALSE;
$firstProviderFlag = TRUE; // Reset the provider flag
}

}

if ( $existProvider == TRUE ){
$xml->close_provider();
$xml->close_measure_group();
}

$xml->close_submission();

?>

<html>
<head>
<? html_header_show();?>
<link rel=stylesheet href="<?echo $css_header;?>" type="text/css">
<title><?php echo htmlspecialchars( xl('Export PQRI Report'), ENT_NOQUOTES); ?></title>
</head>
<body>

<p><?php echo htmlspecialchars( xl('The exported data appears in the text area below. You can copy and paste this into an email or to any other desired destination.'), ENT_NOQUOTES); ?></p>

<center>
<form>

<textarea rows='50' cols='500' style='width:95%' readonly>
<? echo $xml->getXml(); ?>
</textarea>

<p><input type='button' value='<?php echo htmlspecialchars( xl('OK'), ENT_QUOTES); ?>' onclick='window.close()' /></p>
</form>
</center>

</body>
</html>
23 changes: 22 additions & 1 deletion interface/reports/cqm.php
Expand Up @@ -56,6 +56,18 @@ function refreshme() {
document.forms[0].submit();
}

function GenXml() {
top.restoreSession();

var sNested = 'true';
if ( theform.rule_filter.value == 'cqm' ) {
sNested = 'false';
}
var sLoc = '../../custom/export_registry_xml.php?&target_date=' + theform.target_date.value + '&nested=' + sNested;
dlgopen(sLoc, '_blank', 600, 500);
return false;
}

</script>

<style type="text/css">
Expand Down Expand Up @@ -201,8 +213,12 @@ function refreshme() {
<?php echo htmlspecialchars( xl('Submit'), ENT_NOQUOTES); ?>
</span>
</a>

<?php if ($_POST['form_refresh']) { ?>
<a href='#' class='css_button' onclick='return GenXml()'>
<span>
<?php echo htmlspecialchars( xl('Generate PQRI report'), ENT_NOQUOTES); ?>
</span>
</a>
<a href='#' class='css_button' onclick='window.print()'>
<span>
<?php echo htmlspecialchars( xl('Print'), ENT_NOQUOTES); ?>
Expand Down Expand Up @@ -350,6 +366,11 @@ function refreshme() {
<?php } ?>

<input type='hidden' name='form_refresh' id='form_refresh' value=''/>
<input type='hidden' name='provider' value='<?php echo htmlspecialchars($provider, ENT_QUOTES) ?>'/>
<input type='hidden' name='rule_filter' value='<?php echo htmlspecialchars($rule_filter, ENT_QUOTES) ?>'/>
<input type='hidden' name='target_date' value='<?php echo htmlspecialchars($target_date, ENT_QUOTES) ?>'/>
<input type='hidden' name='plan_filter' value='<?php echo htmlspecialchars($plan_filter, ENT_QUOTES) ?>'/>
<input type='hidden' name='organize_method' value='<?php echo htmlspecialchars($organize_method, ENT_QUOTES) ?>'/>

</form>

Expand Down
100 changes: 100 additions & 0 deletions library/classes/PQRIXml.class.php
@@ -0,0 +1,100 @@
<?php
// Copyright (C) 2011 Ensoftek
//
// 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 2
// of the License, or (at your option) any later version.

// This program implements the XML Writer to generate PQRI 2009 XML.

require_once("XmlWriterOemr.class.php");

class PQRIXml extends XmlWriterOemr {

function PQRIXml($indent = ' ') {
parent::XmlWriterOemr($indent);
}

function open_submission() {

$this->push('submission', array('type'=>'PQRI-REGISTRY', 'option'=>'payment',
'xmlns:xsi'=>'http://www.w3.org/2001/XMLSchema-instance', 'xsi:noNamespaceSchemaLocation'=>'Registry_Payment.xsd'));
}

function close_submission() {
$this->pop();
}


function add_file_audit_data() {

$res = sqlQuery("select * from users where username=?", array($_SESSION{"authUser"}) );


$this->push('file_audit_data');
$this->element('create-date', date("m-d-Y"));
$this->element('create-time', date("H:i"));
$this->element('create-by', $res{"fname"}.' '.$res{"lname"});
$this->element('version', '1.0');
$this->element('file-number', '1');
$this->element('number-of-files', '1');
$this->pop();
}

function add_registry($submission_method) {

$this->push('registry');
$this->element('registry-name', $GLOBALS['pqri_registry_name']);
$this->element('registry-id', $GLOBALS['pqri_registry_id']);
$this->element('submit-method', $submission_method);
$this->pop();
}

function add_measure_group_stats($arrStats) {
$this->push('measure-group-stat');

foreach ($arrStats as $key => $value)
{
$this->element($key, $value);
}

$this->pop();
}

function add_pqri_measures($arrStats) {
$this->push('pqri-measure');

foreach ($arrStats as $key => $value)
{
$this->element($key, $value);
}

$this->pop();
}


function open_provider($arrStats) {
$this->push('provider');

foreach ($arrStats as $key => $value)
{
$this->element($key, $value);
}

}

function close_provider() {
$this->pop();
}

function open_measure_group($id) {
$this->push('measure-group', array('ID'=>$id));
}

function close_measure_group() {
$this->pop();
}

}
?>
59 changes: 59 additions & 0 deletions library/classes/XmlWriterOemr.class.php
@@ -0,0 +1,59 @@
<?php
// Copyright (C) 2011 Ensoftek
//
// 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 2
// of the License, or (at your option) any later version.

// This program is the base class to implement XML writer.

class XmlWriterOemr {
var $xml;
var $indent;
var $stack = array();
function XmlWriterOemr($indent = ' ') {
$this->indent = $indent;
$this->xml = '<?xml version="1.0" encoding="utf-8"?>'."\n";
}
function _indent() {
for ($i = 0, $j = count($this->stack); $i < $j; $i++) {
$this->xml .= $this->indent;
}
}
function push($element, $attributes = array()) {
$this->_indent();
$this->xml .= '<'.$element;
foreach ($attributes as $key => $value) {
$this->xml .= ' '.htmlspecialchars($key).'="'.htmlspecialchars($value).'"';
}
$this->xml .= ">\n";
$this->stack[] = htmlspecialchars($element);
}
function element($element, $content, $attributes = array()) {
$this->_indent();
$this->xml .= '<'.$element;
foreach ($attributes as $key => $value) {
$this->xml .= ' '.htmlspecialchars($key).'="'.htmlspecialchars($value).'"';
}
$this->xml .= '>'.htmlspecialchars($content).'</'.htmlspecialchars($element).'>'."\n";
}
function emptyelement($element, $attributes = array()) {
$this->_indent();
$this->xml .= '<'.htmlspecialchars($element);
foreach ($attributes as $key => $value) {
$this->xml .= ' '.htmlspecialchars($key).'="'.htmlspecialchars($value).'"';
}
$this->xml .= " />\n";
}
function pop() {
$element = array_pop($this->stack);
$this->_indent();
$this->xml .= "</".htmlspecialchars($element).">"."\n";
}
function getXml() {
return $this->xml;
}
}

?>

0 comments on commit b9cdbd7

Please sign in to comment.