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 getMeasureNumber($row) {
27 if (!empty($row['cqm_pqri_code']) ||
!empty($row['cqm_nqf_code']) ) {
28 if (!empty($row['cqm_pqri_code'])) {
29 return $row['cqm_pqri_code'];
31 if (!empty($row['cqm_nqf_code'])) {
32 return $row['cqm_nqf_code'];
42 // Collect parameters (set defaults if empty)
43 $target_date = (isset($_GET['target_date'])) ?
trim($_GET['target_date']) : date('Y-m-d H:i:s');
44 $nested = (isset($_GET['nested'])) ?
trim($_GET['nested']) : 'false';
47 // Add the XML parent tag.
48 $xml->open_submission();
50 // Add the file audit data
51 $xml->add_file_audit_data();
53 // Add the registry entries
54 if ( $nested == 'false') {
55 $xml->add_registry('A');
58 $xml->add_registry('E');
62 // Add the measure groups.
63 if ( $nested == 'false' ) {
64 $dataSheet = test_rules_clinic('collate_outer','cqm',$target_date,'report','','','');
67 $dataSheet = test_rules_clinic('collate_inner','cqm',$target_date,'report','','cqm','plans');
70 $firstProviderFlag = TRUE;
71 $firstPlanFlag = TRUE;
72 $existProvider = FALSE;
74 if ( $nested == 'false' ){
75 $xml->open_measure_group('X');
78 foreach ($dataSheet as $row) {
80 if (isset($row['is_main']) ||
isset($row['is_sub'])) {
81 if (isset($row['is_main'])) {
83 $pqri_measures = array();
84 $pqri_measures['pqri-measure-number'] = getMeasureNumber($row);
85 $pqri_measures['eligible-instances'] = $row['pass_filter'];
86 $pqri_measures['meets-performance-instances'] = $row['pass_target'];
87 $pqri_measures['performance-exclusion-instances'] = $row['excluded'];
88 $performance_not_met_instances = (int)$row['pass_filter'] - (int)$row['pass_target'] - (int)$row['excluded'];
89 $pqri_measures['performance-not-met-instances'] = (string)$performance-not
-met
-instances
;
90 $pqri_measures['performance-rate'] = $row['percentage'];
91 $pqri_measures['reporting-rate'] = '';
92 $xml->add_pqri_measures($pqri_measures);
94 else { // $row[0] == "sub"
98 else if (isset($row['is_provider'])) {
99 if ( $firstProviderFlag == FALSE ){
100 $xml->close_provider();
103 $physician_ids = array();
104 if (!empty($row['npi']) ||
!empty($row['federaltaxid'])) {
105 if (!empty($row['npi'])) {
106 $physician_ids['npi'] = $row['npi'];
108 if (!empty($row['federaltaxid'])) {
109 $physician_ids['tin'] = $row['federaltaxid'];
112 $physician_ids['encounter-from-date'] = '01-01-' . date('Y', strtotime($target_date ));
113 $physician_ids['encounter-to-date'] = '12-31-' . date('Y', strtotime($target_date ));
115 $xml->open_provider($physician_ids);
116 $firstProviderFlag = FALSE;
117 $existProvider = TRUE;
119 else { // isset($row['is_plan'])
121 if ( $firstPlanFlag == FALSE ) {
122 if ( $firstProviderFlag == FALSE ) {
123 $xml->close_provider();
125 if ( $nested == 'true' ) {
126 $xml->close_measure_group();
130 if ( $nested == 'true' ){
131 $xml->open_measure_group($row['cqm_measure_group']);
133 $firstPlanFlag = FALSE;
134 $firstProviderFlag = TRUE; // Reset the provider flag
139 if ( $existProvider == TRUE ){
140 $xml->close_provider();
141 $xml->close_measure_group();
144 $xml->close_submission();
150 <?
html_header_show();?
>
151 <link rel
=stylesheet href
="<?echo $css_header;?>" type
="text/css">
152 <title
><?php
echo htmlspecialchars( xl('Export PQRI Report'), ENT_NOQUOTES
); ?
></title
>
156 <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
>
161 <textarea rows
='50' cols
='500' style
='width:95%' readonly
>
162 <?
echo $xml->getXml(); ?
>
165 <p
><input type
='button' value
='<?php echo htmlspecialchars( xl('OK
'), ENT_QUOTES); ?>' onclick
='window.close()' /></p
>