2 // Copyright (C) 2011 Ensoftek
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // This program exports report to PQRI 2009 XML format.
11 //SANITIZE ALL ESCAPES
12 $sanitize_all_escapes=true;
15 //STOP FAKE REGISTER GLOBALS
16 $fake_register_globals=false;
20 require_once("../interface/globals.php");
21 require_once("../library/patient.inc");
22 require_once "../library/options.inc.php";
23 require_once("../library/clinical_rules.php");
24 require_once("../library/classes/PQRIXml.class.php");
26 function getLabelNumber($label) {
28 if ( strlen($label) == 0) {
32 $tokens = explode(" ", $label);
34 $num_tokens = sizeof($tokens);
35 if ( $tokens[$num_tokens-1] != null ) {
36 if ( is_numeric($tokens[$num_tokens-1])) {
37 return $tokens[$num_tokens-1];
45 function getMeasureNumber($row) {
46 if (!empty($row['cqm_pqri_code']) ||
!empty($row['cqm_nqf_code']) ) {
47 if (!empty($row['cqm_pqri_code'])) {
48 return $row['cqm_pqri_code'];
50 if (!empty($row['cqm_nqf_code'])) {
51 return $row['cqm_nqf_code'];
61 // Collect parameters (set defaults if empty)
62 $target_date = (isset($_GET['target_date'])) ?
trim($_GET['target_date']) : date('Y-m-d H:i:s');
63 $nested = (isset($_GET['nested'])) ?
trim($_GET['nested']) : 'false';
66 // Add the XML parent tag.
67 $xml->open_submission();
69 // Add the file audit data
70 $xml->add_file_audit_data();
72 // Add the registry entries
73 if ( $nested == 'false') {
74 $xml->add_registry('A');
77 $xml->add_registry('E');
81 // Add the measure groups.
82 if ( $nested == 'false' ) {
83 $dataSheet = test_rules_clinic('collate_outer','cqm',$target_date,'report','','','');
86 $dataSheet = test_rules_clinic('collate_inner','cqm',$target_date,'report','','cqm','plans');
89 $firstProviderFlag = TRUE;
90 $firstPlanFlag = TRUE;
91 $existProvider = FALSE;
93 if ( $nested == 'false' ){
94 $xml->open_measure_group('X');
97 foreach ($dataSheet as $row) {
99 if (isset($row['is_main']) ||
isset($row['is_sub'])) {
100 if (isset($row['is_main'])) {
102 $pqri_measures = array();
103 $pqri_measures['pqri-measure-number'] = getMeasureNumber($row);
104 $pqri_measures['patient-population'] = getLabelNumber($row['population_label']);
105 $pqri_measures['numerator'] = getLabelNumber($row['numerator_label']);
106 $pqri_measures['eligible-instances'] = $row['pass_filter'];
107 $pqri_measures['meets-performance-instances'] = $row['pass_target'];
108 $pqri_measures['performance-exclusion-instances'] = $row['excluded'];
109 $performance_not_met_instances = (int)$row['pass_filter'] - (int)$row['pass_target'] - (int)$row['excluded'];
110 $pqri_measures['performance-not-met-instances'] = (string)$performance_not_met_instances;
111 $pqri_measures['performance-rate'] = $row['percentage'];
112 $pqri_measures['reporting-rate'] = (($row['pass_filter']-$row['excluded'])/$row['pass_filter'])*100;
113 $pqri_measures['reporting-rate']=$pqri_measures['reporting-rate'].'%';
114 $xml->add_pqri_measures($pqri_measures);
116 else { // $row[0] == "sub"
120 else if (isset($row['is_provider'])) {
121 if ( $firstProviderFlag == FALSE ){
122 $xml->close_provider();
125 $physician_ids = array();
126 if (!empty($row['npi']) ||
!empty($row['federaltaxid'])) {
127 if (!empty($row['npi'])) {
128 $physician_ids['npi'] = $row['npi'];
130 if (!empty($row['federaltaxid'])) {
131 $physician_ids['tin'] = $row['federaltaxid'];
134 $physician_ids['encounter-from-date'] = '01-01-' . date('Y', strtotime($target_date ));
135 $physician_ids['encounter-to-date'] = '12-31-' . date('Y', strtotime($target_date ));
137 $xml->open_provider($physician_ids);
138 $firstProviderFlag = FALSE;
139 $existProvider = TRUE;
141 else { // isset($row['is_plan'])
143 if ( $firstPlanFlag == FALSE ) {
144 if ( $firstProviderFlag == FALSE ) {
145 $xml->close_provider();
147 if ( $nested == 'true' ) {
148 $xml->close_measure_group();
152 if ( $nested == 'true' ){
153 $xml->open_measure_group($row['cqm_measure_group']);
155 $firstPlanFlag = FALSE;
156 $firstProviderFlag = TRUE; // Reset the provider flag
161 if ( $existProvider == TRUE ){
162 $xml->close_provider();
163 $xml->close_measure_group();
166 $xml->close_submission();
172 <?php
html_header_show();?
>
173 <link rel
=stylesheet href
="<?php echo $css_header;?>" type
="text/css">
174 <title
><?php
echo htmlspecialchars( xl('Export PQRI Report'), ENT_NOQUOTES
); ?
></title
>
178 <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
>
183 <textarea rows
='50' cols
='500' style
='width:95%' readonly
>
184 <?php
echo $xml->getXml(); ?
>
187 <p
><input type
='button' value
='<?php echo htmlspecialchars( xl('OK
'), ENT_QUOTES); ?>' onclick
='window.close()' /></p
>